Skip to content

Commit

Permalink
Windows: Browse for folder like Qt.
Browse files Browse the repository at this point in the history
Better to separate out the platform specific stuff.
  • Loading branch information
unknownbrackets committed Feb 17, 2019
1 parent 8b40f1a commit d19e59d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
25 changes: 10 additions & 15 deletions UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
#include "Core/HLE/sceUmd.h"

#ifdef _WIN32
#include "Windows/W32Util/ShellUtil.h"
#include "Windows/MainWindow.h"
// Unfortunate, for undef DrawText...
#include "Common/CommonWindows.h"
#endif

#ifdef ANDROID_NDK_PROFILER
Expand Down Expand Up @@ -467,18 +467,13 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#ifdef __ANDROID__
SetPath(g_Config.memStickDirectory);
#elif defined(USING_QT_UI)
System_SendMessage("browse_folder", "");
#elif defined(_WIN32)
#if PPSSPP_PLATFORM(UWP)
#elif defined(USING_QT_UI) || defined(USING_WIN_UI)
if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
System_SendMessage("browse_folder", "");
}
#elif PPSSPP_PLATFORM(UWP)
// TODO UWP
#else
I18NCategory *mm = GetI18NCategory("MainMenu");
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), mm->T("Choose folder"));
if (!folder.size())
return UI::EVENT_DONE;
SetPath(folder);
#endif
SetPath(g_Config.memStickDirectory);
#else
SetPath(getenv("HOME"));
#endif
Expand Down Expand Up @@ -526,7 +521,7 @@ void GameBrowser::Refresh() {
if (allowBrowsing_) {
topBar->Add(new Spacer(2.0f));
topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
#if defined(_WIN32) || defined(USING_QT_UI)
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
topBar->Add(new Choice(mm->T("Browse", "Browse..."), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
#else
topBar->Add(new Choice(mm->T("Home"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
Expand Down Expand Up @@ -908,7 +903,7 @@ void MainScreen::CreateViews() {
TextView *ver = rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))));
ver->SetSmall(true);
ver->SetClip(false);
#if defined(_WIN32) || defined(USING_QT_UI)
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
rightColumnItems->Add(new Choice(mm->T("Load","Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile);
#endif
rightColumnItems->Add(new Choice(mm->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings);
Expand Down
9 changes: 8 additions & 1 deletion Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
#include <shellapi.h>
#include <mmsystem.h>

#include "base/NativeApp.h"
#include "base/display.h"
#include "file/vfs.h"
#include "file/zip_read.h"
#include "base/NativeApp.h"
#include "i18n/i18n.h"
#include "profiler/profiler.h"
#include "thread/threadutil.h"
#include "util/text/utf8.h"
Expand Down Expand Up @@ -58,6 +59,7 @@
#include "Windows/GEDebugger/GEDebugger.h"

#include "Windows/W32Util/DialogManager.h"
#include "Windows/W32Util/ShellUtil.h"

#include "Windows/Debugger/CtrlDisAsmView.h"
#include "Windows/Debugger/CtrlMemView.h"
Expand Down Expand Up @@ -274,6 +276,11 @@ void System_SendMessage(const char *command, const char *parameter) {
}
} else if (!strcmp(command, "browse_file")) {
MainWindow::BrowseAndBoot("");
} else if (!strcmp(command, "browse_folder")) {
I18NCategory *mm = GetI18NCategory("MainMenu");
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), mm->T("Choose folder"));
if (folder.size())
NativeMessageReceived("browse_folderSelect", folder.c_str());
} else if (!strcmp(command, "bgImage_browse")) {
MainWindow::BrowseBackground();
} else if (!strcmp(command, "toggle_fullscreen")) {
Expand Down

0 comments on commit d19e59d

Please sign in to comment.