achievement_menu: fix timestamp and scroll bar padding

This commit is contained in:
Hyper 2024-12-03 22:07:33 +00:00
parent 578dc8c186
commit b8ca2c49b0
2 changed files with 10 additions and 6 deletions

View file

@ -140,7 +140,7 @@ static void DrawHeaderContainer(const char* text)
( (
g_fntNewRodinUB, g_fntNewRodinUB,
fontSize, fontSize,
{ /* X */ min.x + textMarginX, /* Y */ min.y + ((max.y - min.y) - textSize.y) / 2 - Scale(5) }, { /* X */ min.x + textMarginX, /* Y */ CENTRE_TEXT_VERT(min, max, textSize) - Scale(5) },
IM_COL32(255, 255, 255, 255 * alpha), IM_COL32(255, 255, 255, 255 * alpha),
text, text,
3, 3,
@ -265,11 +265,11 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
localtime_s(&time, &timestamp); localtime_s(&time, &timestamp);
strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M", &time); strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M", &time);
fontSize = Scale(14); fontSize = Scale(12);
textSize = g_fntNewRodinDB->CalcTextSizeA(fontSize, FLT_MAX, 0, buffer); textSize = g_fntNewRodinDB->CalcTextSizeA(fontSize, FLT_MAX, 0, buffer);
auto containerMarginX = Scale(10); auto containerMarginX = Scale(10);
auto textMarginX = Scale(3); auto textMarginX = Scale(8);
ImVec2 timestampMin = { max.x - containerMarginX - textSize.x - (textMarginX * 2), min.y + titleTextY }; ImVec2 timestampMin = { max.x - containerMarginX - textSize.x - (textMarginX * 2), min.y + titleTextY };
ImVec2 timestampMax = { max.x - containerMarginX, min.y + Scale(46) }; ImVec2 timestampMax = { max.x - containerMarginX, min.y + Scale(46) };
@ -330,11 +330,12 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
IM_COL32(16, 16, 16, 192) IM_COL32(16, 16, 16, 192)
); );
// Draw timestamp text.
DrawTextWithOutline<int> DrawTextWithOutline<int>
( (
g_fntNewRodinDB, g_fntNewRodinDB,
fontSize, fontSize,
{ /* X */ timestampMin.x + textMarginX, /* Y */ timestampMin.y + ((timestampMax.y - timestampMin.y) - textSize.y) / 2 }, { /* X */ CENTRE_TEXT_HORZ(timestampMin, timestampMax, textSize), /* Y */ CENTRE_TEXT_VERT(timestampMin, timestampMax, textSize) },
IM_COL32(255, 255, 255, 255), IM_COL32(255, 255, 255, 255),
buffer, buffer,
2, 2,
@ -379,7 +380,7 @@ static void DrawAchievementTotal(ImVec2 min, ImVec2 max)
( (
g_fntNewRodinDB, g_fntNewRodinDB,
fontSize, fontSize,
{ /* X */ imageMin.x - textSize.x - Scale(6), /* Y */ imageMin.y + ((imageMax.y - imageMin.y) - textSize.y) / 2 }, { /* X */ imageMin.x - textSize.x - Scale(6), /* Y */ CENTRE_TEXT_VERT(imageMin, imageMax, textSize) },
IM_COL32(255, 255, 255, 255 * alpha), IM_COL32(255, 255, 255, 255 * alpha),
str.c_str(), str.c_str(),
2, 2,
@ -562,7 +563,7 @@ static void DrawContentContainer()
if (rowCount > visibleRowCount) if (rowCount > visibleRowCount)
{ {
float cornerRadius = Scale(25); float cornerRadius = Scale(25);
float totalHeight = (clipRectMax.y - clipRectMin.y - cornerRadius) - Scale(3); float totalHeight = (clipRectMax.y - clipRectMin.y - cornerRadius) - Scale(5);
float heightRatio = float(visibleRowCount) / float(rowCount); float heightRatio = float(visibleRowCount) / float(rowCount);
float offsetRatio = float(g_firstVisibleRowIndex) / float(rowCount); float offsetRatio = float(g_firstVisibleRowIndex) / float(rowCount);
float offsetX = clipRectMax.x - Scale(39); float offsetX = clipRectMax.x - Scale(39);

View file

@ -10,6 +10,9 @@
#define GET_UV_COORDS(tuple) std::get<0>(tuple), std::get<1>(tuple) #define GET_UV_COORDS(tuple) std::get<0>(tuple), std::get<1>(tuple)
#define CENTRE_TEXT_HORZ(min, max, textSize) min.x + ((max.x - min.x) - textSize.x) / 2
#define CENTRE_TEXT_VERT(min, max, textSize) min.y + ((max.y - min.y) - textSize.y) / 2
static std::vector<std::unique_ptr<ImGuiCallbackData>> g_callbackData; static std::vector<std::unique_ptr<ImGuiCallbackData>> g_callbackData;
static uint32_t g_callbackDataIndex = 0; static uint32_t g_callbackDataIndex = 0;