From 5b9123b3c5ccb337a4fc515df2e5ed3251818d56 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 15 Oct 2013 13:28:09 +0200 Subject: [PATCH] Main screen: Add Browse button on Windows to choose a folder easily --- UI/MainScreen.cpp | 22 ++++++++++++++++------ Windows/W32Util/ShellUtil.cpp | 2 +- Windows/W32Util/ShellUtil.h | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index b3d7d6de4a..3556323277 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -42,6 +42,11 @@ #include "GPU/GPUInterface.h" #include "i18n/i18n.h" +#ifdef _WIN32 +#include "Windows/W32Util/ShellUtil.h" +#include "Windows/WndMainWindow.h" +#endif + #ifdef USING_QT_UI #include #include @@ -50,12 +55,6 @@ #include -#ifdef _WIN32 -namespace MainWindow { - void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false); -} -#endif - class GameButton : public UI::Clickable { public: GameButton(const std::string &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0) @@ -344,7 +343,16 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) { } UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) { +#ifdef ANDROID path_.SetPath(g_Config.memCardDirectory); +#elif defined(_WIN32) + I18NCategory *m = GetI18NCategory("MainMenu"); + std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), m->T("Choose folder")); + if (!folder.size()) + return UI::EVENT_DONE; + path_.SetPath(folder); +#endif + g_Config.currentDirectory = path_.GetPath(); Refresh(); return UI::EVENT_DONE; @@ -365,6 +373,8 @@ void GameBrowser::Refresh() { topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER, 0.7f, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 1.0f, pathMargins))); #ifdef ANDROID topBar->Add(new Choice(m->T("Home")))->OnClick.Handle(this, &GameBrowser::HomeClick); +#elif defined(_WIN32) + topBar->Add(new Choice(m->T("Browse", "Browse...")))->OnClick.Handle(this, &GameBrowser::HomeClick); #endif ChoiceStrip *layoutChoice = topBar->Add(new ChoiceStrip(ORIENT_HORIZONTAL)); layoutChoice->AddChoice(I_GRID); diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index cb4a3be724..030b449d4d 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -12,7 +12,7 @@ namespace W32Util { - std::string BrowseForFolder(HWND parent, char *title) + std::string BrowseForFolder(HWND parent, const char *title) { std::wstring titleString = ConvertUTF8ToWString(title); diff --git a/Windows/W32Util/ShellUtil.h b/Windows/W32Util/ShellUtil.h index 8d55f33553..09dd35ae4a 100644 --- a/Windows/W32Util/ShellUtil.h +++ b/Windows/W32Util/ShellUtil.h @@ -6,7 +6,7 @@ namespace W32Util { - std::string BrowseForFolder(HWND parent, char *title); + std::string BrowseForFolder(HWND parent, const char *title); bool BrowseForFileName (bool _bLoad, HWND _hParent, const wchar_t*_pTitle, const wchar_t *_pInitialFolder,const wchar_t *_pFilter,const wchar_t*_pExtension, std::string& _strFileName);