wesnoth.scroll_to_tile can now skip if onscreen

This commit is contained in:
Celtic Minstrel 2016-09-20 01:51:13 -04:00 committed by Celtic Minstrel
parent bf9581cce4
commit c58e2d0095
3 changed files with 13 additions and 4 deletions

View file

@ -26,6 +26,8 @@ Version 1.13.6+dev:
* New read-only keys: share_maps, share_view
num_units, num_villages, total_upkeep, expenses, net_income
* Existing keys made mutable: shroud, fog, flag, flag_icon
* wesnoth.scroll_to_tile now accepts a third boolean argument - if true, the scroll
is skipped when the tile is already visible onscreen.
* WML Engine:
* Removed LOW_MEM option when building.
* Add color= attribute to [floating_text]

View file

@ -354,7 +354,7 @@ function wesnoth.wml_actions.message(cfg)
else
-- Check ~= false, because the default if omitted should be true
if cfg.scroll ~= false then
wesnoth.scroll_to_tile(speaker.x, speaker.y)
wesnoth.scroll_to_tile(speaker.x, speaker.y, false, false, true)
end
wesnoth.highlight_hex(speaker.x, speaker.y)

View file

@ -2371,15 +2371,22 @@ int game_lua_kernel::intf_play_sound(lua_State *L)
* - Arg 1: location.
* - Arg 2: boolean preventing scroll to fog.
* - Arg 3: boolean specifying whether to warp instantly.
* - Arg 4: boolean specifying whether to skip if already onscreen
*/
int game_lua_kernel::intf_scroll_to_tile(lua_State *L)
{
map_location loc = luaW_checklocation(L, 1);
bool check_fogged = luaW_toboolean(L, 2);
bool immediate = luaW_toboolean(L, 3);
game_display::SCROLL_TYPE scroll = luaW_toboolean(L, 4)
? luaW_toboolean(L, 3)
? game_display::WARP
: game_display::SCROLL
: luaW_toboolean(L, 3)
? game_display::ONSCREEN_WARP
: game_display::ONSCREEN
;
if (game_display_) {
game_display_->scroll_to_tile(loc,
immediate ? game_display::WARP : game_display::SCROLL, check_fogged);
game_display_->scroll_to_tile(loc, scroll, check_fogged);
}
return 0;
}