Compare commits

..

7 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
46b387c19f
Merge a82628adaa into 7d911e453d 2026-02-03 19:00:21 -05:00
fallenoak
7d911e453d
feat(ui): implement Script_GetActionBarPage
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-03 17:11:18 -06:00
fallenoak
d34336cd7e
feat(ui): add ActionBarRegisterScriptFunctions 2026-02-03 17:03:59 -06:00
fallenoak
3bf95af10c
feat(ui): implement CSimpleTexture_SetDrawLayer
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-03 16:24:09 -06:00
fallenoak
0681e432e2
feat(ui): handle 3 argument form in CSimpleFrame_GetAttribute 2026-02-03 14:57:22 -06:00
fallenoak
66fd4a6564
feat(ui): implement CSimpleFrame_SetAttribute 2026-02-03 10:13:08 -06:00
fallenoak
c201da76cd
feat(ui): partially implement CSimpleFrame_GetAttribute 2026-02-03 09:40:46 -06:00
9 changed files with 404 additions and 3 deletions

View File

@ -0,0 +1,164 @@
#include "ui/game/ActionBarScript.hpp"
#include "ui/FrameScript.hpp"
#include "ui/game/CGActionBar.hpp"
#include "util/Lua.hpp"
#include "util/Unimplemented.hpp"
namespace {
int32_t Script_GetActionInfo(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionTexture(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionCount(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionCooldown(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionAutocast(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionText(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_HasAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_UseAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_PickupAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_PlaceAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsAttackAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsCurrentAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsAutoRepeatAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsUsableAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsConsumableAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsStackableAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsEquippedAction(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_ActionHasRange(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsActionInRange(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetBonusBarOffset(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetMultiCastBarOffset(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_ChangeActionBarPage(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetActionBarPage(lua_State* L) {
if (CGActionBar::s_tempPageActiveFlags) {
lua_pushinteger(L, 1);
} else {
lua_pushinteger(L, CGActionBar::s_currentPage + 1);
}
return 1;
}
int32_t Script_GetActionBarToggles(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_SetActionBarToggles(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_IsPossessBarVisible(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_GetMultiCastTotemSpells(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
int32_t Script_SetMultiCastSpell(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
}
}
static FrameScript_Method s_ScriptFunctions[] = {
{ "GetActionInfo", &Script_GetActionInfo },
{ "GetActionTexture", &Script_GetActionTexture },
{ "GetActionCount", &Script_GetActionCount },
{ "GetActionCooldown", &Script_GetActionCooldown },
{ "GetActionAutocast", &Script_GetActionAutocast },
{ "GetActionText", &Script_GetActionText },
{ "HasAction", &Script_HasAction },
{ "UseAction", &Script_UseAction },
{ "PickupAction", &Script_PickupAction },
{ "PlaceAction", &Script_PlaceAction },
{ "IsAttackAction", &Script_IsAttackAction },
{ "IsCurrentAction", &Script_IsCurrentAction },
{ "IsAutoRepeatAction", &Script_IsAutoRepeatAction },
{ "IsUsableAction", &Script_IsUsableAction },
{ "IsConsumableAction", &Script_IsConsumableAction },
{ "IsStackableAction", &Script_IsStackableAction },
{ "IsEquippedAction", &Script_IsEquippedAction },
{ "ActionHasRange", &Script_ActionHasRange },
{ "IsActionInRange", &Script_IsActionInRange },
{ "GetBonusBarOffset", &Script_GetBonusBarOffset },
{ "GetMultiCastBarOffset", &Script_GetMultiCastBarOffset },
{ "ChangeActionBarPage", &Script_ChangeActionBarPage },
{ "GetActionBarPage", &Script_GetActionBarPage },
{ "GetActionBarToggles", &Script_GetActionBarToggles },
{ "SetActionBarToggles", &Script_SetActionBarToggles },
{ "IsPossessBarVisible", &Script_IsPossessBarVisible },
{ "GetMultiCastTotemSpells", &Script_GetMultiCastTotemSpells },
{ "SetMultiCastSpell", &Script_SetMultiCastSpell },
};
void ActionBarRegisterScriptFunctions() {
for (auto& func : s_ScriptFunctions) {
FrameScript_RegisterFunction(func.name, func.method);
}
}

View File

@ -0,0 +1,6 @@
#ifndef UI_GAME_ACTION_BAR_SCRIPT_HPP
#define UI_GAME_ACTION_BAR_SCRIPT_HPP
void ActionBarRegisterScriptFunctions();
#endif

View File

@ -0,0 +1,4 @@
#include "ui/game/CGActionBar.hpp"
uint32_t CGActionBar::s_currentPage;
uint32_t CGActionBar::s_tempPageActiveFlags;

View File

@ -0,0 +1,13 @@
#ifndef UI_GAME_C_G_ACTION_BAR_HPP
#define UI_GAME_C_G_ACTION_BAR_HPP
#include <cstdint>
class CGActionBar {
public:
// Static variables
static uint32_t s_currentPage;
static uint32_t s_tempPageActiveFlags;
};
#endif

View File

@ -3,6 +3,7 @@
#include "ui/CScriptObject.hpp" #include "ui/CScriptObject.hpp"
#include "ui/FrameXML.hpp" #include "ui/FrameXML.hpp"
#include "ui/Key.hpp" #include "ui/Key.hpp"
#include "ui/game/ActionBarScript.hpp"
#include "ui/game/BattlefieldInfoScript.hpp" #include "ui/game/BattlefieldInfoScript.hpp"
#include "ui/game/CGCharacterModelBase.hpp" #include "ui/game/CGCharacterModelBase.hpp"
#include "ui/game/CGCooldown.hpp" #include "ui/game/CGCooldown.hpp"
@ -46,6 +47,10 @@ void LoadScriptFunctions() {
// TODO // TODO
ActionBarRegisterScriptFunctions();
// TODO
CharacterInfoRegisterScriptFunctions(); CharacterInfoRegisterScriptFunctions();
// TODO // TODO

View File

@ -95,6 +95,10 @@ void CSimpleFrame::AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer) {
this->NotifyDrawLayerChanged(drawlayer); this->NotifyDrawLayerChanged(drawlayer);
} }
int32_t CSimpleFrame::AttributeChangesAllowed() {
return true;
}
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) { void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
this->m_drawenabled[drawlayer] = 0; this->m_drawenabled[drawlayer] = 0;
this->NotifyDrawLayerChanged(drawlayer); this->NotifyDrawLayerChanged(drawlayer);

View File

@ -128,6 +128,7 @@ class CSimpleFrame : public CScriptRegion {
// Member functions // Member functions
CSimpleFrame(CSimpleFrame* parent); CSimpleFrame(CSimpleFrame* parent);
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer); void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
int32_t AttributeChangesAllowed();
void DisableDrawLayer(uint32_t drawlayer); void DisableDrawLayer(uint32_t drawlayer);
void DisableEvent(CSimpleEventType eventType); void DisableEvent(CSimpleEventType eventType);
void EnableDrawLayer(uint32_t drawlayer); void EnableDrawLayer(uint32_t drawlayer);

View File

@ -180,11 +180,197 @@ int32_t CSimpleFrame_CanChangeAttributes(lua_State* L) {
} }
int32_t CSimpleFrame_GetAttribute(lua_State* L) { int32_t CSimpleFrame_GetAttribute(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleFrame::GetObjectType();
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
// 3 argument form
if (lua_gettop(L) == 4 && lua_isstring(L, 3)) {
size_t prefixLen, nameLen, suffixLen;
auto prefix = lua_tolstring(L, 2, &prefixLen);
auto name = lua_tolstring(L, 3, &nameLen);
auto suffix = lua_tolstring(L, 4, &suffixLen);
char buffer[256];
char* write;
size_t remaining;
size_t copyLen;
int32_t luaRef;
// Attempt 1: prefix + name + suffix
write = buffer;
remaining = 255;
if (prefixLen > 0) {
copyLen = (prefixLen < remaining) ? prefixLen : remaining;
memcpy(write, prefix, copyLen);
write += copyLen;
remaining -= copyLen;
}
if (nameLen > 0) {
copyLen = (nameLen < remaining) ? nameLen : remaining;
memcpy(write, name, copyLen);
write += copyLen;
remaining -= copyLen;
}
if (suffixLen > 0) {
copyLen = (suffixLen < remaining) ? suffixLen : remaining;
memcpy(write, suffix, copyLen);
write += copyLen;
}
*write = '\0';
if (frame->GetAttribute(buffer, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Attempt 2: "*" + name + suffix
write = buffer;
*write++ = '*';
remaining = 254;
if (nameLen > 0) {
copyLen = (nameLen < remaining) ? nameLen : remaining;
memcpy(write, name, copyLen);
write += copyLen;
remaining -= copyLen;
}
if (suffixLen > 0) {
copyLen = (suffixLen < remaining) ? suffixLen : remaining;
memcpy(write, suffix, copyLen);
write += copyLen;
}
*write = '\0';
if (frame->GetAttribute(buffer, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Attempt 3: prefix + name + "*"
write = buffer;
remaining = 254;
if (prefixLen > 0) {
copyLen = (prefixLen < remaining) ? prefixLen : remaining;
memcpy(write, prefix, copyLen);
write += copyLen;
remaining -= copyLen;
}
if (nameLen > 0) {
copyLen = (nameLen < remaining) ? nameLen : remaining;
memcpy(write, name, copyLen);
write += copyLen;
}
*write++ = '*';
*write = '\0';
if (frame->GetAttribute(buffer, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Attempt 4: "*" + name + "*"
write = buffer;
*write++ = '*';
remaining = 253;
if (nameLen > 0) {
copyLen = (nameLen < remaining) ? nameLen : remaining;
memcpy(write, name, copyLen);
write += copyLen;
}
*write++ = '*';
*write = '\0';
if (frame->GetAttribute(buffer, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Attempt 5: name
if (frame->GetAttribute(name, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Not found
lua_pushnil(L);
return 1;
}
// 1 argument form
if (lua_isstring(L, 2)) {
auto attrName = lua_tostring(L, 2);
int32_t luaRef;
if (frame->GetAttribute(attrName, luaRef)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
return 1;
}
// Not found
lua_pushnil(L);
return 1;
}
// Invalid call
luaL_error(L, "Usage: %s:GetAttribute(\"name\")", frame->GetDisplayName());
return 0;
} }
int32_t CSimpleFrame_SetAttribute(lua_State* L) { int32_t CSimpleFrame_SetAttribute(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleFrame::GetObjectType();
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
if (!frame->ProtectedFunctionsAllowed() && !frame->AttributeChangesAllowed()) {
// TODO disallowed logic
return 0;
}
lua_settop(L, 3);
if (!lua_isstring(L, 2) || lua_type(L, 3) == LUA_TNONE) {
luaL_error(L, "Usage: %s:SetAttribute(\"name\", value)", frame->GetDisplayName());
return 0;
}
auto attrName = lua_tostring(L, 2);
int32_t luaRef;
if (frame->GetAttribute(attrName, luaRef)) {
luaL_unref(L, LUA_REGISTRYINDEX, luaRef);
}
// TODO taint management
luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
// TODO taint management
frame->SetAttribute(attrName, luaRef);
return 0;
} }
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) { int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {

View File

@ -19,7 +19,25 @@ int32_t CSimpleTexture_GetDrawLayer(lua_State* L) {
} }
int32_t CSimpleTexture_SetDrawLayer(lua_State* L) { int32_t CSimpleTexture_SetDrawLayer(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleTexture::GetObjectType();
auto texture = static_cast<CSimpleTexture*>(FrameScript_GetObjectThis(L, type));
if (!lua_isstring(L, 2)) {
luaL_error(L, "Usage: %s:SetDrawLayer(\"layer\")", texture->GetDisplayName());
return 0;
}
auto drawlayerStr = lua_tostring(L, 2);
int32_t drawlayer = texture->m_drawlayer;
if (!StringToDrawLayer(drawlayerStr, drawlayer)) {
luaL_error(L, "Usage: %s:SetDrawLayer(\"layer\")", texture->GetDisplayName());
return 0;
}
texture->SetFrame(texture->m_parent, drawlayer, texture->m_shown);
return 0;
} }
int32_t CSimpleTexture_GetBlendMode(lua_State* L) { int32_t CSimpleTexture_GetBlendMode(lua_State* L) {