CGuiVirtualBox imps

This commit is contained in:
Jack Andersen 2016-03-17 16:45:45 -10:00
parent 7c7140cffd
commit a9826de57f
2 changed files with 251 additions and 0 deletions

View File

@ -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 ; 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),
xf8_(a), xfc_(b),
x118_(f), x119_(e),
x11c_(h), x120_(g),
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)
{
}
@ -75,4 +239,33 @@ bool CGuiTableGroup::MAF_MenuCancel(CGuiFunctionDef* def, CGuiControllerInfo* in
{
}
CGuiTableGroup* CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
int a = in.readInt16Big();
int b = in.readInt16Big();
ETableGroupModes modes = ETableGroupModes(in.readUint32Big());
int c = in.readInt16Big();
int d = in.readInt16Big();
bool e = in.readBool();
bool f = in.readBool();
float g = in.readFloatBig();
float h = in.readFloatBig();
bool i = in.readBool();
float j = in.readFloatBig();
int ba = in.readInt16Big();
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);
return ret;
}
}

View File

@ -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<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
{
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);
};
}