mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Adjust size and alignment based on trophy name length
This commit is contained in:
parent
f1cd552f05
commit
2c353d9a20
@ -88,12 +88,22 @@ void TrophyUI::Draw() {
|
|||||||
ImGui::Indent(60);
|
ImGui::Indent(60);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowFontScale((1.2 * AdjustHeight));
|
const std::string combinedString = "Trophy earned!\n%s" + trophy_name;
|
||||||
char earned_text[] = "Trophy earned!\n%s";
|
const float wrap_width =
|
||||||
const float text_height =
|
CalcWrapWidthForPos(GetCursorScreenPos(), (window_size.x - (60 * AdjustWidth)));
|
||||||
ImGui::CalcTextSize(std::strcat(earned_text, trophy_name.c_str())).y;
|
SetWindowFontScale(1.2 * AdjustHeight);
|
||||||
SetCursorPosY((window_size.y - text_height) * 0.5f);
|
// If trophy name exceeds 1 line
|
||||||
|
if (CalcTextSize(trophy_name.c_str()).x > wrap_width) {
|
||||||
|
SetCursorPosY(5 * AdjustHeight);
|
||||||
|
if (CalcTextSize(trophy_name.c_str()).x > (wrap_width * 2)) {
|
||||||
|
SetWindowFontScale(0.95 * AdjustHeight);
|
||||||
|
} else {
|
||||||
|
SetWindowFontScale(1.1 * AdjustHeight);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const float text_height = ImGui::CalcTextSize(combinedString.c_str()).y;
|
||||||
|
SetCursorPosY((window_size.y - text_height) * 0.5);
|
||||||
|
}
|
||||||
ImGui::PushTextWrapPos(window_size.x - (60 * AdjustWidth));
|
ImGui::PushTextWrapPos(window_size.x - (60 * AdjustWidth));
|
||||||
TextWrapped("Trophy earned!\n%s", trophy_name.c_str());
|
TextWrapped("Trophy earned!\n%s", trophy_name.c_str());
|
||||||
ImGui::SameLine(window_size.x - (60 * AdjustWidth));
|
ImGui::SameLine(window_size.x - (60 * AdjustWidth));
|
||||||
@ -104,7 +114,7 @@ void TrophyUI::Draw() {
|
|||||||
} else {
|
} else {
|
||||||
// placeholder
|
// placeholder
|
||||||
const auto pos = GetCursorScreenPos();
|
const auto pos = GetCursorScreenPos();
|
||||||
ImGui::GetWindowDrawList()->AddRectFilled(pos, pos + ImVec2{30.0f * AdjustHeight},
|
ImGui::GetWindowDrawList()->AddRectFilled(pos, pos + ImVec2{50.0f * AdjustHeight},
|
||||||
GetColorU32(ImVec4{0.7f}));
|
GetColorU32(ImVec4{0.7f}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user