| 464 | } |
| 465 | |
| 466 | void Scene_Settings::UpdateFont(bool mincho) { |
| 467 | auto fs = Game_Config::GetFontFilesystem(); |
| 468 | |
| 469 | auto& last_index = options_window->GetFrame().scratch; |
| 470 | |
| 471 | if (font_size_window) { |
| 472 | font_size_window->SetY(options_window->GetY() + options_window->GetCursorRect().y); |
| 473 | font_size_window->Update(); |
| 474 | } |
| 475 | |
| 476 | int index = options_window->GetIndex(); |
| 477 | if (last_index == index) { |
| 478 | if (index == 0 || !help_window2->GetFont() || help_window2->GetFont()->GetCurrentStyle().size == options_window->font_size.Get()) { |
| 479 | // Same index or font size did not change |
| 480 | UpdateOptions(); |
| 481 | return; |
| 482 | } |
| 483 | } |
| 484 | last_index = index; |
| 485 | |
| 486 | if (!font_size_window) { |
| 487 | font_size_window = std::make_unique<Window_Help>(options_window->GetRightX(), 0, 32, 32); |
| 488 | font_size_window->SetLeftArrow(true); |
| 489 | font_size_window->SetRightArrow(true); |
| 490 | font_size_window->SetAnimateArrows(true); |
| 491 | } |
| 492 | |
| 493 | font_size_window->SetVisible(false); |
| 494 | font_size_window->SetText(std::to_string(options_window->font_size.Get())); |
| 495 | |
| 496 | if (index == 0) { |
| 497 | // Built-In font |
| 498 | help_window2->Clear(); |
| 499 | help_window2->SetFont(Font::DefaultBitmapFont(mincho)); |
| 500 | help_window2->SetVisible(true); |
| 501 | } else if (index >= options_window->GetRowMax() - 2) { |
| 502 | // Sample or browse |
| 503 | help_window2->Clear(); |
| 504 | help_window2->SetFont(nullptr); |
| 505 | help_window2->SetVisible(true); |
| 506 | } else { |
| 507 | auto is = fs.OpenInputStream(options_window->GetCurrentOption().text); |
| 508 | if (is) { |
| 509 | auto font = Font::CreateFtFont(std::move(is), options_window->font_size.Get(), false, false); |
| 510 | if (font) { |
| 511 | help_window2->Clear(); |
| 512 | help_window2->SetFont(font); |
| 513 | help_window2->SetVisible(true); |
| 514 | font_size_window->SetVisible(true); |
| 515 | } else { |
| 516 | auto& opt = options_window->GetCurrentOption(); |
| 517 | opt.action = nullptr; |
| 518 | opt.value_text = "[Broken]"; |
| 519 | opt.help2.clear(); |
| 520 | options_window->DrawOption(options_window->GetIndex()); |
| 521 | } |
| 522 | } |
| 523 | } |
nothing calls this directly
no test coverage detected