metaforce/Runtime/MP1/CSamusHud.hpp

292 lines
11 KiB
C++
Raw Normal View History

2017-02-12 03:17:18 +00:00
#ifndef __URDE_CSAMUSHUD_HPP__
#define __URDE_CSAMUSHUD_HPP__
2017-02-18 02:19:50 +00:00
#include "CInGameGuiManager.hpp"
2017-04-02 03:03:37 +00:00
#include "GuiSys/CTargetingManager.hpp"
#include "GuiSys/CHudBallInterface.hpp"
#include "GuiSys/CHudBossEnergyInterface.hpp"
#include "GuiSys/CHudDecoInterface.hpp"
#include "GuiSys/CHudEnergyInterface.hpp"
#include "GuiSys/CHudFreeLookInterface.hpp"
#include "GuiSys/CHudHelmetInterface.hpp"
#include "GuiSys/CHudMissileInterface.hpp"
#include "GuiSys/CHudRadarInterface.hpp"
#include "GuiSys/CHudThreatInterface.hpp"
#include "GuiSys/CHudVisorBeamMenu.hpp"
2017-06-01 05:34:24 +00:00
#include "Graphics/Shaders/CRandomStaticFilter.hpp"
2017-02-18 02:19:50 +00:00
2017-02-12 03:17:18 +00:00
namespace urde
{
class CGuiFrame;
class CStateManager;
2017-04-02 03:03:37 +00:00
class CGuiLight;
2017-02-12 03:17:18 +00:00
2017-04-02 03:03:37 +00:00
struct CHUDMemoParms
2017-03-24 05:30:16 +00:00
{
2017-04-13 19:28:31 +00:00
float x0_alpha = 0.f;
bool x4_initializeMemo = false;
bool x5_hintDismissSound = false;
bool x6_hintMemo = false;
2017-04-03 01:39:23 +00:00
CHUDMemoParms() = default;
2017-04-13 19:28:31 +00:00
CHUDMemoParms(float alpha, bool initializeMemo, bool hintDismissSound, bool hintMemo)
: x0_alpha(alpha), x4_initializeMemo(initializeMemo),
x5_hintDismissSound(hintDismissSound), x6_hintMemo(hintMemo) {}
2017-04-03 01:39:23 +00:00
CHUDMemoParms(CInputStream& in)
{
2017-04-13 19:28:31 +00:00
x0_alpha = in.readFloatBig();
x4_initializeMemo = in.readBool();
2017-04-03 01:39:23 +00:00
}
2017-03-24 05:30:16 +00:00
};
2017-04-02 03:03:37 +00:00
enum class EHudState
{
Combat,
XRay,
Thermal,
Scan,
Ball,
None
};
2017-02-12 03:17:18 +00:00
namespace MP1
{
class CSamusHud
{
2017-04-02 03:03:37 +00:00
enum class ELoadPhase
{
2017-04-03 01:39:23 +00:00
Zero,
One,
Two,
Three
2017-04-02 03:03:37 +00:00
};
2017-04-03 01:39:23 +00:00
2017-04-02 03:03:37 +00:00
enum class ETransitionState
{
2017-04-03 01:39:23 +00:00
NotTransitioning,
Countdown,
Loading,
Transitioning
2017-04-02 03:03:37 +00:00
};
struct SCachedHudLight
{
zeus::CVector3f x0_pos;
zeus::CColor xc_color;
2017-04-13 19:28:31 +00:00
float x10_distC = 0.f;
float x14_distL = 0.f;
float x18_distQ = 0.f;
float x1c_fader = 0.f;
2017-04-02 03:03:37 +00:00
SCachedHudLight(const zeus::CVector3f& pos, const zeus::CColor& color,
float f1, float f2, float f3, float f4)
2017-04-13 19:28:31 +00:00
: x0_pos(pos), xc_color(color), x10_distC(f1), x14_distL(f2), x18_distQ(f3), x1c_fader(f4) {}
2017-04-02 03:03:37 +00:00
};
struct SVideoBand
{
CGuiModel* x0_videoband = nullptr;
float x4_randA = 0.f;
float x8_randB = 0.f;
};
struct SProfileInfo
{
u32 x0_ = 0;
u32 x4_ = 0;
2017-05-21 16:01:04 +00:00
u64 x8_profUsec = 0;
2017-04-02 03:03:37 +00:00
};
2017-02-12 03:17:18 +00:00
friend class CInGameGuiManager;
2017-04-02 03:03:37 +00:00
ELoadPhase x4_loadPhase = ELoadPhase::Zero;
CTargetingManager x8_targetingMgr;
TLockedToken<CGuiFrame> x258_frmeHelmet;
CGuiFrame* x264_loadedFrmeHelmet = nullptr;
TLockedToken<CGuiFrame> x268_frmeBaseHud;
CGuiFrame* x274_loadedFrmeBaseHud = nullptr;
TLockedToken<CGuiFrame> x278_selectedHud; // used to be optional
CGuiFrame* x288_loadedSelectedHud = nullptr;
2017-04-08 20:40:36 +00:00
std::unique_ptr<CHudEnergyInterface> x28c_energyIntf;
2017-04-07 05:35:09 +00:00
std::unique_ptr<CHudThreatInterface> x290_threatIntf;
2017-04-04 05:48:13 +00:00
std::unique_ptr<CHudMissileInterface> x294_missileIntf;
2017-04-02 03:03:37 +00:00
std::unique_ptr<IFreeLookInterface> x298_freeLookIntf;
std::unique_ptr<IHudDecoInterface> x29c_decoIntf;
std::unique_ptr<CHudHelmetInterface> x2a0_helmetIntf;
std::unique_ptr<CHudVisorBeamMenu> x2a4_visorMenu;
std::unique_ptr<CHudVisorBeamMenu> x2a8_beamMenu;
std::unique_ptr<CHudRadarInterface> x2ac_radarIntf;
std::unique_ptr<CHudBallInterface> x2b0_ballIntf;
std::unique_ptr<CHudBossEnergyInterface> x2b4_bossEnergyIntf;
EHudState x2b8_curState = EHudState::None;
EHudState x2bc_nextState = EHudState::None;
2017-04-03 01:39:23 +00:00
EHudState x2c0_setState = EHudState::None;
ETransitionState x2c4_activeTransState = ETransitionState::NotTransitioning;
float x2c8_transT = 1.f;
u32 x2cc_preLoadCountdown = 0;
2017-04-03 05:37:54 +00:00
float x2d0_playerHealth = 0.f;
2017-04-02 03:03:37 +00:00
u32 x2d4_totalEnergyTanks = 0;
u32 x2d8_missileAmount = 0;
u32 x2dc_missileCapacity = 0;
union
{
struct
{
2017-04-07 05:35:09 +00:00
bool x2e0_24_inFreeLook : 1;
bool x2e0_25_lookControlHeld : 1;
2017-04-03 01:39:23 +00:00
bool x2e0_26_latestFirstPerson : 1;
2017-04-02 03:03:37 +00:00
bool x2e0_27_energyLow : 1;
};
u16 _dummy = 0;
};
u32 x2e4_ = 0;
u32 x2e8_ = 0;
2017-04-09 06:14:22 +00:00
CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive;
2017-04-03 01:39:23 +00:00
float x2f0_visorBeamMenuAlpha = 1.f;
2017-04-02 03:03:37 +00:00
zeus::CVector3f x2f8_fpCamDir;
zeus::CVector3f x304_basewidgetIdlePos;
zeus::CVector3f x310_cameraPos;
2017-04-09 06:14:22 +00:00
zeus::CQuaternion x31c_hudLag;
zeus::CQuaternion x32c_invHudLag;
2017-04-02 03:03:37 +00:00
std::unique_ptr<CActorLights> x33c_lights;
rstl::reserved_vector<SCachedHudLight, 3> x340_hudLights;
CSfxHandle x3a4_damageSfx;
2017-06-01 05:34:24 +00:00
CCameraFilterPass<CColoredQuadFilter> x3a8_camFilter;
2017-04-08 20:40:36 +00:00
CGuiLight* x3d4_damageLight = nullptr;
2017-04-02 03:03:37 +00:00
std::vector<zeus::CTransform> x3d8_lightTransforms;
2017-04-13 19:28:31 +00:00
float x3e8_damageTIme = 0.f;
float x3ec_damageLightPulser = 0.f;
float x3f0_damageFilterAmtInit = 1.f;
float x3f4_damageFilterAmt = 0.f;
float x3f8_damageFilterAmtGain = 0.f;
float x3fc_hudDamagePracticalsInit = 0.f;
float x400_hudDamagePracticals = 0.f;
float x404_hudDamagePracticalsGain = 0.f;
zeus::CVector3f x408_damagerToPlayerNorm;
float x414_decoShakeTranslateAmt = 0.f;
float x418_decoShakeTranslateAmtVel = 0.f;
zeus::CVector3f x41c_decoShakeTranslate;
zeus::CMatrix3f x428_decoShakeRotate;
zeus::CQuaternion x44c_hudLagShakeRot;
float x45c_decoShakeAmtInit = 0.f;
float x460_decoShakeAmt = 0.f;
float x464_decoShakeAmtGain = 0.f;
2017-04-02 03:03:37 +00:00
rstl::reserved_vector<zeus::CTransform, 3> x46c_;
2017-04-03 01:39:23 +00:00
zeus::CVector2f x500_viewportScale = {1.f, 1.f};
2017-04-09 06:14:22 +00:00
CSfxHandle x508_staticSfxHi;
CSfxHandle x50c_staticSfxLo;
float x510_staticInterp = 0.f;
float x514_staticCycleTimerHi = 0.f;
float x518_staticCycleTimerLo = 0.f;
2017-06-01 05:34:24 +00:00
CCameraFilterPass<CRandomStaticFilter> x51c_camFilter2;
2017-04-03 01:39:23 +00:00
CHUDMemoParms x548_hudMemoParms;
TLockedToken<CStringTable> x550_hudMemoString;
u32 x554_hudMemoIdx = 0;
float x558_messageTextAlpha = 0.f;
float x55c_lastSfxChars = 0.f;
float x560_messageTextScale = 0.f;
2017-04-08 20:40:36 +00:00
CSfxHandle x564_freeLookSfx;
2017-04-03 01:39:23 +00:00
zeus::CVector3f x568_fpCamDir;
2017-04-08 20:40:36 +00:00
float x574_lookDeltaDot = 1.f;
float x578_freeLookSfxCycleTimer = 0.f;
2017-04-03 01:39:23 +00:00
float x57c_energyLowTimer = 0.f;
float x580_energyLowPulse = 0.f;
float x584_abuttonPulse = 0.f;
2017-04-02 03:03:37 +00:00
CGuiWidget* x588_base_basewidget_pivot;
CGuiWidget* x58c_helmet_BaseWidget_Pivot;
CGuiModel* x590_base_Model_AutoMapper;
CGuiTextPane* x594_base_textpane_counter;
CGuiWidget* x598_base_basewidget_message;
CGuiTextPane* x59c_base_textpane_message;
CGuiModel* x5a0_base_model_abutton;
rstl::reserved_vector<SVideoBand, 4> x5a4_videoBands;
rstl::reserved_vector<CGuiLight*, 4> x5d8_guiLights;
2017-04-03 01:39:23 +00:00
float x5ec_camFovTweaks[16];
float x62c_camYTweaks[64];
float x72c_camZTweaks[32];
2017-04-02 03:03:37 +00:00
rstl::reserved_vector<SProfileInfo, 15> x7ac_;
2017-06-01 05:34:24 +00:00
CColoredQuadFilter m_energyDrainFilter;
CCookieCutterDepthRandomStaticFilter m_cookieCutterStatic = { EFilterType::NoColor };
2017-03-24 05:30:16 +00:00
static CSamusHud* g_SamusHud;
2017-04-02 03:03:37 +00:00
static rstl::prereserved_vector<bool, 4> BuildPlayerHasVisors(const CStateManager& mgr);
static rstl::prereserved_vector<bool, 4> BuildPlayerHasBeams(const CStateManager& mgr);
void InitializeFrameGluePermanent(const CStateManager& mgr);
void InitializeFrameGlueMutable(const CStateManager& mgr);
2017-04-03 01:39:23 +00:00
void UninitializeFrameGlueMutable();
2017-04-08 20:40:36 +00:00
void InitializeDamageLight();
2017-04-02 03:03:37 +00:00
void UpdateEnergy(float dt, const CStateManager& mgr, bool init);
2017-04-03 01:39:23 +00:00
void UpdateFreeLook(float dt, const CStateManager& mgr);
2017-04-02 03:03:37 +00:00
void UpdateMissile(float dt, const CStateManager& mgr, bool init);
2017-04-03 01:39:23 +00:00
void UpdateVideoBands(float dt, const CStateManager& mgr);
2017-04-02 03:03:37 +00:00
void UpdateBallMode(const CStateManager& mgr, bool init);
2017-04-03 01:39:23 +00:00
void UpdateThreatAssessment(float dt, const CStateManager& mgr);
void UpdateVisorAndBeamMenus(float dt, const CStateManager& mgr);
void UpdateCameraDebugSettings();
void UpdateEnergyLow(float dt, const CStateManager& mgr);
2017-04-09 06:14:22 +00:00
void ApplyClassicLag(const zeus::CUnitVector3f& lookDir, zeus::CQuaternion& rot,
const CStateManager& mgr, float dt, bool invert);
2017-04-03 01:39:23 +00:00
void UpdateHudLag(float dt, const CStateManager& mgr);
2017-04-13 19:28:31 +00:00
bool IsCachedLightInAreaLights(const SCachedHudLight& light, const CActorLights& areaLights) const;
bool IsAreaLightInCachedLights(const CLight& light) const;
int FindEmptyHudLightSlot(const CLight& light) const;
zeus::CColor GetVisorHudLightColor(const zeus::CColor& color, const CStateManager& mgr) const;
2017-04-03 01:39:23 +00:00
void UpdateHudDynamicLights(float dt, const CStateManager& mgr);
void UpdateHudDamage(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis);
2017-04-09 06:14:22 +00:00
void UpdateStaticSfx(CSfxHandle& handle, float& cycleTimer, u16 sfxId, float dt,
float oldStaticInterp, float staticThreshold);
2017-04-03 01:39:23 +00:00
void UpdateStaticInterference(float dt, const CStateManager& mgr);
2017-04-13 19:28:31 +00:00
int GetRelativeDirection(const zeus::CVector3f& position, const CStateManager& mgr);
2017-04-03 01:39:23 +00:00
void ShowDamage(const zeus::CVector3f& position, float dam, float prevDam, const CStateManager& mgr);
void EnterFirstPerson(const CStateManager& mgr);
void LeaveFirstPerson(const CStateManager& mgr);
2017-05-21 16:01:04 +00:00
void DrawAttachedEnemyEffect(const CStateManager& mgr) const;
2017-04-02 03:03:37 +00:00
static EHudState GetDesiredHudState(const CStateManager& mgr);
2017-02-12 03:17:18 +00:00
public:
CSamusHud(CStateManager& stateMgr);
2017-04-08 20:40:36 +00:00
~CSamusHud();
2017-04-03 01:39:23 +00:00
void Update(float dt, const CStateManager& mgr,
2017-05-18 19:27:21 +00:00
CInGameGuiManager::EHelmetVisMode helmetVis,
2017-04-03 01:39:23 +00:00
bool hudVis, bool targetingManager);
2017-05-21 16:01:04 +00:00
void Draw(const CStateManager& mgr, float alpha,
CInGameGuiManager::EHelmetVisMode helmetVis,
bool hudVis, bool targetingManager) const;
void DrawHelmet(const CStateManager& mgr, float camYOff) const;
2017-04-15 05:32:25 +00:00
void ProcessControllerInput(const CFinalInput& input);
2017-04-02 03:03:37 +00:00
void UpdateStateTransition(float time, const CStateManager& mgr);
2017-02-12 03:17:18 +00:00
bool CheckLoadComplete(CStateManager& stateMgr);
2017-02-18 02:19:50 +00:00
void OnNewInGameGuiState(EInGameGuiState state, CStateManager& stateMgr);
2017-04-02 03:03:37 +00:00
void RefreshHudOptions();
2017-02-12 03:17:18 +00:00
void Touch();
2017-05-18 19:27:21 +00:00
CTargetingManager& GetTargetingManager() { return x8_targetingMgr; }
const zeus::CVector2f& GetViewportScale() const { return x500_viewportScale; }
2017-04-02 03:03:37 +00:00
static zeus::CTransform BuildFinalCameraTransform(const zeus::CQuaternion& rot,
const zeus::CVector3f& pos,
const zeus::CVector3f& camPos);
2017-11-13 06:19:18 +00:00
static void DisplayHudMemo(std::u16string_view text, const CHUDMemoParms& info)
2017-04-03 01:39:23 +00:00
{
if (g_SamusHud)
g_SamusHud->InternalDisplayHudMemo(text, info);
}
2017-11-13 06:19:18 +00:00
void InternalDisplayHudMemo(std::u16string_view text, const CHUDMemoParms& info)
2017-04-03 01:39:23 +00:00
{
SetMessage(text, info);
}
2017-11-13 06:19:18 +00:00
void SetMessage(std::u16string_view text, const CHUDMemoParms& info);
2017-08-13 05:26:14 +00:00
static void DeferHintMemo(CAssetId strg, u32 strgIdx, const CHUDMemoParms& info)
2017-03-24 05:30:16 +00:00
{
if (g_SamusHud)
2017-04-13 19:28:31 +00:00
g_SamusHud->InternalDeferHintMemo(strg, strgIdx, info);
2017-03-24 05:30:16 +00:00
}
2017-08-13 05:26:14 +00:00
void InternalDeferHintMemo(CAssetId strg, u32 strgIdx, const CHUDMemoParms& info);
2017-05-21 16:01:04 +00:00
CGuiFrame* GetBaseHudFrame() const { return x274_loadedFrmeBaseHud; }
2017-02-12 03:17:18 +00:00
};
}
}
#endif // __URDE_CSAMUSHUD_HPP__