Change Enable/Disable All to just a Disable All button.

This commit is contained in:
Henrik Rydgård 2023-03-23 10:32:11 +01:00
parent e21867315b
commit f5afc91f23
4 changed files with 41 additions and 16 deletions

View File

@ -255,12 +255,34 @@ std::wstring Path::ToWString() const {
}
#endif
std::string Path::ToVisualString() const {
std::string Path::ToVisualString(const char *relativeRoot) const {
if (type_ == PathType::CONTENT_URI) {
return AndroidContentURI(path_).ToVisualString();
#if PPSSPP_PLATFORM(WINDOWS)
} else if (type_ == PathType::NATIVE) {
return ReplaceAll(path_, "/", "\\");
// It can be useful to show the path as relative to the memstick
if (relativeRoot) {
std::string root = ReplaceAll(relativeRoot, "/", "\\");
std::string path = ReplaceAll(path_, "/", "\\");
if (startsWithNoCase(path, root)) {
return path.substr(root.size());
} else {
return path;
}
} else {
return ReplaceAll(path_, "/", "\\");
}
#else
if (relativeRoot) {
std::string root = relativeRoot;
if (startsWithNoCase(path_, root)) {
return path_.substr(root.size());
} else {
return path_;
}
} else {
return path_;
}
#endif
} else {
return path_;

View File

@ -92,7 +92,8 @@ public:
std::wstring ToWString() const;
#endif
std::string ToVisualString() const;
// Pass in a relative root to turn the path into a relative path - if it is one!
std::string ToVisualString(const char *relativeRoot = nullptr) const;
bool CanNavigateUp() const;
Path NavigateUp() const;

View File

@ -35,7 +35,7 @@
static const int FILE_CHECK_FRAME_INTERVAL = 53;
static Path GetGlobalCheatFile() {
static Path GetGlobalCheatFilePath() {
return GetSysDirectory(DIRECTORY_CHEATS) / "cheat.db";
}
@ -93,16 +93,20 @@ void CwCheatScreen::CreateViews() {
//leftColumn->Add(new Choice(cw->T("Add Cheat")))->OnClick.Handle(this, &CwCheatScreen::OnAddCheat);
leftColumn->Add(new ItemHeader(cw->T("Import Cheats")));
Path cheatPath = GetGlobalCheatFile();
Path cheatPath = GetGlobalCheatFilePath();
leftColumn->Add(new Choice(cheatPath.ToVisualString()))->OnClick.Handle(this, &CwCheatScreen::OnImportCheat);
std::string root = GetSysDirectory(DIRECTORY_MEMSTICK_ROOT).ToString();
leftColumn->Add(new Choice(cheatPath.ToVisualString(root.c_str())))->OnClick.Handle(this, &CwCheatScreen::OnImportCheat);
leftColumn->Add(new Choice(mm->T("Browse"), ImageID("I_FOLDER_OPEN")))->OnClick.Handle(this, &CwCheatScreen::OnImportBrowse);
errorMessageView_ = leftColumn->Add(new TextView(di->T("LoadingFailed")));
errorMessageView_->SetVisibility(V_GONE);
leftColumn->Add(new ItemHeader(cw->T("Options")));
leftColumn->Add(new ItemHeader(di->T("Options")));
#if !defined(MOBILE_DEVICE)
leftColumn->Add(new Choice(cw->T("Edit Cheat File")))->OnClick.Handle(this, &CwCheatScreen::OnEditCheatFile);
#endif
leftColumn->Add(new Choice(cw->T("Enable/Disable All")))->OnClick.Handle(this, &CwCheatScreen::OnEnableAll);
leftColumn->Add(new Choice(di->T("Disable All")))->OnClick.Handle(this, &CwCheatScreen::OnDisableAll);
leftColumn->Add(new PopupSliderChoice(&g_Config.iCwCheatRefreshRate, 1, 1000, cw->T("Refresh Rate"), 1, screenManager()));
rightScroll_ = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 0.5f));
@ -153,12 +157,10 @@ void CwCheatScreen::onFinish(DialogResult result) {
}
}
UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams &params) {
enableAllFlag_ = !enableAllFlag_;
// Flip all the switches.
UI::EventReturn CwCheatScreen::OnDisableAll(UI::EventParams &params) {
// Disable all the switches.
for (auto &info : fileInfo_) {
info.enabled = enableAllFlag_;
info.enabled = false;
}
if (!RebuildCheatFile(INDEX_ALL)) {
@ -215,14 +217,14 @@ UI::EventReturn CwCheatScreen::OnImportBrowse(UI::EventParams &params) {
// Show an error message?
}
RecreateViews();
// Chose a cheat file.
});
return UI::EVENT_DONE;
}
UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams &params) {
if (!ImportCheats(GetGlobalCheatFile())) {
if (!ImportCheats(GetGlobalCheatFilePath())) {
// Show an error message?
errorMessageView_->SetVisibility(UI::V_VISIBLE);
return UI::EVENT_DONE;
}

View File

@ -37,7 +37,7 @@ public:
UI::EventReturn OnImportCheat(UI::EventParams &params);
UI::EventReturn OnImportBrowse(UI::EventParams &params);
UI::EventReturn OnEditCheatFile(UI::EventParams &params);
UI::EventReturn OnEnableAll(UI::EventParams &params);
UI::EventReturn OnDisableAll(UI::EventParams &params);
void update() override;
void onFinish(DialogResult result) override;