big_picture: Improvements to UI settings (#4575)

This commit is contained in:
squidbus 2026-06-14 02:15:51 -07:00 committed by GitHub
parent 3590426ab8
commit 942834db32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 21 deletions

View File

@ -200,7 +200,8 @@ void Launch(char* executableName) {
}
SDL_Window* window =
SDL_CreateWindow("shadPS4 Big Picture Mode", 1280, 720, SDL_WINDOW_FULLSCREEN);
SDL_CreateWindow("shadPS4 Big Picture Mode", 1280, 720,
EmulatorSettings.IsFullScreen() ? SDL_WINDOW_FULLSCREEN : 0);
renderer = SDL_CreateRenderer(window, nullptr);
if (window == nullptr) {
@ -229,11 +230,19 @@ void Launch(char* executableName) {
ImGui_ImplSDL3_InitForSDLRenderer(window, renderer);
ImGui_ImplSDLRenderer3_Init(renderer);
GetGameIconInfo(gameIcons);
uiScale = static_cast<float>(EmulatorSettings.GetBigPictureScale() / 1000.f);
ImGuiEmuSettings::SettingsWindow settingsWindow(false);
float sliderScale = 1.0f;
auto applySettings = [&] {
uiScale = EmulatorSettings.GetBigPictureScale() / 1000.f;
sliderScale = uiScale;
GetGameIconInfo(gameIcons);
SDL_SetWindowFullscreen(window,
EmulatorSettings.IsFullScreen() ? SDL_WINDOW_FULLSCREEN : 0);
};
applySettings();
while (!done) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
@ -297,7 +306,6 @@ void Launch(char* executableName) {
ImGui::SetNextItemWidth(300.0f * uiScale);
static float sliderScale = 1.0f;
if (ImGui::IsWindowAppearing()) {
sliderScale = uiScale;
}
@ -317,6 +325,9 @@ void Launch(char* executableName) {
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - buttonsWidth);
if (ImGui::Button("Settings")) {
EmulatorSettings.SetBigPictureScale(static_cast<int>(uiScale * 1000));
EmulatorSettings.Save();
settingsWindow.Prepare();
showSettings = true;
}
@ -350,16 +361,7 @@ void Launch(char* executableName) {
}
if (showSettings) {
EmulatorSettings.SetBigPictureScale(static_cast<int>(uiScale * 1000));
EmulatorSettings.Save();
settingsWindow.DrawSettings(&showSettings);
// update when settings dialog closed
if (!showSettings) {
uiScale = static_cast<float>(EmulatorSettings.GetBigPictureScale() / 1000.f);
sliderScale = uiScale;
GetGameIconInfo(gameIcons);
}
settingsWindow.DrawSettings(&showSettings, applySettings);
}
ImGui::PopStyleVar(8);

View File

@ -202,7 +202,6 @@ SettingsWindow::SettingsWindow(bool gameRunning) : isGameRunning(gameRunning) {
currentProfile = "Global";
m_GameInstallDirs = EmulatorSettings.GetAllGameInstallDirs();
currentCategory = isGameRunning ? SettingsCategory::General : SettingsCategory::Profiles;
uiScale = static_cast<float>(EmulatorSettings.GetBigPictureScale() / 1000.f);
bool customConfigFound = false;
if (isGameRunning) {
@ -223,6 +222,10 @@ SettingsWindow::SettingsWindow(bool gameRunning) : isGameRunning(gameRunning) {
customConfigFound ? LoadSettings(runningGameSerial) : LoadSettings("Global");
}
void SettingsWindow::Prepare() {
uiScale = EmulatorSettings.GetBigPictureScale() / 1000.f;
}
void SettingsWindow::DeInit() {
EmulatorSettings.Load();
EmulatorSettings.SetBigPictureScale(static_cast<int>(uiScale * 1000));
@ -232,7 +235,7 @@ void SettingsWindow::DeInit() {
EmulatorSettings.Load(runningGameSerial);
}
}
void SettingsWindow::DrawSettings(bool* open) {
void SettingsWindow::DrawSettings(bool* open, const std::function<void()>& applySettings) {
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.06f, 0.06f, 0.06f, 1.00f)); // black
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.20f, 0.40f, 0.70f, 1.00f)); // blue
ImGui::PushStyleColor(ImGuiCol_HeaderHovered,
@ -253,7 +256,7 @@ void SettingsWindow::DrawSettings(bool* open) {
SetupWindow();
DrawCategoryTabs();
DrawMainContent(open);
DrawMainContent(open, applySettings);
ImGui::PopStyleVar(8);
ImGui::PopStyleColor(5);
@ -366,7 +369,7 @@ void SettingsWindow::AddCategory(std::string name,
ImGui::EndGroup();
}
void SettingsWindow::DrawMainContent(bool* open) {
void SettingsWindow::DrawMainContent(bool* open, const std::function<void()>& applySettings) {
ImVec4 settingsColor = ImVec4(0.1f, 0.1f, 0.12f, 0.8f); // Darker gray
ImGui::PushStyleColor(ImGuiCol_ChildBg, settingsColor);
ImGuiWindowFlags child_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
@ -442,6 +445,9 @@ void SettingsWindow::DrawMainContent(bool* open) {
} else {
ImGui::CloseCurrentPopup();
}
if (applySettings) {
applySettings();
}
}
ImGui::EndPopup();
@ -451,6 +457,9 @@ void SettingsWindow::DrawMainContent(bool* open) {
if (ImGui::Button("Cancel")) {
DeInit();
*open = false;
if (applySettings) {
applySettings();
}
}
}

View File

@ -3,6 +3,7 @@
#pragma once
#include <functional>
#include <map>
#include <variant>
#include <SDL3/SDL.h>
@ -18,7 +19,8 @@ class SettingsWindow {
public:
SettingsWindow(bool gameRunning);
void DrawSettings(bool* open);
void Prepare();
void DrawSettings(bool* open, const std::function<void()>& applySettings);
private:
enum class SettingsCategory {
@ -40,7 +42,7 @@ private:
void DeInit();
void GetProfileInfo();
void DrawMainContent(bool* open);
void DrawMainContent(bool* open, const std::function<void()>& applySettings);
void DrawSettingsTable(SettingsCategory);
void DrawProfileSelector();
void DrawGameFolderManager();

View File

@ -13,6 +13,7 @@ static std::optional<SettingsLayer> settingsLayer = std::nullopt;
SettingsLayer::SettingsLayer() {
AddLayer(this);
settingsWindow.Prepare();
}
SettingsLayer::~SettingsLayer() {}
@ -24,7 +25,7 @@ void SettingsLayer::Finish() {
void SettingsLayer::Draw() {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[IMGUI_FONT_SETTINGS_WINDOW]);
settingsWindow.DrawSettings(&running);
settingsWindow.DrawSettings(&running, nullptr);
ImGui::PopFont();
if (!running) {