Minor UI upgrades on MemStickScreen and system settings

This commit is contained in:
Henrik Rydgård 2023-07-15 12:22:00 +02:00
parent c363cccc58
commit 7144e01472
3 changed files with 20 additions and 8 deletions

View file

@ -851,15 +851,17 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
auto vr = GetI18NCategory(I18NCat::VR); auto vr = GetI18NCategory(I18NCat::VR);
auto th = GetI18NCategory(I18NCat::THEMES); auto th = GetI18NCategory(I18NCat::THEMES);
systemSettings->Add(new ItemHeader(sy->T("UI"))); systemSettings->Add(new ItemHeader(sy->T("RetroAchievements")));
auto retro = systemSettings->Add(new Choice(sy->T("RetroAchievements"))); auto retro = systemSettings->Add(new Choice(sy->T("RetroAchievements")));
retro->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { retro->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn {
screenManager()->push(new RetroAchievementsSettingsScreen(gamePath_)); screenManager()->push(new RetroAchievementsSettingsScreen(gamePath_));
return UI::EVENT_DONE; return UI::EVENT_DONE;
}); });
retro->SetIcon(ImageID("I_RETROACHIEVEMENTS_LOGO")); retro->SetIcon(ImageID("I_RETROACHIEVEMENTS_LOGO"));
systemSettings->Add(new ItemHeader(sy->T("UI")));
auto langCodeToName = [](const char *value) -> std::string { auto langCodeToName = [](const char *value) -> std::string {
auto &mapping = g_Config.GetLangValuesMapping(); auto &mapping = g_Config.GetLangValuesMapping();
auto iter = mapping.find(value); auto iter = mapping.find(value);
@ -1232,20 +1234,21 @@ UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) {
File::Delete(bgPng); File::Delete(bgPng);
File::Delete(bgJpg); File::Delete(bgJpg);
UIBackgroundShutdown(); UIBackgroundShutdown();
RecreateViews();
} else { } else {
auto sy = GetI18NCategory(I18NCat::SYSTEM); auto sy = GetI18NCategory(I18NCat::SYSTEM);
System_BrowseForImage(sy->T("Set UI background..."), [](const std::string &value, int) { System_BrowseForImage(sy->T("Set UI background..."), [=](const std::string &value, int) {
if (!value.empty()) { if (!value.empty()) {
Path dest = GetSysDirectory(DIRECTORY_SYSTEM) / (endsWithNoCase(value, ".jpg") ? "background.jpg" : "background.png"); Path dest = GetSysDirectory(DIRECTORY_SYSTEM) / (endsWithNoCase(value, ".jpg") ? "background.jpg" : "background.png");
File::Copy(Path(value), dest); File::Copy(Path(value), dest);
} }
// It will init again automatically. We can't init outside a frame on Vulkan. // It will init again automatically. We can't init outside a frame on Vulkan.
UIBackgroundShutdown(); UIBackgroundShutdown();
RecreateViews();
}); });
} }
// Change to a browse or clear button. // Change to a browse or clear button.
RecreateViews();
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }

View file

@ -48,6 +48,7 @@
#include "UI/MemStickScreen.h" #include "UI/MemStickScreen.h"
#include "UI/MainScreen.h" #include "UI/MainScreen.h"
#include "UI/MiscScreens.h" #include "UI/MiscScreens.h"
#include "UI/OnScreenDisplay.h"
static bool FolderSeemsToBeUsed(Path newMemstickFolder) { static bool FolderSeemsToBeUsed(Path newMemstickFolder) {
// Inspect the potential new folder, quickly. // Inspect the potential new folder, quickly.
@ -245,6 +246,9 @@ void MemStickScreen::CreateViews() {
leftColumn->Add(new TextView(iz->T("DataCanBeShared", "Data can be shared between PPSSPP regular/Gold.")))->SetBullet(true); leftColumn->Add(new TextView(iz->T("DataCanBeShared", "Data can be shared between PPSSPP regular/Gold.")))->SetBullet(true);
// TODO: Show current folder here if we have one set. // TODO: Show current folder here if we have one set.
} }
errorNoticeView_ = leftColumn->Add(new NoticeView(NoticeLevel::WARN, iz->T("Cancelled - try again"), ""));
errorNoticeView_->SetVisibility(UI::V_GONE);
if (choice_ == CHOICE_BROWSE_FOLDER || choice_ == CHOICE_SET_MANUAL) { if (choice_ == CHOICE_BROWSE_FOLDER || choice_ == CHOICE_SET_MANUAL) {
UI::View *extraView = nullptr; UI::View *extraView = nullptr;
if (!g_Config.memStickDirectory.empty()) { if (!g_Config.memStickDirectory.empty()) {
@ -312,7 +316,6 @@ UI::EventReturn MemStickScreen::OnChoiceClick(UI::EventParams &params) {
// Change the confirm button to match the choice, // Change the confirm button to match the choice,
// and change the text that we show. // and change the text that we show.
RecreateViews(); RecreateViews();
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -455,7 +458,10 @@ UI::EventReturn MemStickScreen::Browse(UI::EventParams &params) {
done_ = true; done_ = true;
return; return;
} }
errorNoticeView_->SetVisibility(UI::V_GONE);
screenManager()->push(new ConfirmMemstickMoveScreen(pendingMemStickFolder, initialSetup_)); screenManager()->push(new ConfirmMemstickMoveScreen(pendingMemStickFolder, initialSetup_));
}, [=]() {
errorNoticeView_->SetVisibility(UI::V_VISIBLE);
}); });
return UI::EVENT_DONE; return UI::EVENT_DONE;
} }
@ -555,15 +561,15 @@ void ConfirmMemstickMoveScreen::CreateViews() {
leftColumn->Add(new TextView(iz->T("Selected PSP Data Folder"), ALIGN_LEFT, false)); leftColumn->Add(new TextView(iz->T("Selected PSP Data Folder"), ALIGN_LEFT, false));
if (!initialSetup_) { if (!initialSetup_) {
leftColumn->Add(new TextView(iz->T("PPSSPP will restart after the change"), ALIGN_LEFT, false)); leftColumn->Add(new NoticeView(NoticeLevel::WARN, iz->T("PPSSPP will restart after the change"), ""));
} }
leftColumn->Add(new TextView(newMemstickFolder_.ToVisualString(), ALIGN_LEFT, false)); leftColumn->Add(new TextView(newMemstickFolder_.ToVisualString(), ALIGN_LEFT, false));
std::string newFreeSpaceText = std::string(iz->T("Free space")) + ": " + FormatSpaceString(freeSpaceNew); std::string newFreeSpaceText = std::string(iz->T("Free space")) + ": " + FormatSpaceString(freeSpaceNew);
leftColumn->Add(new TextView(newFreeSpaceText, ALIGN_LEFT, false)); leftColumn->Add(new TextView(newFreeSpaceText, ALIGN_LEFT, false));
if (existingFilesInNewFolder_) { if (existingFilesInNewFolder_) {
leftColumn->Add(new TextView(iz->T("Already contains PSP data"), ALIGN_LEFT, false)); leftColumn->Add(new NoticeView(NoticeLevel::SUCCESS, iz->T("Already contains PSP data"), ""));
if (!moveData_) { if (!moveData_) {
leftColumn->Add(new TextView(iz->T("No data will be changed"), ALIGN_LEFT, false)); leftColumn->Add(new NoticeView(NoticeLevel::INFO, iz->T("No data will be changed"), ""));
} }
} }
if (!error_.empty()) { if (!error_.empty()) {

View file

@ -29,6 +29,8 @@
#include "UI/MiscScreens.h" #include "UI/MiscScreens.h"
class NoticeView;
// MemStickScreen - let's you configure your memory stick directory. // MemStickScreen - let's you configure your memory stick directory.
// Currently only useful for Android. // Currently only useful for Android.
class MemStickScreen : public UIDialogScreenWithBackground { class MemStickScreen : public UIDialogScreenWithBackground {
@ -75,6 +77,7 @@ private:
UI::EventReturn OnChoiceClick(UI::EventParams &params); UI::EventReturn OnChoiceClick(UI::EventParams &params);
SettingInfoMessage *settingInfo_ = nullptr; SettingInfoMessage *settingInfo_ = nullptr;
NoticeView *errorNoticeView_ = nullptr;
bool initialSetup_; bool initialSetup_;
bool storageBrowserWorking_; bool storageBrowserWorking_;