From 5a163ec5e6f6fba5f4901f02071042211d6a25eb Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Sat, 6 Sep 2014 23:44:25 -0400 Subject: [PATCH] Add an IsMovieActive function. Makes things a bit simpler, since this is a common check. --- Source/Core/Core/HW/EXI_DeviceIPL.cpp | 2 +- Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp | 2 +- Source/Core/Core/HW/SI.cpp | 7 +++---- Source/Core/Core/HW/Wiimote.cpp | 2 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 4 ++-- Source/Core/Core/Movie.cpp | 11 ++++++++--- Source/Core/Core/Movie.h | 1 + Source/Core/Core/State.cpp | 10 +++++----- Source/Core/DolphinWX/ConfigMain.cpp | 2 +- Source/Core/DolphinWX/FrameTools.cpp | 4 ++-- 10 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Source/Core/Core/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI_DeviceIPL.cpp index 32a180123b..111925a640 100644 --- a/Source/Core/Core/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI_DeviceIPL.cpp @@ -338,7 +338,7 @@ u32 CEXIIPL::GetGCTime() u64 ltime = 0; static const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000 - if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) + if (Movie::IsMovieActive()) { ltime = Movie::GetRecordingStartTime(); diff --git a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp index f2222df5ba..5348a4ba72 100644 --- a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp @@ -500,7 +500,7 @@ void CEXIMemoryCard::DoState(PointerWrap &p) // for movie sync, we need to save/load memory card contents (and other data) in savestates. // otherwise, we'll assume the user wants to keep their memcards and saves separate, // unless we're loading (in which case we let the savestate contents decide, in order to stay aligned with them). - bool storeContents = (Movie::IsRecordingInput() || Movie::IsPlayingInput()); + bool storeContents = (Movie::IsMovieActive()); p.Do(storeContents); if (storeContents) diff --git a/Source/Core/Core/HW/SI.cpp b/Source/Core/Core/HW/SI.cpp index b36d4028fd..e1512ed3cd 100644 --- a/Source/Core/Core/HW/SI.cpp +++ b/Source/Core/Core/HW/SI.cpp @@ -230,8 +230,7 @@ void DoState(PointerWrap &p) // if we had to create a temporary device, discard it if we're not loading. // also, if no movie is active, we'll assume the user wants to keep their current devices // instead of the ones they had when the savestate was created. - if (p.GetMode() != PointerWrap::MODE_READ || - (!Movie::IsRecordingInput() && !Movie::IsPlayingInput())) + if (p.GetMode() != PointerWrap::MODE_READ || !Movie::IsMovieActive()) { delete pSaveDevice; } @@ -257,7 +256,7 @@ void Init() g_Channel[i].m_InHi.Hex = 0; g_Channel[i].m_InLo.Hex = 0; - if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) + if (Movie::IsMovieActive()) AddDevice(Movie::IsUsingPad(i) ? (Movie::IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i); else if (!NetPlay::IsNetPlayRunning()) AddDevice(SConfig::GetInstance().m_SIDevice[i], i); @@ -531,7 +530,7 @@ void RunSIBuffer() int GetTicksToNextSIPoll() { // Poll for input at regular intervals (once per frame) when playing or recording a movie - if (Movie::IsPlayingInput() || Movie::IsRecordingInput()) + if (Movie::IsMovieActive()) { if (Movie::IsNetPlayRecording()) return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate / 2; diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index ae55df1c63..433422a467 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -53,7 +53,7 @@ void Initialize(void* const hwnd, bool wait) WiimoteReal::Initialize(wait); // reload Wiimotes with our settings - if (Movie::IsPlayingInput() || Movie::IsRecordingInput()) + if (Movie::IsMovieActive()) Movie::ChangeWiiPads(); } diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 682c783a72..cecd637ecf 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -329,7 +329,7 @@ bool Wiimote::Step() m_rumble->controls[0]->control_ref->State(m_rumble_on); // when a movie is active, this button status update is disabled (moved), because movies only record data reports. - if (!(Movie::IsPlayingInput() || Movie::IsRecordingInput()) || NetPlay::IsNetPlayRunning()) + if (!(Movie::IsMovieActive()) || NetPlay::IsNetPlayRunning()) { UpdateButtonsStatus(); } @@ -383,7 +383,7 @@ void Wiimote::UpdateButtonsStatus() void Wiimote::GetCoreData(u8* const data) { // when a movie is active, the button update happens here instead of Wiimote::Step, to avoid potential desync issues. - if (Movie::IsPlayingInput() || Movie::IsRecordingInput() || NetPlay::IsNetPlayRunning()) + if (Movie::IsMovieActive() || NetPlay::IsNetPlayRunning()) { UpdateButtonsStatus(); } diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 3834f417b8..6411f4abbb 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -113,7 +113,7 @@ static bool IsMovieHeader(u8 magic[4]) std::string GetInputDisplay() { - if (!IsPlayingInput() && !IsRecordingInput()) + if (!IsMovieActive()) { g_numPads = 0; for (int i = 0; i < 4; i++) @@ -198,7 +198,7 @@ void Init() for (auto& disp : g_InputDisplay) disp.clear(); - if (!IsPlayingInput() && !IsRecordingInput()) + if (!IsMovieActive()) { g_bRecordingFromSaveState = false; g_rerecords = 0; @@ -273,7 +273,7 @@ void SetReadOnly(bool bEnabled) void FrameSkipping() { // Frameskipping will desync movie playback - if (!IsPlayingInput() && !IsRecordingInput()) + if (!IsMovieActive()) { std::lock_guard lk(cs_frameSkip); @@ -310,6 +310,11 @@ bool IsPlayingInput() return (g_playMode == MODE_PLAYING); } +bool IsMovieActive() +{ + return g_playMode != MODE_NONE; +} + bool IsReadOnly() { return g_bReadOnly; diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index c83438cc74..40bf54224d 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -123,6 +123,7 @@ bool IsRecordingInputFromSaveState(); bool IsJustStartingRecordingInputFromSaveState(); bool IsJustStartingPlayingInputFromSaveState(); bool IsPlayingInput(); +bool IsMovieActive(); bool IsReadOnly(); u64 GetRecordingStartTime(); diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 87b0c6c97e..aee3213c13 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -236,9 +236,9 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args) File::Rename(filename + ".dtm", File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav.dtm"); } - if ((Movie::IsRecordingInput() || Movie::IsPlayingInput()) && !Movie::IsJustStartingRecordingInputFromSaveState()) + if ((Movie::IsMovieActive()) && !Movie::IsJustStartingRecordingInputFromSaveState()) Movie::SaveRecording(filename + ".dtm"); - else if (!Movie::IsRecordingInput() && !Movie::IsPlayingInput()) + else if (!Movie::IsMovieActive()) File::Delete(filename + ".dtm"); File::IOFile f(filename, "wb"); @@ -437,7 +437,7 @@ void LoadAs(const std::string& filename) { std::lock_guard lk(g_cs_undo_load_buffer); SaveToBuffer(g_undo_load_buffer); - if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) + if (Movie::IsMovieActive()) Movie::SaveRecording(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); else if (File::Exists(File::GetUserPath(D_STATESAVES_IDX) +"undo.dtm")) File::Delete(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); @@ -607,10 +607,10 @@ void UndoLoadState() std::lock_guard lk(g_cs_undo_load_buffer); if (!g_undo_load_buffer.empty()) { - if (File::Exists(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm") || (!Movie::IsRecordingInput() && !Movie::IsPlayingInput())) + if (File::Exists(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm") || (!Movie::IsMovieActive())) { LoadFromBuffer(g_undo_load_buffer); - if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) + if (Movie::IsMovieActive()) Movie::LoadInput(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm"); } else diff --git a/Source/Core/DolphinWX/ConfigMain.cpp b/Source/Core/DolphinWX/ConfigMain.cpp index 34261e8792..485525c93c 100644 --- a/Source/Core/DolphinWX/ConfigMain.cpp +++ b/Source/Core/DolphinWX/ConfigMain.cpp @@ -757,7 +757,7 @@ void CConfigMain::CreateGUIControls() { sbGamecubeDevSettings->Add(GCSIDeviceText[i], 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 0); sbGamecubeDevSettings->Add(GCSIDevice[i], 1, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 0); - if (NetPlay::IsNetPlayRunning() || Movie::IsRecordingInput() || Movie::IsPlayingInput()) + if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive()) { GCSIDevice[i]->Disable(); } diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 7341e62336..0bc0b80165 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1084,7 +1084,7 @@ void CFrame::DoStop() // TODO: Show the author/description dialog here if (Movie::IsRecordingInput()) DoRecordingSave(); - if (Movie::IsPlayingInput() || Movie::IsRecordingInput()) + if (Movie::IsMovieActive()) Movie::EndPlayInput(false); NetPlay::StopGame(); @@ -1631,7 +1631,7 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_RESET)->Enable(Running || Paused); GetMenuBar()->FindItem(IDM_RECORD)->Enable(!Movie::IsRecordingInput()); GetMenuBar()->FindItem(IDM_PLAYRECORD)->Enable(!Initialized); - GetMenuBar()->FindItem(IDM_RECORDEXPORT)->Enable(Movie::IsPlayingInput() || Movie::IsRecordingInput()); + GetMenuBar()->FindItem(IDM_RECORDEXPORT)->Enable(Movie::IsMovieActive()); GetMenuBar()->FindItem(IDM_FRAMESTEP)->Enable(Running || Paused); GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(Running || Paused); GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->Enable(Running || Paused);