From 9d88498809ece4680317adc58f51450d62fd25e7 Mon Sep 17 00:00:00 2001 From: VDm Date: Mon, 11 Aug 2025 02:13:18 +0400 Subject: [PATCH] feat(gameui): implement Script_GetInventorySlotInfo --- .../scripts/GameScriptFunctionsActionBar.cpp | 15 ++++-- .../GameScriptFunctionsCharacterInfo.cpp | 34 ++++++++++++- .../GameScriptFunctionsScriptEvents.cpp | 48 ++++++++++++++----- .../scripts/GameScriptFunctionsSound.cpp | 16 +++++-- 4 files changed, 92 insertions(+), 21 deletions(-) diff --git a/src/gameui/scripts/GameScriptFunctionsActionBar.cpp b/src/gameui/scripts/GameScriptFunctionsActionBar.cpp index bc3edef..8a398b2 100644 --- a/src/gameui/scripts/GameScriptFunctionsActionBar.cpp +++ b/src/gameui/scripts/GameScriptFunctionsActionBar.cpp @@ -13,7 +13,9 @@ static int32_t Script_GetActionTexture(lua_State* L) { } static int32_t Script_GetActionCount(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_GetActionCooldown(lua_State* L) { @@ -29,7 +31,9 @@ static int32_t Script_GetActionText(lua_State* L) { } static int32_t Script_HasAction(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnil(L); + return 1; } static int32_t Script_UseAction(lua_State* L) { @@ -81,11 +85,14 @@ static int32_t Script_IsActionInRange(lua_State* L) { } static int32_t Script_GetBonusBarOffset(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_GetMultiCastBarOffset(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + lua_pushnumber(L, 6.0); + return 1; } static int32_t Script_ChangeActionBarPage(lua_State* L) { diff --git a/src/gameui/scripts/GameScriptFunctionsCharacterInfo.cpp b/src/gameui/scripts/GameScriptFunctionsCharacterInfo.cpp index 9ff1b34..5110dd3 100644 --- a/src/gameui/scripts/GameScriptFunctionsCharacterInfo.cpp +++ b/src/gameui/scripts/GameScriptFunctionsCharacterInfo.cpp @@ -1,11 +1,43 @@ #include "gameui/GameScriptFunctions.hpp" #include "ui/FrameScript.hpp" +#include "db/Db.hpp" #include "util/Lua.hpp" #include "util/Unimplemented.hpp" static int32_t Script_GetInventorySlotInfo(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + const char* buttonName = nullptr; + + if (lua_isstring(L, 1)) { + buttonName = lua_tolstring(L, 1, nullptr); + } + + if (!buttonName || g_paperDollItemFrameDB.GetNumRecords() < 1) { + return luaL_error(L, "Invalid inventory slot in GetInventorySlotInfo"); + } + + PaperDollItemFrameRec* record = nullptr; + bool found = false; + for (int32_t i = 0; i < g_paperDollItemFrameDB.GetNumRecords(); ++i) { + record = g_paperDollItemFrameDB.GetRecordByIndex(i); + if (!SStrCmpI(record->m_itemButtonName, buttonName, STORM_MAX_STR)) { + found = true; + break; + } + } + + if (!found) { + return luaL_error(L, "Invalid inventory slot in GetInventorySlotInfo"); + } + + lua_pushnumber(L, record->m_slotNumber); + lua_pushstring(L, record->m_slotIcon); + if (record->m_slotNumber == 18) { + lua_pushnumber(L, 1.0); + } else { + lua_pushnil(L); + } + return 3; } static int32_t Script_GetInventoryItemsForSlot(lua_State* L) { diff --git a/src/gameui/scripts/GameScriptFunctionsScriptEvents.cpp b/src/gameui/scripts/GameScriptFunctionsScriptEvents.cpp index 81af2c6..7174dd2 100644 --- a/src/gameui/scripts/GameScriptFunctionsScriptEvents.cpp +++ b/src/gameui/scripts/GameScriptFunctionsScriptEvents.cpp @@ -177,39 +177,57 @@ static int32_t Script_UnitPVPName(lua_State* L) { } static int32_t Script_UnitXP(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 50.0); + return 1; } static int32_t Script_UnitXPMax(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 100.0); + return 1; } static int32_t Script_UnitHealth(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 50.0); + return 1; } static int32_t Script_UnitHealthMax(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 100.0); + return 1; } static int32_t Script_UnitMana(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 50.0); + return 1; } static int32_t Script_UnitManaMax(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 100.0); + return 1; } static int32_t Script_UnitPower(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 50.0); + return 1; } static int32_t Script_UnitPowerMax(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 100.0); + return 1; } static int32_t Script_UnitPowerType(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_UnitOnTaxi(lua_State* L) { @@ -221,15 +239,21 @@ static int32_t Script_UnitIsFeignDeath(lua_State* L) { } static int32_t Script_UnitIsDead(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushboolean(L, 0); + return 1; } static int32_t Script_UnitIsGhost(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushboolean(L, 0); + return 1; } static int32_t Script_UnitIsDeadOrGhost(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushboolean(L, 0); + return 1; } static int32_t Script_UnitIsConnected(lua_State* L) { diff --git a/src/gameui/scripts/GameScriptFunctionsSound.cpp b/src/gameui/scripts/GameScriptFunctionsSound.cpp index 7c16fea..6ce97e0 100644 --- a/src/gameui/scripts/GameScriptFunctionsSound.cpp +++ b/src/gameui/scripts/GameScriptFunctionsSound.cpp @@ -21,7 +21,9 @@ static int32_t Script_StopMusic(lua_State* L) { } static int32_t Script_Sound_GameSystem_GetNumInputDrivers(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_Sound_GameSystem_GetInputDriverNameByIndex(lua_State* L) { @@ -29,7 +31,9 @@ static int32_t Script_Sound_GameSystem_GetInputDriverNameByIndex(lua_State* L) { } static int32_t Script_Sound_GameSystem_GetNumOutputDrivers(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_Sound_GameSystem_GetOutputDriverNameByIndex(lua_State* L) { @@ -41,7 +45,9 @@ static int32_t Script_Sound_GameSystem_RestartSoundSystem(lua_State* L) { } static int32_t Script_Sound_ChatSystem_GetNumInputDrivers(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_Sound_ChatSystem_GetInputDriverNameByIndex(lua_State* L) { @@ -49,7 +55,9 @@ static int32_t Script_Sound_ChatSystem_GetInputDriverNameByIndex(lua_State* L) { } static int32_t Script_Sound_ChatSystem_GetNumOutputDrivers(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnumber(L, 0.0); + return 1; } static int32_t Script_Sound_ChatSystem_GetOutputDriverNameByIndex(lua_State* L) {