achievement_menu: fix locked shadow and marquee width

This commit is contained in:
Hyper 2024-12-11 23:03:01 +00:00
parent 4f26d0b263
commit 05ec19874e
2 changed files with 10 additions and 8 deletions

View file

@ -205,13 +205,14 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
drawList->PushClipRect(min, max, true); drawList->PushClipRect(min, max, true);
auto colLockedText = IM_COL32(60, 60, 60, 29); auto colLockedText = IM_COL32(80, 80, 80, 127);
auto colTextShadow = isUnlocked auto colTextShadow = isUnlocked
? IM_COL32(0, 0, 0, 255) ? IM_COL32(0, 0, 0, 255)
: IM_COL32(60, 60, 60, 28); : IM_COL32(20, 20, 20, 127);
auto shadowOffset = isUnlocked ? 2 : 1; auto shadowOffset = isUnlocked ? 2 : 1;
auto shadowRadius = isUnlocked ? 1 : 0.5f;
// Draw achievement name. // Draw achievement name.
DrawTextWithShadow DrawTextWithShadow
@ -222,13 +223,14 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
isUnlocked ? IM_COL32(252, 243, 5, 255) : colLockedText, isUnlocked ? IM_COL32(252, 243, 5, 255) : colLockedText,
achievement.Name.c_str(), achievement.Name.c_str(),
shadowOffset, shadowOffset,
1.0f, shadowRadius,
colTextShadow colTextShadow
); );
ImVec2 marqueeMin = { textMarqueeX, min.y }; ImVec2 marqueeMin = { textMarqueeX, min.y };
ImVec2 marqueeMax = { max.x - Scale(10) /* timestamp margin X */, max.y };
SetMarqueeFade(marqueeMin, max, Scale(32)); SetMarqueeFade(marqueeMin, marqueeMax, Scale(32));
if (isSelected && textX + textSize.x >= max.x - Scale(10)) if (isSelected && textX + textSize.x >= max.x - Scale(10))
{ {
@ -239,14 +241,14 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
fontSize, fontSize,
{ textX, min.y + descTextY }, { textX, min.y + descTextY },
marqueeMin, marqueeMin,
max, marqueeMax,
isUnlocked ? IM_COL32_WHITE : colLockedText, isUnlocked ? IM_COL32_WHITE : colLockedText,
desc, desc,
g_rowSelectionTime, g_rowSelectionTime,
0.9, 0.9,
Scale(250), Scale(250),
shadowOffset, shadowOffset,
0.4f, shadowRadius,
colTextShadow colTextShadow
); );
} }
@ -261,7 +263,7 @@ static void DrawAchievement(int rowIndex, float yOffset, Achievement& achievemen
isUnlocked ? IM_COL32_WHITE : colLockedText, isUnlocked ? IM_COL32_WHITE : colLockedText,
desc, desc,
shadowOffset, shadowOffset,
1.0f, shadowRadius,
colTextShadow colTextShadow
); );
} }

View file

@ -337,7 +337,7 @@ static void DrawCentredParagraph(const ImFont* font, float fontSize, const ImVec
} }
} }
static void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 colour, const char* text, double time, double delay, double speed, float offset = 2.0f, float radius = 0.4f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255)) static void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 colour, const char* text, double time, double delay, double speed, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
{ {
auto drawList = ImGui::GetForegroundDrawList(); auto drawList = ImGui::GetForegroundDrawList();
auto rectWidth = max.x - min.x; auto rectWidth = max.x - min.x;