Skip to content

Commit 6622c67

Browse files
FileEXqaisjp
authored andcommitted
Add missing guiEditGetMaxLength & guiEditIsMasked functions (#255)
1 parent 7fc2950 commit 6622c67

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

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

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ void CLuaGUIDefs::LoadFunctions(void)
126126
CLuaCFunctions::AddFunction("guiEditSetCaretIndex", GUIEditSetCaretIndex);
127127
CLuaCFunctions::AddFunction("guiEditGetCaretIndex", GUIEditGetCaretIndex);
128128
CLuaCFunctions::AddFunction("guiEditSetMasked", GUIEditSetMasked);
129+
CLuaCFunctions::AddFunction("guiEditIsMasked", GUIEditIsMasked);
129130
CLuaCFunctions::AddFunction("guiEditSetMaxLength", GUIEditSetMaxLength);
131+
CLuaCFunctions::AddFunction("guiEditGetMaxLength", GUIEditGetMaxLength);
130132
CLuaCFunctions::AddFunction("guiEditSetReadOnly", GUIEditSetReadOnly);
131133
CLuaCFunctions::AddFunction("guiEditIsReadOnly", GUIEditIsReadOnly);
132134

@@ -281,8 +283,8 @@ void CLuaGUIDefs::AddGuiEditClass(lua_State* luaVM)
281283

282284
lua_classvariable(luaVM, "caretIndex", "guiEditSetCaretIndex", "guiEditGetCaretIndex");
283285
lua_classvariable(luaVM, "readOnly", "guiEditSetReadOnly", "guiEditIsReadOnly");
284-
lua_classvariable(luaVM, "masked", "guiEditSetMasked", NULL);
285-
lua_classvariable(luaVM, "maxLength", "guiEditSetMaxLength", NULL);
286+
lua_classvariable(luaVM, "masked", "guiEditSetMasked", "guiEditIsMasked");
287+
lua_classvariable(luaVM, "maxLength", "guiEditSetMaxLength", "guiEditGetMaxLength");
286288

287289
lua_registerclass(luaVM, "GuiEdit", "GuiElement");
288290
}
@@ -3044,6 +3046,28 @@ int CLuaGUIDefs::GUIEditSetMasked(lua_State* luaVM)
30443046
return 1;
30453047
}
30463048

3049+
int CLuaGUIDefs::GUIEditIsMasked(lua_State* luaVM)
3050+
{
3051+
//bool guiEditIsMasked(element theElement)
3052+
CClientGUIElement* theElement;
3053+
3054+
CScriptArgReader argStream(luaVM);
3055+
argStream.ReadUserData<CGUIEdit>(theElement);
3056+
3057+
if (!argStream.HasErrors())
3058+
{
3059+
bool masked = static_cast<CGUIEdit*>(theElement->GetCGUIElement())->IsMasked();
3060+
lua_pushboolean(luaVM, masked);
3061+
return 1;
3062+
}
3063+
else
3064+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3065+
3066+
// error: bad arguments
3067+
lua_pushnil(luaVM);
3068+
return 1;
3069+
}
3070+
30473071
int CLuaGUIDefs::GUIEditSetMaxLength(lua_State* luaVM)
30483072
{
30493073
// bool guiEditSetMaxLength ( element theElement, int length )
@@ -3068,6 +3092,27 @@ int CLuaGUIDefs::GUIEditSetMaxLength(lua_State* luaVM)
30683092
return 1;
30693093
}
30703094

3095+
int CLuaGUIDefs::GUIEditGetMaxLength(lua_State* luaVM)
3096+
{
3097+
// int guiEditGetMaxLength(element theElement)
3098+
CClientGUIElement* theElement;
3099+
3100+
CScriptArgReader argStream(luaVM);
3101+
argStream.ReadUserData<CGUIEdit>(theElement);
3102+
3103+
if (!argStream.HasErrors())
3104+
{
3105+
lua_pushnumber(luaVM, static_cast<CGUIEdit*>(theElement->GetCGUIElement())->GetMaxLength());
3106+
return 1;
3107+
}
3108+
else
3109+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
3110+
3111+
// error: bad arguments
3112+
lua_pushboolean(luaVM, false);
3113+
return 1;
3114+
}
3115+
30713116
int CLuaGUIDefs::GUIEditSetCaretIndex(lua_State* luaVM)
30723117
{
30733118
// bool guiEditSetCaretIndex ( element theElement, int index )

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ class CLuaGUIDefs : public CLuaDefs
116116
LUA_DECLARE(GUIEditSetReadOnly);
117117
LUA_DECLARE(GUIEditIsReadOnly);
118118
LUA_DECLARE(GUIEditSetMasked);
119+
LUA_DECLARE(GUIEditIsMasked);
119120
LUA_DECLARE(GUIEditSetMaxLength);
121+
LUA_DECLARE(GUIEditGetMaxLength);
120122
LUA_DECLARE(GUIEditSetCaretIndex);
121123
LUA_DECLARE(GUIEditGetCaretIndex);
122124
LUA_DECLARE(GUIMemoSetReadOnly);

0 commit comments

Comments
 (0)