mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-27 19:25:58 +00:00
Merge pull request #6700 from lat9nq/fullscreen-enum
general: Implement FullscreenMode enumeration
This commit is contained in:
commit
d05e6003f0
|
@ -42,6 +42,11 @@ enum class CPUAccuracy : u32 {
|
||||||
Unsafe = 2,
|
Unsafe = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class FullscreenMode : u32 {
|
||||||
|
Borderless = 0,
|
||||||
|
Exclusive = 1,
|
||||||
|
};
|
||||||
|
|
||||||
/** The BasicSetting class is a simple resource manager. It defines a label and default value
|
/** The BasicSetting class is a simple resource manager. It defines a label and default value
|
||||||
* alongside the actual value of the setting for simpler and less-error prone use with frontend
|
* alongside the actual value of the setting for simpler and less-error prone use with frontend
|
||||||
* configurations. Setting a default value and label is required, though subclasses may deviate from
|
* configurations. Setting a default value and label is required, though subclasses may deviate from
|
||||||
|
@ -322,11 +327,11 @@ struct Values {
|
||||||
Setting<u16> resolution_factor{1, "resolution_factor"};
|
Setting<u16> resolution_factor{1, "resolution_factor"};
|
||||||
// *nix platforms may have issues with the borderless windowed fullscreen mode.
|
// *nix platforms may have issues with the borderless windowed fullscreen mode.
|
||||||
// Default to exclusive fullscreen on these platforms for now.
|
// Default to exclusive fullscreen on these platforms for now.
|
||||||
Setting<int> fullscreen_mode{
|
Setting<FullscreenMode> fullscreen_mode{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
0,
|
FullscreenMode::Borderless,
|
||||||
#else
|
#else
|
||||||
1,
|
FullscreenMode::Exclusive,
|
||||||
#endif
|
#endif
|
||||||
"fullscreen_mode"};
|
"fullscreen_mode"};
|
||||||
Setting<int> aspect_ratio{0, "aspect_ratio"};
|
Setting<int> aspect_ratio{0, "aspect_ratio"};
|
||||||
|
|
|
@ -1332,7 +1332,10 @@ void Config::SaveRendererValues() {
|
||||||
static_cast<u32>(Settings::values.renderer_backend.GetDefault()),
|
static_cast<u32>(Settings::values.renderer_backend.GetDefault()),
|
||||||
Settings::values.renderer_backend.UsingGlobal());
|
Settings::values.renderer_backend.UsingGlobal());
|
||||||
WriteGlobalSetting(Settings::values.vulkan_device);
|
WriteGlobalSetting(Settings::values.vulkan_device);
|
||||||
WriteGlobalSetting(Settings::values.fullscreen_mode);
|
WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()),
|
||||||
|
static_cast<u32>(Settings::values.fullscreen_mode.GetValue(global)),
|
||||||
|
static_cast<u32>(Settings::values.fullscreen_mode.GetDefault()),
|
||||||
|
Settings::values.fullscreen_mode.UsingGlobal());
|
||||||
WriteGlobalSetting(Settings::values.aspect_ratio);
|
WriteGlobalSetting(Settings::values.aspect_ratio);
|
||||||
WriteGlobalSetting(Settings::values.max_anisotropy);
|
WriteGlobalSetting(Settings::values.max_anisotropy);
|
||||||
WriteGlobalSetting(Settings::values.use_speed_limit);
|
WriteGlobalSetting(Settings::values.use_speed_limit);
|
||||||
|
|
|
@ -181,5 +181,6 @@ private:
|
||||||
// These metatype declarations cannot be in common/settings.h because core is devoid of QT
|
// These metatype declarations cannot be in common/settings.h because core is devoid of QT
|
||||||
Q_DECLARE_METATYPE(Settings::CPUAccuracy);
|
Q_DECLARE_METATYPE(Settings::CPUAccuracy);
|
||||||
Q_DECLARE_METATYPE(Settings::GPUAccuracy);
|
Q_DECLARE_METATYPE(Settings::GPUAccuracy);
|
||||||
|
Q_DECLARE_METATYPE(Settings::FullscreenMode);
|
||||||
Q_DECLARE_METATYPE(Settings::RendererBackend);
|
Q_DECLARE_METATYPE(Settings::RendererBackend);
|
||||||
Q_DECLARE_METATYPE(Settings::ShaderBackend);
|
Q_DECLARE_METATYPE(Settings::ShaderBackend);
|
||||||
|
|
|
@ -25,20 +25,6 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<int>* setting,
|
|
||||||
const QComboBox* combobox) {
|
|
||||||
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
|
|
||||||
setting->SetValue(combobox->currentIndex());
|
|
||||||
} else if (!Settings::IsConfiguringGlobal()) {
|
|
||||||
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
|
||||||
setting->SetGlobal(true);
|
|
||||||
} else {
|
|
||||||
setting->SetGlobal(false);
|
|
||||||
setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
|
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
|
||||||
const Settings::Setting<bool>* setting) {
|
const Settings::Setting<bool>* setting) {
|
||||||
if (setting->UsingGlobal()) {
|
if (setting->UsingGlobal()) {
|
||||||
|
|
|
@ -28,7 +28,20 @@ enum class CheckState {
|
||||||
// ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting
|
// ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting
|
||||||
void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,
|
void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,
|
||||||
const CheckState& tracker);
|
const CheckState& tracker);
|
||||||
void ApplyPerGameSetting(Settings::Setting<int>* setting, const QComboBox* combobox);
|
template <typename Type>
|
||||||
|
void ApplyPerGameSetting(Settings::Setting<Type>* setting, const QComboBox* combobox) {
|
||||||
|
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
|
||||||
|
setting->SetValue(static_cast<Type>(combobox->currentIndex()));
|
||||||
|
} else if (!Settings::IsConfiguringGlobal()) {
|
||||||
|
if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||||
|
setting->SetGlobal(true);
|
||||||
|
} else {
|
||||||
|
setting->SetGlobal(false);
|
||||||
|
setting->SetValue(static_cast<Type>(combobox->currentIndex() -
|
||||||
|
ConfigurationShared::USE_GLOBAL_OFFSET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sets a Qt UI element given a Settings::Setting
|
// Sets a Qt UI element given a Settings::Setting
|
||||||
void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting);
|
void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting);
|
||||||
|
|
|
@ -65,6 +65,7 @@ void ConfigureCpu::UpdateGroup(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCpu::ApplyConfiguration() {
|
void ConfigureCpu::ApplyConfiguration() {
|
||||||
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpu_accuracy, ui->accuracy);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_unfuse_fma,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_unfuse_fma,
|
||||||
ui->cpuopt_unsafe_unfuse_fma,
|
ui->cpuopt_unsafe_unfuse_fma,
|
||||||
cpuopt_unsafe_unfuse_fma);
|
cpuopt_unsafe_unfuse_fma);
|
||||||
|
@ -80,22 +81,6 @@ void ConfigureCpu::ApplyConfiguration() {
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check,
|
||||||
ui->cpuopt_unsafe_fastmem_check,
|
ui->cpuopt_unsafe_fastmem_check,
|
||||||
cpuopt_unsafe_fastmem_check);
|
cpuopt_unsafe_fastmem_check);
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
|
||||||
// Guard if during game and set to game-specific value
|
|
||||||
if (Settings::values.cpu_accuracy.UsingGlobal()) {
|
|
||||||
Settings::values.cpu_accuracy.SetValue(
|
|
||||||
static_cast<Settings::CPUAccuracy>(ui->accuracy->currentIndex()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ui->accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
|
||||||
Settings::values.cpu_accuracy.SetGlobal(true);
|
|
||||||
} else {
|
|
||||||
Settings::values.cpu_accuracy.SetGlobal(false);
|
|
||||||
Settings::values.cpu_accuracy.SetValue(static_cast<Settings::CPUAccuracy>(
|
|
||||||
ui->accuracy->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCpu::changeEvent(QEvent* event) {
|
void ConfigureCpu::changeEvent(QEvent* event) {
|
||||||
|
|
|
@ -98,7 +98,8 @@ void ConfigureGraphics::SetConfiguration() {
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend.GetValue()));
|
ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend.GetValue()));
|
||||||
ui->fullscreen_mode_combobox->setCurrentIndex(Settings::values.fullscreen_mode.GetValue());
|
ui->fullscreen_mode_combobox->setCurrentIndex(
|
||||||
|
static_cast<int>(Settings::values.fullscreen_mode.GetValue()));
|
||||||
ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue());
|
ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue());
|
||||||
} else {
|
} else {
|
||||||
ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend);
|
ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend);
|
||||||
|
@ -310,8 +311,9 @@ void ConfigureGraphics::SetupPerGameUI() {
|
||||||
|
|
||||||
ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label,
|
ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label,
|
||||||
Settings::values.aspect_ratio.GetValue(true));
|
Settings::values.aspect_ratio.GetValue(true));
|
||||||
ConfigurationShared::SetColoredComboBox(ui->fullscreen_mode_combobox, ui->fullscreen_mode_label,
|
ConfigurationShared::SetColoredComboBox(
|
||||||
Settings::values.fullscreen_mode.GetValue(true));
|
ui->fullscreen_mode_combobox, ui->fullscreen_mode_label,
|
||||||
|
static_cast<int>(Settings::values.fullscreen_mode.GetValue(true)));
|
||||||
ConfigurationShared::InsertGlobalItem(
|
ConfigurationShared::InsertGlobalItem(
|
||||||
ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true)));
|
ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||||
// Subtract 2 if configuring per-game (separator and "use global configuration" take 2 slots)
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy);
|
||||||
const auto gpu_accuracy = static_cast<Settings::GPUAccuracy>(
|
|
||||||
ui->gpu_accuracy->currentIndex() -
|
|
||||||
((Settings::IsConfiguringGlobal()) ? 0 : ConfigurationShared::USE_GLOBAL_OFFSET));
|
|
||||||
|
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
||||||
ui->anisotropic_filtering_combobox);
|
ui->anisotropic_filtering_combobox);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
|
||||||
|
@ -63,20 +59,6 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||||
use_caches_gc);
|
use_caches_gc);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time,
|
||||||
ui->use_fast_gpu_time, use_fast_gpu_time);
|
ui->use_fast_gpu_time, use_fast_gpu_time);
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
|
||||||
// Must guard in case of a during-game configuration when set to be game-specific.
|
|
||||||
if (Settings::values.gpu_accuracy.UsingGlobal()) {
|
|
||||||
Settings::values.gpu_accuracy.SetValue(gpu_accuracy);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ui->gpu_accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
|
||||||
Settings::values.gpu_accuracy.SetGlobal(true);
|
|
||||||
} else {
|
|
||||||
Settings::values.gpu_accuracy.SetGlobal(false);
|
|
||||||
Settings::values.gpu_accuracy.SetValue(gpu_accuracy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
|
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
|
||||||
|
|
|
@ -2513,7 +2513,7 @@ void GMainWindow::ShowFullscreen() {
|
||||||
ui.menubar->hide();
|
ui.menubar->hide();
|
||||||
statusBar()->hide();
|
statusBar()->hide();
|
||||||
|
|
||||||
if (Settings::values.fullscreen_mode.GetValue() == 1) {
|
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
|
||||||
showFullScreen();
|
showFullScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2528,7 +2528,7 @@ void GMainWindow::ShowFullscreen() {
|
||||||
} else {
|
} else {
|
||||||
UISettings::values.renderwindow_geometry = render_window->saveGeometry();
|
UISettings::values.renderwindow_geometry = render_window->saveGeometry();
|
||||||
|
|
||||||
if (Settings::values.fullscreen_mode.GetValue() == 1) {
|
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
|
||||||
render_window->showFullScreen();
|
render_window->showFullScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2545,7 +2545,7 @@ void GMainWindow::ShowFullscreen() {
|
||||||
|
|
||||||
void GMainWindow::HideFullscreen() {
|
void GMainWindow::HideFullscreen() {
|
||||||
if (ui.action_Single_Window_Mode->isChecked()) {
|
if (ui.action_Single_Window_Mode->isChecked()) {
|
||||||
if (Settings::values.fullscreen_mode.GetValue() == 1) {
|
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
|
||||||
showNormal();
|
showNormal();
|
||||||
restoreGeometry(UISettings::values.geometry);
|
restoreGeometry(UISettings::values.geometry);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2559,7 +2559,7 @@ void GMainWindow::HideFullscreen() {
|
||||||
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
|
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
|
||||||
ui.menubar->show();
|
ui.menubar->show();
|
||||||
} else {
|
} else {
|
||||||
if (Settings::values.fullscreen_mode.GetValue() == 1) {
|
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
|
||||||
render_window->showNormal();
|
render_window->showNormal();
|
||||||
render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
|
render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -124,7 +124,7 @@ void EmuWindow_SDL2::OnResize() {
|
||||||
|
|
||||||
void EmuWindow_SDL2::Fullscreen() {
|
void EmuWindow_SDL2::Fullscreen() {
|
||||||
switch (Settings::values.fullscreen_mode.GetValue()) {
|
switch (Settings::values.fullscreen_mode.GetValue()) {
|
||||||
case 1: // Exclusive fullscreen
|
case Settings::FullscreenMode::Exclusive:
|
||||||
// Set window size to render size before entering fullscreen -- SDL does not resize to
|
// Set window size to render size before entering fullscreen -- SDL does not resize to
|
||||||
// display dimensions in this mode.
|
// display dimensions in this mode.
|
||||||
// TODO: Multiply the window size by resolution_factor (for both docked modes)
|
// TODO: Multiply the window size by resolution_factor (for both docked modes)
|
||||||
|
@ -140,7 +140,7 @@ void EmuWindow_SDL2::Fullscreen() {
|
||||||
LOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError());
|
LOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError());
|
||||||
LOG_INFO(Frontend, "Attempting to use borderless fullscreen...");
|
LOG_INFO(Frontend, "Attempting to use borderless fullscreen...");
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case 0: // Borderless window
|
case Settings::FullscreenMode::Borderless:
|
||||||
if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) {
|
if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue