Handle an empty path in the game browser.

This commit is contained in:
Henrik Rydgård committed 2021-08-04 23:22:43 +02:00
1 parent 4aef413c13
commit dbd3d8ca2a
2 files changed
+12 -2

No files matched your search

+7 -1
View File
@@ -144,11 +144,14 @@ void PathBrowser::HandlePath() {
std::unique_lock<std::mutex> guard(pendingLock_);
std::vector<File::FileInfo> results;
Path lastPath;
Path lastPath("NONSENSE THAT WONT EQUAL A PATH");
while (!pendingStop_) {
while (lastPath == pendingPath_ && !pendingCancel_) {
pendingCond_.wait(guard);
}
if (pendingStop_) {
break;
}
lastPath = pendingPath_;
bool success = false;
if (lastPath.Type() == PathType::HTTP) {
@@ -156,6 +159,9 @@ void PathBrowser::HandlePath() {
results.clear();
success = LoadRemoteFileList(lastPath, &pendingCancel_, results);
guard.lock();
} else if (lastPath.empty()) {
results.clear();
success = true;
} else {
guard.unlock();
results.clear();
+5 -1
View File
@@ -816,7 +816,7 @@ void GameBrowser::Refresh() {
}
// Show a button to toggle pinning at the very end.
if (browseFlags_ & BrowseFlags::PIN) {
if ((browseFlags_ & BrowseFlags::PIN) && !path_.GetPath().empty()) {
std::string caption = IsCurrentPathPinned() ? "-" : "+";
if (!*gridStyle_) {
caption = IsCurrentPathPinned() ? mm->T("UnpinPath", "Unpin") : mm->T("PinPath", "Pin");
@@ -825,6 +825,10 @@ void GameBrowser::Refresh() {
OnClick.Handle(this, &GameBrowser::PinToggleClick);
}
if (path_.GetPath().empty()) {
Add(new TextView(mm->T("UseBrowseOrLoad", "Use Browse to choose a folder, or Load to choose a file.")));
}
if (!lastText_.empty() && gameButtons.empty()) {
Add(new Spacer());
Add(new Choice(lastText_, new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT)))->OnClick.Handle(this, &GameBrowser::LastClick);