Delay checking for active backend until you click the Backend popup

This commit is contained in:
Henrik Rydgård
2025-08-30 15:39:57 +02:00
parent 539abb8d4f
commit f83b9c511d
3 changed files with 24 additions and 8 deletions
+5
View File
@@ -96,6 +96,11 @@ std::string ChopTitle(const std::string &title) {
}
UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
if (!callbackExecuted_ && preOpenCallback_) {
preOpenCallback_(this);
callbackExecuted_ = true;
}
restoreFocus_ = HasFocus();
auto category = GetI18NCategory(category_);
+7
View File
@@ -236,6 +236,10 @@ public:
return hidden_.find(c) != hidden_.end();
}
void SetPreOpenCallback(std::function<void(PopupMultiChoice *)> callback) {
preOpenCallback_ = callback;
}
UI::Event OnChoice;
protected:
@@ -259,6 +263,9 @@ private:
bool restoreFocus_ = false;
std::set<int> hidden_;
std::map<int, ImageID> icons_;
std::function<void(PopupMultiChoice *)> preOpenCallback_;
bool callbackExecuted_ = false;
};
// Allows passing in a dynamic vector of strings. Saves the string.
+12 -8
View File
@@ -267,15 +267,19 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
#if !PPSSPP_PLATFORM(UWP)
static const char *renderingBackend[] = { "OpenGL", "Direct3D 9", "Direct3D 11", "Vulkan" };
PopupMultiChoice *renderingBackendChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iGPUBackend, gr->T("Backend"), renderingBackend, (int)GPUBackend::OPENGL, ARRAY_SIZE(renderingBackend), I18NCat::GRAPHICS, screenManager()));
renderingBackendChoice->HideChoice(1);
renderingBackendChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend);
renderingBackendChoice->SetPreOpenCallback([this](UI::PopupMultiChoice *choice) {
// Don't filter until the last possible moment, since it involves trying to initialize Vulkan, if we were
// started in OpenGL mode on Android.
choice->HideChoice(1);
choice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingBackend);
if (!g_Config.IsBackendEnabled(GPUBackend::OPENGL))
renderingBackendChoice->HideChoice((int)GPUBackend::OPENGL);
if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11))
renderingBackendChoice->HideChoice((int)GPUBackend::DIRECT3D11);
if (!g_Config.IsBackendEnabled(GPUBackend::VULKAN))
renderingBackendChoice->HideChoice((int)GPUBackend::VULKAN);
if (!g_Config.IsBackendEnabled(GPUBackend::OPENGL))
choice->HideChoice((int)GPUBackend::OPENGL);
if (!g_Config.IsBackendEnabled(GPUBackend::DIRECT3D11))
choice->HideChoice((int)GPUBackend::DIRECT3D11);
if (!g_Config.IsBackendEnabled(GPUBackend::VULKAN))
choice->HideChoice((int)GPUBackend::VULKAN);
});
if (!IsFirstInstance()) {
// If we're not the first instance, can't save the setting, and it requires a restart, so...