From b796b59a64f90b8b2f5c2fd056cc09e53f8132d5 Mon Sep 17 00:00:00 2001 From: DeaTh-G Date: Tue, 4 Feb 2025 07:05:49 +0100 Subject: [PATCH 1/3] use correct size calculation --- UnleashedRecomp/ui/options_menu.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 22860ad2..6b086982 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1388,7 +1388,6 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) auto textX = clipRectMin.x - Scale(0.5f); auto textY = thumbnailMax.y + offsetY; - auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x, 5.0f, desc.c_str()); if (Config::Language == ELanguage::Japanese) { @@ -1405,6 +1404,14 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) textY += annotationFontSize; } + const auto input = RemoveRubyAnnotations(desc.c_str()); + auto lines = Split(input.first.c_str(), g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x); + + for (auto& line : lines) + line = ReAddRubyAnnotations(line, input.second); + + auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, 5.0f, lines); + drawList->PushClipRect(clipRectMin, clipRectMax, false); static auto isScrolling = false; From 0c721b0b83128f5f3428381f0ca5a2d55fd80fa0 Mon Sep 17 00:00:00 2001 From: DeaTh-G Date: Tue, 4 Feb 2025 16:32:21 +0100 Subject: [PATCH 2/3] remove empty lines from descriptions without value desc, move fix --- UnleashedRecomp/ui/imgui_utils.cpp | 8 +++++++- UnleashedRecomp/ui/options_menu.cpp | 14 ++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/UnleashedRecomp/ui/imgui_utils.cpp b/UnleashedRecomp/ui/imgui_utils.cpp index ef5163bf..066f53a2 100644 --- a/UnleashedRecomp/ui/imgui_utils.cpp +++ b/UnleashedRecomp/ui/imgui_utils.cpp @@ -633,7 +633,13 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMar ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float maxWidth, float lineMargin, const char* text) { - return MeasureCentredParagraph(font, fontSize, lineMargin, Split(text, font, fontSize, maxWidth)); + const auto input = RemoveRubyAnnotations(text); + auto lines = Split(input.first.c_str(), font, fontSize, maxWidth); + + for (auto& line : lines) + line = ReAddRubyAnnotations(line, input.second); + + 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) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 6b086982..2373833c 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1373,7 +1373,11 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) desc = buf; } - desc += "\n\n" + g_selectedItem->GetValueDescription(Config::Language); + const auto& valueDescription = g_selectedItem->GetValueDescription(Config::Language); + if (!valueDescription.empty()) + { + desc += "\n\n" + valueDescription; + } } clipRectMin = { clipRectMin.x, thumbnailMax.y }; @@ -1404,13 +1408,7 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) textY += annotationFontSize; } - const auto input = RemoveRubyAnnotations(desc.c_str()); - auto lines = Split(input.first.c_str(), g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x); - - for (auto& line : lines) - line = ReAddRubyAnnotations(line, input.second); - - auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, 5.0f, lines); + auto textSize = MeasureCentredParagraph(g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x, 5.0f, desc.c_str()); drawList->PushClipRect(clipRectMin, clipRectMax, false); From 4eb4e0cddbcd608d3b2ce72e7f6f1fe77fc3008b Mon Sep 17 00:00:00 2001 From: DeaTh-G Date: Tue, 4 Feb 2025 17:01:14 +0100 Subject: [PATCH 3/3] remove calculating the space for the next annotation after the last line --- UnleashedRecomp/ui/imgui_utils.cpp | 2 +- UnleashedRecomp/ui/message_window.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/UnleashedRecomp/ui/imgui_utils.cpp b/UnleashedRecomp/ui/imgui_utils.cpp index 066f53a2..9f7e2766 100644 --- a/UnleashedRecomp/ui/imgui_utils.cpp +++ b/UnleashedRecomp/ui/imgui_utils.cpp @@ -624,7 +624,7 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMar x = std::max(x, textSize.x); y += textSize.y + Scale(lineMargin); - if (paragraph.annotated) + if (paragraph.annotated && i != (annotationRemovedLines.size() - 1)) y += fontSize * ANNOTATION_FONT_SIZE_MODIFIER; } diff --git a/UnleashedRecomp/ui/message_window.cpp b/UnleashedRecomp/ui/message_window.cpp index 8e562c77..fe05b8b3 100644 --- a/UnleashedRecomp/ui/message_window.cpp +++ b/UnleashedRecomp/ui/message_window.cpp @@ -292,9 +292,9 @@ void MessageWindow::Draw() if (Config::Language == ELanguage::Japanese) { textMarginX -= Scale(2.5f); - textMarginY -= Scale(7.5f); + textMarginY -= Scale(2.0f); - textY += Scale(lines.size() % 2 == 0 ? 8.5f : 15.5f); + textY += Scale(lines.size() % 2 == 0 ? 1.5f : 8.0f); } bool isController = hid::IsInputDeviceController();