Skip to content

Commit

Permalink
wesnoth.scroll_to_tile can now skip if onscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Dec 11, 2016
1 parent bf9581c commit c58e2d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion data/lua/wml/message.lua
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit c58e2d0

Please sign in to comment.