Author: sveinung
Date: Mon Jan  5 11:51:11 2015
New Revision: 27528

URL: http://svn.gna.org/viewcvs/freeciv?rev=27528&view=rev
Log:
Gtk clients: Auto generate the action selection dialog buttons.

Automatically create a button for each action a unit can do in stead of hard
coding a button for each action. This reduces the amount of work required to
add a new action.

See patch #5656

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=27528&r1=27527&r2=27528&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Mon Jan  5 11:51:11 2015
@@ -1075,91 +1075,30 @@
 
   /* Spy/Diplomat acting against a city */
 
-  action_entry(shl,
-               ACTION_ESTABLISH_EMBASSY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_INVESTIGATE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_POISON,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_STEAL_GOLD,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_SABOTAGE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_TARGETED_SABOTAGE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_STEAL_TECH,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_TARGETED_STEAL_TECH,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_INCITE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_TRADE_ROUTE,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_MARKETPLACE,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_HELP_WONDER,
-               act_probs,
-               city_prod_remaining(target_city),
-               data);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_CITY) {
+      action_entry(shl,
+                   (enum gen_action)act,
+                   act_probs,
+                   act == ACTION_HELP_WONDER ?
+                     city_prod_remaining(target_city) : NULL,
+                   data);
+    }
+  } action_iterate_end;
 
   /* Spy/Diplomat acting against a unit */
 
-  action_entry(shl,
-               ACTION_SPY_BRIBE_UNIT,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_SABOTAGE_UNIT,
-               act_probs,
-               NULL,
-               data);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_UNIT) {
+      action_entry(shl,
+                   (enum gen_action)act,
+                   act_probs,
+                   NULL,
+                   data);
+    }
+  } action_iterate_end;
 
   if (unit_can_move_to_tile(actor_unit, target_tile, FALSE)
       || (is_military_unit(actor_unit) || is_attack_unit(actor_unit))

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=27528&r1=27527&r2=27528&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Mon Jan  5 11:51:11 2015
@@ -1085,91 +1085,30 @@
 
   /* Spy/Diplomat acting against a city */
 
-  action_entry(shl,
-               ACTION_ESTABLISH_EMBASSY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_INVESTIGATE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_POISON,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_STEAL_GOLD,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_SABOTAGE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_TARGETED_SABOTAGE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_STEAL_TECH,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_TARGETED_STEAL_TECH,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_INCITE_CITY,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_TRADE_ROUTE,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_MARKETPLACE,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_HELP_WONDER,
-               act_probs,
-               city_prod_remaining(target_city),
-               data);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_CITY) {
+      action_entry(shl,
+                   (enum gen_action)act,
+                   act_probs,
+                   act == ACTION_HELP_WONDER ?
+                     city_prod_remaining(target_city) : NULL,
+                   data);
+    }
+  } action_iterate_end;
 
   /* Spy/Diplomat acting against a unit */
 
-  action_entry(shl,
-               ACTION_SPY_BRIBE_UNIT,
-               act_probs,
-               NULL,
-               data);
-
-  action_entry(shl,
-               ACTION_SPY_SABOTAGE_UNIT,
-               act_probs,
-               NULL,
-               data);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_UNIT) {
+      action_entry(shl,
+                   (enum gen_action)act,
+                   act_probs,
+                   NULL,
+                   data);
+    }
+  } action_iterate_end;
 
   if (unit_can_move_to_tile(actor_unit, target_tile, FALSE)
       || (is_military_unit(actor_unit) || is_attack_unit(actor_unit))


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

Reply via email to