move wml [open_help] impl to lua

also fixes an issue where the help topic was being cast
unnecessarily to a tstring
This commit is contained in:
Chris Beck 2014-12-24 14:42:37 -05:00
parent 75767d3a77
commit 171f92a6a5
4 changed files with 15 additions and 7 deletions

View file

@ -1388,6 +1388,10 @@ function wml_actions.modify_side(cfg)
wesnoth.modify_side(cfg)
end
function wml_actions.open_help(cfg)
wesnoth.open_help(cfg.topic)
end
function wml_actions.redraw(cfg)
local clear_shroud = cfg.clear_shroud

View file

@ -1041,13 +1041,6 @@ WML_HANDLER_FUNCTION(object, event_info, cfg)
}
}
WML_HANDLER_FUNCTION(open_help, /*event_info*/, cfg)
{
game_display &screen = *resources::screen;
t_string topic_id = cfg["topic"];
help::show_help(screen, topic_id.to_serialized());
}
WML_HANDLER_FUNCTION(print, /*event_info*/, cfg)
{
// Remove any old message.

View file

@ -55,6 +55,7 @@
#include "game_events/manager.hpp" // for add_event_handler
#include "game_events/pump.hpp" // for queued_event
#include "game_preferences.hpp" // for encountered_units
#include "help/help.hpp"
#include "image.hpp" // for get_image, locator
#include "log.hpp" // for LOG_STREAM, logger, etc
#include "lua/lauxlib.h" // for luaL_checkinteger, etc
@ -1443,6 +1444,14 @@ int game_lua_kernel::intf_message(lua_State *L)
return 0;
}
int game_lua_kernel::intf_open_help(lua_State *L)
{
if (game_display_) {
help::show_help(*game_display_, luaL_checkstring(L, 1));
}
return 0;
}
/**
* Dumps a wml table or userdata wml object into a pretty string.
* - Arg 1: wml table or vconfig userdata
@ -3626,6 +3635,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
{ "match_unit", boost::bind(&game_lua_kernel::intf_match_unit, this, _1) },
{ "message", boost::bind(&game_lua_kernel::intf_message, this, _1) },
{ "modify_side", boost::bind(&game_lua_kernel::intf_modify_side, this, _1) },
{ "open_help", boost::bind(&game_lua_kernel::intf_open_help, this, _1) },
{ "play_sound", boost::bind(&game_lua_kernel::intf_play_sound, this, _1) },
{ "place_shroud", boost::bind(&game_lua_kernel::intf_shroud_op, this, _1, true) },
{ "put_recall_unit", boost::bind(&game_lua_kernel::intf_put_recall_unit, this, _1) },

View file

@ -105,6 +105,7 @@ class game_lua_kernel : public lua_kernel_base
int intf_find_reach(lua_State *L);
int intf_find_cost_map(lua_State *L);
int intf_message(lua_State *L);
int intf_open_help(lua_State *L);
int intf_play_sound(lua_State *L);
int intf_put_unit(lua_State *L);
int intf_put_recall_unit(lua_State *L);