Skip to content

Commit 8b0c6af

Browse files
authored
Merge pull request #10459 from Dentomologist/convert_movie_playmode_to_enum_class
Movie: Convert PlayMode to enum class and move to cpp file
2 parents 1e126d2 + f562511 commit 8b0c6af

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

Source/Core/Core/Movie.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@ namespace Movie
7979
using namespace WiimoteCommon;
8080
using namespace WiimoteEmu;
8181

82+
enum class PlayMode
83+
{
84+
None = 0,
85+
Recording,
86+
Playing,
87+
};
88+
8289
static bool s_bReadOnly = true;
8390
static u32 s_rerecords = 0;
84-
static PlayMode s_playMode = MODE_NONE;
91+
static PlayMode s_playMode = PlayMode::None;
8592

8693
static std::array<ControllerType, 4> s_controllers{};
8794
static std::array<bool, 4> s_wiimotes{};
@@ -308,7 +315,7 @@ void SetReadOnly(bool bEnabled)
308315

309316
bool IsRecordingInput()
310317
{
311-
return (s_playMode == MODE_RECORDING);
318+
return (s_playMode == PlayMode::Recording);
312319
}
313320

314321
bool IsRecordingInputFromSaveState()
@@ -328,12 +335,12 @@ bool IsJustStartingPlayingInputFromSaveState()
328335

329336
bool IsPlayingInput()
330337
{
331-
return (s_playMode == MODE_PLAYING);
338+
return (s_playMode == PlayMode::Playing);
332339
}
333340

334341
bool IsMovieActive()
335342
{
336-
return s_playMode != MODE_NONE;
343+
return s_playMode != PlayMode::None;
337344
}
338345

339346
bool IsReadOnly()
@@ -528,7 +535,7 @@ void ChangeWiiPads(bool instantly)
528535
bool BeginRecordingInput(const ControllerTypeArray& controllers,
529536
const WiimoteEnabledArray& wiimotes)
530537
{
531-
if (s_playMode != MODE_NONE ||
538+
if (s_playMode != PlayMode::None ||
532539
(controllers == ControllerTypeArray{} && wiimotes == WiimoteEnabledArray{}))
533540
return false;
534541

@@ -585,7 +592,7 @@ bool BeginRecordingInput(const ControllerTypeArray& controllers,
585592
Wiimote::ResetAllWiimotes();
586593
}
587594

588-
s_playMode = MODE_RECORDING;
595+
s_playMode = PlayMode::Recording;
589596
s_author = Config::Get(Config::MAIN_MOVIE_MOVIE_AUTHOR);
590597
s_temp_input.clear();
591598

@@ -937,7 +944,7 @@ void ReadHeader()
937944
// NOTE: Host Thread
938945
bool PlayInput(const std::string& movie_path, std::optional<std::string>* savestate_path)
939946
{
940-
if (s_playMode != MODE_NONE)
947+
if (s_playMode != PlayMode::None)
941948
return false;
942949

943950
File::IOFile recording_file(movie_path, "rb");
@@ -959,7 +966,7 @@ bool PlayInput(const std::string& movie_path, std::optional<std::string>* savest
959966
s_currentLagCount = 0;
960967
s_currentInputCount = 0;
961968

962-
s_playMode = MODE_PLAYING;
969+
s_playMode = PlayMode::Playing;
963970

964971
// Wiimotes cause desync issues if they're not reset before launching the game
965972
Wiimote::ResetAllWiimotes();
@@ -1139,18 +1146,18 @@ void LoadInput(const std::string& movie_path)
11391146
{
11401147
if (s_bReadOnly)
11411148
{
1142-
if (s_playMode != MODE_PLAYING)
1149+
if (s_playMode != PlayMode::Playing)
11431150
{
1144-
s_playMode = MODE_PLAYING;
1151+
s_playMode = PlayMode::Playing;
11451152
Core::UpdateWantDeterminism();
11461153
Core::DisplayMessage("Switched to playback", 2000);
11471154
}
11481155
}
11491156
else
11501157
{
1151-
if (s_playMode != MODE_RECORDING)
1158+
if (s_playMode != PlayMode::Recording)
11521159
{
1153-
s_playMode = MODE_RECORDING;
1160+
s_playMode = PlayMode::Recording;
11541161
Core::UpdateWantDeterminism();
11551162
Core::DisplayMessage("Switched to recording", 2000);
11561163
}
@@ -1317,18 +1324,18 @@ void EndPlayInput(bool cont)
13171324
// If !IsMovieActive(), changing s_playMode requires calling UpdateWantDeterminism
13181325
ASSERT(IsMovieActive());
13191326

1320-
s_playMode = MODE_RECORDING;
1327+
s_playMode = PlayMode::Recording;
13211328
Core::DisplayMessage("Reached movie end. Resuming recording.", 2000);
13221329
}
1323-
else if (s_playMode != MODE_NONE)
1330+
else if (s_playMode != PlayMode::None)
13241331
{
13251332
// We can be called by EmuThread during boot (CPU::State::PowerDown)
13261333
bool was_running = Core::IsRunningAndStarted() && !CPU::IsStepping();
13271334
if (was_running && Config::Get(Config::MAIN_MOVIE_PAUSE_MOVIE))
13281335
CPU::Break();
13291336
s_rerecords = 0;
13301337
s_currentByte = 0;
1331-
s_playMode = MODE_NONE;
1338+
s_playMode = PlayMode::None;
13321339
Core::DisplayMessage("Movie End.", 2000);
13331340
s_bRecordingFromSaveState = false;
13341341
// we don't clear these things because otherwise we can't resume playback if we load a movie

Source/Core/Core/Movie.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ class EncryptionKey;
3737
namespace Movie
3838
{
3939
// Enumerations and structs
40-
enum PlayMode
41-
{
42-
MODE_NONE = 0,
43-
MODE_RECORDING,
44-
MODE_PLAYING
45-
};
46-
4740
enum class ControllerType
4841
{
4942
None = 0,

0 commit comments

Comments
 (0)