diff --git a/Runtime/GuiSys/CGuiTableGroup.cpp b/Runtime/GuiSys/CGuiTableGroup.cpp index 23dd204aa..823f1bdd1 100644 --- a/Runtime/GuiSys/CGuiTableGroup.cpp +++ b/Runtime/GuiSys/CGuiTableGroup.cpp @@ -1,4 +1,6 @@ #include "CGuiTableGroup.hpp" +#include "CGuiAnimController.hpp" +#include "CGuiLogicalEventTrigger.hpp" namespace urde { @@ -23,6 +25,168 @@ void CGuiTableGroup::LoadWidgetFnMap() 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 ; iParseBaseInfo(frame, in, parms); + return ret; +} + } diff --git a/Runtime/GuiSys/CGuiTableGroup.hpp b/Runtime/GuiSys/CGuiTableGroup.hpp index 0160cb8c0..221f08b12 100644 --- a/Runtime/GuiSys/CGuiTableGroup.hpp +++ b/Runtime/GuiSys/CGuiTableGroup.hpp @@ -6,9 +6,65 @@ 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 x20_; + std::unique_ptr x24_; + std::unique_ptr x28_; + std::unique_ptr 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 { public: + enum class ETableGroupModes + { + }; +private: + 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); @@ -24,6 +80,8 @@ public: bool MAF_InitializeTable(CGuiFunctionDef* def, CGuiControllerInfo* info); bool MAF_MenuAdvance(CGuiFunctionDef* def, CGuiControllerInfo* info); bool MAF_MenuCancel(CGuiFunctionDef* def, CGuiControllerInfo* info); + + static CGuiTableGroup* Create(CGuiFrame* frame, CInputStream& in, bool); }; }