mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 05:46:04 +03:00
feat(gameui): add script events into CGTooltip class
This commit is contained in:
parent
102fc51aef
commit
9d82727c9b
@ -1,8 +1,10 @@
|
||||
#include "gameui/CGTooltip.hpp"
|
||||
#include "gameui/CGTooltipScript.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include <bc/Memory.hpp>
|
||||
|
||||
int32_t CGTooltip::s_metatable;
|
||||
int32_t CGTooltip::s_objectType;
|
||||
|
||||
CSimpleFrame* CGTooltip::Create(CSimpleFrame* parent) {
|
||||
// TODO: Data = CDataAllocator__GetData(0, ".?AVCGTooltip@@", -2);
|
||||
@ -15,15 +17,79 @@ void CGTooltip::CreateScriptMetaTable() {
|
||||
CGTooltip::s_metatable = ref;
|
||||
}
|
||||
|
||||
int32_t CGTooltip::GetObjectType() {
|
||||
if (!CGTooltip::s_objectType) {
|
||||
CGTooltip::s_objectType = ++FrameScript_Object::s_objectTypes;
|
||||
}
|
||||
|
||||
return CGTooltip::s_objectType;
|
||||
}
|
||||
|
||||
void CGTooltip::RegisterScriptMethods(lua_State* L) {
|
||||
CSimpleFrame::RegisterScriptMethods(L);
|
||||
FrameScript_Object::FillScriptMethodTable(L, CGTooltipMethods, NUM_CGTOOLTIP_SCRIPT_METHODS);
|
||||
}
|
||||
|
||||
CGTooltip::CGTooltip(CSimpleFrame* parent)
|
||||
: CSimpleFrame(parent) {
|
||||
}
|
||||
|
||||
bool CGTooltip::IsA(int32_t type) {
|
||||
return type == CGTooltip::s_objectType
|
||||
|| type == CSimpleFrame::s_objectType
|
||||
|| type == CScriptRegion::s_objectType
|
||||
|| type == CScriptObject::s_objectType;
|
||||
}
|
||||
|
||||
int32_t CGTooltip::GetScriptMetaTable() {
|
||||
return CGTooltip::s_metatable;
|
||||
}
|
||||
|
||||
CGTooltip::CGTooltip(CSimpleFrame* parent)
|
||||
: CSimpleFrame(parent) {
|
||||
FrameScript_Object::ScriptIx* CGTooltip::GetScriptByName(const char* name, ScriptData& data) {
|
||||
auto result = this->CSimpleFrame::GetScriptByName(name, data);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetDefaultAnchor", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetDefaultAnchor;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipCleared", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipCleared;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipAddMoney", STORM_MAX_STR)) {
|
||||
data.wrapper = "return function(self,cost,maxcost) %s end";
|
||||
return &this->m_onTooltipAddMoney;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetUnit", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetUnit;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetItem", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetItem;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetSpell", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetSpell;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetQuest", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetQuest;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetAchievement", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetAchievement;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetEquipmentSet", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetEquipmentSet;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(name, "OnTooltipSetFrameStack", STORM_MAX_STR)) {
|
||||
return &this->m_onTooltipSetFrameStack;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -8,17 +8,33 @@ class CGTooltip : public CSimpleFrame {
|
||||
public:
|
||||
// Static variables
|
||||
static int32_t s_metatable;
|
||||
static int32_t s_objectType;
|
||||
|
||||
// Static functions
|
||||
static CSimpleFrame* Create(CSimpleFrame* parent);
|
||||
static void CreateScriptMetaTable();
|
||||
static int32_t GetObjectType();
|
||||
static void RegisterScriptMethods(lua_State* L);
|
||||
|
||||
// Virtual member functions
|
||||
virtual int32_t GetScriptMetaTable();
|
||||
|
||||
// Member functions
|
||||
CGTooltip(CSimpleFrame* parent);
|
||||
|
||||
// Virtual member functions
|
||||
virtual bool IsA(int32_t type);
|
||||
virtual int32_t GetScriptMetaTable();
|
||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||
|
||||
// Members
|
||||
ScriptIx m_onTooltipSetDefaultAnchor;
|
||||
ScriptIx m_onTooltipCleared;
|
||||
ScriptIx m_onTooltipAddMoney;
|
||||
ScriptIx m_onTooltipSetUnit;
|
||||
ScriptIx m_onTooltipSetItem;
|
||||
ScriptIx m_onTooltipSetSpell;
|
||||
ScriptIx m_onTooltipSetQuest;
|
||||
ScriptIx m_onTooltipSetAchievement;
|
||||
ScriptIx m_onTooltipSetEquipmentSet;
|
||||
ScriptIx m_onTooltipSetFrameStack;
|
||||
};
|
||||
|
||||
#endif // GAME_UI_CGTOOLTIP_HPP
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
void OsOutputDebugString(const char* format, ...) {
|
||||
char buffer[256];
|
||||
char buffer[512];
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "util/CStatus.hpp"
|
||||
#include "os/Debug.hpp"
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
@ -19,9 +20,15 @@ void CStatus::Add(STATUS_TYPE severity, const char* format, ...) {
|
||||
// Remove temporary console debug logging
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
printf("\n");
|
||||
|
||||
char output[490];
|
||||
auto length = vsnprintf(output, sizeof(output), format, args);
|
||||
if (length >= sizeof(output)) {
|
||||
output[sizeof(output) - 1] = '\0';
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
OsOutputDebugString("CStatus: %s\n", output);
|
||||
}
|
||||
|
||||
void CStatus::Prepend(STATUS_TYPE severity, const char* format, ...) {
|
||||
@ -29,9 +36,15 @@ void CStatus::Prepend(STATUS_TYPE severity, const char* format, ...) {
|
||||
// Remove temporary console debug logging
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
printf("\n");
|
||||
|
||||
char output[490];
|
||||
auto length = vsnprintf(output, sizeof(output), format, args);
|
||||
if (length >= sizeof(output)) {
|
||||
output[sizeof(output) - 1] = '\0';
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
OsOutputDebugString("CStatus: %s\n", output);
|
||||
}
|
||||
|
||||
CStatus& GetGlobalStatusObj() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user