mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 10:25:59 +03:00
Compare commits
2 Commits
3d8cd8b87f
...
a50ca69e8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a50ca69e8c | ||
|
|
1c65263c61 |
@ -1,8 +1,12 @@
|
|||||||
#include "gameui/CGTooltip.hpp"
|
#include "gameui/CGTooltip.hpp"
|
||||||
#include "gameui/CGTooltipScript.hpp"
|
#include "gameui/CGTooltipScript.hpp"
|
||||||
|
#include "gx/Coordinate.hpp"
|
||||||
#include "ui/CSimpleFontString.hpp"
|
#include "ui/CSimpleFontString.hpp"
|
||||||
|
#include "ui/CSimpleStatusBar.hpp"
|
||||||
|
#include "ui/CSimpleTexture.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include <bc/Memory.hpp>
|
#include <bc/Memory.hpp>
|
||||||
|
#include <common/XML.hpp>
|
||||||
|
|
||||||
int32_t CGTooltip::s_metatable;
|
int32_t CGTooltip::s_metatable;
|
||||||
int32_t CGTooltip::s_objectType;
|
int32_t CGTooltip::s_objectType;
|
||||||
@ -37,6 +41,28 @@ CGTooltip::CGTooltip(CSimpleFrame* parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGTooltip::ClearTooltip() {
|
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) {
|
void CGTooltip::ResetPosition(int32_t a1) {
|
||||||
@ -69,6 +95,13 @@ void CGTooltip::SetOwner(CSimpleFrame* owner, TOOLTIP_ANCHORPOINT anchorpoint, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGTooltip::AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring) {
|
void CGTooltip::AddFontStrings(CSimpleFontString* leftstring, CSimpleFontString* rightstring) {
|
||||||
|
this->m_linesMax++;
|
||||||
|
this->m_leftStrings.SetCount(this->m_linesMax);
|
||||||
|
this->m_rightStrings.SetCount(this->m_linesMax);
|
||||||
|
this->m_wrapLine.SetCount(this->m_linesMax);
|
||||||
|
this->m_leftStrings[this->m_linesMax - 1] = leftstring;
|
||||||
|
this->m_rightStrings[this->m_linesMax - 1] = rightstring;
|
||||||
|
this->m_wrapLine[this->m_linesMax - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGTooltip::AddLine(
|
void CGTooltip::AddLine(
|
||||||
@ -86,11 +119,60 @@ void CGTooltip::AddLine(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->m_lines == this->m_linesMax - 1) {
|
if (this->m_lines == this->m_linesMax - 1) {
|
||||||
|
auto lastLeftString = this->m_leftStrings[this->m_linesMax - 1];
|
||||||
|
auto lastRightString = this->m_rightStrings[this->m_linesMax - 1];
|
||||||
|
|
||||||
char name[256];
|
char name[256];
|
||||||
SStrPrintf(name, sizeof(name), "%sTextLeft%d", this->GetDisplayName(), this->m_linesMax + 1);
|
SStrPrintf(name, sizeof(name), "%sTextLeft%d", this->GetDisplayName(), this->m_linesMax + 1);
|
||||||
// TODO: CDataAllocator
|
// TODO: CDataAllocator
|
||||||
auto leftFontString = NEW(CSimpleFontString, this, 2, 1);
|
auto leftFontString = NEW(CSimpleFontString, this, 2, 1);
|
||||||
leftFontString->SetName(name);
|
leftFontString->SetName(name);
|
||||||
|
leftFontString->SetFontObject(lastLeftString->GetFontObject());
|
||||||
|
|
||||||
|
float yoffset = -2.0f / (CoordinateGetAspectCompensation() * 1024.0f);
|
||||||
|
yoffset = NDCToDDCWidth(yoffset);
|
||||||
|
leftFontString->SetPoint(FRAMEPOINT_TOPLEFT, lastLeftString, FRAMEPOINT_BOTTOMLEFT, 0.0f, yoffset, 0);
|
||||||
|
leftFontString->Hide();
|
||||||
|
|
||||||
|
SStrPrintf(name, sizeof(name), "%sTextRight%d", this->GetDisplayName(), this->m_linesMax + 1);
|
||||||
|
// TODO: CDataAllocator
|
||||||
|
auto rightFontString = NEW(CSimpleFontString, this, 2, 1);
|
||||||
|
rightFontString->SetName(name);
|
||||||
|
rightFontString->SetFontObject(lastRightString->GetFontObject());
|
||||||
|
|
||||||
|
float xoffset = 40.0f / (CoordinateGetAspectCompensation() * 1024.0f);
|
||||||
|
xoffset = NDCToDDCWidth(xoffset);
|
||||||
|
rightFontString->SetPoint(FRAMEPOINT_RIGHT, leftFontString, FRAMEPOINT_LEFT, xoffset, 0.0f, 0);
|
||||||
|
rightFontString->Hide();
|
||||||
|
|
||||||
|
this->AddFontStrings(leftFontString, rightFontString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftText && *leftText) {
|
||||||
|
auto leftString = this->m_leftStrings[this->m_lines];
|
||||||
|
leftString->SetVertexColor(leftColor);
|
||||||
|
leftString->SetText(leftText, 1);
|
||||||
|
leftString->Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightText && *rightText) {
|
||||||
|
auto rightString = this->m_rightStrings[this->m_lines];
|
||||||
|
rightString->SetVertexColor(rightColor);
|
||||||
|
rightString->SetText(rightText, 1);
|
||||||
|
rightString->Show();
|
||||||
|
wrapped = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,3 +235,45 @@ FrameScript_Object::ScriptIx* CGTooltip::GetScriptByName(const char* name, Scrip
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGTooltip::PostLoadXML(XMLNode* node, CStatus* status) {
|
||||||
|
CSimpleFrame::PostLoadXML(node, status);
|
||||||
|
for (int32_t pass = 0; pass < 2; ++pass) {
|
||||||
|
if (pass == 1) {
|
||||||
|
this->m_leftStrings.SetCount(this->m_linesMax);
|
||||||
|
this->m_rightStrings.SetCount(this->m_linesMax);
|
||||||
|
this->m_wrapLine.SetCount(this->m_linesMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (this->m_linesMax = 0; true; ++this->m_linesMax) {
|
||||||
|
char name[256];
|
||||||
|
SStrPrintf(name, sizeof(name), "%sTextLeft%d", this->GetDisplayName(), this->m_linesMax + 1);
|
||||||
|
auto leftObject = CScriptObject::GetScriptObjectByName(name, CGTooltip::GetObjectType());
|
||||||
|
|
||||||
|
SStrPrintf(name, sizeof(name), "%sTextRight%d", this->GetDisplayName(), this->m_linesMax + 1);
|
||||||
|
auto rightObject = CScriptObject::GetScriptObjectByName(name, CGTooltip::GetObjectType());
|
||||||
|
|
||||||
|
if (!leftObject || !rightObject) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pass == 1) {
|
||||||
|
this->m_leftStrings[this->m_linesMax] = static_cast<CSimpleFontString*>(leftObject);
|
||||||
|
this->m_rightStrings[this->m_linesMax] = static_cast<CSimpleFontString*>(rightObject);
|
||||||
|
this->m_wrapLine[this->m_linesMax] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 10; ++i) {
|
||||||
|
char name[256];
|
||||||
|
SStrPrintf(name, sizeof(name), "%sTexture%d", this->GetDisplayName(), i);
|
||||||
|
auto object = CScriptObject::GetScriptObjectByName(name, CSimpleTexture::GetObjectType());
|
||||||
|
this->m_textures[i] = static_cast<CSimpleTexture*>(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
char name[256];
|
||||||
|
SStrPrintf(name, sizeof(name), "%sStatusBar", this->GetDisplayName());
|
||||||
|
auto object = CScriptObject::GetScriptObjectByName(name, CSimpleStatusBar::GetObjectType());
|
||||||
|
this->m_statusBar = static_cast<CSimpleStatusBar*>(object);
|
||||||
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "ui/CSimpleFrame.hpp"
|
#include "ui/CSimpleFrame.hpp"
|
||||||
#include "ui/CSimpleTop.hpp"
|
#include "ui/CSimpleTop.hpp"
|
||||||
|
|
||||||
|
class CSimpleStatusBar;
|
||||||
class CSimpleFontString;
|
class CSimpleFontString;
|
||||||
|
|
||||||
enum TOOLTIP_ANCHORPOINT {
|
enum TOOLTIP_ANCHORPOINT {
|
||||||
@ -23,6 +24,8 @@ enum TOOLTIP_ANCHORPOINT {
|
|||||||
|
|
||||||
class CGTooltip : public CSimpleFrame {
|
class CGTooltip : public CSimpleFrame {
|
||||||
public:
|
public:
|
||||||
|
const float TOOLTIP_FADE_TIME = 2.0f;
|
||||||
|
|
||||||
// Static variables
|
// Static variables
|
||||||
static int32_t s_metatable;
|
static int32_t s_metatable;
|
||||||
static int32_t s_objectType;
|
static int32_t s_objectType;
|
||||||
@ -47,11 +50,13 @@ class CGTooltip : public CSimpleFrame {
|
|||||||
const CImVector& leftColor,
|
const CImVector& leftColor,
|
||||||
const CImVector& rightColor,
|
const CImVector& rightColor,
|
||||||
int32_t wrapped);
|
int32_t wrapped);
|
||||||
|
void FadeOut();
|
||||||
|
|
||||||
// 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);
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
|
virtual void PostLoadXML(XMLNode* node, CStatus* status);
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
CSimpleFrame* m_owner = nullptr;
|
CSimpleFrame* m_owner = nullptr;
|
||||||
@ -61,6 +66,10 @@ class CGTooltip : public CSimpleFrame {
|
|||||||
TSFixedArray<CSimpleFontString*> m_leftStrings;
|
TSFixedArray<CSimpleFontString*> m_leftStrings;
|
||||||
TSFixedArray<CSimpleFontString*> m_rightStrings;
|
TSFixedArray<CSimpleFontString*> m_rightStrings;
|
||||||
TSFixedArray<int32_t> m_wrapLine;
|
TSFixedArray<int32_t> 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_padding = 0.0f;
|
||||||
float m_minWidth = 0.0f;
|
float m_minWidth = 0.0f;
|
||||||
uint32_t m_minWidthForced = 0;
|
uint32_t m_minWidthForced = 0;
|
||||||
|
|||||||
@ -286,7 +286,10 @@ static int32_t Script_AppendText(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_FadeOut(lua_State* L) {
|
static int32_t Script_FadeOut(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CGTooltip::GetObjectType();
|
||||||
|
auto tooltip = static_cast<CGTooltip*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
tooltip->FadeOut();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetHyperlink(lua_State* L) {
|
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) {
|
static int32_t Script_NumLines(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CGTooltip::GetObjectType();
|
||||||
|
auto tooltip = static_cast<CGTooltip*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
lua_pushnumber(L, tooltip->m_lines);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetQuestRewardSpell(lua_State* L) {
|
static int32_t Script_SetQuestRewardSpell(lua_State* L) {
|
||||||
|
|||||||
@ -844,11 +844,17 @@ static int32_t Script_NotWhileDeadError(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetRestState(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) {
|
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) {
|
static int32_t Script_GetTimeToWellRested(lua_State* L) {
|
||||||
|
|||||||
@ -234,7 +234,9 @@ static int32_t Script_BNIsFriend(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_BNGetMaxPlayersInConversation(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() {
|
void BattlenetUIRegisterScriptFunctions() {
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#include "ui/FrameScriptInternal.hpp"
|
#include "ui/FrameScriptInternal.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
#include "os/Debug.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +121,26 @@ int32_t forceinsecure(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t securecall(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) {
|
int32_t hooksecurefunc(lua_State* L) {
|
||||||
@ -132,7 +152,7 @@ int32_t debugload(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t debuginfo(lua_State* L) {
|
int32_t debuginfo(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t debugprint(lua_State* L) {
|
int32_t debugprint(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user