diff --git a/UnleashedRecomp/ui/imgui_utils.cpp b/UnleashedRecomp/ui/imgui_utils.cpp index fca8c929..00952aef 100644 --- a/UnleashedRecomp/ui/imgui_utils.cpp +++ b/UnleashedRecomp/ui/imgui_utils.cpp @@ -597,6 +597,8 @@ ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float maxWidt 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) { + float annotationFontSize = fontSize * ANNOTATION_FONT_SIZE_MODIFIER; + const auto& input = RemoveRubyAnnotations(text); auto lines = Split(input.first.c_str(), font, fontSize, maxWidth); auto paragraphSize = MeasureCentredParagraph(font, fontSize, lineMargin, lines); @@ -614,7 +616,7 @@ void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, c const auto& annotationRemovedLine = RemoveAnnotationFromParagraphLine(annotatedLine); auto textSize = font->CalcTextSizeA(fontSize, FLT_MAX, 0, annotationRemovedLine.c_str()); - auto annotationSize = font->CalcTextSizeA(fontSize, FLT_MAX, 0, ""); + auto annotationSize = font->CalcTextSizeA(annotationFontSize, FLT_MAX, 0, ""); float textX = pos.x; if (isCentred) @@ -635,10 +637,10 @@ void DrawRubyAnnotatedText(const ImFont* font, float fontSize, float maxWidth, c if (segment.annotated) { - annotationSize = font->CalcTextSizeA(fontSize * 0.55f, FLT_MAX, 0, segment.annotation.c_str()); + annotationSize = font->CalcTextSizeA(annotationFontSize, FLT_MAX, 0, segment.annotation.c_str()); float annotationX = textX + (textSize.x - annotationSize.x) / 2.0f; - annotationDrawMethod(segment.annotation.c_str(), fontSize * 0.55f, { annotationX, textY - (fontSize * 0.55f) }); + annotationDrawMethod(segment.annotation.c_str(), annotationFontSize, { annotationX, textY - annotationFontSize }); } drawMethod(segment.text.c_str(), { textX, textY }); diff --git a/UnleashedRecomp/ui/imgui_utils.h b/UnleashedRecomp/ui/imgui_utils.h index faaa9ab5..2398f954 100644 --- a/UnleashedRecomp/ui/imgui_utils.h +++ b/UnleashedRecomp/ui/imgui_utils.h @@ -14,6 +14,8 @@ #define BREATHE_MOTION(start, end, time, rate) Lerp(start, end, (sin((ImGui::GetTime() - time) * (2.0f * M_PI / rate)) + 1.0f) / 2.0f) +constexpr float ANNOTATION_FONT_SIZE_MODIFIER = 0.6f; + extern std::unique_ptr g_texGeneralWindow; extern std::unique_ptr g_texLight; extern std::unique_ptr g_texSelectFade; diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index eca58a49..c03e08da 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1252,20 +1252,37 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) desc += "\n\n" + g_selectedItem->GetValueDescription(Config::Language); } - auto fontSize = Scale(26.0f); + auto fontSize = Scale(28.0f); + auto annotationFontSize = fontSize * ANNOTATION_FONT_SIZE_MODIFIER; + + // Extra padding between the start of the description text and the bottom of the thumbnail + float offsetY = Scale(24.0f); - float offsetY = 0.0f; + float textX = clipRectMin.x - Scale(0.5f); + float textY = thumbnailMax.y + offsetY; + if (Config::Language == ELanguage::Japanese) { - offsetY = Scale(10.0f); + // Removing some padding of the applied due to the inclusion of annotation for Japanese + textY -= Scale(8.0f); + + // The annotation (and thus the Japanese) can be drawn above the edges of the info panel thus the clip needs to be extended a bit + clipRectMin.x -= annotationFontSize; + clipRectMin.y -= annotationFontSize; + clipRectMax.x += annotationFontSize; + clipRectMax.y += annotationFontSize; + + textY += annotationFontSize; } + drawList->PushClipRect(clipRectMin, clipRectMax, false); + DrawRubyAnnotatedText ( g_seuratFont, fontSize, clipRectMax.x - clipRectMin.x, - { clipRectMin.x, thumbnailMax.y + fontSize - 5.0f + offsetY }, + { textX, textY }, 5.0f, desc.c_str(), @@ -1278,6 +1295,8 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) DrawTextBasic(g_seuratFont, size, pos, IM_COL32(255, 255, 255, 255), str); } ); + + drawList->PopClipRect(); } ResetProceduralOrigin();