Author: sveinung
Date: Thu May 12 13:35:53 2016
New Revision: 32678

URL: http://svn.gna.org/viewcvs/freeciv?rev=32678&view=rev
Log:
Add function to get UI name with mnemonic.

Introduce the new function action_get_ui_name_mnemonic(). Have it replace
calls to action_prepare_ui_name() that only add mnemonics to the action UI
name. This reduces the amount of repetition.

See patch #7214

Modified:
    branches/S2_6/client/gui-gtk-2.0/menu.c
    branches/S2_6/client/gui-gtk-3.0/menu.c
    branches/S2_6/common/actions.c
    branches/S2_6/common/actions.h

Modified: branches/S2_6/client/gui-gtk-2.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/menu.c?rev=32678&r1=32677&r2=32678&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/menu.c     (original)
+++ branches/S2_6/client/gui-gtk-2.0/menu.c     Thu May 12 13:35:53 2016
@@ -2302,8 +2302,7 @@
 
   if (units_can_do_action(punits, ACTION_HELP_WONDER, TRUE)) {
     menus_rename(unit_group, "BUILD_CITY",
-                 action_prepare_ui_name(ACTION_HELP_WONDER,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_HELP_WONDER, "_"));
   } else {
     bool city_on_tile = FALSE;
 
@@ -2326,8 +2325,7 @@
 
   if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
     menus_rename(unit_group, "BUILD_ROAD",
-                 action_prepare_ui_name(ACTION_TRADE_ROUTE,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_TRADE_ROUTE, "_"));
   } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
     char road_item[500];
     struct extra_type *pextra = NULL;

Modified: branches/S2_6/client/gui-gtk-3.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/menu.c?rev=32678&r1=32677&r2=32678&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/menu.c     (original)
+++ branches/S2_6/client/gui-gtk-3.0/menu.c     Thu May 12 13:35:53 2016
@@ -2290,8 +2290,7 @@
 
   if (units_can_do_action(punits, ACTION_HELP_WONDER, TRUE)) {
     menus_rename(unit_group, "BUILD_CITY",
-                 action_prepare_ui_name(ACTION_HELP_WONDER,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_HELP_WONDER, "_"));
   } else {
     bool city_on_tile = FALSE;
 
@@ -2314,8 +2313,7 @@
 
   if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
     menus_rename(unit_group, "BUILD_ROAD",
-                 action_prepare_ui_name(ACTION_TRADE_ROUTE,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_TRADE_ROUTE, "_"));
   } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
     char road_item[500];
     struct extra_type *pextra = NULL;

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=32678&r1=32677&r2=32678&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Thu May 12 13:35:53 2016
@@ -260,6 +260,15 @@
 }
 
 /**************************************************************************
+  Get the action name with a mnemonic ready to display in the UI.
+**************************************************************************/
+const char *action_get_ui_name_mnemonic(int action_id,
+                                        const char* mnemonic)
+{
+  return action_prepare_ui_name(action_id, mnemonic, ACTPROB_NA, NULL);
+}
+
+/**************************************************************************
   Get the UI name ready to show the action in the UI. It is possible to
   add a client specific mnemonic. Success probability information is
   interpreted and added to the text. A custom text can be inserted before

Modified: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=32678&r1=32677&r2=32678&view=diff
==============================================================================
--- branches/S2_6/common/actions.h      (original)
+++ branches/S2_6/common/actions.h      Thu May 12 13:35:53 2016
@@ -196,6 +196,8 @@
 
 const char *action_get_rule_name(int action_id);
 const char *action_get_ui_name(int action_id);
+const char *action_get_ui_name_mnemonic(int action_id,
+                                        const char* mnemonic);
 const char *action_prepare_ui_name(int action_id, const char* mnemonic,
                                    const action_probability prob,
                                    const char *custom);


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

Reply via email to