|
| 1 | +#ifndef GAMESTATE_H |
| 2 | +#define GAMESTATE_H |
| 3 | + |
| 4 | +#include "save/persistentgamestate.h" |
| 5 | +#include "save/saverecordlist.h" |
| 6 | +#include "types.h" |
| 7 | +#include "util/displaydriverguid.h" |
| 8 | + |
| 9 | +class GolString; |
| 10 | +class InputManager; |
| 11 | +class SaveGame; |
| 12 | + |
| 13 | +// SIZE 0x438 |
| 14 | +class GameState { |
| 15 | +public: |
| 16 | + GameState(); |
| 17 | + ~GameState(); |
| 18 | + |
| 19 | + void Initialize(InputManager* p_inputManager); |
| 20 | + void Reset(); |
| 21 | + void InitializeInputBindings(InputManager* p_inputManager); |
| 22 | + void SelectInputBinding(LegoU32 p_playerIndex, LegoU32 p_entryIndex); |
| 23 | + void LoadFromSaveGame(SaveGame* p_saveGame, LegoU32 p_activeSaveIndex); |
| 24 | + LegoU32 GetInputEvent(LegoU32 p_playerIndex, LegoU32 p_entryIndex, LegoU32 p_eventIndex); |
| 25 | + void GetInputBindingEntry(LegoU32 p_playerIndex, LegoU32 p_entryIndex, InputBindingState::Entry* p_entry); |
| 26 | + void SetInputEvent(LegoU32 p_entryIndex, LegoU32 p_eventIndex, LegoU32 p_event); |
| 27 | + void WriteToSaveGame(SaveGame*); |
| 28 | + void SetLanguageResourcePath(); |
| 29 | + void SetDisplayDriverGuid(const DisplayDriverGuid& p_guid); |
| 30 | + void GetDisplayDriverGuid(DisplayDriverGuid& p_guid); |
| 31 | + void UnlockParts(LegoU8 p_flags); |
| 32 | + void UnlockCircuits(LegoU8 p_flags); |
| 33 | + LegoU16 GetUnlockedRaces() const; |
| 34 | + LegoBool32 UnlockRace(LegoU32 p_mask); |
| 35 | + LegoBool32 AreAllRacesUnlocked() const; |
| 36 | + LegoU32 GetBestTime(LegoU32 p_raceIndex, LegoBool32 p_raceTime, GolString* p_string) const; |
| 37 | + LegoBool32 SetBestTime(LegoU32 p_raceIndex, LegoBool32 p_raceTime, LegoU32 p_time, GolString* p_string); |
| 38 | + |
| 39 | + void SetDirty(LegoBool32 p_dirty) { m_dirty = p_dirty; } |
| 40 | + void SetRacerCount(LegoU32 p_racerCount) |
| 41 | + { |
| 42 | + m_dirty = 1; |
| 43 | + m_state.m_racerCount = static_cast<LegoU8>(p_racerCount); |
| 44 | + } |
| 45 | + void SetMusicVolume(LegoU8 p_musicVolume) |
| 46 | + { |
| 47 | + m_state.m_musicVolume = p_musicVolume; |
| 48 | + m_dirty = 1; |
| 49 | + } |
| 50 | + void SetSoundVolume(LegoU8 p_soundVolume) |
| 51 | + { |
| 52 | + m_state.m_soundVolume = p_soundVolume; |
| 53 | + m_dirty = 1; |
| 54 | + } |
| 55 | + void SetUnk0x21(LegoU8 p_unk0x21) |
| 56 | + { |
| 57 | + m_state.m_unk0x21 = p_unk0x21; |
| 58 | + m_dirty = 1; |
| 59 | + } |
| 60 | + void SetUnk0x23(LegoU32 p_unk0x23) |
| 61 | + { |
| 62 | + m_dirty = 1; |
| 63 | + m_state.m_unk0x23 = static_cast<LegoU8>(p_unk0x23); |
| 64 | + } |
| 65 | + void SetInputBindingPlayer0Unk0x00(undefined4 p_unk0x00) |
| 66 | + { |
| 67 | + m_state.m_inputBindings.m_players[0].m_selectedRecordId = static_cast<LegoU8>(p_unk0x00); |
| 68 | + m_dirty = 1; |
| 69 | + } |
| 70 | + void SetInputBindingPlayer0Unk0x01(undefined4 p_unk0x01) |
| 71 | + { |
| 72 | + m_state.m_inputBindings.m_players[0].m_selectedRecordSource = static_cast<LegoU8>(p_unk0x01); |
| 73 | + m_dirty = 1; |
| 74 | + } |
| 75 | + void SetInputBindingPlayer0Unk0x02(undefined4 p_unk0x02) |
| 76 | + { |
| 77 | + m_state.m_inputBindings.m_players[0].m_selectedSaveIndex = static_cast<LegoU8>(p_unk0x02); |
| 78 | + m_dirty = 1; |
| 79 | + } |
| 80 | + void SetInputBindingPlayer0RecordValues(const SaveRecordList::Record* p_record) |
| 81 | + { |
| 82 | + m_state.m_inputBindings.m_players[0].m_selectedRecordSource = static_cast<LegoU8>(p_record->m_recordSource); |
| 83 | + m_dirty = 1; |
| 84 | + m_state.m_inputBindings.m_players[0].m_selectedSaveIndex = static_cast<LegoU8>(p_record->m_saveIndex); |
| 85 | + m_dirty = 1; |
| 86 | + m_state.m_inputBindings.m_players[0].m_selectedRecordId = static_cast<LegoU8>(p_record->m_recordId); |
| 87 | + m_dirty = 1; |
| 88 | + } |
| 89 | + void SetLanguageIndex(LegoU8 p_languageIndex) { m_state.m_languageIndex = p_languageIndex; } |
| 90 | + LegoU8 GetSelectedInputBindingEntryIndex(LegoU32 p_playerIndex) const |
| 91 | + { |
| 92 | + return m_state.m_inputBindings.GetSelectedEntryIndex(p_playerIndex); |
| 93 | + } |
| 94 | + LegoBool32 IsDirty() const { return m_dirty; } |
| 95 | + undefined4 GetActiveSaveIndex() const { return m_activeSaveIndex; } |
| 96 | + PersistentGameState& GetState() { return m_state; } |
| 97 | + LegoU8 GetRacerCount() const { return m_state.m_racerCount; } |
| 98 | + LegoU8 GetMusicVolume() const { return m_state.m_musicVolume; } |
| 99 | + LegoU8 GetSoundVolume() const { return m_state.m_soundVolume; } |
| 100 | + LegoU8 GetUnk0x21() const { return m_state.m_unk0x21; } |
| 101 | + LegoU32 GetLanguageIndex() const { return m_state.m_languageIndex; } |
| 102 | + LegoU8 GetUnk0x23() const { return m_state.m_unk0x23; } |
| 103 | + LegoU8 GetPartUnlockFlags() const; |
| 104 | + LegoU8 GetUnlockedCircuits() const; |
| 105 | + |
| 106 | +private: |
| 107 | + enum { |
| 108 | + c_joystickBindingCount = 2, |
| 109 | + c_keyboardBindingStart = 2, |
| 110 | + c_inputBindingEntryCount = 5, |
| 111 | + c_inputBindingEventCount = 9, |
| 112 | + c_joystickDeviceType = 4, |
| 113 | + c_axisJoystickDeviceSubType = 4, |
| 114 | + }; |
| 115 | + |
| 116 | + void Initialize(); |
| 117 | + void SelectFallbackInputBinding(LegoU32 p_playerIndex); |
| 118 | + LegoU32 FindAvailableInputBindingEntry(LegoU32 p_playerIndex); |
| 119 | + LegoBool32 IsInputEventBound(LegoU32 p_entryIndex, LegoU32 p_event); |
| 120 | + LegoU32 GetDefaultInputEvent(LegoU32 p_entryIndex, LegoU32 p_eventIndex); |
| 121 | + LegoU32 GetRegistryLanguageIndex(); |
| 122 | + |
| 123 | + LegoBool32 m_dirty; // 0x00 |
| 124 | + undefined4 m_activeSaveIndex; // 0x04 |
| 125 | + InputManager* m_inputManager; // 0x08 |
| 126 | + PersistentGameState m_state; // 0x0c |
| 127 | +}; |
| 128 | + |
| 129 | +#endif // GAMESTATE_H |
0 commit comments