mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
chore(ui): prefer lua_tostring macro
This commit is contained in:
parent
1e05398ad8
commit
ea034cb960
@ -20,7 +20,7 @@ int32_t CScriptObject_IsObjectType(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: %s:IsObjectType(\"type\")", name);
|
return luaL_error(L, "Usage: %s:IsObjectType(\"type\")", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto type = lua_tolstring(L, 2, nullptr);
|
auto type = lua_tostring(L, 2);
|
||||||
|
|
||||||
if (object->IsA(type)) {
|
if (object->IsA(type)) {
|
||||||
lua_pushnumber(L, 1.0);
|
lua_pushnumber(L, 1.0);
|
||||||
|
|||||||
@ -200,7 +200,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) {
|
|||||||
|
|
||||||
auto relative = region->GetLayoutParent();
|
auto relative = region->GetLayoutParent();
|
||||||
|
|
||||||
const char* pointStr = lua_tolstring(L, 2, 0);
|
const char* pointStr = lua_tostring(L, 2);
|
||||||
FRAMEPOINT point;
|
FRAMEPOINT point;
|
||||||
|
|
||||||
if (!StringToFramePoint(pointStr, point)) {
|
if (!StringToFramePoint(pointStr, point)) {
|
||||||
@ -210,7 +210,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) {
|
|||||||
int32_t argsIndex = 3;
|
int32_t argsIndex = 3;
|
||||||
|
|
||||||
if (lua_type(L, 3) == LUA_TSTRING) {
|
if (lua_type(L, 3) == LUA_TSTRING) {
|
||||||
const char* name = lua_tolstring(L, 3, 0);
|
const char* name = lua_tostring(L, 3);
|
||||||
relative = region->GetLayoutFrameByName(name);
|
relative = region->GetLayoutFrameByName(name);
|
||||||
|
|
||||||
argsIndex++;
|
argsIndex++;
|
||||||
@ -230,7 +230,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!relative) {
|
if (!relative) {
|
||||||
const char* name = lua_tolstring(L, 3, 0);
|
const char* name = lua_tostring(L, 3);
|
||||||
return luaL_error(L, "%s:SetPoint(): Couldn't find region named '%s'", region->GetDisplayName(), name);
|
return luaL_error(L, "%s:SetPoint(): Couldn't find region named '%s'", region->GetDisplayName(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ int32_t CScriptRegion_SetPoint(lua_State* L) {
|
|||||||
FRAMEPOINT relativePoint = point;
|
FRAMEPOINT relativePoint = point;
|
||||||
|
|
||||||
if (lua_type(L, argsIndex) == LUA_TSTRING) {
|
if (lua_type(L, argsIndex) == LUA_TSTRING) {
|
||||||
const char* relativePointStr = lua_tolstring(L, argsIndex, 0);
|
const char* relativePointStr = lua_tostring(L, argsIndex);
|
||||||
|
|
||||||
if (!StringToFramePoint(relativePointStr, relativePoint)) {
|
if (!StringToFramePoint(relativePointStr, relativePoint)) {
|
||||||
return luaL_error(L, "%s:SetPoint(): Unknown region point", region->GetDisplayName());
|
return luaL_error(L, "%s:SetPoint(): Unknown region point", region->GetDisplayName());
|
||||||
@ -289,7 +289,7 @@ int32_t CScriptRegion_SetAllPoints(lua_State* L) {
|
|||||||
auto relative = region->GetLayoutParent();
|
auto relative = region->GetLayoutParent();
|
||||||
|
|
||||||
if (lua_isstring(L, 2)) {
|
if (lua_isstring(L, 2)) {
|
||||||
const char* name = lua_tolstring(L, 2, 0);
|
const char* name = lua_tostring(L, 2);
|
||||||
relative = region->GetLayoutFrameByName(name);
|
relative = region->GetLayoutFrameByName(name);
|
||||||
} else if (lua_type(L, 2) == LUA_TTABLE) {
|
} else if (lua_type(L, 2) == LUA_TTABLE) {
|
||||||
lua_rawgeti(L, 2, 0);
|
lua_rawgeti(L, 2, 0);
|
||||||
@ -303,7 +303,7 @@ int32_t CScriptRegion_SetAllPoints(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!relative) {
|
if (!relative) {
|
||||||
const char* name = lua_tolstring(L, 2, 0);
|
const char* name = lua_tostring(L, 2);
|
||||||
return luaL_error(L, "%s:SetAllPoints(): Couldn't find region named '%s'", region->GetDisplayName(), name);
|
return luaL_error(L, "%s:SetAllPoints(): Couldn't find region named '%s'", region->GetDisplayName(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ int32_t CSimpleButton_SetStateTexture(lua_State* L, CSimpleButtonState state, co
|
|||||||
button->SetStateTexture(state, texture);
|
button->SetStateTexture(state, texture);
|
||||||
|
|
||||||
} else if (lua_isstring(L, 2)) {
|
} else if (lua_isstring(L, 2)) {
|
||||||
auto texFile = lua_tolstring(L, 2, nullptr);
|
auto texFile = lua_tostring(L, 2);
|
||||||
button->SetStateTexture(state, texFile);
|
button->SetStateTexture(state, texFile);
|
||||||
|
|
||||||
} else if (lua_type(L, 2) == LUA_TNIL) {
|
} else if (lua_type(L, 2) == LUA_TNIL) {
|
||||||
@ -135,7 +135,7 @@ int32_t CSimpleButton_SetText(lua_State* L) {
|
|||||||
auto type = CSimpleButton::GetObjectType();
|
auto type = CSimpleButton::GetObjectType();
|
||||||
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
const char* text = lua_tolstring(L, 2, 0);
|
const char* text = lua_tostring(L, 2);
|
||||||
button->SetText(text);
|
button->SetText(text);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -190,7 +190,7 @@ int32_t CSimpleButton_SetHighlightTexture(lua_State* L) {
|
|||||||
|
|
||||||
EGxBlend blendMode = GxBlend_Add;
|
EGxBlend blendMode = GxBlend_Add;
|
||||||
if (lua_isstring(L, 3)) {
|
if (lua_isstring(L, 3)) {
|
||||||
auto blendString = lua_tolstring(L, 3, nullptr);
|
auto blendString = lua_tostring(L, 3);
|
||||||
StringToBlendMode(blendString, blendMode);
|
StringToBlendMode(blendString, blendMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ int32_t CSimpleButton_SetHighlightTexture(lua_State* L) {
|
|||||||
button->SetHighlight(texture, blendMode);
|
button->SetHighlight(texture, blendMode);
|
||||||
|
|
||||||
} else if (lua_isstring(L, 2)) {
|
} else if (lua_isstring(L, 2)) {
|
||||||
auto texFile = lua_tolstring(L, 2, nullptr);
|
auto texFile = lua_tostring(L, 2);
|
||||||
button->SetHighlight(texFile, blendMode);
|
button->SetHighlight(texFile, blendMode);
|
||||||
|
|
||||||
} else if (lua_type(L, 2) == LUA_TNIL) {
|
} else if (lua_type(L, 2) == LUA_TNIL) {
|
||||||
@ -277,7 +277,7 @@ int32_t CSimpleButton_RegisterForClicks(lua_State* L) {
|
|||||||
uint64_t action = 0;
|
uint64_t action = 0;
|
||||||
|
|
||||||
for (int32_t i = 2; lua_isstring(L, i); i++) {
|
for (int32_t i = 2; lua_isstring(L, i); i++) {
|
||||||
auto actionStr = lua_tolstring(L, i, nullptr);
|
auto actionStr = lua_tostring(L, i);
|
||||||
action |= StringToClickAction(actionStr);
|
action |= StringToClickAction(actionStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ int32_t CSimpleButton_Click(lua_State* L) {
|
|||||||
|
|
||||||
auto inputButton = "LeftButton";
|
auto inputButton = "LeftButton";
|
||||||
if (lua_isstring(L, 2)) {
|
if (lua_isstring(L, 2)) {
|
||||||
inputButton = lua_tolstring(L, 2, nullptr);
|
inputButton = lua_tostring(L, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto v6 = StringToBOOL(L, 3, 0);
|
auto v6 = StringToBOOL(L, 3, 0);
|
||||||
|
|||||||
@ -86,7 +86,7 @@ int32_t CSimpleFontString_SetFontObject(lua_State* L) {
|
|||||||
luaL_error(L, "%s:SetFontObject(): Wrong object type, expected font", string->GetDisplayName());
|
luaL_error(L, "%s:SetFontObject(): Wrong object type, expected font", string->GetDisplayName());
|
||||||
}
|
}
|
||||||
} else if (lua_type(L, 2) == LUA_TSTRING) {
|
} else if (lua_type(L, 2) == LUA_TSTRING) {
|
||||||
auto fontName = lua_tolstring(L, 2, nullptr);
|
auto fontName = lua_tostring(L, 2);
|
||||||
font = CSimpleFont::GetFont(fontName, 0);
|
font = CSimpleFont::GetFont(fontName, 0);
|
||||||
|
|
||||||
if (!font) {
|
if (!font) {
|
||||||
@ -125,7 +125,7 @@ int32_t CSimpleFontString_SetText(lua_State* L) {
|
|||||||
luaL_error(L, "%s:SetText(): Font not set", string->GetDisplayName());
|
luaL_error(L, "%s:SetText(): Font not set", string->GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* text = lua_tolstring(L, 2, 0);
|
const char* text = lua_tostring(L, 2);
|
||||||
string->SetText(text, 1);
|
string->SetText(text, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -144,7 +144,7 @@ int32_t CSimpleFrame_RegisterEvent(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: %s:RegisterEvent(\"event\")", frame->GetDisplayName());
|
return luaL_error(L, "Usage: %s:RegisterEvent(\"event\")", frame->GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* event = lua_tolstring(L, 2, 0);
|
const char* event = lua_tostring(L, 2);
|
||||||
|
|
||||||
frame->RegisterScriptEvent(event);
|
frame->RegisterScriptEvent(event);
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ int32_t CSimpleHTML_SetText(lua_State* L) {
|
|||||||
auto type = CSimpleHTML::GetObjectType();
|
auto type = CSimpleHTML::GetObjectType();
|
||||||
auto html = static_cast<CSimpleHTML*>(FrameScript_GetObjectThis(L, type));
|
auto html = static_cast<CSimpleHTML*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
auto text = lua_tolstring(L, 2, nullptr);
|
auto text = lua_tostring(L, 2);
|
||||||
html->SetText(text, nullptr);
|
html->SetText(text, nullptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ int32_t CSimpleModel_SetModel(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: %s:SetModel(\"file\")", model->GetDisplayName());
|
return luaL_error(L, "Usage: %s:SetModel(\"file\")", model->GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* file = lua_tolstring(L, 2, 0);
|
const char* file = lua_tostring(L, 2);
|
||||||
|
|
||||||
model->SetModel(file);
|
model->SetModel(file);
|
||||||
|
|
||||||
|
|||||||
@ -132,7 +132,7 @@ int32_t CSimpleTexture_SetTexture(lua_State* L) {
|
|||||||
|
|
||||||
bool v5 = lua_toboolean(L, 3);
|
bool v5 = lua_toboolean(L, 3);
|
||||||
bool v6 = lua_toboolean(L, 3);
|
bool v6 = lua_toboolean(L, 3);
|
||||||
const char* v7 = lua_tolstring(L, 2, 0);
|
const char* v7 = lua_tostring(L, 2);
|
||||||
|
|
||||||
if (texture->SetTexture(v7, v6, v5, CSimpleTexture::s_textureFilterMode, ImageMode_UI)) {
|
if (texture->SetTexture(v7, v6, v5, CSimpleTexture::s_textureFilterMode, ImageMode_UI)) {
|
||||||
lua_pushnumber(L, 1.0);
|
lua_pushnumber(L, 1.0);
|
||||||
|
|||||||
@ -122,7 +122,7 @@ int32_t FrameScript_CompileFunction(const char* name, const char* wrapper, const
|
|||||||
|
|
||||||
if (luaL_loadbuffer(L, function, SStrLen(function), name)) {
|
if (luaL_loadbuffer(L, function, SStrLen(function), name)) {
|
||||||
if (status) {
|
if (status) {
|
||||||
const char* v10 = lua_tolstring(L, -1, 0);
|
const char* v10 = lua_tostring(L, -1);
|
||||||
status->Add(STATUS_ERROR, "%s", v10);
|
status->Add(STATUS_ERROR, "%s", v10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ int32_t FrameScript_CompileFunction(const char* name, const char* wrapper, const
|
|||||||
return -1;
|
return -1;
|
||||||
} else if (lua_pcall(L, 0, 1, -2)) {
|
} else if (lua_pcall(L, 0, 1, -2)) {
|
||||||
if (status) {
|
if (status) {
|
||||||
const char* v13 = lua_tolstring(L, -1, 0);
|
const char* v13 = lua_tostring(L, -1);
|
||||||
status->Add(STATUS_ERROR, "%s", v13);
|
status->Add(STATUS_ERROR, "%s", v13);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ int32_t FrameScript_ExecuteBuffer(const char* buffer, size_t bufferBytes, const
|
|||||||
|
|
||||||
if (luaL_loadbuffer(L, buffer, bufferBytes, bufferName)) {
|
if (luaL_loadbuffer(L, buffer, bufferBytes, bufferName)) {
|
||||||
if (status) {
|
if (status) {
|
||||||
const char* v7 = lua_tolstring(L, -1, 0);
|
const char* v7 = lua_tostring(L, -1);
|
||||||
status->Add(STATUS_ERROR, "%s", v7);
|
status->Add(STATUS_ERROR, "%s", v7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ int32_t FrameScript_ExecuteBuffer(const char* buffer, size_t bufferBytes, const
|
|||||||
|
|
||||||
if (lua_pcall(L, v9, 0, -2 - v9)) {
|
if (lua_pcall(L, v9, 0, -2 - v9)) {
|
||||||
if (status) {
|
if (status) {
|
||||||
const char* v11 = lua_tolstring(L, -1, 0);
|
const char* v11 = lua_tostring(L, -1);
|
||||||
status->Add(STATUS_ERROR, "%s", v11);
|
status->Add(STATUS_ERROR, "%s", v11);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ int32_t FrameScript_GetVariable(const char* a1, const char** a2) {
|
|||||||
|
|
||||||
if (lua_isstring(L, -1)) {
|
if (lua_isstring(L, -1)) {
|
||||||
v3 = 1;
|
v3 = 1;
|
||||||
*a2 = lua_tolstring(L, -1, 0);
|
*a2 = lua_tostring(L, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_settop(L, -2);
|
lua_settop(L, -2);
|
||||||
@ -591,7 +591,7 @@ int32_t FrameScript_HandleError(lua_State* L) {
|
|||||||
lua_insert(L, -1);
|
lua_insert(L, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* v1 = lua_tolstring(L, -1, 0);
|
const char* v1 = lua_tostring(L, -1);
|
||||||
const char* v2 = SStrStr(v1, "*:");
|
const char* v2 = SStrStr(v1, "*:");
|
||||||
const char* objName = FrameScript_GetCurrentObject(L, 1);
|
const char* objName = FrameScript_GetCurrentObject(L, 1);
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ int32_t Script_SetCharSelectModelFrame(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto type = CSimpleModel::GetObjectType();
|
auto type = CSimpleModel::GetObjectType();
|
||||||
auto name = lua_tolstring(L, 1, nullptr);
|
auto name = lua_tostring(L, 1);
|
||||||
auto frame = CScriptObject::GetScriptObjectByName(name, type);
|
auto frame = CScriptObject::GetScriptObjectByName(name, type);
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
@ -29,7 +29,7 @@ int32_t Script_SetCharSelectBackground(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: SetCharSelectBackground(\"filename\")");
|
return luaL_error(L, "Usage: SetCharSelectBackground(\"filename\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto modelPath = lua_tolstring(L, 1, nullptr);
|
auto modelPath = lua_tostring(L, 1);
|
||||||
CCharacterSelection::SetBackgroundModel(modelPath);
|
CCharacterSelection::SetBackgroundModel(modelPath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -68,7 +68,7 @@ int32_t Script_SetCurrentScreen(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: SetCurrentScreen(\"screen\")");
|
return luaL_error(L, "Usage: SetCurrentScreen(\"screen\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto screen = lua_tolstring(L, 1, nullptr);
|
auto screen = lua_tostring(L, 1);
|
||||||
CGlueMgr::UpdateCurrentScreen(screen);
|
CGlueMgr::UpdateCurrentScreen(screen);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@ -200,8 +200,8 @@ int32_t Script_DefaultServerLogin(lua_State* L) {
|
|||||||
luaL_error(L, "Usage: DefaultServerLogin(\"accountName\", \"password\")");
|
luaL_error(L, "Usage: DefaultServerLogin(\"accountName\", \"password\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto accountName = lua_tolstring(L, 1, nullptr);
|
auto accountName = lua_tostring(L, 1);
|
||||||
auto password = lua_tolstring(L, 2, nullptr);
|
auto password = lua_tostring(L, 2);
|
||||||
|
|
||||||
CGlueMgr::LoginServerLogin(accountName, password);
|
CGlueMgr::LoginServerLogin(accountName, password);
|
||||||
|
|
||||||
|
|||||||
@ -30,9 +30,9 @@ int32_t Script_CreateFrame(lua_State* L) {
|
|||||||
return luaL_error(L, "Usage: CreateFrame(\"frameType\" [, \"name\"] [, parent] [, \"template\"] [, id])");
|
return luaL_error(L, "Usage: CreateFrame(\"frameType\" [, \"name\"] [, parent] [, \"template\"] [, id])");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* v21 = lua_tolstring(L, 1, 0);
|
const char* v21 = lua_tostring(L, 1);
|
||||||
const char* v3 = lua_tolstring(L, 2, 0);
|
const char* v3 = lua_tostring(L, 2);
|
||||||
const char* inherits = lua_tolstring(L, 4, 0);
|
const char* inherits = lua_tostring(L, 4);
|
||||||
|
|
||||||
CSimpleFrame* parent = nullptr;
|
CSimpleFrame* parent = nullptr;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int32_t Script_CreateFrame(lua_State* L) {
|
|||||||
|
|
||||||
// If inherits argument is provided, ensure all inherited nodes exist
|
// If inherits argument is provided, ensure all inherited nodes exist
|
||||||
if (lua_type(L, 4) == LUA_TSTRING) {
|
if (lua_type(L, 4) == LUA_TSTRING) {
|
||||||
inherits = lua_tolstring(L, 4, 0);
|
inherits = lua_tostring(L, 4);
|
||||||
|
|
||||||
char inheritName[1024];
|
char inheritName[1024];
|
||||||
const char* unk1;
|
const char* unk1;
|
||||||
@ -79,7 +79,7 @@ int32_t Script_CreateFrame(lua_State* L) {
|
|||||||
FrameXML_ReleaseHashNode(inheritName);
|
FrameXML_ReleaseHashNode(inheritName);
|
||||||
} while (*inheritName);
|
} while (*inheritName);
|
||||||
|
|
||||||
inherits = lua_tolstring(L, 4, 0);
|
inherits = lua_tostring(L, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build an XMLNode simulating the arguments to CreateFrame()
|
// Build an XMLNode simulating the arguments to CreateFrame()
|
||||||
@ -100,7 +100,7 @@ int32_t Script_CreateFrame(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lua_isstring(L, 5)) {
|
if (lua_isstring(L, 5)) {
|
||||||
const char* idStr = lua_tolstring(L, 5, nullptr);
|
const char* idStr = lua_tostring(L, 5);
|
||||||
frameNode.SetAttribute("id", idStr);
|
frameNode.SetAttribute("id", idStr);
|
||||||
} else if (lua_isnumber(L, 5)) {
|
} else if (lua_isnumber(L, 5)) {
|
||||||
int32_t idNum = lua_tointeger(L, 5);
|
int32_t idNum = lua_tointeger(L, 5);
|
||||||
|
|||||||
@ -99,7 +99,7 @@ bool StringToBOOL(lua_State* L, int32_t idx, int32_t def) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
str = lua_tolstring(L, idx, 0);
|
str = lua_tostring(L, idx);
|
||||||
result = StringToBOOL(str, def);
|
result = StringToBOOL(str, def);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user