Author: shadowmaster
Date: Tue Mar 24 13:20:22 2009
New Revision: 34083
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34083&view=rev
Log:
[switch] and its children, [else] and [case], may be used in story WML
([story]) from now on.
Fulfills FR / bug #13170.
Silene or Sapient may want to check the usage of
vconfig::all_children_iterator in this commit, however.
Modified:
trunk/changelog
trunk/src/intro.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34083&r1=34082&r2=34083&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Mar 24 13:20:22 2009
@@ -20,6 +20,8 @@
* WML Engine:
* Added [show_objectives] tag (part of bug #13042)
* Made moveto events set $x2,$y2 to the source hex. (bug #13140)
+ * [switch] and [case]/[else] can be used to wrap story [part]s in [story]
+ now (bug #13170)
Version 1.6a:
* User interface:
Modified: trunk/src/intro.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/intro.cpp?rev=34083&r1=34082&r2=34083&view=diff
==============================================================================
--- trunk/src/intro.cpp (original)
+++ trunk/src/intro.cpp Tue Mar 24 13:20:22 2009
@@ -20,6 +20,7 @@
#include "global.hpp"
#include "foreach.hpp"
+#include "gamestatus.hpp"
#include "intro.hpp"
#include "variable.hpp"
#include "display.hpp"
@@ -74,6 +75,37 @@
return;
}
show_intro(disp, selection, level);
+ } else if(item.first == "switch") {
+ const vconfig switch_node = item.second;
+ game_state* const gamestate =
game_events::get_state_of_game();
+ assert(gamestate != NULL);
+
+ const std::string var_name = switch_node["variable"];
+ const std::string var_actual_value =
(*gamestate).get_variable_const(var_name);
+ const vconfig::child_list& cases =
item.second.get_children("case");
+ bool not_found = true;
+
+ for(vconfig::all_children_iterator j =
switch_node.ordered_begin(); j != switch_node.ordered_end(); ++j) {
+ if(j->first != "case")
+ continue;
+
+ const std::string var_expected_value =
(j->second)["value"];
+
+ if(var_actual_value == var_expected_value) {
+ not_found = false;
+ show_intro(disp, (j->second), level);
+ // FIXME: stop? the game_events.cpp version
doesn't stop.
+ }
+ }
+
+ if(not_found) {
+ for(vconfig::all_children_iterator j =
switch_node.ordered_begin(); j != switch_node.ordered_end(); ++j) {
+ if(j->first != "else")
+ continue;
+
+ show_intro(disp, (j->second), level);
+ }
+ }
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits