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

Method start

src/engine/engine.cpp:69–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68 return true;
69}
70
71auto Sorcery::Engine::start(const int mode) -> int {
72
73 using namespace std::chrono_literals;
74
75 _ctx.controller->initialise();
76 _ctx.controller->set_flag("in_engine");
77 _ctx.controller->go_to(Enums::Screen::ENGINE);
78 if (_ctx.game->state->get_party_size() > 0)
79 _ctx.controller->set_character(
80 Enums::CharacterSlot::INSPECT,
81 _ctx.game->state->get_party_char(1).value());
82
83 _start_expedition(mode);
84
85 _ctx.audio->set_volume(1.0f);
86
87 fade_in(
88 [this] {
89 _ctx.ui->display_engine();
90 },
91 500ms);
92
93 // Main loop
94 auto done{false};
95 while (!done) {
96
97 SDL_Event event;
98 while (SDL_PollEvent(&event)) {
99
100 ImGui_ImplSDL2_ProcessEvent(&event);
101
102 done = _ctx.controller->check_for_abort(event);
103 if (_ctx.controller->want_to_abort())
104 return ABORT_GAME;
105
106 if (_ctx.controller->check_for_quicksave(event))
107 _application->save_state_to_binary(
108 _ctx.get_file(SAVE_STATE_FILENAME));
109 else if (_ctx.controller->check_for_quickload(event))
110 _application->load_state_from_binary(
111 _ctx.get_file(SAVE_STATE_FILENAME));
112
113 _ctx.controller->check_for_resize(event, _ctx.ui);
114
115 // Check for Debug
116 _ctx.controller->check_for_debug(event);
117
118 // Back closes popup first, otherwise opens camp.
119 if (_ctx.controller->check_for_back(event)) {
120 if (_ctx.ui->in_popup()) {
121 _ctx.ui->close_all_popups();
122 _ctx.controller->clear_modal_flags();
123 } else {
124 _ctx.ui->modal_camp->show = true;
125 _ctx.controller->set_flag("want_camp");
126 }

Callers

nothing calls this directly

Calls 15

set_flagMethod · 0.80
go_toMethod · 0.80
get_party_sizeMethod · 0.80
set_characterMethod · 0.80
get_party_charMethod · 0.80
set_volumeMethod · 0.80
check_for_abortMethod · 0.80
want_to_abortMethod · 0.80
check_for_quicksaveMethod · 0.80
save_state_to_binaryMethod · 0.80
check_for_quickloadMethod · 0.80

Tested by

no test coverage detected