diff --git a/src/gameui/CGTooltip.cpp b/src/gameui/CGTooltip.cpp index 503aec0..f298f8d 100644 --- a/src/gameui/CGTooltip.cpp +++ b/src/gameui/CGTooltip.cpp @@ -1,12 +1,10 @@ #include "gameui/CGTooltip.hpp" #include "gameui/CGTooltipScript.hpp" -#include "ui/CSimpleFontString.hpp" #include "util/Lua.hpp" #include 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); @@ -36,64 +34,6 @@ CGTooltip::CGTooltip(CSimpleFrame* parent) : CSimpleFrame(parent) { } -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); - // 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) { -} - -void CGTooltip::AddLine( - const char* leftText, - const char* rightText, - 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) { return type == CGTooltip::s_objectType || type == CSimpleFrame::s_objectType diff --git a/src/gameui/CGTooltip.hpp b/src/gameui/CGTooltip.hpp index ac0c549..dd64fca 100644 --- a/src/gameui/CGTooltip.hpp +++ b/src/gameui/CGTooltip.hpp @@ -4,29 +4,11 @@ #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 static int32_t s_metatable; static int32_t s_objectType; - static CImVector s_defaultColor; // Static functions static CSimpleFrame* Create(CSimpleFrame* parent); @@ -36,17 +18,6 @@ class CGTooltip : public CSimpleFrame { // Member functions 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); @@ -54,18 +25,6 @@ class CGTooltip : public CSimpleFrame { virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data); // 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; - 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 e33808f..a26a188 100644 --- a/src/gameui/CGTooltipScript.cpp +++ b/src/gameui/CGTooltipScript.cpp @@ -1,83 +1,26 @@ #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" -#include "util/StringTo.hpp" static int32_t Script_AddFontStrings(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_SetMinimumWidth(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_GetMinimumWidth(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_SetPadding(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_GetPadding(lua_State* L) { - auto type = CGTooltip::GetObjectType(); - auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); - lua_pushnumber(L, tooltip->m_padding); - return 1; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_IsOwned(lua_State* L) { @@ -89,7 +32,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) { @@ -100,7 +43,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_owner == frame) { + if (tooltip->m_parent == frame) { lua_pushnumber(L, 1.0); } else { lua_pushnil(L); @@ -112,147 +55,33 @@ static int32_t Script_GetOwner(lua_State* L) { auto type = CGTooltip::GetObjectType(); auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); - 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); - } - + // TODO + lua_pushnil(L); return 1; } static int32_t Script_SetOwner(lua_State* L) { - 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); + WHOA_UNIMPLEMENTED(0); } static int32_t Script_GetAnchorType(lua_State* L) { - auto type = CGTooltip::GetObjectType(); - auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); - lua_pushstring(L, AnchorPointToString(tooltip->m_anchorPoint)); - return 1; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_SetAnchorType(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_ClearLines(lua_State* L) { - auto type = CGTooltip::GetObjectType(); - auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); - tooltip->ClearTooltip(); - return 0; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_AddLine(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_AddDoubleLine(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_AddTexture(lua_State* L) { @@ -260,25 +89,7 @@ static int32_t Script_AddTexture(lua_State* L) { } static int32_t Script_SetText(lua_State* L) { - 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; + WHOA_UNIMPLEMENTED(0); } static int32_t Script_AppendText(lua_State* L) { diff --git a/src/ui/FrameScript.cpp b/src/ui/FrameScript.cpp index 6c049dc..597b4d4 100644 --- a/src/ui/FrameScript.cpp +++ b/src/ui/FrameScript.cpp @@ -447,19 +447,6 @@ 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 d67189a..281e265 100644 --- a/src/ui/FrameScript.hpp +++ b/src/ui/FrameScript.hpp @@ -77,8 +77,6 @@ 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 837a3ee..1b6c069 100644 --- a/src/ui/Util.cpp +++ b/src/ui/Util.cpp @@ -97,32 +97,3 @@ 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 cdbd2a4..38b5d5a 100644 --- a/src/ui/Util.hpp +++ b/src/ui/Util.hpp @@ -15,6 +15,4 @@ int32_t StringToFrameStrata(const char* string, FRAME_STRATA& strata); const char* OrientationToString(uint32_t orientation); -const char* AnchorPointToString(int32_t point); - #endif diff --git a/src/util/StringTo.cpp b/src/util/StringTo.cpp index edcd744..49506e6 100644 --- a/src/util/StringTo.cpp +++ b/src/util/StringTo.cpp @@ -1,7 +1,6 @@ #include "util/StringTo.hpp" #include "util/Lua.hpp" #include -#include uint64_t StringToClickAction(const char* actionStr) { if (!actionStr || !*actionStr) { @@ -171,31 +170,3 @@ 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 4b698ae..1fb435f 100644 --- a/src/util/StringTo.hpp +++ b/src/util/StringTo.hpp @@ -19,6 +19,4 @@ int32_t StringToJustify(const char*, uint32_t&); bool StringToOrientation(const char* string, uint32_t& orientation); -bool StringToAnchorPoint(const char* string, int32_t& point); - #endif