Properly port [scroll] to Lua

This commit is contained in:
Celtic Minstrel 2017-04-18 02:15:28 -04:00
parent 339587ee2b
commit 0a591cd424
4 changed files with 18 additions and 14 deletions

View file

@ -17,6 +17,10 @@ Version 1.13.7+dev:
required to be a space adjacent to the unit.
* New modifiable theme attribute in wesnoth.game_config
* New wesnoth.zoom() function allows changing the zoom level
* The wesnoth.scroll function scrolls the screen by an offset, similar to [scroll].
For example, wesnoth.scroll(5, -2)
* New is_local attribute in side proxy table allows you to detect whether or not the side is
controlled by a network player. Note that use of this has the potential for OOS errors.
* Multiplayer:
* Fixed statistics being lost when reloading an MP game.
* Performance:

View file

@ -919,7 +919,16 @@ function wml_actions.replace_schedule(cfg)
end
function wml_actions.scroll(cfg)
wesnoth.scroll(cfg)
local sides = utils.get_sides(cfg)
local have_human = false
for i, side in ipairs(sides) do
if side.controller == 'human' and side.is_local then
have_human = true
end
end
if have_human or #sides == 0 then
wesnoth.scroll(cfg.x, cfg.y)
end
end
function wml_actions.color_adjust(cfg)

View file

@ -3589,21 +3589,11 @@ int game_lua_kernel::intf_set_time_of_day(lua_State * L)
int game_lua_kernel::intf_scroll(lua_State * L)
{
vconfig cfg = luaW_checkvconfig(L, 1);
int x = luaL_checkinteger(L, 1), y = luaL_checkinteger(L, 2);
if (game_display_) {
const std::vector<int> side_list = get_sides_vector(cfg);
bool side_match = false;
for (int side : side_list) {
if(board().get_team(side).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);
}
game_display_->scroll(x, y, true);
game_display_->draw(true, true);
}
return 0;

View file

@ -74,6 +74,7 @@ static int impl_side_get(lua_State *L)
return_tstring_attrib("faction_name", t.faction_name());
return_string_attrib("color", t.color());
return_cstring_attrib("controller", t.controller().to_string().c_str());
return_bool_attrib("is_local", t.is_local());
return_string_attrib("defeat_condition", t.defeat_condition().to_string());
return_string_attrib("share_vision", t.share_vision().to_string());
return_float_attrib("carryover_bonus", t.carryover_bonus());