diff --git a/pcsx2/Recording/InputRecordingFile.cpp b/pcsx2/Recording/InputRecordingFile.cpp index ea21982dac..81bcfa828d 100644 --- a/pcsx2/Recording/InputRecordingFile.cpp +++ b/pcsx2/Recording/InputRecordingFile.cpp @@ -130,26 +130,10 @@ bool InputRecordingFile::open(const wxString path, bool newRecording) bool InputRecordingFile::OpenNew(const wxString& path, bool fromSavestate) { - if (fromSavestate) - { - if (CoreThread.IsOpen()) - { - if (open(path, true)) - { - savestate.fromSavestate = true; - return true; - } - } - else - inputRec::consoleLog("Game is not open, aborting playing input recording which starts on a save-state."); + if (!open(path, true)) return false; - } - else if (open(path, true)) - { - savestate.fromSavestate = false; - return true; - } - return false; + savestate.fromSavestate = fromSavestate; + return true; } bool InputRecordingFile::OpenExisting(const wxString& path) diff --git a/pcsx2/Recording/NewRecordingFrame.cpp b/pcsx2/Recording/NewRecordingFrame.cpp index a34117d1f3..a79a0f6275 100644 --- a/pcsx2/Recording/NewRecordingFrame.cpp +++ b/pcsx2/Recording/NewRecordingFrame.cpp @@ -33,13 +33,10 @@ NewRecordingFrame::NewRecordingFrame(wxWindow* parent) m_filePicker = new wxFilePickerCtrl(panel, MenuIds_New_Recording_Frame_File, wxEmptyString, "File", L"p2m2 file(*.p2m2)|*.p2m2", wxDefaultPosition, wxDefaultSize, wxFLP_SAVE | wxFLP_OVERWRITE_PROMPT | wxFLP_USE_TEXTCTRL); m_authorInput = new wxTextCtrl(panel, MenuIds_New_Recording_Frame_Author, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); - wxArrayString choices; - choices.Add("Current Frame"); - choices.Add("Power-On"); - m_fromChoice = new wxChoice(panel, MenuIds_New_Recording_Frame_From, wxDefaultPosition, wxDefaultSize, choices); - m_fromChoice->SetSelection(0); + m_fromChoice = new wxChoice(panel, MenuIds_New_Recording_Frame_From, wxDefaultPosition, wxDefaultSize, NULL); - m_startRecording = new wxButton(panel, wxID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize); + m_startRecording = new wxButton(panel, wxID_OK, _("Browse Required"), wxDefaultPosition, wxDefaultSize); + m_startRecording->Enable(false); m_cancelRecording = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize); fgs->Add(m_fileLabel, 1); @@ -58,6 +55,45 @@ NewRecordingFrame::NewRecordingFrame(wxWindow* parent) panel->SetSizer(container); panel->GetSizer()->Fit(this); Centre(); + + m_fileBrowsed = false; + m_filePicker->GetPickerCtrl()->Bind(wxEVT_FILEPICKER_CHANGED, &NewRecordingFrame::OnFileDirChange, this); + m_filePicker->Bind(wxEVT_FILEPICKER_CHANGED, &NewRecordingFrame::OnFileChanged, this); +} + +int NewRecordingFrame::ShowModal(const bool isCoreThreadOpen) +{ + static const char* choices[2] = {"Boot", "Current Frame"}; + m_fromChoice->Set(wxArrayString(1 + isCoreThreadOpen, &choices[0])); + m_fromChoice->SetSelection(isCoreThreadOpen); + return wxDialog::ShowModal(); +} + +void NewRecordingFrame::OnFileDirChange(wxFileDirPickerEvent& event) +{ + m_filePicker->wxFileDirPickerCtrlBase::OnFileDirChange(event); + m_fileBrowsed = true; + EnableOkBox(); +} + +void NewRecordingFrame::OnFileChanged(wxFileDirPickerEvent& event) +{ + EnableOkBox(); +} + +void NewRecordingFrame::EnableOkBox() +{ + if (m_filePicker->GetPath().length() == 0) + { + m_fileBrowsed = false; + m_startRecording->SetLabel(_("Browse Required")); + m_startRecording->Enable(false); + } + else if (m_fileBrowsed) + { + m_startRecording->SetLabel(_("Start")); + m_startRecording->Enable(true); + } } wxString NewRecordingFrame::GetFile() const diff --git a/pcsx2/Recording/NewRecordingFrame.h b/pcsx2/Recording/NewRecordingFrame.h index e4268245c0..d8655f6d77 100644 --- a/pcsx2/Recording/NewRecordingFrame.h +++ b/pcsx2/Recording/NewRecordingFrame.h @@ -32,14 +32,21 @@ class NewRecordingFrame : public wxDialog { public: NewRecordingFrame(wxWindow* parent); + int ShowModal(const bool isCoreThreadOpen); wxString GetFile() const; wxString GetAuthor() const; int GetFrom() const; +protected: + void OnFileDirChange(wxFileDirPickerEvent& event); + void OnFileChanged(wxFileDirPickerEvent& event); + void EnableOkBox(); + private: wxStaticText* m_fileLabel; wxFilePickerCtrl* m_filePicker; + bool m_fileBrowsed; wxStaticText* m_authorLabel; wxTextCtrl* m_authorInput; wxStaticText* m_fromLabel; diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index c201f58050..41e1c94f3a 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -956,9 +956,9 @@ void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent& event) NewRecordingFrame* newRecordingFrame = wxGetApp().GetNewRecordingFramePtr(); if (newRecordingFrame) { - if (newRecordingFrame->ShowModal() != wxID_CANCEL) + if (newRecordingFrame->ShowModal(CoreThread.IsOpen()) != wxID_CANCEL) { - if (g_InputRecording.Create(newRecordingFrame->GetFile(), !newRecordingFrame->GetFrom(), newRecordingFrame->GetAuthor())) + if (g_InputRecording.Create(newRecordingFrame->GetFile(), newRecordingFrame->GetFrom(), newRecordingFrame->GetAuthor())) { if (!g_InputRecording.GetInputRecordingData().FromSaveState()) StartInputRecording();