Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1014 from RachelBryk/active-movie
Add an IsMovieActive function.
  • Loading branch information
skidau committed Sep 7, 2014
2 parents 741c0e2 + 5a163ec commit a21ad12
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI_DeviceIPL.cpp
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions Source/Core/Core/HW/SI.cpp
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/Wiimote.cpp
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -330,7 +330,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();
}
Expand Down Expand Up @@ -384,7 +384,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();
}
Expand Down
11 changes: 8 additions & 3 deletions Source/Core/Core/Movie.cpp
Expand Up @@ -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++)
Expand Down Expand Up @@ -198,7 +198,7 @@ void Init()
for (auto& disp : g_InputDisplay)
disp.clear();

if (!IsPlayingInput() && !IsRecordingInput())
if (!IsMovieActive())
{
g_bRecordingFromSaveState = false;
g_rerecords = 0;
Expand Down Expand Up @@ -273,7 +273,7 @@ void SetReadOnly(bool bEnabled)
void FrameSkipping()
{
// Frameskipping will desync movie playback
if (!IsPlayingInput() && !IsRecordingInput())
if (!IsMovieActive())
{
std::lock_guard<std::mutex> lk(cs_frameSkip);

Expand Down Expand Up @@ -310,6 +310,11 @@ bool IsPlayingInput()
return (g_playMode == MODE_PLAYING);
}

bool IsMovieActive()
{
return g_playMode != MODE_NONE;
}

bool IsReadOnly()
{
return g_bReadOnly;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Movie.h
Expand Up @@ -123,6 +123,7 @@ bool IsRecordingInputFromSaveState();
bool IsJustStartingRecordingInputFromSaveState();
bool IsJustStartingPlayingInputFromSaveState();
bool IsPlayingInput();
bool IsMovieActive();
bool IsReadOnly();
u64 GetRecordingStartTime();

Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/State.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -437,7 +437,7 @@ void LoadAs(const std::string& filename)
{
std::lock_guard<std::mutex> 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");
Expand Down Expand Up @@ -607,10 +607,10 @@ void UndoLoadState()
std::lock_guard<std::mutex> 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
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/ConfigMain.cpp
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinWX/FrameTools.cpp
Expand Up @@ -1097,7 +1097,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();

Expand Down Expand Up @@ -1644,7 +1644,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);
Expand Down

0 comments on commit a21ad12

Please sign in to comment.