MCPcopy Create free account
hub / github.com/davemoore22/sorcery / start

Method start

src/modules/create.cpp:52–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 return true;
51}
52
53auto Sorcery::Create::start() -> int {
54
55 _ctx.controller->go_to(Enums::Screen::CREATE);
56 _ctx.controller->initialise();
57
58 _ctx.game->creation_candidate = std::make_shared<Character>(&_ctx);
59 _ctx.game->creation_candidate->reset(Enums::Character::Stage::ENTER_NAME);
60
61 auto candidate{_ctx.game->creation_candidate};
62
63 _ctx.ui->first_frame = true;
64 _ctx.controller->clear_input_buffer();
65
66 // Main loop
67 auto done{false};
68 SDL_Event event;
69 while (!done) {
70
71 while (SDL_PollEvent(&event)) {
72
73 // Check for Quit Events
74 ImGui_ImplSDL2_ProcessEvent(&event);
75 done = _ctx.controller->check_for_abort(event);
76
77 // Check for Window Resize
78 _ctx.controller->check_for_resize(event, _ctx.ui);
79
80 // Check for Back Event
81 if (_ctx.controller->check_for_back(event)) {
82 if (_go_back_stage())
83 return BACK_TO_TRAINING_GROUNDS;
84 }
85
86 if (_ctx.controller->check_for_quicksave(event))
87 _ctx.application->save_state_to_binary(
88 _ctx.get_file(SAVE_STATE_FILENAME));
89 else if (_ctx.controller->check_for_quickload(event)) {
90 _ctx.application->load_state_from_binary(
91 _ctx.get_file(SAVE_STATE_FILENAME));
92 continue;
93 }
94 }
95
96 using enum Enums::Character::Stage;
97 switch (candidate->get_stage()) {
98 case ENTER_NAME:
99 _ctx.ui->display(Enums::Screen::CREATE_NAME,
100 unenum(candidate->get_stage()));
101
102 if (candidate->get_stage() != Enums::Character::Stage::ENTER_NAME) {
103 candidate->set_stage(CHOOSE_RACE);
104 }
105 break;
106 case CHOOSE_RACE:
107 _ctx.ui->display(Enums::Screen::CREATE_RACE,
108 unenum(candidate->get_stage()));
109 if (candidate->get_stage() !=

Callers

nothing calls this directly

Calls 15

unenumFunction · 0.85
go_toMethod · 0.80
clear_input_bufferMethod · 0.80
check_for_abortMethod · 0.80
check_for_resizeMethod · 0.80
check_for_backMethod · 0.80
check_for_quicksaveMethod · 0.80
save_state_to_binaryMethod · 0.80
check_for_quickloadMethod · 0.80
get_stageMethod · 0.80
set_stageMethod · 0.80

Tested by

no test coverage detected