Author: sveinung
Date: Mon Jan  5 13:22:04 2015
New Revision: 27531

URL: http://svn.gna.org/viewcvs/freeciv?rev=27531&view=rev
Log:
Qt client: 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 #5655

Modified:
    branches/S2_6/client/gui-qt/dialogs.cpp

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=27531&r1=27530&r2=27531&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Mon Jan  5 13:22:04 2015
@@ -1315,94 +1315,33 @@
   /* Set the correct target for the following actions. */
   qv2 = cd->target_id[ATK_CITY];
 
-  action_entry(cd,
-               ACTION_ESTABLISH_EMBASSY,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_INVESTIGATE_CITY,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_POISON,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_STEAL_GOLD,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_SABOTAGE_CITY,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_TARGETED_SABOTAGE_CITY,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_STEAL_TECH,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_TARGETED_STEAL_TECH,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_INCITE_CITY,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_TRADE_ROUTE,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_MARKETPLACE,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_HELP_WONDER,
-               act_probs,
-               city_prod_remaining(target_city),
-               qv1, qv2);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_CITY) {
+      action_entry(cd,
+                   (enum gen_action)act,
+                   act_probs,
+                   act == ACTION_HELP_WONDER ?
+                     city_prod_remaining(target_city) : "",
+                   qv1, qv2);
+    }
+  } action_iterate_end;
 
   /* Spy/Diplomat acting against a unit */
 
   /* Set the correct target for the following actions. */
   qv2 = cd->target_id[ATK_UNIT];
 
-  action_entry(cd,
-               ACTION_SPY_BRIBE_UNIT,
-               act_probs,
-               "",
-               qv1, qv2);
-
-  action_entry(cd,
-               ACTION_SPY_SABOTAGE_UNIT,
-               act_probs,
-               "",
-               qv1, qv2);
+  action_iterate(act) {
+    if (action_get_actor_kind(act) == AAK_UNIT
+        && action_get_target_kind(act) == ATK_UNIT) {
+      action_entry(cd,
+                   (enum gen_action)act,
+                   act_probs,
+                   "",
+                   qv1, qv2);
+    }
+  } 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