MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / setAppState

Function setAppState

TheForceEngine/main.cpp:276–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274static bool s_soundPaused = false;
275
276void setAppState(AppState newState, int argc, char* argv[])
277{
278 const TFE_Settings_Graphics* config = TFE_Settings::getGraphicsSettings();
279
280#if ENABLE_EDITOR == 1
281 if (newState != APP_STATE_EDITOR)
282 {
283 TFE_Editor::disable();
284 }
285#endif
286
287 switch (newState)
288 {
289 case APP_STATE_MENU:
290 case APP_STATE_SET_DEFAULTS:
291 break;
292 case APP_STATE_EDITOR:
293
294 if (validatePath())
295 {
296 #if ENABLE_EDITOR == 1
297 TFE_Editor::enable();
298 #endif
299 }
300 else
301 {
302 newState = APP_STATE_NO_GAME_DATA;
303 }
304 break;
305 case APP_STATE_LOAD:
306 {
307 bool pathIsValid = validatePath();
308 if (pathIsValid && s_loadRequestFilename)
309 {
310 newState = APP_STATE_GAME;
311 TFE_FrontEndUI::setAppState(APP_STATE_GAME);
312
313 TFE_Game* gameInfo = TFE_Settings::getGame();
314 if (s_curGame)
315 {
316 freeGame(s_curGame);
317 s_curGame = nullptr;
318 }
319 s_soundPaused = false;
320 s_curGame = createGame(gameInfo->id);
321 TFE_SaveSystem::setCurrentGame(s_curGame);
322 if (!s_curGame)
323 {
324 TFE_System::logWrite(LOG_ERROR, "AppMain", "Cannot create game '%s'.", gameInfo->game);
325 newState = APP_STATE_CANNOT_RUN;
326 }
327 else if (!TFE_SaveSystem::loadGame(s_loadRequestFilename))
328 {
329 TFE_System::logWrite(LOG_ERROR, "AppMain", "Cannot run game '%s'.", gameInfo->game);
330 freeGame(s_curGame);
331 s_curGame = nullptr;
332 newState = APP_STATE_CANNOT_RUN;
333 }

Callers 1

mainFunction · 0.70

Calls 13

getGraphicsSettingsFunction · 0.85
disableFunction · 0.85
getGameFunction · 0.85
freeGameFunction · 0.85
createGameFunction · 0.85
logWriteFunction · 0.85
loadGameFunction · 0.85
enableRelativeModeFunction · 0.85
startReplayStatusFunction · 0.85
validatePathFunction · 0.70
enableFunction · 0.50
setCurrentGameFunction · 0.50

Tested by

no test coverage detected