FullscreenUI: Enable DrawStringListSetting()
This commit is contained in:
parent
c0c2e69b59
commit
90e9634c19
|
@ -334,12 +334,12 @@ static void DrawIntRectSetting(SettingsInterface* bsi, const char* title, const
|
||||||
int min_value, int max_value, const char* format = "%d", bool enabled = true,
|
int min_value, int max_value, const char* format = "%d", bool enabled = true,
|
||||||
float height = ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font,
|
float height = ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font,
|
||||||
ImFont* summary_font = g_medium_font);
|
ImFont* summary_font = g_medium_font);
|
||||||
static void DrawStringListSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
|
||||||
const char* key, const char* default_value, const char* const* options,
|
|
||||||
const char* const* option_values, size_t option_count, bool enabled = true,
|
|
||||||
float height = ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT,
|
|
||||||
ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
|
|
||||||
#endif
|
#endif
|
||||||
|
static void DrawStringListSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
||||||
|
const char* key, const char* default_value, std::span<const char* const> options,
|
||||||
|
std::span<const char* const> option_values, bool enabled = true,
|
||||||
|
float height = ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT,
|
||||||
|
ImFont* font = UIStyle.LargeFont, ImFont* summary_font = UIStyle.MediumFont);
|
||||||
template<typename DataType, typename SizeType>
|
template<typename DataType, typename SizeType>
|
||||||
static void DrawEnumSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
static void DrawEnumSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
||||||
const char* key, DataType default_value,
|
const char* key, DataType default_value,
|
||||||
|
@ -2463,28 +2463,23 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, const char* tit
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
[[maybe_unused]] void FullscreenUI::DrawStringListSetting(SettingsInterface* bsi, const char* title,
|
||||||
void FullscreenUI::DrawStringListSetting(SettingsInterface* bsi, const char* title, const char* summary,
|
const char* summary, const char* section, const char* key,
|
||||||
const char* section, const char* key, const char* default_value,
|
const char* default_value,
|
||||||
const char* const* options, const char* const* option_values,
|
std::span<const char* const> options,
|
||||||
size_t option_count, bool enabled, float height, ImFont* font,
|
std::span<const char* const> option_values, bool enabled,
|
||||||
ImFont* summary_font)
|
float height, ImFont* font, ImFont* summary_font)
|
||||||
{
|
{
|
||||||
const bool game_settings = IsEditingGameSettings(bsi);
|
const bool game_settings = IsEditingGameSettings(bsi);
|
||||||
const std::optional<SmallString> value(bsi->GetOptionalSmallStringValue(
|
const std::optional<SmallString> value(bsi->GetOptionalSmallStringValue(
|
||||||
section, key, game_settings ? std::nullopt : std::optional<const char*>(default_value)));
|
section, key, game_settings ? std::nullopt : std::optional<const char*>(default_value)));
|
||||||
|
|
||||||
if (option_count == 0)
|
DebugAssert(options.size() == option_values.size());
|
||||||
{
|
|
||||||
// select from null entry
|
|
||||||
while (options && options[option_count] != nullptr)
|
|
||||||
option_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t index = option_count;
|
size_t index = options.size();
|
||||||
if (value.has_value())
|
if (value.has_value())
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < option_count; i++)
|
for (size_t i = 0; i < options.size(); i++)
|
||||||
{
|
{
|
||||||
if (value == option_values[i])
|
if (value == option_values[i])
|
||||||
{
|
{
|
||||||
|
@ -2495,15 +2490,15 @@ void FullscreenUI::DrawStringListSetting(SettingsInterface* bsi, const char* tit
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MenuButtonWithValue(title, summary,
|
if (MenuButtonWithValue(title, summary,
|
||||||
value.has_value() ? ((index < option_count) ? options[index] : "Unknown") :
|
value.has_value() ? ((index < options.size()) ? options[index] : FSUI_CSTR("Unknown")) :
|
||||||
"Use Global Setting",
|
FSUI_CSTR("Use Global Setting"),
|
||||||
enabled, height, font, summary_font))
|
enabled, height, font, summary_font))
|
||||||
{
|
{
|
||||||
ImGuiFullscreen::ChoiceDialogOptions cd_options;
|
ImGuiFullscreen::ChoiceDialogOptions cd_options;
|
||||||
cd_options.reserve(option_count + 1);
|
cd_options.reserve(options.size() + 1);
|
||||||
if (game_settings)
|
if (game_settings)
|
||||||
cd_options.emplace_back("Use Global Setting", !value.has_value());
|
cd_options.emplace_back(FSUI_CSTR("Use Global Setting"), !value.has_value());
|
||||||
for (size_t i = 0; i < option_count; i++)
|
for (size_t i = 0; i < options.size(); i++)
|
||||||
cd_options.emplace_back(options[i], (value.has_value() && i == static_cast<size_t>(index)));
|
cd_options.emplace_back(options[i], (value.has_value() && i == static_cast<size_t>(index)));
|
||||||
OpenChoiceDialog(title, false, std::move(cd_options),
|
OpenChoiceDialog(title, false, std::move(cd_options),
|
||||||
[game_settings, section, key, option_values](s32 index, const std::string& title, bool checked) {
|
[game_settings, section, key, option_values](s32 index, const std::string& title, bool checked) {
|
||||||
|
@ -2530,7 +2525,6 @@ void FullscreenUI::DrawStringListSetting(SettingsInterface* bsi, const char* tit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename DataType, typename SizeType>
|
template<typename DataType, typename SizeType>
|
||||||
void FullscreenUI::DrawEnumSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
void FullscreenUI::DrawEnumSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
|
||||||
|
|
Loading…
Reference in New Issue