Author: sveinung
Date: Thu Nov 12 15:54:11 2015
New Revision: 30570

URL: http://svn.gna.org/viewcvs/freeciv?rev=30570&view=rev
Log:
GTK clients: act sel dlg "Show Location" button

Add a button that focuses the map on the actor unit to the GTK clients'
action selection dialog.

Requested by Marko Lindqvist <cazfi>

See bug #23846

Modified:
    trunk/client/gui-gtk-2.0/action_dialog.c
    trunk/client/gui-gtk-3.0/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=30570&r1=30569&r2=30570&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Thu Nov 12 15:54:11 2015
@@ -50,8 +50,9 @@
 
 /* Locations for non action enabler controlled buttons. */
 #define BUTTON_MOVE ACTION_MOVE
-#define BUTTON_CANCEL BUTTON_MOVE + 1
-#define BUTTON_COUNT BUTTON_MOVE + 2
+#define BUTTON_LOCATION BUTTON_MOVE + 1
+#define BUTTON_CANCEL BUTTON_MOVE + 2
+#define BUTTON_COUNT BUTTON_MOVE + 3
 
 #define BUTTON_NOT_THERE -1
 
@@ -1050,6 +1051,20 @@
 
 
 /**************************************************************************
+  Callback from action selection dialog for "Show Location".
+**************************************************************************/
+static void act_sel_location_callback(GtkWidget *w, gpointer data)
+{
+  struct action_data *args = (struct action_data *)data;
+
+  struct unit *punit;
+
+  if ((punit = game_unit_by_number(args->actor_unit_id))) {
+    center_tile_mapcanvas(unit_tile(punit));
+  }
+}
+
+/**************************************************************************
   Callback from diplomat/spy dialog for "keep moving".
   (This should only occur when entering a tile that has an allied city or
   an allied unit.)
@@ -1382,6 +1397,12 @@
                       data, FALSE, NULL);
   }
 
+  action_button_map[BUTTON_LOCATION] =
+      choice_dialog_get_number_of_buttons(shl);
+  choice_dialog_add(shl, _("Show Location"),
+                    (GCallback)act_sel_location_callback, data,
+                    TRUE, NULL);
+
   action_button_map[BUTTON_CANCEL] =
       choice_dialog_get_number_of_buttons(shl);
   choice_dialog_add(shl, GTK_STOCK_CANCEL,

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=30570&r1=30569&r2=30570&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Thu Nov 12 15:54:11 2015
@@ -50,8 +50,9 @@
 
 /* Locations for non action enabler controlled buttons. */
 #define BUTTON_MOVE ACTION_MOVE
-#define BUTTON_CANCEL BUTTON_MOVE + 1
-#define BUTTON_COUNT BUTTON_MOVE + 2
+#define BUTTON_LOCATION BUTTON_MOVE + 1
+#define BUTTON_CANCEL BUTTON_MOVE + 2
+#define BUTTON_COUNT BUTTON_MOVE + 3
 
 #define BUTTON_NOT_THERE -1
 
@@ -1060,6 +1061,20 @@
 
 
 /**************************************************************************
+  Callback from action selection dialog for "Show Location".
+**************************************************************************/
+static void act_sel_location_callback(GtkWidget *w, gpointer data)
+{
+  struct action_data *args = (struct action_data *)data;
+
+  struct unit *punit;
+
+  if ((punit = game_unit_by_number(args->actor_unit_id))) {
+    center_tile_mapcanvas(unit_tile(punit));
+  }
+}
+
+/**************************************************************************
   Callback from diplomat/spy dialog for "keep moving".
   (This should only occur when entering a tile that has an allied city or
   an allied unit.)
@@ -1392,6 +1407,12 @@
                       data, FALSE, NULL);
   }
 
+  action_button_map[BUTTON_LOCATION] =
+      choice_dialog_get_number_of_buttons(shl);
+  choice_dialog_add(shl, _("Show Location"),
+                    (GCallback)act_sel_location_callback, data,
+                    TRUE, NULL);
+
   action_button_map[BUTTON_CANCEL] =
       choice_dialog_get_number_of_buttons(shl);
   choice_dialog_add(shl, GTK_STOCK_CANCEL,


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

Reply via email to