Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10459 from Dentomologist/convert_movie_playmode_t…
…o_enum_class

Movie: Convert PlayMode to enum class and move to cpp file
  • Loading branch information
lioncash committed Feb 18, 2022
2 parents 1e126d2 + f562511 commit 8b0c6af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
37 changes: 22 additions & 15 deletions Source/Core/Core/Movie.cpp
Expand Up @@ -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{};
Expand Down Expand Up @@ -308,7 +315,7 @@ void SetReadOnly(bool bEnabled)

bool IsRecordingInput()
{
return (s_playMode == MODE_RECORDING);
return (s_playMode == PlayMode::Recording);
}

bool IsRecordingInputFromSaveState()
Expand All @@ -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()
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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");
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -1317,18 +1324,18 @@ 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();
if (was_running && Config::Get(Config::MAIN_MOVIE_PAUSE_MOVIE))
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
Expand Down
7 changes: 0 additions & 7 deletions Source/Core/Core/Movie.h
Expand Up @@ -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,
Expand Down

0 comments on commit 8b0c6af

Please sign in to comment.