mirror of
https://github.com/stenzek/duckstation.git
synced 2025-07-21 17:40:16 +00:00
FullscreenUI: Avoid ID duplication in choice dialogs
If two items, e.g. discs happen to have the same display name.
This commit is contained in:
parent
00623ebf8b
commit
9e319ff495
@ -3390,7 +3390,7 @@ void Achievements::DrawLeaderboardsWindow()
|
|||||||
|
|
||||||
bool visible;
|
bool visible;
|
||||||
text.format(ICON_FA_HOURGLASS_HALF " {}", TRANSLATE_SV("Achievements", "Loading..."));
|
text.format(ICON_FA_HOURGLASS_HALF " {}", TRANSLATE_SV("Achievements", "Loading..."));
|
||||||
ImGuiFullscreen::MenuButtonWithVisibilityQuery(text, {}, {}, &visible, false);
|
ImGuiFullscreen::MenuButtonWithVisibilityQuery(text, text, {}, {}, &visible, false);
|
||||||
if (visible && !s_state.leaderboard_fetch_handle)
|
if (visible && !s_state.leaderboard_fetch_handle)
|
||||||
FetchNextLeaderboardEntries();
|
FetchNextLeaderboardEntries();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
LOG_CHANNEL(ImGuiFullscreen);
|
LOG_CHANNEL(ImGuiFullscreen);
|
||||||
|
|
||||||
namespace ImGuiFullscreen {
|
namespace ImGuiFullscreen {
|
||||||
@ -1870,31 +1872,32 @@ bool ImGuiFullscreen::MenuButton(std::string_view title, std::string_view summar
|
|||||||
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
||||||
{
|
{
|
||||||
bool visible;
|
bool visible;
|
||||||
return MenuButtonWithVisibilityQuery(title, summary, {}, &visible, enabled, text_align);
|
return MenuButtonWithVisibilityQuery(title, title, summary, {}, &visible, enabled, text_align);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuButtonWithoutSummary(std::string_view title, bool enabled /* = true */,
|
bool ImGuiFullscreen::MenuButtonWithoutSummary(std::string_view title, bool enabled /* = true */,
|
||||||
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
||||||
{
|
{
|
||||||
bool visible;
|
bool visible;
|
||||||
return MenuButtonWithVisibilityQuery(title, {}, {}, &visible, enabled, text_align);
|
return MenuButtonWithVisibilityQuery(title, title, {}, {}, &visible, enabled, text_align);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value,
|
bool ImGuiFullscreen::MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value,
|
||||||
bool enabled /* = true*/, const ImVec2& text_align /* = ImVec2(0.0f, 0.0f)*/)
|
bool enabled /* = true*/, const ImVec2& text_align /* = ImVec2(0.0f, 0.0f)*/)
|
||||||
{
|
{
|
||||||
bool visible;
|
bool visible;
|
||||||
return MenuButtonWithVisibilityQuery(title, summary, value, &visible, enabled, text_align);
|
return MenuButtonWithVisibilityQuery(title, title, summary, value, &visible, enabled, text_align);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuButtonWithVisibilityQuery(std::string_view title, std::string_view summary,
|
bool ImGuiFullscreen::MenuButtonWithVisibilityQuery(std::string_view str_id, std::string_view title,
|
||||||
std::string_view value, bool* visible, bool enabled /* = true */,
|
std::string_view summary, std::string_view value, bool* visible,
|
||||||
|
bool enabled /* = true */,
|
||||||
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
const ImVec2& text_align /* = ImVec2(0.0f, 0.0f) */)
|
||||||
{
|
{
|
||||||
const MenuButtonBounds bb(title, value, summary);
|
const MenuButtonBounds bb(title, value, summary);
|
||||||
|
|
||||||
bool hovered;
|
bool hovered;
|
||||||
bool pressed = MenuButtonFrame(title, enabled, bb.frame_bb, visible, &hovered);
|
bool pressed = MenuButtonFrame(str_id, enabled, bb.frame_bb, visible, &hovered);
|
||||||
if (!*visible)
|
if (!*visible)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3157,7 +3160,8 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
|
|
||||||
const SmallString title =
|
const SmallString title =
|
||||||
SmallString::from_format("{0} {1}", option.second ? ICON_FA_SQUARE_CHECK : ICON_FA_SQUARE, option.first);
|
SmallString::from_format("{0} {1}", option.second ? ICON_FA_SQUARE_CHECK : ICON_FA_SQUARE, option.first);
|
||||||
if (MenuButtonWithoutSummary(title))
|
bool visible;
|
||||||
|
if (MenuButtonWithVisibilityQuery(TinyString::from_format("item{}", i), title, {}, {}, &visible))
|
||||||
{
|
{
|
||||||
choice = i;
|
choice = i;
|
||||||
option.second = !option.second;
|
option.second = !option.second;
|
||||||
@ -3201,7 +3205,9 @@ void ImGuiFullscreen::ChoiceDialog::Draw()
|
|||||||
{
|
{
|
||||||
auto& option = m_options[i];
|
auto& option = m_options[i];
|
||||||
|
|
||||||
if (option.second ? MenuButtonWithValue(option.first, {}, ICON_FA_CHECK) : MenuButtonWithoutSummary(option.first))
|
bool visible;
|
||||||
|
if (MenuButtonWithVisibilityQuery(TinyString::from_format("item{}", i), option.first, {},
|
||||||
|
option.second ? ICON_FA_CHECK ""sv : std::string_view(), &visible))
|
||||||
{
|
{
|
||||||
choice = i;
|
choice = i;
|
||||||
for (s32 j = 0; j < static_cast<s32>(m_options.size()); j++)
|
for (s32 j = 0; j < static_cast<s32>(m_options.size()); j++)
|
||||||
|
@ -312,8 +312,9 @@ bool MenuButtonWithoutSummary(std::string_view title, bool enabled = true,
|
|||||||
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||||
bool MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value, bool enabled = true,
|
bool MenuButtonWithValue(std::string_view title, std::string_view summary, std::string_view value, bool enabled = true,
|
||||||
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||||
bool MenuButtonWithVisibilityQuery(std::string_view title, std::string_view summary, std::string_view value,
|
bool MenuButtonWithVisibilityQuery(std::string_view str_id, std::string_view title, std::string_view summary,
|
||||||
bool* visible, bool enabled = true, const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
std::string_view value, bool* visible, bool enabled = true,
|
||||||
|
const ImVec2& text_align = ImVec2(0.0f, 0.0f));
|
||||||
bool MenuImageButton(std::string_view title, std::string_view summary, ImTextureID user_texture_id,
|
bool MenuImageButton(std::string_view title, std::string_view summary, ImTextureID user_texture_id,
|
||||||
const ImVec2& image_size, bool enabled = true, const ImVec2& uv0 = ImVec2(0.0f, 0.0f),
|
const ImVec2& image_size, bool enabled = true, const ImVec2& uv0 = ImVec2(0.0f, 0.0f),
|
||||||
const ImVec2& uv1 = ImVec2(1.0f, 1.0f));
|
const ImVec2& uv1 = ImVec2(1.0f, 1.0f));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user