2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/CGameOptions.hpp"
|
|
|
|
|
2020-04-03 06:14:28 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/CGameHintInfo.hpp"
|
|
|
|
#include "Runtime/CGameState.hpp"
|
|
|
|
#include "Runtime/CMemoryCardSys.hpp"
|
2021-06-05 05:27:52 +00:00
|
|
|
#include "Runtime/CWorldSaveGameInfo.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
|
|
|
#include "Runtime/Audio/CStreamAudioManager.hpp"
|
|
|
|
#include "Runtime/Graphics/CMoviePlayer.hpp"
|
|
|
|
#include "Runtime/Input/CFinalInput.hpp"
|
|
|
|
|
2022-02-21 02:28:07 +00:00
|
|
|
#include "ConsoleVariables/CVarManager.hpp"
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
constexpr std::array<SGameOption, 5> VisorOpts{{
|
2017-01-10 07:15:49 +00:00
|
|
|
{EGameOption::VisorOpacity, 21, 0.f, 255.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::HelmetOpacity, 22, 0.f, 255.f, 1.f, EOptionType::Float},
|
2017-01-13 00:16:26 +00:00
|
|
|
{EGameOption::HUDLag, 23, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::HintSystem, 24, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
2019-08-14 06:49:40 +00:00
|
|
|
{EGameOption::RestoreDefaults, 35, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
2017-01-10 07:15:49 +00:00
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
constexpr std::array<SGameOption, 5> DisplayOpts{{
|
2018-01-21 22:05:25 +00:00
|
|
|
//{EGameOption::ScreenBrightness, 25, 0.f, 8.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenBrightness, 25, -100.f, 100.f, 1.f, EOptionType::Float},
|
2017-01-10 07:15:49 +00:00
|
|
|
{EGameOption::ScreenOffsetX, 26, -30.f, 30.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenOffsetY, 27, -30.f, 30.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenStretch, 28, -10.f, 10.f, 1.f, EOptionType::Float},
|
2019-08-14 06:49:40 +00:00
|
|
|
{EGameOption::RestoreDefaults, 35, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
2017-01-10 07:15:49 +00:00
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
constexpr std::array<SGameOption, 4> SoundOpts{{
|
2017-01-10 07:15:49 +00:00
|
|
|
{EGameOption::SFXVolume, 29, 0.f, 127.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::MusicVolume, 30, 0.f, 127.f, 1.f, EOptionType::Float},
|
2017-01-13 00:16:26 +00:00
|
|
|
{EGameOption::SoundMode, 31, 0.f, 1.f, 1.f, EOptionType::TripleEnum},
|
2019-08-14 06:49:40 +00:00
|
|
|
{EGameOption::RestoreDefaults, 35, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
2017-01-10 07:15:49 +00:00
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
constexpr std::array<SGameOption, 4> ControllerOpts{{
|
2017-01-13 00:16:26 +00:00
|
|
|
{EGameOption::ReverseYAxis, 32, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::Rumble, 33, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::SwapBeamControls, 34, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
2019-08-14 06:49:40 +00:00
|
|
|
{EGameOption::RestoreDefaults, 35, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-16 06:57:04 +00:00
|
|
|
constexpr std::array<SGameOption, 5> VisorOptsNew{{
|
2020-04-16 17:00:08 +00:00
|
|
|
{EGameOption::VisorOpacity, 23, 0.f, 255.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::HelmetOpacity, 24, 0.f, 255.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::HUDLag, 25, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::HintSystem, 26, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::RestoreDefaults, 38, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
2020-04-16 06:57:04 +00:00
|
|
|
|
|
|
|
constexpr std::array<SGameOption, 5> DisplayOptsNew{{
|
|
|
|
//{EGameOption::ScreenBrightness, 25, 0.f, 8.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenBrightness, 28, -100.f, 100.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenOffsetX, 29, -30.f, 30.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenOffsetY, 30, -30.f, 30.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::ScreenStretch, 31, -10.f, 10.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::RestoreDefaults, 38, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
|
|
|
|
|
|
|
constexpr std::array<SGameOption, 4> SoundOptsNew{{
|
|
|
|
{EGameOption::SFXVolume, 32, 0.f, 127.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::MusicVolume, 33, 0.f, 127.f, 1.f, EOptionType::Float},
|
|
|
|
{EGameOption::SoundMode, 34, 0.f, 1.f, 1.f, EOptionType::TripleEnum},
|
|
|
|
{EGameOption::RestoreDefaults, 38, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
|
|
|
|
|
|
|
constexpr std::array<SGameOption, 4> ControllerOptsNew{{
|
|
|
|
{EGameOption::ReverseYAxis, 35, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::Rumble, 37, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::SwapBeamControls, 37, 0.f, 1.f, 1.f, EOptionType::DoubleEnum},
|
|
|
|
{EGameOption::RestoreDefaults, 38, 0.f, 1.f, 1.f, EOptionType::RestoreDefaults},
|
|
|
|
}};
|
|
|
|
|
2020-04-12 09:27:41 +00:00
|
|
|
constexpr std::array<std::pair<size_t, const SGameOption*>, 5> GameOptionsRegistry{{
|
2019-08-14 06:49:40 +00:00
|
|
|
{VisorOpts.size(), VisorOpts.data()},
|
|
|
|
{DisplayOpts.size(), DisplayOpts.data()},
|
|
|
|
{SoundOpts.size(), SoundOpts.data()},
|
|
|
|
{ControllerOpts.size(), ControllerOpts.data()},
|
|
|
|
{0, nullptr},
|
|
|
|
}};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-16 06:57:04 +00:00
|
|
|
constexpr std::array<std::pair<size_t, const SGameOption*>, 5> GameOptionsRegistryNew{{
|
|
|
|
{VisorOptsNew.size(), VisorOptsNew.data()},
|
|
|
|
{DisplayOptsNew.size(), DisplayOptsNew.data()},
|
|
|
|
{SoundOptsNew.size(), SoundOptsNew.data()},
|
|
|
|
{ControllerOptsNew.size(), ControllerOptsNew.data()},
|
|
|
|
{0, nullptr},
|
|
|
|
}};
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
CPersistentOptions::CPersistentOptions(CInputStream& stream) {
|
2020-04-12 09:37:50 +00:00
|
|
|
for (u8& entry : x0_nesState) {
|
2022-02-18 07:37:54 +00:00
|
|
|
entry = stream.ReadBits(8);
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-12 09:37:50 +00:00
|
|
|
for (bool& entry : x68_) {
|
2022-02-18 07:37:54 +00:00
|
|
|
entry = stream.ReadBits(8) != 0;
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
xc0_frozenFpsCount = stream.ReadBits(2);
|
|
|
|
xc4_frozenBallCount = stream.ReadBits(2);
|
|
|
|
xc8_powerBombAmmoCount = stream.ReadBits(1);
|
|
|
|
xcc_logScanPercent = stream.ReadBits(7);
|
|
|
|
xd0_24_fusionLinked = stream.ReadBits(1) != 0;
|
|
|
|
xd0_25_normalModeBeat = stream.ReadBits(1) != 0;
|
|
|
|
xd0_26_hardModeBeat = stream.ReadBits(1) != 0;
|
|
|
|
xd0_27_fusionBeat = stream.ReadBits(1) != 0;
|
2018-12-08 05:30:43 +00:00
|
|
|
xd0_28_fusionSuitActive = false;
|
2022-02-18 07:37:54 +00:00
|
|
|
xd0_29_allItemsCollected = stream.ReadBits(1) != 0;
|
|
|
|
xbc_autoMapperKeyState = stream.ReadBits(2);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-05-08 22:41:27 +00:00
|
|
|
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t cinematicCount = 0;
|
|
|
|
for (const auto& world : memWorlds) {
|
2021-06-05 05:27:52 +00:00
|
|
|
TLockedToken<CWorldSaveGameInfo> saveWorld =
|
2018-12-08 05:30:43 +00:00
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
|
|
|
|
cinematicCount += saveWorld->GetCinematicCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<bool> cinematicStates;
|
|
|
|
cinematicStates.reserve(cinematicCount);
|
2020-04-12 09:37:50 +00:00
|
|
|
for (size_t i = 0; i < cinematicCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
cinematicStates.push_back(stream.ReadBits(1) != 0);
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
for (const auto& world : memWorlds) {
|
2021-06-05 05:27:52 +00:00
|
|
|
TLockedToken<CWorldSaveGameInfo> saveWorld =
|
2018-12-08 05:30:43 +00:00
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
|
|
|
|
|
|
|
|
auto stateIt = cinematicStates.cbegin();
|
|
|
|
for (TEditorId cineId : saveWorld->GetCinematics())
|
|
|
|
if (*stateIt++)
|
|
|
|
SetCinematicState(world.first, cineId, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
void CPersistentOptions::PutTo(COutputStream& w) const {
|
2020-04-12 09:37:50 +00:00
|
|
|
for (const u8 entry : x0_nesState) {
|
2022-02-18 07:37:54 +00:00
|
|
|
w.WriteBits(entry, 8);
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-12 09:37:50 +00:00
|
|
|
for (const bool entry : x68_) {
|
2022-02-18 07:37:54 +00:00
|
|
|
w.WriteBits(u32(entry), 8);
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
w.WriteBits(xc0_frozenFpsCount, 2);
|
|
|
|
w.WriteBits(xc4_frozenBallCount, 2);
|
|
|
|
w.WriteBits(xc8_powerBombAmmoCount, 1);
|
|
|
|
w.WriteBits(xcc_logScanPercent, 7);
|
|
|
|
w.WriteBits(xd0_24_fusionLinked, 1);
|
|
|
|
w.WriteBits(xd0_25_normalModeBeat, 1);
|
|
|
|
w.WriteBits(xd0_26_hardModeBeat, 1);
|
|
|
|
w.WriteBits(xd0_27_fusionBeat, 1);
|
|
|
|
w.WriteBits(xd0_29_allItemsCollected, 1);
|
|
|
|
w.WriteBits(xbc_autoMapperKeyState, 2);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-05-08 22:41:27 +00:00
|
|
|
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const auto& world : memWorlds) {
|
2021-06-05 05:27:52 +00:00
|
|
|
const TLockedToken<CWorldSaveGameInfo> saveWorld =
|
2018-12-08 05:30:43 +00:00
|
|
|
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
|
|
|
|
|
2020-09-18 21:04:50 +00:00
|
|
|
for (const auto& cineId : saveWorld->GetCinematics()) {
|
2022-02-18 07:37:54 +00:00
|
|
|
w.WriteBits(u32(GetCinematicState(world.first, cineId)), 1);
|
2020-04-12 09:37:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPersistentOptions::GetCinematicState(CAssetId mlvlId, TEditorId cineId) const {
|
|
|
|
auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(),
|
|
|
|
[&](const std::pair<CAssetId, TEditorId>& pair) -> bool {
|
|
|
|
return pair.first == mlvlId && pair.second == cineId;
|
|
|
|
});
|
|
|
|
|
|
|
|
return existing != xac_cinematicStates.cend();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPersistentOptions::SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state) {
|
|
|
|
auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(),
|
|
|
|
[&](const std::pair<CAssetId, TEditorId>& pair) -> bool {
|
|
|
|
return pair.first == mlvlId && pair.second == cineId;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (state && existing == xac_cinematicStates.cend())
|
|
|
|
xac_cinematicStates.emplace_back(mlvlId, cineId);
|
|
|
|
else if (!state && existing != xac_cinematicStates.cend())
|
|
|
|
xac_cinematicStates.erase(existing);
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
CGameOptions::CGameOptions(CInputStream& stream) {
|
2019-08-14 06:49:40 +00:00
|
|
|
for (u8& entry : x0_)
|
2022-02-18 07:37:54 +00:00
|
|
|
entry = stream.ReadBits(8);
|
|
|
|
|
|
|
|
x44_soundMode = CAudioSys::ESurroundModes(stream.ReadBits(2));
|
|
|
|
x48_screenBrightness = stream.ReadBits(4);
|
|
|
|
|
|
|
|
x4c_screenXOffset = stream.ReadBits(6) - 30;
|
|
|
|
x50_screenYOffset = stream.ReadBits(6) - 30;
|
|
|
|
x54_screenStretch = stream.ReadBits(5) - 10;
|
|
|
|
x58_sfxVol = stream.ReadBits(7);
|
|
|
|
x5c_musicVol = stream.ReadBits(7);
|
|
|
|
x60_hudAlpha = stream.ReadBits(8);
|
|
|
|
x64_helmetAlpha = stream.ReadBits(8);
|
|
|
|
|
|
|
|
x68_24_hudLag = stream.ReadBits(1) != 0;
|
|
|
|
x68_28_hintSystem = stream.ReadBits(1) != 0;
|
|
|
|
x68_25_invertY = stream.ReadBits(1) != 0;
|
|
|
|
x68_26_rumble = stream.ReadBits(1) != 0;
|
|
|
|
x68_27_swapBeamsControls = stream.ReadBits(1) != 0;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameOptions::ResetToDefaults() {
|
|
|
|
x48_screenBrightness = 4;
|
|
|
|
x4c_screenXOffset = 0;
|
|
|
|
x50_screenYOffset = 0;
|
|
|
|
x54_screenStretch = 0;
|
|
|
|
x58_sfxVol = 0x7f;
|
|
|
|
x5c_musicVol = 0x7f;
|
|
|
|
x44_soundMode = CAudioSys::ESurroundModes::Stereo;
|
|
|
|
x60_hudAlpha = 0xFF;
|
|
|
|
x64_helmetAlpha = 0xFF;
|
|
|
|
x68_24_hudLag = true;
|
|
|
|
x68_25_invertY = false;
|
|
|
|
x68_26_rumble = true;
|
|
|
|
x68_27_swapBeamsControls = false;
|
|
|
|
x68_28_hintSystem = true;
|
|
|
|
InitSoundMode();
|
|
|
|
EnsureSettings();
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
void CGameOptions::PutTo(COutputStream& writer) const {
|
2019-08-14 06:49:40 +00:00
|
|
|
for (const u8 entry : x0_)
|
2022-02-18 07:37:54 +00:00
|
|
|
writer.WriteBits(entry, 8);
|
|
|
|
|
|
|
|
writer.WriteBits(u32(x44_soundMode), 2);
|
|
|
|
writer.WriteBits(x48_screenBrightness, 4);
|
|
|
|
|
|
|
|
writer.WriteBits(x4c_screenXOffset + 30, 6);
|
|
|
|
writer.WriteBits(x50_screenYOffset + 30, 6);
|
|
|
|
writer.WriteBits(x54_screenStretch + 10, 5);
|
|
|
|
writer.WriteBits(x58_sfxVol, 7);
|
|
|
|
writer.WriteBits(x5c_musicVol, 7);
|
|
|
|
writer.WriteBits(x60_hudAlpha, 8);
|
|
|
|
writer.WriteBits(x64_helmetAlpha, 8);
|
|
|
|
|
|
|
|
writer.WriteBits(x68_24_hudLag, 1);
|
|
|
|
writer.WriteBits(x68_28_hintSystem, 1);
|
|
|
|
writer.WriteBits(x68_25_invertY, 1);
|
|
|
|
writer.WriteBits(x68_26_rumble, 1);
|
|
|
|
writer.WriteBits(x68_27_swapBeamsControls, 1);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 19:02:36 +00:00
|
|
|
CGameOptions::CGameOptions()
|
|
|
|
: x68_24_hudLag(true)
|
|
|
|
, x68_25_invertY(false)
|
|
|
|
, x68_26_rumble(true)
|
|
|
|
, x68_27_swapBeamsControls(false)
|
|
|
|
, x68_28_hintSystem(true) {
|
2018-12-08 05:30:43 +00:00
|
|
|
InitSoundMode();
|
|
|
|
}
|
|
|
|
|
2020-04-16 23:42:18 +00:00
|
|
|
float CGameOptions::TuneScreenBrightness() const { return (0.375f * 1.f) + (float(x48_screenBrightness) * 0.25f); }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-16 06:57:04 +00:00
|
|
|
void CGameOptions::InitSoundMode() { /* If system is mono, force x44 to mono, otherwise honor user preference */
|
|
|
|
}
|
2017-01-10 07:15:49 +00:00
|
|
|
static float BrightnessCopyFilter = 0.f;
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetScreenBrightness(s32 value, bool apply) {
|
|
|
|
x48_screenBrightness = zeus::clamp(0, value, 8);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
if (!apply) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BrightnessCopyFilter = TuneScreenBrightness();
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::ApplyGamma() {
|
|
|
|
float gammaT = -m_gamma / 100.f + 1.f;
|
|
|
|
if (gammaT < 1.f)
|
|
|
|
gammaT = gammaT * 0.5f + 0.5f;
|
|
|
|
if (zeus::close_enough(gammaT, 1.f, 0.05f))
|
|
|
|
gammaT = 1.f;
|
2022-02-01 00:06:54 +00:00
|
|
|
// CGraphics::g_BooFactory->setDisplayGamma(gammaT);
|
2018-01-21 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetGamma(s32 value, bool apply) {
|
|
|
|
m_gamma = zeus::clamp(-100, value, 100);
|
2018-01-21 22:05:25 +00:00
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
if (!apply) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplyGamma();
|
2018-01-21 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetScreenPositionX(s32 position, bool apply) {
|
|
|
|
x4c_screenXOffset = zeus::clamp(-30, position, 30);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (apply) {
|
|
|
|
/* TOOD: CGraphics related funcs */
|
|
|
|
}
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetScreenPositionY(s32 position, bool apply) {
|
|
|
|
x50_screenYOffset = zeus::clamp(-30, position, 30);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (apply) {
|
|
|
|
/* TOOD: CGraphics related funcs */
|
|
|
|
}
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetScreenStretch(s32 stretch, bool apply) {
|
|
|
|
x54_screenStretch = zeus::clamp(-10, stretch, 10);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (apply) {
|
|
|
|
/* TOOD: CGraphics related funcs */
|
|
|
|
}
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetSfxVolume(s32 volume, bool apply) {
|
|
|
|
x58_sfxVol = zeus::clamp(0, volume, 0x7f);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
if (!apply) {
|
|
|
|
return;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-04-16 23:49:33 +00:00
|
|
|
|
|
|
|
CAudioSys::SysSetSfxVolume(x58_sfxVol, 1, true, true);
|
|
|
|
CStreamAudioManager::SetSfxVolume(x58_sfxVol);
|
|
|
|
CMoviePlayer::SetSfxVolume(x58_sfxVol);
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 23:49:33 +00:00
|
|
|
void CGameOptions::SetMusicVolume(s32 volume, bool apply) {
|
|
|
|
x5c_musicVol = zeus::clamp(0, volume, 0x7f);
|
|
|
|
|
|
|
|
if (!apply) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CStreamAudioManager::SetMusicVolume(x5c_musicVol);
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetHUDAlpha(u32 alpha) { x60_hudAlpha = alpha; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetHelmetAlpha(u32 alpha) { x64_helmetAlpha = alpha; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetHUDLag(bool lag) { x68_24_hudLag = lag; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetSurroundMode(int mode, bool apply) {
|
|
|
|
x44_soundMode = CAudioSys::ESurroundModes(zeus::clamp(0, mode, 2));
|
|
|
|
if (apply)
|
|
|
|
CAudioSys::SetSurroundMode(x44_soundMode);
|
2017-01-10 07:15:49 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAudioSys::ESurroundModes CGameOptions::GetSurroundMode() const { return x44_soundMode; }
|
2017-01-10 07:15:49 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetInvertYAxis(bool invert) { x68_25_invertY = invert; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetIsRumbleEnabled(bool rumble) { x68_26_rumble = rumble; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetSwapBeamControls(bool swap) {
|
|
|
|
x68_27_swapBeamsControls = swap;
|
|
|
|
if (!swap)
|
|
|
|
SetControls(0);
|
|
|
|
else
|
|
|
|
SetControls(1);
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetIsHintSystemEnabled(bool hints) { x68_28_hintSystem = hints; }
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::SetControls(int controls) {
|
|
|
|
if (controls == 0)
|
|
|
|
g_currentPlayerControl = g_tweakPlayerControl;
|
|
|
|
else
|
|
|
|
g_currentPlayerControl = g_tweakPlayerControlAlt;
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
ResetControllerAssets(controls);
|
2017-01-07 01:58:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 09:42:43 +00:00
|
|
|
constexpr std::array<std::pair<CAssetId, CAssetId>, 5> CStickToDPadRemap{{
|
2022-02-19 13:04:45 +00:00
|
|
|
{0x2A13C23Eu, 0xF13452F8u},
|
|
|
|
{0xA91A7703u, 0xC042EC91u},
|
|
|
|
{0x12A12131u, 0x5F556002u},
|
|
|
|
{0xA9798329u, 0xB306E26Fu},
|
|
|
|
{0xCD7B1ACAu, 0x8ADA8184u},
|
2019-08-14 06:49:40 +00:00
|
|
|
}};
|
|
|
|
|
2020-04-12 09:42:43 +00:00
|
|
|
constexpr std::array<std::pair<CAssetId, CAssetId>, 5> CStickOutlineToDPadRemap{{
|
2022-02-19 13:04:45 +00:00
|
|
|
{0x1A29C0E6u, 0xF13452F8u},
|
|
|
|
{0x5D9F9796u, 0xC042EC91u},
|
|
|
|
{0x951546A8u, 0x5F556002u},
|
|
|
|
{0x7946C4C5u, 0xB306E26Fu},
|
|
|
|
{0x409AA72Eu, 0x8ADA8184u},
|
2019-08-14 06:49:40 +00:00
|
|
|
}};
|
2017-05-31 21:26:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGameOptions::ResetControllerAssets(int controls) {
|
|
|
|
if (controls != 1) {
|
|
|
|
x6c_controlTxtrMap.clear();
|
|
|
|
} else if (x6c_controlTxtrMap.empty()) {
|
|
|
|
x6c_controlTxtrMap.reserve(15);
|
2017-01-07 01:58:05 +00:00
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
for (const auto& entry : CStickToDPadRemap) {
|
2019-10-01 07:38:03 +00:00
|
|
|
const auto& emplaced = x6c_controlTxtrMap.emplace_back(entry);
|
2019-08-14 06:49:40 +00:00
|
|
|
x6c_controlTxtrMap.emplace_back(emplaced.second, emplaced.first);
|
2017-01-10 07:15:49 +00:00
|
|
|
}
|
|
|
|
|
2019-08-14 06:49:40 +00:00
|
|
|
for (const auto& entry : CStickOutlineToDPadRemap)
|
2019-10-01 07:38:03 +00:00
|
|
|
x6c_controlTxtrMap.emplace_back(entry);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
std::sort(x6c_controlTxtrMap.begin(), x6c_controlTxtrMap.end(),
|
|
|
|
[](const std::pair<CAssetId, CAssetId>& a, const std::pair<CAssetId, CAssetId>& b) {
|
|
|
|
return a.first < b.first;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameOptions::EnsureSettings() {
|
|
|
|
SetScreenBrightness(x48_screenBrightness, true);
|
|
|
|
SetGamma(m_gamma, true);
|
|
|
|
SetScreenPositionX(x4c_screenXOffset, true);
|
|
|
|
SetScreenPositionY(x50_screenYOffset, true);
|
|
|
|
SetScreenStretch(x54_screenStretch, true);
|
|
|
|
SetSfxVolume(x58_sfxVol, true);
|
|
|
|
SetMusicVolume(x5c_musicVol, true);
|
|
|
|
SetSurroundMode(int(x44_soundMode), true);
|
|
|
|
SetHelmetAlpha(x64_helmetAlpha);
|
|
|
|
SetHUDLag(x68_24_hudLag);
|
|
|
|
SetInvertYAxis(x68_25_invertY);
|
|
|
|
SetIsRumbleEnabled(x68_26_rumble);
|
|
|
|
SetIsHintSystemEnabled(x68_28_hintSystem);
|
|
|
|
SetSwapBeamControls(x68_27_swapBeamsControls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameOptions::TryRestoreDefaults(const CFinalInput& input, int category, int option, bool frontend,
|
|
|
|
bool forceRestore) {
|
2019-08-14 06:49:40 +00:00
|
|
|
const auto& options = GameOptionsRegistry[category];
|
|
|
|
if (options.first == 0)
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (options.second[option].option != EGameOption::RestoreDefaults)
|
|
|
|
return;
|
|
|
|
|
2019-01-21 04:10:34 +00:00
|
|
|
if (!forceRestore && !input.PA() && !input.PSpecialKey(boo::ESpecialKey::Enter))
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (frontend) {
|
|
|
|
CSfxManager::SfxStart(SFXfnt_advance_L, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
CSfxManager::SfxStart(SFXfnt_advance_R, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
} else {
|
|
|
|
CSfxManager::SfxStart(SFXui_advance, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
}
|
|
|
|
|
|
|
|
CGameOptions& gameOptions = g_GameState->GameOptions();
|
|
|
|
switch (category) {
|
|
|
|
case 0:
|
|
|
|
gameOptions.SetHelmetAlpha(0xff);
|
|
|
|
gameOptions.SetHUDLag(true);
|
|
|
|
gameOptions.SetIsHintSystemEnabled(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
gameOptions.SetScreenBrightness(4, true);
|
|
|
|
gameOptions.SetGamma(0, true);
|
|
|
|
gameOptions.SetScreenPositionX(0, true);
|
|
|
|
gameOptions.SetScreenPositionY(0, true);
|
|
|
|
gameOptions.SetScreenStretch(0, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
gameOptions.SetSfxVolume(0x7f, true);
|
|
|
|
gameOptions.SetMusicVolume(0x7f, true);
|
|
|
|
gameOptions.SetSurroundMode(1, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
gameOptions.SetInvertYAxis(false);
|
|
|
|
gameOptions.SetIsRumbleEnabled(true);
|
|
|
|
gameOptions.SetSwapBeamControls(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameOptions::SetOption(EGameOption option, int value) {
|
|
|
|
CGameOptions& options = g_GameState->GameOptions();
|
|
|
|
|
|
|
|
switch (option) {
|
|
|
|
case EGameOption::VisorOpacity:
|
|
|
|
options.SetHUDAlpha(value);
|
|
|
|
break;
|
|
|
|
case EGameOption::HelmetOpacity:
|
|
|
|
options.SetHelmetAlpha(value);
|
|
|
|
break;
|
|
|
|
case EGameOption::HUDLag:
|
2020-04-12 09:37:50 +00:00
|
|
|
options.SetHUDLag(value != 0);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EGameOption::HintSystem:
|
2020-04-12 09:37:50 +00:00
|
|
|
options.SetIsHintSystemEnabled(value != 0);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EGameOption::ScreenBrightness:
|
|
|
|
options.SetGamma(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::ScreenOffsetX:
|
|
|
|
options.SetScreenPositionX(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::ScreenOffsetY:
|
|
|
|
options.SetScreenPositionY(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::ScreenStretch:
|
|
|
|
options.SetScreenStretch(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::SFXVolume:
|
|
|
|
options.SetSfxVolume(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::MusicVolume:
|
|
|
|
options.SetMusicVolume(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::SoundMode:
|
|
|
|
options.SetSurroundMode(value, true);
|
|
|
|
break;
|
|
|
|
case EGameOption::ReverseYAxis:
|
2020-04-12 09:37:50 +00:00
|
|
|
options.SetInvertYAxis(value != 0);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EGameOption::Rumble:
|
2020-04-12 09:37:50 +00:00
|
|
|
options.SetIsRumbleEnabled(value != 0);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EGameOption::SwapBeamControls:
|
2020-04-12 09:37:50 +00:00
|
|
|
options.SetSwapBeamControls(value != 0);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CGameOptions::GetOption(EGameOption option) {
|
|
|
|
const CGameOptions& options = g_GameState->GameOptions();
|
|
|
|
|
|
|
|
switch (option) {
|
|
|
|
case EGameOption::VisorOpacity:
|
|
|
|
return options.GetHUDAlpha();
|
|
|
|
case EGameOption::HelmetOpacity:
|
|
|
|
return options.GetHelmetAlpha();
|
|
|
|
case EGameOption::HUDLag:
|
2020-04-12 09:37:50 +00:00
|
|
|
return int(options.GetHUDLag());
|
2018-12-08 05:30:43 +00:00
|
|
|
case EGameOption::HintSystem:
|
2020-04-12 09:37:50 +00:00
|
|
|
return int(options.GetIsHintSystemEnabled());
|
2018-12-08 05:30:43 +00:00
|
|
|
case EGameOption::ScreenBrightness:
|
|
|
|
return options.GetGamma();
|
|
|
|
case EGameOption::ScreenOffsetX:
|
|
|
|
return options.GetScreenPositionX();
|
|
|
|
case EGameOption::ScreenOffsetY:
|
|
|
|
return options.GetScreenPositionY();
|
|
|
|
case EGameOption::ScreenStretch:
|
|
|
|
return options.GetScreenStretch();
|
|
|
|
case EGameOption::SFXVolume:
|
|
|
|
return options.GetSfxVolume();
|
|
|
|
case EGameOption::MusicVolume:
|
|
|
|
return options.GetMusicVolume();
|
|
|
|
case EGameOption::SoundMode:
|
|
|
|
return int(options.GetSurroundMode());
|
|
|
|
case EGameOption::ReverseYAxis:
|
2020-04-12 09:37:50 +00:00
|
|
|
return int(options.GetInvertYAxis());
|
2018-12-08 05:30:43 +00:00
|
|
|
case EGameOption::Rumble:
|
2020-04-12 09:37:50 +00:00
|
|
|
return int(options.GetIsRumbleEnabled());
|
2018-12-08 05:30:43 +00:00
|
|
|
case EGameOption::SwapBeamControls:
|
2020-04-12 09:37:50 +00:00
|
|
|
return int(options.GetSwapBeamControls());
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
CHintOptions::CHintOptions(CInputStream& stream) {
|
2018-12-08 05:30:43 +00:00
|
|
|
const auto& hints = g_MemoryCardSys->GetHints();
|
|
|
|
x0_hintStates.reserve(hints.size());
|
|
|
|
|
|
|
|
u32 hintIdx = 0;
|
2020-04-03 06:14:28 +00:00
|
|
|
for ([[maybe_unused]] const auto& hint : hints) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const auto state = EHintState(stream.ReadBits(2));
|
|
|
|
const s32 timeBits = stream.ReadBits(32);
|
2020-04-03 06:14:28 +00:00
|
|
|
float time;
|
|
|
|
std::memcpy(&time, &timeBits, sizeof(s32));
|
|
|
|
if (state == EHintState::Zero) {
|
2018-12-08 05:30:43 +00:00
|
|
|
time = 0.f;
|
2020-04-03 06:14:28 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
x0_hintStates.emplace_back(state, time, false);
|
|
|
|
|
2020-04-03 06:14:28 +00:00
|
|
|
if (x10_nextHintIdx == -1 && state == EHintState::Displaying) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x10_nextHintIdx = hintIdx;
|
2020-04-03 06:14:28 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
++hintIdx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
void CHintOptions::PutTo(COutputStream& writer) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const SHintState& hint : x0_hintStates) {
|
2022-02-18 07:37:54 +00:00
|
|
|
writer.WriteBits(u32(hint.x0_state), 2);
|
2020-04-03 06:14:28 +00:00
|
|
|
|
|
|
|
u32 timeBits;
|
|
|
|
std::memcpy(&timeBits, &hint.x4_time, sizeof(timeBits));
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
writer.WriteBits(timeBits, 32);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHintOptions::SetNextHintTime() {
|
|
|
|
if (x10_nextHintIdx == -1)
|
|
|
|
return;
|
|
|
|
x0_hintStates[x10_nextHintIdx].x4_time = g_MemoryCardSys->GetHints()[x10_nextHintIdx].GetTextTime() + 5.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHintOptions::InitializeMemoryState() {
|
|
|
|
const auto& hints = g_MemoryCardSys->GetHints();
|
|
|
|
x0_hintStates.resize(hints.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
const CHintOptions::SHintState* CHintOptions::GetCurrentDisplayedHint() const {
|
|
|
|
if (!g_GameState->GameOptions().GetIsHintSystemEnabled())
|
2017-02-18 02:19:50 +00:00
|
|
|
return nullptr;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x10_nextHintIdx == -1)
|
|
|
|
return nullptr;
|
2017-02-18 02:19:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const SHintState& hintState = x0_hintStates[x10_nextHintIdx];
|
|
|
|
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[x10_nextHintIdx];
|
|
|
|
if (hintState.x4_time >= hint.GetTextTime())
|
|
|
|
return nullptr;
|
2017-02-18 02:19:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (hintState.x4_time < 3.f)
|
|
|
|
return &hintState;
|
2017-02-18 02:19:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!hintState.x8_dismissed)
|
|
|
|
return &hintState;
|
2017-02-18 02:19:50 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return nullptr;
|
2017-02-18 02:19:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-14 23:59:58 +00:00
|
|
|
void CHintOptions::DelayHint(std::string_view name) {
|
|
|
|
const int idx = CGameHintInfo::FindHintIndex(name);
|
|
|
|
if (idx == -1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
2017-03-24 05:30:16 +00:00
|
|
|
|
2020-03-14 23:59:58 +00:00
|
|
|
if (x10_nextHintIdx == idx) {
|
|
|
|
for (SHintState& state : x0_hintStates) {
|
2018-12-08 05:30:43 +00:00
|
|
|
state.x4_time += 60.f;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
x0_hintStates[idx].x0_state = EHintState::Delayed;
|
|
|
|
}
|
|
|
|
|
2020-03-14 23:59:58 +00:00
|
|
|
void CHintOptions::ActivateImmediateHintTimer(std::string_view name) {
|
|
|
|
const int idx = CGameHintInfo::FindHintIndex(name);
|
|
|
|
if (idx == -1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
SHintState& hintState = x0_hintStates[idx];
|
|
|
|
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
|
2020-03-14 23:59:58 +00:00
|
|
|
if (hintState.x0_state != EHintState::Zero) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
hintState.x0_state = EHintState::Waiting;
|
|
|
|
hintState.x4_time = hint.GetImmediateTime();
|
|
|
|
}
|
|
|
|
|
2020-03-14 23:59:58 +00:00
|
|
|
void CHintOptions::ActivateContinueDelayHintTimer(std::string_view name) {
|
2018-12-08 05:30:43 +00:00
|
|
|
int idx = x10_nextHintIdx;
|
2020-03-14 23:59:58 +00:00
|
|
|
if (idx != 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
idx = CGameHintInfo::FindHintIndex(name);
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
|
|
|
if (idx == -1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
SHintState& hintState = x0_hintStates[idx];
|
|
|
|
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
|
2020-03-14 23:59:58 +00:00
|
|
|
if (hintState.x0_state != EHintState::Displaying) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-03-14 23:59:58 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
hintState.x4_time = hint.GetTextTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHintOptions::DismissDisplayedHint() {
|
|
|
|
if (x10_nextHintIdx == -1)
|
|
|
|
return;
|
|
|
|
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[x10_nextHintIdx];
|
|
|
|
SHintState& hintState = x0_hintStates[x10_nextHintIdx];
|
|
|
|
if (hintState.x4_time >= hint.GetTextTime())
|
|
|
|
return;
|
|
|
|
hintState.x4_time = hint.GetNormalTime();
|
|
|
|
hintState.x8_dismissed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CHintOptions::GetNextHintIdx() const {
|
|
|
|
if (g_GameState->GameOptions().GetIsHintSystemEnabled())
|
|
|
|
return x10_nextHintIdx;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHintOptions::Update(float dt, const CStateManager& stateMgr) {
|
|
|
|
x10_nextHintIdx = -1;
|
|
|
|
int idx = 0;
|
|
|
|
auto memIt = g_MemoryCardSys->GetHints().begin();
|
|
|
|
for (SHintState& state : x0_hintStates) {
|
|
|
|
switch (state.x0_state) {
|
|
|
|
case EHintState::Waiting:
|
|
|
|
state.x4_time -= dt;
|
|
|
|
if (state.x4_time <= 0.f) {
|
|
|
|
state.x0_state = EHintState::Displaying;
|
|
|
|
state.x4_time = memIt->GetTextTime();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EHintState::Displaying:
|
|
|
|
if (x10_nextHintIdx == -1)
|
|
|
|
x10_nextHintIdx = idx;
|
2019-02-18 05:47:46 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
2017-03-24 05:30:16 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
++memIt;
|
|
|
|
++idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x10_nextHintIdx == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SHintState& state = x0_hintStates[x10_nextHintIdx];
|
|
|
|
const CGameHintInfo::CGameHint& data = g_MemoryCardSys->GetHints()[x10_nextHintIdx];
|
|
|
|
|
|
|
|
state.x4_time = std::max(0.f, state.x4_time - dt);
|
|
|
|
if (state.x4_time < data.GetTextTime()) {
|
|
|
|
for (const CGameHintInfo::SHintLocation& loc : data.GetLocations()) {
|
|
|
|
if (loc.x0_mlvlId == stateMgr.GetWorld()->IGetWorldAssetId() && loc.x8_areaId == stateMgr.GetNextAreaId()) {
|
|
|
|
state.x4_time = data.GetNormalTime();
|
|
|
|
state.x8_dismissed = true;
|
|
|
|
}
|
2017-03-24 05:30:16 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-03-24 05:30:16 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|