From 3564b8846081b06623411b6de230d3093e54370d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 18 Aug 2015 00:51:27 -0400 Subject: [PATCH 1/3] Add female_text= to [unstore_unit] and [animate_unit] --- src/game_events/action_wml.cpp | 5 ++++- src/unit_display.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index c57c94529662..1dfbd114e876 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -1684,7 +1684,10 @@ WML_HANDLER_FUNCTION(unstore_unit, /*event_info*/, cfg) resources::units->erase(loc); resources::units->add(loc, *u); - std::string text = cfg["text"]; + config::attribute_value text = cfg["gender"].str() == "female" ? cfg["female_text"] : cfg["text"]; + if(text.blank()) { + text = cfg["text"]; + } play_controller *controller = resources::controller; if(!text.empty() && !controller->is_skipping_replay()) { diff --git a/src/unit_display.cpp b/src/unit_display.cpp index bb532e651fc9..45363d59338c 100644 --- a/src/unit_display.cpp +++ b/src/unit_display.cpp @@ -868,9 +868,14 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m secondary_loc = u->get_location().get_direction(dir); } } + config::attribute_value text = u->gender() == unit_race::FEMALE ? cfg["female_text"] : cfg["text"]; + if(text.blank()) { + text = cfg["text"]; + } + const std::string text_key = u->gender() == unit_race::FEMALE ? "female_text" : "text"; animator.add_animation(&*u, cfg["flag"], u->get_location(), secondary_loc, cfg["value"], cfg["with_bars"].to_bool(), - cfg["text"], text_color, hits, primary, secondary, + text.str(), text_color, hits, primary, secondary, cfg["value_second"]); } const vconfig::child_list sub_anims = cfg.get_children("animate"); From 766f3a7701eb3f5c2a5a5c2443a1dbdc74ad66c6 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 18 Aug 2015 14:12:48 -0400 Subject: [PATCH 2/3] Fix up female_text= especially in [unstore_unit], update changelog --- changelog | 1 + src/game_events/action_wml.cpp | 2 +- src/unit_display.cpp | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index e5f057c538ca..3e398d09f0bb 100644 --- a/changelog +++ b/changelog @@ -36,6 +36,7 @@ Version 1.13.1+dev: * Added support for has_flag= in terrain graphics [variant]. * Added category= to [label] - allows grouping labels so that players can show/hide them + * Add female_text= to [animate_unit] and [unstore_unit] for easier translating * Editor: * Added Category field and color sliders to the Edit Label panel. * Miscellaneous and bug fixes: diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index 1dfbd114e876..3d58c01c5fbe 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -1684,7 +1684,7 @@ WML_HANDLER_FUNCTION(unstore_unit, /*event_info*/, cfg) resources::units->erase(loc); resources::units->add(loc, *u); - config::attribute_value text = cfg["gender"].str() == "female" ? cfg["female_text"] : cfg["text"]; + config::attribute_value text = var["gender"].str() == "female" ? cfg["female_text"] : cfg["male_text"]; if(text.blank()) { text = cfg["text"]; } diff --git a/src/unit_display.cpp b/src/unit_display.cpp index 45363d59338c..e07c352903c9 100644 --- a/src/unit_display.cpp +++ b/src/unit_display.cpp @@ -868,11 +868,10 @@ void wml_animation_internal(unit_animator &animator, const vconfig &cfg, const m secondary_loc = u->get_location().get_direction(dir); } } - config::attribute_value text = u->gender() == unit_race::FEMALE ? cfg["female_text"] : cfg["text"]; + config::attribute_value text = u->gender() == unit_race::FEMALE ? cfg["female_text"] : cfg["male_text"]; if(text.blank()) { text = cfg["text"]; } - const std::string text_key = u->gender() == unit_race::FEMALE ? "female_text" : "text"; animator.add_animation(&*u, cfg["flag"], u->get_location(), secondary_loc, cfg["value"], cfg["with_bars"].to_bool(), text.str(), text_color, hits, primary, secondary, From 001fcdcd890ad62c050ad677f0ceae377066f97d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Tue, 18 Aug 2015 14:14:23 -0400 Subject: [PATCH 3/3] Update DW to use new female_text= feature for stun special (Note: UtBS, and possibly others, should probably be updated too.) --- data/campaigns/Dead_Water/units/Brawler.cfg | 28 ++------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/data/campaigns/Dead_Water/units/Brawler.cfg b/data/campaigns/Dead_Water/units/Brawler.cfg index 250fb8a6f9a6..ee60ee1aeca5 100644 --- a/data/campaigns/Dead_Water/units/Brawler.cfg +++ b/data/campaigns/Dead_Water/units/Brawler.cfg @@ -100,31 +100,11 @@ {VARIABLE second_unit.status.stunned yes} - [if] - [variable] - name=second_unit.gender - equals=female - [/variable] - - [then] - [set_variable] - name=tmp_stunned_text - value= _ "female^stunned" - [/set_variable] - [/then] - - [else] - [set_variable] - name=tmp_stunned_text - value= _ "stunned" - [/set_variable] - [/else] - [/if] - [unstore_unit] variable=second_unit find_vacant=no - text=$tmp_stunned_text + text= _ "stunned" + female_text= _ "female^stunned" red,green,blue=196,196,128 [/unstore_unit] @@ -146,10 +126,6 @@ value=no [/effect] [/object] - - [clear_variable] - name=tmp_stunned_text - [/clear_variable] [/event] [event]