mirror of
https://github.com/stenzek/duckstation.git
synced 2025-07-19 00:20:12 +00:00
FullscreenUI: Minor polish to achievements list
This commit is contained in:
parent
43543ddedc
commit
be867c815d
@ -2822,6 +2822,7 @@ void Achievements::DrawAchievementsWindow()
|
|||||||
{ICON_EMOJI_UNLOCKED, TRANSLATE_NOOP("Achievements", "Recently Unlocked")},
|
{ICON_EMOJI_UNLOCKED, TRANSLATE_NOOP("Achievements", "Recently Unlocked")},
|
||||||
{ICON_FA_STOPWATCH, TRANSLATE_NOOP("Achievements", "Active Challenges")},
|
{ICON_FA_STOPWATCH, TRANSLATE_NOOP("Achievements", "Active Challenges")},
|
||||||
{ICON_FA_RULER_HORIZONTAL, TRANSLATE_NOOP("Achievements", "Almost There")},
|
{ICON_FA_RULER_HORIZONTAL, TRANSLATE_NOOP("Achievements", "Almost There")},
|
||||||
|
{ICON_FA_TRIANGLE_EXCLAMATION, TRANSLATE_NOOP("Achievements", "Unsynchronized")},
|
||||||
};
|
};
|
||||||
|
|
||||||
ImGuiFullscreen::ResetFocusHere();
|
ImGuiFullscreen::ResetFocusHere();
|
||||||
@ -2845,7 +2846,7 @@ void Achievements::DrawAchievementsWindow()
|
|||||||
bucket_collapsed ^= ImGuiFullscreen::MenuHeadingButton(
|
bucket_collapsed ^= ImGuiFullscreen::MenuHeadingButton(
|
||||||
TinyString::from_format("{} {}", bucket_names[bucket.bucket_type].first,
|
TinyString::from_format("{} {}", bucket_names[bucket.bucket_type].first,
|
||||||
Host::TranslateToStringView("Achievements", bucket_names[bucket.bucket_type].second)),
|
Host::TranslateToStringView("Achievements", bucket_names[bucket.bucket_type].second)),
|
||||||
bucket_collapsed ? ICON_FA_CHEVRON_DOWN : ICON_FA_CHEVRON_UP);
|
bucket_collapsed ? ICON_FA_CHEVRON_DOWN : ICON_FA_CHEVRON_UP, UIStyle.MediumLargeFontSize);
|
||||||
if (!bucket_collapsed)
|
if (!bucket_collapsed)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < bucket.num_achievements; i++)
|
for (u32 i = 0; i < bucket.num_achievements; i++)
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#include "fmt/core.h"
|
#include "fmt/core.h"
|
||||||
|
|
||||||
#include "IconsFontAwesome6.h"
|
|
||||||
#include "IconsEmoji.h"
|
#include "IconsEmoji.h"
|
||||||
|
#include "IconsFontAwesome6.h"
|
||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
#include "imgui_stdlib.h"
|
#include "imgui_stdlib.h"
|
||||||
|
|
||||||
@ -1481,10 +1481,10 @@ float ImGuiFullscreen::MenuButtonBounds::CalcAvailWidth()
|
|||||||
return ImGui::GetCurrentWindowRead()->WorkRect.GetWidth() - ImGui::GetStyle().FramePadding.x * 2.0f;
|
return ImGui::GetCurrentWindowRead()->WorkRect.GetWidth() - ImGui::GetStyle().FramePadding.x * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::MenuButtonBounds::CalcValueSize(const std::string_view& value)
|
void ImGuiFullscreen::MenuButtonBounds::CalcValueSize(const std::string_view& value, float font_size)
|
||||||
{
|
{
|
||||||
SetValueSize(value.empty() ? ImVec2() :
|
SetValueSize(value.empty() ? ImVec2() :
|
||||||
UIStyle.Font->CalcTextSizeA(UIStyle.LargeFontSize, UIStyle.BoldFontWeight, FLT_MAX,
|
UIStyle.Font->CalcTextSizeA(font_size, UIStyle.BoldFontWeight, FLT_MAX,
|
||||||
available_width * 0.5f, IMSTR_START_END(value)));
|
available_width * 0.5f, IMSTR_START_END(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1494,41 +1494,41 @@ void ImGuiFullscreen::MenuButtonBounds::SetValueSize(const ImVec2& size)
|
|||||||
available_non_value_width = available_width - ((size.x > 0.0f) ? (size.x + LayoutScale(16.0f)) : 0.0f);
|
available_non_value_width = available_width - ((size.x > 0.0f) ? (size.x + LayoutScale(16.0f)) : 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::MenuButtonBounds::CalcTitleSize(const std::string_view& title)
|
void ImGuiFullscreen::MenuButtonBounds::CalcTitleSize(const std::string_view& title, float font_size)
|
||||||
{
|
{
|
||||||
const std::string_view real_title = ImGuiFullscreen::RemoveHash(title);
|
const std::string_view real_title = ImGuiFullscreen::RemoveHash(title);
|
||||||
title_size = real_title.empty() ? ImVec2() :
|
title_size = real_title.empty() ? ImVec2() :
|
||||||
UIStyle.Font->CalcTextSizeA(UIStyle.LargeFontSize, UIStyle.BoldFontWeight, FLT_MAX,
|
UIStyle.Font->CalcTextSizeA(font_size, UIStyle.BoldFontWeight, FLT_MAX,
|
||||||
available_non_value_width, IMSTR_START_END(real_title));
|
available_non_value_width, IMSTR_START_END(real_title));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::MenuButtonBounds::CalcSummarySize(const std::string_view& summary)
|
void ImGuiFullscreen::MenuButtonBounds::CalcSummarySize(const std::string_view& summary, float font_size)
|
||||||
{
|
{
|
||||||
summary_size = summary.empty() ?
|
summary_size = summary.empty() ? ImVec2() :
|
||||||
ImVec2() :
|
UIStyle.Font->CalcTextSizeA(font_size, UIStyle.NormalFontWeight, FLT_MAX,
|
||||||
UIStyle.Font->CalcTextSizeA(UIStyle.MediumFontSize, UIStyle.NormalFontWeight, FLT_MAX,
|
available_non_value_width, IMSTR_START_END(summary));
|
||||||
available_non_value_width, IMSTR_START_END(summary));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiFullscreen::MenuButtonBounds::MenuButtonBounds(const std::string_view& title, const std::string_view& value,
|
ImGuiFullscreen::MenuButtonBounds::MenuButtonBounds(const std::string_view& title, const std::string_view& value,
|
||||||
const std::string_view& summary)
|
const std::string_view& summary)
|
||||||
{
|
{
|
||||||
CalcValueSize(value);
|
CalcValueSize(value, UIStyle.LargeFontSize);
|
||||||
CalcTitleSize(title);
|
CalcTitleSize(title, UIStyle.LargeFontSize);
|
||||||
CalcSummarySize(summary);
|
CalcSummarySize(summary, UIStyle.MediumFontSize);
|
||||||
CalcBB();
|
CalcBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiFullscreen::MenuButtonBounds::MenuButtonBounds(const std::string_view& title, const std::string_view& value,
|
ImGuiFullscreen::MenuButtonBounds::MenuButtonBounds(const std::string_view& title, const std::string_view& value,
|
||||||
const std::string_view& summary, float left_margin)
|
const std::string_view& summary, float left_margin,
|
||||||
|
float title_value_size, float summary_size)
|
||||||
{
|
{
|
||||||
// ugly, but only used for compact game list, whatever
|
// ugly, but only used for compact game list, whatever
|
||||||
const float orig_width = available_width;
|
const float orig_width = available_width;
|
||||||
available_width -= left_margin;
|
available_width -= left_margin;
|
||||||
|
|
||||||
CalcValueSize(value);
|
CalcValueSize(value, title_value_size);
|
||||||
CalcTitleSize(title);
|
CalcTitleSize(title, title_value_size);
|
||||||
CalcSummarySize(summary);
|
CalcSummarySize(summary, summary_size);
|
||||||
|
|
||||||
available_width = orig_width;
|
available_width = orig_width;
|
||||||
|
|
||||||
@ -1544,8 +1544,8 @@ ImGuiFullscreen::MenuButtonBounds::MenuButtonBounds(const std::string_view& titl
|
|||||||
const std::string_view& summary)
|
const std::string_view& summary)
|
||||||
{
|
{
|
||||||
SetValueSize(value_size);
|
SetValueSize(value_size);
|
||||||
CalcTitleSize(title);
|
CalcTitleSize(title, UIStyle.LargeFontSize);
|
||||||
CalcSummarySize(summary);
|
CalcSummarySize(summary, UIStyle.MediumFontSize);
|
||||||
CalcBB();
|
CalcBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1816,9 +1816,10 @@ void ImGuiFullscreen::MenuHeading(std::string_view title, bool draw_line /*= tru
|
|||||||
if (!visible)
|
if (!visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const u32 color = ImGui::GetColorU32(ImGuiCol_TextDisabled);
|
||||||
RenderShadowedTextClipped(UIStyle.Font, UIStyle.LargeFontSize, UIStyle.BoldFontWeight, bb.title_bb.Min,
|
RenderShadowedTextClipped(UIStyle.Font, UIStyle.LargeFontSize, UIStyle.BoldFontWeight, bb.title_bb.Min,
|
||||||
bb.title_bb.Max, ImGui::GetColorU32(ImGuiCol_TextDisabled), title, &bb.title_size,
|
bb.title_bb.Max, color, title, &bb.title_size, ImVec2(0.0f, 0.0f), bb.title_size.x,
|
||||||
ImVec2(0.0f, 0.0f), bb.title_size.x, &bb.title_bb);
|
&bb.title_bb);
|
||||||
|
|
||||||
if (draw_line)
|
if (draw_line)
|
||||||
{
|
{
|
||||||
@ -1827,37 +1828,34 @@ void ImGuiFullscreen::MenuHeading(std::string_view title, bool draw_line /*= tru
|
|||||||
const ImVec2 shadow_offset = LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET);
|
const ImVec2 shadow_offset = LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET);
|
||||||
ImGui::GetWindowDrawList()->AddLine(line_start + shadow_offset, line_end + shadow_offset, UIStyle.ShadowColor,
|
ImGui::GetWindowDrawList()->AddLine(line_start + shadow_offset, line_end + shadow_offset, UIStyle.ShadowColor,
|
||||||
line_thickness);
|
line_thickness);
|
||||||
ImGui::GetWindowDrawList()->AddLine(line_start, line_end, ImGui::GetColorU32(ImGuiCol_TextDisabled),
|
ImGui::GetWindowDrawList()->AddLine(line_start, line_end, color, line_thickness);
|
||||||
line_thickness);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuHeadingButton(std::string_view title, std::string_view value /*= {}*/,
|
bool ImGuiFullscreen::MenuHeadingButton(std::string_view title, std::string_view value /*= {}*/,
|
||||||
bool enabled /*= true*/, bool draw_line /*= true*/)
|
float font_size /*= UIStyle.LargeFontSize */, bool enabled /*= true*/,
|
||||||
|
bool draw_line /*= true*/)
|
||||||
{
|
{
|
||||||
const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f;
|
const MenuButtonBounds bb(title, value, {}, 0.0f, font_size);
|
||||||
const float line_padding = draw_line ? LayoutScale(5.0f) : 0.0f;
|
|
||||||
|
|
||||||
const MenuButtonBounds bb(title, value, {});
|
|
||||||
bool visible, hovered;
|
bool visible, hovered;
|
||||||
const bool pressed = MenuButtonFrame(title, enabled, bb.frame_bb, &visible, &hovered);
|
const bool pressed = MenuButtonFrame(title, enabled, bb.frame_bb, &visible, &hovered);
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
|
const u32 color = ImGui::GetColorU32(ImGuiCol_TextDisabled);
|
||||||
RenderShadowedTextClipped(UIStyle.Font, UIStyle.LargeFontSize, UIStyle.BoldFontWeight, bb.title_bb.Min,
|
RenderShadowedTextClipped(UIStyle.Font, font_size, UIStyle.BoldFontWeight, bb.title_bb.Min, bb.title_bb.Max, color,
|
||||||
bb.title_bb.Max, color, title, &bb.title_size, ImVec2(0.0f, 0.0f), bb.title_size.x,
|
title, &bb.title_size, ImVec2(0.0f, 0.0f), bb.title_size.x, &bb.title_bb);
|
||||||
&bb.title_bb);
|
|
||||||
|
|
||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
{
|
{
|
||||||
RenderShadowedTextClipped(UIStyle.Font, UIStyle.LargeFontSize, UIStyle.BoldFontWeight, bb.value_bb.Min,
|
RenderShadowedTextClipped(UIStyle.Font, font_size, UIStyle.BoldFontWeight, bb.value_bb.Min, bb.value_bb.Max, color,
|
||||||
bb.value_bb.Max, color, value, &bb.value_size, ImVec2(0.0f, 0.0f), bb.value_size.x,
|
value, &bb.value_size, ImVec2(0.0f, 0.0f), bb.value_size.x, &bb.value_bb);
|
||||||
&bb.value_bb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (draw_line)
|
if (draw_line)
|
||||||
{
|
{
|
||||||
|
const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f;
|
||||||
|
const float line_padding = draw_line ? LayoutScale(5.0f) : 0.0f;
|
||||||
const ImVec2 line_start(bb.title_bb.Min.x, bb.title_bb.Max.y + line_padding);
|
const ImVec2 line_start(bb.title_bb.Min.x, bb.title_bb.Max.y + line_padding);
|
||||||
const ImVec2 line_end(bb.title_bb.Min.x + bb.available_width, line_start.y);
|
const ImVec2 line_end(bb.title_bb.Min.x + bb.available_width, line_start.y);
|
||||||
const ImVec2 shadow_offset = LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET);
|
const ImVec2 shadow_offset = LayoutScale(LAYOUT_SHADOW_OFFSET, LAYOUT_SHADOW_OFFSET);
|
||||||
|
@ -305,7 +305,8 @@ void RenderAutoLabelText(ImDrawList* draw_list, ImFont* font, float font_size, f
|
|||||||
void TextAlignedMultiLine(float align_x, const char* text, const char* text_end = nullptr, float wrap_width = -1.0f);
|
void TextAlignedMultiLine(float align_x, const char* text, const char* text_end = nullptr, float wrap_width = -1.0f);
|
||||||
void TextUnformatted(std::string_view text);
|
void TextUnformatted(std::string_view text);
|
||||||
void MenuHeading(std::string_view title, bool draw_line = true);
|
void MenuHeading(std::string_view title, bool draw_line = true);
|
||||||
bool MenuHeadingButton(std::string_view title, std::string_view value = {}, bool enabled = true, bool draw_line = true);
|
bool MenuHeadingButton(std::string_view title, std::string_view value = {}, float font_size = UIStyle.LargeFontSize,
|
||||||
|
bool enabled = true, bool draw_line = true);
|
||||||
bool MenuButton(std::string_view title, std::string_view summary, bool enabled = true,
|
bool MenuButton(std::string_view title, std::string_view summary, bool enabled = true,
|
||||||
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||||
bool MenuButtonWithoutSummary(std::string_view title, bool enabled = true,
|
bool MenuButtonWithoutSummary(std::string_view title, bool enabled = true,
|
||||||
@ -500,7 +501,8 @@ struct MenuButtonBounds
|
|||||||
|
|
||||||
MenuButtonBounds(const std::string_view& title, const std::string_view& value, const std::string_view& summary);
|
MenuButtonBounds(const std::string_view& title, const std::string_view& value, const std::string_view& summary);
|
||||||
MenuButtonBounds(const std::string_view& title, const std::string_view& value, const std::string_view& summary,
|
MenuButtonBounds(const std::string_view& title, const std::string_view& value, const std::string_view& summary,
|
||||||
float left_margin);
|
float left_margin, float title_value_size = UIStyle.LargeFontSize,
|
||||||
|
float summary_size = UIStyle.MediumFontSize);
|
||||||
MenuButtonBounds(const std::string_view& title, const ImVec2& value_size, const std::string_view& summary);
|
MenuButtonBounds(const std::string_view& title, const ImVec2& value_size, const std::string_view& summary);
|
||||||
MenuButtonBounds(const ImVec2& title_size, const ImVec2& value_size, const ImVec2& summary_size);
|
MenuButtonBounds(const ImVec2& title_size, const ImVec2& value_size, const ImVec2& summary_size);
|
||||||
|
|
||||||
@ -510,10 +512,10 @@ struct MenuButtonBounds
|
|||||||
static float GetSummaryLineHeight(float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING);
|
static float GetSummaryLineHeight(float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING);
|
||||||
|
|
||||||
void CalcBB();
|
void CalcBB();
|
||||||
void CalcTitleSize(const std::string_view& title);
|
void CalcTitleSize(const std::string_view& title, float font_size);
|
||||||
void SetValueSize(const ImVec2& value_size);
|
void SetValueSize(const ImVec2& value_size);
|
||||||
void CalcValueSize(const std::string_view& value);
|
void CalcValueSize(const std::string_view& value, float font_size);
|
||||||
void CalcSummarySize(const std::string_view& summary);
|
void CalcSummarySize(const std::string_view& summary, float font_size);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ImGuiFullscreen
|
} // namespace ImGuiFullscreen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user