Compare commits

...

8 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
Tristan Cormier
a82628adaa feat(glue): implement Script_DeleteCharacter 2026-01-05 22:35:20 -05:00
16 changed files with 452 additions and 5 deletions

View File

@ -160,6 +160,10 @@ ClientConnection* ClientServices::Connection() {
return ClientServices::s_currentConnection;
}
void ClientServices::CharacterDelete(uint64_t guid) {
ClientServices::Connection()->RequestCharacterDelete(guid);
}
void ClientServices::Disconnect() {
ClientServices::Connection()->Disconnect();
}

View File

@ -33,6 +33,7 @@ class ClientServices : public LoginResponse {
// Static functions
static void ConnectToSelectedServer();
static ClientConnection* Connection();
static void CharacterDelete(uint64_t guid);
static void Disconnect();
static const char* GetCurrentLoginPortal();
static const char* GetCurrentLoginServer();

View File

@ -1,4 +1,5 @@
#include "glue/CCharacterSelectionScript.hpp"
#include "CGlueMgr.hpp"
#include "db/Db.hpp"
#include "glue/CCharacterSelection.hpp"
#include "object/client/CGUnit_C.hpp"
@ -157,7 +158,17 @@ int32_t Script_SelectCharacter(lua_State* L) {
}
int32_t Script_DeleteCharacter(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (!lua_isnumber(L, 1)) {
luaL_error(L, "Usage: DeleteCharacter(index)");
}
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
if (index >= 0 && index < CCharacterSelection::s_characterList.Count()) {
CGlueMgr::DeleteCharacter(CCharacterSelection::s_characterList.m_data[index].m_info.guid);
}
return 0;
}
int32_t Script_RenameCharacter(lua_State* L) {

View File

@ -129,6 +129,17 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
ClientServices::Connection()->Connect();
}
void CGlueMgr::DeleteCharacter(uint64_t guid) {
if (guid) {
CGlueMgr::SetIdleState(IDLE_DELETE_CHARACTER);
auto text = FrameScript_GetText(ClientServices::GetErrorToken(70), -1, GENDER_NOT_APPLICABLE);
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "CANCEL", text);
ClientServices::CharacterDelete(guid);
}
}
void CGlueMgr::EnterWorld() {
if (!ClientServices::GetSelectedRealm()) {
return;

View File

@ -66,6 +66,7 @@ class CGlueMgr {
// Static functions
static void CancelRealmListQuery();
static void ChangeRealm(const REALM_INFO* realmInfo);
static void DeleteCharacter(uint64_t guid);
static void DisplayLoginStatus();
static void EnterWorld();
static void GetCharacterList();

View File

@ -1,6 +1,7 @@
#include "net/connection/ClientConnection.hpp"
#include "net/Login.hpp"
#include "client/ClientServices.hpp"
#include "common/datastore/CDataStore.hpp"
#include "net/Login.hpp"
#include "ui/FrameScript.hpp"
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
@ -160,3 +161,19 @@ int32_t ClientConnection::PollStatus(WOWCS_OPS& op, const char** msg, int32_t& r
return this->m_statusComplete;
}
void ClientConnection::RequestCharacterDelete(uint64_t guid) {
this->Initiate(COP_DELETE_CHARACTER, 70, nullptr);
if (this->IsConnected()) {
CDataStore netMsg;
netMsg.Put(static_cast<uint32_t>(CMSG_CHAR_DELETE));
netMsg.Put(guid);
netMsg.Finalize();
this->Send(&netMsg);
}
else {
this->Cancel(4);
}
}

View File

@ -43,6 +43,7 @@ class ClientConnection : public RealmConnection {
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
int32_t IsConnected();
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
void RequestCharacterDelete(uint64_t guid);
};
#endif

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

View File

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

View File

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

View File

@ -19,7 +19,25 @@ int32_t CSimpleTexture_GetDrawLayer(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) {