| 347 | } |
| 348 | |
| 349 | void Scene_Settings::UpdateOptions() { |
| 350 | if (number_window) { |
| 351 | number_window->Update(); |
| 352 | auto& option = options_window->GetCurrentOption(); |
| 353 | option.current_value = Utils::Clamp(number_window->GetNumber(), option.min_value, option.max_value); |
| 354 | option.action(); |
| 355 | |
| 356 | if (Input::IsTriggered(Input::DECISION)) { |
| 357 | options_window->Refresh(); |
| 358 | number_window.reset(); |
| 359 | options_window->SetActive(true); |
| 360 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Game_System::SFX_Decision)); |
| 361 | } |
| 362 | return; |
| 363 | } else if (picker_window) { |
| 364 | picker_window->Update(); |
| 365 | auto& option = options_window->GetCurrentOption(); |
| 366 | option.current_value = option.options_index[picker_window->GetIndex()]; |
| 367 | option.action(); |
| 368 | |
| 369 | if (Input::IsTriggered(Input::DECISION)) { |
| 370 | options_window->Refresh(); |
| 371 | picker_window.reset(); |
| 372 | options_window->SetActive(true); |
| 373 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Game_System::SFX_Decision)); |
| 374 | } |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | if (Input::IsTriggered(Input::DECISION)) { |
| 379 | if (options_window->IsCurrentActionEnabled()) { |
| 380 | Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Game_System::SFX_Decision)); |
| 381 | auto& option = options_window->GetCurrentOption(); |
| 382 | if (option.mode == Window_Settings::eOptionNone) { |
| 383 | option.action(); |
| 384 | options_window->Refresh(); |
| 385 | } else if (option.mode == Window_Settings::eOptionRangeInput) { |
| 386 | number_window.reset(new Window_NumberInput(0, 0, 128, 32)); |
| 387 | number_window->SetNumber(option.current_value); |
| 388 | number_window->SetMaxDigits(std::log10(option.max_value) + 1); |
| 389 | number_window->SetX(options_window->GetX() + options_window->GetWidth() / 2 - number_window->GetWidth() / 2); |
| 390 | number_window->SetY(options_window->GetY() + options_window->GetHeight() / 2 - number_window->GetHeight() / 2); |
| 391 | number_window->SetZ(options_window->GetZ() + 1); |
| 392 | number_window->SetOpacity(255); |
| 393 | number_window->SetActive(true); |
| 394 | help_window->SetText(fmt::format("Input a value from {} to {}", option.min_value, option.max_value)); |
| 395 | options_window->SetActive(false); |
| 396 | } else if (option.mode == Window_Settings::eOptionPicker) { |
| 397 | picker_window.reset(new Window_Command(option.options_text)); |
| 398 | picker_window->SetX(options_window->GetX() + options_window->GetWidth() / 2 - picker_window->GetWidth() / 2); |
| 399 | picker_window->SetY(options_window->GetY() + options_window->GetHeight() / 2 - picker_window->GetHeight() / 2); |
| 400 | picker_window->SetZ(options_window->GetZ() + 1); |
| 401 | picker_window->SetIndex(option.current_value); |
| 402 | picker_window->SetHelpWindow(help_window.get()); |
| 403 | picker_window->SetActive(true); |
| 404 | options_window->SetActive(false); |
| 405 | picker_window->UpdateHelpFn = [this](Window_Help& win, int index) { |
| 406 | win.SetText(options_window->GetCurrentOption().options_help[index]); |
nothing calls this directly
no test coverage detected