2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2017-03-20 05:09:53 +00:00
|
|
|
#include <array>
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/IObj.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiHeadWidget.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiWidgetIdDB.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-03-11 22:50:15 +00:00
|
|
|
class CGuiCamera;
|
|
|
|
class CGuiLight;
|
2019-09-22 21:52:05 +00:00
|
|
|
class CGuiSys;
|
|
|
|
class CLight;
|
2016-09-02 19:32:57 +00:00
|
|
|
class CObjectReference;
|
2016-12-15 22:37:34 +00:00
|
|
|
class CSimplePool;
|
2019-09-22 21:52:05 +00:00
|
|
|
class CVParamTransfer;
|
|
|
|
struct CFinalInput;
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CGuiFrame {
|
|
|
|
friend class CGuiSys;
|
|
|
|
|
2016-03-11 22:50:15 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<CGuiLight*> m_indexedLights;
|
2018-05-06 23:47:55 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId x0_id;
|
|
|
|
u32 x4_ = 0;
|
|
|
|
CGuiSys& x8_guiSys;
|
|
|
|
std::shared_ptr<CGuiHeadWidget> xc_headWidget;
|
|
|
|
std::shared_ptr<CGuiWidget> x10_rootWidget;
|
|
|
|
std::shared_ptr<CGuiCamera> x14_camera;
|
|
|
|
CGuiWidgetIdDB x18_idDB;
|
|
|
|
std::vector<std::shared_ptr<CGuiWidget>> x2c_widgets;
|
|
|
|
std::vector<std::shared_ptr<CGuiLight>> x3c_lights;
|
|
|
|
int x4c_a;
|
|
|
|
int x50_b;
|
|
|
|
int x54_c;
|
2020-04-20 04:57:50 +00:00
|
|
|
mutable bool x58_24_loaded : 1 = false;
|
2016-03-14 23:32:44 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform m_aspectTransform;
|
|
|
|
float m_aspectConstraint = -1.f;
|
|
|
|
float m_maxAspect = -1.f;
|
2017-01-30 04:16:20 +00:00
|
|
|
|
2020-04-10 06:12:11 +00:00
|
|
|
bool m_inMouseDown = false;
|
|
|
|
bool m_inCancel = false;
|
|
|
|
CGuiWidget* m_mouseDownWidget = nullptr;
|
|
|
|
CGuiWidget* m_lastMouseOverWidget = nullptr;
|
2019-01-20 06:43:11 +00:00
|
|
|
std::function<void(CGuiWidget*, CGuiWidget*)> m_mouseOverChangeCb;
|
2019-01-21 04:10:34 +00:00
|
|
|
std::function<void(CGuiWidget*, bool)> m_mouseDownCb;
|
|
|
|
std::function<void(CGuiWidget*, bool)> m_mouseUpCb;
|
2022-02-22 05:53:57 +00:00
|
|
|
std::function<void(CGuiWidget*, const SScrollDelta&, int, int)> m_mouseScrollCb;
|
2019-01-20 06:43:11 +00:00
|
|
|
|
2016-03-11 05:32:18 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiFrame(CAssetId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp);
|
|
|
|
~CGuiFrame();
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiSys& GetGuiSys() { return x8_guiSys; }
|
2019-08-14 10:04:11 +00:00
|
|
|
const CGuiSys& GetGuiSys() const { return x8_guiSys; }
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId GetAssetId() const { return x0_id; }
|
2016-03-12 04:58:56 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiLight* GetFrameLight(int idx) const { return m_indexedLights[idx]; }
|
|
|
|
CGuiCamera* GetFrameCamera() const { return x14_camera.get(); }
|
|
|
|
CGuiWidget* FindWidget(std::string_view name) const;
|
|
|
|
CGuiWidget* FindWidget(s16 id) const;
|
|
|
|
void SetFrameCamera(std::shared_ptr<CGuiCamera>&& camr) { x14_camera = std::move(camr); }
|
|
|
|
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }
|
|
|
|
CGuiHeadWidget* GetHeadWidget() const { return xc_headWidget.get(); }
|
|
|
|
void SortDrawOrder();
|
2022-02-25 07:45:25 +00:00
|
|
|
void EnableLights(u32 lights) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
void DisableLights() const;
|
|
|
|
void RemoveLight(CGuiLight* light);
|
|
|
|
void AddLight(CGuiLight* light);
|
|
|
|
void RegisterLight(std::shared_ptr<CGuiLight>&& light);
|
|
|
|
bool GetIsFinishedLoading() const;
|
|
|
|
void Touch() const;
|
|
|
|
const zeus::CTransform& GetAspectTransform() const { return m_aspectTransform; }
|
|
|
|
void SetAspectConstraint(float c);
|
|
|
|
void SetMaxAspect(float c);
|
2019-01-20 06:43:11 +00:00
|
|
|
void SetMouseOverChangeCallback(std::function<void(CGuiWidget*, CGuiWidget*)>&& cb) {
|
|
|
|
m_mouseOverChangeCb = std::move(cb);
|
|
|
|
}
|
2021-06-07 19:29:18 +00:00
|
|
|
void SetMouseDownCallback(std::function<void(CGuiWidget*, bool)>&& cb) { m_mouseDownCb = std::move(cb); }
|
|
|
|
void SetMouseUpCallback(std::function<void(CGuiWidget*, bool)>&& cb) { m_mouseUpCb = std::move(cb); }
|
2022-02-22 05:53:57 +00:00
|
|
|
void SetMouseScrollCallback(std::function<void(CGuiWidget*, const SScrollDelta&, int, int)>&& cb) {
|
2019-01-22 04:23:51 +00:00
|
|
|
m_mouseScrollCb = std::move(cb);
|
|
|
|
}
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2019-03-10 09:37:36 +00:00
|
|
|
void Reset();
|
2018-12-08 05:30:43 +00:00
|
|
|
void Update(float dt);
|
|
|
|
void Draw(const CGuiWidgetDrawParms& parms) const;
|
2019-01-20 06:43:11 +00:00
|
|
|
CGuiWidget* BestCursorHit(const zeus::CVector2f& point, const CGuiWidgetDrawParms& parms) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
void Initialize();
|
2022-02-23 08:18:50 +00:00
|
|
|
void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp, u32 version);
|
2018-12-08 05:30:43 +00:00
|
|
|
void ProcessUserInput(const CFinalInput& input) const;
|
2020-04-10 06:12:11 +00:00
|
|
|
bool ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms);
|
2019-01-23 07:52:19 +00:00
|
|
|
void ResetMouseState();
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiWidgetIdDB& GetWidgetIdDB() { return x18_idDB; }
|
2019-08-14 10:04:11 +00:00
|
|
|
const CGuiWidgetIdDB& GetWidgetIdDB() const { return x18_idDB; }
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static std::unique_ptr<CGuiFrame> CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp);
|
2016-03-11 05:32:18 +00:00
|
|
|
};
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
2016-09-02 19:32:57 +00:00
|
|
|
CObjectReference* selfRef);
|
2016-03-16 20:49:35 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|