move WML [scroll] implementation to lua
This commit is contained in:
parent
8328bdd5c3
commit
2cc38505dc
4 changed files with 28 additions and 17 deletions
|
@ -1350,3 +1350,7 @@ end
|
|||
function wml_actions.replace_schedule(cfg)
|
||||
wesnoth.replace_schedule(cfg)
|
||||
end
|
||||
|
||||
function wml_actions.scroll(cfg)
|
||||
wesnoth.scroll(cfg)
|
||||
end
|
||||
|
|
|
@ -1694,23 +1694,6 @@ WML_HANDLER_FUNCTION(role, /*event_info*/, cfg)
|
|||
}
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(scroll, /*event_info*/, cfg)
|
||||
{
|
||||
const std::vector<int> side_list = get_sides_vector(cfg);
|
||||
bool side_match = false;
|
||||
BOOST_FOREACH(int side, side_list) {
|
||||
if((*resources::teams)[side-1].is_local_human()) {
|
||||
side_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((cfg["side"].empty() && !cfg.has_child("filter_side")) || side_match) {
|
||||
game_display &screen = *resources::screen;
|
||||
screen.scroll(cfg["x"], cfg["y"], true);
|
||||
screen.draw(true,true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Experimental data persistence
|
||||
/// @todo Finish experimenting.
|
||||
WML_HANDLER_FUNCTION(set_global_variable,/**/,pcfg)
|
||||
|
|
|
@ -3006,6 +3006,28 @@ int game_lua_kernel::intf_replace_schedule(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int game_lua_kernel::intf_scroll(lua_State * L)
|
||||
{
|
||||
vconfig cfg = luaW_checkvconfig(L, 1);
|
||||
|
||||
if (game_display_) {
|
||||
const std::vector<int> side_list = get_sides_vector(cfg);
|
||||
bool side_match = false;
|
||||
BOOST_FOREACH(int side, side_list) {
|
||||
if(teams()[side-1].is_local_human()) {
|
||||
side_match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((cfg["side"].empty() && !cfg.has_child("filter_side")) || side_match) {
|
||||
game_display_->scroll(cfg["x"], cfg["y"], true);
|
||||
game_display_->draw(true,true);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct lua_report_generator : reports::generator
|
||||
{
|
||||
|
@ -3182,6 +3204,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
|
|||
{ "remove_shroud", boost::bind(&game_lua_kernel::intf_shroud_op, this, _1, false) },
|
||||
{ "remove_tile_overlay", boost::bind(&game_lua_kernel::intf_remove_tile_overlay, this, _1) },
|
||||
{ "replace_schedule", boost::bind(&game_lua_kernel::intf_replace_schedule, this, _1) },
|
||||
{ "scroll", boost::bind(&game_lua_kernel::intf_scroll, this, _1) },
|
||||
{ "scroll_to_tile", boost::bind(&game_lua_kernel::intf_scroll_to_tile, this, _1) },
|
||||
{ "select_hex", boost::bind(&game_lua_kernel::intf_select_hex, this, _1) },
|
||||
{ "set_menu_item", boost::bind(&game_lua_kernel::intf_set_menu_item, this, _1) },
|
||||
|
|
|
@ -125,6 +125,7 @@ class game_lua_kernel : public lua_kernel_base
|
|||
int intf_remove_tile_overlay(lua_State *L);
|
||||
int intf_delay(lua_State *L);
|
||||
int intf_replace_schedule(lua_State *l);
|
||||
int intf_scroll(lua_State *L);
|
||||
int intf_get_all_vars(lua_State *L);
|
||||
int impl_theme_item(lua_State *L, std::string name);
|
||||
int impl_theme_items_get(lua_State *L);
|
||||
|
|
Loading…
Add table
Reference in a new issue