mirror of https://github.com/AxioDL/metaforce.git
More CGuiFrame imps
This commit is contained in:
parent
66247cfe79
commit
5566c5b002
|
@ -7,7 +7,7 @@ extern "C" {
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
static inline short DSPSampClamp(int32_t val)
|
static inline int16_t DSPSampClamp(int32_t val)
|
||||||
{
|
{
|
||||||
if (val < -32768) val = -32768;
|
if (val < -32768) val = -32768;
|
||||||
else if (val > 32767) val = 32767;
|
else if (val > 32767) val = 32767;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Graphics/CGraphics.hpp"
|
#include "Graphics/CGraphics.hpp"
|
||||||
|
#include "Graphics/CLight.hpp"
|
||||||
#include "zeus/Math.hpp"
|
#include "zeus/Math.hpp"
|
||||||
|
|
||||||
#undef near
|
#undef near
|
||||||
|
@ -14,8 +15,8 @@ u32 CGraphics::g_NumBreakpointsWaiting = 0;
|
||||||
u32 CGraphics::g_FlippingState;
|
u32 CGraphics::g_FlippingState;
|
||||||
bool CGraphics::g_LastFrameUsedAbove = false;
|
bool CGraphics::g_LastFrameUsedAbove = false;
|
||||||
bool CGraphics::g_InterruptLastFrameUsedAbove = false;
|
bool CGraphics::g_InterruptLastFrameUsedAbove = false;
|
||||||
ERglLight CGraphics::g_LightActive = ERglLight::None;
|
ERglLightBits CGraphics::g_LightActive = ERglLightBits::None;
|
||||||
ERglLight CGraphics::g_LightsWereOn = ERglLight::None;
|
ERglLightBits CGraphics::g_LightsWereOn = ERglLightBits::None;
|
||||||
zeus::CTransform CGraphics::g_GXModelView;
|
zeus::CTransform CGraphics::g_GXModelView;
|
||||||
zeus::CTransform CGraphics::g_GXModelMatrix;
|
zeus::CTransform CGraphics::g_GXModelMatrix;
|
||||||
zeus::CTransform CGraphics::g_ViewMatrix;
|
zeus::CTransform CGraphics::g_ViewMatrix;
|
||||||
|
@ -30,28 +31,39 @@ bool CGraphics::g_IsGXModelMatrixIdentity;
|
||||||
void CGraphics::DisableAllLights()
|
void CGraphics::DisableAllLights()
|
||||||
{
|
{
|
||||||
g_NumLightsActive = 0;
|
g_NumLightsActive = 0;
|
||||||
g_LightActive = ERglLight::None;
|
g_LightActive = ERglLightBits::None;
|
||||||
// TODO: turn lights off for real
|
// TODO: turn lights off for real
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGraphics::LoadLight(ERglLight light, const CLight& info)
|
||||||
|
{
|
||||||
|
// TODO: load light for real
|
||||||
|
}
|
||||||
|
|
||||||
void CGraphics::EnableLight(ERglLight light)
|
void CGraphics::EnableLight(ERglLight light)
|
||||||
{
|
{
|
||||||
if ((light & g_LightActive) == ERglLight::None)
|
ERglLightBits lightBit = ERglLightBits(1 << int(light));
|
||||||
|
if ((lightBit & g_LightActive) == ERglLightBits::None)
|
||||||
{
|
{
|
||||||
g_LightActive |= light;
|
g_LightActive |= lightBit;
|
||||||
++g_NumLightsActive;
|
++g_NumLightsActive;
|
||||||
// TODO: turn light on for real
|
// TODO: turn light on for real
|
||||||
}
|
}
|
||||||
g_LightsWereOn = g_LightActive;
|
g_LightsWereOn = g_LightActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetLightState(ERglLight lightState)
|
void CGraphics::SetLightState(ERglLightBits lightState)
|
||||||
{
|
{
|
||||||
// TODO: set state for real
|
// TODO: set state for real
|
||||||
g_LightActive = lightState;
|
g_LightActive = lightState;
|
||||||
g_NumLightsActive = zeus::PopCount(lightState);
|
g_NumLightsActive = zeus::PopCount(lightState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGraphics::SetAmbientColor(const zeus::CColor& col)
|
||||||
|
{
|
||||||
|
// TODO: set for real
|
||||||
|
}
|
||||||
|
|
||||||
void CGraphics::SetDepthWriteMode(bool test, ERglEnum comp, bool write)
|
void CGraphics::SetDepthWriteMode(bool test, ERglEnum comp, bool write)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,21 @@
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
class CLight;
|
||||||
|
|
||||||
enum class ERglLight : u8
|
enum class ERglLight : u8
|
||||||
|
{
|
||||||
|
Zero = 0,
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
Three,
|
||||||
|
Four,
|
||||||
|
Five,
|
||||||
|
Six,
|
||||||
|
Seven
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ERglLightBits : u8
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Zero = 1,
|
Zero = 1,
|
||||||
|
@ -23,7 +36,7 @@ enum class ERglLight : u8
|
||||||
Six = 1 << 6,
|
Six = 1 << 6,
|
||||||
Seven = 1 << 7
|
Seven = 1 << 7
|
||||||
};
|
};
|
||||||
ENABLE_BITWISE_ENUM(ERglLight)
|
ENABLE_BITWISE_ENUM(ERglLightBits)
|
||||||
|
|
||||||
enum class ERglEnum
|
enum class ERglEnum
|
||||||
{
|
{
|
||||||
|
@ -154,8 +167,8 @@ public:
|
||||||
static u32 g_FlippingState;
|
static u32 g_FlippingState;
|
||||||
static bool g_LastFrameUsedAbove;
|
static bool g_LastFrameUsedAbove;
|
||||||
static bool g_InterruptLastFrameUsedAbove;
|
static bool g_InterruptLastFrameUsedAbove;
|
||||||
static ERglLight g_LightActive;
|
static ERglLightBits g_LightActive;
|
||||||
static ERglLight g_LightsWereOn;
|
static ERglLightBits g_LightsWereOn;
|
||||||
static zeus::CTransform g_GXModelView;
|
static zeus::CTransform g_GXModelView;
|
||||||
static zeus::CTransform g_GXModelMatrix;
|
static zeus::CTransform g_GXModelMatrix;
|
||||||
static zeus::CTransform g_ViewMatrix;
|
static zeus::CTransform g_ViewMatrix;
|
||||||
|
@ -168,8 +181,10 @@ public:
|
||||||
static bool g_IsGXModelMatrixIdentity;
|
static bool g_IsGXModelMatrixIdentity;
|
||||||
|
|
||||||
static void DisableAllLights();
|
static void DisableAllLights();
|
||||||
|
static void LoadLight(ERglLight light, const CLight& info);
|
||||||
static void EnableLight(ERglLight light);
|
static void EnableLight(ERglLight light);
|
||||||
static void SetLightState(ERglLight lightState);
|
static void SetLightState(ERglLightBits lightState);
|
||||||
|
static void SetAmbientColor(const zeus::CColor& col);
|
||||||
static void SetDepthWriteMode(bool test, ERglEnum comp, bool write);
|
static void SetDepthWriteMode(bool test, ERglEnum comp, bool write);
|
||||||
static void SetBlendMode(ERglBlendMode, ERglBlendFactor, ERglBlendFactor, ERglLogicOp);
|
static void SetBlendMode(ERglBlendMode, ERglBlendFactor, ERglBlendFactor, ERglLogicOp);
|
||||||
static void SetCullMode(ERglCullMode);
|
static void SetCullMode(ERglCullMode);
|
||||||
|
|
|
@ -547,9 +547,9 @@ void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples)
|
||||||
for (u32 i=0 ; i<thisSamples ; ++i, out += 2, in += 2)
|
for (u32 i=0 ; i<thisSamples ; ++i, out += 2, in += 2)
|
||||||
{
|
{
|
||||||
out[0] = DSPSampClamp(in[0] +
|
out[0] = DSPSampClamp(in[0] +
|
||||||
s16(s32(tex->audioBuf[(i+tex->playedSamples)*2]) * 0x50F4 / 0x8000));
|
s32(tex->audioBuf[(i+tex->playedSamples)*2]) * 0x50F4 / 0x8000);
|
||||||
out[1] = DSPSampClamp(in[1] +
|
out[1] = DSPSampClamp(in[1] +
|
||||||
s16(s32(tex->audioBuf[(i+tex->playedSamples)*2+1]) * 0x50F4 / 0x8000));
|
s32(tex->audioBuf[(i+tex->playedSamples)*2+1]) * 0x50F4 / 0x8000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -557,9 +557,9 @@ void CMoviePlayer::MixAudio(s16* out, const s16* in, u32 samples)
|
||||||
for (u32 i=0 ; i<thisSamples ; ++i, out += 2)
|
for (u32 i=0 ; i<thisSamples ; ++i, out += 2)
|
||||||
{
|
{
|
||||||
out[0] = DSPSampClamp(
|
out[0] = DSPSampClamp(
|
||||||
s16(s32(tex->audioBuf[(i+tex->playedSamples)*2]) * 0x50F4 / 0x8000));
|
s32(tex->audioBuf[(i+tex->playedSamples)*2]) * 0x50F4 / 0x8000);
|
||||||
out[1] = DSPSampClamp(
|
out[1] = DSPSampClamp(
|
||||||
s16(s32(tex->audioBuf[(i+tex->playedSamples)*2+1]) * 0x50F4 / 0x8000));
|
s32(tex->audioBuf[(i+tex->playedSamples)*2+1]) * 0x50F4 / 0x8000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tex->playedSamples += thisSamples;
|
tex->playedSamples += thisSamples;
|
||||||
|
@ -594,13 +594,13 @@ void CMoviePlayer::MixStaticAudio(s16* out, const s16* in, u32 samples)
|
||||||
for (u32 i=0 ; i<thisSamples ; i+=2)
|
for (u32 i=0 ; i<thisSamples ; i+=2)
|
||||||
{
|
{
|
||||||
out[0] = DSPSampClamp(in[0] +
|
out[0] = DSPSampClamp(in[0] +
|
||||||
s16(s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
|
||||||
out[1] = DSPSampClamp(in[1] +
|
out[1] = DSPSampClamp(in[1] +
|
||||||
s16(s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
|
||||||
out[2] = DSPSampClamp(in[2] +
|
out[2] = DSPSampClamp(in[2] +
|
||||||
s16(s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
|
||||||
out[3] = DSPSampClamp(in[3] +
|
out[3] = DSPSampClamp(in[3] +
|
||||||
s16(s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
|
||||||
thisOffsetLeft += 1;
|
thisOffsetLeft += 1;
|
||||||
thisOffsetRight += 1;
|
thisOffsetRight += 1;
|
||||||
out += 4;
|
out += 4;
|
||||||
|
@ -612,13 +612,13 @@ void CMoviePlayer::MixStaticAudio(s16* out, const s16* in, u32 samples)
|
||||||
for (u32 i=0 ; i<thisSamples ; i+=2)
|
for (u32 i=0 ; i<thisSamples ; i+=2)
|
||||||
{
|
{
|
||||||
out[0] = DSPSampClamp(
|
out[0] = DSPSampClamp(
|
||||||
s16(s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetLeft[0] & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
|
||||||
out[1] = DSPSampClamp(
|
out[1] = DSPSampClamp(
|
||||||
s16(s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetRight[0] & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
|
||||||
out[2] = DSPSampClamp(
|
out[2] = DSPSampClamp(
|
||||||
s16(s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetLeft[0] >> 4 & 0xf, &StaticStateLeft) * StaticVolumeAtten / 0x8000));
|
||||||
out[3] = DSPSampClamp(
|
out[3] = DSPSampClamp(
|
||||||
s16(s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000)));
|
s32(g721_decoder(thisOffsetRight[0] >> 4 & 0xf, &StaticStateRight) * StaticVolumeAtten / 0x8000));
|
||||||
thisOffsetLeft += 1;
|
thisOffsetLeft += 1;
|
||||||
thisOffsetRight += 1;
|
thisOffsetRight += 1;
|
||||||
out += 4;
|
out += 4;
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
#ifndef __URDE_CGUICONTROLLERINFO_HPP__
|
#ifndef __URDE_CGUICONTROLLERINFO_HPP__
|
||||||
#define __URDE_CGUICONTROLLERINFO_HPP__
|
#define __URDE_CGUICONTROLLERINFO_HPP__
|
||||||
|
|
||||||
|
#include "RetroTypes.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGuiControllerInfo
|
struct CGuiControllerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct CGuiControllerStateInfo
|
struct CGuiControllerStateInfo
|
||||||
{
|
{
|
||||||
char cIdx;
|
char cIdx = 0;
|
||||||
char lx, ly, rx, ry;
|
char lx = 0, ly = 0, rx = 0, ry = 0;
|
||||||
};
|
};
|
||||||
|
u32 x0_ = 0;
|
||||||
|
CGuiControllerStateInfo x4_stateInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include "CGuiHeadWidget.hpp"
|
#include "CGuiHeadWidget.hpp"
|
||||||
#include "CGuiAnimController.hpp"
|
#include "CGuiAnimController.hpp"
|
||||||
#include "CGuiMessage.hpp"
|
#include "CGuiMessage.hpp"
|
||||||
|
#include "CGuiLight.hpp"
|
||||||
|
#include "CGuiCamera.hpp"
|
||||||
|
#include "Graphics/CGraphics.hpp"
|
||||||
#include "Input/CFinalInput.hpp"
|
#include "Input/CFinalInput.hpp"
|
||||||
#include "zeus/CColor.hpp"
|
#include "zeus/CColor.hpp"
|
||||||
|
|
||||||
|
@ -12,7 +15,7 @@ namespace urde
|
||||||
|
|
||||||
CGuiFrame::CGuiFrame(TResId id, const std::string& name, CGuiSys& sys, int a, int b, int c)
|
CGuiFrame::CGuiFrame(TResId id, const std::string& name, CGuiSys& sys, int a, int b, int c)
|
||||||
: x4_name(name), x14_id(id), x1c_transitionOpts(EFrameTransitionOptions::Zero),
|
: x4_name(name), x14_id(id), x1c_transitionOpts(EFrameTransitionOptions::Zero),
|
||||||
x3c_guiSys(sys), xb0_a(a), xb4_b(b), xb8_c(c), xbc_24_flag1(false)
|
x3c_guiSys(sys), xb0_a(a), xb4_b(b), xb8_c(c), xbc_24_loaded(false)
|
||||||
{
|
{
|
||||||
xa0_lights.resize(8);
|
xa0_lights.resize(8);
|
||||||
x48_rootWidget.reset(new CGuiWidget(
|
x48_rootWidget.reset(new CGuiWidget(
|
||||||
|
@ -293,8 +296,8 @@ bool CGuiFrame::SendWidgetMessage(s16 id,
|
||||||
for (std::unique_ptr<CGuiFrameMessageMapNode>& node : list)
|
for (std::unique_ptr<CGuiFrameMessageMapNode>& node : list)
|
||||||
{
|
{
|
||||||
CGuiMessage msg(CGuiMessage::Type(node->GetTrigger().GetTriggerId()),
|
CGuiMessage msg(CGuiMessage::Type(node->GetTrigger().GetTriggerId()),
|
||||||
reinterpret_cast<uintptr_t>(&state),
|
reinterpret_cast<intptr_t>(&state),
|
||||||
reinterpret_cast<uintptr_t>(&csInfo));
|
reinterpret_cast<intptr_t>(&csInfo));
|
||||||
if (!widget->Message(msg))
|
if (!widget->Message(msg))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -345,13 +348,66 @@ void CGuiFrame::SortDrawOrder()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGuiFrame::EnableLights(u32 lights) const
|
||||||
|
{
|
||||||
|
CGraphics::DisableAllLights();
|
||||||
|
zeus::CColor accumColor(zeus::CColor::skBlack);
|
||||||
|
ERglLight lightId = ERglLight::Zero;
|
||||||
|
for (CGuiLight* light : xa0_lights)
|
||||||
|
{
|
||||||
|
// accumulate color
|
||||||
|
CGraphics::LoadLight(lightId, light->BuildLight());
|
||||||
|
CGraphics::EnableLight(lightId);
|
||||||
|
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
|
||||||
|
}
|
||||||
|
if (xa0_lights.empty())
|
||||||
|
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
|
||||||
|
else
|
||||||
|
CGraphics::SetAmbientColor(accumColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiFrame::DisableLights() const
|
||||||
|
{
|
||||||
|
CGraphics::DisableAllLights();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiFrame::RemoveLight(CGuiLight* light)
|
||||||
|
{
|
||||||
|
xa0_lights[light->GetLoadedIdx()] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiFrame::AddLight(CGuiLight* light)
|
||||||
|
{
|
||||||
|
xa0_lights[light->GetLoadedIdx()] = light;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGuiFrame::GetIsFinishedLoading() const
|
||||||
|
{
|
||||||
|
if (xbc_24_loaded)
|
||||||
|
return true;
|
||||||
|
for (const CGuiWidget* widget : x90_widgets)
|
||||||
|
{
|
||||||
|
if (widget->GetIsFinishedLoading())
|
||||||
|
continue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
((CGuiFrame*)this)->xbc_24_loaded = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGuiFrame::Touch() const
|
||||||
|
{
|
||||||
|
for (const CGuiWidget* widget : x90_widgets)
|
||||||
|
widget->Touch();
|
||||||
|
}
|
||||||
|
|
||||||
void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
||||||
{
|
{
|
||||||
if (x18_ & 0x4 && input.controllerIdx() == 0)
|
if (x18_ & 0x4 && input.ControllerIdx() == 0)
|
||||||
{
|
{
|
||||||
CGuiPhysicalMsg::PhysicalMap state;
|
CGuiPhysicalMsg::PhysicalMap state;
|
||||||
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::milliseconds>(
|
||||||
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000.f;
|
std::chrono::steady_clock::now() - x3c_guiSys.x40_constructTime).count() / 1000.f;
|
||||||
|
@ -360,16 +416,16 @@ void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
||||||
{
|
{
|
||||||
auto search = x3c_guiSys.GetRepeatMap().find(newPair.first);
|
auto search = x3c_guiSys.GetRepeatMap().find(newPair.first);
|
||||||
if (search != x3c_guiSys.GetRepeatMap().end())
|
if (search != x3c_guiSys.GetRepeatMap().end())
|
||||||
search->second.SetActive(input.controllerIdx(), eventTime);
|
search->second.SetActive(input.ControllerIdx(), eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::pair<const EPhysicalControllerID, CGuiAutoRepeatData>& pair : x3c_guiSys.GetRepeatMap())
|
for (std::pair<const EPhysicalControllerID, CGuiAutoRepeatData>& pair : x3c_guiSys.GetRepeatMap())
|
||||||
{
|
{
|
||||||
pair.second.AddAutoEvent(input.controllerIdx(), state, eventTime);
|
pair.second.AddAutoEvent(input.ControllerIdx(), state, eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGuiPhysicalMsg msg(state);
|
CGuiPhysicalMsg msg(state);
|
||||||
SetControllerStatus(input.controllerIdx(), true);
|
SetControllerStatus(input.ControllerIdx(), true);
|
||||||
|
|
||||||
for (std::pair<const u64, std::unique_ptr<WidgetToLogicalEventMap>>& outer : x7c_messageMap)
|
for (std::pair<const u64, std::unique_ptr<WidgetToLogicalEventMap>>& outer : x7c_messageMap)
|
||||||
{
|
{
|
||||||
|
@ -390,6 +446,139 @@ void CGuiFrame::ProcessControllerInput(const CFinalInput& input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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::Zero);
|
||||||
|
|
||||||
|
if (something)
|
||||||
|
{
|
||||||
|
switch (x34_)
|
||||||
|
{
|
||||||
|
case EFrameStates::One:
|
||||||
|
{
|
||||||
|
x34_ = x38_;
|
||||||
|
x44_headWidget->SetAnimUpdateState(EGuiAnimBehListID::Zero, false, ETraversalMode::NonRecursive);
|
||||||
|
x44_headWidget->InitializeAnimControllers(EGuiAnimBehListID::Two, 0.f, false,
|
||||||
|
EGuiAnimInitMode::Five, ETraversalMode::NonRecursive);
|
||||||
|
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
|
||||||
|
if (camSib)
|
||||||
|
{
|
||||||
|
camSib->SetAnimUpdateState(EGuiAnimBehListID::Zero, false, ETraversalMode::Zero);
|
||||||
|
camSib->InitializeAnimControllers(EGuiAnimBehListID::Two, 0.f, false,
|
||||||
|
EGuiAnimInitMode::Five, ETraversalMode::Zero);
|
||||||
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if (x18_)
|
||||||
|
{
|
||||||
|
CGraphics::SetCullMode(ERglCullMode::None);
|
||||||
|
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
|
||||||
|
DisableLights();
|
||||||
|
x4c_camera->Draw(parms);
|
||||||
|
// Set one-stage modulate
|
||||||
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
||||||
|
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
||||||
|
if (x50_background)
|
||||||
|
x50_background->Draw(parms);
|
||||||
|
|
||||||
|
for (const CGuiWidget* widget : x90_widgets)
|
||||||
|
if (widget->GetIsVisible())
|
||||||
|
widget->Draw(parms);
|
||||||
|
}
|
||||||
|
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::NonRecursive);
|
||||||
|
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
|
||||||
|
if (camSib)
|
||||||
|
{
|
||||||
|
camSib->InitializeAnimControllers(EGuiAnimBehListID::One, transOpts.xc_, true,
|
||||||
|
EGuiAnimInitMode::Two, ETraversalMode::Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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::NonRecursive);
|
||||||
|
len += transOpts.xc_ + transOpts.x10_ + transOpts.x14_;
|
||||||
|
x44_headWidget->InitializeAnimControllers(EGuiAnimBehListID::Zero, len, true,
|
||||||
|
EGuiAnimInitMode::One, ETraversalMode::NonRecursive);
|
||||||
|
CGuiWidget* camSib = static_cast<CGuiWidget*>(x4c_camera->GetNextSibling());
|
||||||
|
if (camSib)
|
||||||
|
{
|
||||||
|
camSib->InitializeAnimControllers(EGuiAnimBehListID::Zero, len, true,
|
||||||
|
EGuiAnimInitMode::One, ETraversalMode::Zero);
|
||||||
|
}
|
||||||
|
x18_ |= 0x7;
|
||||||
|
x44_headWidget->RegisterEventHandler(ETraversalMode::Zero);
|
||||||
|
}
|
||||||
|
|
||||||
void CGuiFrame::Initialize()
|
void CGuiFrame::Initialize()
|
||||||
{
|
{
|
||||||
SortDrawOrder();
|
SortDrawOrder();
|
||||||
|
|
|
@ -22,12 +22,14 @@ enum class EFrameTransitionOptions
|
||||||
Zero
|
Zero
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGuiFrameTransitionOptions
|
struct CGuiFrameTransitionOptions
|
||||||
{
|
{
|
||||||
EFrameTransitionOptions x0_opts;
|
EFrameTransitionOptions x0_opts;
|
||||||
bool x4_ = true;
|
bool x4_ = true;
|
||||||
float x8_ = 1.f;
|
float x8_ = 1.f;
|
||||||
zeus::CVector3f xc_;
|
float xc_ = 0.f;
|
||||||
|
float x10_ = 0.f;
|
||||||
|
float x14_ = 0.f;
|
||||||
public:
|
public:
|
||||||
CGuiFrameTransitionOptions(EFrameTransitionOptions opts)
|
CGuiFrameTransitionOptions(EFrameTransitionOptions opts)
|
||||||
: x0_opts(opts) {}
|
: x0_opts(opts) {}
|
||||||
|
@ -47,6 +49,11 @@ class CGuiFrame
|
||||||
public:
|
public:
|
||||||
enum class EFrameStates
|
enum class EFrameStates
|
||||||
{
|
{
|
||||||
|
Zero = 0,
|
||||||
|
One = 1,
|
||||||
|
Two = 2,
|
||||||
|
Three = 3,
|
||||||
|
Four = 4
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
bool x0_controllerStatus[4] = {};
|
bool x0_controllerStatus[4] = {};
|
||||||
|
@ -54,8 +61,8 @@ private:
|
||||||
TResId x14_id;
|
TResId x14_id;
|
||||||
u32 x18_ = 0;
|
u32 x18_ = 0;
|
||||||
CGuiFrameTransitionOptions x1c_transitionOpts;
|
CGuiFrameTransitionOptions x1c_transitionOpts;
|
||||||
u32 x34_ = 0;
|
EFrameStates x34_ = EFrameStates::Zero;
|
||||||
u32 x38_ = 0;
|
EFrameStates x38_ = EFrameStates::Zero;
|
||||||
CGuiSys& x3c_guiSys;
|
CGuiSys& x3c_guiSys;
|
||||||
u32 x40_ = 0;
|
u32 x40_ = 0;
|
||||||
CGuiHeadWidget* x44_headWidget = nullptr;
|
CGuiHeadWidget* x44_headWidget = nullptr;
|
||||||
|
@ -73,7 +80,7 @@ private:
|
||||||
int xb0_a;
|
int xb0_a;
|
||||||
int xb4_b;
|
int xb4_b;
|
||||||
int xb8_c;
|
int xb8_c;
|
||||||
bool xbc_24_flag1 : 1;
|
bool xbc_24_loaded : 1;
|
||||||
bool xbd_flag2 = false;
|
bool xbd_flag2 = false;
|
||||||
|
|
||||||
static void InterpretGUIControllerState(const CFinalInput& input,
|
static void InterpretGUIControllerState(const CFinalInput& input,
|
||||||
|
@ -103,7 +110,7 @@ public:
|
||||||
void ClearMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
|
void ClearMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
|
||||||
void AddMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
|
void AddMessageMap(const CGuiLogicalEventTrigger* trigger, s16 id);
|
||||||
void SortDrawOrder();
|
void SortDrawOrder();
|
||||||
void EnableLights(u32) const;
|
void EnableLights(u32 lights) const;
|
||||||
void DisableLights() const;
|
void DisableLights() const;
|
||||||
void RemoveLight(CGuiLight* light);
|
void RemoveLight(CGuiLight* light);
|
||||||
void AddLight(CGuiLight* light);
|
void AddLight(CGuiLight* light);
|
||||||
|
@ -111,7 +118,7 @@ public:
|
||||||
void Touch() const;
|
void Touch() const;
|
||||||
void ProcessControllerInput(const CFinalInput& input);
|
void ProcessControllerInput(const CFinalInput& input);
|
||||||
|
|
||||||
void Update(float dt);
|
bool Update(float dt);
|
||||||
void Draw(const CGuiWidgetDrawParms& parms) const;
|
void Draw(const CGuiWidgetDrawParms& parms) const;
|
||||||
void Stop(const CGuiFrameTransitionOptions&, EFrameStates, bool);
|
void Stop(const CGuiFrameTransitionOptions&, EFrameStates, bool);
|
||||||
void Run(CGuiFrame*, const CGuiFrameTransitionOptions&, EFrameStates, bool);
|
void Run(CGuiFrame*, const CGuiFrameTransitionOptions&, EFrameStates, bool);
|
||||||
|
|
|
@ -22,14 +22,14 @@ private:
|
||||||
Type x0_type = Type::Null;
|
Type x0_type = Type::Null;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uintptr_t x4_int;
|
intptr_t x4_int;
|
||||||
float x4_float;
|
float x4_float;
|
||||||
void* x4_ptr = nullptr;
|
void* x4_ptr = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGuiFuncParm() = default;
|
CGuiFuncParm() = default;
|
||||||
CGuiFuncParm(uintptr_t arg) : x0_type(Type::Int), x4_int(arg) {}
|
CGuiFuncParm(intptr_t arg) : x0_type(Type::Int), x4_int(arg) {}
|
||||||
CGuiFuncParm(float arg) : x0_type(Type::Float), x4_float(arg) {}
|
CGuiFuncParm(float arg) : x0_type(Type::Float), x4_float(arg) {}
|
||||||
CGuiFuncParm(void* arg) : x0_type(Type::IntrusivePointer), x4_ptr(arg) {}
|
CGuiFuncParm(void* arg) : x0_type(Type::IntrusivePointer), x4_ptr(arg) {}
|
||||||
~CGuiFuncParm()
|
~CGuiFuncParm()
|
||||||
|
|
|
@ -10,6 +10,11 @@ CGuiLight::CGuiLight(const CGuiWidgetParms& parms, const CLight& light)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLight CGuiLight::BuildLight() const
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||||
{
|
{
|
||||||
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
||||||
|
|
|
@ -9,8 +9,13 @@ namespace urde
|
||||||
|
|
||||||
class CGuiLight : public CGuiWidget
|
class CGuiLight : public CGuiWidget
|
||||||
{
|
{
|
||||||
|
u32 x118_loadedIdx = 0;
|
||||||
public:
|
public:
|
||||||
CGuiLight(const CGuiWidgetParms& parms, const CLight& light);
|
CGuiLight(const CGuiWidgetParms& parms, const CLight& light);
|
||||||
|
|
||||||
|
CLight BuildLight() const;
|
||||||
|
u32 GetLoadedIdx() const {return x118_loadedIdx;}
|
||||||
|
|
||||||
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
|
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,10 @@ private:
|
||||||
CGuiFuncParm x8_a;
|
CGuiFuncParm x8_a;
|
||||||
CGuiFuncParm x10_b;
|
CGuiFuncParm x10_b;
|
||||||
public:
|
public:
|
||||||
CGuiMessage(Type type, uintptr_t a, uintptr_t b)
|
CGuiMessage(Type type, intptr_t a, intptr_t b)
|
||||||
: x4_type(type), x8_a(a), x10_b(b) {}
|
: x4_type(type), x8_a(a), x10_b(b) {}
|
||||||
uintptr_t GetInt(u32 val) const
|
Type GetType() const {return x4_type;}
|
||||||
|
intptr_t GetInt(u32 val) const
|
||||||
{
|
{
|
||||||
if (val == 0x60EF4DB0)
|
if (val == 0x60EF4DB0)
|
||||||
return x8_a.x4_int;
|
return x8_a.x4_int;
|
||||||
|
|
|
@ -16,16 +16,24 @@ class CGuiLogicalEventTrigger;
|
||||||
|
|
||||||
enum class EGuiAnimBehListID
|
enum class EGuiAnimBehListID
|
||||||
{
|
{
|
||||||
|
NegOne = -1,
|
||||||
|
Zero = 0,
|
||||||
|
One = 1,
|
||||||
|
Two = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ETraversalMode
|
enum class ETraversalMode
|
||||||
{
|
{
|
||||||
|
Zero = 0,
|
||||||
Recursive = 1,
|
Recursive = 1,
|
||||||
NonRecursive = 2
|
NonRecursive = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EGuiAnimInitMode
|
enum class EGuiAnimInitMode
|
||||||
{
|
{
|
||||||
|
One = 1,
|
||||||
|
Two = 2,
|
||||||
|
Five = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EGuiTextureClampModeHorz
|
enum class EGuiTextureClampModeHorz
|
||||||
|
@ -109,7 +117,7 @@ public:
|
||||||
virtual void GetKFAMAssets() const;
|
virtual void GetKFAMAssets() const;
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
virtual void Touch() const;
|
virtual void Touch() const;
|
||||||
virtual void GetIsVisible() const;
|
virtual bool GetIsVisible() const;
|
||||||
virtual bool GetIsActive() const;
|
virtual bool GetIsActive() const;
|
||||||
virtual void TextSupport();
|
virtual void TextSupport();
|
||||||
virtual void GetTextSupport() const;
|
virtual void GetTextSupport() const;
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
CFinalInput& operator|=(const CFinalInput& other);
|
CFinalInput& operator|=(const CFinalInput& other);
|
||||||
bool operator==(const CFinalInput& other)
|
bool operator==(const CFinalInput& other)
|
||||||
{ return memcmp(this, &other, sizeof(CFinalInput)) == 0; }
|
{ return memcmp(this, &other, sizeof(CFinalInput)) == 0; }
|
||||||
u32 controllerIdx() const {return x4_controllerIdx;}
|
u32 ControllerIdx() const {return x4_controllerIdx;}
|
||||||
|
|
||||||
bool PStart() const {return x2e_b31_PStart;}
|
bool PStart() const {return x2e_b31_PStart;}
|
||||||
bool PR() const {return x2e_b26_PR;}
|
bool PR() const {return x2e_b26_PR;}
|
||||||
|
|
|
@ -121,7 +121,7 @@ private:
|
||||||
bool x225_29_modelsUseLights = false;
|
bool x225_29_modelsUseLights = false;
|
||||||
bool x226_enableOPTS;
|
bool x226_enableOPTS;
|
||||||
int x228_MBSP = 0; int m_maxMBSP = 0;
|
int x228_MBSP = 0; int m_maxMBSP = 0;
|
||||||
ERglLight x22c_backupLightActive = ERglLight::None;
|
ERglLightBits x22c_backupLightActive = ERglLightBits::None;
|
||||||
CRandom16 x230_randState;
|
CRandom16 x230_randState;
|
||||||
std::vector<std::unique_ptr<CElementGen>> x234_activePartChildren;
|
std::vector<std::unique_ptr<CElementGen>> x234_activePartChildren;
|
||||||
int x244_CSSD = 0;
|
int x244_CSSD = 0;
|
||||||
|
|
Loading…
Reference in New Issue