2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CGAMEOPTIONS_HPP__
|
|
|
|
#define __URDE_CGAMEOPTIONS_HPP__
|
2015-08-17 20:33:58 +00:00
|
|
|
|
2015-08-31 03:44:42 +00:00
|
|
|
#include "RetroTypes.hpp"
|
2017-01-07 01:58:05 +00:00
|
|
|
#include "Audio/CAudioSys.hpp"
|
2017-04-02 03:03:37 +00:00
|
|
|
#include "CSaveWorld.hpp"
|
2015-08-31 03:44:42 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
2018-02-04 06:46:47 +00:00
|
|
|
struct CFinalInput;
|
2017-03-24 05:30:16 +00:00
|
|
|
class CStateManager;
|
2017-01-10 07:15:49 +00:00
|
|
|
|
|
|
|
/** Options presented in UI */
|
|
|
|
enum class EGameOption
|
|
|
|
{
|
|
|
|
VisorOpacity,
|
|
|
|
HelmetOpacity,
|
|
|
|
HUDLag,
|
|
|
|
HintSystem,
|
|
|
|
ScreenBrightness,
|
|
|
|
ScreenOffsetX,
|
|
|
|
ScreenOffsetY,
|
|
|
|
ScreenStretch,
|
|
|
|
SFXVolume,
|
|
|
|
MusicVolume,
|
|
|
|
SoundMode,
|
|
|
|
ReverseYAxis,
|
|
|
|
Rumble,
|
|
|
|
SwapBeamControls,
|
|
|
|
RestoreDefaults
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Option UI type */
|
|
|
|
enum class EOptionType
|
|
|
|
{
|
|
|
|
Float,
|
2017-01-13 00:16:26 +00:00
|
|
|
DoubleEnum,
|
|
|
|
TripleEnum,
|
2017-01-10 07:15:49 +00:00
|
|
|
RestoreDefaults
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Option UI presentation information */
|
|
|
|
struct SGameOption
|
|
|
|
{
|
|
|
|
EGameOption option;
|
|
|
|
u32 stringId;
|
|
|
|
float minVal, maxVal, increment;
|
|
|
|
EOptionType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Static registry of Option UI presentation information */
|
|
|
|
extern const std::pair<int, const SGameOption*> GameOptionsRegistry[];
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2016-09-25 01:58:20 +00:00
|
|
|
/** Options tracked persistently between game sessions */
|
|
|
|
class CPersistentOptions
|
|
|
|
{
|
2016-12-20 21:51:50 +00:00
|
|
|
friend class CGameState;
|
2018-04-05 06:58:11 +00:00
|
|
|
u8 x0_nesState[98] = {};
|
2016-09-25 01:58:20 +00:00
|
|
|
bool x68_[64] = {};
|
2017-08-13 05:26:14 +00:00
|
|
|
std::vector<std::pair<CAssetId, TEditorId>> xac_cinematicStates; /* (MLVL, Cinematic) */
|
2017-04-16 05:52:43 +00:00
|
|
|
u32 xbc_autoMapperKeyState = 0;
|
2017-07-17 03:04:14 +00:00
|
|
|
u32 xc0_frozenFpsCount = 0;
|
|
|
|
u32 xc4_frozenBallCount = 0;
|
2017-09-12 15:27:48 +00:00
|
|
|
u32 xc8_powerBombAmmoCount = 0;
|
2017-07-31 05:19:05 +00:00
|
|
|
u32 xcc_logScanPercent = 0;
|
2016-09-25 01:58:20 +00:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2017-01-01 06:46:52 +00:00
|
|
|
bool xd0_24_fusionLinked : 1;
|
|
|
|
bool xd0_25_normalModeBeat : 1;
|
2016-12-16 23:05:29 +00:00
|
|
|
bool xd0_26_hardModeBeat : 1;
|
2017-01-01 06:46:52 +00:00
|
|
|
bool xd0_27_fusionBeat : 1;
|
|
|
|
bool xd0_28_fusionSuitActive : 1;
|
2016-12-16 23:05:29 +00:00
|
|
|
bool xd0_29_allItemsCollected : 1;
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
u16 _dummy = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
CPersistentOptions() = default;
|
|
|
|
CPersistentOptions(CBitStreamReader& stream);
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
bool GetCinematicState(CAssetId mlvlId, TEditorId cineId) const;
|
|
|
|
void SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state);
|
2017-04-16 05:52:43 +00:00
|
|
|
u32 GetAutoMapperKeyState() const { return xbc_autoMapperKeyState; }
|
|
|
|
void SetAutoMapperKeyState(u32 s) { xbc_autoMapperKeyState = s; }
|
2017-01-01 06:46:52 +00:00
|
|
|
bool GetPlayerLinkedFusion() const { return xd0_24_fusionLinked; }
|
|
|
|
void SetPlayerLinkedFusion(bool v) { xd0_24_fusionLinked = v; }
|
|
|
|
bool GetPlayerBeatNormalMode() const { return xd0_25_normalModeBeat; }
|
|
|
|
void SetPlayerBeatNormalMode(bool v) { xd0_25_normalModeBeat = v; }
|
2016-12-20 21:51:50 +00:00
|
|
|
bool GetPlayerBeatHardMode() const { return xd0_26_hardModeBeat; }
|
|
|
|
void SetPlayerBeatHardMode(bool v) { xd0_26_hardModeBeat = v; }
|
2017-01-01 06:46:52 +00:00
|
|
|
bool GetPlayerBeatFusion() const { return xd0_27_fusionBeat; }
|
|
|
|
void SetPlayerBeatFusion(bool v) { xd0_27_fusionBeat = v; }
|
|
|
|
bool GetPlayerFusionSuitActive() const { return xd0_28_fusionSuitActive; }
|
|
|
|
void SetPlayerFusionSuitActive(bool v) { xd0_28_fusionSuitActive = v; }
|
2016-12-20 21:51:50 +00:00
|
|
|
bool GetAllItemsCollected() const { return xd0_29_allItemsCollected; }
|
|
|
|
void SetAllItemsCollected(bool v) { xd0_29_allItemsCollected = v; }
|
2017-07-31 05:19:05 +00:00
|
|
|
u32 GetLogScanPercent() const { return xcc_logScanPercent; }
|
|
|
|
void SetLogScanPercent(u32 v) { xcc_logScanPercent = v; }
|
2017-07-17 03:04:14 +00:00
|
|
|
void IncrementFrozenFpsCount() { xc0_frozenFpsCount = std::min(int(xc0_frozenFpsCount + 1), 3); }
|
|
|
|
bool GetShowFrozenFpsMessage() const { return xc0_frozenFpsCount != 3; }
|
|
|
|
void IncrementFrozenBallCount() { xc4_frozenBallCount = std::min(int(xc4_frozenBallCount + 1), 3); }
|
|
|
|
bool GetShowFrozenBallMessage() const { return xc4_frozenBallCount != 3; }
|
2017-09-12 15:27:48 +00:00
|
|
|
bool GetShowPowerBombAmmoMessage() const { return xc8_powerBombAmmoCount != 1; }
|
|
|
|
void IncrementPowerBombAmmoCount()
|
|
|
|
{
|
|
|
|
xc8_powerBombAmmoCount = std::min<u32>(1, xc8_powerBombAmmoCount + 1);
|
|
|
|
}
|
|
|
|
|
2016-12-23 06:41:39 +00:00
|
|
|
void PutTo(CBitStreamWriter& w) const;
|
2016-12-31 00:51:51 +00:00
|
|
|
|
2018-04-05 06:58:11 +00:00
|
|
|
u8* GetNESState() { return x0_nesState; }
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Options tracked per game session */
|
2015-08-17 20:33:58 +00:00
|
|
|
class CGameOptions
|
|
|
|
{
|
2017-02-08 06:48:43 +00:00
|
|
|
u8 x0_[64] = {};
|
2017-01-10 07:15:49 +00:00
|
|
|
CAudioSys::ESurroundModes x44_soundMode = CAudioSys::ESurroundModes::Stereo;
|
|
|
|
u32 x48_screenBrightness = 4;
|
2017-01-07 01:58:05 +00:00
|
|
|
s32 x4c_screenXOffset = 0;
|
|
|
|
s32 x50_screenYOffset = 0;
|
|
|
|
s32 x54_screenStretch = 0;
|
|
|
|
u32 x58_sfxVol = 0x7f;
|
2016-12-14 22:56:59 +00:00
|
|
|
u32 x5c_musicVol = 0x7f;
|
2017-01-13 00:16:26 +00:00
|
|
|
u32 x60_hudAlpha = 0xff;
|
|
|
|
u32 x64_helmetAlpha = 0xff;
|
2016-09-25 01:58:20 +00:00
|
|
|
|
2018-01-21 22:05:25 +00:00
|
|
|
s32 m_gamma = 0;
|
|
|
|
|
2016-09-25 01:58:20 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2017-01-07 01:58:05 +00:00
|
|
|
bool x68_24_hudLag : 1;
|
|
|
|
bool x68_25_invertY : 1;
|
|
|
|
bool x68_26_rumble : 1;
|
|
|
|
bool x68_27_swapBeamsControls : 1;
|
|
|
|
bool x68_28_hintSystem : 1;
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
u16 _dummy = 0;
|
|
|
|
};
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
std::vector<std::pair<CAssetId, CAssetId>> x6c_controlTxtrMap;
|
2016-09-25 01:58:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CGameOptions();
|
|
|
|
CGameOptions(CBitStreamReader& stream);
|
2017-01-07 01:58:05 +00:00
|
|
|
void ResetToDefaults();
|
2016-09-25 01:58:20 +00:00
|
|
|
void InitSoundMode();
|
2017-01-07 01:58:05 +00:00
|
|
|
void EnsureSettings();
|
2016-10-09 21:41:23 +00:00
|
|
|
void PutTo(CBitStreamWriter& writer) const;
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2017-01-10 07:15:49 +00:00
|
|
|
float TuneScreenBrightness();
|
|
|
|
void SetScreenBrightness(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetScreenBrightness() const { return x48_screenBrightness; }
|
2018-01-21 22:05:25 +00:00
|
|
|
void ApplyGamma();
|
|
|
|
void SetGamma(s32, bool);
|
|
|
|
s32 GetGamma() const { return m_gamma; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetScreenPositionX(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetScreenPositionX() const { return x4c_screenXOffset; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetScreenPositionY(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetScreenPositionY() const { return x50_screenYOffset; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetScreenStretch(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetScreenStretch() const { return x54_screenStretch; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetSfxVolume(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetSfxVolume() const { return x58_sfxVol; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetMusicVolume(s32, bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
s32 GetMusicVolume() const { return x5c_musicVol; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetHUDAlpha(u32);
|
2017-01-13 00:16:26 +00:00
|
|
|
u32 GetHUDAlpha() const { return x60_hudAlpha; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetHelmetAlpha(u32);
|
2017-01-13 00:16:26 +00:00
|
|
|
u32 GetHelmetAlpha() const { return x64_helmetAlpha; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetHUDLag(bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
bool GetHUDLag() const { return x68_24_hudLag; }
|
2017-01-10 07:15:49 +00:00
|
|
|
void SetSurroundMode(int mode, bool apply);
|
|
|
|
CAudioSys::ESurroundModes GetSurroundMode() const;
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetInvertYAxis(bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
bool GetInvertYAxis() const { return x68_25_invertY; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetIsRumbleEnabled(bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
bool GetIsRumbleEnabled() const { return x68_26_rumble; }
|
|
|
|
void SetSwapBeamControls(bool);
|
|
|
|
bool GetSwapBeamControls() const { return x68_27_swapBeamsControls; }
|
2017-01-07 01:58:05 +00:00
|
|
|
void SetIsHintSystemEnabled(bool);
|
2017-01-13 00:16:26 +00:00
|
|
|
bool GetIsHintSystemEnabled() const { return x68_28_hintSystem; }
|
2017-05-31 21:26:50 +00:00
|
|
|
void SetControls(int controls);
|
|
|
|
void ResetControllerAssets(int controls);
|
2017-08-13 05:26:14 +00:00
|
|
|
const std::vector<std::pair<CAssetId, CAssetId>>& GetControlTXTRMap() const { return x6c_controlTxtrMap; }
|
2017-01-10 07:15:49 +00:00
|
|
|
|
|
|
|
static void TryRestoreDefaults(const CFinalInput& input, int category,
|
2017-02-10 09:00:57 +00:00
|
|
|
int option, bool frontend, bool forceRestore);
|
2017-01-10 07:15:49 +00:00
|
|
|
static void SetOption(EGameOption option, int value);
|
2017-01-13 00:16:26 +00:00
|
|
|
static int GetOption(EGameOption option);
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CHintOptions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class EHintState
|
|
|
|
{
|
|
|
|
Zero,
|
2017-03-24 05:30:16 +00:00
|
|
|
Waiting,
|
|
|
|
Displaying,
|
2017-02-18 02:19:50 +00:00
|
|
|
Delayed
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
struct SHintState
|
|
|
|
{
|
|
|
|
EHintState x0_state = EHintState::Zero;
|
|
|
|
float x4_time = 0.f;
|
2017-03-24 05:30:16 +00:00
|
|
|
bool x8_dismissed = false;
|
2016-09-25 01:58:20 +00:00
|
|
|
|
|
|
|
SHintState() = default;
|
|
|
|
SHintState(EHintState state, float time, bool flag)
|
2017-03-24 05:30:16 +00:00
|
|
|
: x0_state(state), x4_time(time), x8_dismissed(flag) {}
|
2017-02-18 02:19:50 +00:00
|
|
|
|
|
|
|
bool CanContinue() const { return x4_time / 3.f <= 1.f; }
|
2016-09-25 01:58:20 +00:00
|
|
|
};
|
|
|
|
private:
|
|
|
|
std::vector<SHintState> x0_hintStates;
|
|
|
|
u32 x10_nextHintIdx = -1;
|
|
|
|
public:
|
|
|
|
CHintOptions() = default;
|
|
|
|
CHintOptions(CBitStreamReader& stream);
|
2016-10-09 21:41:23 +00:00
|
|
|
void PutTo(CBitStreamWriter& writer) const;
|
2016-12-22 02:48:22 +00:00
|
|
|
void SetNextHintTime();
|
2017-02-06 03:21:58 +00:00
|
|
|
void InitializeMemoryState();
|
2017-02-18 02:19:50 +00:00
|
|
|
const SHintState* GetCurrentDisplayedHint() const;
|
|
|
|
void DelayHint(const char* name);
|
|
|
|
void ActivateImmediateHintTimer(const char* name);
|
|
|
|
void ActivateContinueDelayHintTimer(const char* name);
|
2017-03-24 05:30:16 +00:00
|
|
|
void DismissDisplayedHint();
|
|
|
|
u32 GetNextHintIdx() const;
|
2017-04-15 05:32:25 +00:00
|
|
|
const std::vector<SHintState>& GetHintStates() const { return x0_hintStates; }
|
2017-03-24 05:30:16 +00:00
|
|
|
void Update(float dt, const CStateManager& stateMgr);
|
2015-08-17 20:33:58 +00:00
|
|
|
};
|
|
|
|
|
2015-08-17 22:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CGAMEOPTIONS_HPP__
|