lua: Implement wesnoth.view_locked() and wesnoth.lock_view()

Both are simple wrappers for display::view_locked() and
display::set_view_locked(), respectively. view_locked() returns a
boolean specifying whether the view is locked, and lock_view() takes a
boolean specifying whether to lock the view (true) or unlock it (false).
This commit is contained in:
Ignacio R. Morelle 2012-06-11 23:09:43 +00:00
parent bd8cca5ff8
commit 3536a15b27
2 changed files with 28 additions and 0 deletions

View file

@ -125,6 +125,11 @@ Version 1.11.0-svn:
* wesnoth.scroll_to_tile() now takes a fourth optional argument (boolean)
specifying whether to ignore the scroll speed setting in Preferences and
instantly warp to the given location
* Added wesnoth.lock_view(), taking a boolean argument specifying whether
to lock gamemap view scrolling (so the user cannot scroll, while WML/Lua
actions still can, i.e. for cutscenes), or unlock it
* Added wesnoth.view_locked(), returning a boolean true value if gamemap
view scrolling has been locked, and false otherwise
* Multiplayer:
* A New Land:
* Made it so that the "Elvish Shaman" option in the elvish unit selection

View file

@ -1532,6 +1532,27 @@ static int intf_is_enemy(lua_State *L)
return 1;
}
/**
* Gets whether gamemap scrolling is disabled for the user.
* - Ret 1: boolean.
*/
static int intf_view_locked(lua_State *L)
{
lua_pushboolean(L, resources::screen->view_locked());
return 1;
}
/**
* Sets whether gamemap scrolling is disabled for the user.
* - Arg 1: boolean, specifying the new locked/unlocked status.
*/
static int intf_lock_view(lua_State *L)
{
bool lock = lua_toboolean(L, 1);
resources::screen->set_view_locked(lock);
return 0;
}
/**
* Gets some data on a side (__index metamethod).
* - Arg 1: full userdata containing the team.
@ -3493,6 +3514,7 @@ LuaKernel::LuaKernel(const config &cfg)
{ "get_village_owner", &intf_get_village_owner },
{ "highlight_hex", &intf_highlight_hex },
{ "is_enemy", &intf_is_enemy },
{ "lock_view", &intf_lock_view },
{ "match_location", &intf_match_location },
{ "match_side", &intf_match_side },
{ "match_unit", &intf_match_unit },
@ -3523,6 +3545,7 @@ LuaKernel::LuaKernel(const config &cfg)
{ "unit_defense", &intf_unit_defense },
{ "unit_movement_cost", &intf_unit_movement_cost },
{ "unit_resistance", &intf_unit_resistance },
{ "view_locked", &intf_view_locked },
{ NULL, NULL }
};
luaL_register(L, "wesnoth", callbacks);