Author: sveinung
Date: Thu Mar 10 14:15:06 2016
New Revision: 32223

URL: http://svn.gna.org/viewcvs/freeciv?rev=32223&view=rev
Log:
clients: add a Wait button to the act sel dlgs.

Jacob wanted the usual unit focus keys like "W" to dismiss the popup
non-permanently. To do this while the action selection dialog has focus
would probably require a lot of client specific work. Approximate it by
adding a "Wait" button to the action selection dialog. Give it "W" as
mnemonic in clients with mnemonics support.

Note that some clients allows the player to shift focus from the dialog to
the actor unit. In those cases you can use "W" the way it was requested.

Requested by Jacob Nevins

See patch #3711

Modified:
    branches/S2_6/client/gui-gtk-2.0/action_dialog.c
    branches/S2_6/client/gui-gtk-3.0/action_dialog.c
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-sdl/action_dialog.c
    branches/S2_6/client/gui-sdl2/action_dialog.c

Modified: branches/S2_6/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/action_dialog.c?rev=32223&r1=32222&r2=32223&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/action_dialog.c    Thu Mar 10 14:15:06 2016
@@ -51,8 +51,9 @@
 /* Locations for non action enabler controlled buttons. */
 #define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_LOCATION BUTTON_MOVE + 1
-#define BUTTON_CANCEL BUTTON_MOVE + 2
-#define BUTTON_COUNT BUTTON_MOVE + 3
+#define BUTTON_WAIT BUTTON_MOVE + 2
+#define BUTTON_CANCEL BUTTON_MOVE + 3
+#define BUTTON_COUNT BUTTON_MOVE + 4
 
 #define BUTTON_NOT_THERE -1
 
@@ -934,6 +935,21 @@
   free(args);
 }
 
+/**************************************************************************
+  Delay selection of what action to take.
+**************************************************************************/
+static void act_sel_wait_callback(GtkWidget *w, gpointer data)
+{
+  struct action_data *args = (struct action_data *)data;
+
+  key_unit_wait();
+
+  /* the dialog was destroyed when key_unit_wait() resulted in
+   * action_selection_close() being called. */
+
+  free(args);
+}
+
 /****************************************************************
   Action selection dialog has been destroyed
 *****************************************************************/
@@ -1189,6 +1205,12 @@
                     (GCallback)act_sel_location_callback, data,
                     TRUE, NULL);
 
+  action_button_map[BUTTON_WAIT] =
+      choice_dialog_get_number_of_buttons(shl);
+  choice_dialog_add(shl, _("_Wait"),
+                    (GCallback)act_sel_wait_callback, data,
+                    TRUE, NULL);
+
   action_button_map[BUTTON_CANCEL] =
       choice_dialog_get_number_of_buttons(shl);
   choice_dialog_add(shl, GTK_STOCK_CANCEL,
@@ -1310,16 +1332,21 @@
     }
   } action_iterate_end;
 
+  /* DO NOT change the action_button_map[] for any button to reflect its
+   * new position. A button keeps its choice dialog internal name when its
+   * position changes. A button's id number is therefore based on when
+   * it was added, not on its current position. */
+
+  if (BUTTON_NOT_THERE != action_button_map[BUTTON_WAIT]) {
+    /* Move the wait button below the recently added button. */
+    choice_dialog_button_move_to_the_end(act_sel_dialog,
+        action_button_map[BUTTON_WAIT]);
+  }
+
   if (BUTTON_NOT_THERE != action_button_map[BUTTON_CANCEL]) {
     /* Move the cancel button below the recently added button. */
     choice_dialog_button_move_to_the_end(act_sel_dialog,
         action_button_map[BUTTON_CANCEL]);
-
-    /* DO NOT change action_button_map[BUTTON_CANCEL] or
-     * the action_button_map[] for any other button to reflect the new
-     * positions. A button keeps its choice dialog internal name when its
-     * position changes. A button's id number is therefore based on when
-     * it was added, not on its current position. */
   }
 
   choice_dialog_end(act_sel_dialog);

Modified: branches/S2_6/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/action_dialog.c?rev=32223&r1=32222&r2=32223&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/action_dialog.c    Thu Mar 10 14:15:06 2016
@@ -51,8 +51,9 @@
 /* Locations for non action enabler controlled buttons. */
 #define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_LOCATION BUTTON_MOVE + 1
-#define BUTTON_CANCEL BUTTON_MOVE + 2
-#define BUTTON_COUNT BUTTON_MOVE + 3
+#define BUTTON_WAIT BUTTON_MOVE + 2
+#define BUTTON_CANCEL BUTTON_MOVE + 3
+#define BUTTON_COUNT BUTTON_MOVE + 4
 
 #define BUTTON_NOT_THERE -1
 
@@ -944,6 +945,21 @@
   free(args);
 }
 
+/**************************************************************************
+  Delay selection of what action to take.
+**************************************************************************/
+static void act_sel_wait_callback(GtkWidget *w, gpointer data)
+{
+  struct action_data *args = (struct action_data *)data;
+
+  key_unit_wait();
+
+  /* the dialog was destroyed when key_unit_wait() resulted in
+   * action_selection_close() being called. */
+
+  free(args);
+}
+
 /****************************************************************
   Action selection dialog has been destroyed
 *****************************************************************/
@@ -1199,6 +1215,12 @@
                     (GCallback)act_sel_location_callback, data,
                     TRUE, NULL);
 
+  action_button_map[BUTTON_WAIT] =
+      choice_dialog_get_number_of_buttons(shl);
+  choice_dialog_add(shl, _("_Wait"),
+                    (GCallback)act_sel_wait_callback, data,
+                    TRUE, NULL);
+
   action_button_map[BUTTON_CANCEL] =
       choice_dialog_get_number_of_buttons(shl);
   choice_dialog_add(shl, GTK_STOCK_CANCEL,
@@ -1320,16 +1342,21 @@
     }
   } action_iterate_end;
 
+  /* DO NOT change the action_button_map[] for any button to reflect its
+   * new position. A button keeps its choice dialog internal name when its
+   * position changes. A button's id number is therefore based on when
+   * it was added, not on its current position. */
+
+  if (BUTTON_NOT_THERE != action_button_map[BUTTON_WAIT]) {
+    /* Move the wait button below the recently added button. */
+    choice_dialog_button_move_to_the_end(act_sel_dialog,
+        action_button_map[BUTTON_WAIT]);
+  }
+
   if (BUTTON_NOT_THERE != action_button_map[BUTTON_CANCEL]) {
     /* Move the cancel button below the recently added button. */
     choice_dialog_button_move_to_the_end(act_sel_dialog,
         action_button_map[BUTTON_CANCEL]);
-
-    /* DO NOT change action_button_map[BUTTON_CANCEL] or
-     * the action_button_map[] for any other button to reflect the new
-     * positions. A button keeps its choice dialog internal name when its
-     * position changes. A button's id number is therefore based on when
-     * it was added, not on its current position. */
   }
 
   choice_dialog_end(act_sel_dialog);

Modified: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=32223&r1=32222&r2=32223&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Thu Mar 10 14:15:06 2016
@@ -51,8 +51,9 @@
 
 /* Locations for non action enabler controlled buttons. */
 #define BUTTON_MOVE ACTION_COUNT
-#define BUTTON_CANCEL BUTTON_MOVE + 1
-#define BUTTON_COUNT BUTTON_MOVE + 2
+#define BUTTON_WAIT BUTTON_MOVE + 1
+#define BUTTON_CANCEL BUTTON_MOVE + 2
+#define BUTTON_COUNT BUTTON_MOVE + 3
 
 extern void popdown_all_spaceships_dialogs();
 extern void popdown_players_report();
@@ -1188,6 +1189,14 @@
 }
 
 /***************************************************************************
+  Delay selection of what action to take.
+***************************************************************************/
+static void act_sel_wait(QVariant data1, QVariant data2)
+{
+  key_unit_wait();
+}
+
+/***************************************************************************
   Empty action for choice dialog (just do nothing)
 ***************************************************************************/
 static void keep_moving(QVariant data1, QVariant data2)
@@ -1383,6 +1392,10 @@
                  "", BUTTON_MOVE);
   }
 
+  func = act_sel_wait;
+  cd->add_item(QString(_("&Wait")), func, qv1, qv2,
+               "", BUTTON_WAIT);
+
   func = keep_moving;
   cd->add_item(QString(_("Do nothing")), func, qv1, qv2,
                "", BUTTON_CANCEL);
@@ -2160,6 +2173,7 @@
 {
   choice_dialog *asd;
   Choice_dialog_button *keep_moving_button;
+  Choice_dialog_button *wait_button;
   QVariant qv1, qv2;
 
   asd = gui()->get_diplo_dialog();
@@ -2182,6 +2196,13 @@
     /* Temporary remove the Keep moving button so it won't end up above
      * any added buttons. */
     asd->stack_button(keep_moving_button);
+  }
+
+  wait_button = asd->get_identified_button(BUTTON_WAIT);
+  if (wait_button != NULL) {
+    /* Temporary remove the Wait button so it won't end up above
+     * any added buttons. */
+    asd->stack_button(wait_button);
   }
 
   action_iterate(act) {
@@ -2242,7 +2263,7 @@
     }
   } action_iterate_end;
 
-  if (keep_moving_button != NULL) {
+  if (keep_moving_button != NULL || wait_button != NULL) {
     /* Reinsert the "Keep moving" button below any potential
      * buttons recently added. */
     asd->unstack_all_buttons();

Modified: branches/S2_6/client/gui-sdl/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/action_dialog.c?rev=32223&r1=32222&r2=32223&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/action_dialog.c        (original)
+++ branches/S2_6/client/gui-sdl/action_dialog.c        Thu Mar 10 14:15:06 2016
@@ -680,6 +680,21 @@
   return -1;
 }
 
+/********************************************************************
+  Delay selection of what action to take.
+*********************************************************************/
+static int act_sel_wait_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+    key_unit_wait();
+
+    /* The dialog was popped down when key_unit_wait() resulted in
+     * action_selection_close() being called. */
+  }
+
+  return -1;
+}
+
 /****************************************************************
 ...  Ask the server how much the bribe is
 *****************************************************************/
@@ -1001,7 +1016,19 @@
   }
 
   /* ---------- */
-  
+  create_active_iconlabel(pBuf, pWindow->dst, pStr,
+                          _("Wait"), act_sel_wait_callback);
+
+  pBuf->data.tile = target_tile;
+
+  set_wstate(pBuf, FC_WS_NORMAL);
+
+  add_to_gui_list(MAX_ID - actor_unit->id, pBuf);
+
+  area.w = MAX(area.w, pBuf->size.w);
+  area.h += pBuf->size.h;
+
+  /* ---------- */
   create_active_iconlabel(pBuf, pWindow->dst, pStr,
            _("Cancel"), diplomat_close_callback);
     

Modified: branches/S2_6/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/action_dialog.c?rev=32223&r1=32222&r2=32223&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/action_dialog.c       (original)
+++ branches/S2_6/client/gui-sdl2/action_dialog.c       Thu Mar 10 14:15:06 2016
@@ -682,6 +682,21 @@
   return -1;
 }
 
+/********************************************************************
+  Delay selection of what action to take.
+*********************************************************************/
+static int act_sel_wait_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+    key_unit_wait();
+
+    /* The dialog was popped down when key_unit_wait() resulted in
+     * action_selection_close() being called. */
+  }
+
+  return -1;
+}
+
 /****************************************************************
 ...  Ask the server how much the bribe is
 *****************************************************************/
@@ -1005,7 +1020,19 @@
   }
 
   /* ---------- */
-
+  create_active_iconlabel(pBuf, pWindow->dst, pstr,
+                          _("Wait"), act_sel_wait_callback);
+
+  pBuf->data.tile = target_tile;
+
+  set_wstate(pBuf, FC_WS_NORMAL);
+
+  add_to_gui_list(MAX_ID - actor_unit->id, pBuf);
+
+  area.w = MAX(area.w, pBuf->size.w);
+  area.h += pBuf->size.h;
+
+  /* ---------- */
   create_active_iconlabel(pBuf, pWindow->dst, pstr,
                           _("Cancel"), diplomat_close_callback);
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to