2022-04-23 03:59:50 -05:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-09-12 19:06:13 -05:00
|
|
|
|
2023-06-27 18:13:54 -05:00
|
|
|
#include <version>
|
2023-05-21 14:43:01 -05:00
|
|
|
#if __cpp_lib_chrono >= 201907L
|
|
|
|
#include <chrono>
|
2023-06-27 18:13:54 -05:00
|
|
|
#include <exception>
|
|
|
|
#include <stdexcept>
|
2023-05-21 14:43:01 -05:00
|
|
|
#endif
|
2023-06-10 22:40:39 -05:00
|
|
|
#include <compare>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <forward_list>
|
2023-05-04 02:44:53 -05:00
|
|
|
#include <functional>
|
2020-07-15 12:34:50 -05:00
|
|
|
#include <string_view>
|
2023-06-10 22:40:39 -05:00
|
|
|
#include <type_traits>
|
|
|
|
#include <fmt/core.h>
|
2020-07-15 12:34:50 -05:00
|
|
|
|
2020-11-27 09:50:48 -06:00
|
|
|
#include "common/assert.h"
|
2023-06-10 22:40:39 -05:00
|
|
|
#include "common/fs/fs_util.h"
|
2021-05-25 18:32:56 -05:00
|
|
|
#include "common/fs/path_util.h"
|
2020-11-27 09:50:48 -06:00
|
|
|
#include "common/logging/log.h"
|
2021-04-14 18:07:40 -05:00
|
|
|
#include "common/settings.h"
|
2023-05-23 17:32:28 -05:00
|
|
|
#include "common/time_zone.h"
|
2016-04-11 07:38:42 -05:00
|
|
|
|
2014-09-12 19:06:13 -05:00
|
|
|
namespace Settings {
|
|
|
|
|
2023-06-18 18:57:14 -05:00
|
|
|
#ifndef _CANNOT_EXPLICITLY_INSTANTIATE
|
2023-06-10 22:40:39 -05:00
|
|
|
#define SETTING(TYPE, RANGED) template class Setting<TYPE, RANGED>
|
|
|
|
#define SWITCHABLE(TYPE, RANGED) template class SwitchableSetting<TYPE, RANGED>
|
|
|
|
|
|
|
|
SETTING(AudioEngine, false);
|
|
|
|
SETTING(bool, false);
|
|
|
|
SETTING(int, false);
|
|
|
|
SETTING(std::string, false);
|
|
|
|
SETTING(u16, false);
|
|
|
|
SWITCHABLE(AnisotropyMode, true);
|
|
|
|
SWITCHABLE(AntiAliasing, false);
|
|
|
|
SWITCHABLE(AspectRatio, true);
|
|
|
|
SWITCHABLE(AstcDecodeMode, true);
|
|
|
|
SWITCHABLE(AstcRecompression, true);
|
|
|
|
SWITCHABLE(AudioMode, true);
|
|
|
|
SWITCHABLE(CpuAccuracy, true);
|
|
|
|
SWITCHABLE(FullscreenMode, true);
|
|
|
|
SWITCHABLE(GpuAccuracy, true);
|
|
|
|
SWITCHABLE(Language, true);
|
|
|
|
SWITCHABLE(NvdecEmulation, false);
|
|
|
|
SWITCHABLE(Region, true);
|
|
|
|
SWITCHABLE(RendererBackend, true);
|
|
|
|
SWITCHABLE(ScalingFilter, false);
|
|
|
|
SWITCHABLE(ShaderBackend, true);
|
|
|
|
SWITCHABLE(TimeZone, true);
|
|
|
|
SETTING(VSyncMode, true);
|
|
|
|
SWITCHABLE(bool, false);
|
|
|
|
SWITCHABLE(int, false);
|
|
|
|
SWITCHABLE(int, true);
|
|
|
|
SWITCHABLE(s64, false);
|
|
|
|
SWITCHABLE(u16, true);
|
|
|
|
SWITCHABLE(u32, false);
|
|
|
|
SWITCHABLE(u8, false);
|
|
|
|
SWITCHABLE(u8, true);
|
|
|
|
|
|
|
|
#undef SETTING
|
|
|
|
#undef SWITCHABLE
|
2023-06-18 18:57:14 -05:00
|
|
|
#endif
|
2023-06-10 22:40:39 -05:00
|
|
|
|
2022-04-28 12:22:34 -05:00
|
|
|
Values values;
|
2014-09-12 19:06:13 -05:00
|
|
|
|
2020-05-11 16:50:07 -05:00
|
|
|
std::string GetTimeZoneString() {
|
2020-07-15 12:45:20 -05:00
|
|
|
const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue());
|
2023-05-23 17:32:28 -05:00
|
|
|
ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size());
|
|
|
|
|
2023-05-21 14:43:01 -05:00
|
|
|
std::string location_name;
|
2023-05-23 17:32:28 -05:00
|
|
|
if (time_zone_index == 0) { // Auto
|
2023-07-09 01:26:58 -05:00
|
|
|
#if __cpp_lib_chrono >= 201907L
|
2023-06-27 16:34:16 -05:00
|
|
|
try {
|
2023-07-09 01:26:58 -05:00
|
|
|
const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb();
|
2023-06-27 16:34:16 -05:00
|
|
|
const std::chrono::time_zone* current_zone = time_zone_data.current_zone();
|
|
|
|
std::string_view current_zone_name = current_zone->name();
|
|
|
|
location_name = current_zone_name;
|
|
|
|
} catch (std::runtime_error& runtime_error) {
|
|
|
|
// VCRUNTIME will throw a runtime_error if the operating system's selected time zone
|
|
|
|
// cannot be found
|
|
|
|
location_name = Common::TimeZone::FindSystemTimeZone();
|
|
|
|
LOG_WARNING(Common,
|
|
|
|
"Error occurred when trying to determine system time zone:\n{}\nFalling "
|
|
|
|
"back to hour offset \"{}\"",
|
|
|
|
runtime_error.what(), location_name);
|
|
|
|
}
|
2023-05-21 14:43:01 -05:00
|
|
|
#else
|
2023-05-23 17:32:28 -05:00
|
|
|
location_name = Common::TimeZone::FindSystemTimeZone();
|
2023-05-21 14:43:01 -05:00
|
|
|
#endif
|
2023-05-23 17:32:28 -05:00
|
|
|
} else {
|
|
|
|
location_name = Common::TimeZone::GetTimeZoneStrings()[time_zone_index];
|
2023-05-21 14:43:01 -05:00
|
|
|
}
|
|
|
|
return location_name;
|
2020-05-11 16:50:07 -05:00
|
|
|
}
|
|
|
|
|
2018-07-10 05:02:14 -05:00
|
|
|
void LogSettings() {
|
2020-07-15 12:34:50 -05:00
|
|
|
const auto log_setting = [](std::string_view name, const auto& value) {
|
|
|
|
LOG_INFO(Config, "{}: {}", name, value);
|
|
|
|
};
|
|
|
|
|
2021-05-25 18:32:56 -05:00
|
|
|
const auto log_path = [](std::string_view name, const std::filesystem::path& path) {
|
|
|
|
LOG_INFO(Config, "{}: {}", name, Common::FS::PathToUTF8String(path));
|
|
|
|
};
|
|
|
|
|
2018-07-10 05:02:14 -05:00
|
|
|
LOG_INFO(Config, "yuzu Configuration:");
|
2023-06-07 00:53:57 -05:00
|
|
|
for (auto& [category, settings] : values.linkage.by_category) {
|
|
|
|
settings.sort([](const BasicSetting* a, const BasicSetting* b) {
|
|
|
|
return a->GetLabel() < b->GetLabel();
|
|
|
|
});
|
|
|
|
|
|
|
|
for (const auto& setting : settings) {
|
|
|
|
if (setting->Id() == values.yuzu_token.Id()) {
|
|
|
|
// Hide the token secret, which could be used to share patreon builds
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name = fmt::format(
|
|
|
|
"{:c}{:c} {}.{}", setting->ToString() == setting->DefaultToString() ? '-' : 'M',
|
|
|
|
setting->UsingGlobal() ? '-' : 'C', TranslateCategory(category),
|
|
|
|
setting->GetLabel());
|
|
|
|
|
|
|
|
log_setting(name, setting->Canonicalize());
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 18:32:56 -05:00
|
|
|
log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir));
|
|
|
|
log_path("DataStorage_ConfigDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir));
|
|
|
|
log_path("DataStorage_LoadDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::LoadDir));
|
|
|
|
log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir));
|
|
|
|
log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir));
|
2018-07-10 05:02:14 -05:00
|
|
|
}
|
|
|
|
|
2020-04-15 20:42:05 -05:00
|
|
|
bool IsGPULevelExtreme() {
|
2023-06-07 00:52:23 -05:00
|
|
|
return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme;
|
2020-04-15 20:42:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsGPULevelHigh() {
|
2023-06-07 00:52:23 -05:00
|
|
|
return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme ||
|
|
|
|
values.gpu_accuracy.GetValue() == GpuAccuracy::High;
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 21:42:09 -05:00
|
|
|
}
|
|
|
|
|
2021-06-06 02:57:24 -05:00
|
|
|
bool IsFastmemEnabled() {
|
2021-07-08 15:56:44 -05:00
|
|
|
if (values.cpu_debug_mode) {
|
2021-06-28 14:58:16 -05:00
|
|
|
return static_cast<bool>(values.cpuopt_fastmem);
|
2021-06-06 02:57:24 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-04 03:16:34 -06:00
|
|
|
float Volume() {
|
|
|
|
if (values.audio_muted) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
2022-08-12 10:57:29 -05:00
|
|
|
return values.volume.GetValue() / static_cast<f32>(values.volume.GetDefault());
|
2020-11-04 03:16:34 -06:00
|
|
|
}
|
|
|
|
|
2023-06-09 15:53:01 -05:00
|
|
|
Linkage::Linkage(u32 initial_count) : count{initial_count} {}
|
2023-05-09 00:35:25 -05:00
|
|
|
Linkage::~Linkage() = default;
|
|
|
|
|
2023-06-05 20:05:22 -05:00
|
|
|
const char* TranslateCategory(Category category) {
|
|
|
|
switch (category) {
|
|
|
|
case Category::Audio:
|
|
|
|
return "Audio";
|
|
|
|
case Category::Core:
|
|
|
|
return "Core";
|
|
|
|
case Category::Cpu:
|
2023-05-07 09:35:28 -05:00
|
|
|
case Category::CpuDebug:
|
|
|
|
case Category::CpuUnsafe:
|
2023-06-05 20:05:22 -05:00
|
|
|
return "Cpu";
|
|
|
|
case Category::Renderer:
|
2023-05-07 09:35:28 -05:00
|
|
|
case Category::RendererAdvanced:
|
|
|
|
case Category::RendererDebug:
|
2023-06-05 20:05:22 -05:00
|
|
|
return "Renderer";
|
|
|
|
case Category::System:
|
2023-05-10 16:57:25 -05:00
|
|
|
case Category::SystemAudio:
|
2023-06-05 20:05:22 -05:00
|
|
|
return "System";
|
|
|
|
case Category::DataStorage:
|
|
|
|
return "Data Storage";
|
|
|
|
case Category::Debugging:
|
2023-05-07 09:35:28 -05:00
|
|
|
case Category::DebuggingGraphics:
|
2023-06-05 20:05:22 -05:00
|
|
|
return "Debugging";
|
|
|
|
case Category::Miscellaneous:
|
|
|
|
return "Miscellaneous";
|
|
|
|
case Category::Network:
|
|
|
|
return "Network";
|
|
|
|
case Category::WebService:
|
|
|
|
return "WebService";
|
|
|
|
case Category::AddOns:
|
|
|
|
return "DisabledAddOns";
|
|
|
|
case Category::Controls:
|
|
|
|
return "Controls";
|
|
|
|
case Category::Ui:
|
2023-05-09 00:35:25 -05:00
|
|
|
case Category::UiGeneral:
|
2023-06-05 20:05:22 -05:00
|
|
|
return "UI";
|
|
|
|
case Category::UiLayout:
|
|
|
|
return "UiLayout";
|
|
|
|
case Category::UiGameList:
|
|
|
|
return "UiGameList";
|
|
|
|
case Category::Screenshots:
|
|
|
|
return "Screenshots";
|
|
|
|
case Category::Shortcuts:
|
|
|
|
return "Shortcuts";
|
|
|
|
case Category::Multiplayer:
|
|
|
|
return "Multiplayer";
|
|
|
|
case Category::Services:
|
|
|
|
return "Services";
|
|
|
|
case Category::Paths:
|
|
|
|
return "Paths";
|
|
|
|
case Category::MaxEnum:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return "Miscellaneous";
|
|
|
|
}
|
|
|
|
|
2021-07-18 13:33:20 -05:00
|
|
|
void UpdateRescalingInfo() {
|
2021-10-06 00:18:00 -05:00
|
|
|
const auto setup = values.resolution_setup.GetValue();
|
2021-07-18 13:33:20 -05:00
|
|
|
auto& info = values.resolution_info;
|
2021-10-15 15:59:16 -05:00
|
|
|
info.downscale = false;
|
2021-07-18 13:33:20 -05:00
|
|
|
switch (setup) {
|
2021-07-25 19:20:12 -05:00
|
|
|
case ResolutionSetup::Res1_2X:
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 1;
|
|
|
|
info.down_shift = 1;
|
2021-10-15 15:59:16 -05:00
|
|
|
info.downscale = true;
|
2021-07-18 13:33:20 -05:00
|
|
|
break;
|
2021-10-20 11:56:34 -05:00
|
|
|
case ResolutionSetup::Res3_4X:
|
|
|
|
info.up_scale = 3;
|
|
|
|
info.down_shift = 2;
|
|
|
|
info.downscale = true;
|
|
|
|
break;
|
2021-07-25 19:20:12 -05:00
|
|
|
case ResolutionSetup::Res1X:
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 1;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2023-01-12 23:34:24 -06:00
|
|
|
case ResolutionSetup::Res3_2X:
|
|
|
|
info.up_scale = 3;
|
|
|
|
info.down_shift = 1;
|
|
|
|
break;
|
2021-07-25 19:20:12 -05:00
|
|
|
case ResolutionSetup::Res2X:
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 2;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2021-07-25 19:20:12 -05:00
|
|
|
case ResolutionSetup::Res3X:
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 3;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2021-07-25 19:20:12 -05:00
|
|
|
case ResolutionSetup::Res4X:
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 4;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2021-10-20 11:56:34 -05:00
|
|
|
case ResolutionSetup::Res5X:
|
|
|
|
info.up_scale = 5;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
|
|
|
case ResolutionSetup::Res6X:
|
|
|
|
info.up_scale = 6;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2023-01-13 01:55:26 -06:00
|
|
|
case ResolutionSetup::Res7X:
|
|
|
|
info.up_scale = 7;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
|
|
|
case ResolutionSetup::Res8X:
|
|
|
|
info.up_scale = 8;
|
|
|
|
info.down_shift = 0;
|
|
|
|
break;
|
2021-07-25 19:20:12 -05:00
|
|
|
default:
|
2022-06-07 16:02:29 -05:00
|
|
|
ASSERT(false);
|
2021-07-18 13:33:20 -05:00
|
|
|
info.up_scale = 1;
|
|
|
|
info.down_shift = 0;
|
2022-11-09 08:34:26 -06:00
|
|
|
break;
|
2021-07-18 13:33:20 -05:00
|
|
|
}
|
|
|
|
info.up_factor = static_cast<f32>(info.up_scale) / (1U << info.down_shift);
|
|
|
|
info.down_factor = static_cast<f32>(1U << info.down_shift) / info.up_scale;
|
2021-07-20 11:29:52 -05:00
|
|
|
info.active = info.up_scale != 1 || info.down_shift != 0;
|
2021-07-18 13:33:20 -05:00
|
|
|
}
|
|
|
|
|
2020-11-27 09:50:48 -06:00
|
|
|
void RestoreGlobalState(bool is_powered_on) {
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 21:42:09 -05:00
|
|
|
// If a game is running, DO NOT restore the global settings state
|
2020-11-27 09:50:48 -06:00
|
|
|
if (is_powered_on) {
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 21:42:09 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-05 20:05:22 -05:00
|
|
|
for (const auto& reset : values.linkage.restore_functions) {
|
2023-05-04 02:44:53 -05:00
|
|
|
reset();
|
|
|
|
}
|
2020-04-15 20:42:05 -05:00
|
|
|
}
|
|
|
|
|
2017-08-25 16:53:07 -05:00
|
|
|
} // namespace Settings
|