mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 14:27:42 +00:00
CGuiVirtualBox imps
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user