diff --git a/src/gameui/CGTooltip.cpp b/src/gameui/CGTooltip.cpp index 145ee31..a609517 100644 --- a/src/gameui/CGTooltip.cpp +++ b/src/gameui/CGTooltip.cpp @@ -41,6 +41,28 @@ CGTooltip::CGTooltip(CSimpleFrame* parent) } void CGTooltip::ClearTooltip() { + // TODO + for (uint32_t line = 0; line < this->m_lines; ++line) { + auto leftString = this->m_leftStrings[line]; + leftString->SetWidth(0.0f); + leftString->SetText("", 1); + leftString->Hide(); + + auto rightString = this->m_rightStrings[line]; + rightString->SetWidth(0.0f); + rightString->SetText("", 1); + rightString->Hide(); + + this->m_wrapLine[line] = 0; + } + + if (!this->m_minWidthForced) { + this->m_minWidth = 0.0f; + } + + if (this->m_lines && this->m_onTooltipCleared.luaRef) { + this->RunScript(this->m_onTooltipCleared, 0, nullptr); + } } void CGTooltip::ResetPosition(int32_t a1) { @@ -144,6 +166,16 @@ void CGTooltip::AddLine( this->m_wrapLine[this->m_lines++] = wrapped; } +void CGTooltip::FadeOut() { + if (this->m_anchorPoint == ANCHOR_LEFT || this->m_anchorPoint == ANCHOR_CURSOR_RIGHT) { + this->HideThis(); + this->m_fading = 0; + } else { + this->m_fading = 1; + this->m_fadeTime = TOOLTIP_FADE_TIME; + } +} + 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 41820de..64135c5 100644 --- a/src/gameui/CGTooltip.hpp +++ b/src/gameui/CGTooltip.hpp @@ -24,6 +24,8 @@ enum TOOLTIP_ANCHORPOINT { class CGTooltip : public CSimpleFrame { public: + const float TOOLTIP_FADE_TIME = 2.0f; + // Static variables static int32_t s_metatable; static int32_t s_objectType; @@ -48,6 +50,7 @@ class CGTooltip : public CSimpleFrame { const CImVector& leftColor, const CImVector& rightColor, int32_t wrapped); + void FadeOut(); // Virtual member functions virtual bool IsA(int32_t type); @@ -65,6 +68,8 @@ class CGTooltip : public CSimpleFrame { TSFixedArray m_wrapLine; CSimpleStatusBar* m_statusBar = nullptr; CSimpleTexture* m_textures[10] = {}; + uint32_t m_fading = 0; + float m_fadeTime = 0.0f; float m_padding = 0.0f; float m_minWidth = 0.0f; uint32_t m_minWidthForced = 0; diff --git a/src/gameui/CGTooltipScript.cpp b/src/gameui/CGTooltipScript.cpp index e33808f..e0309ff 100644 --- a/src/gameui/CGTooltipScript.cpp +++ b/src/gameui/CGTooltipScript.cpp @@ -286,7 +286,10 @@ static int32_t Script_AppendText(lua_State* L) { } static int32_t Script_FadeOut(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + tooltip->FadeOut(); + return 0; } static int32_t Script_SetHyperlink(lua_State* L) { @@ -406,7 +409,10 @@ static int32_t Script_SetAuctionItem(lua_State* L) { } static int32_t Script_NumLines(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + auto type = CGTooltip::GetObjectType(); + auto tooltip = static_cast(FrameScript_GetObjectThis(L, type)); + lua_pushnumber(L, tooltip->m_lines); + return 1; } static int32_t Script_SetQuestRewardSpell(lua_State* L) { diff --git a/src/gameui/GameScriptFunctions.cpp b/src/gameui/GameScriptFunctions.cpp index 614d3b9..d1000e8 100644 --- a/src/gameui/GameScriptFunctions.cpp +++ b/src/gameui/GameScriptFunctions.cpp @@ -844,11 +844,17 @@ static int32_t Script_NotWhileDeadError(lua_State* L) { } static int32_t Script_GetRestState(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnil(L); + lua_pushnil(L); + lua_pushnil(L); + return 3; } static int32_t Script_GetXPExhaustion(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO + lua_pushnil(L); + return 1; } static int32_t Script_GetTimeToWellRested(lua_State* L) { diff --git a/src/gameui/scripts/GameScriptFunctionsBattlenetUI.cpp b/src/gameui/scripts/GameScriptFunctionsBattlenetUI.cpp index 3458c56..ffee60f 100644 --- a/src/gameui/scripts/GameScriptFunctionsBattlenetUI.cpp +++ b/src/gameui/scripts/GameScriptFunctionsBattlenetUI.cpp @@ -234,7 +234,9 @@ static int32_t Script_BNIsFriend(lua_State* L) { } static int32_t Script_BNGetMaxPlayersInConversation(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO: LoginConnection + lua_pushnumber(L, 12.0); + return 1; } void BattlenetUIRegisterScriptFunctions() { diff --git a/src/ui/LuaExtraFuncs.cpp b/src/ui/LuaExtraFuncs.cpp index 4720a7b..b452067 100644 --- a/src/ui/LuaExtraFuncs.cpp +++ b/src/ui/LuaExtraFuncs.cpp @@ -3,6 +3,7 @@ #include "ui/FrameScriptInternal.hpp" #include "util/Lua.hpp" #include "util/Unimplemented.hpp" +#include "os/Debug.hpp" #include @@ -120,7 +121,26 @@ int32_t forceinsecure(lua_State* L) { } int32_t securecall(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + // TODO: tainted + if (lua_isstring(L, 1)) { + lua_pushstring(L, lua_tolstring(L, 1, nullptr)); + lua_rawget(L, LUA_GLOBALSINDEX); + lua_remove(L, 1); + lua_insert(L, 1); + } + if (!lua_gettop(L)) { + lua_pushnil(L); + } + + lua_rawgeti(L, LUA_REGISTRYINDEX, FrameScript::s_errorHandlerRef); + lua_insert(L, 1); + if (lua_pcall(L, lua_gettop(L) - 2, -1, 1)) { + lua_settop(L, -3); + } else { + lua_remove(L, 1); + } + // TODO: tainted + return lua_gettop(L); } int32_t hooksecurefunc(lua_State* L) { @@ -132,7 +152,7 @@ int32_t debugload(lua_State* L) { } int32_t debuginfo(lua_State* L) { - WHOA_UNIMPLEMENTED(0); + return 0; } int32_t debugprint(lua_State* L) {