shared_translation.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/time_zone.h"
  4. #include "yuzu/configuration/shared_translation.h"
  5. #include <map>
  6. #include <memory>
  7. #include <tuple>
  8. #include <utility>
  9. #include <QWidget>
  10. #include "common/settings.h"
  11. #include "common/settings_enums.h"
  12. #include "common/settings_setting.h"
  13. #include "yuzu/uisettings.h"
  14. namespace ConfigurationShared {
  15. std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
  16. std::unique_ptr<TranslationMap> translations = std::make_unique<TranslationMap>();
  17. const auto& tr = [parent](const char* text) -> QString { return parent->tr(text); };
  18. #define INSERT(SETTINGS, ID, NAME, TOOLTIP) \
  19. translations->insert(std::pair{SETTINGS::values.ID.Id(), std::pair{tr((NAME)), tr((TOOLTIP))}})
  20. // A setting can be ignored by giving it a blank name
  21. // Audio
  22. INSERT(Settings, sink_id, "Output Engine:", "");
  23. INSERT(Settings, audio_output_device_id, "Output Device:", "");
  24. INSERT(Settings, audio_input_device_id, "Input Device:", "");
  25. INSERT(Settings, audio_muted, "Mute audio when in background", "");
  26. INSERT(Settings, volume, "Volume:", "");
  27. INSERT(Settings, dump_audio_commands, "", "");
  28. // Core
  29. INSERT(Settings, use_multi_core, "Multicore CPU Emulation", "");
  30. INSERT(Settings, memory_layout_mode, "Memory Layout", "");
  31. INSERT(Settings, use_speed_limit, "", "");
  32. INSERT(Settings, speed_limit, "Limit Speed Percent", "");
  33. // Cpu
  34. INSERT(Settings, cpu_accuracy, "Accuracy:", "");
  35. // Cpu Debug
  36. // Cpu Unsafe
  37. INSERT(Settings, cpuopt_unsafe_unfuse_fma,
  38. "Unfuse FMA (improve performance on CPUs without FMA)",
  39. "This option improves speed by reducing accuracy of fused-multiply-add instructions on "
  40. "CPUs without native FMA support.");
  41. INSERT(Settings, cpuopt_unsafe_reduce_fp_error, "Faster FRSQRTE and FRECPE",
  42. "This option improves the speed of some approximate floating-point functions by using "
  43. "less accurate native approximations.");
  44. INSERT(Settings, cpuopt_unsafe_ignore_standard_fpcr, "Faster ASIMD instructions (32 bits only)",
  45. "This option improves the speed of 32 bits ASIMD floating-point functions by running "
  46. "with incorrect rounding modes.");
  47. INSERT(Settings, cpuopt_unsafe_inaccurate_nan, "Inaccurate NaN handling",
  48. "This option improves speed by removing NaN checking. Please note this also reduces "
  49. "accuracy of certain floating-point instructions.");
  50. INSERT(
  51. Settings, cpuopt_unsafe_fastmem_check, "Disable address space checks",
  52. "This option improves speed by eliminating a safety check before every memory read/write "
  53. "in guest. Disabling it may allow a game to read/write the emulator's memory.");
  54. INSERT(Settings, cpuopt_unsafe_ignore_global_monitor, "Ignore global monitor",
  55. "This option improves speed by relying only on the semantics of cmpxchg to ensure "
  56. "safety of exclusive access instructions. Please note this may result in deadlocks and "
  57. "other race conditions.");
  58. // Renderer
  59. INSERT(Settings, renderer_backend, "API:", "");
  60. INSERT(Settings, vulkan_device, "Device:", "");
  61. INSERT(Settings, shader_backend, "Shader Backend:", "");
  62. INSERT(Settings, resolution_setup, "Resolution:", "");
  63. INSERT(Settings, scaling_filter, "Window Adapting Filter:", "");
  64. INSERT(Settings, fsr_sharpening_slider, "FSR Sharpness:", "");
  65. INSERT(Settings, anti_aliasing, "Anti-Aliasing Method:", "");
  66. INSERT(Settings, fullscreen_mode, "Fullscreen Mode:", "");
  67. INSERT(Settings, aspect_ratio, "Aspect Ratio:", "");
  68. INSERT(Settings, use_disk_shader_cache, "Use disk pipeline cache", "");
  69. INSERT(Settings, use_asynchronous_gpu_emulation, "Use asynchronous GPU emulation", "");
  70. INSERT(Settings, nvdec_emulation, "NVDEC emulation:", "");
  71. INSERT(Settings, accelerate_astc, "ASTC Decoding Method:", "");
  72. INSERT(Settings, astc_recompression, "ASTC Recompression Method:", "");
  73. INSERT(Settings, vsync_mode, "VSync Mode:",
  74. "FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
  75. "refresh rate.\nFIFO Relaxed is similar to FIFO but allows tearing as it recovers from "
  76. "a slow down.\nMailbox can have lower latency than FIFO and does not tear but may drop "
  77. "frames.\nImmediate (no synchronization) just presents whatever is available and can "
  78. "exhibit tearing.");
  79. INSERT(Settings, bg_red, "", "");
  80. INSERT(Settings, bg_green, "", "");
  81. INSERT(Settings, bg_blue, "", "");
  82. // Renderer (Advanced Graphics)
  83. INSERT(Settings, async_presentation, "Enable asynchronous presentation (Vulkan only)", "");
  84. INSERT(Settings, renderer_force_max_clock, "Force maximum clocks (Vulkan only)",
  85. "Runs work in the background while waiting for graphics commands to keep the GPU from "
  86. "lowering its clock speed.");
  87. INSERT(Settings, max_anisotropy, "Anisotropic Filtering:", "");
  88. INSERT(Settings, gpu_accuracy, "Accuracy Level:", "");
  89. INSERT(Settings, use_asynchronous_shaders, "Use asynchronous shader building (Hack)",
  90. "Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
  91. "is experimental.");
  92. INSERT(Settings, use_fast_gpu_time, "Use Fast GPU Time (Hack)",
  93. "Enables Fast GPU Time. This option will force most games to run at their highest "
  94. "native resolution.");
  95. INSERT(Settings, use_vulkan_driver_pipeline_cache, "Use Vulkan pipeline cache",
  96. "Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
  97. "time significantly in cases where the Vulkan driver does not store pipeline cache "
  98. "files internally.");
  99. INSERT(Settings, enable_compute_pipelines, "Enable Compute Pipelines (Intel Vulkan Only)",
  100. "Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
  101. "proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled "
  102. "on all other drivers.");
  103. INSERT(Settings, use_reactive_flushing, "Enable Reactive Flushing",
  104. "Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
  105. "syncing.");
  106. INSERT(Settings, use_video_framerate, "Sync to framerate of video playback",
  107. "Run the game at normal speed during video playback, even when the framerate is "
  108. "unlocked.");
  109. INSERT(Settings, barrier_feedback_loops, "Barrier feedback loops",
  110. "Improves rendering of transparency effects in specific games.");
  111. // Renderer (Debug)
  112. // System
  113. INSERT(Settings, rng_seed, "RNG Seed", "");
  114. INSERT(Settings, rng_seed_enabled, "", "");
  115. INSERT(Settings, device_name, "Device Name", "");
  116. INSERT(Settings, custom_rtc, "Custom RTC", "");
  117. INSERT(Settings, custom_rtc_enabled, "", "");
  118. INSERT(Settings, language_index,
  119. "Language:", "Note: this can be overridden when region setting is auto-select");
  120. INSERT(Settings, region_index, "Region:", "");
  121. INSERT(Settings, time_zone_index, "Time Zone:", "");
  122. INSERT(Settings, sound_index, "Sound Output Mode:", "");
  123. INSERT(Settings, use_docked_mode, "Console Mode:", "");
  124. INSERT(Settings, current_user, "", "");
  125. // Controls
  126. // Data Storage
  127. // Debugging
  128. // Debugging Graphics
  129. // Network
  130. // Web Service
  131. // Ui
  132. // Ui General
  133. INSERT(UISettings, select_user_on_boot, "Prompt for user on game boot", "");
  134. INSERT(UISettings, pause_when_in_background, "Pause emulation when in background", "");
  135. INSERT(UISettings, confirm_before_closing, "Confirm exit while emulation is running", "");
  136. INSERT(UISettings, hide_mouse, "Hide mouse on inactivity", "");
  137. INSERT(UISettings, controller_applet_disabled, "Disable controller applet", "");
  138. // Ui Debugging
  139. // Ui Multiplayer
  140. // Ui Games list
  141. #undef INSERT
  142. return translations;
  143. }
  144. std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
  145. std::unique_ptr<ComboboxTranslationMap> translations =
  146. std::make_unique<ComboboxTranslationMap>();
  147. const auto& tr = [&](const char* text, const char* context = "") {
  148. return parent->tr(text, context);
  149. };
  150. #define PAIR(ENUM, VALUE, TRANSLATION) \
  151. { static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION) }
  152. #define CTX_PAIR(ENUM, VALUE, TRANSLATION, CONTEXT) \
  153. { static_cast<u32>(Settings::ENUM::VALUE), tr(TRANSLATION, CONTEXT) }
  154. // Intentionally skipping VSyncMode to let the UI fill that one out
  155. translations->insert({Settings::EnumMetadata<Settings::AstcDecodeMode>::Index(),
  156. {
  157. PAIR(AstcDecodeMode, Cpu, "CPU"),
  158. PAIR(AstcDecodeMode, Gpu, "GPU"),
  159. PAIR(AstcDecodeMode, CpuAsynchronous, "CPU Asynchronous"),
  160. }});
  161. translations->insert({Settings::EnumMetadata<Settings::AstcRecompression>::Index(),
  162. {
  163. PAIR(AstcRecompression, Uncompressed, "Uncompressed (Best quality)"),
  164. PAIR(AstcRecompression, Bc1, "BC1 (Low quality)"),
  165. PAIR(AstcRecompression, Bc3, "BC3 (Medium quality)"),
  166. }});
  167. translations->insert({Settings::EnumMetadata<Settings::RendererBackend>::Index(),
  168. {
  169. #ifdef HAS_OPENGL
  170. PAIR(RendererBackend, OpenGL, "OpenGL"),
  171. #endif
  172. PAIR(RendererBackend, Vulkan, "Vulkan"),
  173. PAIR(RendererBackend, Null, "Null"),
  174. }});
  175. translations->insert({Settings::EnumMetadata<Settings::ShaderBackend>::Index(),
  176. {
  177. PAIR(ShaderBackend, Glsl, "GLSL"),
  178. PAIR(ShaderBackend, Glasm, "GLASM (Assembly Shaders, NVIDIA Only)"),
  179. PAIR(ShaderBackend, SpirV, "SPIR-V (Experimental, Mesa Only)"),
  180. }});
  181. translations->insert({Settings::EnumMetadata<Settings::GpuAccuracy>::Index(),
  182. {
  183. PAIR(GpuAccuracy, Normal, "Normal"),
  184. PAIR(GpuAccuracy, High, "High"),
  185. PAIR(GpuAccuracy, Extreme, "Extreme"),
  186. }});
  187. translations->insert({Settings::EnumMetadata<Settings::CpuAccuracy>::Index(),
  188. {
  189. PAIR(CpuAccuracy, Auto, "Auto"),
  190. PAIR(CpuAccuracy, Accurate, "Accurate"),
  191. PAIR(CpuAccuracy, Unsafe, "Unsafe"),
  192. PAIR(CpuAccuracy, Paranoid, "Paranoid (disables most optimizations)"),
  193. }});
  194. translations->insert({Settings::EnumMetadata<Settings::FullscreenMode>::Index(),
  195. {
  196. PAIR(FullscreenMode, Borderless, "Borderless Windowed"),
  197. PAIR(FullscreenMode, Exclusive, "Exclusive Fullscreen"),
  198. }});
  199. translations->insert({Settings::EnumMetadata<Settings::NvdecEmulation>::Index(),
  200. {
  201. PAIR(NvdecEmulation, Off, "No Video Output"),
  202. PAIR(NvdecEmulation, Cpu, "CPU Video Decoding"),
  203. PAIR(NvdecEmulation, Gpu, "GPU Video Decoding (Default)"),
  204. }});
  205. translations->insert({Settings::EnumMetadata<Settings::ResolutionSetup>::Index(),
  206. {
  207. PAIR(ResolutionSetup, Res1_2X, "0.5X (360p/540p) [EXPERIMENTAL]"),
  208. PAIR(ResolutionSetup, Res3_4X, "0.75X (540p/810p) [EXPERIMENTAL]"),
  209. PAIR(ResolutionSetup, Res1X, "1X (720p/1080p)"),
  210. PAIR(ResolutionSetup, Res3_2X, "1.5X (1080p/1620p) [EXPERIMENTAL]"),
  211. PAIR(ResolutionSetup, Res2X, "2X (1440p/2160p)"),
  212. PAIR(ResolutionSetup, Res3X, "3X (2160p/3240p)"),
  213. PAIR(ResolutionSetup, Res4X, "4X (2880p/4320p)"),
  214. PAIR(ResolutionSetup, Res5X, "5X (3600p/5400p)"),
  215. PAIR(ResolutionSetup, Res6X, "6X (4320p/6480p)"),
  216. PAIR(ResolutionSetup, Res7X, "7X (5040p/7560p)"),
  217. PAIR(ResolutionSetup, Res8X, "8X (5760p/8640p)"),
  218. }});
  219. translations->insert({Settings::EnumMetadata<Settings::ScalingFilter>::Index(),
  220. {
  221. PAIR(ScalingFilter, NearestNeighbor, "Nearest Neighbor"),
  222. PAIR(ScalingFilter, Bilinear, "Bilinear"),
  223. PAIR(ScalingFilter, Bicubic, "Bicubic"),
  224. PAIR(ScalingFilter, Gaussian, "Gaussian"),
  225. PAIR(ScalingFilter, ScaleForce, "ScaleForce"),
  226. PAIR(ScalingFilter, Fsr, "AMD FidelityFX™️ Super Resolution"),
  227. }});
  228. translations->insert({Settings::EnumMetadata<Settings::AntiAliasing>::Index(),
  229. {
  230. PAIR(AntiAliasing, None, "None"),
  231. PAIR(AntiAliasing, Fxaa, "FXAA"),
  232. PAIR(AntiAliasing, Smaa, "SMAA"),
  233. }});
  234. translations->insert({Settings::EnumMetadata<Settings::AspectRatio>::Index(),
  235. {
  236. PAIR(AspectRatio, R16_9, "Default (16:9)"),
  237. PAIR(AspectRatio, R4_3, "Force 4:3"),
  238. PAIR(AspectRatio, R21_9, "Force 21:9"),
  239. PAIR(AspectRatio, R16_10, "Force 16:10"),
  240. PAIR(AspectRatio, Stretch, "Stretch to Window"),
  241. }});
  242. translations->insert({Settings::EnumMetadata<Settings::AnisotropyMode>::Index(),
  243. {
  244. PAIR(AnisotropyMode, Automatic, "Automatic"),
  245. PAIR(AnisotropyMode, Default, "Default"),
  246. PAIR(AnisotropyMode, X2, "2x"),
  247. PAIR(AnisotropyMode, X4, "4x"),
  248. PAIR(AnisotropyMode, X8, "8x"),
  249. PAIR(AnisotropyMode, X16, "16x"),
  250. }});
  251. translations->insert(
  252. {Settings::EnumMetadata<Settings::Language>::Index(),
  253. {
  254. PAIR(Language, Japanese, "Japanese (日本語)"),
  255. PAIR(Language, EnglishAmerican, "American English"),
  256. PAIR(Language, French, "French (français)"),
  257. PAIR(Language, German, "German (Deutsch)"),
  258. PAIR(Language, Italian, "Italian (italiano)"),
  259. PAIR(Language, Spanish, "Spanish (español)"),
  260. PAIR(Language, Chinese, "Chinese"),
  261. PAIR(Language, Korean, "Korean (한국어)"),
  262. PAIR(Language, Dutch, "Dutch (Nederlands)"),
  263. PAIR(Language, Portuguese, "Portuguese (português)"),
  264. PAIR(Language, Russian, "Russian (Русский)"),
  265. PAIR(Language, Taiwanese, "Taiwanese"),
  266. PAIR(Language, EnglishBritish, "British English"),
  267. PAIR(Language, FrenchCanadian, "Canadian French"),
  268. PAIR(Language, SpanishLatin, "Latin American Spanish"),
  269. PAIR(Language, ChineseSimplified, "Simplified Chinese"),
  270. PAIR(Language, ChineseTraditional, "Traditional Chinese (正體中文)"),
  271. PAIR(Language, PortugueseBrazilian, "Brazilian Portuguese (português do Brasil)"),
  272. }});
  273. translations->insert({Settings::EnumMetadata<Settings::Region>::Index(),
  274. {
  275. PAIR(Region, Japan, "Japan"),
  276. PAIR(Region, Usa, "USA"),
  277. PAIR(Region, Europe, "Europe"),
  278. PAIR(Region, Australia, "Australia"),
  279. PAIR(Region, China, "China"),
  280. PAIR(Region, Korea, "Korea"),
  281. PAIR(Region, Taiwan, "Taiwan"),
  282. }});
  283. translations->insert(
  284. {Settings::EnumMetadata<Settings::TimeZone>::Index(),
  285. {
  286. {static_cast<u32>(Settings::TimeZone::Auto),
  287. tr("Auto (%1)", "Auto select time zone")
  288. .arg(QString::fromStdString(
  289. Settings::GetTimeZoneString(Settings::TimeZone::Auto)))},
  290. {static_cast<u32>(Settings::TimeZone::Default),
  291. tr("Default (%1)", "Default time zone")
  292. .arg(QString::fromStdString(Common::TimeZone::GetDefaultTimeZone()))},
  293. PAIR(TimeZone, Cet, "CET"),
  294. PAIR(TimeZone, Cst6Cdt, "CST6CDT"),
  295. PAIR(TimeZone, Cuba, "Cuba"),
  296. PAIR(TimeZone, Eet, "EET"),
  297. PAIR(TimeZone, Egypt, "Egypt"),
  298. PAIR(TimeZone, Eire, "Eire"),
  299. PAIR(TimeZone, Est, "EST"),
  300. PAIR(TimeZone, Est5Edt, "EST5EDT"),
  301. PAIR(TimeZone, Gb, "GB"),
  302. PAIR(TimeZone, GbEire, "GB-Eire"),
  303. PAIR(TimeZone, Gmt, "GMT"),
  304. PAIR(TimeZone, GmtPlusZero, "GMT+0"),
  305. PAIR(TimeZone, GmtMinusZero, "GMT-0"),
  306. PAIR(TimeZone, GmtZero, "GMT0"),
  307. PAIR(TimeZone, Greenwich, "Greenwich"),
  308. PAIR(TimeZone, Hongkong, "Hongkong"),
  309. PAIR(TimeZone, Hst, "HST"),
  310. PAIR(TimeZone, Iceland, "Iceland"),
  311. PAIR(TimeZone, Iran, "Iran"),
  312. PAIR(TimeZone, Israel, "Israel"),
  313. PAIR(TimeZone, Jamaica, "Jamaica"),
  314. PAIR(TimeZone, Japan, "Japan"),
  315. PAIR(TimeZone, Kwajalein, "Kwajalein"),
  316. PAIR(TimeZone, Libya, "Libya"),
  317. PAIR(TimeZone, Met, "MET"),
  318. PAIR(TimeZone, Mst, "MST"),
  319. PAIR(TimeZone, Mst7Mdt, "MST7MDT"),
  320. PAIR(TimeZone, Navajo, "Navajo"),
  321. PAIR(TimeZone, Nz, "NZ"),
  322. PAIR(TimeZone, NzChat, "NZ-CHAT"),
  323. PAIR(TimeZone, Poland, "Poland"),
  324. PAIR(TimeZone, Portugal, "Portugal"),
  325. PAIR(TimeZone, Prc, "PRC"),
  326. PAIR(TimeZone, Pst8Pdt, "PST8PDT"),
  327. PAIR(TimeZone, Roc, "ROC"),
  328. PAIR(TimeZone, Rok, "ROK"),
  329. PAIR(TimeZone, Singapore, "Singapore"),
  330. PAIR(TimeZone, Turkey, "Turkey"),
  331. PAIR(TimeZone, Uct, "UCT"),
  332. PAIR(TimeZone, Universal, "Universal"),
  333. PAIR(TimeZone, Utc, "UTC"),
  334. PAIR(TimeZone, WSu, "W-SU"),
  335. PAIR(TimeZone, Wet, "WET"),
  336. PAIR(TimeZone, Zulu, "Zulu"),
  337. }});
  338. translations->insert({Settings::EnumMetadata<Settings::AudioMode>::Index(),
  339. {
  340. PAIR(AudioMode, Mono, "Mono"),
  341. PAIR(AudioMode, Stereo, "Stereo"),
  342. PAIR(AudioMode, Surround, "Surround"),
  343. }});
  344. translations->insert({Settings::EnumMetadata<Settings::MemoryLayout>::Index(),
  345. {
  346. PAIR(MemoryLayout, Memory_4Gb, "4GB DRAM (Default)"),
  347. PAIR(MemoryLayout, Memory_6Gb, "6GB DRAM (Unsafe)"),
  348. PAIR(MemoryLayout, Memory_8Gb, "8GB DRAM (Unsafe)"),
  349. }});
  350. translations->insert(
  351. {Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
  352. {PAIR(ConsoleMode, Docked, "Docked"), PAIR(ConsoleMode, Handheld, "Handheld")}});
  353. #undef PAIR
  354. #undef CTX_PAIR
  355. return translations;
  356. }
  357. } // namespace ConfigurationShared