From 5e54cca3fabf52f4862875e5cd2c5b085aba8163 Mon Sep 17 00:00:00 2001 From: VDm Date: Wed, 13 Aug 2025 23:53:52 +0400 Subject: [PATCH 1/3] feat(gameui): update CGTooltip script methods --- src/gameui/CGTooltip.cpp | 26 +++++++ src/gameui/CGTooltip.hpp | 28 ++++++++ src/gameui/CGTooltipScript.cpp | 126 ++++++++++++++++++++++++++++++--- src/util/StringTo.cpp | 29 ++++++++ src/util/StringTo.hpp | 2 + 5 files changed, 201 insertions(+), 10 deletions(-) diff --git a/src/gameui/CGTooltip.cpp b/src/gameui/CGTooltip.cpp index f298f8d..ec5ef3a 100644 --- a/src/gameui/CGTooltip.cpp +++ b/src/gameui/CGTooltip.cpp @@ -34,6 +34,32 @@ CGTooltip::CGTooltip(CSimpleFrame* parent) : CSimpleFrame(parent) { } +void CGTooltip::ClearTooltip() { +} + +void CGTooltip::ResetPosition(int32_t a1) { +} + +void CGTooltip::SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset) { + this->ClearTooltip(); + this->SetFrameAlpha(255); + // TODO: this->unk77 = 0; + + if (this->m_owner != owner + || this->m_anchorPoint != anchorpoint + || this->m_offsetX != xoffset + || this->m_offsetY != yoffset) { + this->m_offsetX = xoffset; + this->m_offsetY = yoffset; + this->m_owner = owner; + this->m_anchorPoint = owner ? anchorpoint : ANCHOR_NONE; + this->ResetPosition(1); + } +} + +void CGTooltip::AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring) { +} + bool CGTooltip::IsA(int32_t type) { return type == CGTooltip::s_objectType || type == CSimpleFrame::s_objectType diff --git a/src/gameui/CGTooltip.hpp b/src/gameui/CGTooltip.hpp index dd64fca..baa38ac 100644 --- a/src/gameui/CGTooltip.hpp +++ b/src/gameui/CGTooltip.hpp @@ -4,6 +4,23 @@ #include "ui/CSimpleFrame.hpp" #include "ui/CSimpleTop.hpp" +class CSimpleFontString; + +enum TOOLTIP_ANCHORPOINT { + ANCHOR_LEFT = 0, + ANCHOR_RIGHT, + ANCHOR_BOTTOMLEFT, + ANCHOR_BOTTOM, + ANCHOR_BOTTOMRIGHT, + ANCHOR_TOPLEFT, + ANCHOR_TOP, + ANCHOR_TOPRIGHT, + ANCHOR_CURSOR, + ANCHOR_NONE, + ANCHOR_PRESERVE, + ANCHOR_CURSOR_RIGHT, +}; + class CGTooltip : public CSimpleFrame { public: // Static variables @@ -18,6 +35,10 @@ class CGTooltip : public CSimpleFrame { // Member functions CGTooltip(CSimpleFrame* parent); + void ClearTooltip(); + void ResetPosition(int32_t a1); + void SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset); + void AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring); // Virtual member functions virtual bool IsA(int32_t type); @@ -25,6 +46,13 @@ class CGTooltip : public CSimpleFrame { virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data); // Member variables + CSimpleFrame* m_owner = nullptr; + TOOLTIP_ANCHORPOINT m_anchorPoint = ANCHOR_NONE; + float m_padding = 0.0f; + float m_minWidth = 0.0f; + uint32_t m_minWidthForced = 0; + float m_offsetX = 0.0f; + float m_offsetY = 0.0f; ScriptIx m_onTooltipSetDefaultAnchor; ScriptIx m_onTooltipCleared; ScriptIx m_onTooltipAddMoney; diff --git a/src/gameui/CGTooltipScript.cpp b/src/gameui/CGTooltipScript.cpp index a26a188..5353b56 100644 --- a/src/gameui/CGTooltipScript.cpp +++ b/src/gameui/CGTooltipScript.cpp @@ -1,26 +1,81 @@ #include "gameui/CGTooltipScript.hpp" #include "gameui/CGTooltip.hpp" +#include "ui/CSimpleFontString.hpp" +#include "gx/Coordinate.hpp" #include "util/Lua.hpp" #include "util/Unimplemented.hpp" +#include "util/StringTo.hpp" static int32_t Script_AddFontStrings(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + CSimpleFontString* arguments[2] = {}; + + for (int32_t i = 2; i < 4; ++i) { + if (lua_type(L, i) != LUA_TTABLE) { + return luaL_error(L, "Usage: %s:AddFontStrings(leftstring, rightstring)", tooltip->GetDisplayName()); + } + + lua_rawgeti(L, i, 0); + auto fontString = static_cast(lua_touserdata(L, -1)); + lua_settop(L, -2); + + if (!fontString) { + return luaL_error(L, "%s:AddFontStrings(): Couldn't find 'this' in fontstring", tooltip->GetDisplayName()); + } + + if (!fontString->IsA(CSimpleFontString::GetObjectType())) { + return luaL_error(L, "%s:AddFontStrings(): Wrong object type, expected fontstring", tooltip->GetDisplayName()); + } + + arguments[i - 2] = fontString; + } + + tooltip->AddFontStrings(arguments[0], arguments[1]); + return 0; } static int32_t Script_SetMinimumWidth(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + if (!lua_isnumber(L, 2)) { + return luaL_error(L, "Usage: %s:SetMinimumWidth(width [,force])", tooltip->GetDisplayName()); + } + + tooltip->m_minWidth = lua_tonumber(L, 2); + tooltip->m_minWidthForced = StringToBOOL(L, 3, 0); + return 0; } static int32_t Script_GetMinimumWidth(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + lua_pushnumber(L, tooltip->m_minWidth); + if (tooltip->m_minWidthForced) { + lua_pushnumber(L, 1.0); + } else { + lua_pushnil(L); + } + return 2; } static int32_t Script_SetPadding(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + float value = lua_tonumber(L, 2); + value /= CoordinateGetAspectCompensation() * 1024.0f; + tooltip->m_padding = NDCToDDCWidth(value); + return 0; } static int32_t Script_GetPadding(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + lua_pushnumber(L, tooltip->m_padding); + return 1; } static int32_t Script_IsOwned(lua_State* L) { @@ -32,7 +87,7 @@ static int32_t Script_IsOwned(lua_State* L) { } lua_rawgeti(L, 2, 0); - auto frame = static_cast(lua_touserdata(L, -1)); + auto frame = static_cast(lua_touserdata(L, -1)); lua_settop(L, -2); if (!frame) { @@ -43,7 +98,7 @@ static int32_t Script_IsOwned(lua_State* L) { return luaL_error(L, "%s:IsOwned(): Wrong object type, expected frame", tooltip->GetDisplayName()); } - if (tooltip->m_parent == frame) { + if (tooltip->m_owner == frame) { lua_pushnumber(L, 1.0); } else { lua_pushnil(L); @@ -55,13 +110,64 @@ static int32_t Script_GetOwner(lua_State* L) { auto type = CGTooltip::GetObjectType(); auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); - // TODO - lua_pushnil(L); + if (tooltip->m_owner) { + if (!tooltip->m_owner->lua_registered) { + tooltip->m_owner->RegisterScriptObject(nullptr); + } + lua_rawgeti(L, LUA_REGISTRYINDEX, tooltip->m_owner->lua_objectRef); + } else { + lua_pushnil(L); + } + return 1; } static int32_t Script_SetOwner(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + tooltip->Hide(); + + if (lua_type(L, 2) != LUA_TTABLE) { + return luaL_error(L, "Usage: %s:SetOwner(frame)", tooltip->GetDisplayName()); + } + + lua_rawgeti(L, 2, 0); + auto frame = static_cast(lua_touserdata(L, -1)); + lua_settop(L, -2); + + if (!frame) { + return luaL_error(L, "%s:SetOwner(): Couldn't find 'this' in frame object", tooltip->GetDisplayName()); + } + + if (!frame->IsA(CSimpleFrame::GetObjectType())) { + return luaL_error(L, "%s:SetOwner(): Wrong object type, expected frame", tooltip->GetDisplayName()); + } + + if (frame == tooltip) { + return luaL_error(L, "%s:SetOwner(): Can't set owner to self", tooltip->GetDisplayName()); + } + + int32_t anchorPoint = 0; + if (lua_isstring(L, 3)) { + StringToAnchorPoint(lua_tolstring(L, 3, nullptr), anchorPoint); + } + + float xoffset = 0.0f; + if (lua_isnumber(L, 4)) { + float value = lua_tonumber(L, 4); + value /= CoordinateGetAspectCompensation() * 1024.0f; + xoffset = NDCToDDCWidth(value); + } + + float yoffset = 0.0f; + if (lua_isnumber(L, 5)) { + float value = lua_tonumber(L, 5); + value /= CoordinateGetAspectCompensation() * 1024.0f; + yoffset = NDCToDDCWidth(value); + } + + tooltip->SetOwner(frame, static_cast(anchorPoint), xoffset, yoffset); } static int32_t Script_GetAnchorType(lua_State* L) { diff --git a/src/util/StringTo.cpp b/src/util/StringTo.cpp index 49506e6..edcd744 100644 --- a/src/util/StringTo.cpp +++ b/src/util/StringTo.cpp @@ -1,6 +1,7 @@ #include "util/StringTo.hpp" #include "util/Lua.hpp" #include +#include uint64_t StringToClickAction(const char* actionStr) { if (!actionStr || !*actionStr) { @@ -170,3 +171,31 @@ bool StringToOrientation(const char* string, uint32_t& orientation) { } return false; } + +bool StringToAnchorPoint(const char* string, int32_t& point) { + static std::pair table[12] = { + { 0, "ANCHOR_LEFT" }, + { 1, "ANCHOR_RIGHT" }, + { 2, "ANCHOR_BOTTOMLEFT" }, + { 3, "ANCHOR_BOTTOM" }, + { 4, "ANCHOR_BOTTOMRIGHT" }, + { 5, "ANCHOR_TOPLEFT" }, + { 6, "ANCHOR_TOP" }, + { 7, "ANCHOR_TOPRIGHT" }, + { 8, "ANCHOR_CURSOR" }, + { 9, "ANCHOR_NONE" }, + { 10, "ANCHOR_PRESERVE" }, + { 11, "ANCHOR_CURSOR_RIGHT" }, + }; + + point = 0; + + for (size_t i = 0; i < 12; ++i) { + if (!SStrCmpI(string, table[i].second, STORM_MAX_STR)) { + point = table[i].first; + return true; + } + } + + return false; +} diff --git a/src/util/StringTo.hpp b/src/util/StringTo.hpp index 1fb435f..4b698ae 100644 --- a/src/util/StringTo.hpp +++ b/src/util/StringTo.hpp @@ -19,4 +19,6 @@ int32_t StringToJustify(const char*, uint32_t&); bool StringToOrientation(const char* string, uint32_t& orientation); +bool StringToAnchorPoint(const char* string, int32_t& point); + #endif From 55bcd21c1fb2a1b1d078277d05c7d6c61ebd58d5 Mon Sep 17 00:00:00 2001 From: VDm Date: Thu, 14 Aug 2025 00:32:18 +0400 Subject: [PATCH 2/3] feat(gameui): update CGTooltip script methods --- src/gameui/CGTooltip.cpp | 19 +++++++ src/gameui/CGTooltip.hpp | 8 +++ src/gameui/CGTooltipScript.cpp | 95 +++++++++++++++++++++++++++++++--- src/ui/FrameScript.cpp | 13 +++++ src/ui/FrameScript.hpp | 2 + src/ui/Util.cpp | 29 +++++++++++ src/ui/Util.hpp | 2 + 7 files changed, 162 insertions(+), 6 deletions(-) diff --git a/src/gameui/CGTooltip.cpp b/src/gameui/CGTooltip.cpp index ec5ef3a..37ab488 100644 --- a/src/gameui/CGTooltip.cpp +++ b/src/gameui/CGTooltip.cpp @@ -5,6 +5,7 @@ int32_t CGTooltip::s_metatable; int32_t CGTooltip::s_objectType; +CImVector CGTooltip::s_defaultColor{ 0, 210, 255, 255 }; CSimpleFrame* CGTooltip::Create(CSimpleFrame* parent) { // TODO: Data = CDataAllocator__GetData(0, ".?AVCGTooltip@@", -2); @@ -40,6 +41,15 @@ void CGTooltip::ClearTooltip() { void CGTooltip::ResetPosition(int32_t a1) { } +void CGTooltip::SetAnchorType(TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset) { + this->m_offsetX = xoffset; + this->m_offsetY = yoffset; + if (this->m_owner) { + this->m_anchorPoint = anchorpoint; + } + this->ResetPosition(1); +} + void CGTooltip::SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset) { this->ClearTooltip(); this->SetFrameAlpha(255); @@ -60,6 +70,15 @@ void CGTooltip::SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, f void CGTooltip::AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring) { } +void CGTooltip::AddLine( + const char* leftText, + const char* rightText, + const CImVector& leftColor, + const CImVector& rightColor, + int32_t wrapped) { + +} + bool CGTooltip::IsA(int32_t type) { return type == CGTooltip::s_objectType || type == CSimpleFrame::s_objectType diff --git a/src/gameui/CGTooltip.hpp b/src/gameui/CGTooltip.hpp index baa38ac..04edbaa 100644 --- a/src/gameui/CGTooltip.hpp +++ b/src/gameui/CGTooltip.hpp @@ -26,6 +26,7 @@ class CGTooltip : public CSimpleFrame { // Static variables static int32_t s_metatable; static int32_t s_objectType; + static CImVector s_defaultColor; // Static functions static CSimpleFrame* Create(CSimpleFrame* parent); @@ -37,8 +38,15 @@ class CGTooltip : public CSimpleFrame { CGTooltip(CSimpleFrame* parent); void ClearTooltip(); void ResetPosition(int32_t a1); + void SetAnchorType(TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset); void SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, float xoffset, float yoffset); void AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring); + void AddLine( + const char* leftText, + const char* rightText, + const CImVector& leftColor, + const CImVector& rightColor, + int32_t wrapped); // Virtual member functions virtual bool IsA(int32_t type); diff --git a/src/gameui/CGTooltipScript.cpp b/src/gameui/CGTooltipScript.cpp index 5353b56..e33808f 100644 --- a/src/gameui/CGTooltipScript.cpp +++ b/src/gameui/CGTooltipScript.cpp @@ -1,6 +1,8 @@ #include "gameui/CGTooltipScript.hpp" #include "gameui/CGTooltip.hpp" +#include "ui/FrameScript.hpp" #include "ui/CSimpleFontString.hpp" +#include "ui/Util.hpp" #include "gx/Coordinate.hpp" #include "util/Lua.hpp" #include "util/Unimplemented.hpp" @@ -171,23 +173,86 @@ static int32_t Script_SetOwner(lua_State* L) { } static int32_t Script_GetAnchorType(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + lua_pushstring(L, AnchorPointToString(tooltip->m_anchorPoint)); + return 1; } static int32_t Script_SetAnchorType(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + int32_t anchorPoint = 0; + if (lua_isstring(L, 2)) { + StringToAnchorPoint(lua_tolstring(L, 3, nullptr), anchorPoint); + } else { + return luaL_error(L, "Usage: %s:SetAnchorType( anchorType [,Xoffset] [,Yoffset] )", tooltip->GetDisplayName()); + } + + float xoffset = 0.0f; + if (lua_isnumber(L, 3)) { + float value = lua_tonumber(L, 3); + value /= CoordinateGetAspectCompensation() * 1024.0f; + xoffset = NDCToDDCWidth(value); + } + + float yoffset = 0.0f; + if (lua_isnumber(L, 4)) { + float value = lua_tonumber(L, 4); + value /= CoordinateGetAspectCompensation() * 1024.0f; + yoffset = NDCToDDCWidth(value); + } + + tooltip->SetAnchorType(static_cast(anchorPoint), xoffset, yoffset); + return 0; } static int32_t Script_ClearLines(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + tooltip->ClearTooltip(); + return 0; } static int32_t Script_AddLine(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + const char* line = lua_isstring(L, 2) ? lua_tolstring(L, 2, nullptr) : nullptr; + + CImVector color = CGTooltip::s_defaultColor; + if (lua_isnumber(L, 3)) { + FrameScript_GetColorNoAlpha(L, 3, color); + } + + bool wrapped = StringToBOOL(L, 6, 0); + + tooltip->AddLine(line, nullptr, color, color, wrapped); + return 0; } static int32_t Script_AddDoubleLine(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + const char* leftLine = lua_isstring(L, 2) ? lua_tolstring(L, 2, nullptr) : nullptr; + const char* rightLine = lua_isstring(L, 3) ? lua_tolstring(L, 3, nullptr) : nullptr; + + CImVector leftColor = CGTooltip::s_defaultColor; + if (lua_isnumber(L, 4)) { + FrameScript_GetColorNoAlpha(L, 4, leftColor); + } + + CImVector rightColor = CGTooltip::s_defaultColor; + if (lua_isnumber(L, 7)) { + FrameScript_GetColorNoAlpha(L, 7, rightColor); + } + + bool wrapped = StringToBOOL(L, 10, 0); + + tooltip->AddLine(leftLine, rightLine, leftColor, rightColor, wrapped); + return 0; } static int32_t Script_AddTexture(lua_State* L) { @@ -195,7 +260,25 @@ static int32_t Script_AddTexture(lua_State* L) { } static int32_t Script_SetText(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + + const char* line = lua_isstring(L, 2) ? lua_tolstring(L, 2, nullptr) : nullptr; + if (!line) { + return luaL_error(L, "Usage: %s:SetText(\"text\" [, color])", tooltip->GetDisplayName()); + } + + CImVector color = CGTooltip::s_defaultColor; + if (lua_isnumber(L, 3)) { + FrameScript_GetColor(L, 3, color); + } + + bool wrapped = StringToBOOL(L, 7, 0); + + tooltip->ClearTooltip(); + tooltip->AddLine(line, nullptr, color, color, wrapped); + tooltip->Show(); + return 0; } static int32_t Script_AppendText(lua_State* L) { diff --git a/src/ui/FrameScript.cpp b/src/ui/FrameScript.cpp index 597b4d4..6c049dc 100644 --- a/src/ui/FrameScript.cpp +++ b/src/ui/FrameScript.cpp @@ -447,6 +447,19 @@ void FrameScript_Flush() { } } +void FrameScript_GetColorNoAlpha(lua_State* L, int32_t idx, CImVector& color) { + float r = lua_tonumber(L, idx + 0); + r = std::max(0.0f, std::min(r, 1.0f)); + + float g = lua_tonumber(L, idx + 1); + g = std::max(0.0f, std::min(g, 1.0f)); + + float b = lua_tonumber(L, idx + 2); + b = std::max(0.0f, std::min(b, 1.0f)); + + color.Set(1.0f, r, g, b); +} + void FrameScript_GetColor(lua_State* L, int32_t idx, CImVector& color) { float r = lua_tonumber(L, idx + 0); r = std::max(0.0f, std::min(r, 1.0f)); diff --git a/src/ui/FrameScript.hpp b/src/ui/FrameScript.hpp index 281e265..d67189a 100644 --- a/src/ui/FrameScript.hpp +++ b/src/ui/FrameScript.hpp @@ -77,6 +77,8 @@ int32_t FrameScript_ExecuteFile(const char* filePath, const char* a2, MD5_CTX* m void FrameScript_Flush(); +void FrameScript_GetColorNoAlpha(lua_State* L, int32_t idx, CImVector& color); + void FrameScript_GetColor(lua_State* L, int32_t idx, CImVector& color); int32_t SetDecimalConversion(int32_t enabled); diff --git a/src/ui/Util.cpp b/src/ui/Util.cpp index 1b6c069..837a3ee 100644 --- a/src/ui/Util.cpp +++ b/src/ui/Util.cpp @@ -97,3 +97,32 @@ const char* OrientationToString(uint32_t orientation) { return "UNKNOWN"; } } + +const char* AnchorPointToString(int32_t point) { + switch (point) { + case 0: + return "ANCHOR_LEFT"; + case 1: + return "ANCHOR_RIGHT"; + case 2: + return "ANCHOR_BOTTOMLEFT"; + case 3: + return "ANCHOR_BOTTOM"; + case 4: + return "ANCHOR_BOTTOMRIGHT"; + case 5: + return "ANCHOR_TOPLEFT"; + case 6: + return "ANCHOR_TOP"; + case 7: + return "ANCHOR_TOPRIGHT"; + case 8: + return "ANCHOR_CURSOR"; + case 10: + return "ANCHOR_PRESERVE"; + case 11: + return "ANCHOR_CURSOR_RIGHT"; + default: + return "ANCHOR_NONE"; + } +} diff --git a/src/ui/Util.hpp b/src/ui/Util.hpp index 38b5d5a..cdbd2a4 100644 --- a/src/ui/Util.hpp +++ b/src/ui/Util.hpp @@ -15,4 +15,6 @@ int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata); const char* OrientationToString(uint32_t orientation); +const char* AnchorPointToString(int32_t point); + #endif From 3d8cd8b87f833de75b9365bc3c5abb9e3767a22b Mon Sep 17 00:00:00 2001 From: VDm Date: Thu, 14 Aug 2025 01:20:39 +0400 Subject: [PATCH 3/3] feat(gameui): update CGTooltip member variables --- src/gameui/CGTooltip.cpp | 15 +++++++++++++++ src/gameui/CGTooltip.hpp | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/gameui/CGTooltip.cpp b/src/gameui/CGTooltip.cpp index 37ab488..503aec0 100644 --- a/src/gameui/CGTooltip.cpp +++ b/src/gameui/CGTooltip.cpp @@ -1,5 +1,6 @@ #include "gameui/CGTooltip.hpp" #include "gameui/CGTooltipScript.hpp" +#include "ui/CSimpleFontString.hpp" #include "util/Lua.hpp" #include @@ -76,7 +77,21 @@ void CGTooltip::AddLine( const CImVector& leftColor, const CImVector& rightColor, int32_t wrapped) { + if ((!leftText || !*leftText) && (!rightText || !*rightText)) { + return; + } + if (!this->m_linesMax) { + return; + } + + if (this->m_lines == this->m_linesMax - 1) { + char name[256]; + SStrPrintf(name, sizeof(name), "%sTextLeft%d", this->GetDisplayName(), this->m_linesMax + 1); + // TODO: CDataAllocator + auto leftFontString = NEW(CSimpleFontString, this, 2, 1); + leftFontString->SetName(name); + } } bool CGTooltip::IsA(int32_t type) { diff --git a/src/gameui/CGTooltip.hpp b/src/gameui/CGTooltip.hpp index 04edbaa..ac0c549 100644 --- a/src/gameui/CGTooltip.hpp +++ b/src/gameui/CGTooltip.hpp @@ -56,6 +56,11 @@ class CGTooltip : public CSimpleFrame { // Member variables CSimpleFrame* m_owner = nullptr; TOOLTIP_ANCHORPOINT m_anchorPoint = ANCHOR_NONE; + uint32_t m_lines = 0; + uint32_t m_linesMax = 0; + TSFixedArray m_leftStrings; + TSFixedArray m_rightStrings; + TSFixedArray m_wrapLine; float m_padding = 0.0f; float m_minWidth = 0.0f; uint32_t m_minWidthForced = 0;