MCPcopy Create free account
hub / github.com/crawl/crawl / UIStartupMenu

Method UIStartupMenu

crawl-ref/source/startup.cc:575–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573{
574public:
575 UIStartupMenu(newgame_def& _ng_choice, const newgame_def &_defaults)
576 : done(false), end_game(false), ng_choice(_ng_choice),
577 defaults(_defaults),
578 selected_game_type(crawl_state.last_type)
579 {
580 chars = find_all_saved_characters();
581 num_saves = chars.size();
582 input_string = crawl_state.default_startup_name;
583
584 m_root = make_shared<Box>(Box::VERT);
585 add_internal_child(m_root);
586 m_root->set_cross_alignment(Widget::Align::STRETCH);
587
588 auto about = make_shared<Text>(opening_screen());
589 about->set_margin_for_crt(0, 0, 1, 0);
590 about->set_margin_for_sdl(0, 0, 10, 0);
591
592 m_root->add_child(std::move(about));
593
594 auto grid = make_shared<Grid>();
595 grid->set_margin_for_crt(0, 0, 1, 0);
596
597 auto name_prompt = make_shared<Text>("Enter your name:");
598 name_prompt->set_margin_for_crt(0, 1, 1, 0);
599 name_prompt->set_margin_for_sdl(0, 0, 10, 0);
600
601 // If the game filled in a complete name, the user will
602 // usually want to enter a new name instead of adding
603 // to the current one.
604 input_text = make_shared<Text>(formatted_string(input_string, WHITE));
605 input_text->set_margin_for_crt(0, 0, 1, 0);
606 input_text->set_margin_for_sdl(0, 0, 10, 10);
607
608 grid->add_child(std::move(name_prompt), 0, 0);
609 grid->add_child(input_text, 1, 0);
610
611 descriptions = make_shared<Switcher>();
612
613 auto mode_prompt = make_shared<Text>("Choices:");
614 mode_prompt->set_margin_for_crt(0, 1, 1, 0);
615 mode_prompt->set_margin_for_sdl(0, 0, 10, 0);
616 game_modes_menu = make_shared<OuterMenu>(true, 1, entries.size());
617 game_modes_menu->set_margin_for_sdl(0, 0, 10, 10);
618 game_modes_menu->set_margin_for_crt(0, 0, 1, 0);
619 game_modes_menu->descriptions = descriptions;
620 _construct_game_modes_menu(game_modes_menu);
621
622#ifdef USE_TILE_LOCAL
623 game_modes_menu->min_size().height = TILE_Y*3;
624#else
625 game_modes_menu->min_size().height = 2;
626#endif
627
628 grid->add_child(std::move(mode_prompt), 0, 1);
629 grid->add_child(game_modes_menu, 1, 1);
630
631 save_games_menu = make_shared<OuterMenu>(num_saves > 1, 1, num_saves + 1);
632 if (num_saves > 0)

Callers

nothing calls this directly

Calls 15

menu_item_activatedMethod · 0.95
on_button_focusinMethod · 0.95
opening_screenFunction · 0.85
_find_saveFunction · 0.85
_game_definedFunction · 0.85
newgame_char_descriptionFunction · 0.85
recent_error_messagesFunction · 0.85
parse_stringFunction · 0.85
set_cross_alignmentMethod · 0.80

Tested by

no test coverage detected