Refactor GuiSys (remove general logic handling)

This commit is contained in:
Jack Andersen 2016-12-15 12:37:34 -10:00
parent 6b765838a7
commit 19a371c931
54 changed files with 446 additions and 2642 deletions

View File

@ -1,6 +1,4 @@
#include "CAuiEnergyBarT01.hpp" #include "CAuiEnergyBarT01.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {

View File

@ -3,11 +3,4 @@
namespace urde namespace urde
{ {
typedef bool(CAuiMeter::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info);
static std::unordered_map<u32, FMAF> WidgetFnMap;
void CAuiMeter::LoadWidgetFnMap()
{
}
} }

View File

@ -9,7 +9,6 @@ namespace urde
class CAuiMeter : public CGuiCompoundWidget class CAuiMeter : public CGuiCompoundWidget
{ {
public: public:
static void LoadWidgetFnMap();
}; };
} }

View File

@ -1,85 +0,0 @@
#ifndef __URDE_CGUIANIMBASE_HPP__
#define __URDE_CGUIANIMBASE_HPP__
#include "RetroTypes.hpp"
#include "CGuiRandomVar.hpp"
namespace urde
{
class CGuiAnimController;
class CGuiWidgetDrawParams;
enum class EGuiAnimType
{
Rotation = 0,
Translation = 1,
Scaling = 2,
Shearing = 3,
Dissolve = 4,
Keyframe = 5,
Particles = 6,
SFX = 9
};
class CGuiAnimBase
{
friend class CGuiAnimSet;
float x4_ = 0.f;
float x8_ = 0.f;
float xc_;
CGuiRandomVar x10_randomVar;
float x1c_ = 0.f;
bool x20_isDone = false;
s32 x24_ = -1;
bool x28_;
public:
virtual ~CGuiAnimBase() = default;
CGuiAnimBase(float fval, const CGuiRandomVar& randVar, bool flag)
: xc_(fval), x10_randomVar(randVar), x28_(flag) {}
float GetFVal() const {return xc_;}
const CGuiRandomVar& GetRandomVar() const {return x10_randomVar;}
virtual void AnimInit(const CGuiAnimController* controller, float);
virtual void AnimUpdate(CGuiAnimController* controller, float dt);
virtual void AnimDraw(const CGuiWidgetDrawParams& params) const;
virtual void CalcInitVelocity(const CGuiAnimController* controller);
virtual void GetAnimType(const CGuiAnimController* controller) const;
virtual bool GetIsFinishedLoading() const {return true;}
};
class CGuiAnimRotation : public CGuiAnimBase
{
};
class CGuiAnimTranslation : public CGuiAnimBase
{
};
class CGuiAnimScaling : public CGuiAnimBase
{
};
class CGuiAnimShearing : public CGuiAnimBase
{
};
class CGuiAnimDissolve : public CGuiAnimBase
{
};
class CGuiAnimKeyframe : public CGuiAnimBase
{
};
class CGuiAnimParticles : public CGuiAnimBase
{
};
class CGuiAnimSFX : public CGuiAnimBase
{
};
}
#endif // __URDE_CGUIANIMBASE_HPP__

View File

@ -1,174 +0,0 @@
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiAnimBase.hpp"
#include "CGuiControllerInfo.hpp"
namespace urde
{
void CGuiAnimSet::AddAnim(CGuiAnimBase* anim)
{
x0_map[x20_++] = anim;
RecalcTotalTime();
}
void CGuiAnimSet::RecalcTotalTime()
{
x28_totalTime = 0.f;
for (std::pair<const int, CGuiAnimBase*>& anim : x0_map)
{
float num = anim.second->GetRandomVar().GenNum();
if (num < x28_totalTime)
num = x28_totalTime;
else
num += anim.second->GetFVal();
if (num > x28_totalTime)
x28_totalTime = num;
}
}
void CGuiAnimSet::Init(CGuiAnimController* controller, float fval)
{
x19_isDone = false;
x1c_ = false;
for (std::pair<const int, CGuiAnimBase*>& anim : x0_map)
{
x2c_ = 1.f;
anim.second->AnimInit(controller, fval);
}
}
void CGuiAnimSet::Update(CGuiAnimController* controller, bool flag)
{
x19_isDone = true;
for (std::pair<const int, CGuiAnimBase*>& anim : x0_map)
{
anim.second->AnimUpdate(controller, controller->x164_ * x2c_);
if (!anim.second->x20_isDone)
x19_isDone = false;
}
if (x19_isDone && !x1c_)
{
x1c_ = true;
CGuiFuncParm a(intptr_t(controller->x168_widget->GetSelfId()));
CGuiFuncParm b(intptr_t(int(x14_id) + 5));
CGuiFunctionDef fa(0, false, a, b);
CGuiControllerInfo cInfo;
controller->x168_widget->MAF_SendMessage(&fa, &cInfo);
if (x1b_)
controller->x168_widget->SetVisibility(false, ETraversalMode::Children);
}
if (x19_isDone && x1a_ && flag)
Init(controller, 0.f);
}
CGuiAnimController::CGuiAnimController(const CGuiWidget::CGuiWidgetParms& parms, CGuiWidget* widget)
: CGuiWidget(parms), x168_widget(widget)
{
}
CGuiAnimSet* CGuiAnimController::FindAnimSet(EGuiAnimBehListID id) const
{
if (id < EGuiAnimBehListID::Zero || id >= EGuiAnimBehListID::EGuiAnimBehListIDMAX)
return nullptr;
return xf8_sets[int(id)].get();
}
void CGuiAnimController::AddAnimation(CGuiAnimBase* anim, EGuiAnimBehListID id)
{
CGuiAnimSet* set = FindAnimSet(id);
if (!set)
{
xf8_sets[int(id)] = std::make_unique<CGuiAnimSet>(id);
set = xf8_sets[int(id)].get();
}
set->AddAnim(anim);
}
void CGuiAnimController::ResetListUpdateState()
{
for (std::unique_ptr<CGuiAnimSet>& set : xf8_sets)
set->x18_update = false;
}
void CGuiAnimController::SetListUpdateState(EGuiAnimBehListID id, bool state)
{
CGuiAnimSet* set = FindAnimSet(id);
if (set)
set->x18_update = false;
}
float CGuiAnimController::GetAnimSetLength(EGuiAnimBehListID id) const
{
CGuiAnimSet* set = FindAnimSet(id);
if (set)
return set->x28_totalTime;
return 0.f;
}
void CGuiAnimController::IsAnimsDone(EGuiAnimBehListID id, bool& isDone) const
{
CGuiAnimSet* set = FindAnimSet(id);
if (set)
isDone = set->x19_isDone;
else
isDone = true;
}
void CGuiAnimController::InitTransform(CGuiWidget* widget, EGuiAnimBehListID id, float fval,
bool flag, EGuiAnimInitMode initMode)
{
switch (initMode)
{
case EGuiAnimInitMode::One:
case EGuiAnimInitMode::Three:
FinishAnim();
default: break;
}
x80_transform = widget->GetTransform();
switch (initMode)
{
case EGuiAnimInitMode::Three:
case EGuiAnimInitMode::Two:
x16c_ = xb8_;
break;
case EGuiAnimInitMode::One:
x16c_ = zeus::CColor::skClear;
default: break;
}
if (flag)
ResetListUpdateState();
CGuiAnimSet* set = FindAnimSet(id);
if (set)
{
set->Init(this, fval);
set->x18_update = true;
}
Update(0.f);
}
void CGuiAnimController::FinishAnim()
{
float bup = x164_;
x164_ = 100000.f;
Step(false);
x164_ = bup;
}
void CGuiAnimController::Step(bool flag)
{
x170_ = 0;
for (std::unique_ptr<CGuiAnimSet>& set : xf8_sets)
if (set && set->x18_update)
set->Update(this, flag);
}
}

View File

@ -1,57 +0,0 @@
#ifndef __URDE_CGUIANIMCONTROLLER_HPP__
#define __URDE_CGUIANIMCONTROLLER_HPP__
#include "CGuiWidget.hpp"
#include <array>
namespace urde
{
class CGuiAnimSet
{
friend class CGuiAnimController;
std::unordered_map<int, CGuiAnimBase*> x0_map;
EGuiAnimBehListID x14_id;
bool x18_update = false;
bool x19_isDone = true;
bool x1a_ = false;
bool x1b_ = false;
bool x1c_ = false;
u32 x20_ = 0;
u32 x24_ = 0;
float x28_totalTime = 0.f;
float x2c_ = 1.f;
public:
CGuiAnimSet(EGuiAnimBehListID id) : x14_id(id) {}
void AddAnim(CGuiAnimBase* anim);
void RecalcTotalTime();
void Init(CGuiAnimController* controller, float fval);
void Update(CGuiAnimController* controller, bool flag);
};
class CGuiAnimController : public CGuiWidget
{
friend class CGuiAnimSet;
std::array<std::unique_ptr<CGuiAnimSet>, 13> xf8_sets;
float x164_ = 0.f;
CGuiWidget* x168_widget;
zeus::CColor x16c_ = zeus::CColor::skClear;
u32 x170_ = 0;
public:
CGuiAnimController(const CGuiWidget::CGuiWidgetParms& parms, CGuiWidget* widget);
CGuiAnimSet* FindAnimSet(EGuiAnimBehListID id) const;
void AddAnimation(CGuiAnimBase* anim, EGuiAnimBehListID id);
void ResetListUpdateState();
void SetListUpdateState(EGuiAnimBehListID id, bool state);
float GetAnimSetLength(EGuiAnimBehListID id) const;
void IsAnimsDone(EGuiAnimBehListID id, bool& isDone) const;
void InitTransform(CGuiWidget* widget, EGuiAnimBehListID id, float fval, bool flag,
EGuiAnimInitMode initMode);
void FinishAnim();
void Step(bool flag);
};
}
#endif // __URDE_CGUIANIMCONTROLLER_HPP__

View File

@ -1,30 +0,0 @@
#include "CGuiAutoRepeatData.hpp"
namespace urde
{
void CGuiAutoRepeatData::AddAutoEvent(int cIdx, CGuiPhysicalMsg::PhysicalMap& events, float eTime)
{
if (x28_pressed[cIdx])
{
if (x2c_defer[cIdx])
{
x2c_defer[cIdx] = false;
return;
}
if (eTime >= x8_nextDue[cIdx])
{
CGuiPhysicalMsg::AddControllerID(events, x0_instEvent, true);
x8_nextDue[cIdx] = x18_remainder[cIdx] + eTime;
x18_remainder[cIdx] -= 0.05;
if (x18_remainder[cIdx] < 0.05)
x18_remainder[cIdx] = 0.05;
}
if (CGuiPhysicalMsg::FindControllerID(events, x4_contEvent) ==
CGuiPhysicalMsg::EControllerState::NotPressed)
x28_pressed[cIdx] = false;
}
}
}

View File

@ -1,32 +0,0 @@
#ifndef __URDE_CGUIAUTOREPEATDATA_HPP__
#define __URDE_CGUIAUTOREPEATDATA_HPP__
#include "CGuiPhysicalMsg.hpp"
namespace urde
{
class CGuiAutoRepeatData
{
EPhysicalControllerID x0_instEvent;
EPhysicalControllerID x4_contEvent;
float x8_nextDue[4] = {0.f, 0.f, 0.f, 0.f};
float x18_remainder[4] = {0.2f, 0.2f, 0.2f, 0.2f};
bool x28_pressed[4] = {};
bool x2c_defer[4] = {};
public:
CGuiAutoRepeatData(EPhysicalControllerID inst, EPhysicalControllerID cont)
: x0_instEvent(inst), x4_contEvent(cont) {}
void SetActive(int cIdx, float eTime)
{
x8_nextDue[cIdx] = eTime + 0.6f;
x28_pressed[cIdx] = true;
x2c_defer[cIdx] = true;
x18_remainder[cIdx] = 0.2f;
}
void AddAutoEvent(int cIdx, CGuiPhysicalMsg::PhysicalMap& events, float eTime);
};
}
#endif // __URDE_CGUIAUTOREPEATDATA_HPP__

View File

@ -1,6 +1,4 @@
#include "CGuiBackground.hpp" #include "CGuiBackground.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {

View File

@ -1,6 +1,5 @@
#include "CGuiCamera.hpp" #include "CGuiCamera.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiAnimController.hpp"
#include "Graphics/CGraphics.hpp" #include "Graphics/CGraphics.hpp"
namespace urde namespace urde

View File

@ -1,6 +1,4 @@
#include "CGuiCompoundWidget.hpp" #include "CGuiCompoundWidget.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {
@ -10,18 +8,7 @@ CGuiCompoundWidget::CGuiCompoundWidget(const CGuiWidgetParms& parms)
{ {
} }
void CGuiCompoundWidget::OnInvisible() void CGuiCompoundWidget::OnVisibleChange()
{
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child)
{
child->SetIsVisible(false);
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
CGuiWidget::OnInvisible();
}
void CGuiCompoundWidget::OnVisible()
{ {
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject()); CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child) while (child)
@ -29,29 +16,18 @@ void CGuiCompoundWidget::OnVisible()
child->SetIsVisible(true); child->SetIsVisible(true);
child = static_cast<CGuiWidget*>(child->GetNextSibling()); child = static_cast<CGuiWidget*>(child->GetNextSibling());
} }
CGuiWidget::OnVisible(); CGuiWidget::OnVisibleChange();
} }
void CGuiCompoundWidget::OnDeActivate() void CGuiCompoundWidget::OnActiveChange()
{ {
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject()); CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child) while (child)
{ {
child->SetIsActive(false, false); child->SetIsActive(true);
child = static_cast<CGuiWidget*>(child->GetNextSibling()); child = static_cast<CGuiWidget*>(child->GetNextSibling());
} }
CGuiWidget::OnDeActivate(); CGuiWidget::OnActiveChange();
}
void CGuiCompoundWidget::OnActivate(bool flag)
{
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child)
{
child->SetIsActive(true, flag);
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
CGuiWidget::OnDeActivate();
} }
CGuiWidget* CGuiCompoundWidget::GetWorkerWidget(int id) CGuiWidget* CGuiCompoundWidget::GetWorkerWidget(int id)

View File

@ -12,10 +12,8 @@ public:
CGuiCompoundWidget(const CGuiWidgetParms& parms); CGuiCompoundWidget(const CGuiWidgetParms& parms);
FourCC GetWidgetTypeID() const {return FourCC(-1);} FourCC GetWidgetTypeID() const {return FourCC(-1);}
void OnInvisible(); void OnVisibleChange();
void OnVisible(); void OnActiveChange();
void OnDeActivate();
void OnActivate(bool);
virtual CGuiWidget* GetWorkerWidget(int id); virtual CGuiWidget* GetWorkerWidget(int id);
}; };

View File

@ -1,23 +0,0 @@
#ifndef __URDE_CGUICONTROLLERINFO_HPP__
#define __URDE_CGUICONTROLLERINFO_HPP__
#include "RetroTypes.hpp"
namespace urde
{
struct CGuiControllerInfo
{
public:
struct CGuiControllerStateInfo
{
char cIdx = 0;
char lx = 0, ly = 0, rx = 0, ry = 0;
};
u32 x0_ = 0;
CGuiControllerStateInfo x4_stateInfo;
};
}
#endif // __URDE_CGUICONTROLLERINFO_HPP__

View File

@ -1,10 +0,0 @@
#ifndef __URDE_CGUIFACTORIES_HPP__
#define __URDE_CGUIFACTORIES_HPP__
namespace urde
{
}
#endif // __URDE_CGUIFACTORIES_HPP__

View File

@ -2,31 +2,29 @@
#include "CGuiWidget.hpp" #include "CGuiWidget.hpp"
#include "CGuiSys.hpp" #include "CGuiSys.hpp"
#include "CGuiHeadWidget.hpp" #include "CGuiHeadWidget.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiMessage.hpp"
#include "CGuiLight.hpp" #include "CGuiLight.hpp"
#include "CGuiCamera.hpp" #include "CGuiCamera.hpp"
#include "Graphics/CGraphics.hpp" #include "Graphics/CGraphics.hpp"
#include "Input/CFinalInput.hpp" #include "Input/CFinalInput.hpp"
#include "zeus/CColor.hpp" #include "zeus/CColor.hpp"
#include "CSimplePool.hpp"
namespace urde namespace urde
{ {
CGuiFrame::CGuiFrame(ResId id, const std::string& name, CGuiSys& sys, int a, int b, int c) CGuiFrame::CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp)
: x4_name(name), x14_id(id), x1c_transitionOpts(EFrameTransitionOptions::Zero), : x0_id(id), x8_guiSys(sys), x4c_a(a), x50_b(b), x54_c(c), x58_24_loaded(false)
x3c_guiSys(sys), xb0_a(a), xb4_b(b), xb8_c(c), xbc_24_loaded(false)
{ {
xa0_lights.resize(8); x3c_lights.resize(8);
x48_rootWidget.reset(new CGuiWidget( x10_rootWidget.reset(new CGuiWidget(
CGuiWidget::CGuiWidgetParms(this, false, 0, 0, false, false, false, zeus::CColor::skWhite, CGuiWidget::CGuiWidgetParms(this, false, 0, 0, false, false, false, zeus::CColor::skWhite,
CGuiWidget::EGuiModelDrawFlags::Alpha, false, CGuiWidget::EGuiModelDrawFlags::Alpha, false,
x3c_guiSys.x2c_mode != CGuiSys::EUsageMode::Zero))); x8_guiSys.x8_mode != CGuiSys::EUsageMode::Zero)));
} }
CGuiWidget* CGuiFrame::FindWidget(const std::string& name) const CGuiWidget* CGuiFrame::FindWidget(const std::string& name) const
{ {
s16 id = x64_idDB.FindWidgetID(name); s16 id = x18_idDB.FindWidgetID(name);
if (id == -1) if (id == -1)
return nullptr; return nullptr;
return FindWidget(id); return FindWidget(id);
@ -34,319 +32,12 @@ CGuiWidget* CGuiFrame::FindWidget(const std::string& name) const
CGuiWidget* CGuiFrame::FindWidget(s16 id) const CGuiWidget* CGuiFrame::FindWidget(s16 id) const
{ {
return x48_rootWidget->FindWidget(id); return x10_rootWidget->FindWidget(id);
}
void CGuiFrame::ResetControllerStatus()
{
x0_controllerStatus[0] = false;
x0_controllerStatus[1] = false;
x0_controllerStatus[2] = false;
x0_controllerStatus[3] = false;
}
void CGuiFrame::InterpretGUIControllerState(const CFinalInput& input,
CGuiPhysicalMsg::PhysicalMap& state,
char& lx, char& ly, char& rx, char& ry)
{
zeus::CVector2f left(std::fabs(input.ALeftX()), std::fabs(input.ALeftY()));
bool leftThreshold = false;
if (left.magnitude() >= 0.6f)
leftThreshold = true;
zeus::CVector2f right(std::fabs(input.ARightX()), std::fabs(input.ARightY()));
bool rightThreshold = false;
if (right.magnitude() >= 0.6f)
rightThreshold = true;
if (leftThreshold)
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickThreshold, false);
if (input.ALeftX() < 0.f)
lx = input.ALeftX() * 128.f;
else
lx = input.ALeftX() * 127.f;
if (input.ALeftY() < 0.f)
ly = input.ALeftY() * 128.f;
else
ly = input.ALeftY() * 127.f;
if (0.7f < input.ALeftY())
{
if (input.PLAUp())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickUpInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUpInst, false);
}
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickUp, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUp, false);
}
if (-0.7f > input.ALeftY())
{
if (input.PLADown())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickDownInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDownInst, false);
}
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickDown, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDown, false);
}
if (0.7f < input.ALeftX())
{
if (input.PLARight())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRightInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRightInst, false);
}
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRight, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRight, false);
}
if (-0.7f > input.ALeftX())
{
if (input.PLALeft())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickLeftInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeftInst, false);
}
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickLeft, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeft, false);
}
}
else
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftStickRelease, false);
lx = 0;
ly = 0;
}
if (rightThreshold)
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickThreshold, false);
if (input.ARightX() < 0.f)
rx = input.ARightX() * 128.f;
else
rx = input.ARightX() * 127.f;
if (input.ARightY() < 0.f)
ry = input.ARightY() * 128.f;
else
ry = input.ARightY() * 127.f;
if (0.7f < input.ARightY())
{
if (input.PRAUp())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickUpInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickUp, false);
}
if (-0.7f > input.ARightY())
{
if (input.PRADown())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickDownInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickDown, false);
}
if (0.7f < input.ARightX())
{
if (input.PRARight())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRightInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRight, false);
}
if (-0.7f > input.ARightX())
{
if (input.PRALeft())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickLeftInst, false);
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickLeft, false);
}
}
else
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RightStickRelease, false);
rx = 0;
ry = 0;
}
if (input.PDPUp())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadUpInst, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUpInst, false);
}
else if (input.DDPUp())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadUp, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftUp, false);
}
if (input.PDPDown())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadDownInst, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDownInst, false);
}
else if (input.DDPDown())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadDown, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftDown, false);
}
if (input.PDPRight())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadRightInst, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRightInst, false);
}
else if (input.DDPRight())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadRight, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftRight, false);
}
if (input.PDPLeft())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadLeftInst, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeftInst, false);
}
else if (input.DDPLeft())
{
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::DPadLeft, false);
if (leftThreshold)
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LeftLeft, false);
}
if (input.PStart())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::StartInst, false);
if (input.DStart())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Start, false);
if (input.PB())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::BInst, false);
if (input.DB())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::B, false);
if (input.PA())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::AInst, false);
if (input.DA())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::A, false);
if (input.PX())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::XInst, false);
if (input.DX())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::X, false);
if (input.PY())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::YInst, false);
if (input.DY())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Y, false);
if (input.PZ())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::ZInst, false);
if (input.DZ())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::Z, false);
if (input.PLTrigger())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::LInst, false);
if (input.DLTrigger())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::L, false);
if (input.PRTrigger())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::RInst, false);
if (input.DRTrigger())
CGuiPhysicalMsg::AddControllerID(state, EPhysicalControllerID::R, false);
}
CGuiFrame::WidgetToLogicalEventMap* CGuiFrame::FindWidget2LogicalEventMap(u64 events)
{
auto search = x7c_messageMap.find(events);
if (search == x7c_messageMap.cend())
return nullptr;
return search->second.get();
}
CGuiFrame::LogicalEventList* CGuiFrame::FindLogicalEventList(u64 events, s16 id)
{
CGuiFrame::WidgetToLogicalEventMap* map = FindWidget2LogicalEventMap(events);
if (!map)
return nullptr;
auto search = map->find(id);
if (search == map->cend())
return nullptr;
return search->second.get();
}
bool CGuiFrame::SendWidgetMessage(s16 id,
std::list<std::unique_ptr<CGuiFrameMessageMapNode>>& list,
CGuiPhysicalMsg::PhysicalMap& state,
CGuiControllerInfo::CGuiControllerStateInfo& csInfo)
{
CGuiWidget* widget = FindWidget(id);
for (std::unique_ptr<CGuiFrameMessageMapNode>& node : list)
{
CGuiMessage msg(CGuiMessage::Type(node->GetTrigger().GetTriggerId()),
reinterpret_cast<intptr_t>(&state),
reinterpret_cast<intptr_t>(&csInfo));
if (!widget->Message(msg))
return false;
}
return true;
}
void CGuiFrame::ClearAllMessageMap()
{
x7c_messageMap.clear();
}
void CGuiFrame::ClearMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id)
{
CGuiFrame::LogicalEventList* list =
FindLogicalEventList(trigger->GetPhysicalMsg().x0_curStates, id);
if (list)
list->clear();
}
void CGuiFrame::AddMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id)
{
u64 events = trigger->GetPhysicalMsg().x0_curStates;
int triggerId = trigger->GetTriggerId();
CGuiFrame::WidgetToLogicalEventMap* map = FindWidget2LogicalEventMap(events);
if (!map)
{
auto it =
x7c_messageMap.emplace(std::make_pair(events, std::make_unique<WidgetToLogicalEventMap>()));
map = it.first->second.get();
}
CGuiFrame::LogicalEventList* list = FindLogicalEventList(events, id);
if (!list)
{
auto it =
map->emplace(std::make_pair(id, std::make_unique<LogicalEventList>()));
list = it.first->second.get();
}
for (std::unique_ptr<CGuiFrameMessageMapNode>& node : *list)
if (node->GetTrigger().GetTriggerId() == triggerId)
return;
list->push_back(std::make_unique<CGuiFrameMessageMapNode>(trigger->GetPhysicalMsg(), triggerId));
} }
void CGuiFrame::SortDrawOrder() void CGuiFrame::SortDrawOrder()
{ {
std::sort(x90_widgets.begin(), x90_widgets.end(), std::sort(x2c_widgets.begin(), x2c_widgets.end(),
[](const CGuiWidget* a, const CGuiWidget* b) -> bool [](const CGuiWidget* a, const CGuiWidget* b) -> bool
{ {
return a->GetWorldPosition().y < b->GetWorldPosition().y; return a->GetWorldPosition().y < b->GetWorldPosition().y;
@ -359,7 +50,7 @@ void CGuiFrame::EnableLights(u32 lights) const
zeus::CColor accumColor(zeus::CColor::skBlack); zeus::CColor accumColor(zeus::CColor::skBlack);
ERglLight lightId = ERglLight::Zero; ERglLight lightId = ERglLight::Zero;
int idx = 0; int idx = 0;
for (CGuiLight* light : xa0_lights) for (CGuiLight* light : x3c_lights)
{ {
if ((lights & (1 << idx)) != 0) if ((lights & (1 << idx)) != 0)
{ {
@ -371,7 +62,7 @@ void CGuiFrame::EnableLights(u32 lights) const
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId); ++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx; ++idx;
} }
if (xa0_lights.empty()) if (x3c_lights.empty())
CGraphics::SetAmbientColor(zeus::CColor::skWhite); CGraphics::SetAmbientColor(zeus::CColor::skWhite);
else else
CGraphics::SetAmbientColor(accumColor); CGraphics::SetAmbientColor(accumColor);
@ -384,223 +75,69 @@ void CGuiFrame::DisableLights() const
void CGuiFrame::RemoveLight(CGuiLight* light) void CGuiFrame::RemoveLight(CGuiLight* light)
{ {
xa0_lights[light->GetLoadedIdx()] = nullptr; x3c_lights[light->GetLoadedIdx()] = nullptr;
} }
void CGuiFrame::AddLight(CGuiLight* light) void CGuiFrame::AddLight(CGuiLight* light)
{ {
xa0_lights[light->GetLoadedIdx()] = light; x3c_lights[light->GetLoadedIdx()] = light;
} }
bool CGuiFrame::GetIsFinishedLoading() const bool CGuiFrame::GetIsFinishedLoading() const
{ {
if (xbc_24_loaded) if (x58_24_loaded)
return true; return true;
for (const CGuiWidget* widget : x90_widgets) for (const CGuiWidget* widget : x2c_widgets)
{ {
if (widget->GetIsFinishedLoading()) if (widget->GetIsFinishedLoading())
continue; continue;
return false; return false;
} }
const_cast<CGuiFrame*>(this)->xbc_24_loaded = true; const_cast<CGuiFrame*>(this)->x58_24_loaded = true;
return true; return true;
} }
void CGuiFrame::Touch() const void CGuiFrame::Touch() const
{ {
for (const CGuiWidget* widget : x90_widgets) for (const CGuiWidget* widget : x2c_widgets)
widget->Touch(); widget->Touch();
} }
void CGuiFrame::ProcessControllerInput(const CFinalInput& input) void CGuiFrame::Update(float dt)
{ {
if (x18_ & 0x4 && input.ControllerIdx() == 0) xc_headWidget->Update(dt);
{
CGuiPhysicalMsg::PhysicalMap state;
CGuiControllerInfo::CGuiControllerStateInfo stateInfo;
stateInfo.cIdx = input.ControllerIdx();
InterpretGUIControllerState(input, state, stateInfo.lx, stateInfo.ly, stateInfo.rx, stateInfo.ry);
float eventTime = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000000.f;
for (const std::pair<EPhysicalControllerID, CGuiPhysicalMsg::CPhysicalID>& newPair : state)
{
auto search = x3c_guiSys.GetRepeatMap().find(newPair.first);
if (search != x3c_guiSys.GetRepeatMap().end())
search->second.SetActive(input.ControllerIdx(), eventTime);
}
for (std::pair<const EPhysicalControllerID, CGuiAutoRepeatData>& pair : x3c_guiSys.GetRepeatMap())
{
pair.second.AddAutoEvent(input.ControllerIdx(), state, eventTime);
}
CGuiPhysicalMsg msg(state);
SetControllerStatus(input.ControllerIdx(), true);
for (std::pair<const u64, std::unique_ptr<WidgetToLogicalEventMap>>& outer : x7c_messageMap)
{
if (outer.second)
{
for (std::pair<const s16, std::unique_ptr<LogicalEventList>>& inner : *outer.second)
{
if (inner.second && inner.second->size())
{
LogicalEventList& list = *inner.second;
if (msg.Exists(list.back()->GetTrigger().GetPhysicalMsg()))
if (!SendWidgetMessage(inner.first, list, state, stateInfo))
break;
}
}
}
}
}
}
bool CGuiFrame::Update(float dt)
{
if (x34_ != EFrameStates::Four)
return false;
if (x18_ & 2)
{
EGuiAnimBehListID listId = EGuiAnimBehListID::NegOne;
bool something = true;
x44_headWidget->InitializeRGBAFactor();
x44_headWidget->Update(dt);
x44_headWidget->RecalculateAllRGBA();
switch (x34_)
{
case EFrameStates::One:
if (!xbd_flag2)
{
CGuiControllerInfo cInfo;
x44_headWidget->BroadcastMessage(0, &cInfo);
xbd_flag2 = true;
}
break;
case EFrameStates::Three:
listId = EGuiAnimBehListID::One;
break;
default:
break;
}
if (listId != EGuiAnimBehListID::NegOne)
x44_headWidget->IsAllAnimsDone(listId, something, ETraversalMode::ChildrenAndSiblings);
if (something)
{
switch (x34_)
{
case EFrameStates::One:
{
x34_ = x38_;
x44_headWidget->SetAnimUpdateState(EGuiAnimBehListID::Zero, false, ETraversalMode::Single);
x44_headWidget->InitializeAnimControllers(EGuiAnimBehListID::Two, 0.f, false,
EGuiAnimInitMode::Five, ETraversalMode::Single);
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
if (camSib)
{
camSib->SetAnimUpdateState(EGuiAnimBehListID::Zero, false, ETraversalMode::ChildrenAndSiblings);
camSib->InitializeAnimControllers(EGuiAnimBehListID::Two, 0.f, false,
EGuiAnimInitMode::Five, ETraversalMode::ChildrenAndSiblings);
}
xbd_flag2 = false;
break;
}
case EFrameStates::Three:
{
CGuiControllerInfo cInfo;
x44_headWidget->BroadcastMessage(1, &cInfo);
ClearAllMessageMap();
x18_ &= ~0x3;
x44_headWidget->ResetAllAnimUpdateState();
xbd_flag2 = false;
break;
}
default:
break;
}
}
return x34_ != EFrameStates::Zero;
}
return false;
} }
void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const
{ {
if (x18_) if (x4_)
{ {
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
CGraphics::SetAmbientColor(zeus::CColor::skWhite); CGraphics::SetAmbientColor(zeus::CColor::skWhite);
DisableLights(); DisableLights();
x4c_camera->Draw(parms); x14_camera->Draw(parms);
// Set one-stage modulate // Set one-stage modulate
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
if (x50_background)
x50_background->Draw(parms);
for (const CGuiWidget* widget : x90_widgets) for (const CGuiWidget* widget : x2c_widgets)
if (widget->GetIsVisible()) if (widget->GetIsVisible())
widget->Draw(parms); widget->Draw(parms);
} }
CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Front);
} }
void CGuiFrame::Stop(const CGuiFrameTransitionOptions& transOpts, EFrameStates states, bool flag)
{
x18_ &= 0xFFFFFFFB;
x38_ = states;
if (flag)
x34_ = x38_;
else
{
x44_headWidget->InitializeAnimControllers(EGuiAnimBehListID::One, transOpts.xc_, true,
EGuiAnimInitMode::Two, ETraversalMode::Single);
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
if (camSib)
{
camSib->InitializeAnimControllers(EGuiAnimBehListID::One, transOpts.xc_, true,
EGuiAnimInitMode::Two, ETraversalMode::ChildrenAndSiblings);
}
}
}
void CGuiFrame::Run(CGuiFrame* frame, const CGuiFrameTransitionOptions& transOpts,
EFrameStates states, bool flag)
{
ResetControllerStatus();
x34_ = EFrameStates::One;
x38_ = EFrameStates::Two;
float len = 0.f;
x4c_camera->GetBranchAnimLen(EGuiAnimBehListID::Zero, len, ETraversalMode::Single);
len += transOpts.xc_ + transOpts.x10_ + transOpts.x14_;
x44_headWidget->InitializeAnimControllers(EGuiAnimBehListID::Zero, len, true,
EGuiAnimInitMode::One, ETraversalMode::Single);
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
if (camSib)
{
camSib->InitializeAnimControllers(EGuiAnimBehListID::Zero, len, true,
EGuiAnimInitMode::One, ETraversalMode::ChildrenAndSiblings);
}
x18_ |= 0x7;
x44_headWidget->RegisterEventHandler(ETraversalMode::ChildrenAndSiblings);
}
void CGuiFrame::Initialize() void CGuiFrame::Initialize()
{ {
SortDrawOrder(); SortDrawOrder();
x44_headWidget->SetColor(x44_headWidget->xbc_color); xc_headWidget->SetColor(xc_headWidget->xa4_color);
x44_headWidget->InitializeRecursive(); xc_headWidget->InitializeRecursive();
} }
void CGuiFrame::LoadWidgetsInGame(CInputStream& in) void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
{ {
u32 count = in.readUint32Big(); u32 count = in.readUint32Big();
x90_widgets.reserve(count); x2c_widgets.reserve(count);
for (u32 i=0 ; i<count ; ++i) for (u32 i=0 ; i<count ; ++i)
{ {
FourCC type = in.readUint32Big(); FourCC type = in.readUint32Big();
@ -613,39 +150,33 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
case SBIG('BGND'): case SBIG('BGND'):
break; break;
default: default:
x90_widgets.push_back(widget); x2c_widgets.push_back(widget);
break; break;
} }
} }
Initialize(); Initialize();
} }
CGuiFrame* CGuiFrame::CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in) CGuiFrame* CGuiFrame::CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp)
{ {
std::string name = CreateFrameName(frmeId);
in.readInt32Big(); in.readInt32Big();
int a = in.readInt32Big(); int a = in.readInt32Big();
int b = in.readInt32Big(); int b = in.readInt32Big();
int c = in.readInt32Big(); int c = in.readInt32Big();
CGuiFrame* ret = new CGuiFrame(frmeId, name, sys, a, b, c); CGuiFrame* ret = new CGuiFrame(frmeId, sys, a, b, c, sp);
ret->LoadWidgetsInGame(in); ret->LoadWidgetsInGame(in);
return ret; return ret;
} }
std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in, std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in,
const CVParamTransfer&, const CVParamTransfer& cvParms,
CObjectReference* selfRef) CObjectReference* selfRef)
{ {
std::unique_ptr<CGuiFrame> frame(CGuiFrame::CreateFrame(tag.id, *g_GuiSys, in)); CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(cvParms.GetObj())->GetParam());
std::unique_ptr<CGuiFrame> frame(CGuiFrame::CreateFrame(tag.id, *g_GuiSys, in, sp));
return TToken<CGuiFrame>::GetIObjObjectFor(std::move(frame)); return TToken<CGuiFrame>::GetIObjObjectFor(std::move(frame));
} }
std::string CGuiFrame::CreateFrameName(ResId frmeId)
{
/* formatting token originally "frame_%x" for 32-bit ids */
return hecl::Format("frame_%016" PRIX64, frmeId);
}
} }

View File

@ -2,10 +2,6 @@
#define __URDE_CGUIFRAME_HPP__ #define __URDE_CGUIFRAME_HPP__
#include "CGuiWidget.hpp" #include "CGuiWidget.hpp"
#include "CGuiAutoRepeatData.hpp"
#include "CGuiPhysicalMsg.hpp"
#include "CGuiControllerInfo.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiWidgetIdDB.hpp" #include "CGuiWidgetIdDB.hpp"
#include "IObj.hpp" #include "IObj.hpp"
@ -19,99 +15,35 @@ class CFinalInput;
class CGuiLight; class CGuiLight;
class CVParamTransfer; class CVParamTransfer;
class CObjectReference; class CObjectReference;
class CSimplePool;
enum class EFrameTransitionOptions
{
Zero
};
struct CGuiFrameTransitionOptions
{
EFrameTransitionOptions x0_opts;
bool x4_ = true;
float x8_ = 1.f;
float xc_ = 0.f;
float x10_ = 0.f;
float x14_ = 0.f;
public:
CGuiFrameTransitionOptions(EFrameTransitionOptions opts)
: x0_opts(opts) {}
};
class CGuiFrameMessageMapNode
{
CGuiLogicalEventTrigger x0_trigger;
public:
CGuiFrameMessageMapNode(const CGuiPhysicalMsg& msg, int val)
: x0_trigger(msg, val, false) {}
const CGuiLogicalEventTrigger& GetTrigger() const {return x0_trigger;}
};
class CGuiFrame class CGuiFrame
{ {
public:
enum class EFrameStates
{
Zero = 0,
One = 1,
Two = 2,
Three = 3,
Four = 4
};
private: private:
bool x0_controllerStatus[4] = {}; ResId x0_id;
std::string x4_name; u32 x4_ = 0;
ResId x14_id; CGuiSys& x8_guiSys;
u32 x18_ = 0; CGuiHeadWidget* xc_headWidget = nullptr;
CGuiFrameTransitionOptions x1c_transitionOpts; std::unique_ptr<CGuiWidget> x10_rootWidget;
EFrameStates x34_ = EFrameStates::Zero; CGuiCamera* x14_camera = nullptr;
EFrameStates x38_ = EFrameStates::Zero; CGuiWidgetIdDB x18_idDB;
CGuiSys& x3c_guiSys; std::vector<CGuiWidget*> x2c_widgets;
u32 x40_ = 0; std::vector<CGuiLight*> x3c_lights;
CGuiHeadWidget* x44_headWidget = nullptr; int x4c_a;
std::unique_ptr<CGuiWidget> x48_rootWidget; int x50_b;
CGuiCamera* x4c_camera = nullptr; int x54_c;
CGuiWidget* x50_background = nullptr; bool x58_24_loaded : 1;
zeus::CQuaternion x54_;
CGuiWidgetIdDB x64_idDB;
using LogicalEventList = std::list<std::unique_ptr<CGuiFrameMessageMapNode>>;
using WidgetToLogicalEventMap =
std::unordered_map<s16, std::unique_ptr<LogicalEventList>>;
std::unordered_map<u64, std::unique_ptr<WidgetToLogicalEventMap>> x7c_messageMap;
std::vector<CGuiWidget*> x90_widgets;
std::vector<CGuiLight*> xa0_lights;
int xb0_a;
int xb4_b;
int xb8_c;
bool xbc_24_loaded : 1;
bool xbd_flag2 = false;
static void InterpretGUIControllerState(const CFinalInput& input,
CGuiPhysicalMsg::PhysicalMap& state,
char& lx, char& ly, char& rx, char& ry);
public: public:
CGuiFrame(ResId id, const std::string& name, CGuiSys& sys, int a, int b, int c); CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp);
CGuiSys& GetGuiSys() {return x3c_guiSys;} CGuiSys& GetGuiSys() {return x8_guiSys;}
CGuiLight* GetFrameLight(int idx) {return xa0_lights[idx];} CGuiLight* GetFrameLight(int idx) {return x3c_lights[idx];}
CGuiWidget* FindWidget(const std::string& name) const; CGuiWidget* FindWidget(const std::string& name) const;
CGuiWidget* FindWidget(s16 id) const; CGuiWidget* FindWidget(s16 id) const;
void ResetControllerStatus(); void SetFrameCamera(CGuiCamera* camr) {x14_camera = camr;}
void SetControllerStatus(int idx, bool set) {x0_controllerStatus[idx] = set;} void SetHeadWidget(CGuiHeadWidget* hwig) {xc_headWidget = hwig;}
void SetFrameBackground(CGuiWidget* bg) {x50_background = bg;}
void SetFrameCamera(CGuiCamera* camr) {x4c_camera = camr;}
void SetHeadWidget(CGuiHeadWidget* hwig) {x44_headWidget = hwig;}
WidgetToLogicalEventMap* FindWidget2LogicalEventMap(u64 events);
LogicalEventList* FindLogicalEventList(u64 events, s16 id);
bool SendWidgetMessage(s16,
std::list<std::unique_ptr<CGuiFrameMessageMapNode>>&,
CGuiPhysicalMsg::PhysicalMap& state,
CGuiControllerInfo::CGuiControllerStateInfo& csInfo);
void ClearAllMessageMap();
void ClearMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
void AddMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
void SortDrawOrder(); void SortDrawOrder();
void EnableLights(u32 lights) const; void EnableLights(u32 lights) const;
void DisableLights() const; void DisableLights() const;
@ -119,19 +51,15 @@ public:
void AddLight(CGuiLight* light); void AddLight(CGuiLight* light);
bool GetIsFinishedLoading() const; bool GetIsFinishedLoading() const;
void Touch() const; void Touch() const;
void ProcessControllerInput(const CFinalInput& input);
bool Update(float dt); void Update(float dt);
void Draw(const CGuiWidgetDrawParms& parms) const; void Draw(const CGuiWidgetDrawParms& parms) const;
void Stop(const CGuiFrameTransitionOptions&, EFrameStates, bool);
void Run(CGuiFrame*, const CGuiFrameTransitionOptions&, EFrameStates, bool);
void Initialize(); void Initialize();
void LoadWidgetsInGame(CInputStream& in); void LoadWidgetsInGame(CInputStream& in);
CGuiWidgetIdDB& GetWidgetIdDB() {return x64_idDB;} CGuiWidgetIdDB& GetWidgetIdDB() {return x18_idDB;}
static CGuiFrame* CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in); static CGuiFrame* CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp);
static std::string CreateFrameName(ResId frmeId);
}; };
std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in, std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in,

View File

@ -1,44 +0,0 @@
#ifndef __URDE_CGUIFUNCPARM_HPP__
#define __URDE_CGUIFUNCPARM_HPP__
#include "RetroTypes.hpp"
namespace urde
{
class CGuiFuncParm
{
friend class CGuiMessage;
public:
enum class Type
{
Null = -1,
Int = 0,
Float = 1,
IntrusivePointer = 2
};
private:
Type x0_type = Type::Null;
union
{
intptr_t x4_int;
float x4_float;
void* x4_ptr = nullptr;
};
public:
CGuiFuncParm() = default;
CGuiFuncParm(intptr_t arg) : x0_type(Type::Int), x4_int(arg) {}
CGuiFuncParm(float arg) : x0_type(Type::Float), x4_float(arg) {}
CGuiFuncParm(void* arg) : x0_type(Type::IntrusivePointer), x4_ptr(arg) {}
~CGuiFuncParm()
{
if (x0_type == Type::IntrusivePointer)
delete static_cast<u8*>(x4_ptr);
}
};
}
#endif // __URDE_CGUIFUNCPARM_HPP__

View File

@ -1,30 +0,0 @@
#include "CGuiFunctionDef.hpp"
namespace urde
{
CGuiFunctionDef::CGuiFunctionDef(int funcId, bool flag,
const CGuiFuncParm& a, const CGuiFuncParm& b,
const CGuiFuncParm& c, const CGuiFuncParm& d)
: x0_funcId(funcId), x4_parmCount(4), x48_flag(flag)
{
x8_parms[0] = a;
x8_parms[1] = b;
x8_parms[2] = c;
x8_parms[3] = d;
}
CGuiFunctionDef::CGuiFunctionDef(int funcId, bool flag,
const CGuiFuncParm& a, const CGuiFuncParm& b)
: x0_funcId(funcId), x4_parmCount(2), x48_flag(flag)
{
x8_parms[0] = a;
x8_parms[1] = b;
}
CGuiFunctionDef::CGuiFunctionDef(int funcId, bool flag)
: x0_funcId(funcId), x48_flag(flag)
{
}
}

View File

@ -1,32 +0,0 @@
#ifndef __URDE_CGUIFUNCTIONDEF_HPP__
#define __URDE_CGUIFUNCTIONDEF_HPP__
#include "CGuiFuncParm.hpp"
#include <array>
namespace urde
{
class CGuiFunctionDef
{
int x0_funcId;
unsigned x4_parmCount = 0;
std::array<CGuiFuncParm, 8> x8_parms;
bool x48_flag;
public:
const CGuiFuncParm& GetParm(int parm)
{
return x8_parms[parm];
}
CGuiFunctionDef(int funcId, bool,
const CGuiFuncParm& a, const CGuiFuncParm& b,
const CGuiFuncParm& c, const CGuiFuncParm& d);
CGuiFunctionDef(int funcId, bool,
const CGuiFuncParm& a, const CGuiFuncParm& b);
CGuiFunctionDef(int funcId, bool);
};
}
#endif // __URDE_CGUIFUNCTIONDEF_HPP__

View File

@ -1,7 +1,4 @@
#include "CGuiGroup.hpp" #include "CGuiGroup.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiControllerInfo.hpp"
namespace urde namespace urde
{ {
@ -25,8 +22,8 @@ void CGuiGroup::SelectWorkerWidget(int workerId, bool setActive, bool setVisible
CGuiWidget* sel = GetSelectedWidget(); CGuiWidget* sel = GetSelectedWidget();
if (setActive) if (setActive)
{ {
sel->SetIsActive(false, false); sel->SetIsActive(false);
child->SetIsActive(true, false); child->SetIsActive(true);
} }
if (setVisible) if (setVisible)
{ {
@ -50,42 +47,11 @@ bool CGuiGroup::AddWorkerWidget(CGuiWidget* worker)
return true; return true;
} }
void CGuiGroup::OnDeActivate() void CGuiGroup::OnActiveChange()
{ {
CGuiWidget* sel = GetSelectedWidget(); CGuiWidget* sel = GetSelectedWidget();
if (sel) if (sel)
sel->SetIsActive(false, true); sel->SetIsActive(true);
}
void CGuiGroup::OnActivate(bool flag)
{
CGuiWidget* sel = GetSelectedWidget();
if (sel)
sel->SetIsActive(true, flag);
}
bool CGuiGroup::DoUnregisterEventHandler()
{
CGuiWidget::DoUnregisterEventHandler();
GetSelectedWidget()->UnregisterEventHandler(ETraversalMode::Children);
return true;
}
bool CGuiGroup::DoRegisterEventHandler()
{
CGuiWidget::DoRegisterEventHandler();
CGuiWidget* sel = GetSelectedWidget();
if (GetIsActive() && sel)
{
CGuiFuncParm a((intptr_t(sel->GetSelfId())));
CGuiFuncParm b((intptr_t(3)));
CGuiFunctionDef def(0, false, a, b);
CGuiControllerInfo cInfo;
MAF_SendMessage(&def, &cInfo);
}
if (sel)
sel->RegisterEventHandler(ETraversalMode::Children);
return true;
} }
CGuiGroup* CGuiGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag) CGuiGroup* CGuiGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)

View File

@ -18,10 +18,7 @@ public:
void SelectWorkerWidget(int workerId, bool setActive, bool setVisible); void SelectWorkerWidget(int workerId, bool setActive, bool setVisible);
CGuiWidget* GetSelectedWidget(); CGuiWidget* GetSelectedWidget();
bool AddWorkerWidget(CGuiWidget* worker); bool AddWorkerWidget(CGuiWidget* worker);
void OnDeActivate(); void OnActiveChange();
void OnActivate(bool flag);
bool DoUnregisterEventHandler();
bool DoRegisterEventHandler();
static CGuiGroup* Create(CGuiFrame* frame, CInputStream& in, bool flag); static CGuiGroup* Create(CGuiFrame* frame, CInputStream& in, bool flag);
static void LoadWidgetFnMap(); static void LoadWidgetFnMap();

View File

@ -1,6 +1,5 @@
#include "CGuiHeadWidget.hpp" #include "CGuiHeadWidget.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiAnimController.hpp"
namespace urde namespace urde
{ {

View File

@ -1,6 +1,4 @@
#include "CGuiLight.hpp" #include "CGuiLight.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
namespace urde namespace urde
@ -21,7 +19,7 @@ CGuiLight::CGuiLight(const CGuiWidgetParms& parms, const CLight& light)
CGuiLight::~CGuiLight() CGuiLight::~CGuiLight()
{ {
xc8_frame->RemoveLight(this); xb0_frame->RemoveLight(this);
} }
CLight CGuiLight::BuildLight() const CLight CGuiLight::BuildLight() const
@ -31,13 +29,13 @@ CLight CGuiLight::BuildLight() const
switch (xf8_type) switch (xf8_type)
{ {
case ELightType::Spot: case ELightType::Spot:
ret = CLight::BuildSpot(GetWorldPosition(), x34_worldXF.basis[1], xbc_color, xfc_spotCutoff); ret = CLight::BuildSpot(GetWorldPosition(), x34_worldXF.basis[1], xa4_color, xfc_spotCutoff);
break; break;
case ELightType::Point: case ELightType::Point:
ret = CLight::BuildPoint(GetWorldPosition(), xbc_color); ret = CLight::BuildPoint(GetWorldPosition(), xa4_color);
break; break;
case ELightType::Directional: case ELightType::Directional:
ret = CLight::BuildDirectional(x34_worldXF.basis[1], xbc_color); ret = CLight::BuildDirectional(x34_worldXF.basis[1], xa4_color);
break; break;
default: break; default: break;
} }
@ -50,9 +48,9 @@ CLight CGuiLight::BuildLight() const
void CGuiLight::SetIsVisible(bool vis) void CGuiLight::SetIsVisible(bool vis)
{ {
if (vis) if (vis)
xc8_frame->AddLight(this); xb0_frame->AddLight(this);
else else
xc8_frame->RemoveLight(this); xb0_frame->RemoveLight(this);
CGuiWidget::SetIsVisible(vis); CGuiWidget::SetIsVisible(vis);
} }

View File

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

View File

@ -1,38 +0,0 @@
#ifndef __URDE_CGUIMESSAGE_HPP__
#define __URDE_CGUIMESSAGE_HPP__
#include "RetroTypes.hpp"
#include "CGuiFuncParm.hpp"
namespace urde
{
class CGuiMessage
{
public:
enum class Type
{
Eighteen = 18,
Nineteen = 19
};
private:
Type x4_type;
CGuiFuncParm x8_a;
CGuiFuncParm x10_b;
public:
CGuiMessage(Type type, intptr_t a, intptr_t b)
: x4_type(type), x8_a(a), x10_b(b) {}
Type GetType() const {return x4_type;}
intptr_t GetInt(u32 val) const
{
if (val == 0x60EF4DB0)
return x8_a.x4_int;
else
return x10_b.x4_int;
}
};
}
#endif // __URDE_CGUIMESSAGE_HPP__

View File

@ -2,7 +2,6 @@
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiSys.hpp" #include "CGuiSys.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiWidgetDrawParms.hpp" #include "CGuiWidgetDrawParms.hpp"
#include "Graphics/CGraphics.hpp" #include "Graphics/CGraphics.hpp"
@ -55,13 +54,13 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
if (GetIsVisible()) if (GetIsVisible())
{ {
zeus::CColor moduCol = xb4_; zeus::CColor moduCol = xa8_color2;
moduCol.a *= parms.x0_alphaMod; moduCol.a *= parms.x0_alphaMod;
xc8_frame->EnableLights(x10c_lightMask); xb0_frame->EnableLights(x10c_lightMask);
if (xf6_29_cullFaces) if (xb6_29_cullFaces)
CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Front);
switch (xc4_drawFlags) switch (xac_drawFlags)
{ {
case EGuiModelDrawFlags::Shadeless: case EGuiModelDrawFlags::Shadeless:
{ {
@ -77,24 +76,24 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
} }
case EGuiModelDrawFlags::Alpha: case EGuiModelDrawFlags::Alpha:
{ {
CModelFlags flags(4, 0, (xf7_24_depthWrite << 1) | xf6_31_depthTest, moduCol); CModelFlags flags(4, 0, (xb7_24_depthWrite << 1) | xb6_31_depthTest, moduCol);
model->Draw(flags); model->Draw(flags);
break; break;
} }
case EGuiModelDrawFlags::Additive: case EGuiModelDrawFlags::Additive:
{ {
CModelFlags flags(3, 0, (xf7_24_depthWrite << 1) | xf6_31_depthTest, moduCol); CModelFlags flags(3, 0, (xb7_24_depthWrite << 1) | xb6_31_depthTest, moduCol);
model->Draw(flags); model->Draw(flags);
break; break;
} }
case EGuiModelDrawFlags::AlphaAdditiveOverdraw: case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
{ {
CModelFlags flags(4, 0, xf6_31_depthTest, moduCol); CModelFlags flags(4, 0, xb6_31_depthTest, moduCol);
model->Draw(flags); model->Draw(flags);
flags.m_blendMode = 5; flags.m_blendMode = 5;
flags.m_matSetIdx = 0; flags.m_matSetIdx = 0;
flags.m_flags = (xf7_24_depthWrite << 1) | xf6_31_depthTest; flags.m_flags = (xb7_24_depthWrite << 1) | xb6_31_depthTest;
flags.color = moduCol; flags.color = moduCol;
model->Draw(flags); model->Draw(flags);
break; break;
@ -102,9 +101,9 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
default: break; default: break;
} }
if (xf6_29_cullFaces) if (xb6_29_cullFaces)
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
xc8_frame->DisableLights(); xb0_frame->DisableLights();
} }
CGuiWidget::Draw(parms); CGuiWidget::Draw(parms);

View File

@ -9,9 +9,6 @@
namespace urde namespace urde
{ {
struct CGuiWidgetDrawParms; struct CGuiWidgetDrawParms;
class CGuiMessage;
class CGuiFunctionDef;
struct CGuiControllerInfo;
class CGuiObject class CGuiObject
{ {
@ -26,7 +23,7 @@ public:
virtual ~CGuiObject(); virtual ~CGuiObject();
virtual void Update(float dt); virtual void Update(float dt);
virtual void Draw(const CGuiWidgetDrawParms& parms) const; virtual void Draw(const CGuiWidgetDrawParms& parms) const;
virtual bool Message(const CGuiMessage& msg)=0; virtual bool Message()=0;
void MoveInWorld(const zeus::CVector3f& vec); void MoveInWorld(const zeus::CVector3f& vec);
const zeus::CVector3f& GetLocalPosition() const {return x4_localXF.origin;} const zeus::CVector3f& GetLocalPosition() const {return x4_localXF.origin;}

View File

@ -1,6 +1,4 @@
#include "CGuiPane.hpp" #include "CGuiPane.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {

View File

@ -1,47 +0,0 @@
#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_repeat)
x8_repeatStates |= physicalBit;
else
x8_repeatStates &= ~physicalBit;
}
}
void CGuiPhysicalMsg::AddControllerID(PhysicalMap& map, EPhysicalControllerID key, bool repeat)
{
map.emplace(std::make_pair(key, CPhysicalID{key, repeat}));
}
CGuiPhysicalMsg::EControllerState
CGuiPhysicalMsg::FindControllerID(const PhysicalMap& map, EPhysicalControllerID key)
{
auto search = map.find(key);
if (search == map.cend())
return EControllerState::NotPressed;
return search->second.x4_repeat ? EControllerState::PressRepeat : EControllerState::Press;
}
}

View File

@ -1,111 +0,0 @@
#ifndef __URDE_CGUIPHYSICALMSG_HPP__
#define __URDE_CGUIPHYSICALMSG_HPP__
#include <unordered_map>
#include "RetroTypes.hpp"
namespace urde
{
enum class EPhysicalControllerID
{
AInst = 1,
A = 2,
BInst = 3,
B = 4,
LInst = 5,
L = 6,
RInst = 7,
R = 8,
XInst = 9,
X = 10,
YInst = 11,
Y = 12,
ZInst = 13,
Z = 14,
StartInst = 15,
Start = 16,
DPadUpInst = 17,
DPadUp = 18,
DPadRightInst = 19,
DPadRight = 20,
DPadDownInst = 21,
DPadDown = 22,
DPadLeftInst = 23,
DPadLeft = 24,
LeftUpInst = 25,
LeftUp = 26,
LeftRightInst = 27,
LeftRight = 28,
LeftDownInst = 29,
LeftDown = 30,
LeftLeftInst = 31,
LeftLeft = 32,
LeftStickUpInst = 33,
LeftStickUp = 34,
LeftStickRightInst = 35,
LeftStickRight = 36,
LeftStickDownInst = 37,
LeftStickDown = 38,
LeftStickLeftInst = 39,
LeftStickLeft = 40,
RightStickUpInst = 41,
RightStickUp = 42,
RightStickRightInst = 43,
RightStickRight = 44,
RightStickDownInst = 45,
RightStickDown = 46,
RightStickLeftInst = 47,
RightStickLeft = 48,
LeftStickThreshold = 49,
LeftStickRelease = 50,
RightStickThreshold = 51,
RightStickRelease = 52
};
}
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_repeat;
CPhysicalID(EPhysicalControllerID key, bool repeat) : x0_key(key), x4_repeat(repeat) {}
};
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 repeat);
enum class EControllerState
{
NotPressed = -1,
Press = 0,
PressRepeat = 1
};
static EControllerState FindControllerID(const PhysicalMap& map, EPhysicalControllerID key);
};
}
#endif // __URDE_CGUIPHYSICALMSG_HPP__

View File

@ -1,32 +0,0 @@
#ifndef __URDE_CGUIRANDOMVAR_HPP__
#define __URDE_CGUIRANDOMVAR_HPP__
namespace urde
{
class CGuiRandomVar
{
public:
enum class Type
{
Zero,
One
} x0_type;
float x4_num;
float GenNum() const
{
switch (x0_type)
{
case Type::Zero:
case Type::One:
return x4_num;
default: break;
}
return 0.f;
}
};
}
#endif // __URDE_CGUIRANDOMVAR_HPP__

View File

@ -1,19 +1,8 @@
#include "CGuiSliderGroup.hpp" #include "CGuiSliderGroup.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {
typedef bool(CGuiSliderGroup::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info);
static std::unordered_map<u32, FMAF> WidgetFnMap;
void CGuiSliderGroup::LoadWidgetFnMap()
{
WidgetFnMap.emplace(std::make_pair(18, &CGuiSliderGroup::MAF_Increment));
WidgetFnMap.emplace(std::make_pair(19, &CGuiSliderGroup::MAF_Decrement));
}
CGuiSliderGroup::CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d) CGuiSliderGroup::CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d)
: CGuiCompoundWidget(parms), xf8_minVal(a), xfc_maxVal(b), x100_curVal(c), x104_increment(d) : CGuiCompoundWidget(parms), xf8_minVal(a), xfc_maxVal(b), x100_curVal(c), x104_increment(d)
{ {
@ -25,22 +14,6 @@ void CGuiSliderGroup::SetSelectionChangedCallback
x114_changeCallback = std::move(func); x114_changeCallback = std::move(func);
} }
bool CGuiSliderGroup::MAF_Increment(CGuiFunctionDef*, CGuiControllerInfo*)
{
float oldVal = x100_curVal;
SetCurVal(x100_curVal + x104_increment);
x114_changeCallback(this, oldVal);
return true;
}
bool CGuiSliderGroup::MAF_Decrement(CGuiFunctionDef*, CGuiControllerInfo*)
{
float oldVal = x100_curVal;
SetCurVal(x100_curVal - x104_increment);
x114_changeCallback(this, oldVal);
return true;
}
void CGuiSliderGroup::SetCurVal(float cur) void CGuiSliderGroup::SetCurVal(float cur)
{ {
x100_curVal = zeus::clamp(xf8_minVal, cur, xfc_maxVal); x100_curVal = zeus::clamp(xf8_minVal, cur, xfc_maxVal);

View File

@ -19,11 +19,8 @@ class CGuiSliderGroup : public CGuiCompoundWidget
public: public:
CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d); CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d);
FourCC GetWidgetTypeID() const {return FOURCC('SLGP');} FourCC GetWidgetTypeID() const {return FOURCC('SLGP');}
static void LoadWidgetFnMap();
void SetSelectionChangedCallback(std::function<void(const CGuiSliderGroup*, float)>&& func); void SetSelectionChangedCallback(std::function<void(const CGuiSliderGroup*, float)>&& func);
bool MAF_Increment(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_Decrement(CGuiFunctionDef* def, CGuiControllerInfo* info);
void SetIncrement(float inc) {x104_increment = inc;} void SetIncrement(float inc) {x104_increment = inc;}
void SetMinVal(float min) {xf8_minVal = min; SetCurVal(x100_curVal);} void SetMinVal(float min) {xf8_minVal = min; SetCurVal(x100_curVal);}
void SetMaxVal(float max) {xfc_maxVal = max; SetCurVal(x100_curVal);} void SetMaxVal(float max) {xfc_maxVal = max; SetCurVal(x100_curVal);}

View File

@ -1,6 +1,4 @@
#include "CGuiStaticImage.hpp" #include "CGuiStaticImage.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiSys.hpp" #include "CGuiSys.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"

View File

@ -25,15 +25,6 @@ CGuiSys* g_GuiSys = nullptr;
CTextExecuteBuffer* g_TextExecuteBuf = nullptr; CTextExecuteBuffer* g_TextExecuteBuf = nullptr;
CTextParser* g_TextParser = nullptr; CTextParser* g_TextParser = nullptr;
void CGuiSys::AddFactories(EUsageMode /* mode */)
{
x8_factoryMgr.m_factories.clear();
}
void CGuiSys::LoadWidgetFunctions()
{
}
CGuiWidget* CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame) CGuiWidget* CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame)
{ {
switch (type) switch (type)
@ -74,62 +65,12 @@ CGuiWidget* CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame
} }
CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode) CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode)
: x0_resFactory(resFactory), x4_resStore(resStore), x2c_mode(mode), : x0_resFactory(resFactory), x4_resStore(resStore), x8_mode(mode),
x38_frameFactoryParams(new TObjOwnerParam<CGuiResFrameData>(CGuiResFrameData(*this))), xc_textExecuteBuf(new CTextExecuteBuffer()),
x30_textExecuteBuf(new CTextExecuteBuffer()), x10_textParser(new CTextParser(resStore))
x34_textParser(new CTextParser(resStore)),
x40_constructTime(std::chrono::steady_clock::now())
{ {
AddFactories(mode); g_TextExecuteBuf = xc_textExecuteBuf.get();
LoadWidgetFunctions(); g_TextParser = x10_textParser.get();
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadUpInst,
CGuiAutoRepeatData(EPhysicalControllerID::DPadUpInst, EPhysicalControllerID::DPadUp)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadRightInst,
CGuiAutoRepeatData(EPhysicalControllerID::DPadRightInst, EPhysicalControllerID::DPadRight)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadDownInst,
CGuiAutoRepeatData(EPhysicalControllerID::DPadDownInst, EPhysicalControllerID::DPadDown)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::DPadLeftInst,
CGuiAutoRepeatData(EPhysicalControllerID::DPadLeftInst, EPhysicalControllerID::DPadLeft)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickRightInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickRightInst, EPhysicalControllerID::LeftStickRight)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickDownInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickDownInst, EPhysicalControllerID::LeftStickDown)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftStickLeftInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftStickLeftInst, EPhysicalControllerID::LeftStickLeft)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickUpInst,
CGuiAutoRepeatData(EPhysicalControllerID::RightStickUpInst, EPhysicalControllerID::RightStickUp)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickRightInst,
CGuiAutoRepeatData(EPhysicalControllerID::RightStickRightInst, EPhysicalControllerID::RightStickRight)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickDownInst,
CGuiAutoRepeatData(EPhysicalControllerID::RightStickDownInst, EPhysicalControllerID::RightStickDown)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::RightStickLeftInst,
CGuiAutoRepeatData(EPhysicalControllerID::RightStickLeftInst, EPhysicalControllerID::RightStickLeft)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftUpInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftUpInst, EPhysicalControllerID::LeftUp)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftRightInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftRightInst, EPhysicalControllerID::LeftRight)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftDownInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftDownInst, EPhysicalControllerID::LeftDown)));
x18_repeatMap.emplace(std::make_pair(EPhysicalControllerID::LeftLeftInst,
CGuiAutoRepeatData(EPhysicalControllerID::LeftLeftInst, EPhysicalControllerID::LeftLeft)));
g_TextExecuteBuf = x30_textExecuteBuf.get();
g_TextParser = x34_textParser.get();
} }
} }

View File

@ -5,8 +5,6 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <chrono>
#include "CGuiAutoRepeatData.hpp"
#include "CSaveableState.hpp" #include "CSaveableState.hpp"
#include "IOStreams.hpp" #include "IOStreams.hpp"
@ -22,19 +20,6 @@ class CGuiFrame;
class CTextParser; class CTextParser;
class CTextExecuteBuffer; class CTextExecuteBuffer;
typedef CGuiObject*(*FGuiFactoryFunc)(const SObjectTag&, const CVParamTransfer&);
class CGuiFactoryMgr
{
friend class CGuiSys;
std::unordered_map<FourCC, FGuiFactoryFunc> m_factories;
public:
void AddFactory(FourCC key, FGuiFactoryFunc func)
{
m_factories[key] = func;
}
};
class CGuiSys class CGuiSys
{ {
friend class CGuiFrame; friend class CGuiFrame;
@ -48,23 +33,16 @@ public:
private: private:
IFactory& x0_resFactory; IFactory& x0_resFactory;
CSimplePool& x4_resStore; CSimplePool& x4_resStore;
CGuiFactoryMgr x8_factoryMgr; EUsageMode x8_mode;
std::unordered_map<EPhysicalControllerID, CGuiAutoRepeatData> x18_repeatMap; std::unique_ptr<CTextExecuteBuffer> xc_textExecuteBuf;
EUsageMode x2c_mode; std::unique_ptr<CTextParser> x10_textParser;
std::unique_ptr<CTextExecuteBuffer> x30_textExecuteBuf;
std::unique_ptr<CTextParser> x34_textParser;
CVParamTransfer x38_frameFactoryParams;
std::chrono::time_point<std::chrono::steady_clock> x40_constructTime;
void AddFactories(EUsageMode mode);
void LoadWidgetFunctions();
static CGuiWidget* CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame); static CGuiWidget* CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame);
public: public:
CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode); CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode);
CSimplePool& GetResStore() {return x4_resStore;} CSimplePool& GetResStore() {return x4_resStore;}
std::unordered_map<EPhysicalControllerID, CGuiAutoRepeatData>& GetRepeatMap() {return x18_repeatMap;} EUsageMode GetUsageMode() const {return x8_mode;}
EUsageMode GetUsageMode() const {return x2c_mode;}
}; };
/** Global GuiSys instance */ /** Global GuiSys instance */
@ -76,13 +54,6 @@ extern CTextExecuteBuffer* g_TextExecuteBuf;
/** Global CTextParser instance */ /** Global CTextParser instance */
extern CTextParser* g_TextParser; extern CTextParser* g_TextParser;
/** Parameter pack for FRME factory */
struct CGuiResFrameData
{
CGuiSys& x0_guiSys;
CGuiResFrameData(CGuiSys& guiSys) : x0_guiSys(guiSys) {}
};
} }
#endif // __URDE_CGUISYS_HPP__ #endif // __URDE_CGUISYS_HPP__

View File

@ -1,282 +1,36 @@
#include "CGuiTableGroup.hpp" #include "CGuiTableGroup.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde namespace urde
{ {
typedef bool(CGuiTableGroup::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info); CGuiTableGroup::CGuiTableGroup(const CGuiWidgetParms& parms, int a, int b, bool c)
static std::unordered_map<u32, FMAF> WidgetFnMap;
void CGuiTableGroup::LoadWidgetFnMap()
{
WidgetFnMap.emplace(std::make_pair(21, &CGuiTableGroup::MAF_SelectNextColumn));
WidgetFnMap.emplace(std::make_pair(22, &CGuiTableGroup::MAF_SelectPrevColumn));
WidgetFnMap.emplace(std::make_pair(23, &CGuiTableGroup::MAF_SelectNextRow));
WidgetFnMap.emplace(std::make_pair(24, &CGuiTableGroup::MAF_SelectPrevRow));
WidgetFnMap.emplace(std::make_pair(25, &CGuiTableGroup::MAF_SelectNextColumnSkipUnActivated));
WidgetFnMap.emplace(std::make_pair(26, &CGuiTableGroup::MAF_SelectPrevColumnSkipUnActivated));
WidgetFnMap.emplace(std::make_pair(27, &CGuiTableGroup::MAF_SelectNextRowSkipUnActivated));
WidgetFnMap.emplace(std::make_pair(28, &CGuiTableGroup::MAF_SelectPrevRowSkipUnActivated));
WidgetFnMap.emplace(std::make_pair(29, &CGuiTableGroup::MAF_SelectColumnAtIndex));
WidgetFnMap.emplace(std::make_pair(30, &CGuiTableGroup::MAF_SelectRowAtIndex));
WidgetFnMap.emplace(std::make_pair(31, &CGuiTableGroup::MAF_InitializeTable));
WidgetFnMap.emplace(std::make_pair(32, &CGuiTableGroup::MAF_MenuAdvance));
WidgetFnMap.emplace(std::make_pair(33, &CGuiTableGroup::MAF_MenuCancel));
}
void CGuiVirtualBox::GetDifference(int a, int b, int& aOut, int& bOut)
{
if (a < x0_)
{
aOut = a - x0_;
}
else
{
if (a > x0_ + x8_)
aOut = a - x0_ + x8_;
else
aOut = 0;
}
if (b < x4_)
{
bOut = b - x4_;
}
else
{
if (b > x4_ + xc_)
bOut = b - x4_ + xc_;
else
bOut = 0;
}
}
bool CGuiVirtualBox::ShiftHorizontal(int a, bool b)
{
bool ret = false;
FillCellsInBox(x24_.get());
int r31 = x4_ + a;
if (r31 < 0)
{
ret = true;
if (b)
x4_ = x14_ - xc_;
else
x4_ = 0;
}
else
{
if (r31 + xc_ > x14_)
{
ret = true;
if (b)
x4_ = 0;
else
x4_ = x14_ - xc_;
}
else
x4_ = r31;
}
FillCellsInBox(x20_.get());
ResolveTransitionCells();
return ret;
}
bool CGuiVirtualBox::ShiftVertical(int a, bool b)
{
bool ret = false;
FillCellsInBox(x24_.get());
int r31 = x0_ + a;
if (r31 < 0)
{
ret = true;
if (b)
x0_ = x10_ - x8_;
else
x0_ = 0;
}
else
{
if (r31 + x8_ > x10_)
{
ret = true;
if (b)
x0_ = 0;
else
x0_ = x10_ - x8_;
}
else
x0_ = r31;
}
FillCellsInBox(x20_.get());
ResolveTransitionCells();
return ret;
}
void CGuiVirtualBox::ResolveTransitionCells()
{
int prod = x8_ * xc_;
x1c_ = 0;
for (int i=0 ; i<prod ; ++i)
x20_[i].x8_ = 0;
for (int i=0 ; i<prod ; ++i)
{
CCellPos& c1 = x24_[i];
bool needsAdd = true;
for (int j=0 ; j<prod ; ++j)
{
CCellPos& c2 = x20_[i];
if (c2.x8_)
continue;
if (c1.x0_ == c2.x0_ && c1.x4_ == c2.x4_)
{
c2.x8_ = true;
needsAdd = false;
break;
}
}
if (needsAdd)
x2c_[x1c_++] = c1;
}
for (int i=0, j=0 ; i<prod ; ++i)
{
CCellPos& c1 = x20_[i];
if (c1.x8_)
continue;
x28_[j++] = c1;
}
}
void CGuiVirtualBox::FillCellsInBox(CCellPos* cells)
{
for (int i=0 ; i<x8_ ; ++i)
{
int val = x0_ + i;
for (int j=0 ; j<xc_ ; ++j)
{
CCellPos& cell = cells[i*xc_+j];
cell.x0_ = val;
cell.x4_ = x4_ + j;
}
}
}
CGuiTableGroup::CGuiTableGroup(const CGuiWidgetParms& parms, int a, int b, ETableGroupModes modes,
int c, int d, bool e, bool f, float g, float h, bool i, float j,
CGuiVirtualBox&& box)
: CGuiCompoundWidget(parms), : CGuiCompoundWidget(parms),
xf8_(a), xfc_(b), xc0_(a), xc4_(b),
x118_(f), x119_(e), xc8_(b), xcc_(b),
x11c_(h), x120_(g), xd0_(c)
x124_(i), x128_(j), {}
x130_modes(modes),
x134_box(std::move(box))
{
x100_[0][0] = c;
x100_[0][1] = d;
x100_[1][0] = c;
x100_[1][1] = d;
x100_[2][0] = c;
x100_[2][1] = d;
}
bool CGuiTableGroup::MAF_SelectNextColumn(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectPrevColumn(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectNextRow(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectPrevRow(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectNextColumnSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectPrevColumnSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectNextRowSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectPrevRowSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectColumnAtIndex(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_SelectRowAtIndex(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_InitializeTable(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_MenuAdvance(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiTableGroup::MAF_MenuCancel(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
CGuiTableGroup* CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag) CGuiTableGroup* CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{ {
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag); CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
int a = in.readInt16Big(); int a = in.readInt16Big();
in.readInt16Big();
in.readUint32Big();
int b = in.readInt16Big(); int b = in.readInt16Big();
ETableGroupModes modes = ETableGroupModes(in.readUint32Big()); in.readInt16Big();
int c = in.readInt16Big(); bool c = in.readBool();
int d = in.readInt16Big(); in.readBool();
bool e = in.readBool(); in.readFloatBig();
bool f = in.readBool(); in.readFloatBig();
float g = in.readFloatBig(); in.readBool();
float h = in.readFloatBig(); in.readFloatBig();
bool i = in.readBool(); in.readInt16Big();
float j = in.readFloatBig(); in.readInt16Big();
in.readInt16Big();
in.readInt16Big();
int ba = in.readInt16Big(); CGuiTableGroup* ret = new CGuiTableGroup(parms, a, b, c);
int bb = in.readInt16Big();
int bc = in.readInt16Big();
int bd = in.readInt16Big();
CGuiVirtualBox box(ba, bb, bc, bd, a, b);
CGuiTableGroup* ret = new CGuiTableGroup(parms, a, b, modes, c, d, e,
f, g, h, i, j, std::move(box));
ret->ParseBaseInfo(frame, in, parms); ret->ParseBaseInfo(frame, in, parms);
return ret; return ret;
} }

View File

@ -6,83 +6,30 @@
namespace urde namespace urde
{ {
struct CCellPos
{
u32 x0_ = 0;
u32 x4_ = 0;
bool x8_ = false;
};
class CGuiVirtualBox
{
int x0_;
int x4_;
int x8_;
int xc_;
int x10_;
int x14_;
int x18_;
int x1c_ = 0;
std::unique_ptr<CCellPos[]> x20_;
std::unique_ptr<CCellPos[]> x24_;
std::unique_ptr<CCellPos[]> x28_;
std::unique_ptr<CCellPos[]> x2c_;
public:
CGuiVirtualBox(int a,int b,int c,int d,int e,int f)
: x0_(a), x4_(b), x8_(c), xc_(d), x10_(e), x14_(f), x18_(std::max(x10_, x14_)),
x20_(new CCellPos[c*d]),
x24_(new CCellPos[c*d]),
x28_(new CCellPos[x18_]),
x2c_(new CCellPos[x18_]) {}
void GetDifference(int,int,int&,int&);
bool ShiftHorizontal(int,bool);
bool ShiftVertical(int,bool);
void ResolveTransitionCells();
void FillCellsInBox(CCellPos* cells);
};
class CGuiTableGroup : public CGuiCompoundWidget class CGuiTableGroup : public CGuiCompoundWidget
{ {
public: public:
enum class ETableGroupModes struct SomeState
{ {
float x0_ = 0.f;
}; };
private: private:
SomeState xb8_;
SomeState xbc_;
int xc0_;
int xc4_;
int xc8_;
int xcc_;
bool xd0_;
bool xd1_ = true;
std::function<void(const CGuiTableGroup*)> xd4_doMenuAdvance; std::function<void(const CGuiTableGroup*)> xd4_doMenuAdvance;
std::function<void(const CGuiTableGroup*)> xec_doMenuCancel; std::function<void(const CGuiTableGroup*)> xec_doMenuCancel;
std::function<void(const CGuiTableGroup*)> x104_doMenuSelChange; std::function<void(const CGuiTableGroup*)> x104_doMenuSelChange;
int xf8_;
int xfc_;
int x100_[3][2];
bool x118_;
bool x119_;
float x11c_;
float x120_;
bool x124_;
float x128_;
bool x12c_ = false;
ETableGroupModes x130_modes;
CGuiVirtualBox x134_box;
public:
CGuiTableGroup(const CGuiWidgetParms& parms, int, int, ETableGroupModes modes,
int, int, bool, bool, float, float, bool, float, CGuiVirtualBox&& box);
FourCC GetWidgetTypeID() const {return FOURCC('TBGP');}
static void LoadWidgetFnMap();
bool MAF_SelectNextColumn(CGuiFunctionDef* def, CGuiControllerInfo* info); public:
bool MAF_SelectPrevColumn(CGuiFunctionDef* def, CGuiControllerInfo* info); CGuiTableGroup(const CGuiWidgetParms& parms, int, int, bool);
bool MAF_SelectNextRow(CGuiFunctionDef* def, CGuiControllerInfo* info); FourCC GetWidgetTypeID() const {return FOURCC('TBGP');}
bool MAF_SelectPrevRow(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectNextColumnSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectPrevColumnSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectNextRowSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectPrevRowSkipUnActivated(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectColumnAtIndex(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SelectRowAtIndex(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_InitializeTable(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_MenuAdvance(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_MenuCancel(CGuiFunctionDef* def, CGuiControllerInfo* info);
void SetMenuAdvanceCallback(std::function<void(const CGuiTableGroup*)>&& cb) void SetMenuAdvanceCallback(std::function<void(const CGuiTableGroup*)>&& cb)
{ {
@ -99,6 +46,8 @@ public:
x104_doMenuSelChange = std::move(cb); x104_doMenuSelChange = std::move(cb);
} }
void SetD1(bool v) { xd1_ = v; }
static CGuiTableGroup* Create(CGuiFrame* frame, CInputStream& in, bool); static CGuiTableGroup* Create(CGuiFrame* frame, CInputStream& in, bool);
}; };

View File

@ -1,6 +1,4 @@
#include "CGuiTextPane.hpp" #include "CGuiTextPane.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CFontImageDef.hpp" #include "CFontImageDef.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiSys.hpp" #include "CGuiSys.hpp"
@ -63,13 +61,13 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
zeus::CTransform::Scale(dims.x, 1.f, dims.y); zeus::CTransform::Scale(dims.x, 1.f, dims.y);
CGraphics::SetModelMatrix(x34_worldXF * local); CGraphics::SetModelMatrix(x34_worldXF * local);
zeus::CColor geomCol = xb4_; zeus::CColor geomCol = xa8_color2;
geomCol.a *= parms.x0_alphaMod; geomCol.a *= parms.x0_alphaMod;
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor(geomCol); const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor(geomCol);
CGraphics::SetDepthWriteMode(xf6_31_depthTest, ERglEnum::LEqual, xf7_24_depthWrite); CGraphics::SetDepthWriteMode(xb6_31_depthTest, ERglEnum::LEqual, xb7_24_depthWrite);
switch (xc4_drawFlags) switch (xac_drawFlags)
{ {
case EGuiModelDrawFlags::Shadeless: case EGuiModelDrawFlags::Shadeless:
case EGuiModelDrawFlags::Opaque: case EGuiModelDrawFlags::Opaque:

View File

@ -176,7 +176,7 @@ void CGuiTextSupport::AddText(const std::wstring& str)
ClearBuffer(); ClearBuffer();
} }
void CGuiTextSupport::SetText(const std::wstring& str) void CGuiTextSupport::SetText(const std::wstring& str, bool scanFlag)
{ {
if (x0_string.compare(str)) if (x0_string.compare(str))
{ {
@ -184,12 +184,14 @@ void CGuiTextSupport::SetText(const std::wstring& str)
x3c_curTime = 0.f; x3c_curTime = 0.f;
x0_string = str; x0_string = str;
ClearBuffer(); ClearBuffer();
x308_scanFlag = scanFlag;
x304_scanCounter = 0;
} }
} }
void CGuiTextSupport::SetText(const std::string& str) void CGuiTextSupport::SetText(const std::string& str, bool scanFlag)
{ {
SetText(hecl::UTF8ToWide(str)); SetText(hecl::UTF8ToWide(str), scanFlag);
} }
bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const

View File

@ -100,8 +100,8 @@ class CGuiTextSupport
std::list<u8> x2f0_; std::list<u8> x2f0_;
u32 x300_ = 0; u32 x300_ = 0;
u32 x304_ = 0; u32 x304_scanCounter = 0;
u32 x308_ = 0; bool x308_scanFlag = false;
public: public:
CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
@ -119,8 +119,8 @@ public:
void SetOutlineColor(const zeus::CColor& col); void SetOutlineColor(const zeus::CColor& col);
void SetFontColor(const zeus::CColor& col); void SetFontColor(const zeus::CColor& col);
void AddText(const std::wstring& str); void AddText(const std::wstring& str);
void SetText(const std::wstring& str); void SetText(const std::wstring& str, bool scanFlag=false); // Flag set for scan write effect
void SetText(const std::string& str); void SetText(const std::string& str, bool scanFlag=false);
bool GetIsTextSupportFinishedLoading() const; bool GetIsTextSupportFinishedLoading() const;
}; };

View File

@ -1,38 +1,20 @@
#include "CGuiWidget.hpp" #include "CGuiWidget.hpp"
#include "CGuiFrame.hpp" #include "CGuiFrame.hpp"
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
#include "CGuiMessage.hpp"
namespace urde namespace urde
{ {
static logvisor::Module Log("urde::CGuiWidget"); static logvisor::Module Log("urde::CGuiWidget");
typedef bool(CGuiWidget::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info);
static std::unordered_map<u32, FMAF> WidgetFnMap;
void CGuiWidget::LoadWidgetFnMap()
{
WidgetFnMap.emplace(std::make_pair(2, &CGuiWidget::MAF_StartAnimationSet));
WidgetFnMap.emplace(std::make_pair(3, &CGuiWidget::MAF_SendMessage));
WidgetFnMap.emplace(std::make_pair(6, &CGuiWidget::MAF_PauseAnim));
WidgetFnMap.emplace(std::make_pair(7, &CGuiWidget::MAF_ResumeAnim));
WidgetFnMap.emplace(std::make_pair(11, &CGuiWidget::MAF_SetState));
WidgetFnMap.emplace(std::make_pair(12, &CGuiWidget::MAF_SetStateOfWidget));
}
CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms) CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
: x7c_selfId(parms.x6_selfId), x7e_parentId(parms.x8_parentId), : x70_selfId(parms.x6_selfId), x72_parentId(parms.x8_parentId),
xbc_color(parms.x10_color), xc0_color2(parms.x10_color), xa4_color(parms.x10_color), xa8_color2(parms.x10_color),
xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame), xac_drawFlags(parms.x14_drawFlags), xb0_frame(parms.x0_frame),
xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible), xb6_24_pg(parms.xd_g), xb6_25_isVisible(parms.xa_defaultVisible),
xf6_26_isActive(parms.xb_defaultActive), xb6_26_isActive(parms.xb_defaultActive),
xf6_27_(true), xf6_28_eventLock(false), xb6_27_(true), xb6_28_eventLock(false),
xf6_29_cullFaces(parms.xc_cullFaces), xf6_30_(false), xb6_29_cullFaces(parms.xc_cullFaces), xb6_30_(false),
xf6_31_depthTest(true), xf7_24_depthWrite(false), xf7_25_(true) xb6_31_depthTest(true), xb7_24_depthWrite(false), xb7_25_(true)
{ {
if (parms.x4_useAnimController)
EnsureHasAnimController();
RecalcWidgetColor(ETraversalMode::Single); RecalcWidgetColor(ETraversalMode::Single);
} }
@ -65,7 +47,7 @@ CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
return ret; return ret;
} }
bool CGuiWidget::Message(const CGuiMessage& msg) bool CGuiWidget::Message()
{ {
return false; return false;
} }
@ -75,97 +57,49 @@ void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWid
CGuiWidget* parent = frame->FindWidget(parms.x8_parentId); CGuiWidget* parent = frame->FindWidget(parms.x8_parentId);
bool a = in.readBool(); bool a = in.readBool();
if (a) if (a)
xf4_workerId = in.readInt16Big(); xb4_workerId = in.readInt16Big();
zeus::CVector3f trans; zeus::CVector3f trans;
trans.readBig(in); trans.readBig(in);
zeus::CMatrix3f orient; zeus::CMatrix3f orient;
orient.readBig(in); orient.readBig(in);
x80_transform = zeus::CTransform(orient, trans); x74_transform = zeus::CTransform(orient, trans);
ReapplyXform(); ReapplyXform();
zeus::CVector3f rotCenter; zeus::CVector3f rotCenter;
rotCenter.readBig(in); rotCenter.readBig(in);
SetRotationCenter(rotCenter); SetRotationCenter(rotCenter);
ParseMessages(in, parms); in.readUint16Big();
ParseAnimations(in, parms);
if (a) if (a)
if (!parent->AddWorkerWidget(this)) if (!parent->AddWorkerWidget(this))
{ {
Log.report(logvisor::Warning, Log.report(logvisor::Warning,
"Warning: Discarding useless worker id. Parent is not a compound widget."); "Warning: Discarding useless worker id. Parent is not a compound widget.");
xf4_workerId = -1; xb4_workerId = -1;
} }
parent->AddChildWidget(this, false, true); parent->AddChildWidget(this, false, true);
} }
void CGuiWidget::ParseMessages(CInputStream& in, const CGuiWidgetParms& parms) void CGuiWidget::Update(float dt)
{ {
s16 count = in.readInt16Big(); CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
assert(count == 0); if (ch)
count = in.readInt16Big(); ch->Update(dt);
assert(count == 0); CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
} if (sib)
sib->Update(dt);
void CGuiWidget::ParseAnimations(CInputStream& in, const CGuiWidgetParms& parms)
{
s16 count = in.readInt16Big();
assert(count == 0);
}
std::vector<ResId> CGuiWidget::GetTextureAssets() const
{
return {};
}
std::vector<ResId> CGuiWidget::GetModelAssets() const
{
return {};
}
std::vector<ResId> CGuiWidget::GetFontAssets() const
{
return {};
} }
void CGuiWidget::Draw(const CGuiWidgetDrawParms&) const {}
void CGuiWidget::Initialize() {} void CGuiWidget::Initialize() {}
void CGuiWidget::Touch() const {} void CGuiWidget::Touch() const {}
bool CGuiWidget::GetIsVisible() const bool CGuiWidget::GetIsVisible() const
{ {
return xf6_25_isVisible; return xb6_25_isVisible;
} }
bool CGuiWidget::GetIsActive() const bool CGuiWidget::GetIsActive() const
{ {
return xf6_26_isActive; return xb6_26_isActive;
}
CGuiTextSupport* CGuiWidget::TextSupport()
{
return nullptr;
}
const CGuiTextSupport* CGuiWidget::GetTextSupport() const
{
return nullptr;
}
void CGuiWidget::ModifyRGBA(CGuiWidget* widget)
{
xb8_ += widget->xb8_;
xb4_ = xb8_ + xc0_color2;
}
void CGuiWidget::RecalculateAllRGBA()
{
CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
if (parent)
ModifyRGBA(parent);
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->RecalculateAllRGBA();
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->RecalculateAllRGBA();
} }
void CGuiWidget::InitializeRGBAFactor() void CGuiWidget::InitializeRGBAFactor()
@ -183,52 +117,9 @@ bool CGuiWidget::GetIsFinishedLoadingWidgetSpecific() const
return true; return true;
} }
std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* CGuiWidget::FindTriggerList(int id)
{
auto search = xcc_triggerMap.find(id);
if (search == xcc_triggerMap.cend())
return nullptr;
return search->second.get();
}
void CGuiWidget::AddTrigger(std::unique_ptr<CGuiLogicalEventTrigger>&& trigger)
{
int tid = trigger->GetTriggerId();
std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* list = FindTriggerList(tid);
if (!list)
{
auto it =
xcc_triggerMap.emplace(std::make_pair(tid,
std::make_unique<std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>>()));
list = it.first->second.get();
}
list->push_back(std::move(trigger));
}
std::vector<std::unique_ptr<CGuiFunctionDef>>* CGuiWidget::FindFunctionDefList(int id)
{
auto search = xe0_functionMap.find(id);
if (search == xe0_functionMap.cend())
return nullptr;
return search->second.get();
}
void CGuiWidget::AddFunctionDef(s32 id, std::unique_ptr<CGuiFunctionDef>&& def)
{
std::vector<std::unique_ptr<CGuiFunctionDef>>* list = FindFunctionDefList(id);
if (!list)
{
auto it =
xe0_functionMap.emplace(std::make_pair(id,
std::make_unique<std::vector<std::unique_ptr<CGuiFunctionDef>>>()));
list = it.first->second.get();
}
list->push_back(std::move(def));
}
void CGuiWidget::SetIdlePosition(const zeus::CVector3f& pos, bool reapply) void CGuiWidget::SetIdlePosition(const zeus::CVector3f& pos, bool reapply)
{ {
x80_transform.origin = pos; x74_transform.origin = pos;
if (reapply) if (reapply)
ReapplyXform(); ReapplyXform();
} }
@ -237,136 +128,7 @@ void CGuiWidget::ReapplyXform()
{ {
RotateReset(); RotateReset();
SetLocalPosition(zeus::CVector3f::skZero); SetLocalPosition(zeus::CVector3f::skZero);
MultiplyO2P(x80_transform); MultiplyO2P(x74_transform);
}
void CGuiWidget::EnsureHasAnimController()
{
if (!xb0_animController)
{
xb0_animController.reset(new CGuiAnimController(
CGuiWidgetParms(xc8_frame, false, -1, -1, true, false, false,
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha,
true, false), this));
}
}
void CGuiWidget::BroadcastMessage(int id, CGuiControllerInfo* info)
{
CGuiFuncParm a((intptr_t(x7c_selfId)));
CGuiFuncParm b((intptr_t(id)));
CGuiFunctionDef def(0, false, a, b);
MAF_SendMessage(&def, info);
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
if (ch)
ch->BroadcastMessage(id, info);
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
if (sib)
sib->BroadcastMessage(id, info);
}
void CGuiWidget::LockEvents(bool lock)
{
xf6_28_eventLock = lock;
if (lock)
DoUnregisterEventHandler();
else
DoRegisterEventHandler();
}
void CGuiWidget::UnregisterEventHandler()
{
bool flag = DoUnregisterEventHandler();
if (!flag)
{
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
if (ch)
ch->UnregisterEventHandler();
}
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
if (sib && flag)
sib->UnregisterEventHandler();
}
void CGuiWidget::UnregisterEventHandler(ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
if (!DoUnregisterEventHandler())
{
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
if (ch)
ch->UnregisterEventHandler();
}
break;
case ETraversalMode::Single:
DoUnregisterEventHandler();
break;
default:
UnregisterEventHandler();
break;
}
}
bool CGuiWidget::DoUnregisterEventHandler()
{
for (auto& item : xcc_triggerMap)
for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
xc8_frame->ClearMessageMap(trigger.get(), x7c_selfId);
return false;
}
void CGuiWidget::RegisterEventHandler()
{
bool flag = DoRegisterEventHandler();
if (!flag)
{
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
if (ch)
ch->RegisterEventHandler();
}
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
if (sib && flag)
sib->RegisterEventHandler();
}
void CGuiWidget::RegisterEventHandler(ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
if (!DoRegisterEventHandler())
{
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
if (ch)
ch->RegisterEventHandler();
}
break;
case ETraversalMode::Single:
DoRegisterEventHandler();
break;
default:
RegisterEventHandler();
break;
}
}
bool CGuiWidget::DoRegisterEventHandler()
{
if (xf6_28_eventLock || !GetIsActive())
return false;
for (auto& item : xcc_triggerMap)
for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
xc8_frame->AddMessageMap(trigger.get(), x7c_selfId);
return false;
}
CGuiWidget* CGuiWidget::RemoveChildWidget(CGuiWidget* widget, bool makeWorldLocal)
{
return static_cast<CGuiWidget*>(RemoveChildObject(widget, makeWorldLocal));
} }
void CGuiWidget::AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd) void CGuiWidget::AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd)
@ -379,29 +141,6 @@ bool CGuiWidget::AddWorkerWidget(CGuiWidget* worker)
return false; return false;
} }
void CGuiWidget::AddAnim(EGuiAnimBehListID id, CGuiAnimBase* anim)
{
if (!xb0_animController)
{
xb0_animController.reset(new CGuiAnimController(
CGuiWidgetParms(xc8_frame, false, -1, -1, false, false, false,
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha, true, false), this));
}
xb0_animController->AddAnimation(anim, id);
}
void CGuiWidget::ResetAllAnimUpdateState()
{
if (xb0_animController)
xb0_animController->ResetListUpdateState();
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->ResetAllAnimUpdateState();
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->ResetAllAnimUpdateState();
}
void CGuiWidget::SetVisibility(bool vis, ETraversalMode mode) void CGuiWidget::SetVisibility(bool vis, ETraversalMode mode)
{ {
switch (mode) switch (mode)
@ -428,184 +167,13 @@ void CGuiWidget::SetVisibility(bool vis, ETraversalMode mode)
SetIsVisible(vis); SetIsVisible(vis);
} }
void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state)
{
if (xb0_animController)
xb0_animController->SetListUpdateState(id, state);
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->SetAnimUpdateState(id, state);
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->SetAnimUpdateState(id, state);
}
void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state, ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
{
if (xb0_animController)
xb0_animController->SetListUpdateState(id, state);
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->SetAnimUpdateState(id, state);
break;
}
case ETraversalMode::Single:
{
if (xb0_animController)
xb0_animController->SetListUpdateState(id, state);
break;
}
default:
SetAnimUpdateState(id, state);
break;
}
}
void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len)
{
if (xb0_animController)
{
float aLen = xb0_animController->GetAnimSetLength(id);
if (aLen > len)
len = aLen;
}
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->GetBranchAnimLen(id, len);
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->GetBranchAnimLen(id, len);
}
void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len, ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
{
if (xb0_animController)
{
float aLen = xb0_animController->GetAnimSetLength(id);
if (aLen > len)
len = aLen;
}
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->GetBranchAnimLen(id, len);
break;
}
case ETraversalMode::Single:
{
if (xb0_animController)
{
float aLen = xb0_animController->GetAnimSetLength(id);
if (aLen > len)
len = aLen;
}
break;
}
default:
GetBranchAnimLen(id, len);
break;
}
}
void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone)
{
if (xb0_animController)
{
if (!isDone)
return;
xb0_animController->IsAnimsDone(id, isDone);
}
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->IsAllAnimsDone(id, isDone);
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->IsAllAnimsDone(id, isDone);
}
void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone, ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
{
if (xb0_animController)
{
xb0_animController->IsAnimsDone(id, isDone);
if (!isDone)
return;
}
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->IsAllAnimsDone(id, isDone);
break;
}
case ETraversalMode::Single:
{
if (xb0_animController)
xb0_animController->IsAnimsDone(id, isDone);
break;
}
default:
IsAllAnimsDone(id, isDone);
break;
}
}
void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
EGuiAnimInitMode initMode)
{
if (xb0_animController)
xb0_animController->InitTransform(this, id, fval, flag, initMode);
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->InitializeAnimControllers(id, fval, flag, initMode);
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
if (nextSib)
nextSib->InitializeAnimControllers(id, fval, flag, initMode);
}
void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
EGuiAnimInitMode initMode, ETraversalMode mode)
{
switch (mode)
{
case ETraversalMode::Children:
{
if (xb0_animController)
xb0_animController->InitTransform(this, id, fval, flag, initMode);
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child)
child->InitializeAnimControllers(id, fval, flag, initMode);
break;
}
case ETraversalMode::Single:
{
if (xb0_animController)
xb0_animController->InitTransform(this, id, fval, flag, initMode);
break;
}
default:
InitializeAnimControllers(id, fval, flag, initMode);
break;
}
}
void CGuiWidget::RecalcWidgetColor(ETraversalMode mode) void CGuiWidget::RecalcWidgetColor(ETraversalMode mode)
{ {
CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent()); CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
if (parent) if (parent)
xc0_color2 = xbc_color * parent->xc0_color2; xa8_color2 = xa4_color * parent->xa8_color2;
else else
xc0_color2 = xbc_color; xa8_color2 = xa4_color;
xb4_ = xb8_ + xc0_color2;
switch (mode) switch (mode)
{ {
@ -627,7 +195,7 @@ void CGuiWidget::RecalcWidgetColor(ETraversalMode mode)
CGuiWidget* CGuiWidget::FindWidget(s16 id) CGuiWidget* CGuiWidget::FindWidget(s16 id)
{ {
if (x7c_selfId == id) if (x70_selfId == id)
return this; return this;
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject()); CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
if (child) if (child)
@ -648,10 +216,7 @@ CGuiWidget* CGuiWidget::FindWidget(s16 id)
bool CGuiWidget::GetIsFinishedLoading() const bool CGuiWidget::GetIsFinishedLoading() const
{ {
bool widgetFinished = GetIsFinishedLoadingWidgetSpecific(); return GetIsFinishedLoadingWidgetSpecific();
if (!xb0_animController)
return widgetFinished;
return widgetFinished && xb0_animController->GetIsFinishedLoading();
} }
void CGuiWidget::InitializeRecursive() void CGuiWidget::InitializeRecursive()
@ -667,69 +232,26 @@ void CGuiWidget::InitializeRecursive()
void CGuiWidget::SetColor(const zeus::CColor& color) void CGuiWidget::SetColor(const zeus::CColor& color)
{ {
xbc_color = color; xa4_color = color;
RecalcWidgetColor(ETraversalMode::Children); RecalcWidgetColor(ETraversalMode::Children);
} }
void CGuiWidget::OnDeActivate() {} void CGuiWidget::OnActiveChange() {}
void CGuiWidget::OnActivate(bool) {} void CGuiWidget::OnVisibleChange() {}
void CGuiWidget::OnInvisible() {}
void CGuiWidget::OnVisible() {}
void CGuiWidget::SetIsVisible(bool vis) void CGuiWidget::SetIsVisible(bool vis)
{ {
xf6_25_isVisible = vis; xb6_25_isVisible = vis;
if (vis) OnVisibleChange();
OnVisible();
else
OnInvisible();
} }
void CGuiWidget::SetIsActive(bool a, bool b) void CGuiWidget::SetIsActive(bool a)
{ {
if (a == xf6_26_isActive) if (a != xb6_26_isActive)
return;
xf6_26_isActive = a;
if (a)
{ {
RegisterEventHandler(ETraversalMode::Children); xb6_26_isActive = a;
OnActivate(b); OnActiveChange();
}
else
{
RegisterEventHandler(ETraversalMode::Children);
OnDeActivate();
} }
} }
bool CGuiWidget::MAF_StartAnimationSet(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiWidget::MAF_SendMessage(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiWidget::MAF_PauseAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiWidget::MAF_ResumeAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiWidget::MAF_SetState(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
bool CGuiWidget::MAF_SetStateOfWidget(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
return false;
}
} }

View File

@ -3,27 +3,13 @@
#include "IOStreams.hpp" #include "IOStreams.hpp"
#include "CGuiObject.hpp" #include "CGuiObject.hpp"
#include "CGuiFunctionDef.hpp"
#include "zeus/CColor.hpp" #include "zeus/CColor.hpp"
namespace urde namespace urde
{ {
class CGuiAnimBase;
class CGuiFrame; class CGuiFrame;
class CGuiMessage;
class CGuiAnimController;
class CGuiLogicalEventTrigger;
class CGuiTextSupport; class CGuiTextSupport;
enum class EGuiAnimBehListID
{
NegOne = -1,
Zero = 0,
One = 1,
Two = 2,
EGuiAnimBehListIDMAX = 13
};
enum class ETraversalMode enum class ETraversalMode
{ {
ChildrenAndSiblings = 0, ChildrenAndSiblings = 0,
@ -31,14 +17,6 @@ enum class ETraversalMode
Single = 2 Single = 2
}; };
enum class EGuiAnimInitMode
{
One = 1,
Two = 2,
Three = 3,
Five = 5
};
enum class EGuiTextureClampModeHorz enum class EGuiTextureClampModeHorz
{ {
NoClamp = 0, NoClamp = 0,
@ -88,32 +66,25 @@ public:
x8_parentId(parentId), xa_defaultVisible(defaultVisible), xb_defaultActive(defaultActive), x8_parentId(parentId), xa_defaultVisible(defaultVisible), xb_defaultActive(defaultActive),
xc_cullFaces(cullFaces), xd_g(g), xe_h(h), x10_color(color), x14_drawFlags(drawFlags) {} xc_cullFaces(cullFaces), xd_g(g), xe_h(h), x10_color(color), x14_drawFlags(drawFlags) {}
}; };
static void LoadWidgetFnMap();
virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
protected: protected:
s16 x7c_selfId; s16 x70_selfId;
s16 x7e_parentId; s16 x72_parentId;
zeus::CTransform x80_transform; zeus::CTransform x74_transform;
std::unique_ptr<CGuiAnimController> xb0_animController; zeus::CColor xa4_color;
zeus::CColor xb4_ = zeus::CColor::skWhite; zeus::CColor xa8_color2;
zeus::CColor xb8_ = zeus::CColor::skClear; EGuiModelDrawFlags xac_drawFlags;
zeus::CColor xbc_color; CGuiFrame* xb0_frame;
zeus::CColor xc0_color2; s16 xb4_workerId = -1;
EGuiModelDrawFlags xc4_drawFlags; bool xb6_24_pg : 1;
CGuiFrame* xc8_frame; bool xb6_25_isVisible : 1;
std::unordered_map<int, std::unique_ptr<std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>>> xcc_triggerMap; bool xb6_26_isActive : 1;
std::unordered_map<int, std::unique_ptr<std::vector<std::unique_ptr<CGuiFunctionDef>>>> xe0_functionMap; bool xb6_27_ : 1;
s16 xf4_workerId = -1; bool xb6_28_eventLock : 1;
bool xf6_24_pg : 1; bool xb6_29_cullFaces : 1;
bool xf6_25_isVisible : 1; bool xb6_30_ : 1;
bool xf6_26_isActive : 1; bool xb6_31_depthTest : 1;
bool xf6_27_ : 1; bool xb7_24_depthWrite : 1;
bool xf6_28_eventLock : 1; bool xb7_25_ : 1;
bool xf6_29_cullFaces : 1;
bool xf6_30_ : 1;
bool xf6_31_depthTest : 1;
bool xf7_24_depthWrite : 1;
bool xf7_25_ : 1;
public: public:
CGuiWidget(const CGuiWidgetParms& parms); CGuiWidget(const CGuiWidgetParms& parms);
@ -121,77 +92,40 @@ public:
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool); static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool);
static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, bool); static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
virtual bool Message(const CGuiMessage& msg); virtual void Update(float dt);
virtual void ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms); virtual void Draw(const CGuiWidgetDrawParms& drawParms) const;
virtual void ParseMessages(CInputStream& in, const CGuiWidgetParms& parms); virtual bool Message();
virtual void ParseAnimations(CInputStream& in, const CGuiWidgetParms& parms);
virtual std::vector<ResId> GetTextureAssets() const;
virtual std::vector<ResId> GetModelAssets() const;
virtual std::vector<ResId> GetFontAssets() const;
virtual void Initialize(); virtual void Initialize();
virtual void Touch() const; virtual void Touch() const;
virtual bool GetIsVisible() const; virtual bool GetIsVisible() const;
virtual bool GetIsActive() const; virtual bool GetIsActive() const;
virtual CGuiTextSupport* TextSupport(); virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');}
virtual const CGuiTextSupport* GetTextSupport() const;
virtual void ModifyRGBA(CGuiWidget* widget);
virtual void AddAnim(EGuiAnimBehListID, CGuiAnimBase*);
virtual void AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd);
virtual CGuiWidget* RemoveChildWidget(CGuiWidget* widget, bool makeWorldLocal);
virtual bool AddWorkerWidget(CGuiWidget* worker); virtual bool AddWorkerWidget(CGuiWidget* worker);
virtual bool GetIsFinishedLoadingWidgetSpecific() const; virtual bool GetIsFinishedLoadingWidgetSpecific() const;
virtual void OnVisible(); virtual void OnVisibleChange();
virtual void OnInvisible(); virtual void OnActiveChange();
virtual void OnActivate(bool);
virtual void OnDeActivate();
virtual bool DoRegisterEventHandler();
virtual bool DoUnregisterEventHandler();
s16 GetSelfId() const {return x7c_selfId;} s16 GetSelfId() const {return x70_selfId;}
s16 GetParentId() const {return x7e_parentId;} s16 GetParentId() const {return x72_parentId;}
s16 GetWorkerId() const {return xf4_workerId;} s16 GetWorkerId() const {return xb4_workerId;}
const zeus::CTransform& GetTransform() const {return x80_transform;} const zeus::CTransform& GetTransform() const {return x74_transform;}
std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* FindTriggerList(int id); const zeus::CVector3f& GetIdlePosition() const {return x74_transform.origin;}
void AddTrigger(std::unique_ptr<CGuiLogicalEventTrigger>&& trigger);
std::vector<std::unique_ptr<CGuiFunctionDef>>* FindFunctionDefList(int id);
void AddFunctionDef(s32 id, std::unique_ptr<CGuiFunctionDef>&& def);
const zeus::CVector3f& GetIdlePosition() const {return x80_transform.origin;}
void SetIdlePosition(const zeus::CVector3f& pos, bool reapply); void SetIdlePosition(const zeus::CVector3f& pos, bool reapply);
void ReapplyXform(); void ReapplyXform();
void SetIsVisible(bool); void SetIsVisible(bool);
void SetIsActive(bool, bool); void SetIsActive(bool);
void EnsureHasAnimController();
void BroadcastMessage(int, CGuiControllerInfo* info); void SetB627(bool v) { xb6_27_ = v; }
void LockEvents(bool);
void UnregisterEventHandler(); void ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms);
void UnregisterEventHandler(ETraversalMode); void AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd);
void RegisterEventHandler();
void RegisterEventHandler(ETraversalMode);
void ResetAllAnimUpdateState();
void SetVisibility(bool, ETraversalMode); void SetVisibility(bool, ETraversalMode);
void SetAnimUpdateState(EGuiAnimBehListID, bool);
void SetAnimUpdateState(EGuiAnimBehListID, bool, ETraversalMode);
void GetBranchAnimLen(EGuiAnimBehListID, float&);
void GetBranchAnimLen(EGuiAnimBehListID, float&, ETraversalMode);
void IsAllAnimsDone(EGuiAnimBehListID, bool&);
void IsAllAnimsDone(EGuiAnimBehListID, bool&, ETraversalMode);
void InitializeAnimControllers(EGuiAnimBehListID, float, bool, EGuiAnimInitMode);
void InitializeAnimControllers(EGuiAnimBehListID, float, bool, EGuiAnimInitMode, ETraversalMode);
void RecalcWidgetColor(ETraversalMode); void RecalcWidgetColor(ETraversalMode);
void SetColor(const zeus::CColor& color); void SetColor(const zeus::CColor& color);
void RecalculateAllRGBA();
void InitializeRGBAFactor(); void InitializeRGBAFactor();
CGuiWidget* FindWidget(s16 id); CGuiWidget* FindWidget(s16 id);
bool GetIsFinishedLoading() const; bool GetIsFinishedLoading() const;
void InitializeRecursive(); void InitializeRecursive();
bool MAF_StartAnimationSet(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SendMessage(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_PauseAnim(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_ResumeAnim(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SetState(CGuiFunctionDef* def, CGuiControllerInfo* info);
bool MAF_SetStateOfWidget(CGuiFunctionDef* def, CGuiControllerInfo* info);
}; };
} }

View File

@ -15,24 +15,14 @@ set(GUISYS_SOURCES
CConsoleOutputWindow.hpp CConsoleOutputWindow.hpp
CErrorOutputWindow.cpp CErrorOutputWindow.cpp
CErrorOutputWindow.hpp CErrorOutputWindow.hpp
CGuiAnimBase.cpp
CGuiAnimBase.hpp
CGuiAnimController.cpp
CGuiAnimController.hpp
CGuiAutoRepeatData.cpp
CGuiAutoRepeatData.hpp
CGuiCamera.cpp CGuiCamera.cpp
CGuiCamera.hpp CGuiCamera.hpp
CGuiFactories.cpp
CGuiFactories.hpp
CGuiFrame.cpp CGuiFrame.cpp
CGuiFrame.hpp CGuiFrame.hpp
CGuiLight.cpp CGuiLight.cpp
CGuiLight.hpp CGuiLight.hpp
CGuiModel.cpp CGuiModel.cpp
CGuiModel.hpp CGuiModel.hpp
CGuiRandomVar.cpp
CGuiRandomVar.hpp
CGuiSliderGroup.cpp CGuiSliderGroup.cpp
CGuiSliderGroup.hpp CGuiSliderGroup.hpp
CGuiStaticImage.cpp CGuiStaticImage.cpp
@ -62,15 +52,6 @@ set(GUISYS_SOURCES
CRasterFont.hpp CRasterFont.hpp
CGuiGroup.cpp CGuiGroup.cpp
CGuiGroup.hpp CGuiGroup.hpp
CGuiFunctionDef.cpp
CGuiFunctionDef.hpp
CGuiFuncParm.cpp
CGuiFuncParm.hpp
CGuiPhysicalMsg.cpp
CGuiPhysicalMsg.hpp
CGuiControllerInfo.hpp
CGuiLogicalEventTrigger.cpp
CGuiLogicalEventTrigger.hpp
CGuiWidgetIdDB.cpp CGuiWidgetIdDB.cpp
CGuiWidgetIdDB.hpp CGuiWidgetIdDB.hpp
CGuiHeadWidget.cpp CGuiHeadWidget.cpp
@ -79,8 +60,6 @@ set(GUISYS_SOURCES
CGuiBackground.hpp CGuiBackground.hpp
CGuiPane.cpp CGuiPane.cpp
CGuiPane.hpp CGuiPane.hpp
CGuiMessage.cpp
CGuiMessage.hpp
CFontRenderState.cpp CFontRenderState.cpp
CFontRenderState.hpp CFontRenderState.hpp
CTextExecuteBuffer.cpp CTextExecuteBuffer.cpp

View File

@ -13,6 +13,7 @@
#include "GuiSys/CGuiFrame.hpp" #include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CStringTable.hpp" #include "GuiSys/CStringTable.hpp"
#include "GuiSys/CGuiTableGroup.hpp" #include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiModel.hpp"
#include "CGameState.hpp" #include "CGameState.hpp"
#include "CDependencyGroup.hpp" #include "CDependencyGroup.hpp"
#include "Audio/CAudioGroupSet.hpp" #include "Audio/CAudioGroupSet.hpp"
@ -67,20 +68,125 @@ CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveUI* sui, u32 rnd)
: x0_rnd(rnd), x4_saveUI(sui) : x0_rnd(rnd), x4_saveUI(sui)
{ {
x10_frme = g_SimplePool->GetObj("FRME_NewFileSelect"); x10_frme = g_SimplePool->GetObj("FRME_NewFileSelect");
}
CFrontEndUI::SFileSelectOption CFrontEndUI::FindFileSelectOption(CGuiFrame* frame, int idx)
{
SFileSelectOption ret;
ret.x0_base = frame->FindWidget(hecl::Format("basewidget_file%d", idx).c_str());
ret.x4_textpanes[0] = FindTextPanePair(frame, hecl::Format("textpane_filename%d", idx).c_str());
ret.x4_textpanes[1] = FindTextPanePair(frame, hecl::Format("textpane_world%d", idx).c_str());
ret.x4_textpanes[2] = FindTextPanePair(frame, hecl::Format("textpane_playtime%d", idx).c_str());
ret.x4_textpanes[3] = FindTextPanePair(frame, hecl::Format("textpane_date%d", idx).c_str());
return ret;
}
void CFrontEndUI::SNewFileSelectFrame::FinishedLoading()
{
x20_tablegroup_fileselect = static_cast<CGuiTableGroup*>(x1c_loadedFrame->FindWidget("tablegroup_fileselect"));
x24_model_erase = static_cast<CGuiModel*>(x1c_loadedFrame->FindWidget("model_erase"));
xf8_model_erase_position = x24_model_erase->GetLocalPosition();
x28_textpane_erase = FindTextPanePair(x1c_loadedFrame, "textpane_erase");
x58_textpane_popupextra = FindTextPanePair(x1c_loadedFrame, "textpane_popupextra");
x40_tablegroup_popup = static_cast<CGuiTableGroup*>(x1c_loadedFrame->FindWidget("tablegroup_popup"));
x44_model_dash7 = static_cast<CGuiModel*>(x1c_loadedFrame->FindWidget("model_dash7"));
x60_textpane_cancel = static_cast<CGuiTextPane*>(x1c_loadedFrame->FindWidget("textpane_cancel"));
FindAndSetPairText(x1c_loadedFrame, "textpane_title", g_MainStringTable->GetString(97));
CGuiTextPane* proceed = static_cast<CGuiTextPane*>(x1c_loadedFrame->FindWidget("textpane_proceed"));
if (proceed)
proceed->TextSupport()->SetText(g_MainStringTable->GetString(85));
x40_tablegroup_popup->SetIsVisible(false);
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetD1(false);
CGuiWidget* worker = x40_tablegroup_popup->GetWorkerWidget(2);
worker->SetB627(false);
worker->SetVisibility(false, ETraversalMode::Children);
x20_tablegroup_fileselect->SetMenuAdvanceCallback(
std::bind(&SNewFileSelectFrame::DoMenuAdvance, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuSelectionChangeCallback(
std::bind(&SNewFileSelectFrame::DoMenuSelectionChange, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuCancelCallback(
std::bind(&SNewFileSelectFrame::DoMenuAdvance, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuAdvanceCallback(
std::bind(&SNewFileSelectFrame::DoMenuAdvance, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuSelectionChangeCallback(
std::bind(&SNewFileSelectFrame::DoMenuSelectionChange, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuCancelCallback(
std::bind(&SNewFileSelectFrame::DoMenuAdvance, this, std::placeholders::_1));
for (int i=0 ; i<3 ; ++i)
x64_fileSelections[i] = FindFileSelectOption(x1c_loadedFrame, i);
x104_rowPitch = (x64_fileSelections[1].x0_base->GetLocalPosition() - x64_fileSelections[0].x0_base->GetLocalPosition()).z;
} }
bool CFrontEndUI::SNewFileSelectFrame::PumpLoad() bool CFrontEndUI::SNewFileSelectFrame::PumpLoad()
{ {
if (x1c_loadedFrame)
return true;
if (x10_frme.IsLoaded())
{
if (x10_frme->GetIsFinishedLoading())
{
x1c_loadedFrame = x10_frme.GetObj();
FinishedLoading();
return true;
}
}
return false; return false;
} }
void CFrontEndUI::SNewFileSelectFrame::DoMenuSelectionChange(const CGuiTableGroup* caller)
{
}
void CFrontEndUI::SNewFileSelectFrame::DoMenuAdvance(const CGuiTableGroup* caller)
{
}
CFrontEndUI::SGBASupportFrame::SGBASupportFrame()
{
x4_gbaSupport = std::make_unique<CGBASupport>();
xc_gbaScreen = g_SimplePool->GetObj("FRME_GBAScreen");
x18_gbaLink = g_SimplePool->GetObj("FRME_GBALink");
}
void CFrontEndUI::SGBASupportFrame::FinishedLoading()
{
}
bool CFrontEndUI::SGBASupportFrame::PumpLoad()
{
}
void CFrontEndUI::SGuiTextPair::SetPairText(const std::wstring& str) void CFrontEndUI::SGuiTextPair::SetPairText(const std::wstring& str)
{ {
x0_panes[0]->TextSupport()->SetText(str); x0_panes[0]->TextSupport()->SetText(str);
x0_panes[1]->TextSupport()->SetText(str); x0_panes[1]->TextSupport()->SetText(str);
} }
CFrontEndUI::SGuiTextPair CFrontEndUI::FindTextPanePair(CGuiFrame* frame, const char* name)
{
SGuiTextPair ret;
ret.x0_panes[0] = static_cast<CGuiTextPane*>(frame->FindWidget(name));
ret.x0_panes[1] = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
return ret;
}
void CFrontEndUI::FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str)
{
CGuiTextPane* w1 = static_cast<CGuiTextPane*>(frame->FindWidget(name));
w1->TextSupport()->SetText(str);
CGuiTextPane* w2 = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
w2->TextSupport()->SetText(str);
}
void CFrontEndUI::SFrontEndFrame::FinishedLoading() void CFrontEndUI::SFrontEndFrame::FinishedLoading()
{ {
x18_tablegroup_mainmenu = static_cast<CGuiTableGroup*>(x14_loadedFrme->FindWidget("tablegroup_mainmenu")); x18_tablegroup_mainmenu = static_cast<CGuiTableGroup*>(x14_loadedFrme->FindWidget("tablegroup_mainmenu"));
@ -123,22 +229,6 @@ bool CFrontEndUI::SFrontEndFrame::PumpLoad()
return false; return false;
} }
CFrontEndUI::SGuiTextPair CFrontEndUI::SFrontEndFrame::FindTextPanePair(CGuiFrame* frame, const char* name)
{
SGuiTextPair ret;
ret.x0_panes[0] = static_cast<CGuiTextPane*>(frame->FindWidget(name));
ret.x0_panes[1] = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
return ret;
}
void CFrontEndUI::SFrontEndFrame::FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str)
{
CGuiTextPane* w1 = static_cast<CGuiTextPane*>(frame->FindWidget(name));
w1->TextSupport()->SetText(str);
CGuiTextPane* w2 = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
w2->TextSupport()->SetText(str);
}
void CFrontEndUI::SFrontEndFrame::DoMenuSelectionChange(const CGuiTableGroup* caller) void CFrontEndUI::SFrontEndFrame::DoMenuSelectionChange(const CGuiTableGroup* caller)
{ {
} }
@ -167,6 +257,20 @@ CFrontEndUI::SFusionBonusFrame::SFusionBonusFrame()
0, 0, g_SimplePool); 0, 0, g_SimplePool);
} }
bool CFrontEndUI::SFusionBonusFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveUi)
{
bool flag = (saveUi && saveUi->x10_ != 16) ? false : true;
x10_remTime = std::max(x10_remTime - dt, 0.f);
zeus::CColor geomCol(zeus::CColor::skWhite);
geomCol.a = std::min(x10_remTime, 1.f);
xc_textSupport->SetGeometryColor(geomCol);
if (xc_textSupport->GetIsTextSupportFinishedLoading())
{
}
}
CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame() CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame()
{ {
x4_frme = g_SimplePool->GetObj("FRME_OptionsFrontEnd"); x4_frme = g_SimplePool->GetObj("FRME_OptionsFrontEnd");
@ -404,14 +508,14 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
void CFrontEndUI::TransitionToFive() void CFrontEndUI::TransitionToFive()
{ {
if (x14_screen >= EScreen::Five) if (x14_phase >= EPhase::Five)
return; return;
const u16* sfx = FETransitionForwardSFX[x1c_rndB]; const u16* sfx = FETransitionForwardSFX[x1c_rndB];
CSfxManager::SfxStart(sfx[0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(sfx[0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(sfx[1], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(sfx[1], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x14_screen = EScreen::Five; x14_phase = EPhase::Five;
StartStateTransition(EScreen::Five); StartStateTransition(EScreen::Five);
} }
@ -444,40 +548,40 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
UpdateMusicVolume(); UpdateMusicVolume();
switch (x14_screen) switch (x14_phase)
{ {
case EScreen::Zero: case EPhase::Zero:
if (!x20_depsGroup.IsLoaded()) if (!x20_depsGroup.IsLoaded())
return EMessageReturn::Exit; return EMessageReturn::Exit;
FinishedLoadingDepsGroup(); FinishedLoadingDepsGroup();
x20_depsGroup.Unlock(); x20_depsGroup.Unlock();
x14_screen = EScreen::One; x14_phase = EPhase::One;
case EScreen::One: case EPhase::One:
if (PumpLoad()) if (PumpLoad())
{ {
xe0_newFileSel = std::make_unique<SNewFileSelectFrame>(xdc_saveUI.get(), x1c_rndB); xe0_newFileSel = std::make_unique<SNewFileSelectFrame>(xdc_saveUI.get(), x1c_rndB);
xe4_gbaSupport = std::make_unique<CGBASupport>(); xe4_gbaSupportFrme = std::make_unique<SGBASupportFrame>();
xe8_frontendFrme = std::make_unique<SFrontEndFrame>(x1c_rndB); xe8_frontendFrme = std::make_unique<SFrontEndFrame>(x1c_rndB);
x38_pressStart.GetObj(); x38_pressStart.GetObj();
CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData()); CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664); xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664);
xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980); xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980);
x14_screen = EScreen::Two; x14_phase = EPhase::Two;
} }
if (x14_screen == EScreen::One) if (x14_phase == EPhase::One)
return EMessageReturn::Exit; return EMessageReturn::Exit;
case EScreen::Two: case EPhase::Two:
if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() || if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() ||
!xe0_newFileSel->PumpLoad() || !xe4_gbaSupport->PumpLoad() || !xe0_newFileSel->PumpLoad() || !xe4_gbaSupportFrme->PumpLoad() ||
!xe8_frontendFrme->PumpLoad() || !xdc_saveUI->PumpLoad()) !xe8_frontendFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
return EMessageReturn::Exit; return EMessageReturn::Exit;
xf4_curAudio = xd4_audio1.get(); xf4_curAudio = xd4_audio1.get();
xf4_curAudio->StartMixing(); xf4_curAudio->StartMixing();
x14_screen = EScreen::Three; x14_phase = EPhase::Three;
case EScreen::Three: case EPhase::Three:
{ {
bool moviesReady = true; bool moviesReady = true;
if (PumpMovieLoad()) if (PumpMovieLoad())
@ -497,16 +601,23 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
if (moviesReady) if (moviesReady)
{ {
x14_screen = EScreen::Four; x14_phase = EPhase::Four;
StartStateTransition(EScreen::One); StartStateTransition(EScreen::One);
} }
else else
return EMessageReturn::Exit; return EMessageReturn::Exit;
} }
case EScreen::Four: case EPhase::Four:
if (xec_) case EPhase::Five:
if (xec_fusionFrme)
{ {
xdc_saveUI->Update(dt); if (xec_fusionFrme->DoUpdateWithSaveUI(dt, xdc_saveUI.get()))
{
xec_fusionFrme.reset();
xf4_curAudio->StartMixing();
}
break;
} }
} }
@ -530,7 +641,7 @@ CIOWin::EMessageReturn CFrontEndUI::OnMessage(const CArchitectureMessage& msg, C
} }
case EArchMsgType::QuitGameplay: case EArchMsgType::QuitGameplay:
{ {
x14_screen = EScreen::Six; x14_phase = EPhase::Six;
break; break;
} }
default: break; default: break;

View File

@ -27,6 +27,7 @@ class CSaveUI;
class CGuiTextPane; class CGuiTextPane;
class CGuiWidget; class CGuiWidget;
class CGuiTableGroup; class CGuiTableGroup;
class CGuiModel;
namespace MP1 namespace MP1
{ {
@ -35,6 +36,16 @@ class CNESEmulator;
class CFrontEndUI : public CIOWin class CFrontEndUI : public CIOWin
{ {
public: public:
enum class EPhase
{
Zero,
One,
Two,
Three,
Four,
Five,
Six
};
enum class EScreen enum class EScreen
{ {
Zero, Zero,
@ -64,32 +75,66 @@ public:
CGuiTextPane* x0_panes[2] = {}; CGuiTextPane* x0_panes[2] = {};
void SetPairText(const std::wstring& str); void SetPairText(const std::wstring& str);
}; };
static SGuiTextPair FindTextPanePair(CGuiFrame* frame, const char* name);
static void FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str);
struct SFileSelectOption
{
CGuiWidget* x0_base;
/* filename, world, playtime, date */
SGuiTextPair x4_textpanes[4];
};
static SFileSelectOption FindFileSelectOption(CGuiFrame* frame, int idx);
struct SNewFileSelectFrame struct SNewFileSelectFrame
{ {
u32 x0_rnd; u32 x0_rnd;
CSaveUI* x4_saveUI; CSaveUI* x4_saveUI;
TLockedToken<CGuiFrame> x10_frme; TLockedToken<CGuiFrame> x10_frme;
CGuiFrame* x1c_ = nullptr; CGuiFrame* x1c_loadedFrame = nullptr;
CGuiWidget* x20_ = nullptr; CGuiTableGroup* x20_tablegroup_fileselect = nullptr;
CGuiWidget* x24_ = nullptr; CGuiModel* x24_model_erase = nullptr;
SGuiTextPair x28_; SGuiTextPair x28_textpane_erase;
SGuiTextPair x30_; SGuiTextPair x30_;
SGuiTextPair x38_; SGuiTextPair x38_;
CGuiWidget* x40_ = nullptr; CGuiTableGroup* x40_tablegroup_popup = nullptr;
CGuiWidget* x44_ = nullptr; CGuiModel* x44_model_dash7 = nullptr;
SGuiTextPair x48_; SGuiTextPair x48_;
SGuiTextPair x50_; SGuiTextPair x50_;
SGuiTextPair x58_; SGuiTextPair x58_textpane_popupextra;
CGuiWidget* x60_ = nullptr; CGuiTextPane* x60_textpane_cancel = nullptr;
CGuiWidget* x64_ = nullptr; SFileSelectOption x64_fileSelections[3];
zeus::CVector3f xf8_; zeus::CVector3f xf8_model_erase_position;
float x104_ = 0.f; float x104_rowPitch = 0.f;
float x108_ = 0.f; float x108_ = 0.f;
bool x10c_ = false; bool x10c_ = false;
bool x10d_ = false; bool x10d_ = false;
bool x10e_ = false; bool x10e_ = false;
SNewFileSelectFrame(CSaveUI* sui, u32 rnd); SNewFileSelectFrame(CSaveUI* sui, u32 rnd);
void FinishedLoading();
bool PumpLoad();
void DoMenuSelectionChange(const CGuiTableGroup* caller);
void DoMenuAdvance(const CGuiTableGroup* caller);
};
struct SGBASupportFrame
{
u32 x0_ = 0;
std::unique_ptr<CGBASupport> x4_gbaSupport;
TLockedToken<CGuiFrame> xc_gbaScreen;
TLockedToken<CGuiFrame> x18_gbaLink;
CGuiFrame* x24_loadedFrame = nullptr;
CGuiWidget* x28_ = nullptr;
CGuiWidget* x2c_ = nullptr;
SGuiTextPair x30_;
bool x38_ = false;
bool x39_ = false;
bool x3a_ = false;
SGBASupportFrame();
void FinishedLoading();
bool PumpLoad(); bool PumpLoad();
}; };
@ -104,8 +149,6 @@ public:
SFrontEndFrame(u32 rnd); SFrontEndFrame(u32 rnd);
void FinishedLoading(); void FinishedLoading();
bool PumpLoad(); bool PumpLoad();
static SGuiTextPair FindTextPanePair(CGuiFrame* frame, const char* name);
static void FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str);
void DoMenuSelectionChange(const CGuiTableGroup* caller); void DoMenuSelectionChange(const CGuiTableGroup* caller);
void DoMenuAdvance(const CGuiTableGroup* caller); void DoMenuAdvance(const CGuiTableGroup* caller);
@ -116,11 +159,12 @@ public:
u32 x0_ = 0; u32 x0_ = 0;
std::unique_ptr<CNESEmulator> x4_nesEmu; std::unique_ptr<CNESEmulator> x4_nesEmu;
std::unique_ptr<CGuiTextSupport> xc_textSupport; std::unique_ptr<CGuiTextSupport> xc_textSupport;
float x10_ = 8.f; float x10_remTime = 8.f;
bool x14_ = false; bool x14_ = false;
bool x15_ = true; bool x15_ = true;
SFusionBonusFrame(); SFusionBonusFrame();
bool DoUpdateWithSaveUI(float dt, CSaveUI* saveUi);
}; };
struct SOptionsFrontEndFrame struct SOptionsFrontEndFrame
@ -151,7 +195,7 @@ public:
}; };
private: private:
EScreen x14_screen = EScreen::Zero; EPhase x14_phase = EPhase::Zero;
u32 x18_rndA; u32 x18_rndA;
u32 x1c_rndB; u32 x1c_rndB;
TLockedToken<CDependencyGroup> x20_depsGroup; TLockedToken<CDependencyGroup> x20_depsGroup;
@ -178,10 +222,10 @@ private:
std::unique_ptr<CStaticAudioPlayer> xd8_audio2; std::unique_ptr<CStaticAudioPlayer> xd8_audio2;
std::unique_ptr<CSaveUI> xdc_saveUI; std::unique_ptr<CSaveUI> xdc_saveUI;
std::unique_ptr<SNewFileSelectFrame> xe0_newFileSel; std::unique_ptr<SNewFileSelectFrame> xe0_newFileSel;
std::unique_ptr<CGBASupport> xe4_gbaSupport; std::unique_ptr<SGBASupportFrame> xe4_gbaSupportFrme;
std::unique_ptr<SFrontEndFrame> xe8_frontendFrme; std::unique_ptr<SFrontEndFrame> xe8_frontendFrme;
u32 xec_ = 0; std::unique_ptr<SFusionBonusFrame> xec_fusionFrme;
u32 xf0_ = 0; std::unique_ptr<SOptionsFrontEndFrame> xf0_optionsFrme;
CStaticAudioPlayer* xf4_curAudio = nullptr; CStaticAudioPlayer* xf4_curAudio = nullptr;
void SetMovieSecondsDeferred() void SetMovieSecondsDeferred()

View File

@ -5,9 +5,21 @@ namespace urde
namespace MP1 namespace MP1
{ {
bool CGBASupport::PumpLoad() CGBASupport* CGBASupport::SharedInstance = nullptr;
CGBASupport::CGBASupport()
: CDvdFile("client_pad.bin")
{ {
return false; x28_fileSize = ROUND_UP_32(Length());
x2c_buffer.reset(new u8[x28_fileSize]);
x30_dvdReq = AsyncRead(x2c_buffer.get(), x28_fileSize);
//InitDSPComm();
SharedInstance = this;
}
CGBASupport::~CGBASupport()
{
SharedInstance = nullptr;
} }
} }

View File

@ -1,15 +1,28 @@
#ifndef __URDE_CGBASUPPORT_HPP__ #ifndef __URDE_CGBASUPPORT_HPP__
#define __URDE_CGBASUPPORT_HPP__ #define __URDE_CGBASUPPORT_HPP__
#include "CDvdFile.hpp"
namespace urde namespace urde
{ {
namespace MP1 namespace MP1
{ {
class CGBASupport class CGBASupport : public CDvdFile
{ {
u32 x28_fileSize;
std::unique_ptr<u8[]> x2c_buffer;
std::shared_ptr<IDvdRequest> x30_dvdReq;
u32 x34_ = 0;
float x38_ = 0.f;
bool x3c_ = false;
u32 x40_ = -1;
bool x44_ = false;
bool x45_ = false;
static CGBASupport* SharedInstance;
public: public:
bool PumpLoad(); CGBASupport();
~CGBASupport();
}; };
} }