mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
fully support annotated text in options menu
This commit is contained in:
parent
703684b9c7
commit
810ca6865d
3 changed files with 30 additions and 7 deletions
|
|
@ -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<void(const char*, ImVec2)> drawMethod, std::function<void(const char*, float, ImVec2)> 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 });
|
||||
|
|
|
|||
|
|
@ -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<GuestTexture> g_texGeneralWindow;
|
||||
extern std::unique_ptr<GuestTexture> g_texLight;
|
||||
extern std::unique_ptr<GuestTexture> g_texSelectFade;
|
||||
|
|
|
|||
|
|
@ -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 textX = clipRectMin.x - Scale(0.5f);
|
||||
float textY = thumbnailMax.y + offsetY;
|
||||
|
||||
float offsetY = 0.0f;
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue