diff --git a/changelog b/changelog index fd70463e8e6d..8f6a310403c0 100644 --- a/changelog +++ b/changelog @@ -19,6 +19,8 @@ Version 1.13.6+dev: * New mutable keys: suppress_end_turn_confirmation, share_vision * New read-only keys: share_maps, share_view * 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] diff --git a/data/lua/wml/message.lua b/data/lua/wml/message.lua index 78ba6218287a..2d10f2a32dc6 100644 --- a/data/lua/wml/message.lua +++ b/data/lua/wml/message.lua @@ -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) diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 2eece65f59b8..b84835924838 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -2372,15 +2372,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; }