mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/AxioDL/urde
This commit is contained in:
commit
72d96d18db
|
@ -232,16 +232,12 @@ size_t FRME::Widget::LITEInfo::binarySize(size_t __isz) const
|
||||||
void FRME::Widget::TXPNInfo::read(athena::io::IStreamReader& __dna_reader)
|
void FRME::Widget::TXPNInfo::read(athena::io::IStreamReader& __dna_reader)
|
||||||
{
|
{
|
||||||
IWidgetInfo::read(__dna_reader);
|
IWidgetInfo::read(__dna_reader);
|
||||||
/* frameVals[0] */
|
/* xDim */
|
||||||
frameVals[0] = __dna_reader.readFloatBig();
|
xDim = __dna_reader.readFloatBig();
|
||||||
/* frameVals[1] */
|
/* zDim */
|
||||||
frameVals[1] = __dna_reader.readFloatBig();
|
zDim = __dna_reader.readFloatBig();
|
||||||
/* frameVals[2] */
|
/* scaleCenter */
|
||||||
frameVals[2] = __dna_reader.readFloatBig();
|
scaleCenter = __dna_reader.readVec3fBig();
|
||||||
/* frameVals[3] */
|
|
||||||
frameVals[3] = __dna_reader.readFloatBig();
|
|
||||||
/* frameVals[4] */
|
|
||||||
frameVals[4] = __dna_reader.readFloatBig();
|
|
||||||
/* font */
|
/* font */
|
||||||
font.read(__dna_reader);
|
font.read(__dna_reader);
|
||||||
/* unk1 */
|
/* unk1 */
|
||||||
|
@ -272,16 +268,12 @@ void FRME::Widget::TXPNInfo::read(athena::io::IStreamReader& __dna_reader)
|
||||||
void FRME::Widget::TXPNInfo::write(athena::io::IStreamWriter& __dna_writer) const
|
void FRME::Widget::TXPNInfo::write(athena::io::IStreamWriter& __dna_writer) const
|
||||||
{
|
{
|
||||||
IWidgetInfo::write(__dna_writer);
|
IWidgetInfo::write(__dna_writer);
|
||||||
/* frameVals[0] */
|
/* xDim */
|
||||||
__dna_writer.writeFloatBig(frameVals[0]);
|
__dna_writer.writeFloatBig(xDim);
|
||||||
/* frameVals[1] */
|
/* zDim */
|
||||||
__dna_writer.writeFloatBig(frameVals[1]);
|
__dna_writer.writeFloatBig(zDim);
|
||||||
/* frameVals[2] */
|
/* scaleCenter */
|
||||||
__dna_writer.writeFloatBig(frameVals[2]);
|
__dna_writer.writeVec3fBig(scaleCenter);
|
||||||
/* frameVals[3] */
|
|
||||||
__dna_writer.writeFloatBig(frameVals[3]);
|
|
||||||
/* frameVals[4] */
|
|
||||||
__dna_writer.writeFloatBig(frameVals[4]);
|
|
||||||
/* font */
|
/* font */
|
||||||
font.write(__dna_writer);
|
font.write(__dna_writer);
|
||||||
/* unk1 */
|
/* unk1 */
|
||||||
|
|
|
@ -157,8 +157,7 @@ struct FRME : BigDNA
|
||||||
struct GRUPInfo : IWidgetInfo
|
struct GRUPInfo : IWidgetInfo
|
||||||
{
|
{
|
||||||
DECL_DNA
|
DECL_DNA
|
||||||
Value<bool> unk1;
|
Value<atInt16> defaultWorker;
|
||||||
Value<bool> unk2;
|
|
||||||
Value<bool> unk3;
|
Value<bool> unk3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,8 +186,8 @@ struct FRME : BigDNA
|
||||||
DECL_DNA
|
DECL_DNA
|
||||||
Value<float> min;
|
Value<float> min;
|
||||||
Value<float> max;
|
Value<float> max;
|
||||||
Value<float> unk1;
|
Value<float> cur;
|
||||||
Value<float> unk2;
|
Value<float> increment;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TXPNInfo : IWidgetInfo
|
struct TXPNInfo : IWidgetInfo
|
||||||
|
@ -207,7 +206,9 @@ struct FRME : BigDNA
|
||||||
TXPNInfo(atUint32 version)
|
TXPNInfo(atUint32 version)
|
||||||
: version(version)
|
: version(version)
|
||||||
{}
|
{}
|
||||||
Value<float> frameVals[5];
|
Value<float> xDim;
|
||||||
|
Value<float> zDim;
|
||||||
|
Value<atVec3f> scaleCenter;
|
||||||
UniqueID32 font;
|
UniqueID32 font;
|
||||||
Value<bool> unk1;
|
Value<bool> unk1;
|
||||||
Value<bool> unk2;
|
Value<bool> unk2;
|
||||||
|
|
|
@ -20,7 +20,7 @@ CGuiFrame::CGuiFrame(TResId id, const std::string& name, CGuiSys& sys, int a, in
|
||||||
xa0_lights.resize(8);
|
xa0_lights.resize(8);
|
||||||
x48_rootWidget.reset(new CGuiWidget(
|
x48_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::Two, false,
|
CGuiWidget::EGuiModelDrawFlags::Alpha, false,
|
||||||
x3c_guiSys.x2c_mode != CGuiSys::EUsageMode::Zero)));
|
x3c_guiSys.x2c_mode != CGuiSys::EUsageMode::Zero)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,8 +420,8 @@ void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
||||||
CGuiControllerInfo::CGuiControllerStateInfo stateInfo;
|
CGuiControllerInfo::CGuiControllerStateInfo stateInfo;
|
||||||
stateInfo.cIdx = input.ControllerIdx();
|
stateInfo.cIdx = input.ControllerIdx();
|
||||||
InterpretGUIControllerState(input, state, stateInfo.lx, stateInfo.ly, stateInfo.rx, stateInfo.ry);
|
InterpretGUIControllerState(input, state, stateInfo.lx, stateInfo.ly, stateInfo.rx, stateInfo.ry);
|
||||||
float eventTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
float eventTime = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000.f;
|
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000000.f;
|
||||||
|
|
||||||
for (const std::pair<EPhysicalControllerID, CGuiPhysicalMsg::CPhysicalID>& newPair : state)
|
for (const std::pair<EPhysicalControllerID, CGuiPhysicalMsg::CPhysicalID>& newPair : state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
|
|
||||||
switch (xc4_drawFlags)
|
switch (xc4_drawFlags)
|
||||||
{
|
{
|
||||||
case EGuiModelDrawFlags::Zero:
|
case EGuiModelDrawFlags::Shadeless:
|
||||||
{
|
{
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
flags.f1 = 0;
|
flags.f1 = 0;
|
||||||
|
@ -73,7 +73,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
model->Draw(flags);
|
model->Draw(flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EGuiModelDrawFlags::One:
|
case EGuiModelDrawFlags::Opaque:
|
||||||
{
|
{
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
flags.f1 = 1;
|
flags.f1 = 1;
|
||||||
|
@ -83,7 +83,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
model->Draw(flags);
|
model->Draw(flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EGuiModelDrawFlags::Two:
|
case EGuiModelDrawFlags::Alpha:
|
||||||
{
|
{
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
flags.f1 = 4;
|
flags.f1 = 4;
|
||||||
|
@ -93,7 +93,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
model->Draw(flags);
|
model->Draw(flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EGuiModelDrawFlags::Three:
|
case EGuiModelDrawFlags::Additive:
|
||||||
{
|
{
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
flags.f1 = 3;
|
flags.f1 = 3;
|
||||||
|
@ -103,7 +103,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
model->Draw(flags);
|
model->Draw(flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EGuiModelDrawFlags::Four:
|
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
||||||
{
|
{
|
||||||
CModelFlags flags;
|
CModelFlags flags;
|
||||||
flags.f1 = 4;
|
flags.f1 = 4;
|
||||||
|
@ -124,6 +124,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
|
|
||||||
if (xf6_29_cullFaces)
|
if (xf6_29_cullFaces)
|
||||||
CGraphics::SetCullMode(ERglCullMode::None);
|
CGraphics::SetCullMode(ERglCullMode::None);
|
||||||
|
xc8_frame->DisableLights();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGuiWidget::Draw(parms);
|
CGuiWidget::Draw(parms);
|
||||||
|
|
|
@ -5,26 +5,47 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, float a, float b, const zeus::CVector3f& vec)
|
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, float xDim, float zDim,
|
||||||
: CGuiWidget(parms), xf8_a(a), xfc_b(b), x108_vec(vec)
|
const zeus::CVector3f& scaleCenter)
|
||||||
|
: CGuiWidget(parms), xf8_xDim(xDim), xfc_zDim(zDim), x108_scaleCenter(scaleCenter)
|
||||||
{
|
{
|
||||||
InitializeBuffers();
|
InitializeBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale)
|
void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale)
|
||||||
{
|
{
|
||||||
|
InitializeBuffers();
|
||||||
|
|
||||||
|
for (specter::View::TexShaderVert& v : x100_verts)
|
||||||
|
{
|
||||||
|
v.m_pos -= x108_scaleCenter;
|
||||||
|
v.m_pos *= scale;
|
||||||
|
v.m_pos += x108_scaleCenter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiPane::SetDimensions(const zeus::CVector2f& dim, bool flag)
|
void CGuiPane::SetDimensions(const zeus::CVector2f& dim, bool initVBO)
|
||||||
{
|
{
|
||||||
|
xf8_xDim = dim.x;
|
||||||
|
xfc_zDim = dim.y;
|
||||||
|
if (initVBO)
|
||||||
|
InitializeBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
const zeus::CVector3f& CGuiPane::GetDimensions() const
|
zeus::CVector2f CGuiPane::GetDimensions() const
|
||||||
{
|
{
|
||||||
|
return {xf8_xDim, xfc_zDim};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiPane::InitializeBuffers()
|
void CGuiPane::InitializeBuffers()
|
||||||
{
|
{
|
||||||
|
if (x100_verts.size() < 4)
|
||||||
|
x100_verts.resize(4);
|
||||||
|
|
||||||
|
x100_verts[0].m_pos.assign(-xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
|
||||||
|
x100_verts[1].m_pos.assign(-xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
|
||||||
|
x100_verts[2].m_pos.assign(xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
|
||||||
|
x100_verts[3].m_pos.assign(xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiPane::WriteData(COutputStream& out, bool flag) const
|
void CGuiPane::WriteData(COutputStream& out, bool flag) const
|
||||||
|
@ -34,11 +55,11 @@ void CGuiPane::WriteData(COutputStream& out, bool flag) const
|
||||||
CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
{
|
{
|
||||||
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
||||||
float a = in.readFloatBig();
|
float x = in.readFloatBig();
|
||||||
float b = in.readFloatBig();
|
float z = in.readFloatBig();
|
||||||
zeus::CVector3f vec;
|
zeus::CVector3f scaleCenter;
|
||||||
vec.readBig(in);
|
scaleCenter.readBig(in);
|
||||||
return new CGuiPane(parms, a, b, vec);
|
return new CGuiPane(parms, x, z, scaleCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,26 +2,34 @@
|
||||||
#define __URDE_CGUIPANE_HPP__
|
#define __URDE_CGUIPANE_HPP__
|
||||||
|
|
||||||
#include "CGuiWidget.hpp"
|
#include "CGuiWidget.hpp"
|
||||||
|
#include "specter/View.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGuiPane : public CGuiWidget
|
class CGuiPane : public CGuiWidget
|
||||||
{
|
{
|
||||||
float xf8_a;
|
protected:
|
||||||
float xfc_b;
|
float xf8_xDim;
|
||||||
u32 x100_ = 0;
|
float xfc_zDim;
|
||||||
u32 x104_ = 4;
|
|
||||||
zeus::CVector3f x108_vec;
|
/* Originally a vert-buffer pointer for GX */
|
||||||
|
std::vector<specter::View::TexShaderVert> x100_verts;
|
||||||
|
// u32 x104_ = 4; /* vert count */
|
||||||
|
|
||||||
|
zeus::CVector3f x108_scaleCenter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGuiPane(const CGuiWidgetParms& parms, float a, float b, const zeus::CVector3f& vec);
|
CGuiPane(const CGuiWidgetParms& parms, float xDim, float zDim, const zeus::CVector3f& scaleCenter);
|
||||||
static CGuiPane* Create(CGuiFrame* frame, CInputStream& in, bool);
|
FourCC GetWidgetTypeID() const {return FOURCC('PANE');}
|
||||||
|
|
||||||
virtual void ScaleDimensions(const zeus::CVector3f& scale);
|
virtual void ScaleDimensions(const zeus::CVector3f& scale);
|
||||||
virtual void SetDimensions(const zeus::CVector2f& dim, bool flag);
|
virtual void SetDimensions(const zeus::CVector2f& dim, bool initVBO);
|
||||||
virtual const zeus::CVector3f& GetDimensions() const;
|
virtual zeus::CVector2f GetDimensions() const;
|
||||||
virtual void InitializeBuffers();
|
virtual void InitializeBuffers();
|
||||||
virtual void WriteData(COutputStream& out, bool flag) const;
|
virtual void WriteData(COutputStream& out, bool flag) const;
|
||||||
|
|
||||||
|
static CGuiPane* Create(CGuiFrame* frame, CInputStream& in, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "CGuiSliderGroup.hpp"
|
#include "CGuiSliderGroup.hpp"
|
||||||
|
#include "CGuiAnimController.hpp"
|
||||||
|
#include "CGuiLogicalEventTrigger.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
@ -12,12 +14,72 @@ void CGuiSliderGroup::LoadWidgetFnMap()
|
||||||
WidgetFnMap.emplace(std::make_pair(19, &CGuiSliderGroup::MAF_Decrement));
|
WidgetFnMap.emplace(std::make_pair(19, &CGuiSliderGroup::MAF_Decrement));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGuiSliderGroup::MAF_Increment(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGuiSliderGroup::MAF_Decrement(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
void CGuiSliderGroup::SetSelectionChangedCallback
|
||||||
|
(std::function<void(const CGuiSliderGroup*, float)>&& 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)
|
||||||
|
{
|
||||||
|
x100_curVal = zeus::clamp(xf8_minVal, cur, xfc_maxVal);
|
||||||
|
float factor = 0.f;
|
||||||
|
if (xfc_maxVal != xf8_minVal)
|
||||||
|
factor = (x100_curVal - xf8_minVal) / (xfc_maxVal - xf8_minVal);
|
||||||
|
|
||||||
|
const zeus::CVector3f& w0Idle = x10c_workers[0]->GetIdlePosition();
|
||||||
|
const zeus::CVector3f& w1Idle = x10c_workers[1]->GetIdlePosition();
|
||||||
|
x10c_workers[0]->SetLocalPosition(zeus::CVector3f::lerp(w0Idle, w1Idle, factor));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGuiSliderGroup::AddWorkerWidget(CGuiWidget* worker)
|
||||||
|
{
|
||||||
|
if (worker->GetWorkerId() < 0 || worker->GetWorkerId() > 1)
|
||||||
|
return true;
|
||||||
|
x10c_workers[worker->GetWorkerId()] = worker;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGuiWidget* CGuiSliderGroup::GetWorkerWidget(int id)
|
||||||
|
{
|
||||||
|
if (id < 0 || id > 1)
|
||||||
|
return nullptr;
|
||||||
|
return x10c_workers[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
CGuiSliderGroup* CGuiSliderGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
|
{
|
||||||
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
||||||
|
|
||||||
|
float min = in.readFloatBig();
|
||||||
|
float max = in.readFloatBig();
|
||||||
|
float cur = in.readFloatBig();
|
||||||
|
float increment = in.readFloatBig();
|
||||||
|
|
||||||
|
CGuiSliderGroup* ret = new CGuiSliderGroup(parms, min, max, cur, increment);
|
||||||
|
ret->ParseBaseInfo(frame, in, parms);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,37 @@
|
||||||
#define __URDE_CGUISLIDERGROUP_HPP__
|
#define __URDE_CGUISLIDERGROUP_HPP__
|
||||||
|
|
||||||
#include "CGuiCompoundWidget.hpp"
|
#include "CGuiCompoundWidget.hpp"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGuiSliderGroup : public CGuiCompoundWidget
|
class CGuiSliderGroup : public CGuiCompoundWidget
|
||||||
{
|
{
|
||||||
|
float xf8_minVal;
|
||||||
|
float xfc_maxVal;
|
||||||
|
float x100_curVal;
|
||||||
|
float x104_increment;
|
||||||
|
u32 x108_ = 2;
|
||||||
|
CGuiWidget* x10c_workers[2] = {};
|
||||||
|
std::function<void(const CGuiSliderGroup*, float)> x114_changeCallback;
|
||||||
public:
|
public:
|
||||||
|
CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d);
|
||||||
|
FourCC GetWidgetTypeID() const {return FOURCC('SLGP');}
|
||||||
static void LoadWidgetFnMap();
|
static void LoadWidgetFnMap();
|
||||||
|
|
||||||
|
void SetSelectionChangedCallback(std::function<void(const CGuiSliderGroup*, float)>&& func);
|
||||||
bool MAF_Increment(CGuiFunctionDef* def, CGuiControllerInfo* info);
|
bool MAF_Increment(CGuiFunctionDef* def, CGuiControllerInfo* info);
|
||||||
bool MAF_Decrement(CGuiFunctionDef* def, CGuiControllerInfo* info);
|
bool MAF_Decrement(CGuiFunctionDef* def, CGuiControllerInfo* info);
|
||||||
|
void SetIncrement(float inc) {x104_increment = inc;}
|
||||||
|
void SetMinVal(float min) {xf8_minVal = min; SetCurVal(x100_curVal);}
|
||||||
|
void SetMaxVal(float max) {xfc_maxVal = max; SetCurVal(x100_curVal);}
|
||||||
|
void SetCurVal(float cur);
|
||||||
|
|
||||||
|
bool AddWorkerWidget(CGuiWidget* worker);
|
||||||
|
CGuiWidget* GetWorkerWidget(int id);
|
||||||
|
|
||||||
|
static CGuiSliderGroup* Create(CGuiFrame* frame, CInputStream& in, bool flag);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,166 @@
|
||||||
#include "CGuiStaticImage.hpp"
|
#include "CGuiStaticImage.hpp"
|
||||||
#include "CGuiAnimController.hpp"
|
#include "CGuiAnimController.hpp"
|
||||||
#include "CGuiLogicalEventTrigger.hpp"
|
#include "CGuiLogicalEventTrigger.hpp"
|
||||||
|
#include "CGuiFrame.hpp"
|
||||||
|
#include "CGuiSys.hpp"
|
||||||
|
#include "CSimplePool.hpp"
|
||||||
|
#include "Graphics/CGraphics.hpp"
|
||||||
|
#include "Graphics/CTexture.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
CGuiStaticImage::CGuiStaticImage
|
CGuiStaticImage::CGuiStaticImage
|
||||||
(const CGuiWidgetParms& parms, float a, float b, const zeus::CVector3f& c,
|
(const CGuiWidgetParms& parms, float xDim, float zDim,
|
||||||
EGuiTextureClampModeHorz, EGuiTextureClampModeVert,
|
const zeus::CVector3f& scaleCenter,
|
||||||
CGuiStaticImage::EMaterialType, u32, u32,
|
EGuiTextureClampModeHorz clampH, EGuiTextureClampModeVert clampV,
|
||||||
std::vector<float>&&, bool)
|
CGuiStaticImage::EMaterialType matType, TResId txtrId1, TResId txtrId2,
|
||||||
: CGuiPane(parms, a, b, c)
|
const std::vector<float>& frame, bool useTexture)
|
||||||
|
: CGuiPane(parms, xDim, zDim, scaleCenter),
|
||||||
|
x114_materialType(matType),
|
||||||
|
x120_textureID1(txtrId1),
|
||||||
|
x124_textureID2(txtrId2),
|
||||||
|
x128_clampH(clampH),
|
||||||
|
x12c_clampV(clampV),
|
||||||
|
x130_clampedUVs(frame),
|
||||||
|
x140_UVs(frame)
|
||||||
{
|
{
|
||||||
|
CGuiSys& guiSys = parms.x0_frame->GetGuiSys();
|
||||||
|
if (useTexture && guiSys.GetUsageMode() != CGuiSys::EUsageMode::Two)
|
||||||
|
{
|
||||||
|
if ((txtrId1 & 0xffff) != 0xffff)
|
||||||
|
x118_texture1 = guiSys.GetResStore().GetObj({SBIG('TXTR'), txtrId1});
|
||||||
|
if ((txtrId2 & 0xffff) != 0xffff)
|
||||||
|
x11c_texture2 = guiSys.GetResStore().GetObj({SBIG('TXTR'), txtrId2});
|
||||||
|
}
|
||||||
|
SetDimensions({xDim, zDim}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiStaticImage::ScaleDimensions(const zeus::CVector3f& scale)
|
||||||
|
{
|
||||||
|
CGuiPane::ScaleDimensions(scale);
|
||||||
|
zeus::CVector2f dim = GetDimensions();
|
||||||
|
|
||||||
|
float resH1 = x140_UVs[4];
|
||||||
|
float resH0 = x140_UVs[0];
|
||||||
|
float resV1 = x140_UVs[3];
|
||||||
|
float resV0 = x140_UVs[1];
|
||||||
|
|
||||||
|
float f3 = resH1 - resH0;
|
||||||
|
float f1 = std::fabs(x100_verts[2].m_pos.x - x100_verts[0].m_pos.x) - dim.x;
|
||||||
|
|
||||||
|
switch (x128_clampH)
|
||||||
|
{
|
||||||
|
case EGuiTextureClampModeHorz::Right:
|
||||||
|
resH1 += f3 * f1 / dim.x;
|
||||||
|
break;
|
||||||
|
case EGuiTextureClampModeHorz::Left:
|
||||||
|
resH0 -= f3 * f1 / dim.x;
|
||||||
|
break;
|
||||||
|
case EGuiTextureClampModeHorz::Center:
|
||||||
|
resH1 += f3 * f1 * 0.5f / dim.x;
|
||||||
|
resH0 -= f3 * f1 * 0.5f / dim.x;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
f3 = resV1 - resV0;
|
||||||
|
f1 = std::fabs(x100_verts[0].m_pos.z - x100_verts[1].m_pos.z) - dim.y;
|
||||||
|
|
||||||
|
switch (x12c_clampV)
|
||||||
|
{
|
||||||
|
case EGuiTextureClampModeVert::Top:
|
||||||
|
resV0 -= f3 * f1 / dim.y;
|
||||||
|
break;
|
||||||
|
case EGuiTextureClampModeVert::Bottom:
|
||||||
|
resV1 += f3 * f1 / dim.y;
|
||||||
|
break;
|
||||||
|
case EGuiTextureClampModeVert::Center:
|
||||||
|
resV1 += f3 * f1 * 0.5f / dim.y;
|
||||||
|
resV0 -= f3 * f1 * 0.5f / dim.y;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
x130_clampedUVs[0] = resH0;
|
||||||
|
x130_clampedUVs[1] = resV0;
|
||||||
|
x130_clampedUVs[2] = resH0;
|
||||||
|
x130_clampedUVs[3] = resV1;
|
||||||
|
x130_clampedUVs[4] = resH1;
|
||||||
|
x130_clampedUVs[5] = resV0;
|
||||||
|
x130_clampedUVs[6] = resH1;
|
||||||
|
x130_clampedUVs[7] = resV1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiStaticImage::Draw(const CGuiWidgetDrawParms& parms) const
|
||||||
|
{
|
||||||
|
CGraphics::SetModelMatrix(x34_worldXF * zeus::CTransform::Translate(x108_scaleCenter));
|
||||||
|
if (GetIsVisible())
|
||||||
|
{
|
||||||
|
switch (x114_materialType)
|
||||||
|
{
|
||||||
|
case EMaterialType::OneTexture:
|
||||||
|
x118_texture1->Load(0, CTexture::EClampMode::One);
|
||||||
|
break;
|
||||||
|
case EMaterialType::TwoTextures:
|
||||||
|
x118_texture1->Load(0, CTexture::EClampMode::One);
|
||||||
|
x11c_texture2->Load(1, CTexture::EClampMode::One);
|
||||||
|
break;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGraphics::SetBlendMode(ERglBlendMode::Blend,
|
||||||
|
ERglBlendFactor::SrcAlpha,
|
||||||
|
ERglBlendFactor::InvSrcAlpha,
|
||||||
|
ERglLogicOp::Clear);
|
||||||
|
|
||||||
|
/* Begin tri-strip of verts in x100_verts */
|
||||||
|
/* Vtx Color xb4_ */
|
||||||
|
/* UVs x130_clampedUVs[0], x130_clampedUVs[3] */
|
||||||
|
/* UVs x130_clampedUVs[2], x130_clampedUVs[1] */
|
||||||
|
/* UVs x130_clampedUVs[4], x130_clampedUVs[7] */
|
||||||
|
/* UVs x130_clampedUVs[6], x130_clampedUVs[5] */
|
||||||
|
}
|
||||||
|
CGuiWidget::Draw(parms);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<TResId> CGuiStaticImage::GetTextureAssets() const
|
||||||
|
{
|
||||||
|
std::vector<TResId> ret;
|
||||||
|
ret.reserve(2);
|
||||||
|
if ((x120_textureID1 & 0xffff) != 0xffff)
|
||||||
|
ret.push_back(x120_textureID1);
|
||||||
|
if ((x124_textureID2 & 0xffff) != 0xffff)
|
||||||
|
ret.push_back(x124_textureID2);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGuiStaticImage* CGuiStaticImage::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
CGuiStaticImage* CGuiStaticImage::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
{
|
{
|
||||||
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
||||||
|
|
||||||
|
float xDim = in.readFloatBig();
|
||||||
|
float zDim = in.readFloatBig();
|
||||||
|
zeus::CVector3f scaleCenter;
|
||||||
|
scaleCenter.readBig(in);
|
||||||
|
|
||||||
|
CGuiStaticImage::EMaterialType matType = CGuiStaticImage::EMaterialType(in.readUint32Big());
|
||||||
|
TResId txtr1 = in.readUint32Big();
|
||||||
|
TResId txtr2 = in.readUint32Big();
|
||||||
|
|
||||||
|
EGuiTextureClampModeHorz clampH = EGuiTextureClampModeHorz(in.readUint32Big());
|
||||||
|
EGuiTextureClampModeVert clampV = EGuiTextureClampModeVert(in.readUint32Big());
|
||||||
|
|
||||||
float a = in.readFloatBig();
|
float a = in.readFloatBig();
|
||||||
float b = in.readFloatBig();
|
float b = in.readFloatBig();
|
||||||
float c = in.readFloatBig();
|
float c = in.readFloatBig();
|
||||||
float d = in.readFloatBig();
|
float d = in.readFloatBig();
|
||||||
std::vector<float> floats = {a, b, a, d, c, b, c, d};
|
std::vector<float> floats = {a, b, a, d, c, b, c, d};
|
||||||
|
|
||||||
zeus::CVector3f vec;
|
CGuiStaticImage* ret = new CGuiStaticImage(parms, xDim, zDim, scaleCenter, clampH, clampV,
|
||||||
vec.readBig(in);
|
matType, txtr1, txtr2, floats, true);
|
||||||
u32 e = in.readUint32Big();
|
ret->ParseBaseInfo(frame, in, parms);
|
||||||
u32 f = in.readUint32Big();
|
return ret;
|
||||||
u32 g = in.readUint32Big();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,42 @@
|
||||||
#define __URDE_CGUISTATICIMAGE_HPP__
|
#define __URDE_CGUISTATICIMAGE_HPP__
|
||||||
|
|
||||||
#include "CGuiPane.hpp"
|
#include "CGuiPane.hpp"
|
||||||
|
#include "CToken.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
class CTexture;
|
||||||
|
|
||||||
class CGuiStaticImage : public CGuiPane
|
class CGuiStaticImage : public CGuiPane
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class EMaterialType
|
enum class EMaterialType
|
||||||
{
|
{
|
||||||
|
OneTexture = 0,
|
||||||
|
TwoTextures = 1
|
||||||
};
|
};
|
||||||
CGuiStaticImage(const CGuiWidgetParms& parms, float, float, const zeus::CVector3f&,
|
private:
|
||||||
EGuiTextureClampModeHorz, EGuiTextureClampModeVert,
|
EMaterialType x114_materialType;
|
||||||
CGuiStaticImage::EMaterialType, u32, u32,
|
TLockedToken<CTexture> x118_texture1;
|
||||||
std::vector<float>&&, bool);
|
TLockedToken<CTexture> x11c_texture2;
|
||||||
|
TResId x120_textureID1;
|
||||||
|
TResId x124_textureID2;
|
||||||
|
EGuiTextureClampModeHorz x128_clampH;
|
||||||
|
EGuiTextureClampModeVert x12c_clampV;
|
||||||
|
std::vector<float> x130_clampedUVs;
|
||||||
|
std::vector<float> x140_UVs;
|
||||||
|
public:
|
||||||
|
CGuiStaticImage(const CGuiWidgetParms& parms, float xDim, float zDim,
|
||||||
|
const zeus::CVector3f& scaleCenter,
|
||||||
|
EGuiTextureClampModeHorz clampH, EGuiTextureClampModeVert clampV,
|
||||||
|
CGuiStaticImage::EMaterialType matType, TResId txtrId1, TResId txtrId2,
|
||||||
|
const std::vector<float>& frame, bool useTexture);
|
||||||
|
FourCC GetWidgetTypeID() const {return FOURCC('IMAG');}
|
||||||
|
|
||||||
|
void ScaleDimensions(const zeus::CVector3f& scale);
|
||||||
|
void Draw(const CGuiWidgetDrawParms& parms) const;
|
||||||
|
std::vector<TResId> GetTextureAssets() const;
|
||||||
|
|
||||||
static CGuiStaticImage* Create(CGuiFrame* frame, CInputStream& in, bool flag);
|
static CGuiStaticImage* Create(CGuiFrame* frame, CInputStream& in, bool flag);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ void CGuiWidget::EnsureHasAnimController()
|
||||||
{
|
{
|
||||||
xb0_animController.reset(new CGuiAnimController(
|
xb0_animController.reset(new CGuiAnimController(
|
||||||
CGuiWidgetParms(xc8_frame, false, -1, -1, true, false, false,
|
CGuiWidgetParms(xc8_frame, false, -1, -1, true, false, false,
|
||||||
zeus::CColor::skWhite, EGuiModelDrawFlags::Two,
|
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha,
|
||||||
true, false), this));
|
true, false), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ void CGuiWidget::AddAnim(EGuiAnimBehListID id, CGuiAnimBase* anim)
|
||||||
{
|
{
|
||||||
xb0_animController.reset(new CGuiAnimController(
|
xb0_animController.reset(new CGuiAnimController(
|
||||||
CGuiWidgetParms(xc8_frame, false, -1, -1, false, false, false,
|
CGuiWidgetParms(xc8_frame, false, -1, -1, false, false, false,
|
||||||
zeus::CColor::skWhite, EGuiModelDrawFlags::Two, true, false), this));
|
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha, true, false), this));
|
||||||
}
|
}
|
||||||
xb0_animController->AddAnimation(anim, id);
|
xb0_animController->AddAnimation(anim, id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,18 @@ enum class EGuiAnimInitMode
|
||||||
|
|
||||||
enum class EGuiTextureClampModeHorz
|
enum class EGuiTextureClampModeHorz
|
||||||
{
|
{
|
||||||
|
NoClamp = 0,
|
||||||
|
Right = 1,
|
||||||
|
Left = 2,
|
||||||
|
Center = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EGuiTextureClampModeVert
|
enum class EGuiTextureClampModeVert
|
||||||
{
|
{
|
||||||
|
NoClamp = 0,
|
||||||
|
Top = 1,
|
||||||
|
Bottom = 2,
|
||||||
|
Center = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGuiWidget : public CGuiObject
|
class CGuiWidget : public CGuiObject
|
||||||
|
@ -53,11 +61,11 @@ class CGuiWidget : public CGuiObject
|
||||||
public:
|
public:
|
||||||
enum class EGuiModelDrawFlags
|
enum class EGuiModelDrawFlags
|
||||||
{
|
{
|
||||||
Zero = 0,
|
Shadeless = 0,
|
||||||
One = 1,
|
Opaque = 1,
|
||||||
Two = 2,
|
Alpha = 2,
|
||||||
Three = 3,
|
Additive = 3,
|
||||||
Four = 4
|
AlphaAdditiveOverdraw = 4
|
||||||
};
|
};
|
||||||
struct CGuiWidgetParms
|
struct CGuiWidgetParms
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue