Author: shadowmaster
Date: Sat Dec  6 21:58:40 2008
New Revision: 31319

URL: http://svn.gna.org/viewcvs/wesnoth?rev=31319&view=rev
Log:
Implemented WML interfaces for changing the
end-of-campaign text. They are described in changelog.
(Feature / bug #10449)

We still lack a [scenario] interface; it would be
possibly redundant, but still nice to have. That's
for later...

Modified:
    trunk/changelog
    trunk/src/game.cpp
    trunk/src/game_events.cpp
    trunk/src/gamestatus.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=31319&r1=31318&r2=31319&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sat Dec  6 21:58:40 2008
@@ -47,6 +47,10 @@
    * Added a horizontal scrollbar widget.
  * WML engine:
    * Added the 'round' key to [set_variable].
+   * It is possible to override the end-of-campaign screen text
+     and its duration using end_text and end_text_duration attributes
+     respectively, in [endlevel] or [campaign] tags. end_text_duration
+     is measured in milliseconds. (feature #10449) 
  * Miscellaneous and bug fixes:
    * New memory allocator introduced to the engine. It should
      produce 5-10% savings in memory usage on 64-bit systems.

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=31319&r1=31318&r2=31319&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sat Dec  6 21:58:40 2008
@@ -1099,6 +1099,8 @@
        state_.campaign = campaign["id"];
        state_.abbrev = campaign["abbrev"];
        state_.scenario = campaign["first_scenario"];
+       state_.end_text = campaign["end_text"];
+       state_.end_text_duration = lexical_cast_default<unsigned 
int>(campaign["end_text_duration"]);
 
        const std::string difficulty_descriptions = 
campaign["difficulty_descriptions"];
        std::vector<std::string> difficulty_options = 
utils::split(difficulty_descriptions, ';');

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=31319&r1=31318&r2=31319&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Dec  6 21:58:40 2008
@@ -2490,6 +2490,16 @@
                if(next_scenario.empty() == false) {
                        state_of_game->next_scenario = next_scenario;
                }
+               
+               const std::string end_of_campaign_text = cfg["end_text"];
+               if(! end_of_campaign_text.empty()) {
+                       state_of_game->end_text = end_of_campaign_text;
+               }
+               const std::string end_of_campaign_text_delay = 
cfg["end_text_duration"];
+               if(! end_of_campaign_text_delay.empty()) {
+                       state_of_game->end_text_duration =
+                               lexical_cast_default<unsigned int,const 
std::string&>(end_of_campaign_text_delay, state_of_game->end_text_duration);
+               }
 
                const std::string result = cfg["result"].base_str(); //do not 
translate
                const std::string endlevel_music = cfg["music"];

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=31319&r1=31318&r2=31319&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Sat Dec  6 21:58:40 2008
@@ -624,6 +624,9 @@
 
        cfg["random_seed"] = 
lexical_cast<std::string>(gamestate.rng().get_random_seed());
        cfg["random_calls"] = 
lexical_cast<std::string>(gamestate.rng().get_random_calls());
+       
+       cfg["end_text"] = gamestate.end_text;
+       cfg["end_text_duration"] = str_cast<unsigned 
int>(gamestate.end_text_duration);
 
        cfg.add_child("variables",gamestate.get_variables());
 
@@ -681,6 +684,8 @@
        out.write_key_val("random_seed", 
lexical_cast<std::string>(gamestate.rng().get_random_seed()));
        out.write_key_val("random_calls", 
lexical_cast<std::string>(gamestate.rng().get_random_calls()));
        out.write_key_val("next_underlying_unit_id", 
lexical_cast<std::string>(n_unit::id_manager::instance().get_save_id()));
+       out.write_key_val("end_text", gamestate.end_text);
+       out.write_key_val("end_text_duration", str_cast<unsigned 
int>(gamestate.end_text_duration));
        out.write_child("variables", gamestate.get_variables());
 
        for(std::map<std::string, wml_menu_item *>::const_iterator 
j=gamestate.wml_menu_items.begin();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to