mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-03 02:00:05 +00:00
FullscreenUI: Mostly replace C string usage with string_view
This commit is contained in:
parent
8f8f7cd1cb
commit
057398b4ab
@ -13,7 +13,7 @@ with open(src_file, "r") as f:
|
||||
full_source = f.read()
|
||||
|
||||
strings = set()
|
||||
for token in ["FSUI_STR", "FSUI_CSTR", "FSUI_FSTR", "FSUI_NSTR", "FSUI_ICONSTR", "FSUI_VSTR"]:
|
||||
for token in ["FSUI_STR", "FSUI_CSTR", "FSUI_FSTR", "FSUI_NSTR", "FSUI_VSTR", "FSUI_ICONSTR", "FSUI_ICONVSTR", "FSUI_ICONCSTR"]:
|
||||
token_len = len(token)
|
||||
last_pos = 0
|
||||
while True:
|
||||
|
@ -2433,10 +2433,9 @@ void Achievements::DrawGameOverlays()
|
||||
AchievementProgressIndicator& indicator = s_state.active_progress_indicator.value();
|
||||
const float opacity = IndicatorOpacity(io.DeltaTime, indicator);
|
||||
|
||||
const char* text_start = s_state.active_progress_indicator->achievement->measured_progress;
|
||||
const char* text_end = text_start + std::strlen(text_start);
|
||||
const std::string_view text = s_state.active_progress_indicator->achievement->measured_progress;
|
||||
const ImVec2 text_size =
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, text_start, text_end);
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(text));
|
||||
|
||||
const ImVec2 box_min = ImVec2(position.x - image_size.x - text_size.x - spacing - padding * 2.0f,
|
||||
position.y - image_size.y - padding * 2.0f);
|
||||
@ -2457,8 +2456,8 @@ void Achievements::DrawGameOverlays()
|
||||
box_min + ImVec2(padding + image_size.x + spacing, (box_max.y - box_min.y - text_size.y) * 0.5f);
|
||||
const ImRect text_clip_rect(text_pos, box_max);
|
||||
RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, box_max,
|
||||
ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity)), text_start, text_end,
|
||||
&text_size, ImVec2(0.0f, 0.0f), 0.0f, &text_clip_rect);
|
||||
ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity)), text, &text_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &text_clip_rect);
|
||||
|
||||
if (!indicator.active && opacity <= 0.01f)
|
||||
{
|
||||
@ -2481,7 +2480,7 @@ void Achievements::DrawGameOverlays()
|
||||
for (u32 i = 0; i < indicator.text.length(); i++)
|
||||
width_string.append('0');
|
||||
const ImVec2 size = ImGuiFullscreen::UIStyle.MediumFont->CalcTextSizeA(
|
||||
ImGuiFullscreen::UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, width_string.c_str(), width_string.end_ptr());
|
||||
ImGuiFullscreen::UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(width_string));
|
||||
|
||||
const ImRect box(ImVec2(position.x - size.x - padding * 2.0f, position.y - size.y - padding * 2.0f), position);
|
||||
dl->AddRectFilled(box.Min, box.Max,
|
||||
@ -2489,16 +2488,14 @@ void Achievements::DrawGameOverlays()
|
||||
|
||||
const u32 text_col = ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity));
|
||||
const ImVec2 text_size = ImGuiFullscreen::UIStyle.MediumFont->CalcTextSizeA(
|
||||
ImGuiFullscreen::UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, indicator.text.c_str(),
|
||||
indicator.text.c_str() + indicator.text.length());
|
||||
ImGuiFullscreen::UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(indicator.text));
|
||||
const ImVec2 text_pos = ImVec2(box.Max.x - padding - text_size.x, box.Min.y + padding);
|
||||
RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, box.Max, text_col, indicator.text.c_str(),
|
||||
indicator.text.c_str() + indicator.text.length(), &text_size, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&box);
|
||||
RenderShadowedTextClipped(dl, UIStyle.MediumFont, text_pos, box.Max, text_col, indicator.text, &text_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &box);
|
||||
|
||||
const ImVec2 icon_pos = ImVec2(box.Min.x + padding, box.Min.y + padding);
|
||||
RenderShadowedTextClipped(dl, UIStyle.MediumFont, icon_pos, box.Max, text_col, ICON_FA_STOPWATCH, nullptr,
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &box);
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &box);
|
||||
|
||||
if (!indicator.active && opacity <= 0.01f)
|
||||
{
|
||||
@ -2555,11 +2552,10 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
|
||||
const auto get_achievement_height = [&badge_size, &badge_text_width, &text_spacing](std::string_view description,
|
||||
bool show_measured) {
|
||||
const ImVec2 description_size =
|
||||
description.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, badge_text_width, description.data(),
|
||||
description.data() + description.length());
|
||||
const ImVec2 description_size = description.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX,
|
||||
badge_text_width, IMSTR_START_END(description));
|
||||
const float text_height = UIStyle.MediumFont->FontSize + text_spacing + description_size.y;
|
||||
return std::max(text_height, badge_size);
|
||||
};
|
||||
@ -2596,26 +2592,25 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
const ImVec2 image_max = ImVec2(text_pos.x + badge_size, text_pos.y + badge_size);
|
||||
ImVec2 badge_text_pos = ImVec2(image_max.x + text_spacing + text_spacing, text_pos.y);
|
||||
const ImVec4 clip_rect = ImVec4(badge_text_pos.x, badge_text_pos.y, badge_text_pos.x + badge_text_width, box_max.y);
|
||||
const ImVec2 description_size =
|
||||
description.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, badge_text_width, description.data(),
|
||||
description.data() + description.length());
|
||||
const ImVec2 description_size = description.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX,
|
||||
badge_text_width, IMSTR_START_END(description));
|
||||
|
||||
GPUTexture* badge_tex = ImGuiFullscreen::GetCachedTextureAsync(badge_path);
|
||||
dl->AddImage(badge_tex, text_pos, image_max);
|
||||
|
||||
if (!title.empty())
|
||||
{
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, badge_text_pos, title_text_color, title.data(),
|
||||
title.data() + title.length(), 0.0f, &clip_rect);
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, badge_text_pos, title_text_color,
|
||||
IMSTR_START_END(title), 0.0f, &clip_rect);
|
||||
badge_text_pos.y += UIStyle.MediumFont->FontSize + text_spacing;
|
||||
}
|
||||
|
||||
if (!description.empty())
|
||||
{
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, badge_text_pos, text_color, description.data(),
|
||||
description.data() + description.length(), badge_text_width, &clip_rect);
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, badge_text_pos, text_color,
|
||||
IMSTR_START_END(description), badge_text_width, &clip_rect);
|
||||
badge_text_pos.y += description_size.y;
|
||||
}
|
||||
|
||||
@ -2631,11 +2626,10 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
const float unlocked_fraction = static_cast<float>(s_state.game_summary.num_unlocked_achievements) /
|
||||
static_cast<float>(s_state.game_summary.num_core_achievements);
|
||||
buffer.format("{}%", static_cast<u32>(std::ceil(unlocked_fraction * 100.0f)));
|
||||
text_size =
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, buffer.c_str(), buffer.end_ptr());
|
||||
text_size = UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(buffer));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize,
|
||||
ImVec2(text_pos.x + (box_content_width - text_size.x), text_pos.y), text_color, buffer.c_str(),
|
||||
buffer.end_ptr());
|
||||
ImVec2(text_pos.x + (box_content_width - text_size.x), text_pos.y), text_color,
|
||||
IMSTR_START_END(buffer));
|
||||
text_pos.y += UIStyle.MediumFont->FontSize + paragraph_spacing;
|
||||
|
||||
const ImRect progress_bb(text_pos, text_pos + ImVec2(box_content_width, progress_height));
|
||||
@ -2650,12 +2644,11 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
}
|
||||
|
||||
buffer.format("{}/{}", s_state.game_summary.num_unlocked_achievements, s_state.game_summary.num_core_achievements);
|
||||
text_size =
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, buffer.c_str(), buffer.end_ptr());
|
||||
text_size = UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(buffer));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize,
|
||||
ImVec2(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f)),
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), buffer.c_str(), buffer.end_ptr());
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), IMSTR_START_END(buffer));
|
||||
text_pos.y += progress_height + paragraph_spacing;
|
||||
|
||||
if (pending_count > 0)
|
||||
@ -2663,8 +2656,8 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
buffer.format(ICON_EMOJI_WARNING " {}",
|
||||
TRANSLATE_PLURAL_SSTR("Achievements", "%n unlocks have not been confirmed by the server.",
|
||||
"Pause Menu", pending_count));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, title_text_color, buffer.c_str(),
|
||||
buffer.end_ptr());
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, title_text_color,
|
||||
IMSTR_START_END(buffer));
|
||||
text_pos.y += UIStyle.MediumFont->FontSize + paragraph_spacing;
|
||||
}
|
||||
}
|
||||
@ -2672,8 +2665,7 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
if (s_state.most_recent_unlock.has_value())
|
||||
{
|
||||
buffer.format(ICON_FA_LOCK_OPEN " {}", TRANSLATE_DISAMBIG_SV("Achievements", "Most Recent", "Pause Menu"));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, buffer.c_str(),
|
||||
buffer.end_ptr());
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, IMSTR_START_END(buffer));
|
||||
text_pos.y += UIStyle.MediumFont->FontSize + paragraph_spacing;
|
||||
|
||||
draw_achievement_with_summary(s_state.most_recent_unlock->title, s_state.most_recent_unlock->description,
|
||||
@ -2686,8 +2678,7 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
if (s_state.achievement_nearest_completion.has_value())
|
||||
{
|
||||
buffer.format(ICON_FA_LOCK " {}", TRANSLATE_DISAMBIG_SV("Achievements", "Nearest Completion", "Pause Menu"));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, buffer.c_str(),
|
||||
buffer.end_ptr());
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, IMSTR_START_END(buffer));
|
||||
text_pos.y += UIStyle.MediumFont->FontSize + paragraph_spacing;
|
||||
|
||||
draw_achievement_with_summary(s_state.achievement_nearest_completion->title,
|
||||
@ -2716,8 +2707,7 @@ void Achievements::DrawPauseMenuOverlays(float start_pos_y)
|
||||
|
||||
buffer.format(ICON_FA_STOPWATCH " {}",
|
||||
TRANSLATE_DISAMBIG_SV("Achievements", "Active Challenge Achievements", "Pause Menu"));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, buffer.c_str(),
|
||||
buffer.end_ptr());
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos, text_color, IMSTR_START_END(buffer));
|
||||
text_pos.y += UIStyle.MediumFont->FontSize;
|
||||
|
||||
for (const AchievementChallengeIndicator& indicator : s_state.active_challenge_indicators)
|
||||
@ -2794,7 +2784,7 @@ void Achievements::DrawAchievementsWindow()
|
||||
|
||||
if (!s_state.game_icon.empty())
|
||||
{
|
||||
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(s_state.game_icon.c_str());
|
||||
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(s_state.game_icon);
|
||||
if (badge)
|
||||
{
|
||||
ImGui::GetWindowDrawList()->AddImage(badge, icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f),
|
||||
@ -2821,8 +2811,8 @@ void Achievements::DrawAchievementsWindow()
|
||||
|
||||
top += UIStyle.LargeFont->FontSize + spacing;
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, ImGui::GetColorU32(ImGuiCol_Text),
|
||||
text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, ImGui::GetColorU32(ImGuiCol_Text), text,
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + UIStyle.MediumFont->FontSize));
|
||||
if (s_state.game_summary.num_core_achievements > 0)
|
||||
@ -2849,8 +2839,8 @@ void Achievements::DrawAchievementsWindow()
|
||||
|
||||
RenderShadowedTextClipped(
|
||||
UIStyle.MediumFont, summary_bb.Min, summary_bb.Max,
|
||||
ImGui::GetColorU32(ImGuiFullscreen::DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), text.c_str(),
|
||||
text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
ImGui::GetColorU32(ImGuiFullscreen::DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), text, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
|
||||
if (s_state.game_summary.num_core_achievements > 0)
|
||||
{
|
||||
@ -2870,12 +2860,12 @@ void Achievements::DrawAchievementsWindow()
|
||||
|
||||
text.format("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
text_size =
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, text.c_str(), text.end_ptr());
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(text));
|
||||
const ImVec2 text_pos(
|
||||
progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos,
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), text.c_str(), text.end_ptr());
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), IMSTR_START_END(text));
|
||||
// top += progress_height + spacing;
|
||||
}
|
||||
}
|
||||
@ -3028,11 +3018,11 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
const float midpoint = bb.Min.y + UIStyle.LargeFont->FontSize + spacing;
|
||||
text = TRANSLATE_PLURAL_SSTR("Achievements", "%n points", "Achievement points", cheevo->points);
|
||||
const ImVec2 points_size(
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, text.c_str(), text.end_ptr()));
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(text)));
|
||||
const float points_template_start = bb.Max.x - points_template_size.x;
|
||||
const float points_start = points_template_start + ((points_template_size.x - points_size.x) * 0.5f);
|
||||
|
||||
const char* right_icon_text;
|
||||
std::string_view right_icon_text;
|
||||
switch (cheevo->type)
|
||||
{
|
||||
case RC_CLIENT_ACHIEVEMENT_TYPE_MISSABLE:
|
||||
@ -3054,8 +3044,8 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
break;
|
||||
}
|
||||
|
||||
const ImVec2 right_icon_size(
|
||||
UIStyle.LargeFont->CalcTextSizeA(UIStyle.LargeFont->FontSize, FLT_MAX, 0.0f, right_icon_text));
|
||||
const ImVec2 right_icon_size =
|
||||
UIStyle.LargeFont->CalcTextSizeA(UIStyle.LargeFont->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(right_icon_text));
|
||||
|
||||
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
|
||||
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(points_start, midpoint));
|
||||
@ -3067,18 +3057,18 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
const ImRect lock_bb(ImVec2(points_template_start + ((points_template_size.x - right_icon_size.x) * 0.5f), bb.Min.y),
|
||||
ImVec2(bb.Max.x, midpoint));
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, cheevo->title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, cheevo->title, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, lock_bb.Min, lock_bb.Max, text_color, right_icon_text, nullptr,
|
||||
&right_icon_size, ImVec2(0.0f, 0.0f), 0.0f, &lock_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, points_bb.Min, points_bb.Max, summary_color, text.c_str(),
|
||||
text.end_ptr(), &points_size, ImVec2(0.0f, 0.0f), 0.0f, &points_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, lock_bb.Min, lock_bb.Max, text_color, right_icon_text, &right_icon_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &lock_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, points_bb.Min, points_bb.Max, summary_color, text, &points_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &points_bb);
|
||||
|
||||
if (cheevo->description && summary_length > 0)
|
||||
{
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, summary_color, cheevo->description,
|
||||
cheevo->description + summary_length, &summary_text_size, ImVec2(0.0f, 0.0f),
|
||||
summary_wrap_width, &summary_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, summary_color,
|
||||
std::string_view(cheevo->description, summary_length), &summary_text_size,
|
||||
ImVec2(0.0f, 0.0f), summary_wrap_width, &summary_bb);
|
||||
}
|
||||
|
||||
// display hc if hc is active
|
||||
@ -3091,14 +3081,14 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
text.format(TRANSLATE_FS("Achievements", "Unlocked: {} | {:.1f}% of players have this achievement"), date,
|
||||
rarity_to_display);
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, unlock_rarity_bb.Min, unlock_rarity_bb.Max, rarity_color,
|
||||
text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &unlock_rarity_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, unlock_rarity_bb.Min, unlock_rarity_bb.Max, rarity_color, text,
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &unlock_rarity_bb);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.format(TRANSLATE_FS("Achievements", "{:.1f}% of players have this achievement"), rarity_to_display);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, unlock_rarity_bb.Min, unlock_rarity_bb.Max, rarity_color,
|
||||
text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &unlock_rarity_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, unlock_rarity_bb.Min, unlock_rarity_bb.Max, rarity_color, text,
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &unlock_rarity_bb);
|
||||
}
|
||||
|
||||
if (!is_unlocked && is_measured)
|
||||
@ -3116,14 +3106,12 @@ void Achievements::DrawAchievement(const rc_client_achievement_t* cheevo)
|
||||
dl->AddRectFilled(progress_bb.Min, ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UIStyle.SecondaryColor), progress_rounding);
|
||||
|
||||
const ImVec2 text_size =
|
||||
UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f, measured_progress.data(),
|
||||
measured_progress.data() + measured_progress.size());
|
||||
const ImVec2 text_size = UIStyle.MediumFont->CalcTextSizeA(UIStyle.MediumFont->FontSize, FLT_MAX, 0.0f,
|
||||
IMSTR_START_END(measured_progress));
|
||||
const ImVec2 text_pos(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos,
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UIStyle.PrimaryTextColor), measured_progress.data(),
|
||||
measured_progress.data() + measured_progress.size());
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UIStyle.PrimaryTextColor), IMSTR_START_END(measured_progress));
|
||||
}
|
||||
|
||||
if (clicked)
|
||||
@ -3225,7 +3213,7 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
|
||||
if (!s_state.game_icon.empty())
|
||||
{
|
||||
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(s_state.game_icon.c_str());
|
||||
GPUTexture* badge = ImGuiFullscreen::GetCachedTextureAsync(s_state.game_icon);
|
||||
if (badge)
|
||||
{
|
||||
ImGui::GetWindowDrawList()->AddImage(badge, icon_min, icon_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f),
|
||||
@ -3261,8 +3249,8 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
|
||||
top += UIStyle.LargeFont->FontSize + spacing;
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, text.c_str(), text.end_ptr(),
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, text, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
u32 summary_color;
|
||||
if (is_leaderboard_open)
|
||||
@ -3273,8 +3261,8 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
top += UIStyle.LargeFont->FontSize + spacing_small;
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, subtitle_bb.Min, subtitle_bb.Max,
|
||||
ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])),
|
||||
text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &subtitle_bb);
|
||||
ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), text,
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &subtitle_bb);
|
||||
|
||||
text.assign(s_state.open_leaderboard->description);
|
||||
summary_color = ImGui::GetColorU32(DarkerColor(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])));
|
||||
@ -3291,8 +3279,8 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + UIStyle.MediumFont->FontSize));
|
||||
top += UIStyle.MediumFont->FontSize + spacing_small;
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, summary_color, text.c_str(),
|
||||
text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max, summary_color, text, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
|
||||
if (!is_leaderboard_open && !Achievements::IsHardcoreModeActive())
|
||||
{
|
||||
@ -3306,8 +3294,7 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, hardcore_warning_bb.Min, hardcore_warning_bb.Max,
|
||||
ImGui::GetColorU32(DarkerColor(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text]))),
|
||||
text.c_str(), text.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&hardcore_warning_bb);
|
||||
text, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &hardcore_warning_bb);
|
||||
}
|
||||
|
||||
if (is_leaderboard_open)
|
||||
@ -3360,14 +3347,12 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
|
||||
const ImRect rank_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, rank_bb.Min, rank_bb.Max, heading_color,
|
||||
TRANSLATE("Achievements", "Rank"), nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&rank_bb);
|
||||
TRANSLATE_SV("Achievements", "Rank"), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &rank_bb);
|
||||
text_start_x += rank_column_width + column_spacing;
|
||||
|
||||
const ImRect user_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, user_bb.Min, user_bb.Max, heading_color,
|
||||
TRANSLATE("Achievements", "Name"), nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&user_bb);
|
||||
TRANSLATE_SV("Achievements", "Name"), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &user_bb);
|
||||
text_start_x += name_column_width + column_spacing;
|
||||
|
||||
static const char* value_headings[NUM_RC_CLIENT_LEADERBOARD_FORMATS] = {
|
||||
@ -3379,16 +3364,16 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
const ImRect score_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(
|
||||
UIStyle.LargeFont, score_bb.Min, score_bb.Max, heading_color,
|
||||
Host::TranslateToCString(
|
||||
Host::TranslateToStringView(
|
||||
"Achievements",
|
||||
value_headings[std::min<u8>(s_state.open_leaderboard->format, NUM_RC_CLIENT_LEADERBOARD_FORMATS - 1)]),
|
||||
nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &score_bb);
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &score_bb);
|
||||
text_start_x += time_column_width + column_spacing;
|
||||
|
||||
const ImRect date_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, date_bb.Min, date_bb.Max, heading_color,
|
||||
TRANSLATE("Achievements", "Date Submitted"), nullptr, nullptr, ImVec2(0.0f, 0.0f),
|
||||
0.0f, &date_bb);
|
||||
TRANSLATE_SV("Achievements", "Date Submitted"), nullptr, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&date_bb);
|
||||
|
||||
const float line_thickness = LayoutScale(1.0f);
|
||||
const float line_padding = LayoutScale(5.0f);
|
||||
@ -3468,7 +3453,7 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
const ImVec2 pos_min(0.0f, heading_height);
|
||||
const ImVec2 pos_max(display_size.x, display_size.y);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, pos_min, pos_max, text_color,
|
||||
TRANSLATE("Achievements", "Downloading leaderboard data, please wait..."), nullptr,
|
||||
TRANSLATE_SV("Achievements", "Downloading leaderboard data, please wait..."),
|
||||
nullptr, ImVec2(0.5f, 0.5f), 0.0f);
|
||||
}
|
||||
}
|
||||
@ -3486,15 +3471,15 @@ void Achievements::DrawLeaderboardsWindow()
|
||||
// Fetch next chunk if the loading indicator becomes visible (i.e. we scrolled enough).
|
||||
bool visible, hovered;
|
||||
text.format(ICON_FA_HOURGLASS_HALF " {}", TRANSLATE_SV("Achievements", "Loading..."));
|
||||
ImGuiFullscreen::MenuButtonFrame(text.c_str(), false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
||||
&visible, &hovered, &bb.Min, &bb.Max);
|
||||
ImGuiFullscreen::MenuButtonFrame(text, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, &visible,
|
||||
&hovered, &bb.Min, &bb.Max);
|
||||
if (visible)
|
||||
{
|
||||
const float midpoint = bb.Min.y + UIStyle.LargeFont->FontSize + LayoutScale(4.0f);
|
||||
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, text.c_str(),
|
||||
text.end_ptr(), nullptr, ImVec2(0, 0), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, text_color, text, nullptr,
|
||||
ImVec2(0, 0), 0.0f, &title_bb);
|
||||
|
||||
if (!s_state.leaderboard_fetch_handle)
|
||||
FetchNextLeaderboardEntries();
|
||||
@ -3554,8 +3539,8 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
|
||||
ImGui::GetStyle().Colors[ImGuiCol_Text]);
|
||||
|
||||
const ImRect rank_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, rank_bb.Min, rank_bb.Max, text_color, text.c_str(), text.end_ptr(),
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &rank_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, rank_bb.Min, rank_bb.Max, text_color, text, nullptr, ImVec2(0.0f, 0.0f),
|
||||
0.0f, &rank_bb);
|
||||
text_start_x += rank_column_width + column_spacing;
|
||||
|
||||
const float icon_size = bb.Max.y - bb.Min.y;
|
||||
@ -3584,20 +3569,20 @@ void Achievements::DrawLeaderboardEntry(const rc_client_leaderboard_entry_t& ent
|
||||
}
|
||||
|
||||
const ImRect user_bb(ImVec2(text_start_x + column_spacing + icon_size, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, user_bb.Min, user_bb.Max, text_color, entry.user, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, user_bb.Min, user_bb.Max, text_color, entry.user, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &user_bb);
|
||||
text_start_x += name_column_width + column_spacing;
|
||||
|
||||
const ImRect score_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, score_bb.Min, score_bb.Max, text_color, entry.display, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, score_bb.Min, score_bb.Max, text_color, entry.display, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &score_bb);
|
||||
text_start_x += time_column_width + column_spacing;
|
||||
|
||||
const ImRect time_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
SmallString submit_time;
|
||||
FullscreenUI::TimeToPrintableString(&submit_time, entry.submitted);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, time_bb.Min, time_bb.Max, text_color, submit_time.c_str(),
|
||||
submit_time.end_ptr(), nullptr, ImVec2(0.0f, 0.0f), 0.0f, &time_bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, time_bb.Min, time_bb.Max, text_color, submit_time, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &time_bb);
|
||||
|
||||
if (pressed)
|
||||
{
|
||||
@ -3630,13 +3615,13 @@ void Achievements::DrawLeaderboardListEntry(const rc_client_leaderboard_t* lboar
|
||||
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, title_bb.Min, title_bb.Max, ImGui::GetColorU32(ImGuiCol_Text),
|
||||
lboard->title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
lboard->title, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
if (lboard->description && lboard->description[0] != '\0')
|
||||
{
|
||||
RenderShadowedTextClipped(UIStyle.MediumFont, summary_bb.Min, summary_bb.Max,
|
||||
ImGui::GetColorU32(ImGuiFullscreen::DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])),
|
||||
lboard->description, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
lboard->description, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
if (pressed)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,9 +52,9 @@ static void DrawLoadingScreen(std::string_view image, std::string_view message,
|
||||
s32 progress_value, bool is_persistent);
|
||||
static void DrawNotifications(ImVec2& position, float spacing);
|
||||
static void DrawToast();
|
||||
static bool MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered, ImRect* bb,
|
||||
ImGuiButtonFlags flags = 0, float hover_alpha = 1.0f);
|
||||
static ImGuiID GetBackgroundProgressID(const char* str_id);
|
||||
static bool MenuButtonFrame(std::string_view str_id, bool enabled, float height, bool* visible, bool* hovered,
|
||||
ImRect* bb, ImGuiButtonFlags flags = 0, float hover_alpha = 1.0f);
|
||||
static ImGuiID GetBackgroundProgressID(std::string_view str_id);
|
||||
|
||||
namespace {
|
||||
|
||||
@ -1169,25 +1169,22 @@ void ImGuiFullscreen::DrawFullscreenFooter()
|
||||
if (!s_state.last_fullscreen_footer_text.empty())
|
||||
{
|
||||
const ImVec2 text_size =
|
||||
font->CalcTextSizeA(font->FontSize, max_width, 0.0f, s_state.last_fullscreen_footer_text.c_str(),
|
||||
s_state.last_fullscreen_footer_text.end_ptr());
|
||||
font->CalcTextSizeA(font->FontSize, max_width, 0.0f, IMSTR_START_END(s_state.last_fullscreen_footer_text));
|
||||
const ImVec2 text_pos =
|
||||
ImVec2(io.DisplaySize.x - padding * 2.0f - text_size.x, io.DisplaySize.y - font->FontSize - padding);
|
||||
dl->AddText(font, font->FontSize, text_pos + shadow_offset, MulAlpha(UIStyle.ShadowColor, prev_opacity),
|
||||
s_state.last_fullscreen_footer_text.c_str(), s_state.last_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.last_fullscreen_footer_text));
|
||||
dl->AddText(font, font->FontSize, text_pos, ModAlpha(text_color, prev_opacity),
|
||||
s_state.last_fullscreen_footer_text.c_str(), s_state.last_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.last_fullscreen_footer_text));
|
||||
}
|
||||
|
||||
if (!s_state.last_left_fullscreen_footer_text.empty())
|
||||
{
|
||||
const ImVec2 text_pos = ImVec2(padding, io.DisplaySize.y - font->FontSize - padding);
|
||||
dl->AddText(font, font->FontSize, text_pos + shadow_offset, MulAlpha(UIStyle.ShadowColor, prev_opacity),
|
||||
s_state.last_left_fullscreen_footer_text.c_str(),
|
||||
s_state.last_left_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.last_left_fullscreen_footer_text));
|
||||
dl->AddText(font, font->FontSize, text_pos, ModAlpha(text_color, prev_opacity),
|
||||
s_state.last_left_fullscreen_footer_text.c_str(),
|
||||
s_state.last_left_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.last_left_fullscreen_footer_text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1201,15 +1198,14 @@ void ImGuiFullscreen::DrawFullscreenFooter()
|
||||
if (!s_state.fullscreen_footer_text.empty())
|
||||
{
|
||||
const ImVec2 text_size =
|
||||
font->CalcTextSizeA(font->FontSize, max_width, 0.0f, s_state.fullscreen_footer_text.c_str(),
|
||||
s_state.fullscreen_footer_text.end_ptr());
|
||||
font->CalcTextSizeA(font->FontSize, max_width, 0.0f, IMSTR_START_END(s_state.fullscreen_footer_text));
|
||||
const ImVec2 text_pos =
|
||||
ImVec2(io.DisplaySize.x - padding * 2.0f - text_size.x, io.DisplaySize.y - font->FontSize - padding);
|
||||
const float opacity = 1.0f - prev_opacity;
|
||||
dl->AddText(font, font->FontSize, text_pos + shadow_offset, MulAlpha(UIStyle.ShadowColor, opacity),
|
||||
s_state.fullscreen_footer_text.c_str(), s_state.fullscreen_footer_text.end_ptr());
|
||||
dl->AddText(font, font->FontSize, text_pos, ModAlpha(text_color, opacity), s_state.fullscreen_footer_text.c_str(),
|
||||
s_state.fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.fullscreen_footer_text));
|
||||
dl->AddText(font, font->FontSize, text_pos, ModAlpha(text_color, opacity),
|
||||
IMSTR_START_END(s_state.fullscreen_footer_text));
|
||||
}
|
||||
|
||||
if (!s_state.left_fullscreen_footer_text.empty())
|
||||
@ -1217,9 +1213,9 @@ void ImGuiFullscreen::DrawFullscreenFooter()
|
||||
const ImVec2 text_pos = ImVec2(padding, io.DisplaySize.y - font->FontSize - padding);
|
||||
const float opacity = 1.0f - prev_opacity;
|
||||
dl->AddText(font, font->FontSize, text_pos + shadow_offset, MulAlpha(UIStyle.ShadowColor, opacity),
|
||||
s_state.left_fullscreen_footer_text.c_str(), s_state.left_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.left_fullscreen_footer_text));
|
||||
dl->AddText(font, font->FontSize, text_pos, ModAlpha(text_color, opacity),
|
||||
s_state.left_fullscreen_footer_text.c_str(), s_state.left_fullscreen_footer_text.end_ptr());
|
||||
IMSTR_START_END(s_state.left_fullscreen_footer_text));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1302,7 +1298,7 @@ void ImGuiFullscreen::EndMenuButtons()
|
||||
ImGui::PopStyleVar(4);
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::DrawWindowTitle(const char* title)
|
||||
void ImGuiFullscreen::DrawWindowTitle(std::string_view title)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
const ImVec2 pos(window->DC.CursorPos + LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
@ -1315,7 +1311,7 @@ void ImGuiFullscreen::DrawWindowTitle(const char* title)
|
||||
return;
|
||||
|
||||
ImGui::PushFont(UIStyle.LargeFont);
|
||||
ImGui::RenderTextClipped(rect.Min, rect.Max, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), &rect);
|
||||
ImGui::RenderTextClipped(rect.Min, rect.Max, IMSTR_START_END(title), nullptr, ImVec2(0.0f, 0.0f), &rect);
|
||||
ImGui::PopFont();
|
||||
|
||||
const ImVec2 line_start(pos.x, pos.y + UIStyle.LargeFont->FontSize + LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
@ -1332,7 +1328,7 @@ void ImGuiFullscreen::GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2
|
||||
*size = ImVec2(window->WorkRect.GetWidth(), LayoutScale(height) + ImGui::GetStyle().FramePadding.y * 2.0f);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered,
|
||||
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, bool enabled, float height, bool* visible, bool* hovered,
|
||||
ImRect* bb, ImGuiButtonFlags flags, float hover_alpha)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
@ -1347,7 +1343,7 @@ bool ImGuiFullscreen::MenuButtonFrame(const char* str_id, bool enabled, float he
|
||||
GetMenuButtonFrameBounds(height, &pos, &size);
|
||||
*bb = ImRect(pos, pos + size);
|
||||
|
||||
const ImGuiID id = window->GetID(str_id);
|
||||
const ImGuiID id = window->GetID(IMSTR_START_END(str_id));
|
||||
ImGui::ItemSize(size);
|
||||
if (enabled)
|
||||
{
|
||||
@ -1442,7 +1438,7 @@ void ImGuiFullscreen::DrawMenuButtonFrame(const ImVec2& p_min, const ImVec2& p_m
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered,
|
||||
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, bool enabled, float height, bool* visible, bool* hovered,
|
||||
ImVec2* min, ImVec2* max, ImGuiButtonFlags flags /*= 0*/,
|
||||
float hover_alpha /*= 0*/)
|
||||
{
|
||||
@ -1460,21 +1456,25 @@ void ImGuiFullscreen::ResetMenuButtonFrame()
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min,
|
||||
const ImVec2& pos_max, u32 color, const char* text,
|
||||
const char* text_end, const ImVec2* text_size_if_known,
|
||||
const ImVec2& align, float wrap_width, const ImRect* clip_rect,
|
||||
float shadow_offset)
|
||||
const ImVec2& pos_max, u32 color, std::string_view text,
|
||||
const ImVec2* text_size_if_known, const ImVec2& align, float wrap_width,
|
||||
const ImRect* clip_rect, float shadow_offset)
|
||||
{
|
||||
const char* text_display_end = ImGui::FindRenderedTextEnd(text, text_end);
|
||||
const int text_len = (int)(text_display_end - text);
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
const char* text_display_end = ImGui::FindRenderedTextEnd(IMSTR_START_END(text));
|
||||
const size_t text_len = (text_display_end - text.data());
|
||||
if (text_len == 0)
|
||||
return;
|
||||
|
||||
text = text.substr(0, text_len);
|
||||
|
||||
// Perform CPU side clipping for single clipped element to avoid using scissor state
|
||||
ImVec2 pos = pos_min;
|
||||
const ImVec2 text_size = text_size_if_known ?
|
||||
*text_size_if_known :
|
||||
font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, text, text_display_end, nullptr);
|
||||
font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(text), nullptr);
|
||||
|
||||
const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min;
|
||||
const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max;
|
||||
@ -1498,39 +1498,38 @@ void ImGuiFullscreen::RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* f
|
||||
if (need_clipping)
|
||||
{
|
||||
ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y);
|
||||
draw_list->AddText(font, font->FontSize, ImVec2(pos.x + shadow_offset, pos.y + shadow_offset), shadow_color, text,
|
||||
text_display_end, wrap_width, &fine_clip_rect);
|
||||
draw_list->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, &fine_clip_rect);
|
||||
draw_list->AddText(font, font->FontSize, ImVec2(pos.x + shadow_offset, pos.y + shadow_offset), shadow_color,
|
||||
IMSTR_START_END(text), wrap_width, &fine_clip_rect);
|
||||
draw_list->AddText(font, font->FontSize, pos, color, IMSTR_START_END(text), wrap_width, &fine_clip_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_list->AddText(font, font->FontSize, ImVec2(pos.x + shadow_offset, pos.y + shadow_offset), shadow_color, text,
|
||||
text_display_end, wrap_width, nullptr);
|
||||
draw_list->AddText(font, font->FontSize, pos, color, text, text_display_end, wrap_width, nullptr);
|
||||
draw_list->AddText(font, font->FontSize, ImVec2(pos.x + shadow_offset, pos.y + shadow_offset), shadow_color,
|
||||
IMSTR_START_END(text), wrap_width, nullptr);
|
||||
draw_list->AddText(font, font->FontSize, pos, color, IMSTR_START_END(text), wrap_width, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min,
|
||||
const ImVec2& pos_max, u32 color, const char* text,
|
||||
const char* text_end, const ImVec2* text_size_if_known /* = nullptr */,
|
||||
const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/,
|
||||
const ImRect* clip_rect /* = nullptr */)
|
||||
{
|
||||
RenderShadowedTextClipped(draw_list, font, pos_min, pos_max, color, text, text_end, text_size_if_known, align,
|
||||
wrap_width, clip_rect, LayoutScale(LAYOUT_SHADOW_OFFSET));
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color,
|
||||
const char* text, const char* text_end,
|
||||
const ImVec2& pos_max, u32 color, std::string_view text,
|
||||
const ImVec2* text_size_if_known /* = nullptr */,
|
||||
const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/,
|
||||
const ImRect* clip_rect /* = nullptr */)
|
||||
{
|
||||
RenderShadowedTextClipped(ImGui::GetWindowDrawList(), font, pos_min, pos_max, color, text, text_end,
|
||||
text_size_if_known, align, wrap_width, clip_rect);
|
||||
RenderShadowedTextClipped(draw_list, font, pos_min, pos_max, color, text, text_size_if_known, align, wrap_width,
|
||||
clip_rect, LayoutScale(LAYOUT_SHADOW_OFFSET));
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::MenuHeading(const char* title, bool draw_line /*= true*/)
|
||||
void ImGuiFullscreen::RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color,
|
||||
std::string_view text, const ImVec2* text_size_if_known /* = nullptr */,
|
||||
const ImVec2& align /* = ImVec2(0, 0)*/, float wrap_width /* = 0.0f*/,
|
||||
const ImRect* clip_rect /* = nullptr */)
|
||||
{
|
||||
RenderShadowedTextClipped(ImGui::GetWindowDrawList(), font, pos_min, pos_max, color, text, text_size_if_known, align,
|
||||
wrap_width, clip_rect);
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::MenuHeading(std::string_view title, bool draw_line /*= true*/)
|
||||
{
|
||||
const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f;
|
||||
const float line_padding = draw_line ? LayoutScale(5.0f) : 0.0f;
|
||||
@ -1542,7 +1541,7 @@ void ImGuiFullscreen::MenuHeading(const char* title, bool draw_line /*= true*/)
|
||||
return;
|
||||
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_TextDisabled), title,
|
||||
nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
|
||||
if (draw_line)
|
||||
{
|
||||
@ -1556,8 +1555,8 @@ void ImGuiFullscreen::MenuHeading(const char* title, bool draw_line /*= true*/)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuHeadingButton(const char* title, const char* value /*= nullptr*/, bool enabled /*= true*/,
|
||||
bool draw_line /*= true*/)
|
||||
bool ImGuiFullscreen::MenuHeadingButton(std::string_view title, std::string_view value /*= {}*/,
|
||||
bool enabled /*= true*/, bool draw_line /*= true*/)
|
||||
{
|
||||
const float line_thickness = draw_line ? LayoutScale(1.0f) : 0.0f;
|
||||
const float line_padding = draw_line ? LayoutScale(5.0f) : 0.0f;
|
||||
@ -1569,15 +1568,14 @@ bool ImGuiFullscreen::MenuHeadingButton(const char* title, const char* value /*=
|
||||
return false;
|
||||
|
||||
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, bb.Min, bb.Max, color, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f,
|
||||
&bb);
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, bb.Min, bb.Max, color, title, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
|
||||
if (value)
|
||||
if (!value.empty())
|
||||
{
|
||||
const ImVec2 value_size(
|
||||
UIStyle.LargeFont->CalcTextSizeA(UIStyle.LargeFont->FontSize, std::numeric_limits<float>::max(), 0.0f, value));
|
||||
const ImVec2 value_size(UIStyle.LargeFont->CalcTextSizeA(
|
||||
UIStyle.LargeFont->FontSize, std::numeric_limits<float>::max(), 0.0f, IMSTR_START_END(value)));
|
||||
const ImRect value_bb(ImVec2(bb.Max.x - value_size.x, bb.Min.y), ImVec2(bb.Max.x, bb.Max.y));
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, value_bb.Min, value_bb.Max, color, value, nullptr, &value_size,
|
||||
RenderShadowedTextClipped(UIStyle.LargeFont, value_bb.Min, value_bb.Max, color, value, &value_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &value_bb);
|
||||
}
|
||||
|
||||
@ -1595,8 +1593,8 @@ bool ImGuiFullscreen::MenuHeadingButton(const char* title, const char* value /*=
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuButton(const char* title, const char* summary, bool enabled, float height, ImFont* font,
|
||||
ImFont* summary_font, const ImVec2& text_align /*= ImVec2(0.0f, 0.0f)*/)
|
||||
bool ImGuiFullscreen::MenuButton(std::string_view title, std::string_view summary, bool enabled, float height,
|
||||
ImFont* font, ImFont* summary_font, const ImVec2& text_align /*= ImVec2(0.0f, 0.0f)*/)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -1607,29 +1605,29 @@ bool ImGuiFullscreen::MenuButton(const char* title, const char* summary, bool en
|
||||
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
|
||||
const ImRect title_bb(bb.Min, ImVec2(bb.Max.x, midpoint));
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
text_align, 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, text_align,
|
||||
0.0f, &title_bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), bb.Max);
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, text_align, 0.0f, &summary_bb);
|
||||
summary, nullptr, text_align, 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
s_state.menu_button_index++;
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuButtonWithoutSummary(const char* title, bool enabled /*= true*/,
|
||||
bool ImGuiFullscreen::MenuButtonWithoutSummary(std::string_view title, bool enabled /*= true*/,
|
||||
float height /*= LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY*/,
|
||||
ImFont* font /*= UIStyle.LargeFont*/,
|
||||
const ImVec2& text_align /*= ImVec2(0.0f, 0.0f)*/)
|
||||
{
|
||||
return MenuButton(title, nullptr, enabled, height, font, nullptr, text_align);
|
||||
return MenuButton(title, {}, enabled, height, font, nullptr, text_align);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuImageButton(const char* title, const char* summary, ImTextureID user_texture_id,
|
||||
bool ImGuiFullscreen::MenuImageButton(std::string_view title, std::string_view summary, ImTextureID user_texture_id,
|
||||
const ImVec2& image_size, bool enabled, float height, const ImVec2& uv0,
|
||||
const ImVec2& uv1, ImFont* title_font, ImFont* summary_font)
|
||||
{
|
||||
@ -1648,24 +1646,25 @@ bool ImGuiFullscreen::MenuImageButton(const char* title, const char* summary, Im
|
||||
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
s_state.menu_button_index++;
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::FloatingButton(const char* text, float x, float y, float width, float height, float anchor_x,
|
||||
bool ImGuiFullscreen::FloatingButton(std::string_view text, float x, float y, float width, float height, float anchor_x,
|
||||
float anchor_y, bool enabled, ImFont* font, ImVec2* out_position,
|
||||
bool repeat_button)
|
||||
{
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, text));
|
||||
const ImVec2 text_size(
|
||||
font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, IMSTR_START_END(text)));
|
||||
const ImVec2& padding(ImGui::GetStyle().FramePadding);
|
||||
if (width < 0.0f)
|
||||
width = (padding.x * 2.0f) + text_size.x;
|
||||
@ -1700,7 +1699,7 @@ bool ImGuiFullscreen::FloatingButton(const char* text, float x, float y, float w
|
||||
const ImVec2 base(ImGui::GetWindowPos() + ImVec2(x, y));
|
||||
ImRect bb(base, base + ImVec2(width, height));
|
||||
|
||||
const ImGuiID id = window->GetID(text);
|
||||
const ImGuiID id = window->GetID(IMSTR_START_END(text));
|
||||
if (enabled)
|
||||
{
|
||||
if (!ImGui::ItemAdd(bb, id))
|
||||
@ -1738,12 +1737,12 @@ bool ImGuiFullscreen::FloatingButton(const char* text, float x, float y, float w
|
||||
bb.Max -= padding;
|
||||
|
||||
const u32 color = enabled ? ImGui::GetColorU32(ImGuiCol_Text) : ImGui::GetColorU32(ImGuiCol_TextDisabled);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, color, text, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, color, text, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::ToggleButton(const char* title, const char* summary, bool* v, bool enabled, float height,
|
||||
ImFont* font, ImFont* summary_font)
|
||||
bool ImGuiFullscreen::ToggleButton(std::string_view title, std::string_view summary, bool* v, bool enabled,
|
||||
float height, ImFont* font, ImFont* summary_font)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -1757,13 +1756,13 @@ bool ImGuiFullscreen::ToggleButton(const char* title, const char* summary, bool*
|
||||
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
const float toggle_width = LayoutScale(50.0f);
|
||||
@ -1779,7 +1778,8 @@ bool ImGuiFullscreen::ToggleButton(const char* title, const char* summary, bool*
|
||||
float t = *v ? 1.0f : 0.0f;
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (UIStyle.Animations && g.LastActiveId == g.CurrentWindow->GetID(title)) // && g.LastActiveIdTimer < ANIM_SPEED)
|
||||
if (UIStyle.Animations &&
|
||||
g.LastActiveId == g.CurrentWindow->GetID(IMSTR_START_END(title))) // && g.LastActiveIdTimer < ANIM_SPEED)
|
||||
{
|
||||
static constexpr const float ANIM_SPEED = 0.08f;
|
||||
float t_anim = ImSaturate(g.LastActiveIdTimer / ANIM_SPEED);
|
||||
@ -1809,8 +1809,8 @@ bool ImGuiFullscreen::ToggleButton(const char* title, const char* summary, bool*
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::ThreeWayToggleButton(const char* title, const char* summary, std::optional<bool>* v, bool enabled,
|
||||
float height, ImFont* font, ImFont* summary_font)
|
||||
bool ImGuiFullscreen::ThreeWayToggleButton(std::string_view title, std::string_view summary, std::optional<bool>* v,
|
||||
bool enabled, float height, ImFont* font, ImFont* summary_font)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -1824,13 +1824,13 @@ bool ImGuiFullscreen::ThreeWayToggleButton(const char* title, const char* summar
|
||||
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0, 0.0f), 0.0f, &title_bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
const float toggle_width = LayoutScale(50.0f);
|
||||
@ -1854,7 +1854,7 @@ bool ImGuiFullscreen::ThreeWayToggleButton(const char* title, const char* summar
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
ImGuiContext& g = *GImGui;
|
||||
float ANIM_SPEED = 0.08f;
|
||||
if (g.LastActiveId == g.CurrentWindow->GetID(title)) // && g.LastActiveIdTimer < ANIM_SPEED)
|
||||
if (g.LastActiveId == g.CurrentWindow->GetID(IMSTR_START_END(title))) // && g.LastActiveIdTimer < ANIM_SPEED)
|
||||
{
|
||||
float t_anim = ImSaturate(g.LastActiveIdTimer / ANIM_SPEED);
|
||||
t = (v->has_value() ? (v->value() ? std::min(t_anim + 0.5f, 1.0f) : (1.0f - t_anim)) : (t_anim * 0.5f));
|
||||
@ -1882,10 +1882,10 @@ bool ImGuiFullscreen::ThreeWayToggleButton(const char* title, const char* summar
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* value, s32 min, s32 max, s32 increment,
|
||||
const char* format, bool enabled /*= true*/,
|
||||
bool ImGuiFullscreen::RangeButton(std::string_view title, std::string_view summary, s32* value, s32 min, s32 max,
|
||||
s32 increment, const char* format, bool enabled /*= true*/,
|
||||
float height /*= LAYOUT_MENU_BUTTON_HEIGHT*/, ImFont* font /*= g_large_font*/,
|
||||
ImFont* summary_font /*= g_medium_font*/, const char* ok_text /*= "OK"*/)
|
||||
ImFont* summary_font /*= g_medium_font*/, std::string_view ok_text /*= "OK"*/)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -1893,24 +1893,23 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
|
||||
if (!visible)
|
||||
return false;
|
||||
|
||||
const SmallString value_text = SmallString::from_sprintf(format, *value);
|
||||
const ImVec2 value_size =
|
||||
font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, value_text.c_str(), value_text.end_ptr());
|
||||
SmallString value_text = SmallString::from_sprintf(format, *value);
|
||||
const ImVec2 value_size = font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(value_text));
|
||||
|
||||
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
|
||||
const float text_end = bb.Max.x - value_size.x;
|
||||
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
|
||||
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text.c_str(), value_text.end_ptr(),
|
||||
&value_size, ImVec2(1.0f, 0.5f), 0.0f, &bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text, &value_size,
|
||||
ImVec2(1.0f, 0.5f), 0.0f, &bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
if (pressed)
|
||||
@ -1944,10 +1943,10 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* v
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float* value, float min, float max,
|
||||
bool ImGuiFullscreen::RangeButton(std::string_view title, std::string_view summary, float* value, float min, float max,
|
||||
float increment, const char* format, bool enabled /*= true*/,
|
||||
float height /*= LAYOUT_MENU_BUTTON_HEIGHT*/, ImFont* font /*= g_large_font*/,
|
||||
ImFont* summary_font /*= g_medium_font*/, const char* ok_text /*= "OK"*/)
|
||||
ImFont* summary_font /*= g_medium_font*/, std::string_view ok_text /*= "OK"*/)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -1955,24 +1954,23 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
|
||||
if (!visible)
|
||||
return false;
|
||||
|
||||
const SmallString value_text = SmallString::from_sprintf(format, *value);
|
||||
const ImVec2 value_size =
|
||||
font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, value_text.c_str(), value_text.end_ptr());
|
||||
SmallString value_text = SmallString::from_sprintf(format, *value);
|
||||
const ImVec2 value_size = font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, IMSTR_START_END(value_text));
|
||||
|
||||
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
|
||||
const float text_end = bb.Max.x - value_size.x;
|
||||
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
|
||||
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text.c_str(), value_text.end_ptr(),
|
||||
&value_size, ImVec2(1.0f, 0.5f), 0.0f, &bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value_text, &value_size,
|
||||
ImVec2(1.0f, 0.5f), 0.0f, &bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
if (pressed)
|
||||
@ -2005,8 +2003,8 @@ bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float*
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::MenuButtonWithValue(const char* title, const char* summary, const char* value, bool enabled,
|
||||
float height, ImFont* font, ImFont* summary_font)
|
||||
bool ImGuiFullscreen::MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value,
|
||||
bool enabled, float height, ImFont* font, ImFont* summary_font)
|
||||
{
|
||||
ImRect bb;
|
||||
bool visible, hovered;
|
||||
@ -2014,28 +2012,28 @@ bool ImGuiFullscreen::MenuButtonWithValue(const char* title, const char* summary
|
||||
if (!visible)
|
||||
return false;
|
||||
|
||||
const ImVec2 value_size(ImGui::CalcTextSize(value));
|
||||
const ImVec2 value_size = ImGui::CalcTextSize(IMSTR_START_END(value));
|
||||
|
||||
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
|
||||
const float text_end = bb.Max.x - value_size.x;
|
||||
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
|
||||
const ImVec4& color = ImGui::GetStyle().Colors[enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled];
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr, nullptr,
|
||||
RenderShadowedTextClipped(font, title_bb.Min, title_bb.Max, ImGui::GetColorU32(color), title, nullptr,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &title_bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value, nullptr, nullptr,
|
||||
ImVec2(1.0f, 0.5f), 0.0f, &bb);
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(color), value, nullptr, ImVec2(1.0f, 0.5f), 0.0f,
|
||||
&bb);
|
||||
|
||||
if (summary)
|
||||
if (!summary.empty())
|
||||
{
|
||||
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
|
||||
RenderShadowedTextClipped(summary_font, summary_bb.Min, summary_bb.Max, ImGui::GetColorU32(DarkerColor(color)),
|
||||
summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
summary, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &summary_bb);
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::EnumChoiceButtonImpl(const char* title, const char* summary, s32* value_pointer,
|
||||
bool ImGuiFullscreen::EnumChoiceButtonImpl(std::string_view title, std::string_view summary, s32* value_pointer,
|
||||
const char* (*to_display_name_function)(s32 value, void* opaque),
|
||||
void* opaque, u32 count, bool enabled, float height, ImFont* font,
|
||||
ImFont* summary_font)
|
||||
@ -2045,7 +2043,7 @@ bool ImGuiFullscreen::EnumChoiceButtonImpl(const char* title, const char* summar
|
||||
|
||||
if (pressed)
|
||||
{
|
||||
s_state.enum_choice_button_id = ImGui::GetID(title);
|
||||
s_state.enum_choice_button_id = ImGui::GetID(IMSTR_START_END(title));
|
||||
s_state.enum_choice_button_value = *value_pointer;
|
||||
s_state.enum_choice_button_set = false;
|
||||
|
||||
@ -2064,7 +2062,7 @@ bool ImGuiFullscreen::EnumChoiceButtonImpl(const char* title, const char* summar
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
if (s_state.enum_choice_button_set && s_state.enum_choice_button_id == ImGui::GetID(title))
|
||||
if (s_state.enum_choice_button_set && s_state.enum_choice_button_id == ImGui::GetID(IMSTR_START_END(title)))
|
||||
{
|
||||
changed = s_state.enum_choice_button_value != *value_pointer;
|
||||
if (changed)
|
||||
@ -2096,7 +2094,7 @@ void ImGuiFullscreen::EndNavBar()
|
||||
ImGui::PopStyleVar(4);
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::NavTitle(const char* title, float height /*= LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY*/,
|
||||
void ImGuiFullscreen::NavTitle(std::string_view title, float height /*= LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY*/,
|
||||
ImFont* font /*= g_large_font*/)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
@ -2105,7 +2103,8 @@ void ImGuiFullscreen::NavTitle(const char* title, float height /*= LAYOUT_MENU_B
|
||||
|
||||
s_state.menu_button_index++;
|
||||
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, title));
|
||||
const ImVec2 text_size(
|
||||
font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, IMSTR_START_END(title)));
|
||||
const ImVec2 pos(window->DC.CursorPos);
|
||||
const ImGuiStyle& style = ImGui::GetStyle();
|
||||
const ImVec2 size = ImVec2(text_size.x, LayoutScale(height) + style.FramePadding.y * 2.0f);
|
||||
@ -2121,7 +2120,7 @@ void ImGuiFullscreen::NavTitle(const char* title, float height /*= LAYOUT_MENU_B
|
||||
bb.Min.y += style.FramePadding.y;
|
||||
bb.Max.y -= style.FramePadding.y;
|
||||
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Text), title, nullptr, &text_size,
|
||||
RenderShadowedTextClipped(font, bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Text), title, &text_size,
|
||||
ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
}
|
||||
|
||||
@ -2138,8 +2137,8 @@ void ImGuiFullscreen::RightAlignNavButtons(u32 num_items /*= 0*/,
|
||||
ImGui::SetCursorPosX(window->InnerClipRect.Max.x - margin - style.FramePadding.x);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::NavButton(const char* title, bool is_active, bool enabled /* = true */, float width /* = -1.0f */,
|
||||
float height /* = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY */,
|
||||
bool ImGuiFullscreen::NavButton(std::string_view title, bool is_active, bool enabled /* = true */,
|
||||
float width /* = -1.0f */, float height /* = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY */,
|
||||
ImFont* font /* = g_large_font */)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
@ -2148,7 +2147,8 @@ bool ImGuiFullscreen::NavButton(const char* title, bool is_active, bool enabled
|
||||
|
||||
s_state.menu_button_index++;
|
||||
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, title));
|
||||
const ImVec2 text_size(
|
||||
font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, IMSTR_START_END(title)));
|
||||
const ImVec2 pos(window->DC.CursorPos);
|
||||
const ImGuiStyle& style = ImGui::GetStyle();
|
||||
const ImVec2 size = ImVec2(((width < 0.0f) ? text_size.x : LayoutScale(width)) + style.FramePadding.x * 2.0f,
|
||||
@ -2159,7 +2159,7 @@ bool ImGuiFullscreen::NavButton(const char* title, bool is_active, bool enabled
|
||||
ImGui::SameLine();
|
||||
|
||||
ImRect bb(pos, pos + size);
|
||||
const ImGuiID id = window->GetID(title);
|
||||
const ImGuiID id = window->GetID(IMSTR_START_END(title));
|
||||
if (enabled)
|
||||
{
|
||||
// bit contradictory - we don't want this button to be used for *gamepad* navigation, since they're usually
|
||||
@ -2198,13 +2198,13 @@ bool ImGuiFullscreen::NavButton(const char* title, bool is_active, bool enabled
|
||||
RenderShadowedTextClipped(
|
||||
font, bb.Min, bb.Max,
|
||||
ImGui::GetColorU32(enabled ? (is_active ? ImGuiCol_Text : ImGuiCol_TextDisabled) : ImGuiCol_ButtonHovered), title,
|
||||
nullptr, &text_size, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
&text_size, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /* = true */, float width, float height,
|
||||
const ImVec4& background, ImFont* font /* = g_large_font */)
|
||||
bool ImGuiFullscreen::NavTab(std::string_view title, bool is_active, bool enabled /* = true */, float width,
|
||||
float height, const ImVec4& background, ImFont* font /* = g_large_font */)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
@ -2212,7 +2212,8 @@ bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /*
|
||||
|
||||
s_state.menu_button_index++;
|
||||
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, title));
|
||||
const ImVec2 text_size(
|
||||
font->CalcTextSizeA(font->FontSize, std::numeric_limits<float>::max(), 0.0f, IMSTR_START_END(title)));
|
||||
const ImVec2 pos(window->DC.CursorPos);
|
||||
const ImVec2 size = ImVec2(((width < 0.0f) ? text_size.x : LayoutScale(width)), LayoutScale(height));
|
||||
|
||||
@ -2222,7 +2223,7 @@ bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /*
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImRect bb(pos, pos + size);
|
||||
const ImGuiID id = window->GetID(title);
|
||||
const ImGuiID id = window->GetID(IMSTR_START_END(title));
|
||||
if (enabled)
|
||||
{
|
||||
// bit contradictory - we don't want this button to be used for *gamepad* navigation, since they're usually
|
||||
@ -2272,7 +2273,7 @@ bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /*
|
||||
RenderShadowedTextClipped(
|
||||
font, bb.Min, bb.Max,
|
||||
ImGui::GetColorU32(enabled ? (is_active ? ImGuiCol_Text : ImGuiCol_TextDisabled) : ImGuiCol_ButtonHovered), title,
|
||||
nullptr, nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
nullptr, ImVec2(0.0f, 0.0f), 0.0f, &bb);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -2308,7 +2309,8 @@ void ImGuiFullscreen::EndHorizontalMenu()
|
||||
EndFullscreenWindow(true, true);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, const char* title, const char* description, u32 color)
|
||||
bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, std::string_view title, std::string_view description,
|
||||
u32 color)
|
||||
{
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
@ -2318,7 +2320,7 @@ bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, const char* title, co
|
||||
const ImVec2 size = LayoutScale(LAYOUT_HORIZONTAL_MENU_ITEM_WIDTH, LAYOUT_HORIZONTAL_MENU_HEIGHT);
|
||||
ImRect bb = ImRect(pos, pos + size);
|
||||
|
||||
const ImGuiID id = window->GetID(title);
|
||||
const ImGuiID id = window->GetID(IMSTR_START_END(title));
|
||||
ImGui::ItemSize(size);
|
||||
if (!ImGui::ItemAdd(bb, id))
|
||||
return false;
|
||||
@ -2352,25 +2354,28 @@ bool ImGuiFullscreen::HorizontalMenuItem(GPUTexture* icon, const char* title, co
|
||||
color);
|
||||
|
||||
ImFont* title_font = UIStyle.LargeFont;
|
||||
const ImVec2 title_size =
|
||||
title_font->CalcTextSizeA(title_font->FontSize, std::numeric_limits<float>::max(), avail_width, title);
|
||||
const ImVec2 title_size = title_font->CalcTextSizeA(title_font->FontSize, std::numeric_limits<float>::max(),
|
||||
avail_width, IMSTR_START_END(title));
|
||||
const ImVec2 title_pos =
|
||||
ImVec2(bb.Min.x + (avail_width - title_size.x) * 0.5f, icon_pos.y + icon_size + LayoutScale(10.0f));
|
||||
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
|
||||
|
||||
RenderShadowedTextClipped(title_font, title_bb.Min, title_bb.Max,
|
||||
ImGui::GetColorU32(ImGui::GetStyle().Colors[ImGuiCol_Text]), title, nullptr, &title_size,
|
||||
ImGui::GetColorU32(ImGui::GetStyle().Colors[ImGuiCol_Text]), title, &title_size,
|
||||
ImVec2(0.0f, 0.0f), avail_width, &title_bb);
|
||||
|
||||
ImFont* desc_font = UIStyle.MediumFont;
|
||||
const ImVec2 desc_size =
|
||||
desc_font->CalcTextSizeA(desc_font->FontSize, std::numeric_limits<float>::max(), avail_width, description);
|
||||
const ImVec2 desc_pos = ImVec2(bb.Min.x + (avail_width - desc_size.x) * 0.5f, title_bb.Max.y + LayoutScale(10.0f));
|
||||
const ImRect desc_bb = ImRect(desc_pos, desc_pos + desc_size);
|
||||
if (!description.empty())
|
||||
{
|
||||
ImFont* desc_font = UIStyle.MediumFont;
|
||||
const ImVec2 desc_size = desc_font->CalcTextSizeA(desc_font->FontSize, std::numeric_limits<float>::max(),
|
||||
avail_width, IMSTR_START_END(description));
|
||||
const ImVec2 desc_pos = ImVec2(bb.Min.x + (avail_width - desc_size.x) * 0.5f, title_bb.Max.y + LayoutScale(10.0f));
|
||||
const ImRect desc_bb = ImRect(desc_pos, desc_pos + desc_size);
|
||||
|
||||
RenderShadowedTextClipped(desc_font, desc_bb.Min, desc_bb.Max,
|
||||
ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), description,
|
||||
nullptr, nullptr, ImVec2(0.0f, 0.0f), avail_width, &desc_bb);
|
||||
RenderShadowedTextClipped(desc_font, desc_bb.Min, desc_bb.Max,
|
||||
ImGui::GetColorU32(DarkerColor(ImGui::GetStyle().Colors[ImGuiCol_Text])), description,
|
||||
nullptr, ImVec2(0.0f, 0.0f), avail_width, &desc_bb);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
@ -2443,11 +2448,8 @@ bool ImGuiFullscreen::PopupDialog::BeginRender(float scaled_window_padding /* =
|
||||
if (m_state == State::Reopening) [[unlikely]]
|
||||
{
|
||||
// close it under the old name
|
||||
if (ImGui::IsPopupOpen(ImGui::GetCurrentWindowRead()->GetID(m_title.c_str(), m_title.c_str() + m_title.length()),
|
||||
ImGuiPopupFlags_None))
|
||||
{
|
||||
if (ImGui::IsPopupOpen(ImGui::GetCurrentWindowRead()->GetID(IMSTR_START_END(m_title)), ImGuiPopupFlags_None))
|
||||
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size, true);
|
||||
}
|
||||
|
||||
// and open under the new name
|
||||
m_state = State::OpeningTrigger;
|
||||
@ -2522,8 +2524,8 @@ bool ImGuiFullscreen::PopupDialog::BeginRender(float scaled_window_padding /* =
|
||||
ImGui::SetNextWindowSize(scaled_window_size);
|
||||
|
||||
// Based on BeginPopupModal(), because we need to control is_open smooth closing.
|
||||
const bool popup_open = ImGui::IsPopupOpen(
|
||||
ImGui::GetCurrentWindowRead()->GetID(m_title.c_str(), m_title.c_str() + m_title.length()), ImGuiPopupFlags_None);
|
||||
const bool popup_open =
|
||||
ImGui::IsPopupOpen(ImGui::GetCurrentWindowRead()->GetID(IMSTR_START_END(m_title)), ImGuiPopupFlags_None);
|
||||
const ImGuiWindowFlags window_flags = ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
|
||||
(m_title.starts_with("##") ? ImGuiWindowFlags_NoTitleBar : 0);
|
||||
@ -2697,19 +2699,22 @@ void ImGuiFullscreen::FileSelectorDialog::Draw()
|
||||
|
||||
if (!m_current_directory.empty())
|
||||
{
|
||||
MenuButton(SmallString::from_format(ICON_FA_FOLDER_OPEN " {}", m_current_directory).c_str(), nullptr, false,
|
||||
MenuButton(SmallString::from_format(ICON_FA_FOLDER_OPEN " {}", m_current_directory), std::string_view(), false,
|
||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
}
|
||||
|
||||
if (m_is_directory && !m_current_directory.empty())
|
||||
{
|
||||
if (MenuButton(ICON_FA_FOLDER_PLUS " <Use This Directory>", nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
if (MenuButton(ICON_FA_FOLDER_PLUS " <Use This Directory>", std::string_view(), true,
|
||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
{
|
||||
directory_selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (Item& item : m_items)
|
||||
{
|
||||
if (MenuButton(item.display_name.c_str(), nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
if (MenuButton(item.display_name, std::string_view(), true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
selected = &item;
|
||||
}
|
||||
|
||||
@ -2822,7 +2827,7 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
||||
|
||||
const SmallString title =
|
||||
SmallString::from_format("{0} {1}", option.second ? ICON_FA_CHECK_SQUARE : ICON_FA_SQUARE, option.first);
|
||||
if (MenuButton(title.c_str(), nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
if (MenuButton(title, std::string_view(), true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
|
||||
{
|
||||
choice = i;
|
||||
option.second = !option.second;
|
||||
@ -2859,9 +2864,9 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
||||
{
|
||||
auto& option = m_options[i];
|
||||
|
||||
if (option.second ? MenuButtonWithValue(option.first.c_str(), nullptr, ICON_FA_CHECK, true,
|
||||
LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) :
|
||||
MenuButtonWithoutSummary(option.first.c_str()))
|
||||
if (option.second ?
|
||||
MenuButtonWithValue(option.first, {}, ICON_FA_CHECK, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) :
|
||||
MenuButtonWithoutSummary(option.first))
|
||||
{
|
||||
choice = i;
|
||||
for (s32 j = 0; j < static_cast<s32>(m_options.size()); j++)
|
||||
@ -2977,7 +2982,7 @@ void ImGuiFullscreen::InputStringDialog::Draw()
|
||||
if (!m_caption.empty())
|
||||
{
|
||||
const float prev = ImGui::GetCursorPosX();
|
||||
ImGui::TextUnformatted(m_caption.c_str());
|
||||
ImGui::TextUnformatted(IMSTR_START_END(m_caption));
|
||||
ImGui::SetNextItemWidth(ImGui::GetCursorPosX() - prev);
|
||||
}
|
||||
else
|
||||
@ -2990,7 +2995,7 @@ void ImGuiFullscreen::InputStringDialog::Draw()
|
||||
|
||||
const bool ok_enabled = !m_text.empty();
|
||||
|
||||
if (MenuButtonWithoutSummary(m_ok_text.c_str(), ok_enabled) && ok_enabled)
|
||||
if (MenuButtonWithoutSummary(m_ok_text, ok_enabled) && ok_enabled)
|
||||
{
|
||||
// have to move out in case they open another dialog in the callback
|
||||
const InputStringDialogCallback cb = std::exchange(m_callback, InputStringDialogCallback());
|
||||
@ -3061,7 +3066,7 @@ void ImGuiFullscreen::MessageDialog::Draw()
|
||||
|
||||
for (s32 button_index = 0; button_index < static_cast<s32>(m_buttons.size()); button_index++)
|
||||
{
|
||||
if (!m_buttons[button_index].empty() && MenuButtonWithoutSummary(m_buttons[button_index].c_str()))
|
||||
if (!m_buttons[button_index].empty() && MenuButtonWithoutSummary(m_buttons[button_index]))
|
||||
result = button_index;
|
||||
}
|
||||
|
||||
@ -3147,12 +3152,13 @@ void ImGuiFullscreen::SetNotificationVerticalPosition(float position, float dire
|
||||
s_notification_vertical_direction = direction;
|
||||
}
|
||||
|
||||
ImGuiID ImGuiFullscreen::GetBackgroundProgressID(const char* str_id)
|
||||
ImGuiID ImGuiFullscreen::GetBackgroundProgressID(std::string_view str_id)
|
||||
{
|
||||
return ImHashStr(str_id);
|
||||
return ImHashStr(str_id.data(), str_id.length());
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::OpenBackgroundProgressDialog(const char* str_id, std::string message, s32 min, s32 max, s32 value)
|
||||
void ImGuiFullscreen::OpenBackgroundProgressDialog(std::string_view str_id, std::string message, s32 min, s32 max,
|
||||
s32 value)
|
||||
{
|
||||
const ImGuiID id = GetBackgroundProgressID(str_id);
|
||||
|
||||
@ -3174,7 +3180,7 @@ void ImGuiFullscreen::OpenBackgroundProgressDialog(const char* str_id, std::stri
|
||||
s_state.background_progress_dialogs.push_back(std::move(data));
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::UpdateBackgroundProgressDialog(const char* str_id, std::string message, s32 min, s32 max,
|
||||
void ImGuiFullscreen::UpdateBackgroundProgressDialog(std::string_view str_id, std::string message, s32 min, s32 max,
|
||||
s32 value)
|
||||
{
|
||||
const ImGuiID id = GetBackgroundProgressID(str_id);
|
||||
@ -3196,7 +3202,7 @@ void ImGuiFullscreen::UpdateBackgroundProgressDialog(const char* str_id, std::st
|
||||
Panic("Updating unknown progress entry.");
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::CloseBackgroundProgressDialog(const char* str_id)
|
||||
void ImGuiFullscreen::CloseBackgroundProgressDialog(std::string_view str_id)
|
||||
{
|
||||
const ImGuiID id = GetBackgroundProgressID(str_id);
|
||||
|
||||
@ -3214,7 +3220,7 @@ void ImGuiFullscreen::CloseBackgroundProgressDialog(const char* str_id)
|
||||
Panic("Closing unknown progress entry.");
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::IsBackgroundProgressDialogOpen(const char* str_id)
|
||||
bool ImGuiFullscreen::IsBackgroundProgressDialogOpen(std::string_view str_id)
|
||||
{
|
||||
const ImGuiID id = GetBackgroundProgressID(str_id);
|
||||
|
||||
@ -3251,7 +3257,7 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
|
||||
|
||||
ImVec2 pos(window_pos_x + LayoutScale(10.0f), window_pos_y + LayoutScale(10.0f));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, pos, IM_COL32(255, 255, 255, 255),
|
||||
data.message.c_str(), nullptr, 0.0f);
|
||||
IMSTR_START_END(data.message), 0.0f);
|
||||
pos.y += UIStyle.MediumFont->FontSize + LayoutScale(10.0f);
|
||||
|
||||
const ImVec2 box_end(pos.x + window_width - LayoutScale(10.0f * 2.0f), pos.y + LayoutScale(25.0f));
|
||||
@ -3263,12 +3269,12 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
|
||||
dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (box_end.x - pos.x), box_end.y),
|
||||
ImGui::GetColorU32(UIStyle.SecondaryColor));
|
||||
|
||||
const auto text = TinyString::from_format("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
TinyString text = TinyString::from_format("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
const ImVec2 text_size(ImGui::CalcTextSize(text));
|
||||
const ImVec2 text_pos(pos.x + ((box_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
pos.y + ((box_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f));
|
||||
dl->AddText(UIStyle.MediumFont, UIStyle.MediumFont->FontSize, text_pos,
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), text.c_str(), text.end_ptr());
|
||||
ImGui::GetColorU32(UIStyle.PrimaryTextColor), IMSTR_START_END(text));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3398,17 +3404,17 @@ void ImGuiFullscreen::DrawLoadingScreen(std::string_view image, std::string_view
|
||||
if (has_progress || is_persistent)
|
||||
{
|
||||
if (!message.empty())
|
||||
ImGui::TextUnformatted(message.data(), message.data() + message.size());
|
||||
ImGui::TextUnformatted(IMSTR_START_END(message));
|
||||
|
||||
if (has_progress)
|
||||
{
|
||||
TinyString buf;
|
||||
buf.format("{}/{}", progress_value, progress_max);
|
||||
|
||||
const ImVec2 prog_size = ImGui::CalcTextSize(buf.c_str(), buf.end_ptr());
|
||||
const ImVec2 prog_size = ImGui::CalcTextSize(IMSTR_START_END(buf));
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(width - padding_and_rounding - prog_size.x);
|
||||
ImGui::TextUnformatted(buf.c_str(), buf.end_ptr());
|
||||
ImGui::TextUnformatted(IMSTR_START_END(buf));
|
||||
}
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5.0f * scale);
|
||||
@ -3422,9 +3428,9 @@ void ImGuiFullscreen::DrawLoadingScreen(std::string_view image, std::string_view
|
||||
{
|
||||
if (!message.empty())
|
||||
{
|
||||
const ImVec2 text_size(ImGui::CalcTextSize(message.data(), message.data() + message.size()));
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(IMSTR_START_END(message));
|
||||
ImGui::SetCursorPosX((width - text_size.x) / 2.0f);
|
||||
ImGui::TextUnformatted(message.data(), message.data() + message.size());
|
||||
ImGui::TextUnformatted(IMSTR_START_END(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3523,11 +3529,10 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||
continue;
|
||||
}
|
||||
|
||||
const ImVec2 title_size(title_font->CalcTextSizeA(title_font->FontSize, max_text_width, max_text_width,
|
||||
notif.title.c_str(), notif.title.c_str() + notif.title.size()));
|
||||
|
||||
const ImVec2 text_size(text_font->CalcTextSizeA(text_font->FontSize, max_text_width, max_text_width,
|
||||
notif.text.c_str(), notif.text.c_str() + notif.text.size()));
|
||||
const ImVec2 title_size =
|
||||
title_font->CalcTextSizeA(title_font->FontSize, max_text_width, max_text_width, IMSTR_START_END(notif.title));
|
||||
const ImVec2 text_size =
|
||||
text_font->CalcTextSizeA(text_font->FontSize, max_text_width, max_text_width, IMSTR_START_END(notif.text));
|
||||
|
||||
float box_width = std::max((horizontal_padding * 2.0f) + badge_size + horizontal_spacing +
|
||||
ImCeil(std::max(title_size.x, text_size.x)),
|
||||
@ -3593,8 +3598,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||
const ImVec2 badge_max(badge_min.x + badge_size, badge_min.y + badge_size);
|
||||
if (!notif.badge_path.empty())
|
||||
{
|
||||
GPUTexture* tex =
|
||||
GetCachedTexture(notif.badge_path.c_str(), static_cast<u32>(badge_size), static_cast<u32>(badge_size));
|
||||
GPUTexture* tex = GetCachedTexture(notif.badge_path, static_cast<u32>(badge_size), static_cast<u32>(badge_size));
|
||||
if (tex)
|
||||
{
|
||||
dl->AddImage(tex, badge_min, badge_max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f),
|
||||
@ -3607,15 +3611,13 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
|
||||
|
||||
const ImVec2 title_pos = ImVec2(badge_max.x + horizontal_spacing, box_min.y + vertical_padding);
|
||||
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
|
||||
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, title_col, notif.title.c_str(),
|
||||
notif.title.c_str() + notif.title.size(), &title_size, ImVec2(0.0f, 0.0f), max_text_width,
|
||||
&title_bb);
|
||||
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, title_col, notif.title, &title_size,
|
||||
ImVec2(0.0f, 0.0f), max_text_width, &title_bb);
|
||||
|
||||
const ImVec2 text_pos = ImVec2(badge_max.x + horizontal_spacing, title_bb.Max.y + vertical_spacing);
|
||||
const ImRect text_bb = ImRect(text_pos, text_pos + text_size);
|
||||
RenderShadowedTextClipped(dl, text_font, text_bb.Min, text_bb.Max, text_col, notif.text.c_str(),
|
||||
notif.text.c_str() + notif.text.size(), &text_size, ImVec2(0.0f, 0.0f), max_text_width,
|
||||
&text_bb);
|
||||
RenderShadowedTextClipped(dl, text_font, text_bb.Min, text_bb.Max, text_col, notif.text, &text_size,
|
||||
ImVec2(0.0f, 0.0f), max_text_width, &text_bb);
|
||||
|
||||
if (clip_box)
|
||||
dl->PopClipRect();
|
||||
@ -3676,17 +3678,15 @@ void ImGuiFullscreen::DrawToast()
|
||||
const float total_padding = padding * 2.0f;
|
||||
const float margin = LayoutScale(20.0f + (s_state.fullscreen_footer_text.empty() ? 0.0f : LAYOUT_FOOTER_HEIGHT));
|
||||
const float spacing = s_state.toast_title.empty() ? 0.0f : LayoutScale(10.0f);
|
||||
const ImVec2 display_size(ImGui::GetIO().DisplaySize);
|
||||
const ImVec2 title_size(s_state.toast_title.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
title_font->CalcTextSizeA(title_font->FontSize, FLT_MAX, max_width,
|
||||
s_state.toast_title.c_str(),
|
||||
s_state.toast_title.c_str() + s_state.toast_title.length()));
|
||||
const ImVec2 message_size(
|
||||
const ImVec2 display_size = ImGui::GetIO().DisplaySize;
|
||||
const ImVec2 title_size =
|
||||
s_state.toast_title.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
title_font->CalcTextSizeA(title_font->FontSize, FLT_MAX, max_width, IMSTR_START_END(s_state.toast_title));
|
||||
const ImVec2 message_size =
|
||||
s_state.toast_message.empty() ?
|
||||
ImVec2(0.0f, 0.0f) :
|
||||
message_font->CalcTextSizeA(message_font->FontSize, FLT_MAX, max_width, s_state.toast_message.c_str(),
|
||||
s_state.toast_message.c_str() + s_state.toast_message.length()));
|
||||
message_font->CalcTextSizeA(message_font->FontSize, FLT_MAX, max_width, IMSTR_START_END(s_state.toast_message));
|
||||
const ImVec2 comb_size(std::max(title_size.x, message_size.x), title_size.y + spacing + message_size.y);
|
||||
|
||||
const ImVec2 box_size(comb_size.x + total_padding, comb_size.y + total_padding);
|
||||
@ -3702,8 +3702,7 @@ void ImGuiFullscreen::DrawToast()
|
||||
const float offset = (comb_size.x - title_size.x) * 0.5f;
|
||||
const ImVec2 title_pos = box_pos + ImVec2(offset + padding, padding);
|
||||
const ImRect title_bb = ImRect(title_pos, title_pos + title_size);
|
||||
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, text_col, s_state.toast_title.c_str(),
|
||||
s_state.toast_title.c_str() + s_state.toast_title.length(), &title_size,
|
||||
RenderShadowedTextClipped(dl, title_font, title_bb.Min, title_bb.Max, text_col, s_state.toast_title, &title_size,
|
||||
ImVec2(0.0f, 0.0f), max_width, &title_bb);
|
||||
}
|
||||
if (!s_state.toast_message.empty())
|
||||
@ -3713,9 +3712,8 @@ void ImGuiFullscreen::DrawToast()
|
||||
const float offset = (comb_size.x - message_size.x) * 0.5f;
|
||||
const ImVec2 message_pos = box_pos + ImVec2(offset + padding, padding + spacing + title_size.y);
|
||||
const ImRect message_bb = ImRect(message_pos, message_pos + message_size);
|
||||
RenderShadowedTextClipped(dl, message_font, message_bb.Min, message_bb.Max, text_col, s_state.toast_message.c_str(),
|
||||
s_state.toast_message.c_str() + s_state.toast_message.length(), &message_size,
|
||||
ImVec2(0.0f, 0.0f), max_width, &message_bb);
|
||||
RenderShadowedTextClipped(dl, message_font, message_bb.Min, message_bb.Max, text_col, s_state.toast_message,
|
||||
&message_size, ImVec2(0.0f, 0.0f), max_width, &message_bb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,14 @@ class GPUTexture;
|
||||
class SmallStringBase;
|
||||
|
||||
namespace ImGuiFullscreen {
|
||||
|
||||
#define HEX_TO_IMVEC4(hex, alpha) \
|
||||
ImVec4(static_cast<float>((hex >> 16) & 0xFFu) / 255.0f, static_cast<float>((hex >> 8) & 0xFFu) / 255.0f, \
|
||||
static_cast<float>(hex & 0xFFu) / 255.0f, static_cast<float>(alpha) / 255.0f)
|
||||
|
||||
// end_ptr() for string_view
|
||||
#define IMSTR_START_END(sv) (sv).data(), (sv).data() + (sv).length()
|
||||
|
||||
static constexpr float LAYOUT_SCREEN_WIDTH = 1280.0f;
|
||||
static constexpr float LAYOUT_SCREEN_HEIGHT = 720.0f;
|
||||
static constexpr float LAYOUT_LARGE_FONT_SIZE = 26.0f;
|
||||
@ -230,7 +234,7 @@ void CancelPendingMenuClose();
|
||||
void PushPrimaryColor();
|
||||
void PopPrimaryColor();
|
||||
|
||||
void DrawWindowTitle(const char* title);
|
||||
void DrawWindowTitle(std::string_view title);
|
||||
|
||||
bool BeginFullscreenColumns(const char* title = nullptr, float pos_y = 0.0f, bool expand_to_screen_width = false,
|
||||
bool footer = false);
|
||||
@ -264,60 +268,60 @@ void BeginMenuButtons(u32 num_items = 0, float y_align = 0.0f, float x_padding =
|
||||
float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING, float item_height = LAYOUT_MENU_BUTTON_HEIGHT);
|
||||
void EndMenuButtons();
|
||||
void GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size);
|
||||
bool MenuButtonFrame(const char* str_id, bool enabled, float height, bool* visible, bool* hovered, ImVec2* min,
|
||||
bool MenuButtonFrame(std::string_view str_id, bool enabled, float height, bool* visible, bool* hovered, ImVec2* min,
|
||||
ImVec2* max, ImGuiButtonFlags flags = 0, float hover_alpha = 1.0f);
|
||||
void DrawMenuButtonFrame(const ImVec2& p_min, const ImVec2& p_max, ImU32 fill_col, bool border = true);
|
||||
void ResetMenuButtonFrame();
|
||||
void RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color, const char* text,
|
||||
const char* text_end, const ImVec2* text_size_if_known = nullptr,
|
||||
void RenderShadowedTextClipped(ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max, u32 color,
|
||||
std::string_view text, const ImVec2* text_size_if_known = nullptr,
|
||||
const ImVec2& align = ImVec2(0, 0), float wrap_width = 0.0f,
|
||||
const ImRect* clip_rect = nullptr);
|
||||
void RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max,
|
||||
u32 color, const char* text, const char* text_end,
|
||||
const ImVec2* text_size_if_known = nullptr, const ImVec2& align = ImVec2(0, 0),
|
||||
float wrap_width = 0.0f, const ImRect* clip_rect = nullptr);
|
||||
u32 color, std::string_view text, const ImVec2* text_size_if_known = nullptr,
|
||||
const ImVec2& align = ImVec2(0, 0), float wrap_width = 0.0f,
|
||||
const ImRect* clip_rect = nullptr);
|
||||
void RenderShadowedTextClipped(ImDrawList* draw_list, ImFont* font, const ImVec2& pos_min, const ImVec2& pos_max,
|
||||
u32 color, const char* text, const char* text_end, const ImVec2* text_size_if_known,
|
||||
const ImVec2& align, float wrap_width, const ImRect* clip_rect, float shadow_offset);
|
||||
void MenuHeading(const char* title, bool draw_line = true);
|
||||
bool MenuHeadingButton(const char* title, const char* value = nullptr, bool enabled = true, bool draw_line = true);
|
||||
bool MenuButton(const char* title, const char* summary, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont,
|
||||
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||
bool MenuButtonWithoutSummary(const char* title, bool enabled = true,
|
||||
u32 color, std::string_view text, const ImVec2* text_size_if_known, const ImVec2& align,
|
||||
float wrap_width, const ImRect* clip_rect, float shadow_offset);
|
||||
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 MenuButton(std::string_view title, std::string_view summary, bool enabled = true,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = UIStyle.LargeFont,
|
||||
ImFont* summary_font = UIStyle.MediumFont, const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||
bool MenuButtonWithoutSummary(std::string_view title, bool enabled = true,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont,
|
||||
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||
bool MenuButtonWithValue(const char* title, const char* summary, const char* value, bool enabled = true,
|
||||
bool MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value, bool enabled = true,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = UIStyle.LargeFont,
|
||||
ImFont* summary_font = UIStyle.MediumFont);
|
||||
bool MenuImageButton(const char* title, const char* summary, ImTextureID user_texture_id, const ImVec2& image_size,
|
||||
bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
bool MenuImageButton(std::string_view title, std::string_view summary, ImTextureID user_texture_id,
|
||||
const ImVec2& image_size, bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
const ImVec2& uv0 = ImVec2(0.0f, 0.0f), const ImVec2& uv1 = ImVec2(1.0f, 1.0f),
|
||||
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont);
|
||||
bool FloatingButton(const char* text, float x, float y, float width = -1.0f,
|
||||
bool FloatingButton(std::string_view text, float x, float y, float width = -1.0f,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, float anchor_x = 0.0f, float anchor_y = 0.0f,
|
||||
bool enabled = true, ImFont* font = UIStyle.LargeFont, ImVec2* out_position = nullptr,
|
||||
bool repeat_button = false);
|
||||
bool ToggleButton(const char* title, const char* summary, bool* v, bool enabled = true,
|
||||
bool ToggleButton(std::string_view title, std::string_view summary, bool* v, bool enabled = true,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = UIStyle.LargeFont,
|
||||
ImFont* summary_font = UIStyle.MediumFont);
|
||||
bool ThreeWayToggleButton(const char* title, const char* summary, std::optional<bool>* v, bool enabled = true,
|
||||
bool ThreeWayToggleButton(std::string_view title, std::string_view summary, std::optional<bool>* v, bool enabled = true,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = UIStyle.LargeFont,
|
||||
ImFont* summary_font = UIStyle.MediumFont);
|
||||
bool RangeButton(const char* title, const char* summary, s32* value, s32 min, s32 max, s32 increment,
|
||||
bool RangeButton(std::string_view title, std::string_view summary, s32* value, s32 min, s32 max, s32 increment,
|
||||
const char* format = "%d", bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont,
|
||||
const char* ok_text = "OK");
|
||||
bool RangeButton(const char* title, const char* summary, float* value, float min, float max, float increment,
|
||||
std::string_view ok_text = "OK");
|
||||
bool RangeButton(std::string_view title, std::string_view summary, float* value, float min, float max, float increment,
|
||||
const char* format = "%f", bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont,
|
||||
const char* ok_text = "OK");
|
||||
bool EnumChoiceButtonImpl(const char* title, const char* summary, s32* value_pointer,
|
||||
std::string_view ok_text = "OK");
|
||||
bool EnumChoiceButtonImpl(std::string_view title, std::string_view summary, s32* value_pointer,
|
||||
const char* (*to_display_name_function)(s32 value, void* opaque), void* opaque, u32 count,
|
||||
bool enabled, float height, ImFont* font, ImFont* summary_font);
|
||||
|
||||
template<typename DataType, typename CountType>
|
||||
ALWAYS_INLINE static bool EnumChoiceButton(const char* title, const char* summary, DataType* value_pointer,
|
||||
ALWAYS_INLINE static bool EnumChoiceButton(std::string_view title, std::string_view summary, DataType* value_pointer,
|
||||
const char* (*to_display_name_function)(DataType value), CountType count,
|
||||
bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT,
|
||||
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont)
|
||||
@ -341,18 +345,19 @@ ALWAYS_INLINE static bool EnumChoiceButton(const char* title, const char* summar
|
||||
|
||||
void BeginNavBar(float x_padding = LAYOUT_MENU_BUTTON_X_PADDING, float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING);
|
||||
void EndNavBar();
|
||||
void NavTitle(const char* title, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont);
|
||||
void NavTitle(std::string_view title, float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
||||
ImFont* font = UIStyle.LargeFont);
|
||||
void RightAlignNavButtons(u32 num_items = 0, float item_width = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY,
|
||||
float item_height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
bool NavButton(const char* title, bool is_active, bool enabled = true, float width = -1.0f,
|
||||
bool NavButton(std::string_view title, bool is_active, bool enabled = true, float width = -1.0f,
|
||||
float height = LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, ImFont* font = UIStyle.LargeFont);
|
||||
bool NavTab(const char* title, bool is_active, bool enabled, float width, float height, const ImVec4& background,
|
||||
bool NavTab(std::string_view title, bool is_active, bool enabled, float width, float height, const ImVec4& background,
|
||||
ImFont* font = UIStyle.LargeFont);
|
||||
|
||||
bool BeginHorizontalMenu(const char* name, const ImVec2& position, const ImVec2& size, const ImVec4& bg_color,
|
||||
u32 num_items);
|
||||
void EndHorizontalMenu();
|
||||
bool HorizontalMenuItem(GPUTexture* icon, const char* title, const char* description,
|
||||
bool HorizontalMenuItem(GPUTexture* icon, std::string_view title, std::string_view description,
|
||||
u32 color = IM_COL32(255, 255, 255, 255));
|
||||
|
||||
using FileSelectorCallback = std::function<void(std::string path)>;
|
||||
@ -393,10 +398,10 @@ float GetNotificationVerticalPosition();
|
||||
float GetNotificationVerticalDirection();
|
||||
void SetNotificationVerticalPosition(float position, float direction);
|
||||
|
||||
void OpenBackgroundProgressDialog(const char* str_id, std::string message, s32 min, s32 max, s32 value);
|
||||
void UpdateBackgroundProgressDialog(const char* str_id, std::string message, s32 min, s32 max, s32 value);
|
||||
void CloseBackgroundProgressDialog(const char* str_id);
|
||||
bool IsBackgroundProgressDialogOpen(const char* str_id);
|
||||
void OpenBackgroundProgressDialog(std::string_view str_id, std::string message, s32 min, s32 max, s32 value);
|
||||
void UpdateBackgroundProgressDialog(std::string_view str_id, std::string message, s32 min, s32 max, s32 value);
|
||||
void CloseBackgroundProgressDialog(std::string_view str_id);
|
||||
bool IsBackgroundProgressDialogOpen(std::string_view str_id);
|
||||
|
||||
/// Displays a loading screen with the logo, rendered with ImGui. Use when executing possibly-time-consuming tasks
|
||||
/// such as compiling shaders when starting up.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||
|
||||
#include "imgui_manager.h"
|
||||
@ -1034,8 +1034,7 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||
break;
|
||||
|
||||
const ImVec2 pos(position_x, actual_y);
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, max_width, max_width, msg.text.c_str(),
|
||||
msg.text.c_str() + msg.text.length()));
|
||||
const ImVec2 text_size(font->CalcTextSizeA(font->FontSize, max_width, max_width, IMSTR_START_END(msg.text)));
|
||||
const ImVec2 size(text_size.x + padding * 2.0f, text_size.y + padding * 2.0f);
|
||||
const ImRect text_rect(pos.x + padding, pos.y + padding, pos.x + size.x - padding, pos.y + size.y - padding);
|
||||
|
||||
@ -1043,9 +1042,8 @@ void ImGuiManager::DrawOSDMessages(Timer::Value current_time)
|
||||
dl->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y),
|
||||
ImGui::GetColorU32(ModAlpha(UIStyle.ToastBackgroundColor, opacity * 0.95f)), rounding);
|
||||
RenderShadowedTextClipped(dl, font, text_rect.Min, text_rect.Max,
|
||||
ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity)), msg.text.c_str(),
|
||||
msg.text.c_str() + msg.text.length(), &text_size, ImVec2(0.0f, 0.0f), max_width,
|
||||
&text_rect, scale);
|
||||
ImGui::GetColorU32(ModAlpha(UIStyle.ToastTextColor, opacity)), msg.text, &text_size,
|
||||
ImVec2(0.0f, 0.0f), max_width, &text_rect, scale);
|
||||
position_y += size.y + spacing;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user