Skip to content

Commit 2de8d90

Browse files
authored
Merge pull request #236 from FileEX/master
0006962: Add missing isReadOnly functions for GUI Memos and Edit fields.
2 parents 22f1223 + 9641fea commit 2de8d90

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

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

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ void CLuaGUIDefs::LoadFunctions(void)
128128
CLuaCFunctions::AddFunction("guiEditSetMasked", GUIEditSetMasked);
129129
CLuaCFunctions::AddFunction("guiEditSetMaxLength", GUIEditSetMaxLength);
130130
CLuaCFunctions::AddFunction("guiEditSetReadOnly", GUIEditSetReadOnly);
131+
CLuaCFunctions::AddFunction("guiEditIsReadOnly", GUIEditIsReadOnly);
131132

132133
CLuaCFunctions::AddFunction("guiMemoSetCaretIndex", GUIMemoSetCaretIndex);
133134
CLuaCFunctions::AddFunction("guiMemoGetCaretIndex", GUIMemoGetCaretIndex);
134135
CLuaCFunctions::AddFunction("guiMemoSetReadOnly", GUIMemoSetReadOnly);
136+
CLuaCFunctions::AddFunction("guiMemoIsReadOnly", GUIMemoIsReadOnly);
135137

136138
CLuaCFunctions::AddFunction("guiLabelSetColor", GUILabelSetColor);
137139
CLuaCFunctions::AddFunction("guiLabelGetColor", GUILabelGetColor);
@@ -276,7 +278,7 @@ void CLuaGUIDefs::AddGuiEditClass(lua_State* luaVM)
276278
lua_classfunction(luaVM, "setMaxLength", "guiEditSetMaxLength");
277279

278280
lua_classvariable(luaVM, "caretIndex", "guiEditSetCaretIndex", "guiEditGetCaretIndex");
279-
lua_classvariable(luaVM, "readOnly", "guiEditSetReadOnly", NULL);
281+
lua_classvariable(luaVM, "readOnly", "guiEditSetReadOnly", "guiEditIsReadOnly");
280282
lua_classvariable(luaVM, "masked", "guiEditSetMasked", NULL);
281283
lua_classvariable(luaVM, "maxLength", "guiEditSetMaxLength", NULL);
282284

@@ -319,7 +321,7 @@ void CLuaGUIDefs::AddGuiMemoClass(lua_State* luaVM)
319321
lua_classfunction(luaVM, "setReadOnly", "guiMemoSetReadOnly");
320322

321323
lua_classvariable(luaVM, "caretIndex", "guiMemoSetCaretIndex", "guiMemoGetCaretIndex");
322-
lua_classvariable(luaVM, "readOnly", "guiMemoSetReadOnly", NULL);
324+
lua_classvariable(luaVM, "readOnly", "guiMemoSetReadOnly", "guiMemoIsReadOnly");
323325

324326
lua_registerclass(luaVM, "GuiMemo", "GuiElement");
325327
}
@@ -2945,6 +2947,28 @@ int CLuaGUIDefs::GUIEditSetReadOnly(lua_State* luaVM)
29452947
return 1;
29462948
}
29472949

2950+
int CLuaGUIDefs::GUIEditIsReadOnly(lua_State* luaVM)
2951+
{
2952+
// bool guiEditIsReadOnly( element editField )
2953+
CClientGUIElement* editField;
2954+
2955+
CScriptArgReader argStream(luaVM);
2956+
argStream.ReadUserData<CGUIEdit>(editField);
2957+
2958+
if (!argStream.HasErrors())
2959+
{
2960+
bool readOnly = static_cast<CGUIEdit*>(editField->GetCGUIElement())->IsReadOnly();
2961+
lua_pushboolean(luaVM, readOnly);
2962+
return 1;
2963+
}
2964+
else
2965+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
2966+
2967+
// error: bad arguments
2968+
lua_pushnil(luaVM);
2969+
return 1;
2970+
}
2971+
29482972
int CLuaGUIDefs::GUIMemoSetReadOnly(lua_State* luaVM)
29492973
{
29502974
// bool guiMemoSetReadOnly ( gui-memo theMemo, bool status )
@@ -2969,6 +2993,28 @@ int CLuaGUIDefs::GUIMemoSetReadOnly(lua_State* luaVM)
29692993
return 1;
29702994
}
29712995

2996+
int CLuaGUIDefs::GUIMemoIsReadOnly(lua_State* luaVM)
2997+
{
2998+
// bool guiMemoIsReadOnly( gui-memo theMemo )
2999+
CClientGUIElement* theMemo;
3000+
3001+
CScriptArgReader argStream(luaVM);
3002+
argStream.ReadUserData<CGUIMemo>(theMemo);
3003+
3004+
if (!argStream.HasErrors())
3005+
{
3006+
bool readOnly = static_cast<CGUIMemo*>(theMemo->GetCGUIElement())->IsReadOnly();
3007+
lua_pushboolean(luaVM, readOnly);
3008+
return 1;
3009+
}
3010+
else
3011+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3012+
3013+
// error: bad arguments
3014+
lua_pushnil(luaVM);
3015+
return 1;
3016+
}
3017+
29723018
int CLuaGUIDefs::GUIEditSetMasked(lua_State* luaVM)
29733019
{
29743020
// bool guiEditSetMasked ( element theElement, bool status )

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ class CLuaGUIDefs : public CLuaDefs
114114
LUA_DECLARE(GUIProgressBarSetProgress);
115115
LUA_DECLARE(GUIProgressBarGetProgress);
116116
LUA_DECLARE(GUIEditSetReadOnly);
117+
LUA_DECLARE(GUIEditIsReadOnly);
117118
LUA_DECLARE(GUIEditSetMasked);
118119
LUA_DECLARE(GUIEditSetMaxLength);
119120
LUA_DECLARE(GUIEditSetCaretIndex);
120121
LUA_DECLARE(GUIEditGetCaretIndex);
121122
LUA_DECLARE(GUIMemoSetReadOnly);
123+
LUA_DECLARE(GUIMemoIsReadOnly);
122124
LUA_DECLARE(GUIMemoSetCaretIndex);
123125
LUA_DECLARE(GUIMemoGetCaretIndex);
124126
LUA_DECLARE(GUIWindowSetMovable);

0 commit comments

Comments
 (0)