metaforce/Runtime/AutoMapper/CAutoMapper.hpp

325 lines
12 KiB
C++
Raw Normal View History

2016-07-29 17:00:23 +00:00
#ifndef __URDE_CAUTOMAPPER_HPP__
#define __URDE_CAUTOMAPPER_HPP__
#include "RetroTypes.hpp"
#include "CInGameTweakManagerBase.hpp"
#include "zeus/CQuaternion.hpp"
#include "zeus/CTransform.hpp"
#include "zeus/CVector3f.hpp"
2017-02-12 03:17:18 +00:00
#include "MP1/CInGameGuiManager.hpp"
2016-07-29 17:00:23 +00:00
namespace urde
{
class CFinalInput;
class IWorld;
class CMapWorldInfo;
class CStateManager;
2017-03-20 05:09:53 +00:00
class CMapUniverse;
2016-07-29 17:00:23 +00:00
class CAutoMapper
{
public:
2017-02-12 03:17:18 +00:00
using EInGameGuiState = MP1::EInGameGuiState;
2017-03-20 05:09:53 +00:00
enum class ELoadPhase
{
LoadResources,
LoadUniverse,
Done
};
2016-07-29 17:00:23 +00:00
enum class EAutoMapperState
{
2017-04-15 05:32:25 +00:00
MiniMap,
MapScreen,
MapScreenUniverse
2016-07-29 17:00:23 +00:00
};
struct SAutoMapperRenderState
{
2017-04-15 05:32:25 +00:00
enum class Ease
{
None,
Linear,
Out,
In,
InOut
};
2017-03-20 05:09:53 +00:00
zeus::CVector2i x0_viewportSize;
zeus::CQuaternion x8_camOrientation;
2017-04-15 05:32:25 +00:00
float x18_camDist;
float x1c_camAngle;
2017-03-20 05:09:53 +00:00
zeus::CVector3f x20_areaPoint;
float x2c_drawDepth1;
float x30_drawDepth2;
float x34_alphaSurfaceVisited;
float x38_alphaOutlineVisited;
float x3c_alphaSurfaceUnvisited;
float x40_alphaOutlineUnvisited;
2017-04-15 05:32:25 +00:00
Ease x44_viewportEase;
Ease x48_camEase;
Ease x4c_pointEase;
Ease x50_depth1Ease;
Ease x54_depth2Ease;
Ease x58_alphaEase;
2017-03-20 05:09:53 +00:00
SAutoMapperRenderState() = default;
SAutoMapperRenderState(const zeus::CVector2i& v1, const zeus::CQuaternion& rot,
float f1, float f2, const zeus::CVector3f& v2, float f3, float f4,
float f5, float f6, float f7, float f8)
2017-04-15 05:32:25 +00:00
: x0_viewportSize(v1), x8_camOrientation(rot), x18_camDist(f1), x1c_camAngle(f2),
2017-03-20 05:09:53 +00:00
x20_areaPoint(v2), x2c_drawDepth1(f3), x30_drawDepth2(f4),
x34_alphaSurfaceVisited(f5), x38_alphaOutlineVisited(f6),
x3c_alphaSurfaceUnvisited(f7), x40_alphaOutlineUnvisited(f8),
2017-04-15 05:32:25 +00:00
x44_viewportEase(Ease::None), x48_camEase(Ease::None), x4c_pointEase(Ease::None),
x50_depth1Ease(Ease::None), x54_depth2Ease(Ease::None), x58_alphaEase(Ease::None) {}
static void InterpolateWithClamp(const SAutoMapperRenderState& a,
SAutoMapperRenderState& out,
const SAutoMapperRenderState& b,
float t);
void ResetInterpolation()
{
x44_viewportEase = Ease::None;
x48_camEase = Ease::None;
x4c_pointEase = Ease::None;
x50_depth1Ease = Ease::None;
x54_depth2Ease = Ease::None;
x58_alphaEase = Ease::None;
}
};
struct SAutoMapperHintStep
{
enum class Type
{
PanToArea,
PanToWorld,
SwitchToUniverse,
SwitchToWorld,
ShowBeacon,
2017-04-16 05:52:43 +00:00
ZoomIn,
ZoomOut
2017-04-15 05:32:25 +00:00
};
struct PanToArea {};
struct PanToWorld {};
struct SwitchToUniverse {};
struct SwitchToWorld {};
struct ShowBeacon {};
2017-04-16 05:52:43 +00:00
struct ZoomIn {};
struct ZoomOut {};
2017-04-15 05:32:25 +00:00
Type x0_type;
union
{
ResId x4_worldId;
TAreaId x4_areaId;
float x4_float;
};
2017-04-16 05:52:43 +00:00
bool x8_processing = false;
2017-04-15 05:32:25 +00:00
SAutoMapperHintStep(PanToArea, TAreaId areaId) : x0_type(Type::PanToArea), x4_areaId(areaId) {}
SAutoMapperHintStep(PanToWorld, ResId worldId) : x0_type(Type::PanToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(SwitchToUniverse) : x0_type(Type::SwitchToUniverse), x4_worldId(0) {}
SAutoMapperHintStep(SwitchToWorld, ResId worldId) : x0_type(Type::SwitchToWorld), x4_worldId(worldId) {}
SAutoMapperHintStep(ShowBeacon, float val) : x0_type(Type::ShowBeacon), x4_float(val) {}
2017-04-16 05:52:43 +00:00
SAutoMapperHintStep(ZoomIn) : x0_type(Type::ZoomIn), x4_worldId(0) {}
SAutoMapperHintStep(ZoomOut) : x0_type(Type::ZoomOut), x4_worldId(0) {}
2017-04-15 05:32:25 +00:00
};
struct SAutoMapperHintLocation
{
u32 x0_showBeacon;
float x4_beaconAlpha;
2017-04-15 05:32:25 +00:00
ResId x8_worldId;
TAreaId xc_areaId;
2016-07-29 17:00:23 +00:00
};
class CAudioMenu
{
public:
enum class EMenu
{
};
struct SMenuOption
{
SMenuOption(const std::string&, s32, s32, s32);
void BuildDrawableString();
};
private:
public:
CAudioMenu()=default;
void SetIsHighlighted(bool);
void AddOption(const SMenuOption&);
void ProcessControllerInput(const CFinalInput&);
u32 GetSelectionIndex() const;
const SMenuOption& GetOption(s32) const;
SMenuOption& Option(s32);
void SetSelectionIndex(s32);
void Draw(EMenu) const;
};
private:
2017-04-15 05:32:25 +00:00
enum class EZoomState
{
None,
In,
Out
};
2017-03-20 05:09:53 +00:00
ELoadPhase x4_loadPhase = ELoadPhase::LoadResources;
TLockedToken<CMapUniverse> x8_mapu;
std::vector<std::unique_ptr<IWorld>> x14_dummyWorlds;
2017-04-15 05:32:25 +00:00
const CWorld* x24_world;
2017-04-16 05:52:43 +00:00
TLockedToken<CGuiFrame> x28_frmeMapScreen; // Used to be ptr
bool m_frmeInitialized = false;
2017-03-20 05:09:53 +00:00
TLockedToken<CModel> x30_miniMapSamus;
TLockedToken<CTexture> x3c_hintBeacon;
std::vector<CTexturedQuadFilter> m_hintBeaconFilters;
2017-03-20 05:09:53 +00:00
rstl::reserved_vector<TLockedToken<CTexture>, 5> x48_mapIcons;
2017-04-16 05:52:43 +00:00
ResId x74_areaHintDescId = -1;
TLockedToken<CStringTable> x78_areaHintDesc;
2017-03-20 05:09:53 +00:00
u32 x84_ = 0;
2017-04-16 20:56:34 +00:00
ResId x88_mapAreaStringId = -1;
TLockedToken<CStringTable> x8c_mapAreaString; // Used to be optional
2017-03-20 05:09:53 +00:00
u32 x9c_worldIdx = 0;
TAreaId xa0_curAreaId;
TAreaId xa4_otherAreaId;
2017-04-16 05:52:43 +00:00
SAutoMapperRenderState xa8_renderStates[3]; // xa8, x104, x160; current, next, prev
2017-04-15 05:32:25 +00:00
EAutoMapperState x1bc_state = EAutoMapperState::MiniMap;
EAutoMapperState x1c0_nextState = EAutoMapperState::MiniMap;
2017-04-16 05:52:43 +00:00
float x1c4_interpDur = 0.f;
float x1c8_interpTime = 0.f;
2017-04-15 05:32:25 +00:00
CSfxHandle x1cc_panningSfx;
CSfxHandle x1d0_rotatingSfx;
CSfxHandle x1d4_zoomingSfx;
2017-04-16 20:56:34 +00:00
float x1d8_flashTimer = 0.f;
2017-04-22 21:46:18 +00:00
float x1dc_playerFlashPulse = 0.f;
2017-04-15 05:32:25 +00:00
std::list<SAutoMapperHintStep> x1e0_hintSteps;
std::list<SAutoMapperHintLocation> x1f8_hintLocations;
2017-03-20 05:09:53 +00:00
rstl::reserved_vector<TLockedToken<CTexture>, 9> x210_lstick;
rstl::reserved_vector<TLockedToken<CTexture>, 9> x25c_cstick;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2a8_ltrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2bc_rtrigger;
rstl::reserved_vector<TLockedToken<CTexture>, 2> x2d0_abutton;
2017-04-15 05:32:25 +00:00
u32 x2e4_lStickPos = 0;
u32 x2e8_rStickPos = 0;
2017-04-16 05:52:43 +00:00
u32 x2ec_lTriggerPos = 0;
u32 x2f0_rTriggerPos = 0;
u32 x2f4_aButtonPos = 0;
CGuiTextPane* x2f8_textpane_areaname = nullptr;
CGuiTextPane* x2fc_textpane_hint = nullptr;
CGuiTextPane* x300_textpane_instructions = nullptr;
CGuiTextPane* x304_textpane_instructions1 = nullptr;
CGuiTextPane* x308_textpane_instructions2 = nullptr;
CGuiWidget* x30c_basewidget_leftPane = nullptr;
CGuiWidget* x310_basewidget_yButtonPane = nullptr;
CGuiWidget* x314_basewidget_bottomPane = nullptr;
float x318_leftPanePos = 0.f;
float x31c_yButtonPanePos = 0.f;
float x320_bottomPanePos = 0.f;
2017-04-15 05:32:25 +00:00
EZoomState x324_zoomState = EZoomState::None;
2017-03-20 05:09:53 +00:00
u32 x328_ = 0;
2017-04-15 05:32:25 +00:00
bool x32c_loadingDummyWorld = false;
template <class T>
static void SetResLockState(T& list, bool lock)
{
for (auto& res : list)
if (lock)
res.Lock();
else
res.Unlock();
}
bool NotHintNavigating() const;
bool CanLeaveMapScreenInternal(const CStateManager& mgr) const;
2017-04-16 05:52:43 +00:00
void LeaveMapScreen(const CStateManager& mgr);
void SetupMiniMapWorld(const CStateManager& mgr);
2017-04-15 05:32:25 +00:00
bool HasCurrentMapUniverseWorld() const;
bool CheckDummyWorldLoad(const CStateManager& mgr);
void UpdateHintNavigation(float dt, const CStateManager& mgr);
static zeus::CVector2i GetMiniMapViewportSize();
static zeus::CVector2i GetMapScreenViewportSize();
static float GetMapAreaMiniMapDrawDepth() { return 2.f; }
float GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId) const;
static float GetMapAreaMiniMapDrawAlphaSurfaceVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineVisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaSurfaceUnvisited(const CStateManager&);
static float GetMapAreaMiniMapDrawAlphaOutlineUnvisited(const CStateManager&);
2017-04-16 05:52:43 +00:00
float GetDesiredMiniMapCameraDistance(const CStateManager&) const;
2017-04-15 05:32:25 +00:00
static float GetBaseMapScreenCameraMoveSpeed();
float GetClampedMapScreenCameraDistance(float);
float GetFinalMapScreenCameraMoveSpeed() const;
void ProcessMapRotateInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapZoomInput(const CFinalInput& input, const CStateManager& mgr);
void ProcessMapPanInput(const CFinalInput& input, const CStateManager& mgr);
void SetShouldPanningSoundBePlaying(bool);
void SetShouldZoomingSoundBePlaying(bool);
void SetShouldRotatingSoundBePlaying(bool);
void TransformRenderStatesWorldToUniverse();
void TransformRenderStatesUniverseToWorld();
void TransformRenderStateWorldToUniverse(SAutoMapperRenderState&);
void SetupHintNavigation();
2017-04-16 20:56:34 +00:00
ResId GetAreaHintDescriptionString(ResId mreaId);
2017-03-20 05:09:53 +00:00
2016-07-29 17:00:23 +00:00
public:
2017-03-20 05:09:53 +00:00
CAutoMapper(CStateManager& stateMgr);
2016-07-29 17:00:23 +00:00
bool CheckLoadComplete();
2017-04-15 05:32:25 +00:00
bool CanLeaveMapScreen(const CStateManager&) const;
2016-07-29 17:00:23 +00:00
float GetMapRotationX() const;
float GetMapRotationZ() const;
u32 GetFocusAreaIndex() const;
ResId GetCurrWorldAssetId() const;
2017-03-20 05:09:53 +00:00
void SetCurWorldAssetId(ResId mlvlId);
2016-07-29 17:00:23 +00:00
void MuteAllLoopedSounds();
void UnmuteAllLoopedSounds();
void ProcessControllerInput(const CFinalInput&, CStateManager&);
bool IsInPlayerControlState() const;
2017-04-16 05:52:43 +00:00
void Update(float dt, const CStateManager& mgr);
2016-07-29 17:00:23 +00:00
void Draw(const CStateManager&, const zeus::CTransform&, float) const;
bool IsInOrTransitioningToMapScreenState() const;
float GetTimeIntoInterpolation() const;
bool IsFullyInMapScreenState() const;
void BeginMapperStateTransition(EAutoMapperState, const CStateManager&);
2017-04-16 05:52:43 +00:00
void CompleteMapperStateTransition(const CStateManager&);
2016-07-29 17:00:23 +00:00
void ResetInterpolationTimer(float);
2017-03-20 05:09:53 +00:00
SAutoMapperRenderState BuildMiniMapWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
2017-04-15 05:32:25 +00:00
SAutoMapperRenderState BuildMapScreenWorldRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId, bool) const;
2017-03-20 05:09:53 +00:00
SAutoMapperRenderState BuildMapScreenUniverseRenderState(const CStateManager&, const zeus::CQuaternion&, TAreaId) const;
2016-07-29 17:00:23 +00:00
void LeaveMapScreenState();
2017-04-15 05:32:25 +00:00
void ProcessMapScreenInput(const CFinalInput& input, const CStateManager& mgr);
2017-03-20 05:09:53 +00:00
zeus::CQuaternion GetMiniMapCameraOrientation(const CStateManager&) const;
zeus::CVector3f GetAreaPointOfInterest(const CStateManager&, TAreaId) const;
2017-04-15 05:32:25 +00:00
TAreaId FindClosestVisibleArea(const zeus::CVector3f&, const zeus::CUnitVector3f&, const CStateManager&,
const IWorld&, const CMapWorldInfo&) const;
2017-04-16 05:52:43 +00:00
std::pair<int, int>
2017-04-15 05:32:25 +00:00
FindClosestVisibleWorld(const zeus::CVector3f&, const zeus::CUnitVector3f&, const CStateManager&) const;
2017-03-20 05:09:53 +00:00
bool IsInMapperState(EAutoMapperState state) const
{
return state == x1bc_state && state == x1c0_nextState;
}
2017-04-15 05:32:25 +00:00
bool IsInMapperStateTransition() const
{
return x1c0_nextState != x1bc_state;
}
bool IsRenderStateInterpolating() const
{
2017-04-16 05:52:43 +00:00
return x1c8_interpTime < x1c4_interpDur;
2017-04-15 05:32:25 +00:00
}
2016-07-29 17:00:23 +00:00
void UpdateOptionsMenu(const CTweakValue::Audio&);
void UpdateAudioMusicMenu();
void UpdateAudioEvents();
void UpdateAudioEventMenu();
void GetCurrentAudioInfo() const;
void PresentAudioMenuInput(const CFinalInput&);
void SetFocusAudioMenu(CAudioMenu::EMenu);
bool IsStateTransitioning() const;
bool IsFullyInMiniMapState() const;
static bool IsDrawState(EAutoMapperState);
void OnNewInGameGuiState(EInGameGuiState, const CStateManager&);
void OnChangeAudioMusicSelection();
};
}
#endif // __URDE_CAUTOMAPPER_HPP__