From 5cbed2fe2225152780afab845387cfd5c4359e59 Mon Sep 17 00:00:00 2001 From: DeaTh-G Date: Thu, 20 Feb 2025 06:52:23 +0100 Subject: [PATCH] fix installer wizard text positioning when a line starts with a normal kana in japanese --- UnleashedRecomp/locale/locale.cpp | 18 +++++++++--------- UnleashedRecomp/ui/imgui_utils.cpp | 10 ++++++++-- UnleashedRecomp/ui/imgui_utils.h | 2 +- UnleashedRecomp/ui/installer_wizard.cpp | 4 +++- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/UnleashedRecomp/locale/locale.cpp b/UnleashedRecomp/locale/locale.cpp index 5fbf1113..59a0b394 100644 --- a/UnleashedRecomp/locale/locale.cpp +++ b/UnleashedRecomp/locale/locale.cpp @@ -293,7 +293,7 @@ std::unordered_map> "Installer_Page_SelectLanguage", { { ELanguage::English, "Please select a language." }, - { ELanguage::Japanese, " [言語:げんご]を[選択:せんたく]してください" }, + { ELanguage::Japanese, "[言語:げんご]を[選択:せんたく]してください" }, { ELanguage::German, "Bitte eine Sprache auswählen." }, { ELanguage::French, "Choisissez une langue." }, { ELanguage::Spanish, "Selecciona un idioma." }, @@ -317,7 +317,7 @@ std::unordered_map> "Installer_Page_SelectGameAndUpdate", { { ELanguage::English, "Add the sources for the game and its title update." }, - { ELanguage::Japanese, " ゲームのソースとタイトルアップデート\n を[追加:ついか]" }, + { ELanguage::Japanese, "ゲームのソースとタイトルアップデート\nを[追加:ついか]" }, { ELanguage::German, "Füge die Quellen für das Spiel und dessen Update hinzu." }, { ELanguage::French, "Ajouter les fichiers du jeu ainsi que ses mises à jour." }, { ELanguage::Spanish, "Añade las fuentes para el juego y su actualización." }, @@ -329,7 +329,7 @@ std::unordered_map> "Installer_Page_SelectDLC", { { ELanguage::English, "Add the sources for the DLC." }, - { ELanguage::Japanese, " DLCのソースを[追加:ついか]" }, + { ELanguage::Japanese, "DLCのソースを[追加:ついか]" }, { ELanguage::German, "Füge die Quellen für die Erweiterungen des Spiels hinzu." }, { ELanguage::French, "Ajouter les fichiers pour les DLCs." }, { ELanguage::Spanish, "Añade las fuentes para el DLC." }, @@ -341,7 +341,7 @@ std::unordered_map> "Installer_Page_CheckSpace", { { ELanguage::English, "The content will be installed to the program's folder.\n\n" }, - { ELanguage::Japanese, " コンテンツはプログラムのフォルダに\n インストールされます\n" }, + { ELanguage::Japanese, "コンテンツはプログラムのフォルダに\nインストールされます\n" }, { ELanguage::German, "Der Inhalt wird in dem Ordner des Programms installiert.\n" }, { ELanguage::French, "Le contenu sera installé dans le même dossier que le programme.\n" }, { ELanguage::Spanish, "El contenido será instalado a la carpeta del programa.\n\n" }, @@ -353,7 +353,7 @@ std::unordered_map> "Installer_Page_Installing", { { ELanguage::English, "Please wait while the content is being installed..." }, - { ELanguage::Japanese, " コンテンツのインストール[中:ちゅう]はお[待:ま]ち\n ください" }, + { ELanguage::Japanese, "コンテンツのインストール[中:ちゅう]はお[待:ま]ち\nください" }, { ELanguage::German, "Bitte warten. Der Inhalt wird installiert..." }, { ELanguage::French, "Veuillez patienter pendant l'installation du contenu..." }, { ELanguage::Spanish, "Por favor, espera mientras el contenido se instala... " }, @@ -365,7 +365,7 @@ std::unordered_map> "Installer_Page_InstallSucceeded", { { ELanguage::English, "Installation complete!\nThis project is brought to you by:" }, - { ELanguage::Japanese, " インストール[完了:かんりょう]!\n プロジェクト[制作:せいさく]:" }, + { ELanguage::Japanese, "インストール[完了:かんりょう]!\nプロジェクト[制作:せいさく]:" }, { ELanguage::German, "Installation abgeschlossen!\nDieses Projekt wird präsentiert von:" }, { ELanguage::French, "Installation terminée !\nCe projet vous est présenté par:" }, { ELanguage::Spanish, "¡Instalación completada!\nEste proyecto ha sido posible gracias a:" }, @@ -377,7 +377,7 @@ std::unordered_map> "Installer_Page_InstallFailed", { { ELanguage::English, "Installation failed.\n\nError: " }, - { ELanguage::Japanese, " インストールに[失敗:しっぱい]しました\n\nエラー: " }, + { ELanguage::Japanese, "インストールに[失敗:しっぱい]しました\n\nエラー: " }, { ELanguage::German, "Installation fehlgeschlagen.\n\nFehler: " }, { ELanguage::French, "L'installation a échouée.\n\nErreur : " }, { ELanguage::Spanish, "La instalación falló.\n\nError: " }, @@ -411,7 +411,7 @@ std::unordered_map> "Installer_Step_RequiredSpace", { { ELanguage::English, "Required space: %2.2f GiB" }, - { ELanguage::Japanese, " [必要:ひつよう]な[容量:ようりょう]: %2.2f GiB" }, + { ELanguage::Japanese, "[必要:ひつよう]な[容量:ようりょう]: %2.2f GiB" }, { ELanguage::German, "Benötigter Speicherplatz:\n%2.2f GiB" }, { ELanguage::French, "Espace nécessaire :\n%2.2f Gio" }, { ELanguage::Spanish, "Espacio necesario: %2.2f GiB" }, @@ -423,7 +423,7 @@ std::unordered_map> "Installer_Step_AvailableSpace", { { ELanguage::English, "Available space: %2.2f GiB" }, - { ELanguage::Japanese, " [使用:しよう][可能:かのう]な[容量:ようりょう]: %2.2f GiB" }, + { ELanguage::Japanese, "[使用:しよう][可能:かのう]な[容量:ようりょう]: %2.2f GiB" }, { ELanguage::German, "Verfügbarer Speicherplatz:\n%2.2f GiB" }, { ELanguage::French, "Espace disponible :\n%2.2f Gio" }, { ELanguage::Spanish, "Espacio disponible: %2.2f GiB" }, diff --git a/UnleashedRecomp/ui/imgui_utils.cpp b/UnleashedRecomp/ui/imgui_utils.cpp index f5f3b12d..7323c9c4 100644 --- a/UnleashedRecomp/ui/imgui_utils.cpp +++ b/UnleashedRecomp/ui/imgui_utils.cpp @@ -670,7 +670,7 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float maxWidt return MeasureCentredParagraph(font, fontSize, lineMargin, lines); } -void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, const ImVec2& pos, float lineMargin, const char* text, std::function drawMethod, std::function annotationDrawMethod, bool isCentred) +void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, const ImVec2& pos, float lineMargin, const char* text, std::function drawMethod, std::function annotationDrawMethod, bool isCentred, bool leadingSpace) { auto annotationFontSize = fontSize * ANNOTATION_FONT_SIZE_MODIFIER; @@ -678,8 +678,14 @@ void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, c auto lines = Split(input.first.c_str(), font, fontSize, maxWidth); for (auto& line : lines) + { line = ReAddRubyAnnotations(line, input.second); - + if (!line.empty() && line.substr(0, 3) != "「" && leadingSpace) + { + line = " " + line; + } + } + auto paragraphSize = MeasureCentredParagraph(font, fontSize, lineMargin, lines); auto offsetY = 0.0f; diff --git a/UnleashedRecomp/ui/imgui_utils.h b/UnleashedRecomp/ui/imgui_utils.h index e641ac2d..e26c546b 100644 --- a/UnleashedRecomp/ui/imgui_utils.h +++ b/UnleashedRecomp/ui/imgui_utils.h @@ -72,7 +72,7 @@ std::vector RemoveAnnotationFromParagraph(const std::vector& annotatedLine); ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMargin, const std::vector& lines); ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float maxWidth, float lineMargin, const char* text); -void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, const ImVec2& pos, float lineMargin, const char* text, std::function drawMethod, std::function annotationDrawMethod, bool isCentred = false); +void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, const ImVec2& pos, float lineMargin, const char* text, std::function drawMethod, std::function annotationDrawMethod, bool isCentred = false, bool leadingSpace = false); float Lerp(float a, float b, float t); float Cubic(float a, float b, float t); float Hermite(float a, float b, float t); diff --git a/UnleashedRecomp/ui/installer_wizard.cpp b/UnleashedRecomp/ui/installer_wizard.cpp index fe587921..8da2d65b 100644 --- a/UnleashedRecomp/ui/installer_wizard.cpp +++ b/UnleashedRecomp/ui/installer_wizard.cpp @@ -800,7 +800,9 @@ static void DrawDescriptionContainer() [=](const char* str, float size, ImVec2 pos) { DrawTextBasic(g_seuratFont, size, pos, IM_COL32(255, 255, 255, 255 * textAlpha), str); - } + }, + false, + Config::Language == ELanguage::Japanese ); drawList->PopClipRect();