mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-25 18:46:55 +01:00
ui: Add Open Cemu folder & delete shader cache buttons (#524)
* Add option to open UserDataPath folder * Add option to remove shader caches Co-authored-by: ssimco <ssimco-github@proton.me>
This commit is contained in:
parent
cbdf381b31
commit
8162477dc1
@ -71,6 +71,7 @@ enum
|
|||||||
// file
|
// file
|
||||||
MAINFRAME_MENU_ID_FILE_LOAD = 20100,
|
MAINFRAME_MENU_ID_FILE_LOAD = 20100,
|
||||||
MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE,
|
MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE,
|
||||||
|
MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER,
|
||||||
MAINFRAME_MENU_ID_FILE_EXIT,
|
MAINFRAME_MENU_ID_FILE_EXIT,
|
||||||
MAINFRAME_MENU_ID_FILE_END_EMULATION,
|
MAINFRAME_MENU_ID_FILE_END_EMULATION,
|
||||||
MAINFRAME_MENU_ID_FILE_RECENT_0,
|
MAINFRAME_MENU_ID_FILE_RECENT_0,
|
||||||
@ -160,6 +161,7 @@ EVT_MOVE(MainWindow::OnMove)
|
|||||||
// file menu
|
// file menu
|
||||||
EVT_MENU(MAINFRAME_MENU_ID_FILE_LOAD, MainWindow::OnFileMenu)
|
EVT_MENU(MAINFRAME_MENU_ID_FILE_LOAD, MainWindow::OnFileMenu)
|
||||||
EVT_MENU(MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MainWindow::OnInstallUpdate)
|
EVT_MENU(MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MainWindow::OnInstallUpdate)
|
||||||
|
EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, MainWindow::OnOpenCemuFolder)
|
||||||
EVT_MENU(MAINFRAME_MENU_ID_FILE_EXIT, MainWindow::OnFileExit)
|
EVT_MENU(MAINFRAME_MENU_ID_FILE_EXIT, MainWindow::OnFileExit)
|
||||||
EVT_MENU(MAINFRAME_MENU_ID_FILE_END_EMULATION, MainWindow::OnFileMenu)
|
EVT_MENU(MAINFRAME_MENU_ID_FILE_END_EMULATION, MainWindow::OnFileMenu)
|
||||||
EVT_MENU_RANGE(MAINFRAME_MENU_ID_FILE_RECENT_0 + 0, MAINFRAME_MENU_ID_FILE_RECENT_LAST, MainWindow::OnFileMenu)
|
EVT_MENU_RANGE(MAINFRAME_MENU_ID_FILE_RECENT_0 + 0, MAINFRAME_MENU_ID_FILE_RECENT_LAST, MainWindow::OnFileMenu)
|
||||||
@ -616,6 +618,11 @@ void MainWindow::OnFileMenu(wxCommandEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnOpenCemuFolder(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLaunchDefaultApplication(ActiveSettings::GetUserDataPath().wstring());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::OnInstallUpdate(wxCommandEvent& event)
|
void MainWindow::OnInstallUpdate(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -1976,7 +1983,8 @@ void MainWindow::RecreateMenu()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_fileMenuSeparator1 = m_fileMenu->AppendSeparator();
|
m_fileMenuSeparator1 = m_fileMenu->AppendSeparator();
|
||||||
|
m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder"));
|
||||||
|
m_fileMenu->AppendSeparator();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
void OnMouseWheel(wxMouseEvent& event);
|
void OnMouseWheel(wxMouseEvent& event);
|
||||||
void OnClose(wxCloseEvent& event);
|
void OnClose(wxCloseEvent& event);
|
||||||
void OnFileMenu(wxCommandEvent& event);
|
void OnFileMenu(wxCommandEvent& event);
|
||||||
|
void OnOpenCemuFolder(wxCommandEvent& event);
|
||||||
void OnLaunchFromFile(wxLaunchGameEvent& event);
|
void OnLaunchFromFile(wxLaunchGameEvent& event);
|
||||||
void OnInstallUpdate(wxCommandEvent& event);
|
void OnInstallUpdate(wxCommandEvent& event);
|
||||||
void OnFileExit(wxCommandEvent& event);
|
void OnFileExit(wxCommandEvent& event);
|
||||||
|
@ -47,6 +47,25 @@ void _stripPathFilename(fs::path& path)
|
|||||||
path = path.parent_path();
|
path = path.parent_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<fs::path> _getCachesPaths(const TitleId& titleId)
|
||||||
|
{
|
||||||
|
std::list<fs::path> cachePaths{
|
||||||
|
ActiveSettings::GetCachePath(L"shaderCache/driver/vk/{:016x}.bin", titleId),
|
||||||
|
ActiveSettings::GetCachePath(L"shaderCache/precompiled/{:016x}_spirv.bin", titleId),
|
||||||
|
ActiveSettings::GetCachePath(L"shaderCache/precompiled/{:016x}_gl.bin", titleId),
|
||||||
|
ActiveSettings::GetCachePath(L"shaderCache/transferable/{:016x}_shaders.bin", titleId),
|
||||||
|
ActiveSettings::GetCachePath(L"shaderCache/transferable/{:016x}_vkpipeline.bin", titleId)};
|
||||||
|
|
||||||
|
cachePaths.remove_if(
|
||||||
|
[](const fs::path& cachePath)
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
return !fs::exists(cachePath, ec);
|
||||||
|
});
|
||||||
|
|
||||||
|
return cachePaths;
|
||||||
|
}
|
||||||
|
|
||||||
wxGameList::wxGameList(wxWindow* parent, wxWindowID id)
|
wxGameList::wxGameList(wxWindow* parent, wxWindowID id)
|
||||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, GetStyleFlags(Style::kList)), m_style(Style::kList)
|
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, GetStyleFlags(Style::kList)), m_style(Style::kList)
|
||||||
{
|
{
|
||||||
@ -504,6 +523,8 @@ enum ContextMenuEntries
|
|||||||
kContextMenuEditGraphicPacks,
|
kContextMenuEditGraphicPacks,
|
||||||
kContextMenuEditGameProfile,
|
kContextMenuEditGameProfile,
|
||||||
|
|
||||||
|
kContextMenuRemoveCache,
|
||||||
|
|
||||||
kContextMenuStyleList,
|
kContextMenuStyleList,
|
||||||
kContextMenuStyleIcon,
|
kContextMenuStyleIcon,
|
||||||
kContextMenuStyleIconSmall,
|
kContextMenuStyleIconSmall,
|
||||||
@ -540,6 +561,9 @@ void wxGameList::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
menu.Append(kContextMenuUpdateFolder, _("&Update directory"))->Enable(gameInfo.HasUpdate());
|
menu.Append(kContextMenuUpdateFolder, _("&Update directory"))->Enable(gameInfo.HasUpdate());
|
||||||
menu.Append(kContextMenuDLCFolder, _("&DLC directory"))->Enable(gameInfo.HasAOC());
|
menu.Append(kContextMenuDLCFolder, _("&DLC directory"))->Enable(gameInfo.HasAOC());
|
||||||
|
|
||||||
|
menu.AppendSeparator();
|
||||||
|
menu.Append(kContextMenuRemoveCache, _("&Remove shader caches"))->Enable(!_getCachesPaths(gameInfo.GetBaseTitleId()).empty());
|
||||||
|
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
menu.Append(kContextMenuEditGraphicPacks, _("&Edit graphic packs"));
|
menu.Append(kContextMenuEditGraphicPacks, _("&Edit graphic packs"));
|
||||||
menu.Append(kContextMenuEditGameProfile, _("&Edit game profile"));
|
menu.Append(kContextMenuEditGameProfile, _("&Edit game profile"));
|
||||||
@ -647,6 +671,11 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event)
|
|||||||
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(path))));
|
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(path))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kContextMenuRemoveCache:
|
||||||
|
{
|
||||||
|
RemoveCache(_getCachesPaths(gameInfo.GetBaseTitleId()), gameInfo.GetTitleName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case kContextMenuEditGraphicPacks:
|
case kContextMenuEditGraphicPacks:
|
||||||
{
|
{
|
||||||
wxTitleIdEvent open_event(wxEVT_OPEN_GRAPHIC_PACK, title_id);
|
wxTitleIdEvent open_event(wxEVT_OPEN_GRAPHIC_PACK, title_id);
|
||||||
@ -1055,6 +1084,26 @@ void wxGameList::HandleTitleListCallback(CafeTitleListCallbackEvent* evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGameList::RemoveCache(const std::list<fs::path>& cachePaths, const std::string& titleName)
|
||||||
|
{
|
||||||
|
wxMessageDialog dialog(this, fmt::format(fmt::runtime(_("Remove the shader caches for {}?").ToStdString()), titleName), _("Remove shader caches"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION);
|
||||||
|
dialog.SetYesNoLabels(_("Yes"), _("No"));
|
||||||
|
|
||||||
|
const auto dialogResult = dialog.ShowModal();
|
||||||
|
if (dialogResult != wxID_YES)
|
||||||
|
return;
|
||||||
|
std::list<std::string> errs;
|
||||||
|
for (const fs::path& cachePath : cachePaths)
|
||||||
|
{
|
||||||
|
if (std::error_code ec; !fs::remove(cachePath, ec))
|
||||||
|
errs.emplace_back(fmt::format("{} : {}", cachePath.string(), ec.message()));
|
||||||
|
}
|
||||||
|
if (errs.empty())
|
||||||
|
wxMessageDialog(this, _("The shader caches were removed!"), _("Shader caches removed"), wxCENTRE | wxOK | wxICON_INFORMATION).ShowModal();
|
||||||
|
else
|
||||||
|
wxMessageDialog(this, fmt::format(fmt::runtime(_("Failed to remove the shader caches:\n{}").ToStdString()), fmt::join(errs, "\n")), _("Error"), wxCENTRE | wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
void wxGameList::AsyncWorkerThread()
|
void wxGameList::AsyncWorkerThread()
|
||||||
{
|
{
|
||||||
while (m_async_worker_active)
|
while (m_async_worker_active)
|
||||||
|
@ -111,6 +111,8 @@ private:
|
|||||||
|
|
||||||
void HandleTitleListCallback(struct CafeTitleListCallbackEvent* evt);
|
void HandleTitleListCallback(struct CafeTitleListCallbackEvent* evt);
|
||||||
|
|
||||||
|
void RemoveCache(const std::list<fs::path>& cachePath, const std::string& titleName);
|
||||||
|
|
||||||
void AsyncWorkerThread();
|
void AsyncWorkerThread();
|
||||||
void RequestLoadIconAsync(TitleId titleId);
|
void RequestLoadIconAsync(TitleId titleId);
|
||||||
bool QueryIconForTitle(TitleId titleId, int& icon, int& iconSmall);
|
bool QueryIconForTitle(TitleId titleId, int& icon, int& iconSmall);
|
||||||
|
Loading…
Reference in New Issue
Block a user