Skip to content

Commit d2c8306

Browse files
FileEXqaisjp
authored andcommitted
Add missing guiWindowIsMovable/Sizable functions (#272)
1 parent 2419698 commit d2c8306

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

Client/mods/deathmatch/logic/luadefs/CLuaGUIDefs.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ void CLuaGUIDefs::LoadFunctions(void)
149149

150150
CLuaCFunctions::AddFunction("guiWindowSetMovable", GUIWindowSetMovable);
151151
CLuaCFunctions::AddFunction("guiWindowSetSizable", GUIWindowSetSizable);
152+
CLuaCFunctions::AddFunction("guiWindowIsMovable", GUIWindowIsMovable);
153+
CLuaCFunctions::AddFunction("guiWindowIsSizable", GUIWindowIsSizable);
152154

153155
CLuaCFunctions::AddFunction("getChatboxLayout", GUIGetChatboxLayout);
154156

@@ -252,11 +254,15 @@ void CLuaGUIDefs::AddGuiWindowClass(lua_State* luaVM)
252254
lua_newclass(luaVM);
253255

254256
lua_classfunction(luaVM, "create", "guiCreateWindow");
257+
255258
lua_classfunction(luaVM, "setMovable", "guiWindowSetMovable");
256259
lua_classfunction(luaVM, "setSizable", "guiWindowSetSizable");
257260

258-
lua_classvariable(luaVM, "movable", "guiWindowSetMovable", NULL);
259-
lua_classvariable(luaVM, "sizable", "guiWindowSetSizable", NULL);
261+
lua_classfunction(luaVM, "isMovable", "guiWindowIsMovable");
262+
lua_classfunction(luaVM, "isSizable", "guiWindowIsSizable");
263+
264+
lua_classvariable(luaVM, "movable", "guiWindowSetMovable", "guiWindowIsMovable");
265+
lua_classvariable(luaVM, "sizable", "guiWindowSetSizable", "guiWindowIsSizable");
260266

261267
lua_registerclass(luaVM, "GuiWindow", "GuiElement");
262268
}
@@ -3273,6 +3279,28 @@ int CLuaGUIDefs::GUIWindowSetMovable(lua_State* luaVM)
32733279
return 1;
32743280
}
32753281

3282+
int CLuaGUIDefs::GUIWindowIsMovable(lua_State* luaVM)
3283+
{
3284+
// bool guiWindowIsMovable( element theElement )
3285+
CClientGUIElement* theElement;
3286+
3287+
CScriptArgReader argStream(luaVM);
3288+
argStream.ReadUserData<CGUIWindow>(theElement);
3289+
3290+
if (!argStream.HasErrors())
3291+
{
3292+
bool movable = static_cast<CGUIWindow*>(theElement->GetCGUIElement())->IsMovable();
3293+
lua_pushboolean(luaVM, movable);
3294+
return 1;
3295+
}
3296+
else
3297+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3298+
3299+
// error: bad arguments
3300+
lua_pushnil(luaVM);
3301+
return 1;
3302+
}
3303+
32763304
int CLuaGUIDefs::GUIWindowSetSizable(lua_State* luaVM)
32773305
{
32783306
// bool guiWindowSetSizable ( element theElement, bool status )
@@ -3297,6 +3325,28 @@ int CLuaGUIDefs::GUIWindowSetSizable(lua_State* luaVM)
32973325
return 1;
32983326
}
32993327

3328+
int CLuaGUIDefs::GUIWindowIsSizable(lua_State* luaVM)
3329+
{
3330+
// bool guiWindowIsSizable( elemen theElement )
3331+
CClientGUIElement* theElement;
3332+
3333+
CScriptArgReader argStream(luaVM);
3334+
argStream.ReadUserData<CGUIWindow>(theElement);
3335+
3336+
if (!argStream.HasErrors())
3337+
{
3338+
bool sizable = static_cast<CGUIWindow*>(theElement->GetCGUIElement())->IsSizingEnabled();
3339+
lua_pushboolean(luaVM, sizable);
3340+
return 1;
3341+
}
3342+
else
3343+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3344+
3345+
// error: bad arguments
3346+
lua_pushnil(luaVM);
3347+
return 1;
3348+
}
3349+
33003350
int CLuaGUIDefs::GUILabelGetTextExtent(lua_State* luaVM)
33013351
{
33023352
// float guiLabelGetTextExtent ( element theLabel )

Client/mods/deathmatch/logic/luadefs/CLuaGUIDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ class CLuaGUIDefs : public CLuaDefs
129129
LUA_DECLARE(GUIMemoSetVerticalScrollPosition);
130130
LUA_DECLARE(GUIWindowSetMovable);
131131
LUA_DECLARE(GUIWindowSetSizable);
132-
LUA_DECLARE(GUIWindowGetMovable);
133-
LUA_DECLARE(GUIWindowGetSizable);
132+
LUA_DECLARE(GUIWindowIsMovable);
133+
LUA_DECLARE(GUIWindowIsSizable);
134134
LUA_DECLARE(GUIWindowGetCloseButtonEnabled);
135135
LUA_DECLARE(GUIWindowGetTitleBarEnabled);
136136
LUA_DECLARE(GUILabelSetColor);

0 commit comments

Comments
 (0)