diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 694e059e7f..66d589487e 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -1,5 +1,6 @@ add_library(rpcs3_emu IdManager.cpp + localized_string.cpp System.cpp system_config.cpp system_config_types.cpp diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index 5948d35bff..4f0c2612bd 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -5,6 +5,8 @@ #include "overlay_utils.h" #include "overlay_fonts.h" +#include "Emu/localized_string.h" + #include #include #include @@ -442,6 +444,12 @@ namespace rsx is_compiled = false; } + virtual void set_text(localized_string_id id) + { + this->text = get_localized_u32string(id); + is_compiled = false; + } + virtual void set_font(const char* font_name, u16 font_size) { font_ref = fontmgr::get(font_name, font_size); @@ -1045,7 +1053,7 @@ namespace rsx struct edit_text : public label { - enum direction + enum class direction { up, down, diff --git a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp index 4c27d2686f..1bfc5b6797 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_edit_text.cpp @@ -33,7 +33,7 @@ namespace rsx { switch (dir) { - case left: + case direction::left: { if (caret_position) { @@ -42,7 +42,7 @@ namespace rsx } break; } - case right: + case direction::right: { if (caret_position < text.length()) { @@ -51,7 +51,7 @@ namespace rsx } break; } - case up: + case direction::up: { const size_t current_line_start = get_line_start(text, caret_position); if (current_line_start == 0) @@ -70,7 +70,7 @@ namespace rsx refresh(); break; } - case down: + case direction::down: { const size_t current_line_end = get_line_end(text, caret_position); if (current_line_end == text.length()) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp index 9176366efc..edfb712ce5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp @@ -40,8 +40,8 @@ namespace rsx m_accept_btn->set_pos(30, height + 20); m_cancel_btn->set_pos(180, height + 20); - m_accept_btn->set_text("Select"); - m_cancel_btn->set_text("Cancel"); + m_accept_btn->set_text(localized_string_id::RSX_OVERLAYS_LIST_SELECT); + m_cancel_btn->set_text(localized_string_id::RSX_OVERLAYS_LIST_CANCEL); m_accept_btn->set_font("Arial", 16); m_cancel_btn->set_font("Arial", 16); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp index 303db62d08..6a32f0393f 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_message_dialog.cpp @@ -29,12 +29,12 @@ namespace rsx progress_1.back_color = color4f(0.25f, 0.f, 0.f, 0.85f); progress_2.back_color = color4f(0.25f, 0.f, 0.f, 0.85f); - btn_ok.set_text("Yes"); + btn_ok.set_text(localized_string_id::RSX_OVERLAYS_MSG_DIALOG_YES); btn_ok.set_size(140, 30); btn_ok.set_pos(545, 420); btn_ok.set_font("Arial", 16); - btn_cancel.set_text("No"); + btn_cancel.set_text(localized_string_id::RSX_OVERLAYS_MSG_DIALOG_NO); btn_cancel.set_size(140, 30); btn_cancel.set_pos(685, 420); btn_cancel.set_font("Arial", 16); @@ -197,13 +197,13 @@ namespace rsx if (interactive) { btn_cancel.set_pos(585, btn_cancel.y); - btn_cancel.set_text("Cancel"); + btn_cancel.set_text(localized_string_id::RSX_OVERLAYS_MSG_DIALOG_CANCEL); cancel_only = true; } break; case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK: btn_ok.set_pos(600, btn_ok.y); - btn_ok.set_text("OK"); + btn_ok.set_text(localized_string_id::RSX_OVERLAYS_MSG_DIALOG_OK); interactive = true; ok_only = true; break; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index c23a130f46..371cdd3aa3 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -227,27 +227,27 @@ namespace rsx m_btn_cancel.set_pos(frame_x, frame_y + frame_h + 10); m_btn_cancel.set_size(140, 30); - m_btn_cancel.set_text("Cancel"); + m_btn_cancel.set_text(localized_string_id::RSX_OVERLAYS_OSK_DIALOG_CANCEL); m_btn_cancel.set_text_vertical_adjust(5); m_btn_space.set_pos(frame_x + 100, frame_y + frame_h + 10); m_btn_space.set_size(100, 30); - m_btn_space.set_text("Space"); + m_btn_space.set_text(localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SPACE); m_btn_space.set_text_vertical_adjust(5); m_btn_delete.set_pos(frame_x + 200, frame_y + frame_h + 10); m_btn_delete.set_size(100, 30); - m_btn_delete.set_text("Backspace"); + m_btn_delete.set_text(localized_string_id::RSX_OVERLAYS_OSK_DIALOG_BACKSPACE); m_btn_delete.set_text_vertical_adjust(5); m_btn_shift.set_pos(frame_x + 320, frame_y + frame_h + 10); m_btn_shift.set_size(80, 30); - m_btn_shift.set_text("Shift"); + m_btn_shift.set_text(localized_string_id::RSX_OVERLAYS_OSK_DIALOG_SHIFT); m_btn_shift.set_text_vertical_adjust(5); m_btn_accept.set_pos(frame_x + 400, frame_y + frame_h + 10); m_btn_accept.set_size(100, 30); - m_btn_accept.set_text("Accept"); + m_btn_accept.set_text(localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ACCEPT); m_btn_accept.set_text_vertical_adjust(5); m_update = true; @@ -662,12 +662,10 @@ namespace rsx std::u32string osk_dialog::get_placeholder() { - if (m_password_mode) - { - return U"[Enter Password]"; - } - - return U"[Enter Text]"; + const localized_string_id id = m_password_mode + ? localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_PASSWORD + : localized_string_id::RSX_OVERLAYS_OSK_DIALOG_ENTER_TEXT; + return get_localized_u32string(id); } void osk_dialog::update() diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index d7a71f4f0c..799fba3fd4 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -90,7 +90,7 @@ namespace rsx m_description->set_font("Arial", 20); m_description->set_pos(20, 37); - m_description->set_text("Save Dialog"); + m_description->set_text(localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_TITLE); m_time_thingy->set_font("Arial", 14); m_time_thingy->set_pos(1000, 30); @@ -176,15 +176,15 @@ namespace rsx if (op >= 8) { - m_description->set_text("Delete Save"); + m_description->set_text(localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_DELETE); } else if (op & 1) { - m_description->set_text("Load Save"); + m_description->set_text(localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_LOAD); } else { - m_description->set_text("Save"); + m_description->set_text(localized_string_id::RSX_OVERLAYS_SAVE_DIALOG_SAVE); } const bool newpos_head = listSet && listSet->newData && listSet->newData->iconPosition == CELL_SAVEDATA_ICONPOS_HEAD; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp index 776e3fb83b..454feb4c30 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_shader_compile_notification.cpp @@ -12,7 +12,7 @@ namespace rsx const u16 pos_y = g_cfg.video.shader_compilation_hint.pos_y; m_text.set_font("Arial", 16); - m_text.set_text("Compiling shaders"); + m_text.set_text(localized_string_id::RSX_OVERLAYS_COMPILING_SHADERS); m_text.auto_resize(); m_text.set_pos(pos_x, pos_y); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp index 63b6605f0d..9ca3dc43c5 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_trophy_notification.cpp @@ -118,18 +118,18 @@ namespace rsx image.set_raw_image(icon_info.get()); } - std::string trophy_message; + localized_string_id string_id = localized_string_id::INVALID; switch (trophy.trophyGrade) { - case SCE_NP_TROPHY_GRADE_BRONZE: trophy_message = "bronze"; break; - case SCE_NP_TROPHY_GRADE_SILVER: trophy_message = "silver"; break; - case SCE_NP_TROPHY_GRADE_GOLD: trophy_message = "gold"; break; - case SCE_NP_TROPHY_GRADE_PLATINUM: trophy_message = "platinum"; break; + case SCE_NP_TROPHY_GRADE_BRONZE: string_id = localized_string_id::RSX_OVERLAYS_TROPHY_BRONZE; break; + case SCE_NP_TROPHY_GRADE_SILVER: string_id = localized_string_id::RSX_OVERLAYS_TROPHY_SILVER; break; + case SCE_NP_TROPHY_GRADE_GOLD: string_id = localized_string_id::RSX_OVERLAYS_TROPHY_GOLD; break; + case SCE_NP_TROPHY_GRADE_PLATINUM: string_id = localized_string_id::RSX_OVERLAYS_TROPHY_PLATINUM; break; default: break; } - trophy_message = "You have earned the " + trophy_message + " trophy\n" + trophy.name; - text_view.set_text(trophy_message); + text_view.set_text(trophy.name); + text_view.set_text(get_localized_u32string(string_id) + text_view.text); text_view.auto_resize(); // Resize background to cover the text diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 78abe687ad..33edaa459e 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -8,6 +8,8 @@ u64 get_system_time(); u64 get_guest_system_time(); +enum class localized_string_id; + enum class system_state { running, @@ -49,6 +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; }; class Emulator final diff --git a/rpcs3/Emu/localized_string.cpp b/rpcs3/Emu/localized_string.cpp new file mode 100644 index 0000000000..c438e063d5 --- /dev/null +++ b/rpcs3/Emu/localized_string.cpp @@ -0,0 +1,13 @@ +#include "stdafx.h" +#include "localized_string.h" +#include "System.h" + +std::string get_localized_string(localized_string_id id) +{ + return Emu.GetCallbacks().get_localized_string(id); +} + +std::u32string get_localized_u32string(localized_string_id id) +{ + return Emu.GetCallbacks().get_localized_u32string(id); +} diff --git a/rpcs3/Emu/localized_string.h b/rpcs3/Emu/localized_string.h new file mode 100644 index 0000000000..6c1a418cb2 --- /dev/null +++ b/rpcs3/Emu/localized_string.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +enum class localized_string_id +{ + INVALID, + + RSX_OVERLAYS_TROPHY_BRONZE, + RSX_OVERLAYS_TROPHY_SILVER, + RSX_OVERLAYS_TROPHY_GOLD, + RSX_OVERLAYS_TROPHY_PLATINUM, + RSX_OVERLAYS_COMPILING_SHADERS, + RSX_OVERLAYS_MSG_DIALOG_YES, + RSX_OVERLAYS_MSG_DIALOG_NO, + RSX_OVERLAYS_MSG_DIALOG_CANCEL, + RSX_OVERLAYS_MSG_DIALOG_OK, + RSX_OVERLAYS_SAVE_DIALOG_TITLE, + RSX_OVERLAYS_SAVE_DIALOG_DELETE, + RSX_OVERLAYS_SAVE_DIALOG_LOAD, + RSX_OVERLAYS_SAVE_DIALOG_SAVE, + RSX_OVERLAYS_OSK_DIALOG_ACCEPT, + RSX_OVERLAYS_OSK_DIALOG_CANCEL, + RSX_OVERLAYS_OSK_DIALOG_SPACE, + RSX_OVERLAYS_OSK_DIALOG_BACKSPACE, + RSX_OVERLAYS_OSK_DIALOG_SHIFT, + RSX_OVERLAYS_OSK_DIALOG_ENTER_TEXT, + RSX_OVERLAYS_OSK_DIALOG_ENTER_PASSWORD, + RSX_OVERLAYS_LIST_SELECT, + RSX_OVERLAYS_LIST_CANCEL, +}; + +std::string get_localized_string(localized_string_id id); +std::u32string get_localized_u32string(localized_string_id id); diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 1ad84bd04d..a05998b9db 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -100,6 +100,7 @@ + @@ -488,6 +489,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 2013b953f1..8a4365a397 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -968,6 +968,9 @@ Emu\NP + + Emu + @@ -1858,6 +1861,9 @@ Emu\NP + + Emu + diff --git a/rpcs3/headless_application.cpp b/rpcs3/headless_application.cpp index e9b715d9ef..765fb6f245 100644 --- a/rpcs3/headless_application.cpp +++ b/rpcs3/headless_application.cpp @@ -98,6 +98,9 @@ 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 {}; }; + Emu.SetCallbacks(std::move(callbacks)); } diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 4ea22fff55..cb7121307d 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -471,6 +471,11 @@ true true + + true + true + true + true true @@ -766,6 +771,11 @@ true true + + true + true + true + true true @@ -1081,6 +1091,11 @@ true true + + true + true + true + true true @@ -1376,6 +1391,11 @@ true true + + true + true + true + true true @@ -1555,6 +1575,7 @@ + @@ -2388,6 +2409,24 @@ .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DWITH_DISCORD_RPC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\release" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DWITH_DISCORD_RPC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\release" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 9a8d8910f4..9bfff284da 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -1090,6 +1090,21 @@ Generated Files\Debug - LLVM + + Gui\settings + + + Generated Files\Release - LLVM + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files\Debug - LLVM + @@ -1415,6 +1430,9 @@ Gui\settings + + Gui\settings + diff --git a/rpcs3/rpcs3qt/CMakeLists.txt b/rpcs3/rpcs3qt/CMakeLists.txt index 268628da6e..7389e97150 100644 --- a/rpcs3/rpcs3qt/CMakeLists.txt +++ b/rpcs3/rpcs3qt/CMakeLists.txt @@ -28,6 +28,7 @@ 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 e8161b1473..aa6fcbbcd3 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -9,6 +9,7 @@ #include "gs_frame.h" #include "gl_gs_frame.h" #include "display_sleep_control.h" +#include "localized_emu.h" #ifdef WITH_DISCORD_RPC #include "_discord_utils.h" @@ -358,6 +359,16 @@ void gui_application::InitializeCallbacks() } }; + callbacks.get_localized_string = [](localized_string_id id) -> std::string + { + return localized_emu::get_string(id); + }; + + callbacks.get_localized_u32string = [](localized_string_id id) -> std::u32string + { + return localized_emu::get_u32string(id); + }; + Emu.SetCallbacks(std::move(callbacks)); } diff --git a/rpcs3/rpcs3qt/localized_emu.cpp b/rpcs3/rpcs3qt/localized_emu.cpp new file mode 100644 index 0000000000..af72b31540 --- /dev/null +++ b/rpcs3/rpcs3qt/localized_emu.cpp @@ -0,0 +1,48 @@ +#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 new file mode 100644 index 0000000000..2ba08e4719 --- /dev/null +++ b/rpcs3/rpcs3qt/localized_emu.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include + +#include "Emu/localized_string.h" + +/** + * Localized emucore string collection class + * Due to special characters this file should stay in UTF-8 format + */ +class localized_emu : public QObject +{ + Q_OBJECT + +public: + localized_emu(); + + static std::string get_string(localized_string_id id); + static std::u32string get_u32string(localized_string_id id); + +private: + static QString translated(localized_string_id id); +};