MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DrawFloatListSetting

Method DrawFloatListSetting

pcsx2/ImGui/FullscreenUI_Settings.cpp:1282–1350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1280}
1281
1282void FullscreenUI::DrawFloatListSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
1283 const char* key, float default_value, const char* const* options, const float* option_values, size_t option_count,
1284 bool translate_options, bool enabled, float height, std::pair<ImFont*, float> font, std::pair<ImFont*, float> summary_font)
1285{
1286 const bool game_settings = IsEditingGameSettings(bsi);
1287 const std::optional<float> value(
1288 bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value)));
1289
1290 if (option_count == 0)
1291 {
1292 // select from null entry
1293 while (options && options[option_count] != nullptr)
1294 option_count++;
1295 }
1296
1297 size_t index = option_count;
1298 if (value.has_value())
1299 {
1300 for (size_t i = 0; i < option_count; i++)
1301 {
1302 if (value == option_values[i])
1303 {
1304 index = i;
1305 break;
1306 }
1307 }
1308 }
1309
1310 if (MenuButtonWithValue(title, summary,
1311 value.has_value() ?
1312 ((index < option_count) ? (translate_options ? Host::TranslateToCString(TR_CONTEXT, options[index]) : options[index]) :
1313 FSUI_CSTR("Unknown")) :
1314 FSUI_CSTR("Use Global Setting"),
1315 enabled, height, font, summary_font))
1316 {
1317 ImGuiFullscreen::ChoiceDialogOptions cd_options;
1318 cd_options.reserve(option_count + 1);
1319 if (game_settings)
1320 cd_options.emplace_back(FSUI_STR("Use Global Setting"), !value.has_value());
1321 for (size_t i = 0; i < option_count; i++)
1322 {
1323 cd_options.emplace_back(translate_options ? Host::TranslateToString(TR_CONTEXT, options[i]) : std::string(options[i]),
1324 (value.has_value() && i == static_cast<size_t>(index)));
1325 }
1326 OpenChoiceDialog(title, false, std::move(cd_options),
1327 [game_settings, section, key, option_values](s32 index, const std::string& title, bool checked) {
1328 if (index >= 0)
1329 {
1330 auto lock = Host::GetSettingsLock();
1331 SettingsInterface* bsi = GetEditingSettingsInterface(game_settings);
1332 if (game_settings)
1333 {
1334 if (index == 0)
1335 bsi->DeleteValue(section, key);
1336 else
1337 bsi->SetFloatValue(section, key, option_values[index - 1]);
1338 }
1339 else

Callers

nothing calls this directly

Calls 4

stringClass · 0.50
reserveMethod · 0.45
DeleteValueMethod · 0.45
SetFloatValueMethod · 0.45

Tested by

no test coverage detected