mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 13:56:05 +03:00
feat(ui): implement CSimpleFrame::LoadXML_Attributes
This commit is contained in:
parent
b76a9fed82
commit
88f2cb7e5f
@ -24,7 +24,7 @@ class CGTooltip : public CSimpleFrame {
|
|||||||
virtual int32_t GetScriptMetaTable();
|
virtual int32_t GetScriptMetaTable();
|
||||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
|
|
||||||
// Members
|
// Member variables
|
||||||
ScriptIx m_onTooltipSetDefaultAnchor;
|
ScriptIx m_onTooltipSetDefaultAnchor;
|
||||||
ScriptIx m_onTooltipCleared;
|
ScriptIx m_onTooltipCleared;
|
||||||
ScriptIx m_onTooltipAddMoney;
|
ScriptIx m_onTooltipAddMoney;
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include "gameui/CGTabardModelFrame.hpp"
|
#include "gameui/CGTabardModelFrame.hpp"
|
||||||
#include "gameui/CGQuestPOIFrame.hpp"
|
#include "gameui/CGQuestPOIFrame.hpp"
|
||||||
#include "console/Console.hpp"
|
#include "console/Console.hpp"
|
||||||
|
#include "gx/CGVideoOptions.hpp"
|
||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
@ -1690,6 +1691,7 @@ void LoadScriptFunctions() {
|
|||||||
GlyphInfoRegisterScriptFunctions();
|
GlyphInfoRegisterScriptFunctions();
|
||||||
AchievementInfoRegisterScriptFunctions();
|
AchievementInfoRegisterScriptFunctions();
|
||||||
CurrencyTypesRegisterScriptFunctions();
|
CurrencyTypesRegisterScriptFunctions();
|
||||||
|
CGVideoOptions::RegisterScriptFunctions();
|
||||||
EquipmentManagerRegisterScriptFunctions();
|
EquipmentManagerRegisterScriptFunctions();
|
||||||
GMTicketInfoRegisterScriptFunctions();
|
GMTicketInfoRegisterScriptFunctions();
|
||||||
BattlenetUIRegisterScriptFunctions();
|
BattlenetUIRegisterScriptFunctions();
|
||||||
|
|||||||
@ -5,11 +5,15 @@
|
|||||||
|
|
||||||
|
|
||||||
static int32_t Script_GetNumPartyMembers(lua_State* L) {
|
static int32_t Script_GetNumPartyMembers(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
// TODO
|
||||||
|
lua_pushnumber(L, 0.0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetRealNumPartyMembers(lua_State* L) {
|
static int32_t Script_GetRealNumPartyMembers(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
// TODO
|
||||||
|
lua_pushnumber(L, 0.0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetPartyMember(lua_State* L) {
|
static int32_t Script_GetPartyMember(lua_State* L) {
|
||||||
|
|||||||
@ -5,11 +5,15 @@
|
|||||||
|
|
||||||
|
|
||||||
static int32_t Script_GetNumRaidMembers(lua_State* L) {
|
static int32_t Script_GetNumRaidMembers(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
// TODO
|
||||||
|
lua_pushnumber(L, 0.0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetRealNumRaidMembers(lua_State* L) {
|
static int32_t Script_GetRealNumRaidMembers(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
// TODO
|
||||||
|
lua_pushnumber(L, 0.0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetRaidRosterInfo(lua_State* L) {
|
static int32_t Script_GetRaidRosterInfo(lua_State* L) {
|
||||||
|
|||||||
@ -128,7 +128,18 @@ int32_t CSimpleButton_SetFontString(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_GetFontString(lua_State* L) {
|
int32_t CSimpleButton_GetFontString(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CSimpleButton::GetObjectType();
|
||||||
|
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
auto fontString = button->m_text;
|
||||||
|
if (fontString) {
|
||||||
|
if (!fontString->lua_registered) {
|
||||||
|
fontString->RegisterScriptObject(nullptr);
|
||||||
|
}
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, fontString->lua_objectRef);
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_SetText(lua_State* L) {
|
int32_t CSimpleButton_SetText(lua_State* L) {
|
||||||
|
|||||||
@ -700,7 +700,70 @@ int32_t CSimpleFrame::HideThis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::LoadXML_Attributes(XMLNode* node, CStatus* status) {
|
void CSimpleFrame::LoadXML_Attributes(XMLNode* node, CStatus* status) {
|
||||||
// TODO
|
auto L = FrameScript_GetContext();
|
||||||
|
|
||||||
|
auto child = node->m_child;
|
||||||
|
while (child) {
|
||||||
|
auto childName = child->m_name.GetString();
|
||||||
|
if (SStrCmpI(childName, "Attribute", STORM_MAX_STR)) {
|
||||||
|
const char* frameName = this->GetName();
|
||||||
|
if (!frameName) {
|
||||||
|
frameName = "<unnamed>";
|
||||||
|
}
|
||||||
|
status->Add(STATUS_WARNING, "Frame %s: Unknown attributes element %s", frameName, childName);
|
||||||
|
child = child->m_next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto name = child->GetAttributeByName("name");
|
||||||
|
if (!name) {
|
||||||
|
const char* frameName = this->GetName();
|
||||||
|
if (!frameName) {
|
||||||
|
frameName = "<unnamed>";
|
||||||
|
}
|
||||||
|
status->Add(STATUS_WARNING, "Frame %s: unnamed attribute element", frameName);
|
||||||
|
child = child->m_next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto type = child->GetAttributeByName("type");
|
||||||
|
if (!type) {
|
||||||
|
type = "string";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto value = child->GetAttributeByName("value");
|
||||||
|
if (!value || !SStrCmpI(value, "nil", STORM_MAX_STR)) {
|
||||||
|
const char* frameName = this->GetName();
|
||||||
|
if (!frameName) {
|
||||||
|
frameName = "<unnamed>";
|
||||||
|
}
|
||||||
|
status->Add(STATUS_WARNING, "Frame %s: attribute element named %s missing value", frameName, name);
|
||||||
|
child = child->m_next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(type, "nil", STORM_MAX_STR)) {
|
||||||
|
lua_pushnil(L);
|
||||||
|
} else if (!SStrCmpI(type, "boolean", STORM_MAX_STR)) {
|
||||||
|
lua_pushboolean(L, StringToBOOL(value));
|
||||||
|
} else if (!SStrCmpI(type, "number", STORM_MAX_STR)) {
|
||||||
|
lua_pushnumber(L, SStrToFloat(value));
|
||||||
|
} else {
|
||||||
|
lua_pushstring(L, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto attribute = this->m_attributes.Ptr(name);
|
||||||
|
if (attribute) {
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, attribute->luaRef);
|
||||||
|
} else {
|
||||||
|
attribute = this->m_attributes.New(name, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: LUA Tainted Logic
|
||||||
|
attribute->luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
|
||||||
|
child = child->m_next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::LoadXML_Backdrop(XMLNode* node, CStatus* status) {
|
void CSimpleFrame::LoadXML_Backdrop(XMLNode* node, CStatus* status) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <storm/List.hpp>
|
#include <storm/List.hpp>
|
||||||
|
#include <storm/Hash.hpp>
|
||||||
|
|
||||||
class CBackdropGenerator;
|
class CBackdropGenerator;
|
||||||
class CCharEvent;
|
class CCharEvent;
|
||||||
@ -16,6 +17,11 @@ class CSimpleTitleRegion;
|
|||||||
class CSimpleTop;
|
class CSimpleTop;
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
|
class FRAMEATTR : public TSHashObject<FRAMEATTR, HASHKEY_STRI> {
|
||||||
|
public:
|
||||||
|
int32_t luaRef;
|
||||||
|
};
|
||||||
|
|
||||||
class CSimpleFrame : public CScriptRegion {
|
class CSimpleFrame : public CScriptRegion {
|
||||||
public:
|
public:
|
||||||
// Static members
|
// Static members
|
||||||
@ -79,6 +85,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
TSLink<CSimpleFrame> m_framesLink;
|
TSLink<CSimpleFrame> m_framesLink;
|
||||||
TSLink<CSimpleFrame> m_destroyedLink;
|
TSLink<CSimpleFrame> m_destroyedLink;
|
||||||
TSLink<CSimpleFrame> m_strataLink;
|
TSLink<CSimpleFrame> m_strataLink;
|
||||||
|
TSHashTable<FRAMEATTR, HASHKEY_STRI> m_attributes;
|
||||||
|
|
||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
virtual ~CSimpleFrame();
|
virtual ~CSimpleFrame();
|
||||||
|
|||||||
@ -37,3 +37,23 @@ bool CSimpleStatusBar::IsA(int32_t type) {
|
|||||||
int32_t CSimpleStatusBar::GetScriptMetaTable() {
|
int32_t CSimpleStatusBar::GetScriptMetaTable() {
|
||||||
return CSimpleStatusBar::s_metatable;
|
return CSimpleStatusBar::s_metatable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name, ScriptData& data) {
|
||||||
|
auto parentScript = CSimpleFrame::GetScriptByName(name, data);
|
||||||
|
|
||||||
|
if (parentScript) {
|
||||||
|
return parentScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(name, "OnValueChanged", STORM_MAX_STR)) {
|
||||||
|
data.wrapper = "return function(self,value) %s end";
|
||||||
|
return &this->m_onValueChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SStrCmpI(name, "OnMinMaxChanged", STORM_MAX_STR)) {
|
||||||
|
data.wrapper = "return function(self,min,max) %s end";
|
||||||
|
return &this->m_onMinMaxChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|||||||
@ -20,6 +20,11 @@ class CSimpleStatusBar : public CSimpleFrame {
|
|||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
virtual bool IsA(int32_t type);
|
virtual bool IsA(int32_t type);
|
||||||
virtual int32_t GetScriptMetaTable();
|
virtual int32_t GetScriptMetaTable();
|
||||||
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
|
|
||||||
|
// Member variables
|
||||||
|
ScriptIx m_onValueChanged;
|
||||||
|
ScriptIx m_onMinMaxChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user