From 0d3b8c08086402f25f4982736967a161ddd43c16 Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sat, 31 May 2014 11:40:37 +0100 Subject: [PATCH 1/3] Add Menu and INI option to autostart emulation --- rpcs3/Gui/MainFrame.cpp | 48 ++++++++++++++++++++++++++++++++++++++++- rpcs3/Gui/MainFrame.h | 1 + rpcs3/Ini.h | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 6b5d46f1d4..879d8f498e 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -39,6 +39,7 @@ enum IDs id_tools_fnid_generator, id_help_about, id_update_dbg, + id_boot_game_and_run, }; wxString GetPaneName() @@ -65,6 +66,7 @@ MainFrame::MainFrame() wxMenu* menu_boot = new wxMenu(); menubar->Append(menu_boot, "Boot"); menu_boot->Append(id_boot_game, "Boot game"); + menu_boot->Append(id_boot_game_and_run, "Boot game and start"); menu_boot->Append(id_install_pkg, "Install PKG"); menu_boot->AppendSeparator(); menu_boot->Append(id_boot_elf, "Boot (S)ELF"); @@ -109,6 +111,7 @@ MainFrame::MainFrame() // Events Bind(wxEVT_MENU, &MainFrame::BootGame, this, id_boot_game); + Bind(wxEVT_MENU, &MainFrame::BootGameAndRun, this, id_boot_game_and_run); Bind(wxEVT_MENU, &MainFrame::InstallPkg, this, id_install_pkg); Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf); @@ -184,6 +187,11 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) if(Emu.BootGame(ctrl.GetPath().ToStdString())) { ConLog.Success("Game: boot done."); + + if (Ini.CPUAlwaysStart.GetValue() && Emu.IsReady()) + { + Emu.Run(); + } } else { @@ -191,6 +199,40 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) } } +void MainFrame::BootGameAndRun(wxCommandEvent& WXUNUSED(event)) +{ + bool stopped = false; + + if (Emu.IsRunning()) + { + Emu.Pause(); + stopped = true; + } + + wxDirDialog ctrl(this, L"Select game folder", wxEmptyString); + + if (ctrl.ShowModal() == wxID_CANCEL) + { + if (stopped) Emu.Resume(); + return; + } + + Emu.Stop(); + + if (Emu.BootGame(ctrl.GetPath().ToStdString())) + { + ConLog.Success("Game: boot done."); + } + else + { + ConLog.Error("PS3 executable not found in selected folder (%s)", ctrl.GetPath().wx_str()); + } + + if (Emu.IsReady()) + { + Emu.Run(); + } +} void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) { bool stopped = false; @@ -378,8 +420,9 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) wxCheckBox* chbox_hle_logging = new wxCheckBox(p_hle, wxID_ANY, "Log all SysCalls"); wxCheckBox* chbox_hle_hook_stfunc = new wxCheckBox(p_hle, wxID_ANY, "Hook static functions"); wxCheckBox* chbox_hle_savetty = new wxCheckBox(p_hle, wxID_ANY, "Save TTY output to file"); - wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes"); + wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes"); wxCheckBox* chbox_hle_hide_debug_console = new wxCheckBox(p_hle, wxID_ANY, "Hide Debug Console"); + wxCheckBox* chbox_cpu_always_start = new wxCheckBox(p_cpu, wxID_ANY, "Always start after boot"); //cbox_cpu_decoder->Append("DisAsm"); cbox_cpu_decoder->Append("Interpreter & DisAsm"); @@ -457,6 +500,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) chbox_hle_savetty ->SetValue(Ini.HLESaveTTY.GetValue()); chbox_hle_exitonstop ->SetValue(Ini.HLEExitOnStop.GetValue()); chbox_hle_hide_debug_console->SetValue(Ini.HLEHideDebugConsole.GetValue()); + chbox_cpu_always_start ->SetValue(Ini.CPUAlwaysStart.GetValue()); cbox_cpu_decoder ->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0); cbox_spu_decoder ->SetSelection(Ini.SPUDecoderMode.GetValue() ? Ini.SPUDecoderMode.GetValue() - 1 : 0); @@ -497,6 +541,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) // Core s_subpanel_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_cpu_decoder->Add(chbox_cpu_ignore_rwerrors, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_cpu_decoder->Add(chbox_cpu_always_start, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_cpu->Add(s_round_spu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); // Graphics @@ -570,6 +615,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.HLELogLvl.SetValue(cbox_hle_loglvl->GetSelection()); Ini.SysLanguage.SetValue(cbox_sys_lang->GetSelection()); Ini.HLEHideDebugConsole.SetValue(chbox_hle_hide_debug_console->GetValue()); + Ini.CPUAlwaysStart.SetValue(chbox_cpu_always_start->GetValue()); Ini.Save(); } diff --git a/rpcs3/Gui/MainFrame.h b/rpcs3/Gui/MainFrame.h index f0262bac0e..15ab70c11e 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -23,6 +23,7 @@ private: void OnQuit(wxCloseEvent& event); void BootGame(wxCommandEvent& event); + void BootGameAndRun(wxCommandEvent& event); void InstallPkg(wxCommandEvent& event); void BootElf(wxCommandEvent& event); void Pause(wxCommandEvent& event); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index aa3263667f..ded1a92c81 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -119,6 +119,7 @@ public: IniEntry SysLanguage; IniEntry SkipPamf; IniEntry HLEHideDebugConsole; + IniEntry CPUAlwaysStart; IniEntry PadHandlerLStickLeft; IniEntry PadHandlerLStickDown; @@ -217,6 +218,7 @@ public: { CPUDecoderMode.Load(2); CPUIgnoreRWErrors.Load(true); + CPUAlwaysStart.Load(false); SPUDecoderMode.Load(1); GSRenderMode.Load(1); GSResolution.Load(4); @@ -269,6 +271,7 @@ public: { CPUDecoderMode.Save(); CPUIgnoreRWErrors.Save(); + CPUAlwaysStart.Save(); SPUDecoderMode.Save(); GSRenderMode.Save(); GSResolution.Save(); From 934856c3501b33b13762ec46140fe08b6ea5244a Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sun, 1 Jun 2014 14:10:26 +0100 Subject: [PATCH 2/3] Moved autostart to HLE Section --- rpcs3/Gui/MainFrame.cpp | 10 +++++----- rpcs3/Ini.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 879d8f498e..66dff765ab 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -188,7 +188,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) { ConLog.Success("Game: boot done."); - if (Ini.CPUAlwaysStart.GetValue() && Emu.IsReady()) + if (Ini.HLEAlwaysStart.GetValue() && Emu.IsReady()) { Emu.Run(); } @@ -422,7 +422,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) wxCheckBox* chbox_hle_savetty = new wxCheckBox(p_hle, wxID_ANY, "Save TTY output to file"); wxCheckBox* chbox_hle_exitonstop = new wxCheckBox(p_hle, wxID_ANY, "Exit RPCS3 when process finishes"); wxCheckBox* chbox_hle_hide_debug_console = new wxCheckBox(p_hle, wxID_ANY, "Hide Debug Console"); - wxCheckBox* chbox_cpu_always_start = new wxCheckBox(p_cpu, wxID_ANY, "Always start after boot"); + wxCheckBox* chbox_hle_always_start = new wxCheckBox(p_hle, wxID_ANY, "Always start after boot"); //cbox_cpu_decoder->Append("DisAsm"); cbox_cpu_decoder->Append("Interpreter & DisAsm"); @@ -500,7 +500,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) chbox_hle_savetty ->SetValue(Ini.HLESaveTTY.GetValue()); chbox_hle_exitonstop ->SetValue(Ini.HLEExitOnStop.GetValue()); chbox_hle_hide_debug_console->SetValue(Ini.HLEHideDebugConsole.GetValue()); - chbox_cpu_always_start ->SetValue(Ini.CPUAlwaysStart.GetValue()); + chbox_hle_always_start ->SetValue(Ini.HLEAlwaysStart.GetValue()); cbox_cpu_decoder ->SetSelection(Ini.CPUDecoderMode.GetValue() ? Ini.CPUDecoderMode.GetValue() - 1 : 0); cbox_spu_decoder ->SetSelection(Ini.SPUDecoderMode.GetValue() ? Ini.SPUDecoderMode.GetValue() - 1 : 0); @@ -541,7 +541,6 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) // Core s_subpanel_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_cpu_decoder->Add(chbox_cpu_ignore_rwerrors, wxSizerFlags().Border(wxALL, 5).Expand()); - s_round_cpu_decoder->Add(chbox_cpu_always_start, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_cpu->Add(s_round_spu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); // Graphics @@ -570,6 +569,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) s_subpanel_hle->Add(chbox_hle_savetty, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_hle_exitonstop, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel_hle->Add(chbox_hle_hide_debug_console, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel_hle->Add(chbox_hle_always_start, wxSizerFlags().Border(wxALL, 5).Expand()); // System s_subpanel_system->Add(s_round_sys_lang, wxSizerFlags().Border(wxALL, 5).Expand()); @@ -615,7 +615,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.HLELogLvl.SetValue(cbox_hle_loglvl->GetSelection()); Ini.SysLanguage.SetValue(cbox_sys_lang->GetSelection()); Ini.HLEHideDebugConsole.SetValue(chbox_hle_hide_debug_console->GetValue()); - Ini.CPUAlwaysStart.SetValue(chbox_cpu_always_start->GetValue()); + Ini.HLEAlwaysStart.SetValue(chbox_hle_always_start->GetValue()); Ini.Save(); } diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index ded1a92c81..e00af60e68 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -119,7 +119,7 @@ public: IniEntry SysLanguage; IniEntry SkipPamf; IniEntry HLEHideDebugConsole; - IniEntry CPUAlwaysStart; + IniEntry HLEAlwaysStart; IniEntry PadHandlerLStickLeft; IniEntry PadHandlerLStickDown; @@ -218,7 +218,7 @@ public: { CPUDecoderMode.Load(2); CPUIgnoreRWErrors.Load(true); - CPUAlwaysStart.Load(false); + HLEAlwaysStart.Load(false); SPUDecoderMode.Load(1); GSRenderMode.Load(1); GSResolution.Load(4); @@ -271,7 +271,7 @@ public: { CPUDecoderMode.Save(); CPUIgnoreRWErrors.Save(); - CPUAlwaysStart.Save(); + HLEAlwaysStart.Save(); SPUDecoderMode.Save(); GSRenderMode.Save(); GSResolution.Save(); From dab71d01c15b10f0576b0fcdf7740923ef8d84a2 Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sun, 1 Jun 2014 19:36:08 +0100 Subject: [PATCH 3/3] Add Remove Game option to Gameviewer Can right click game to remove from list and installation --- rpcs3/Gui/GameViewer.cpp | 75 +++++++++++++++++++++++++++++++++++++++- rpcs3/Gui/GameViewer.h | 7 ++-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index 7f79afc6cf..bf63a00ef7 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -10,8 +10,12 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent) m_path = "/dev_hdd0/game/"; + m_popup = new wxMenu(); + m_popup->Append(0, _T("Remove Game")); + Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this); Bind(wxEVT_LIST_COL_CLICK, &GameViewer::OnColClick, this); + Bind(wxEVT_LIST_ITEM_RIGHT_CLICK, &GameViewer::RightClick, this); Refresh(); } @@ -36,7 +40,7 @@ int wxCALLBACK ListItemCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortinfo long index2 = pGameViewer->FindItem(-1, item2); wxString string1 = pGameViewer->GetItemText(index1, Column); wxString string2 = pGameViewer->GetItemText(index2, Column); - + if (string1.Cmp(string2) < 0) { return SortAscending ? -1 : 1; @@ -84,6 +88,7 @@ void GameViewer::LoadGames() m_games.push_back(info->name); } } + dir.Close(); //ConLog.Write("path: %s", m_path.wx_str()); //ConLog.Write("folders count: %d", m_games.GetCount()); @@ -163,3 +168,71 @@ void GameViewer::DClick(wxListEvent& event) } Emu.Run(); } + +void GameViewer::RightClick(wxListEvent& event) +{ + m_popup->Destroy(m_popup->FindItemByPosition(0)); + + wxMenuItem *pMenuItemA = m_popup->Append(event.GetIndex(), _T("Remove Game")); + Bind(wxEVT_MENU, &GameViewer::RemoveGame, this, event.GetIndex()); + PopupMenu(m_popup, event.GetPoint()); +} + +class WxDirDeleteTraverser : public wxDirTraverser +{ +public: + virtual wxDirTraverseResult OnFile(const wxString& filename) + { + if (!wxRemoveFile(filename)){ + ConLog.Error("Couldn't delete File: %s", fmt::ToUTF8(filename).c_str()); + } + return wxDIR_CONTINUE; + } + virtual wxDirTraverseResult OnDir(const wxString& dirname) + { + wxDir dir(dirname); + dir.Traverse(*this); + if (!wxRmDir(dirname)){ + //this get triggered a few times while clearing folders + //but if this gets reimplented we should probably warn + //if directories can't be removed + } + return wxDIR_CONTINUE; + } +}; + +void GameViewer::RemoveGame(wxCommandEvent& event) +{ + wxString GameName = this->GetItemText(event.GetId(), 5); + + Emu.GetVFS().Init(m_path); + vfsDir dir(m_path); + if (!dir.IsOpened()) return; + + std::string sPath = dir.GetPath(); + std::string sGameFolder = GameName.mb_str().data(); + + Emu.GetVFS().UnMountAll(); + + sPath.erase(0, 1); + + RemoveFolder(sPath + sGameFolder); + + Refresh(); + +} + +bool GameViewer::RemoveFolder(std::string localPath) +{ + //TODO: replace wxWidgetsSpecific filesystem stuff + if (wxDirExists(fmt::FromUTF8(localPath))){ + WxDirDeleteTraverser deleter; + wxDir dir(localPath); + dir.Traverse(deleter); + return TRUE; + } + else{ + return FALSE; + } + +} \ No newline at end of file diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index d78c241e0f..c503c830b0 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -242,7 +242,7 @@ class GameViewer : public wxListView std::vector m_games; std::vector m_game_data; ColumnsArr m_columns; - + wxMenu* m_popup; public: ListSortInfo SortInfo; @@ -260,7 +260,10 @@ public: void LoadSettings(); void Refresh(); + void RemoveGame(wxCommandEvent& event); + bool RemoveFolder(std::string localPath); private: virtual void DClick(wxListEvent& event); - void OnColClick(wxListEvent& event); + virtual void OnColClick(wxListEvent& event); + virtual void RightClick(wxListEvent& event); };