diff --git a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp index 9ca3dc43c5..ab7b5aca21 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp @@ -128,8 +128,7 @@ namespace rsx default: break; } - text_view.set_text(trophy.name); - text_view.set_text(get_localized_u32string(string_id) + text_view.text); + text_view.set_text(get_localized_u32string(string_id, trophy.name)); text_view.auto_resize(); // Resize background to cover the text diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 33edaa459e..eec81247ef 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -51,8 +51,8 @@ struct EmuCallbacks std::function()> get_osk_dialog; std::function()> get_save_dialog; std::function()> get_trophy_notification_dialog; - std::function get_localized_string; - std::function get_localized_u32string; + std::function get_localized_string; + std::function get_localized_u32string; }; class Emulator final diff --git a/rpcs3/Emu/localized_string.cpp b/rpcs3/Emu/localized_string.cpp index c438e063d5..c8fa79b7a0 100644 --- a/rpcs3/Emu/localized_string.cpp +++ b/rpcs3/Emu/localized_string.cpp @@ -2,12 +2,12 @@ #include "localized_string.h" #include "System.h" -std::string get_localized_string(localized_string_id id) +std::string get_localized_string(localized_string_id id, const char* args) { - return Emu.GetCallbacks().get_localized_string(id); + return Emu.GetCallbacks().get_localized_string(id, args); } -std::u32string get_localized_u32string(localized_string_id id) +std::u32string get_localized_u32string(localized_string_id id, const char* args) { - return Emu.GetCallbacks().get_localized_u32string(id); + return Emu.GetCallbacks().get_localized_u32string(id, args); } diff --git a/rpcs3/Emu/localized_string.h b/rpcs3/Emu/localized_string.h index 6c1a418cb2..0d9fe9ff9a 100644 --- a/rpcs3/Emu/localized_string.h +++ b/rpcs3/Emu/localized_string.h @@ -30,5 +30,5 @@ enum class localized_string_id RSX_OVERLAYS_LIST_CANCEL, }; -std::string get_localized_string(localized_string_id id); -std::u32string get_localized_u32string(localized_string_id id); +std::string get_localized_string(localized_string_id id, const char* args = ""); +std::u32string get_localized_u32string(localized_string_id id, const char* args = ""); diff --git a/rpcs3/headless_application.cpp b/rpcs3/headless_application.cpp index 765fb6f245..c6904fcdf0 100644 --- a/rpcs3/headless_application.cpp +++ b/rpcs3/headless_application.cpp @@ -98,8 +98,8 @@ void headless_application::InitializeCallbacks() callbacks.on_stop = []() {}; callbacks.on_ready = []() {}; - callbacks.get_localized_string = [](localized_string_id) -> std::string { return {}; }; - callbacks.get_localized_u32string = [](localized_string_id) -> std::u32string { return {}; }; + callbacks.get_localized_string = [](localized_string_id, const char*) -> std::string { return {}; }; + callbacks.get_localized_u32string = [](localized_string_id, const char*) -> std::u32string { return {}; }; Emu.SetCallbacks(std::move(callbacks)); } diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index cb7121307d..5972039f0e 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -1575,7 +1575,6 @@ - diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 9bfff284da..b475912212 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -1090,9 +1090,6 @@ Generated Files\Debug - LLVM - - Gui\settings - Generated Files\Release - LLVM diff --git a/rpcs3/rpcs3qt/CMakeLists.txt b/rpcs3/rpcs3qt/CMakeLists.txt index 7389e97150..268628da6e 100644 --- a/rpcs3/rpcs3qt/CMakeLists.txt +++ b/rpcs3/rpcs3qt/CMakeLists.txt @@ -28,7 +28,6 @@ instruction_editor_dialog.cpp kernel_explorer.cpp localized.cpp - localized_emu.cpp log_frame.cpp main_window.cpp memory_string_searcher.cpp diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index aa6fcbbcd3..9cbd06fdfe 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -359,14 +359,14 @@ void gui_application::InitializeCallbacks() } }; - callbacks.get_localized_string = [](localized_string_id id) -> std::string + callbacks.get_localized_string = [](localized_string_id id, const char* args) -> std::string { - return localized_emu::get_string(id); + return localized_emu::get_string(id, args); }; - callbacks.get_localized_u32string = [](localized_string_id id) -> std::u32string + callbacks.get_localized_u32string = [](localized_string_id id, const char* args) -> std::u32string { - return localized_emu::get_u32string(id); + return localized_emu::get_u32string(id, args); }; Emu.SetCallbacks(std::move(callbacks)); diff --git a/rpcs3/rpcs3qt/localized_emu.cpp b/rpcs3/rpcs3qt/localized_emu.cpp deleted file mode 100644 index af72b31540..0000000000 --- a/rpcs3/rpcs3qt/localized_emu.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include "localized_emu.h" - -localized_emu::localized_emu() -{ -} - -QString localized_emu::translated(localized_string_id id) -{ - switch (id) - { - case localized_string_id::RSX_OVERLAYS_TROPHY_BRONZE: return tr("You have earned the bronze trophy\n"); - case localized_string_id::RSX_OVERLAYS_TROPHY_SILVER: return tr("You have earned the silver trophy\n"); - case localized_string_id::RSX_OVERLAYS_TROPHY_GOLD: return tr("You have earned the gold trophy\n"); - case localized_string_id::RSX_OVERLAYS_TROPHY_PLATINUM: return tr("You have earned the platinum trophy\n"); - case localized_string_id::RSX_OVERLAYS_COMPILING_SHADERS: return tr("Compiling shaders"); - case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_YES: return tr("Yes"); - case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_NO: return tr("No"); - case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_CANCEL: return tr("Cancel"); - case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_OK: return tr("OK"); - case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_TITLE: return tr("Save Dialog"); - case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_DELETE: return tr("Delete Save"); - case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_LOAD: return tr("Load Save"); - case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_SAVE: return tr("Save"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ACCEPT: return tr("Accept"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_CANCEL: return tr("Cancel"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SPACE: return tr("Space"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_BACKSPACE: return tr("Backspace"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SHIFT: return tr("Shift"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_TEXT: return tr("[Enter Text]"); - case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_PASSWORD: return tr("[Enter Password]"); - case localized_string_id::RSX_OVERLAYS_LIST_SELECT: return tr("Select"); - case localized_string_id::RSX_OVERLAYS_LIST_CANCEL: return tr("Cancel"); - - case localized_string_id::INVALID: return tr("Invalid"); - default: return tr("Unknown"); - } -} - -std::string localized_emu::get_string(localized_string_id id) -{ - return translated(id).toStdString(); -} - -std::u32string localized_emu::get_u32string(localized_string_id id) -{ - return translated(id).toStdU32String(); -} diff --git a/rpcs3/rpcs3qt/localized_emu.h b/rpcs3/rpcs3qt/localized_emu.h index 2ba08e4719..2dbd589601 100644 --- a/rpcs3/rpcs3qt/localized_emu.h +++ b/rpcs3/rpcs3qt/localized_emu.h @@ -14,11 +14,51 @@ class localized_emu : public QObject Q_OBJECT public: - localized_emu(); + localized_emu() = default; - static std::string get_string(localized_string_id id); - static std::u32string get_u32string(localized_string_id id); + template + static std::string get_string(localized_string_id id, Args&&... args) + { + return translated(id, std::forward(args)...).toStdString(); + } + + template + static std::u32string get_u32string(localized_string_id id, Args&&... args) + { + return translated(id, std::forward(args)...).toStdU32String(); + } private: - static QString translated(localized_string_id id); + template + static QString translated(localized_string_id id, Args&&... args) + { + switch (id) + { + case localized_string_id::RSX_OVERLAYS_TROPHY_BRONZE: return tr("You have earned the bronze trophy\n%0").arg(std::forward(args)...); + case localized_string_id::RSX_OVERLAYS_TROPHY_SILVER: return tr("You have earned the silver trophy\n%0").arg(std::forward(args)...); + case localized_string_id::RSX_OVERLAYS_TROPHY_GOLD: return tr("You have earned the gold trophy\n%0").arg(std::forward(args)...); + case localized_string_id::RSX_OVERLAYS_TROPHY_PLATINUM: return tr("You have earned the platinum trophy\n%0").arg(std::forward(args)...); + case localized_string_id::RSX_OVERLAYS_COMPILING_SHADERS: return tr("Compiling shaders"); + case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_YES: return tr("Yes"); + case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_NO: return tr("No"); + case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_CANCEL: return tr("Cancel"); + case localized_string_id::RSX_OVERLAYS_MSG_DIALOG_OK: return tr("OK"); + case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_TITLE: return tr("Save Dialog"); + case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_DELETE: return tr("Delete Save"); + case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_LOAD: return tr("Load Save"); + case localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_SAVE: return tr("Save"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ACCEPT: return tr("Accept"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_CANCEL: return tr("Cancel"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SPACE: return tr("Space"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_BACKSPACE: return tr("Backspace"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SHIFT: return tr("Shift"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_TEXT: return tr("[Enter Text]"); + case localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_PASSWORD: return tr("[Enter Password]"); + case localized_string_id::RSX_OVERLAYS_LIST_SELECT: return tr("Select"); + case localized_string_id::RSX_OVERLAYS_LIST_CANCEL: return tr("Cancel"); + + case localized_string_id::INVALID: return tr("Invalid"); + default: return tr("Unknown"); + } + } };