More GuiSys classes and fields

This commit is contained in:
Jack Andersen 2016-03-11 12:50:15 -10:00
parent cc4b5d3f98
commit 0e637156c2
16 changed files with 441 additions and 50 deletions

View File

@ -1,45 +1,11 @@
#ifndef __URDE_CGUIAUTOREPEATDATA_HPP__
#define __URDE_CGUIAUTOREPEATDATA_HPP__
#include "CGuiPhysicalMsg.hpp"
namespace urde
{
enum class EPhysicalControllerID
{
Seventeen = 17,
Eighteen = 18,
Nineteen = 19,
Twenty = 20,
TwentyOne = 21,
TwentyTwo = 22,
TwentyThree = 23,
TwentyFour = 24,
ThirtyThree = 33,
ThirtyFour = 34,
ThirtyFive = 35,
ThirtySix = 36,
ThirtySeven = 37,
ThirtyEight = 38,
ThirtyNine = 39,
Forty = 40,
FortyOne = 41,
FortyTwo = 42,
FortyThree = 43,
FortyFour = 44,
FortyFive = 45,
FortySix = 46,
FortySeven = 47,
FortyEight = 48,
TwentyFive = 25,
TwentySix = 26,
TwentySeven = 27,
TwentyEight = 28,
TwentyNine = 29,
Thirty = 30,
ThirtyOne = 31,
ThirtyTwo = 32
};
class CGuiAutoRepeatData
{
EPhysicalControllerID x0_a;

View File

@ -0,0 +1,17 @@
#ifndef __URDE_CGUICONTROLLERINFO_HPP__
#define __URDE_CGUICONTROLLERINFO_HPP__
namespace urde
{
class CGuiControllerInfo
{
public:
class CGuiControllerStateInfo
{
};
};
}
#endif // __URDE_CGUICONTROLLERINFO_HPP__

View File

@ -1,12 +1,20 @@
#include "CGuiFrame.hpp"
#include "CGuiWidget.hpp"
#include "CGuiSys.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
CGuiFrame::CGuiFrame(u32 id, const std::string& name, CGuiSys& sys, int, int, int)
: x4_name(name), x14_id(id), x1c_transitionOpts(EFrameTransitionOptions::Zero)
CGuiFrame::CGuiFrame(u32 id, const std::string& name, CGuiSys& sys, int a, int b, int c)
: x4_name(name), x14_id(id), x1c_transitionOpts(EFrameTransitionOptions::Zero),
x3c_guiSys(sys), xb0_a(a), xb4_b(b), xb8_c(c), xbc_24_flag1(false)
{
xa0_.resize(8);
x48_rootWidget.reset(new CGuiWidget(
CGuiWidget::CGuiWidgetParms(this, false, 0, 0, false, false, false, zeus::CColor::skWhite,
CGuiWidget::EGuiModelDrawFlags::Two, false,
x3c_guiSys.x2c_mode != CGuiSys::EUsageMode::Zero)));
}
}

View File

@ -2,10 +2,20 @@
#define __URDE_CGUIFRAME_HPP__
#include "CGuiWidget.hpp"
#include "CGuiAutoRepeatData.hpp"
#include "CGuiPhysicalMsg.hpp"
#include "CGuiControllerInfo.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiWidgetIdDB.hpp"
namespace urde
{
class CGuiSys;
class CLight;
class CGuiCamera;
class CGuiHeadWidget;
class CFinalInput;
class CGuiLight;
enum class EFrameTransitionOptions
{
@ -23,13 +33,85 @@ public:
: x0_opts(opts) {}
};
class CGuiFrameMessageMapNode
{
CGuiLogicalEventTrigger x0_trigger;
public:
CGuiFrameMessageMapNode(const CGuiPhysicalMsg& msg, int val)
: x0_trigger(msg, val, false) {}
};
class CGuiFrame
{
public:
enum class EFrameStates
{
};
private:
std::string x4_name;
u32 x14_id;
CGuiFrameTransitionOptions x1c_transitionOpts;
u32 x34_ = 0;
u32 x38_ = 0;
CGuiSys& x3c_guiSys;
u32 x40_ = 0;
u32 x44_ = 0;
std::unique_ptr<CGuiWidget> x48_rootWidget;
u32 x4c_ = 0;
u32 x50_ = 0;
zeus::CQuaternion x54_;
CGuiWidgetIdDB x64_idDB;
std::unordered_map<u32, u32> x7c_;
std::vector<u32> x90_;
std::vector<u32> xa0_;
int xb0_a;
int xb4_b;
int xb8_c;
bool xbc_24_flag1 : 1;
bool xbd_flag2 = false;
public:
CGuiFrame(u32 id, const std::string& name, CGuiSys& sys, int, int, int);
CGuiFrame(u32 id, const std::string& name, CGuiSys& sys, int a, int b, int c);
CGuiLight* GetFrameLight(int);
CGuiWidget* FindWidget(const char* name) const;
CGuiWidget* FindWidget(const std::string& name) const;
CGuiWidget* FindWidget(s16 id) const;
void ResetControllerStatus();
void SetControllerStatus(int, bool);
void SetFrameBackground(CGuiWidget* widget);
void SetFrameCamera(CGuiCamera* camr);
void SetHeadWidget(CGuiHeadWidget* hwig);
void InterpretGUIControllerState(const CFinalInput& input,
CGuiPhysicalMsg::PhysicalMap& state,
char&, char&, char&, char&);
void FindWidget2LogicalEventMap(u64);
void FindLogicalEventList(u64, s16);
void SendWidgetMessage(s16,
std::list<std::unique_ptr<CGuiFrameMessageMapNode>>&,
CGuiPhysicalMsg::PhysicalMap& state,
CGuiControllerInfo::CGuiControllerStateInfo& csInfo);
void ClearAllMessageMap();
void SortDrawOrder();
void EnableLights(u32) const;
void DisableLights() const;
void RemoveLight(CGuiLight* light);
void AddLight(CGuiLight* light);
bool GetIsFinishedLoading() const;
void Touch() const;
void ProcessControllerInput(const CFinalInput& input);
void Update(float dt);
void Draw(const CGuiWidgetDrawParms& parms) const;
void Stop(const CGuiFrameTransitionOptions&, EFrameStates, bool);
void Run(CGuiFrame*, const CGuiFrameTransitionOptions&, EFrameStates, bool);
void Initialize();
void LoadWidgetsInGame(CInputStream& in);
CGuiWidgetIdDB& GetWidgetIdDB() {return x64_idDB;}
static CGuiFrame* CreateFrame(u32, CGuiSys& sys, CInputStream& in);
static std::string CreateFrameName(u32);
};
}

View File

@ -0,0 +1,19 @@
#include "CGuiHeadWidget.hpp"
#include "CGuiFrame.hpp"
namespace urde
{
CGuiHeadWidget::CGuiHeadWidget(const CGuiWidgetParms& parms)
: CGuiWidget(parms) {}
CGuiHeadWidget* CGuiHeadWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiHeadWidget* ret = new CGuiHeadWidget(parms);
frame->SetHeadWidget(ret);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -0,0 +1,19 @@
#ifndef __URDE_CGUIHEADWIDGET_HPP__
#define __URDE_CGUIHEADWIDGET_HPP__
#include "CGuiWidget.hpp"
namespace urde
{
class CGuiHeadWidget : public CGuiWidget
{
public:
hecl::FourCC GetWidgetTypeID() const {return hecl::FOURCC('HWIG');}
CGuiHeadWidget(const CGuiWidgetParms& parms);
static CGuiHeadWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
};
}
#endif // __URDE_CGUIHEADWIDGET_HPP__

View File

@ -0,0 +1,21 @@
#ifndef __URDE_CGUILOGICALEVENTTRIGGER_HPP__
#define __URDE_CGUILOGICALEVENTTRIGGER_HPP__
#include "CGuiPhysicalMsg.hpp"
namespace urde
{
class CGuiLogicalEventTrigger
{
CGuiPhysicalMsg x0_msg;
int x10_val;
bool x14_flag;
public:
CGuiLogicalEventTrigger(const CGuiPhysicalMsg& msg, int val, bool flag)
: x0_msg(msg), x10_val(val), x14_flag(flag) {}
};
}
#endif // __URDE_CGUILOGICALEVENTTRIGGER_HPP__

View File

@ -0,0 +1,47 @@
#include "CGuiPhysicalMsg.hpp"
namespace urde
{
CGuiPhysicalMsg::CGuiPhysicalMsg(const PhysicalMap& map)
{
SetMessage(map, true);
}
bool CGuiPhysicalMsg::Exists(const CGuiPhysicalMsg& other) const
{
return ((~x8_repeatStates | other.x8_repeatStates) & x0_curStates) == other.x0_curStates;
}
void CGuiPhysicalMsg::SetMessage(const PhysicalMap& map, bool pressed)
{
for (const std::pair<EPhysicalControllerID, CPhysicalID>& item : map)
{
u64 physicalBit = 1 << u64(item.second.x0_key);
if (pressed)
x0_curStates |= physicalBit;
else
x0_curStates &= ~physicalBit;
if (item.second.x4_pressed)
x8_repeatStates |= physicalBit;
else
x8_repeatStates &= ~physicalBit;
}
}
void CGuiPhysicalMsg::AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool pressed)
{
map.emplace(std::make_pair(key, CPhysicalID{key, pressed}));
}
CGuiPhysicalMsg::ControllerState
CGuiPhysicalMsg::FindControllerID(const PhysicalMap& map, EPhysicalControllerID key)
{
auto search = map.find(key);
if (search == map.cend())
return ControllerState::NotFound;
return search->second.x4_pressed ? ControllerState::Pressed : ControllerState::NotPressed;
}
}

View File

@ -0,0 +1,86 @@
#ifndef __URDE_CGUIPHYSICALMSG_HPP__
#define __URDE_CGUIPHYSICALMSG_HPP__
#include <unordered_map>
#include "RetroTypes.hpp"
namespace urde
{
enum class EPhysicalControllerID
{
Seventeen = 17,
Eighteen = 18,
Nineteen = 19,
Twenty = 20,
TwentyOne = 21,
TwentyTwo = 22,
TwentyThree = 23,
TwentyFour = 24,
ThirtyThree = 33,
ThirtyFour = 34,
ThirtyFive = 35,
ThirtySix = 36,
ThirtySeven = 37,
ThirtyEight = 38,
ThirtyNine = 39,
Forty = 40,
FortyOne = 41,
FortyTwo = 42,
FortyThree = 43,
FortyFour = 44,
FortyFive = 45,
FortySix = 46,
FortySeven = 47,
FortyEight = 48,
TwentyFive = 25,
TwentySix = 26,
TwentySeven = 27,
TwentyEight = 28,
TwentyNine = 29,
Thirty = 30,
ThirtyOne = 31,
ThirtyTwo = 32
};
}
namespace std
{
template <> struct hash<urde::EPhysicalControllerID>
{
size_t operator() (const urde::EPhysicalControllerID& id) const noexcept {return size_t(id);}
};
}
namespace urde
{
struct CGuiPhysicalMsg
{
u64 x0_curStates = 0;
u64 x8_repeatStates = 0;
struct CPhysicalID
{
EPhysicalControllerID x0_key;
bool x4_pressed;
CPhysicalID(EPhysicalControllerID key, bool pressed) : x0_key(key), x4_pressed(pressed) {}
};
using PhysicalMap = std::unordered_map<EPhysicalControllerID, CPhysicalID>;
CGuiPhysicalMsg(const PhysicalMap& map);
bool Exists(const CGuiPhysicalMsg& other) const;
void SetMessage(const PhysicalMap& map, bool pressed);
static void AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool pressed);
enum class ControllerState
{
NotFound = -1,
NotPressed = 0,
Pressed = 1
};
static ControllerState FindControllerID(const PhysicalMap& map, EPhysicalControllerID key);
};
}
#endif // __URDE_CGUIPHYSICALMSG_HPP__

View File

@ -9,14 +9,6 @@
#include "CGuiAutoRepeatData.hpp"
#include "CSaveableState.hpp"
namespace std
{
template <> struct hash<urde::EPhysicalControllerID>
{
size_t operator() (const urde::EPhysicalControllerID& id) const NOEXCEPT {return size_t(id);}
};
}
namespace urde
{
class CGuiObject;
@ -40,6 +32,7 @@ public:
class CGuiSys
{
friend class CGuiFrame;
public:
enum class EUsageMode
{

View File

@ -1,4 +1,5 @@
#include "CGuiWidget.hpp"
#include "CGuiFrame.hpp"
namespace urde
{
@ -16,6 +17,34 @@ void CGuiWidget::LoadWidgetFnMap()
WidgetFnMap.emplace(std::make_pair(12, &CGuiWidget::MAF_SetStateOfWidget));
}
CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
{
}
CGuiWidget::CGuiWidgetParms
CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
{
std::string name = in.readString(-1);
s16 selfId = frame->GetWidgetIdDB().AddWidget(name);
std::string parent = in.readString(-1);
s16 parentId = frame->GetWidgetIdDB().AddWidget(parent);
bool a = in.readBool();
bool d = in.readBool();
bool e = in.readBool();
bool f = in.readBool();
zeus::CColor color;
color.readRGBA(in);
EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big());
return CGuiWidget::CGuiWidgetParms(frame, a, selfId, parentId, d, e, f,
color, df, true, flag);
}
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool)
{
}
bool CGuiWidget::MAF_StartAnimationSet(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

View File

@ -3,6 +3,7 @@
#include "IOStreams.hpp"
#include "CGuiObject.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
@ -25,12 +26,37 @@ enum class EGuiAnimInitMode
class CGuiWidget : public CGuiObject
{
public:
enum class EGuiModelDrawFlags
{
Two = 2
};
struct CGuiWidgetParms
{
CGuiFrame* x0_frame;
bool x4_a;
s16 x6_selfId;
s16 x8_parentId;
bool xa_d;
bool xb_e;
bool xc_f;
bool xd_g;
bool xe_h;
zeus::CColor x10_color;
EGuiModelDrawFlags x14_drawFlags;
CGuiWidgetParms(CGuiFrame* frame, bool a, s16 selfId, s16 parentId, bool d, bool e, bool f,
const zeus::CColor& color, EGuiModelDrawFlags drawFlags, bool g, bool h)
: x0_frame(frame), x4_a(a), x6_selfId(selfId), x8_parentId(parentId), xa_d(d), xb_e(e), xc_f(f),
xd_g(g), xe_h(h), x10_color(color), x14_drawFlags(drawFlags) {}
};
static void LoadWidgetFnMap();
virtual hecl::FourCC GetWidgetTypeID() const {return hecl::FOURCC('BWIG');}
private:
public:
CGuiWidget(const CGuiWidgetParms& parms);
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool);
static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
virtual void Message(const CGuiMessage& msg);
virtual void ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms);
virtual void ParseMessages(CInputStream& in, const CGuiWidgetParms& parms);
@ -49,7 +75,6 @@ public:
virtual void AddAnim(EGuiAnimBehListID, CGuiAnimBase*);
virtual void AddChildWidget(CGuiWidget* widget, bool, bool);
virtual void RemoveChildWidget(CGuiWidget* widget, bool);
virtual void GetWidgetTypeID() const;
virtual void AddWorkerWidget(CGuiWidget* worker);
virtual void GetFinishedLoadingWidgetSpecific() const;
virtual void OnVisible();

View File

@ -0,0 +1,47 @@
#include "CGuiWidgetIdDB.hpp"
namespace urde
{
CGuiWidgetIdDB::CGuiWidgetIdDB()
{
AddWidget("kGSYS_DummyWidgetID", 0);
AddWidget("kGSYS_HeadWidgetID", 1);
AddWidget("kGSYS_DefaultCameraID");
AddWidget("kGSYS_DefaultLightID");
}
s16 CGuiWidgetIdDB::FindWidgetID(const std::string& name) const
{
auto search = x0_dbMap.find(name);
if (search == x0_dbMap.cend())
return -1;
return search->second;
}
s16 CGuiWidgetIdDB::AddWidget(const std::string& name, s16 id)
{
s16 findId = FindWidgetID(name);
if (findId == -1)
{
if (id >= x14_lastPoolId)
x14_lastPoolId = id;
x0_dbMap.emplace(std::make_pair(name, id));
findId = id;
}
return findId;
}
s16 CGuiWidgetIdDB::AddWidget(const std::string& name)
{
s16 findId = FindWidgetID(name);
if (findId == -1)
{
++x14_lastPoolId;
x0_dbMap.emplace(std::make_pair(name, x14_lastPoolId));
findId = x14_lastPoolId;
}
return findId;
}
}

View File

@ -0,0 +1,23 @@
#ifndef __URDE_CGUIWIDGETIDDB_HPP__
#define __URDE_CGUIWIDGETIDDB_HPP__
#include <unordered_map>
#include "RetroTypes.hpp"
namespace urde
{
class CGuiWidgetIdDB
{
std::unordered_map<std::string, s16> x0_dbMap;
s16 x14_lastPoolId = 0;
public:
CGuiWidgetIdDB();
s16 FindWidgetID(const std::string& name) const;
s16 AddWidget(const std::string& name, s16 id);
s16 AddWidget(const std::string& name);
};
}
#endif // __URDE_CGUIWIDGETIDDB_HPP__

View File

@ -65,4 +65,13 @@ add_library(RuntimeCommonGuiSys
CGuiFunctionDef.cpp
CGuiFunctionDef.hpp
CGuiFuncParm.cpp
CGuiFuncParm.hpp)
CGuiFuncParm.hpp
CGuiPhysicalMsg.cpp
CGuiPhysicalMsg.hpp
CGuiControllerInfo.hpp
CGuiLogicalEventTrigger.cpp
CGuiLogicalEventTrigger.hpp
CGuiWidgetIdDB.cpp
CGuiWidgetIdDB.hpp
CGuiHeadWidget.cpp
CGuiHeadWidget.hpp)