From 41f4992ebe10ecea42073bc4b2dbaab1fc180f77 Mon Sep 17 00:00:00 2001 From: VDm Date: Sun, 30 Mar 2025 00:15:17 +0400 Subject: [PATCH] feat(gameui): add CGWorldFrame class skeleton --- src/client/ClientHandlers.cpp | 3 ++- src/client/ClientServices.cpp | 2 +- src/gameui/CGGameUI.cpp | 3 ++- src/gameui/CGWorldFrame.cpp | 51 +++++++++++++++++++++++++++++++++++ src/gameui/CGWorldFrame.hpp | 22 +++++++++++++++ src/ui/FrameScript.cpp | 5 +++- src/world/World.cpp | 6 +++++ src/world/World.hpp | 2 ++ 8 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/gameui/CGWorldFrame.cpp create mode 100644 src/gameui/CGWorldFrame.hpp create mode 100644 src/world/World.cpp diff --git a/src/client/ClientHandlers.cpp b/src/client/ClientHandlers.cpp index bd37c0c..4bdc638 100644 --- a/src/client/ClientHandlers.cpp +++ b/src/client/ClientHandlers.cpp @@ -4,6 +4,7 @@ #include #include "console/Line.hpp" +#include "world/World.hpp" uint32_t s_newZoneID = 0; @@ -54,7 +55,7 @@ int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CD // return 0; //} //s_newMapname = *(_DWORD*)(v0 + 4); - //LoadNewWorld(0, 0); + LoadNewWorld(); } return 1; } diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index c5c52ac..ec19c4a 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -81,7 +81,7 @@ void ClientServices::GetCharacterList() { } void ClientServices::CharacterLogin(uint64_t id, const C3Vector& position) { - // TODO + ClientServices::s_currentConnection->CharacterLogin(id); } REALM_INFO* ClientServices::GetRealmInfoByIndex(int32_t index) { diff --git a/src/gameui/CGGameUI.cpp b/src/gameui/CGGameUI.cpp index 4aba2ff..cbf390b 100644 --- a/src/gameui/CGGameUI.cpp +++ b/src/gameui/CGGameUI.cpp @@ -4,6 +4,7 @@ #include #include "client/Client.hpp" +#include "gameui/CGWorldFrame.hpp" #include "gx/Coordinate.hpp" #include "gx/Device.hpp" #include "ui/FrameScript.hpp" @@ -175,7 +176,7 @@ void CGGameUI::Initialize() { } void CGGameUI::RegisterFrameFactories() { - //FrameXML_RegisterFactory("WorldFrame", (int)CGWorldFrame::Create, 1); + FrameXML_RegisterFactory("WorldFrame", CGWorldFrame::Create, 1); //FrameXML_RegisterFactory("GameTooltip", (int)CGTooltip::Create, 0); //FrameXML_RegisterFactory("Cooldown", (int)sub_51A380, 0); //FrameXML_RegisterFactory("Minimap", (int)CGMinimapFrame::Create, 0); diff --git a/src/gameui/CGWorldFrame.cpp b/src/gameui/CGWorldFrame.cpp new file mode 100644 index 0000000..01e72c3 --- /dev/null +++ b/src/gameui/CGWorldFrame.cpp @@ -0,0 +1,51 @@ +#include "gameui/CGWorldFrame.hpp" + +#include "gx/Transform.hpp" + +#include +#include + + +CGWorldFrame* CGWorldFrame::s_currentWorldFrame = nullptr; + + +CGWorldFrame::CGWorldFrame(CSimpleFrame* parent) : CSimpleFrame(parent) { + // TODO + s_currentWorldFrame = this; +} + +void CGWorldFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) { + CSimpleFrame::OnFrameRender(batch, layer); + if (!layer) { + batch->QueueCallback(&CGWorldFrame::RenderWorld, this); + } +} + +CSimpleFrame* CGWorldFrame::Create(CSimpleFrame* parent) { + // TODO: Data = CDataAllocator__GetData(0, ".?AVCGWorldFrame@@", -2); + + auto m = SMemAlloc(sizeof(CGWorldFrame), __FILE__, __LINE__, 0); + return m ? (new (m) CGWorldFrame(parent)) : nullptr; +} + +void CGWorldFrame::RenderWorld(void* param) { + C44Matrix saved_proj; + GxXformProjection(saved_proj); + + C44Matrix saved_view; + GxXformView(saved_view); + + CGWorldFrame::OnWorldUpdate(); + CGWorldFrame::OnWorldRender(); + + //PlayerNameRenderWorldText(); + + GxXformSetProjection(saved_proj); + GxXformSetView(saved_view); +} + +void CGWorldFrame::OnWorldUpdate() { +} + +void CGWorldFrame::OnWorldRender() { +} diff --git a/src/gameui/CGWorldFrame.hpp b/src/gameui/CGWorldFrame.hpp new file mode 100644 index 0000000..a77f21d --- /dev/null +++ b/src/gameui/CGWorldFrame.hpp @@ -0,0 +1,22 @@ +#ifndef GAME_UI_CGWORLDFRAME_HPP +#define GAME_UI_CGWORLDFRAME_HPP + +#include "ui/CSimpleFrame.hpp" +#include "ui/CSimpleTop.hpp" + +class CGWorldFrame : public CSimpleFrame { + public: + CGWorldFrame(CSimpleFrame* parent); + + virtual void OnFrameRender(CRenderBatch* batch, uint32_t layer); + + static CSimpleFrame* Create(CSimpleFrame* parent); + static void RenderWorld(void* param); + static void OnWorldUpdate(); + static void OnWorldRender(); + + public: + static CGWorldFrame* s_currentWorldFrame; +}; + +#endif // GAME_UI_CGWORLDFRAME_HPP diff --git a/src/ui/FrameScript.cpp b/src/ui/FrameScript.cpp index f5b5c9f..efef8f8 100644 --- a/src/ui/FrameScript.cpp +++ b/src/ui/FrameScript.cpp @@ -150,7 +150,10 @@ void FrameScript_CreateEvents(const char* names[], uint32_t count) { FrameScript::s_scriptEvents.SetCount(count); for (int32_t i = 0; i < count; i++) { - auto event = FrameScript::s_scriptEventsHash.New(names[i], 0, 0); + FrameScript_EventObject* event = nullptr; + if (names[i]) { + event = FrameScript::s_scriptEventsHash.New(names[i], 0, 0); + } FrameScript::s_scriptEvents[i] = event; } } diff --git a/src/world/World.cpp b/src/world/World.cpp new file mode 100644 index 0000000..6914fc5 --- /dev/null +++ b/src/world/World.cpp @@ -0,0 +1,6 @@ +#include "world/World.hpp" + +int32_t LoadNewWorld() { + + return 1; +} diff --git a/src/world/World.hpp b/src/world/World.hpp index 5cd208a..baaeb05 100644 --- a/src/world/World.hpp +++ b/src/world/World.hpp @@ -3,4 +3,6 @@ #include "world/CWorld.hpp" +int32_t LoadNewWorld(); + #endif