From 1fb4d36ef850f7ae7b9b81317f912bc3b0a60d9a Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 24 Apr 2017 09:52:18 -0400 Subject: [PATCH] Enable scenarios to change theme in an event --- changelog | 2 ++ data/lua/wml-tags.lua | 4 ++++ src/scripting/game_lua_kernel.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/changelog b/changelog index 66553a089d9..d159c172cf2 100644 --- a/changelog +++ b/changelog @@ -14,6 +14,7 @@ Version 1.13.7+dev: logging data into a saved game. * Small change to animator API - facing parameter replaced with target and required to be a space adjacent to the unit. + * New modifiable theme attribute in wesnoth.game_config * Multiplayer: * Fixed statistics being lost when reloading an MP game. * Performance: @@ -38,6 +39,7 @@ Version 1.13.7+dev: * Canvas colors can now be expressed as formulas. The formula must return the color as a list of its components, eg "([r, g, b, a])" * Empty tags are no longer written to the configs of [unit]s and [side]s. + * New [change_theme] tag to change the theme mid-scenario Version 1.13.7: * AI: diff --git a/data/lua/wml-tags.lua b/data/lua/wml-tags.lua index acaeeee3859..d4df4f95b05 100644 --- a/data/lua/wml-tags.lua +++ b/data/lua/wml-tags.lua @@ -1413,6 +1413,10 @@ function wml_actions.set_variable(cfg) end end +function wesnoth.wml_actions.change_theme(cfg) + wesnoth.game_config.theme = cfg.theme +end + function wesnoth.wml_conditionals.proceed_to_next_scenario(cfg) local endlevel_data = wesnoth.get_end_level_data() if not endlevel_data then diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index dc16a95b04e..9073166e596 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -1236,6 +1236,7 @@ int game_lua_kernel::impl_game_config_get(lua_State *L) return_int_attrib("last_turn", tod_man().number_of_turns()); return_string_attrib("version", game_config::version); return_string_attrib("next_scenario", gamedata().next_scenario()); + return_string_attrib("theme", gamedata().get_theme()); return_bool_attrib("debug", game_config::debug); return_bool_attrib("debug_lua", game_config::debug_lua); return_bool_attrib("mp_debug", game_config::mp_debug); @@ -1285,6 +1286,11 @@ int game_lua_kernel::impl_game_config_set(lua_State *L) modify_int_attrib("kill_experience", game_config::kill_experience = value); modify_int_attrib("last_turn", tod_man().set_number_of_turns_by_wml(value)); modify_string_attrib("next_scenario", gamedata().set_next_scenario(value)); + modify_string_attrib("theme", + gamedata().set_theme(value); + const config& game_config = game_config_manager::get()->game_config(); + game_display_->set_theme(play_controller_.get_theme(game_config, value)); + ); modify_vector_string_attrib("defeat_music", gamedata().set_defeat_music(std::move(value))); modify_vector_string_attrib("victory_music", gamedata().set_victory_music(std::move(value))); std::string err_msg = "unknown modifiable property of game_config: ";