Compare commits

..

5 Commits

Author SHA1 Message Date
fallenoak
22eb04e495
feat(ui): implement CSimpleButton_GetFontString
Some checks failed
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Has been cancelled
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Has been cancelled
2026-01-30 21:41:01 -06:00
fallenoak
2c181e436c
feat(ui): add CGTooltip::IsA 2026-01-30 20:57:48 -06:00
fallenoak
3d7d000190
feat(ui): implement Script_RequestBattlefieldPositions 2026-01-30 20:45:05 -06:00
fallenoak
bdef61479d
feat(ui): implement CGTooltip_IsOwned 2026-01-30 19:53:03 -06:00
fallenoak
85b7537faa
feat(ui): add TOOLTIP_ANCHORPOINT 2026-01-30 19:39:49 -06:00
8 changed files with 93 additions and 3 deletions

View File

@ -98,6 +98,21 @@ enum TextureImageMode {
ImageMode_Desaturate = 1 ImageMode_Desaturate = 1
}; };
enum TOOLTIP_ANCHORPOINT {
TOOLTIP_ANCHOR_LEFT = 0,
TOOLTIP_ANCHOR_RIGHT = 1,
TOOLTIP_ANCHOR_BOTTOMLEFT = 2,
TOOLTIP_ANCHOR_BOTTOM = 3,
TOOLTIP_ANCHOR_BOTTOMRIGHT = 4,
TOOLTIP_ANCHOR_TOPLEFT = 5,
TOOLTIP_ANCHOR_TOP = 6,
TOOLTIP_ANCHOR_TOPRIGHT = 7,
TOOLTIP_ANCHOR_CURSOR = 8,
TOOLTIP_ANCHOR_NONE = 9,
TOOLTIP_ANCHOR_PRESERVE = 10,
TOOLTIP_ANCHOR_CURSOR_RIGHT = 11,
};
struct FRAMEPRIORITY { struct FRAMEPRIORITY {
CSimpleFrame* frame; CSimpleFrame* frame;
uint32_t priority; uint32_t priority;

View File

@ -1,4 +1,5 @@
#include "ui/game/BattlefieldInfoScript.hpp" #include "ui/game/BattlefieldInfoScript.hpp"
#include "ui/game/CGBattlefieldInfo.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include "util/Unimplemented.hpp" #include "util/Unimplemented.hpp"
@ -105,7 +106,9 @@ int32_t Script_GetBattlefieldStatData(lua_State* L) {
} }
int32_t Script_RequestBattlefieldPositions(lua_State* L) { int32_t Script_RequestBattlefieldPositions(lua_State* L) {
WHOA_UNIMPLEMENTED(0); CGBattlefieldInfo::RequestPlayerPositions();
return 0;
} }
int32_t Script_GetNumBattlefieldPositions(lua_State* L) { int32_t Script_GetNumBattlefieldPositions(lua_State* L) {

View File

@ -0,0 +1,5 @@
#include "ui/game/CGBattlefieldInfo.hpp"
void CGBattlefieldInfo::RequestPlayerPositions() {
// TODO
}

View File

@ -0,0 +1,10 @@
#ifndef UI_GAME_C_G_BATTLEFIELD_INFO_HPP
#define UI_GAME_C_G_BATTLEFIELD_INFO_HPP
class CGBattlefieldInfo {
public:
// Static functions
static void RequestPlayerPositions();
};
#endif

View File

@ -35,3 +35,10 @@ CGTooltip::CGTooltip(CSimpleFrame* parent) : CSimpleFrame(parent) {
int32_t CGTooltip::GetScriptMetaTable() { int32_t CGTooltip::GetScriptMetaTable() {
return CGTooltip::s_metatable; return CGTooltip::s_metatable;
} }
bool CGTooltip::IsA(int32_t type) {
return type == CGTooltip::s_objectType
|| type == CSimpleFrame::s_objectType
|| type == CScriptRegion::s_objectType
|| type == CScriptObject::s_objectType;
}

View File

@ -16,9 +16,14 @@ class CGTooltip : public CSimpleFrame {
static void RegisterScriptMethods(lua_State* L); static void RegisterScriptMethods(lua_State* L);
// Member variables // Member variables
CSimpleFrame* m_owner = nullptr;
TOOLTIP_ANCHORPOINT m_anchorPoint;
// TODO
C2Vector m_offset;
// TODO // TODO
// Virtual member functions // Virtual member functions
virtual bool IsA(int32_t type);
virtual int32_t GetScriptMetaTable(); virtual int32_t GetScriptMetaTable();
// Member functions // Member functions

View File

@ -1,5 +1,7 @@
#include "ui/game/CGTooltipScript.hpp" #include "ui/game/CGTooltipScript.hpp"
#include "ui/game/CGTooltip.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include "util/Lua.hpp"
#include "util/Unimplemented.hpp" #include "util/Unimplemented.hpp"
namespace { namespace {
@ -25,7 +27,35 @@ int32_t CGTooltip_GetPadding(lua_State* L) {
} }
int32_t CGTooltip_IsOwned(lua_State* L) { int32_t CGTooltip_IsOwned(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CGTooltip::GetObjectType();
auto tooltip = static_cast<CGTooltip*>(FrameScript_GetObjectThis(L, type));
if (lua_type(L, 2) != LUA_TTABLE) {
luaL_error(L, "Usage: %s:IsOwned(frame)", tooltip->GetDisplayName());
return 0;
}
lua_rawgeti(L, 2, 0);
auto frame = static_cast<CSimpleFrame*>(lua_touserdata(L, -1));
lua_settop(L, -2);
if (!frame) {
luaL_error(L, "%s:IsOwned(): Couldn't find 'this' in frame object", tooltip->GetDisplayName());
return 0;
}
if (!frame->IsA(CSimpleFrame::GetObjectType())) {
luaL_error(L, "%s:IsOwned(): Wrong object type, expected frame", tooltip->GetDisplayName());
return 0;
}
if (tooltip->m_owner == frame) {
lua_pushnumber(L, 1.0);
} else {
lua_pushnil(L);
}
return 1;
} }
int32_t CGTooltip_GetOwner(lua_State* L) { int32_t CGTooltip_GetOwner(lua_State* L) {

View File

@ -218,7 +218,22 @@ int32_t CSimpleButton_SetFontString(lua_State* L) {
} }
int32_t CSimpleButton_GetFontString(lua_State* L) { int32_t CSimpleButton_GetFontString(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleButton::GetObjectType();
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
auto text = button->m_text;
if (!text) {
lua_pushnil(L);
return 1;
}
if (!text->lua_registered) {
text->RegisterScriptObject(nullptr);
}
lua_rawgeti(L, LUA_REGISTRYINDEX, text->lua_objectRef);
return 1;
} }
int32_t CSimpleButton_SetText(lua_State* L) { int32_t CSimpleButton_SetText(lua_State* L) {