Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
- index 6becd19..7b1d2d0 100644
- --- a/src/scripting/lua.cpp
- +++ b/src/scripting/lua.cpp
- @@ -2999,6 +2999,51 @@ static int intf_set_dialog_markup(lua_State *L)
- }
- /**
- + * Sets the visiblity of a widget in the current dialog.
- + * - Arg 1: boolean.
- + * - Args 2..n: path of strings and integers.
- + */
- +static int intf_set_dialog_visible(lua_State *L)
- +{
- + // The GUI2 control visibility value type
- + typedef gui2::tcontrol::tvisible tvisible;
- +
- + tvisible::scoped_enum flag = tvisible::visible;
- +
- + switch (lua_type(L, 1)) {
- + case LUA_TBOOLEAN:
- + flag = bool(lua_toboolean(L, 1))
- + ? tvisible::visible
- + : tvisible::invisible;
- + break;
- + case LUA_TSTRING:
- + {
- + const std::string& str = lua_tostring(L, 1);
- + if(str == "visible") {
- + flag = tvisible::visible;
- + } else if(str == "hidden") { // FIXME: broken
- + flag = tvisible::hidden;
- + } else if(str == "invisible") {
- + flag = tvisible::invisible;
- + } else {
- + return luaL_argerror(L, 1, "string must be one of: visible, hidden, invisible");
- + }
- + }
- + break;
- + default:
- + return luaL_typerror(L, 1, "boolean or string");
- + }
- +
- + gui2::twidget *w = find_widget(L, 2, true);
- + gui2::tcontrol *c = dynamic_cast<gui2::tcontrol *>(w);
- + if (!c) return luaL_argerror(L, lua_gettop(L), "unsupported widget");
- +
- + c->set_visible(flag);
- +
- + return 0;
- +}
- +
- +/**
- * Sets a canvas on a widget of the current dialog.
- * - Arg 1: integer.
- * - Arg 2: WML table.
- @@ -3624,6 +3669,7 @@ LuaKernel::LuaKernel(const config &cfg)
- { "set_dialog_canvas", &intf_set_dialog_canvas },
- { "set_dialog_markup", &intf_set_dialog_markup },
- { "set_dialog_value", &intf_set_dialog_value },
- + { "set_dialog_visible", &intf_set_dialog_visible },
- { "set_music", &intf_set_music },
- { "set_terrain", &intf_set_terrain },
- { "set_variable", &intf_set_variable },
Advertisement
Add Comment
Please, Sign In to add comment