diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 19dc223ed..840798ce3 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -29,7 +29,6 @@ add_library(common layered_settings_interface.h log.cpp log.h - make_array.h memmap.cpp memmap.h md5_digest.cpp diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 47b2a63b3..df252a05f 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -24,7 +24,6 @@ - diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 7f7a16267..4a147b3a9 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -21,7 +21,6 @@ - thirdparty diff --git a/src/common/make_array.h b/src/common/make_array.h deleted file mode 100644 index f64879f28..000000000 --- a/src/common/make_array.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) - -#pragma once -#include -#include - -// Source: https://gist.github.com/klmr/2775736#file-make_array-hpp - -template -constexpr auto make_array(T&&... values) - -> std::array::type>::type, sizeof...(T)> -{ - return {std::forward(values)...}; -} diff --git a/src/core/bus.cpp b/src/core/bus.cpp index d9a6b0028..86b38ee2e 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -26,7 +26,6 @@ #include "common/assert.h" #include "common/intrin.h" #include "common/log.h" -#include "common/make_array.h" #include "common/memmap.h" #include @@ -133,9 +132,9 @@ static std::vector> s_fastmem_ram_views; #endif static u8** s_fastmem_lut = nullptr; -static constexpr auto s_fastmem_ram_mirrors = - make_array(0x00000000u, 0x00200000u, 0x00400000u, 0x00600000u, 0x80000000u, 0x80200000u, 0x80400000u, 0x80600000u, - 0xA0000000u, 0xA0200000u, 0xA0400000u, 0xA0600000u); +static constexpr const std::array s_fastmem_ram_mirrors = {0x00000000u, 0x00200000u, 0x00400000u, 0x00600000u, + 0x80000000u, 0x80200000u, 0x80400000u, 0x80600000u, + 0xA0000000u, 0xA0200000u, 0xA0400000u, 0xA0600000u}; static void SetRAMSize(bool enable_8mb_ram); diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index e10b3ec2b..b20438cbb 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -30,7 +30,6 @@ #include "common/error.h" #include "common/file_system.h" #include "common/log.h" -#include "common/make_array.h" #include "common/path.h" #include "common/small_string.h" #include "common/string_util.h" @@ -2809,7 +2808,7 @@ void FullscreenUI::DrawInterfaceSettingsPage() void FullscreenUI::DrawBIOSSettingsPage() { - static constexpr auto config_keys = make_array("", "PathNTSCJ", "PathNTSCU", "PathPAL"); + static constexpr const std::array config_keys = {"", "PathNTSCJ", "PathNTSCU", "PathPAL"}; SettingsInterface* bsi = GetEditingSettingsInterface(); const bool game_settings = IsEditingGameSettings(bsi); @@ -2881,15 +2880,26 @@ void FullscreenUI::DrawBIOSSettingsPage() void FullscreenUI::DrawConsoleSettingsPage() { - static constexpr auto cdrom_read_speeds = make_array( + static constexpr const std::array cdrom_read_speeds = { FSUI_NSTR("None (Double Speed)"), FSUI_NSTR("2x (Quad Speed)"), FSUI_NSTR("3x (6x Speed)"), - FSUI_NSTR("4x (8x Speed)"), FSUI_NSTR("5x (10x Speed)"), FSUI_NSTR("6x (12x Speed)"), FSUI_NSTR("7x (14x Speed)"), - FSUI_NSTR("8x (16x Speed)"), FSUI_NSTR("9x (18x Speed)"), FSUI_NSTR("10x (20x Speed)")); + FSUI_NSTR("4x (8x Speed)"), FSUI_NSTR("5x (10x Speed)"), FSUI_NSTR("6x (12x Speed)"), + FSUI_NSTR("7x (14x Speed)"), FSUI_NSTR("8x (16x Speed)"), FSUI_NSTR("9x (18x Speed)"), + FSUI_NSTR("10x (20x Speed)"), + }; - static constexpr auto cdrom_seek_speeds = - make_array(FSUI_NSTR("Infinite/Instantaneous"), FSUI_NSTR("None (Normal Speed)"), FSUI_NSTR("2x"), FSUI_NSTR("3x"), - FSUI_NSTR("4x"), FSUI_NSTR("5x"), FSUI_NSTR("6x"), FSUI_NSTR("7x"), FSUI_NSTR("8x"), FSUI_NSTR("9x"), - FSUI_NSTR("10x")); + static constexpr const std::array cdrom_seek_speeds = { + FSUI_NSTR("Infinite/Instantaneous"), + FSUI_NSTR("None (Normal Speed)"), + FSUI_NSTR("2x"), + FSUI_NSTR("3x"), + FSUI_NSTR("4x"), + FSUI_NSTR("5x"), + FSUI_NSTR("6x"), + FSUI_NSTR("7x"), + FSUI_NSTR("8x"), + FSUI_NSTR("9x"), + FSUI_NSTR("10x"), + }; SettingsInterface* bsi = GetEditingSettingsInterface(); @@ -2972,23 +2982,38 @@ void FullscreenUI::DrawConsoleSettingsPage() void FullscreenUI::DrawEmulationSettingsPage() { - static constexpr auto emulation_speed_values = - make_array(0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.5f, 3.0f, - 3.5f, 4.0f, 4.5f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f); - static constexpr auto emulation_speed_titles = - make_array(FSUI_NSTR("Unlimited"), "10% [6 FPS (NTSC) / 5 FPS (PAL)]", - FSUI_NSTR("20% [12 FPS (NTSC) / 10 FPS (PAL)]"), FSUI_NSTR("30% [18 FPS (NTSC) / 15 FPS (PAL)]"), - FSUI_NSTR("40% [24 FPS (NTSC) / 20 FPS (PAL)]"), FSUI_NSTR("50% [30 FPS (NTSC) / 25 FPS (PAL)]"), - FSUI_NSTR("60% [36 FPS (NTSC) / 30 FPS (PAL)]"), FSUI_NSTR("70% [42 FPS (NTSC) / 35 FPS (PAL)]"), - FSUI_NSTR("80% [48 FPS (NTSC) / 40 FPS (PAL)]"), FSUI_NSTR("90% [54 FPS (NTSC) / 45 FPS (PAL)]"), - FSUI_NSTR("100% [60 FPS (NTSC) / 50 FPS (PAL)]"), FSUI_NSTR("125% [75 FPS (NTSC) / 62 FPS (PAL)]"), - FSUI_NSTR("150% [90 FPS (NTSC) / 75 FPS (PAL)]"), FSUI_NSTR("175% [105 FPS (NTSC) / 87 FPS (PAL)]"), - FSUI_NSTR("200% [120 FPS (NTSC) / 100 FPS (PAL)]"), FSUI_NSTR("250% [150 FPS (NTSC) / 125 FPS (PAL)]"), - FSUI_NSTR("300% [180 FPS (NTSC) / 150 FPS (PAL)]"), FSUI_NSTR("350% [210 FPS (NTSC) / 175 FPS (PAL)]"), - FSUI_NSTR("400% [240 FPS (NTSC) / 200 FPS (PAL)]"), FSUI_NSTR("450% [270 FPS (NTSC) / 225 FPS (PAL)]"), - FSUI_NSTR("500% [300 FPS (NTSC) / 250 FPS (PAL)]"), FSUI_NSTR("600% [360 FPS (NTSC) / 300 FPS (PAL)]"), - FSUI_NSTR("700% [420 FPS (NTSC) / 350 FPS (PAL)]"), FSUI_NSTR("800% [480 FPS (NTSC) / 400 FPS (PAL)]"), - FSUI_NSTR("900% [540 FPS (NTSC) / 450 FPS (PAL)]"), FSUI_NSTR("1000% [600 FPS (NTSC) / 500 FPS (PAL)]")); + static constexpr const std::array emulation_speed_values = { + 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.25f, 1.5f, + 1.75f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, + }; + static constexpr const std::array emulation_speed_titles = { + FSUI_NSTR("Unlimited"), + "10% [6 FPS (NTSC) / 5 FPS (PAL)]", + FSUI_NSTR("20% [12 FPS (NTSC) / 10 FPS (PAL)]"), + FSUI_NSTR("30% [18 FPS (NTSC) / 15 FPS (PAL)]"), + FSUI_NSTR("40% [24 FPS (NTSC) / 20 FPS (PAL)]"), + FSUI_NSTR("50% [30 FPS (NTSC) / 25 FPS (PAL)]"), + FSUI_NSTR("60% [36 FPS (NTSC) / 30 FPS (PAL)]"), + FSUI_NSTR("70% [42 FPS (NTSC) / 35 FPS (PAL)]"), + FSUI_NSTR("80% [48 FPS (NTSC) / 40 FPS (PAL)]"), + FSUI_NSTR("90% [54 FPS (NTSC) / 45 FPS (PAL)]"), + FSUI_NSTR("100% [60 FPS (NTSC) / 50 FPS (PAL)]"), + FSUI_NSTR("125% [75 FPS (NTSC) / 62 FPS (PAL)]"), + FSUI_NSTR("150% [90 FPS (NTSC) / 75 FPS (PAL)]"), + FSUI_NSTR("175% [105 FPS (NTSC) / 87 FPS (PAL)]"), + FSUI_NSTR("200% [120 FPS (NTSC) / 100 FPS (PAL)]"), + FSUI_NSTR("250% [150 FPS (NTSC) / 125 FPS (PAL)]"), + FSUI_NSTR("300% [180 FPS (NTSC) / 150 FPS (PAL)]"), + FSUI_NSTR("350% [210 FPS (NTSC) / 175 FPS (PAL)]"), + FSUI_NSTR("400% [240 FPS (NTSC) / 200 FPS (PAL)]"), + FSUI_NSTR("450% [270 FPS (NTSC) / 225 FPS (PAL)]"), + FSUI_NSTR("500% [300 FPS (NTSC) / 250 FPS (PAL)]"), + FSUI_NSTR("600% [360 FPS (NTSC) / 300 FPS (PAL)]"), + FSUI_NSTR("700% [420 FPS (NTSC) / 350 FPS (PAL)]"), + FSUI_NSTR("800% [480 FPS (NTSC) / 400 FPS (PAL)]"), + FSUI_NSTR("900% [540 FPS (NTSC) / 450 FPS (PAL)]"), + FSUI_NSTR("1000% [600 FPS (NTSC) / 500 FPS (PAL)]"), + }; SettingsInterface* bsi = GetEditingSettingsInterface(); @@ -3029,10 +3054,10 @@ void FullscreenUI::DrawEmulationSettingsPage() const bool runahead_enabled = (runahead_frames > 0); const bool rewind_enabled = GetEffectiveBoolSetting(bsi, "Main", "RewindEnable", false); - static constexpr auto runahead_options = - make_array(FSUI_NSTR("Disabled"), FSUI_NSTR("1 Frame"), FSUI_NSTR("2 Frames"), FSUI_NSTR("3 Frames"), - FSUI_NSTR("4 Frames"), FSUI_NSTR("5 Frames"), FSUI_NSTR("6 Frames"), FSUI_NSTR("7 Frames"), - FSUI_NSTR("8 Frames"), FSUI_NSTR("9 Frames"), FSUI_NSTR("10 Frames")); + static constexpr const std::array runahead_options = { + FSUI_NSTR("Disabled"), FSUI_NSTR("1 Frame"), FSUI_NSTR("2 Frames"), FSUI_NSTR("3 Frames"), + FSUI_NSTR("4 Frames"), FSUI_NSTR("5 Frames"), FSUI_NSTR("6 Frames"), FSUI_NSTR("7 Frames"), + FSUI_NSTR("8 Frames"), FSUI_NSTR("9 Frames"), FSUI_NSTR("10 Frames")}; DrawIntListSetting( bsi, FSUI_CSTR("Runahead"), @@ -3529,8 +3554,8 @@ void FullscreenUI::DrawHotkeySettingsPage() void FullscreenUI::DrawMemoryCardSettingsPage() { - static constexpr const auto type_keys = make_array("Card1Type", "Card2Type"); - static constexpr const auto path_keys = make_array("Card1Path", "Card2Path"); + static constexpr const std::array type_keys = {"Card1Type", "Card2Type"}; + static constexpr const std::array path_keys = {"Card1Path", "Card2Path"}; SettingsInterface* bsi = GetEditingSettingsInterface(); const bool game_settings = IsEditingGameSettings(bsi); @@ -3664,12 +3689,25 @@ void FullscreenUI::DrawMemoryCardSettingsPage() void FullscreenUI::DrawDisplaySettingsPage() { - // TODO: Translation context - static constexpr auto resolution_scales = - make_array(FSUI_NSTR("Automatic based on window size"), FSUI_NSTR("1x"), FSUI_NSTR("2x"), - FSUI_NSTR("3x (for 720p)"), FSUI_NSTR("4x"), FSUI_NSTR("5x (for 1080p)"), FSUI_NSTR("6x (for 1440p)"), - FSUI_NSTR("7x"), FSUI_NSTR("8x"), FSUI_NSTR("9x (for 4K)"), FSUI_NSTR("10x"), FSUI_NSTR("11x"), - FSUI_NSTR("12x"), FSUI_NSTR("13x"), FSUI_NSTR("14x"), FSUI_NSTR("15x"), FSUI_NSTR("16x")); + static constexpr const std::array resolution_scales = { + FSUI_NSTR("Automatic based on window size"), + FSUI_NSTR("1x"), + FSUI_NSTR("2x"), + FSUI_NSTR("3x (for 720p)"), + FSUI_NSTR("4x"), + FSUI_NSTR("5x (for 1080p)"), + FSUI_NSTR("6x (for 1440p)"), + FSUI_NSTR("7x"), + FSUI_NSTR("8x"), + FSUI_NSTR("9x (for 4K)"), + FSUI_NSTR("10x"), + FSUI_NSTR("11x"), + FSUI_NSTR("12x"), + FSUI_NSTR("13x"), + FSUI_NSTR("14x"), + FSUI_NSTR("15x"), + FSUI_NSTR("16x"), + }; SettingsInterface* bsi = GetEditingSettingsInterface(); const bool game_settings = IsEditingGameSettings(bsi); diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index aa0b829e2..3c70e0267 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -16,7 +16,6 @@ #include "common/heterogeneous_containers.h" #include "common/http_downloader.h" #include "common/log.h" -#include "common/make_array.h" #include "common/path.h" #include "common/progress_callback.h" #include "common/string_util.h" @@ -674,7 +673,7 @@ static std::string GetFullCoverPath(const std::string_view& filename, const std: std::string GameList::GetCoverImagePath(const std::string& path, const std::string& serial, const std::string& title) { - static constexpr auto extensions = make_array("jpg", "jpeg", "png", "webp"); + static constexpr const std::array extensions = {"jpg", "jpeg", "png", "webp"}; for (const char* extension : extensions) { diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp index 1c37e3217..c3bdc2b7d 100644 --- a/src/core/gpu_sw.cpp +++ b/src/core/gpu_sw.cpp @@ -10,7 +10,6 @@ #include "common/assert.h" #include "common/intrin.h" #include "common/log.h" -#include "common/make_array.h" #include @@ -50,10 +49,10 @@ bool GPU_SW::Initialize() if (!GPU::Initialize() || !m_backend.Initialize(false)) return false; - static constexpr auto formats_for_16bit = make_array(GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551, - GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8); - static constexpr auto formats_for_24bit = make_array(GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8, - GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551); + static constexpr const std::array formats_for_16bit = {GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551, + GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8}; + static constexpr const std::array formats_for_24bit = {GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8, + GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551}; for (const GPUTexture::Format format : formats_for_16bit) { if (g_gpu_device->SupportsTextureFormat(format)) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index fb280b2b7..100824d08 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -14,7 +14,6 @@ #include "common/assert.h" #include "common/file_system.h" #include "common/log.h" -#include "common/make_array.h" #include "common/path.h" #include "common/string_util.h" @@ -743,13 +742,14 @@ void Settings::SetDefaultControllerConfig(SettingsInterface& si) #endif } -static std::array s_log_level_names = { - {"None", "Error", "Warning", "Perf", "Info", "Verbose", "Dev", "Profile", "Debug", "Trace"}}; -static std::array s_log_level_display_names = { - {TRANSLATE_NOOP("LogLevel", "None"), TRANSLATE_NOOP("LogLevel", "Error"), TRANSLATE_NOOP("LogLevel", "Warning"), - TRANSLATE_NOOP("LogLevel", "Performance"), TRANSLATE_NOOP("LogLevel", "Information"), - TRANSLATE_NOOP("LogLevel", "Verbose"), TRANSLATE_NOOP("LogLevel", "Developer"), - TRANSLATE_NOOP("LogLevel", "Profile"), TRANSLATE_NOOP("LogLevel", "Debug"), TRANSLATE_NOOP("LogLevel", "Trace")}}; +static constexpr const std::array s_log_level_names = {"None", "Error", "Warning", "Perf", "Info", + "Verbose", "Dev", "Profile", "Debug", "Trace"}; +static constexpr const std::array s_log_level_display_names = { + TRANSLATE_NOOP("LogLevel", "None"), TRANSLATE_NOOP("LogLevel", "Error"), + TRANSLATE_NOOP("LogLevel", "Warning"), TRANSLATE_NOOP("LogLevel", "Performance"), + TRANSLATE_NOOP("LogLevel", "Information"), TRANSLATE_NOOP("LogLevel", "Verbose"), + TRANSLATE_NOOP("LogLevel", "Developer"), TRANSLATE_NOOP("LogLevel", "Profile"), + TRANSLATE_NOOP("LogLevel", "Debug"), TRANSLATE_NOOP("LogLevel", "Trace")}; std::optional Settings::ParseLogLevelName(const char* str) { @@ -775,11 +775,10 @@ const char* Settings::GetLogLevelDisplayName(LOGLEVEL level) return Host::TranslateToCString("LogLevel", s_log_level_display_names[static_cast(level)]); } -static std::array s_console_region_names = {{"Auto", "NTSC-J", "NTSC-U", "PAL"}}; -static std::array s_console_region_display_names = { - {TRANSLATE_NOOP("ConsoleRegion", "Auto-Detect"), TRANSLATE_NOOP("ConsoleRegion", "NTSC-J (Japan)"), - TRANSLATE_NOOP("ConsoleRegion", "NTSC-U/C (US, Canada)"), - TRANSLATE_NOOP("ConsoleRegion", "PAL (Europe, Australia)")}}; +static constexpr const std::array s_console_region_names = {"Auto", "NTSC-J", "NTSC-U", "PAL"}; +static constexpr const std::array s_console_region_display_names = { + TRANSLATE_NOOP("ConsoleRegion", "Auto-Detect"), TRANSLATE_NOOP("ConsoleRegion", "NTSC-J (Japan)"), + TRANSLATE_NOOP("ConsoleRegion", "NTSC-U/C (US, Canada)"), TRANSLATE_NOOP("ConsoleRegion", "PAL (Europe, Australia)")}; std::optional Settings::ParseConsoleRegionName(const char* str) { @@ -805,11 +804,11 @@ const char* Settings::GetConsoleRegionDisplayName(ConsoleRegion region) return Host::TranslateToCString("ConsoleRegion", s_console_region_display_names[static_cast(region)]); } -static std::array s_disc_region_names = {{"NTSC-J", "NTSC-U", "PAL", "Other", "Non-PS1"}}; -static std::array s_disc_region_display_names = { - {TRANSLATE_NOOP("DiscRegion", "NTSC-J (Japan)"), TRANSLATE_NOOP("DiscRegion", "NTSC-U/C (US, Canada)"), - TRANSLATE_NOOP("DiscRegion", "PAL (Europe, Australia)"), TRANSLATE_NOOP("DiscRegion", "Other"), - TRANSLATE_NOOP("DiscRegion", "Non-PS1")}}; +static constexpr const std::array s_disc_region_names = {"NTSC-J", "NTSC-U", "PAL", "Other", "Non-PS1"}; +static constexpr const std::array s_disc_region_display_names = { + TRANSLATE_NOOP("DiscRegion", "NTSC-J (Japan)"), TRANSLATE_NOOP("DiscRegion", "NTSC-U/C (US, Canada)"), + TRANSLATE_NOOP("DiscRegion", "PAL (Europe, Australia)"), TRANSLATE_NOOP("DiscRegion", "Other"), + TRANSLATE_NOOP("DiscRegion", "Non-PS1")}; std::optional Settings::ParseDiscRegionName(const char* str) { @@ -835,11 +834,11 @@ const char* Settings::GetDiscRegionDisplayName(DiscRegion region) return Host::TranslateToCString("DiscRegion", s_disc_region_display_names[static_cast(region)]); } -static std::array s_cpu_execution_mode_names = {{"Interpreter", "CachedInterpreter", "Recompiler"}}; -static std::array s_cpu_execution_mode_display_names = { - {TRANSLATE_NOOP("CPUExecutionMode", "Interpreter (Slowest)"), - TRANSLATE_NOOP("CPUExecutionMode", "Cached Interpreter (Faster)"), - TRANSLATE_NOOP("CPUExecutionMode", "Recompiler (Fastest)")}}; +static constexpr const std::array s_cpu_execution_mode_names = {"Interpreter", "CachedInterpreter", "Recompiler"}; +static constexpr const std::array s_cpu_execution_mode_display_names = { + TRANSLATE_NOOP("CPUExecutionMode", "Interpreter (Slowest)"), + TRANSLATE_NOOP("CPUExecutionMode", "Cached Interpreter (Faster)"), + TRANSLATE_NOOP("CPUExecutionMode", "Recompiler (Fastest)")}; std::optional Settings::ParseCPUExecutionMode(const char* str) { @@ -865,12 +864,11 @@ const char* Settings::GetCPUExecutionModeDisplayName(CPUExecutionMode mode) return Host::TranslateToCString("CPUExecutionMode", s_cpu_execution_mode_display_names[static_cast(mode)]); } -static std::array(CPUFastmemMode::Count)> s_cpu_fastmem_mode_names = { - {"Disabled", "MMap", "LUT"}}; -static std::array(CPUFastmemMode::Count)> s_cpu_fastmem_mode_display_names = { - {TRANSLATE_NOOP("CPUFastmemMode", "Disabled (Slowest)"), - TRANSLATE_NOOP("CPUFastmemMode", "MMap (Hardware, Fastest, 64-Bit Only)"), - TRANSLATE_NOOP("CPUFastmemMode", "LUT (Faster)")}}; +static constexpr const std::array s_cpu_fastmem_mode_names = {"Disabled", "MMap", "LUT"}; +static constexpr const std::array s_cpu_fastmem_mode_display_names = { + TRANSLATE_NOOP("CPUFastmemMode", "Disabled (Slowest)"), + TRANSLATE_NOOP("CPUFastmemMode", "MMap (Hardware, Fastest, 64-Bit Only)"), + TRANSLATE_NOOP("CPUFastmemMode", "LUT (Faster)")}; std::optional Settings::ParseCPUFastmemMode(const char* str) { @@ -896,11 +894,10 @@ const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode) return Host::TranslateToCString("CPUFastmemMode", s_cpu_fastmem_mode_display_names[static_cast(mode)]); } -static constexpr std::array(GPURenderer::Count)> s_gpu_renderer_names = {{ +static constexpr const std::array s_gpu_renderer_names = { "Automatic", #ifdef _WIN32 - "D3D11", - "D3D12", + "D3D11", "D3D12", #endif #ifdef __APPLE__ "Metal", @@ -912,12 +909,11 @@ static constexpr std::array(GPURenderer::Count)> s "OpenGL", #endif "Software", -}}; -static constexpr std::array(GPURenderer::Count)> s_gpu_renderer_display_names = {{ +}; +static constexpr const std::array s_gpu_renderer_display_names = { TRANSLATE_NOOP("GPURenderer", "Automatic"), #ifdef _WIN32 - TRANSLATE_NOOP("GPURenderer", "Hardware (D3D11)"), - TRANSLATE_NOOP("GPURenderer", "Hardware (D3D12)"), + TRANSLATE_NOOP("GPURenderer", "Hardware (D3D11)"), TRANSLATE_NOOP("GPURenderer", "Hardware (D3D12)"), #endif #ifdef __APPLE__ TRANSLATE_NOOP("GPURenderer", "Hardware (Metal)"), @@ -929,7 +925,7 @@ static constexpr std::array(GPURenderer::Count)> s TRANSLATE_NOOP("GPURenderer", "Hardware (OpenGL)"), #endif TRANSLATE_NOOP("GPURenderer", "Software"), -}}; +}; std::optional Settings::ParseRendererName(const char* str) { @@ -983,14 +979,16 @@ RenderAPI Settings::GetRenderAPIForRenderer(GPURenderer renderer) } } -static constexpr auto s_texture_filter_names = - make_array("Nearest", "Bilinear", "BilinearBinAlpha", "JINC2", "JINC2BinAlpha", "xBR", "xBRBinAlpha"); -static constexpr auto s_texture_filter_display_names = make_array( - TRANSLATE_NOOP("GPUTextureFilter", "Nearest-Neighbor"), TRANSLATE_NOOP("GPUTextureFilter", "Bilinear"), - TRANSLATE_NOOP("GPUTextureFilter", "Bilinear (No Edge Blending)"), TRANSLATE_NOOP("GPUTextureFilter", "JINC2 (Slow)"), +static constexpr const std::array s_texture_filter_names = {"Nearest", "Bilinear", "BilinearBinAlpha", "JINC2", + "JINC2BinAlpha", "xBR", "xBRBinAlpha"}; +static constexpr const std::array s_texture_filter_display_names = { + TRANSLATE_NOOP("GPUTextureFilter", "Nearest-Neighbor"), + TRANSLATE_NOOP("GPUTextureFilter", "Bilinear"), + TRANSLATE_NOOP("GPUTextureFilter", "Bilinear (No Edge Blending)"), + TRANSLATE_NOOP("GPUTextureFilter", "JINC2 (Slow)"), TRANSLATE_NOOP("GPUTextureFilter", "JINC2 (Slow, No Edge Blending)"), TRANSLATE_NOOP("GPUTextureFilter", "xBR (Very Slow)"), - TRANSLATE_NOOP("GPUTextureFilter", "xBR (Very Slow, No Edge Blending)")); + TRANSLATE_NOOP("GPUTextureFilter", "xBR (Very Slow, No Edge Blending)")}; std::optional Settings::ParseTextureFilterName(const char* str) { @@ -1016,11 +1014,11 @@ const char* Settings::GetTextureFilterDisplayName(GPUTextureFilter filter) return Host::TranslateToCString("GPUTextureFilter", s_texture_filter_display_names[static_cast(filter)]); } -static constexpr auto s_downsample_mode_names = make_array("Disabled", "Box", "Adaptive"); -static constexpr auto s_downsample_mode_display_names = - make_array(TRANSLATE_NOOP("GPUDownsampleMode", "Disabled"), - TRANSLATE_NOOP("GPUDownsampleMode", "Box (Downsample 3D/Smooth All)"), - TRANSLATE_NOOP("GPUDownsampleMode", "Adaptive (Preserve 3D/Smooth 2D)")); +static constexpr const std::array s_downsample_mode_names = {"Disabled", "Box", "Adaptive"}; +static constexpr const std::array s_downsample_mode_display_names = { + TRANSLATE_NOOP("GPUDownsampleMode", "Disabled"), + TRANSLATE_NOOP("GPUDownsampleMode", "Box (Downsample 3D/Smooth All)"), + TRANSLATE_NOOP("GPUDownsampleMode", "Adaptive (Preserve 3D/Smooth 2D)")}; std::optional Settings::ParseDownsampleModeName(const char* str) { @@ -1046,10 +1044,10 @@ const char* Settings::GetDownsampleModeDisplayName(GPUDownsampleMode mode) return Host::TranslateToCString("GPUDownsampleMode", s_downsample_mode_display_names[static_cast(mode)]); } -static constexpr auto s_wireframe_mode_names = make_array("Disabled", "OverlayWireframe", "OnlyWireframe"); -static constexpr auto s_wireframe_mode_display_names = - make_array(TRANSLATE_NOOP("GPUWireframeMode", "Disabled"), TRANSLATE_NOOP("GPUWireframeMode", "Overlay Wireframe"), - TRANSLATE_NOOP("GPUWireframeMode", "Only Wireframe")); +static constexpr const std::array s_wireframe_mode_names = {"Disabled", "OverlayWireframe", "OnlyWireframe"}; +static constexpr const std::array s_wireframe_mode_display_names = { + TRANSLATE_NOOP("GPUWireframeMode", "Disabled"), TRANSLATE_NOOP("GPUWireframeMode", "Overlay Wireframe"), + TRANSLATE_NOOP("GPUWireframeMode", "Only Wireframe")}; std::optional Settings::ParseGPUWireframeMode(const char* str) { @@ -1075,10 +1073,10 @@ const char* Settings::GetGPUWireframeModeDisplayName(GPUWireframeMode mode) return Host::TranslateToCString("GPUWireframeMode", s_wireframe_mode_display_names[static_cast(mode)]); } -static std::array s_display_crop_mode_names = {{"None", "Overscan", "Borders"}}; -static std::array s_display_crop_mode_display_names = { - {TRANSLATE_NOOP("DisplayCropMode", "None"), TRANSLATE_NOOP("DisplayCropMode", "Only Overscan Area"), - TRANSLATE_NOOP("DisplayCropMode", "All Borders")}}; +static constexpr const std::array s_display_crop_mode_names = {"None", "Overscan", "Borders"}; +static constexpr const std::array s_display_crop_mode_display_names = { + TRANSLATE_NOOP("DisplayCropMode", "None"), TRANSLATE_NOOP("DisplayCropMode", "Only Overscan Area"), + TRANSLATE_NOOP("DisplayCropMode", "All Borders")}; std::optional Settings::ParseDisplayCropMode(const char* str) { @@ -1104,11 +1102,17 @@ const char* Settings::GetDisplayCropModeDisplayName(DisplayCropMode crop_mode) return Host::TranslateToCString("DisplayCropMode", s_display_crop_mode_display_names[static_cast(crop_mode)]); } -static std::array(DisplayAspectRatio::Count)> s_display_aspect_ratio_names = { - {TRANSLATE_NOOP("DisplayAspectRatio", "Auto (Game Native)"), TRANSLATE_NOOP("DisplayAspectRatio", "Stretch To Fill"), - TRANSLATE_NOOP("DisplayAspectRatio", "Custom"), "4:3", "16:9", "19:9", "20:9", "PAR 1:1"}}; -static constexpr std::array(DisplayAspectRatio::Count)> s_display_aspect_ratio_values = { - {-1.0f, -1.0f, -1.0f, 4.0f / 3.0f, 16.0f / 9.0f, 19.0f / 9.0f, 20.0f / 9.0f, -1.0f}}; +static constexpr const std::array s_display_aspect_ratio_names = { + TRANSLATE_NOOP("DisplayAspectRatio", "Auto (Game Native)"), + TRANSLATE_NOOP("DisplayAspectRatio", "Stretch To Fill"), + TRANSLATE_NOOP("DisplayAspectRatio", "Custom"), + "4:3", + "16:9", + "19:9", + "20:9", + "PAR 1:1"}; +static constexpr const std::array s_display_aspect_ratio_values = { + -1.0f, -1.0f, -1.0f, 4.0f / 3.0f, 16.0f / 9.0f, 19.0f / 9.0f, 20.0f / 9.0f, -1.0f}; std::optional Settings::ParseDisplayAspectRatio(const char* str) { @@ -1159,11 +1163,10 @@ float Settings::GetDisplayAspectRatioValue() const } } -static std::array(DisplayAlignment::Count)> s_display_alignment_names = { - {"LeftOrTop", "Center", "RightOrBottom"}}; -static std::array(DisplayAlignment::Count)> s_display_alignment_display_names = { - {TRANSLATE_NOOP("DisplayAlignment", "Left / Top"), TRANSLATE_NOOP("DisplayAlignment", "Center"), - TRANSLATE_NOOP("DisplayAlignment", "Right / Bottom")}}; +static constexpr const std::array s_display_alignment_names = {"LeftOrTop", "Center", "RightOrBottom"}; +static constexpr const std::array s_display_alignment_display_names = { + TRANSLATE_NOOP("DisplayAlignment", "Left / Top"), TRANSLATE_NOOP("DisplayAlignment", "Center"), + TRANSLATE_NOOP("DisplayAlignment", "Right / Bottom")}; std::optional Settings::ParseDisplayAlignment(const char* str) { @@ -1189,18 +1192,18 @@ const char* Settings::GetDisplayAlignmentDisplayName(DisplayAlignment alignment) return Host::TranslateToCString("DisplayAlignment", s_display_alignment_display_names[static_cast(alignment)]); } -static std::array(DisplayScalingMode::Count)> s_display_scaling_names = {{ +static constexpr const std::array s_display_scaling_names = { "Nearest", "BilinearSmooth", "NearestInteger", "BilinearSharp", -}}; -static std::array(DisplayScalingMode::Count)> s_display_scaling_display_names = {{ +}; +static constexpr const std::array s_display_scaling_display_names = { TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor"), TRANSLATE_NOOP("DisplayScalingMode", "Bilinear (Smooth)"), TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor (Integer)"), TRANSLATE_NOOP("DisplayScalingMode", "Bilinear (Sharp)"), -}}; +}; std::optional Settings::ParseDisplayScaling(const char* str) { @@ -1226,7 +1229,7 @@ const char* Settings::GetDisplayScalingDisplayName(DisplayScalingMode mode) return Host::TranslateToCString("DisplayScalingMode", s_display_scaling_display_names[static_cast(mode)]); } -static constexpr const char* s_audio_backend_names[] = { +static constexpr const std::array s_audio_backend_names = { "Null", #ifdef ENABLE_CUBEB "Cubeb", @@ -1238,7 +1241,7 @@ static constexpr const char* s_audio_backend_names[] = { "AAudio", "OpenSLES", #endif }; -static constexpr const char* s_audio_backend_display_names[] = { +static constexpr const std::array s_audio_backend_display_names = { TRANSLATE_NOOP("AudioBackend", "Null (No Output)"), #ifdef ENABLE_CUBEB TRANSLATE_NOOP("AudioBackend", "Cubeb"), @@ -1276,13 +1279,16 @@ const char* Settings::GetAudioBackendDisplayName(AudioBackend backend) return Host::TranslateToCString("AudioBackend", s_audio_backend_display_names[static_cast(backend)]); } -static std::array s_controller_type_names = { - {"None", "DigitalController", "AnalogController", "AnalogJoystick", "GunCon", "PlayStationMouse", "NeGcon"}}; -static std::array s_controller_display_names = { - {TRANSLATE_NOOP("ControllerType", "None"), TRANSLATE_NOOP("ControllerType", "Digital Controller"), - TRANSLATE_NOOP("ControllerType", "Analog Controller (DualShock)"), - TRANSLATE_NOOP("ControllerType", "Analog Joystick"), TRANSLATE_NOOP("ControllerType", "GunCon"), - TRANSLATE_NOOP("ControllerType", "PlayStation Mouse"), TRANSLATE_NOOP("ControllerType", "NeGcon")}}; +static constexpr const std::array s_controller_type_names = { + "None", "DigitalController", "AnalogController", "AnalogJoystick", "GunCon", "PlayStationMouse", "NeGcon"}; +static constexpr const std::array s_controller_display_names = { + TRANSLATE_NOOP("ControllerType", "None"), + TRANSLATE_NOOP("ControllerType", "Digital Controller"), + TRANSLATE_NOOP("ControllerType", "Analog Controller (DualShock)"), + TRANSLATE_NOOP("ControllerType", "Analog Joystick"), + TRANSLATE_NOOP("ControllerType", "GunCon"), + TRANSLATE_NOOP("ControllerType", "PlayStation Mouse"), + TRANSLATE_NOOP("ControllerType", "NeGcon")}; std::optional Settings::ParseControllerTypeName(const char* str) { @@ -1308,14 +1314,15 @@ const char* Settings::GetControllerTypeDisplayName(ControllerType type) return Host::TranslateToCString("ControllerType", s_controller_display_names[static_cast(type)]); } -static std::array s_memory_card_type_names = { - {"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent"}}; -static std::array s_memory_card_type_display_names = { - {TRANSLATE_NOOP("MemoryCardType", "No Memory Card"), TRANSLATE_NOOP("MemoryCardType", "Shared Between All Games"), - TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Serial)"), - TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Title)"), - TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (File Title)"), - TRANSLATE_NOOP("MemoryCardType", "Non-Persistent Card (Do Not Save)")}}; +static constexpr const std::array s_memory_card_type_names = {"None", "Shared", "PerGame", + "PerGameTitle", "PerGameFileTitle", "NonPersistent"}; +static constexpr const std::array s_memory_card_type_display_names = { + TRANSLATE_NOOP("MemoryCardType", "No Memory Card"), + TRANSLATE_NOOP("MemoryCardType", "Shared Between All Games"), + TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Serial)"), + TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Title)"), + TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (File Title)"), + TRANSLATE_NOOP("MemoryCardType", "Non-Persistent Card (Do Not Save)")}; std::optional Settings::ParseMemoryCardTypeName(const char* str) { @@ -1365,10 +1372,10 @@ std::string Settings::GetGameMemoryCardPath(const std::string_view& serial, u32 return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1)); } -static std::array s_multitap_enable_mode_names = {{"Disabled", "Port1Only", "Port2Only", "BothPorts"}}; -static std::array s_multitap_enable_mode_display_names = { - {TRANSLATE_NOOP("MultitapMode", "Disabled"), TRANSLATE_NOOP("MultitapMode", "Enable on Port 1 Only"), - TRANSLATE_NOOP("MultitapMode", "Enable on Port 2 Only"), TRANSLATE_NOOP("MultitapMode", "Enable on Ports 1 and 2")}}; +static constexpr const std::array s_multitap_enable_mode_names = {"Disabled", "Port1Only", "Port2Only", "BothPorts"}; +static constexpr const std::array s_multitap_enable_mode_display_names = { + TRANSLATE_NOOP("MultitapMode", "Disabled"), TRANSLATE_NOOP("MultitapMode", "Enable on Port 1 Only"), + TRANSLATE_NOOP("MultitapMode", "Enable on Port 2 Only"), TRANSLATE_NOOP("MultitapMode", "Enable on Ports 1 and 2")}; std::optional Settings::ParseMultitapModeName(const char* str) { diff --git a/src/core/system.cpp b/src/core/system.cpp index 8499cce68..3685aba31 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -48,7 +48,6 @@ #include "common/error.h" #include "common/file_system.h" #include "common/log.h" -#include "common/make_array.h" #include "common/path.h" #include "common/string_util.h" #include "common/threading.h" @@ -502,11 +501,13 @@ bool System::IsPsfFileName(const std::string_view& path) bool System::IsLoadableFilename(const std::string_view& path) { - static constexpr auto extensions = make_array(".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs - ".exe", ".psexe", ".ps-exe", // exes - ".psf", ".minipsf", // psf - ".m3u", // playlists - ".pbp"); + static constexpr const std::array extensions = { + ".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs + ".exe", ".psexe", ".ps-exe", // exes + ".psf", ".minipsf", // psf + ".m3u", // playlists + ".pbp", + }; for (const char* test_extension : extensions) { diff --git a/src/duckstation-qt/emulationsettingswidget.cpp b/src/duckstation-qt/emulationsettingswidget.cpp index 5fb51468c..013d92e3c 100644 --- a/src/duckstation-qt/emulationsettingswidget.cpp +++ b/src/duckstation-qt/emulationsettingswidget.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "emulationsettingswidget.h" -#include "common/make_array.h" #include "core/system.h" #include "qtutils.h" #include "settingsdialog.h" @@ -128,8 +127,8 @@ void EmulationSettingsWidget::fillComboBoxWithEmulationSpeeds(QComboBox* cb, flo cb->addItem(tr("Unlimited"), QVariant(0.0f)); - static constexpr auto speeds = make_array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 350, - 400, 450, 500, 600, 700, 800, 900, 1000); + static constexpr const std::array speeds = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, + 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000}; for (const int speed : speeds) { cb->addItem(tr("%1% [%2 FPS (NTSC) / %3 FPS (PAL)]").arg(speed).arg((60 * speed) / 100).arg((50 * speed) / 100), diff --git a/src/duckstation-qt/qtutils.cpp b/src/duckstation-qt/qtutils.cpp index 1e7da3519..1d0766a93 100644 --- a/src/duckstation-qt/qtutils.cpp +++ b/src/duckstation-qt/qtutils.cpp @@ -7,7 +7,6 @@ #include "core/system.h" #include "common/byte_stream.h" -#include "common/make_array.h" #include #include diff --git a/src/util/audio_stream.cpp b/src/util/audio_stream.cpp index 0ccda38ac..fb57ba4a6 100644 --- a/src/util/audio_stream.cpp +++ b/src/util/audio_stream.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "audio_stream.h" +#include "host.h" #include "common/align.h" #include "common/assert.h" #include "common/intrin.h" #include "common/log.h" -#include "common/make_array.h" #include "common/timer.h" #include "SoundTouch.h" @@ -54,8 +54,10 @@ u32 AudioStream::GetMSForBufferSize(u32 sample_rate, u32 buffer_size) return (buffer_size * 1000u) / sample_rate; } -static constexpr const auto s_stretch_mode_names = make_array("None", "Resample", "TimeStretch"); -static constexpr const auto s_stretch_mode_display_names = make_array("None", "Resampling", "Time Stretching"); +static constexpr const std::array s_stretch_mode_names = {"None", "Resample", "TimeStretch"}; +static constexpr const std::array s_stretch_mode_display_names = {TRANSLATE_NOOP("AudioStream", "None"), + TRANSLATE_NOOP("AudioStream", "Resampling"), + TRANSLATE_NOOP("AudioStream", "Time Stretching")}; const char* AudioStream::GetStretchModeName(AudioStretchMode mode) { @@ -65,7 +67,7 @@ const char* AudioStream::GetStretchModeName(AudioStretchMode mode) const char* AudioStream::GetStretchModeDisplayName(AudioStretchMode mode) { return (static_cast(mode) < s_stretch_mode_display_names.size()) ? - s_stretch_mode_display_names[static_cast(mode)] : + Host::TranslateToCString("AudioStream", s_stretch_mode_display_names[static_cast(mode)]) : ""; } diff --git a/src/util/dinput_source.cpp b/src/util/dinput_source.cpp index a585e1480..72af7075a 100644 --- a/src/util/dinput_source.cpp +++ b/src/util/dinput_source.cpp @@ -9,7 +9,6 @@ #include "common/assert.h" #include "common/log.h" -#include "common/make_array.h" #include "common/string_util.h" #include "fmt/format.h"