Accept [story] as ActionWML

This commit is contained in:
Celtic Minstrel 2017-05-02 20:48:52 -04:00
parent a7cacfb77f
commit efb0fe05e9
7 changed files with 33 additions and 14 deletions

View file

@ -39,6 +39,7 @@ Version 1.13.7+dev:
comparable with == or ~=
* wesnoth.set_music is now deprecated, in favour of the above new API
* New wesnoth.sound_volume function gets/sets the current sound volume, as [volume]sound=
* New wesnoth.show_story function launches the storyscreen viewer
* Multiplayer:
* Fixed statistics being lost when reloading an MP game.
* Performance:
@ -71,6 +72,7 @@ Version 1.13.7+dev:
* [kill]animate=yes now plays victory animations if applicable
* Fix [volume] not accepting 100% as the new volume.
* New concat_to_* keys in unit_type inheritance allow amending keys
* Accept [story] as ActionWML in events
* Miscellaneous and bug fixes:
* Fixed base animation showing on walking corpse & soulless bats (bug #25673)

View file

@ -1523,6 +1523,10 @@ function wesnoth.wml_actions.zoom(cfg)
wesnoth.zoom(cfg.factor, cfg.relative)
end
function wesnoth.wml_actions.story(cfg)
wesnoth.show_story(cfg, cfg.title)
end
function wesnoth.wml_conditionals.proceed_to_next_scenario(cfg)
local endlevel_data = wesnoth.get_end_level_data()
if not endlevel_data then

View file

@ -36,20 +36,9 @@ public:
~story_viewer();
static void display(const std::string& scenario_name, const config::const_child_itors& story, CVideo& video)
static void display(const std::string& scenario_name, const config& story, CVideo& video)
{
// Combine all the [story] tags into a single config. Handle this here since
// storyscreen::controller doesn't have a default constructor.
config cfg;
for(const auto& iter : story) {
cfg.append_children(iter);
}
if(cfg.empty()) {
return;
}
story_viewer(scenario_name, cfg).show(video);
story_viewer(scenario_name, story).show(video);
}
private:

View file

@ -235,7 +235,16 @@ LEVEL_RESULT playsingle_controller::play_scenario(const config& level)
sound::commit_music_changes();
if(!this->is_skipping_replay()) {
gui2::dialogs::story_viewer::display(get_scenario_name(), level.child_range("story"), gui_->video());
// Combine all the [story] tags into a single config. Handle this here since
// storyscreen::controller doesn't have a default constructor.
config cfg;
for(const auto& iter : level.child_range("story")) {
cfg.append_children(iter);
}
if(!cfg.empty()) {
gui2::dialogs::story_viewer::display(get_scenario_name(), cfg, gui_->video());
}
}
gui_->labels().read(level);

View file

@ -21,6 +21,7 @@
#include "gui/dialogs/gamestate_inspector.hpp"
#include "gui/dialogs/lua_interpreter.hpp"
#include "gui/dialogs/wml_message.hpp"
#include "gui/dialogs/story_viewer.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/clickable_item.hpp"
#include "gui/widgets/styled_widget.hpp"
@ -387,6 +388,18 @@ int show_popup_dialog(lua_State *L, CVideo & video) {
return 0;
}
/**
* Displays a story screen
* - Arg 1: The story config
* - Arg 2: The default title
*/
int show_story(lua_State* L, CVideo& video) {
config story = luaW_checkconfig(L, 1);
std::string title = luaL_checkstring(L, 2);
gui2::dialogs::story_viewer::display(title, story, video);
return 0;
}
/**
* Displays a popup menu at the current mouse position
* Best used from a [set_menu_item], to show a submenu

View file

@ -38,6 +38,7 @@ int show_dialog(lua_State *L, CVideo & video);
int show_message_dialog(lua_State *L, CVideo & video);
int show_popup_dialog(lua_State *L, CVideo & video);
int show_menu(lua_State* L, CVideo& video);
int show_story(lua_State* L, CVideo& video);
int show_lua_console(lua_State*L, CVideo & video, lua_kernel_base * lk);
int show_gamestate_inspector(CVideo& video, const vconfig& cfg, const game_data& data, const game_state& state);
int intf_remove_dialog_item(lua_State *L);

View file

@ -367,6 +367,7 @@ lua_kernel_base::lua_kernel_base()
{ "show_menu", &video_dispatch<lua_gui2::show_menu> },
{ "show_message_dialog", &video_dispatch<lua_gui2::show_message_dialog> },
{ "show_popup_dialog", &video_dispatch<lua_gui2::show_popup_dialog> },
{ "show_story", &video_dispatch<lua_gui2::show_story> },
{ "show_lua_console", &dispatch<&lua_kernel_base::intf_show_lua_console> },
{ "compile_formula", &lua_formula_bridge::intf_compile_formula},
{ "eval_formula", &lua_formula_bridge::intf_eval_formula},