Merge pull request #10459 from Dentomologist/convert_movie_playmode_to_enum_class

Movie: Convert PlayMode to enum class and move to cpp file
This commit is contained in:
Mai M 2022-02-18 10:00:33 -05:00 committed by GitHub
commit 8b0c6af75a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 22 deletions

View File

@ -79,9 +79,16 @@ namespace Movie
using namespace WiimoteCommon;
using namespace WiimoteEmu;
enum class PlayMode
{
None = 0,
Recording,
Playing,
};
static bool s_bReadOnly = true;
static u32 s_rerecords = 0;
static PlayMode s_playMode = MODE_NONE;
static PlayMode s_playMode = PlayMode::None;
static std::array<ControllerType, 4> s_controllers{};
static std::array<bool, 4> s_wiimotes{};
@ -308,7 +315,7 @@ void SetReadOnly(bool bEnabled)
bool IsRecordingInput()
{
return (s_playMode == MODE_RECORDING);
return (s_playMode == PlayMode::Recording);
}
bool IsRecordingInputFromSaveState()
@ -328,12 +335,12 @@ bool IsJustStartingPlayingInputFromSaveState()
bool IsPlayingInput()
{
return (s_playMode == MODE_PLAYING);
return (s_playMode == PlayMode::Playing);
}
bool IsMovieActive()
{
return s_playMode != MODE_NONE;
return s_playMode != PlayMode::None;
}
bool IsReadOnly()
@ -528,7 +535,7 @@ void ChangeWiiPads(bool instantly)
bool BeginRecordingInput(const ControllerTypeArray& controllers,
const WiimoteEnabledArray& wiimotes)
{
if (s_playMode != MODE_NONE ||
if (s_playMode != PlayMode::None ||
(controllers == ControllerTypeArray{} && wiimotes == WiimoteEnabledArray{}))
return false;
@ -585,7 +592,7 @@ bool BeginRecordingInput(const ControllerTypeArray& controllers,
Wiimote::ResetAllWiimotes();
}
s_playMode = MODE_RECORDING;
s_playMode = PlayMode::Recording;
s_author = Config::Get(Config::MAIN_MOVIE_MOVIE_AUTHOR);
s_temp_input.clear();
@ -937,7 +944,7 @@ void ReadHeader()
// NOTE: Host Thread
bool PlayInput(const std::string& movie_path, std::optional<std::string>* savestate_path)
{
if (s_playMode != MODE_NONE)
if (s_playMode != PlayMode::None)
return false;
File::IOFile recording_file(movie_path, "rb");
@ -959,7 +966,7 @@ bool PlayInput(const std::string& movie_path, std::optional<std::string>* savest
s_currentLagCount = 0;
s_currentInputCount = 0;
s_playMode = MODE_PLAYING;
s_playMode = PlayMode::Playing;
// Wiimotes cause desync issues if they're not reset before launching the game
Wiimote::ResetAllWiimotes();
@ -1139,18 +1146,18 @@ void LoadInput(const std::string& movie_path)
{
if (s_bReadOnly)
{
if (s_playMode != MODE_PLAYING)
if (s_playMode != PlayMode::Playing)
{
s_playMode = MODE_PLAYING;
s_playMode = PlayMode::Playing;
Core::UpdateWantDeterminism();
Core::DisplayMessage("Switched to playback", 2000);
}
}
else
{
if (s_playMode != MODE_RECORDING)
if (s_playMode != PlayMode::Recording)
{
s_playMode = MODE_RECORDING;
s_playMode = PlayMode::Recording;
Core::UpdateWantDeterminism();
Core::DisplayMessage("Switched to recording", 2000);
}
@ -1317,10 +1324,10 @@ void EndPlayInput(bool cont)
// If !IsMovieActive(), changing s_playMode requires calling UpdateWantDeterminism
ASSERT(IsMovieActive());
s_playMode = MODE_RECORDING;
s_playMode = PlayMode::Recording;
Core::DisplayMessage("Reached movie end. Resuming recording.", 2000);
}
else if (s_playMode != MODE_NONE)
else if (s_playMode != PlayMode::None)
{
// We can be called by EmuThread during boot (CPU::State::PowerDown)
bool was_running = Core::IsRunningAndStarted() && !CPU::IsStepping();
@ -1328,7 +1335,7 @@ void EndPlayInput(bool cont)
CPU::Break();
s_rerecords = 0;
s_currentByte = 0;
s_playMode = MODE_NONE;
s_playMode = PlayMode::None;
Core::DisplayMessage("Movie End.", 2000);
s_bRecordingFromSaveState = false;
// we don't clear these things because otherwise we can't resume playback if we load a movie

View File

@ -37,13 +37,6 @@ class EncryptionKey;
namespace Movie
{
// Enumerations and structs
enum PlayMode
{
MODE_NONE = 0,
MODE_RECORDING,
MODE_PLAYING
};
enum class ControllerType
{
None = 0,