Author: sveinung
Date: Wed Mar  9 16:04:42 2016
New Revision: 32212

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

Jacob the 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 <jtn>

See patch #3711

Modified:
    trunk/client/gui-gtk-2.0/action_dialog.c
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-gtk-3.x/action_dialog.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-sdl2/action_dialog.c

Modified: trunk/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/action_dialog.c?rev=32212&r1=32211&r2=32212&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Wed Mar  9 16:04:42 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
 
@@ -1120,6 +1121,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
 *****************************************************************/
@@ -1443,6 +1459,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,
@@ -1564,16 +1586,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: trunk/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/action_dialog.c?rev=32212&r1=32211&r2=32212&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Wed Mar  9 16:04:42 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
 
@@ -1130,6 +1131,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
 *****************************************************************/
@@ -1453,6 +1469,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,
@@ -1574,16 +1596,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: trunk/client/gui-gtk-3.x/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/action_dialog.c?rev=32212&r1=32211&r2=32212&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.x/action_dialog.c    Wed Mar  9 16:04:42 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
 
@@ -1124,6 +1125,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
 *****************************************************************/
@@ -1447,6 +1463,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, _("Cancel"),
@@ -1568,16 +1590,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: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=32212&r1=32211&r2=32212&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Wed Mar  9 16:04:42 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();
@@ -1251,6 +1252,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)
@@ -1507,6 +1516,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);
@@ -2424,6 +2437,7 @@
 {
   choice_dialog *asd;
   Choice_dialog_button *keep_moving_button;
+  Choice_dialog_button *wait_button;
   QVariant qv1, qv2;
 
   asd = gui()->get_diplo_dialog();
@@ -2446,6 +2460,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) {
@@ -2522,7 +2543,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: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=32212&r1=32211&r2=32212&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Wed Mar  9 16:04:42 2016
@@ -759,6 +759,21 @@
     }
 
     popdown_diplomat_dialog();
+  }
+
+  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;
@@ -1300,7 +1315,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