network_stop() and shortcuts to singleplayer and local multiplayer.
This commit is contained in:
@@ -14,44 +14,39 @@ static void state_enter(Presentation_State *state) {
|
||||
(void)ctx;
|
||||
|
||||
ctx->mode = Main_Menu_Mode_Home;
|
||||
|
||||
// if(ctx->game_session != NULL) {
|
||||
// if(ctx->game_session->is_singleplayer) {
|
||||
|
||||
// }
|
||||
// else {
|
||||
// if(ctx->game_session->is_host) {
|
||||
// networking_stop_hosting(ctx->game_networking);
|
||||
// }
|
||||
// else {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// game_session_dispose(ctx->game_session);
|
||||
// ctx->game_session = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
static void state_tick(Presentation_State *state) {
|
||||
Presentation_State_Main_Menu_Context *ctx = (Presentation_State_Main_Menu_Context *)state->context;
|
||||
|
||||
// { // DEBUG
|
||||
// if(IsKeyPressed(KEY_P)) {
|
||||
// game_session_init_default_settings(true, &ctx->session_settings);
|
||||
|
||||
// assert(ctx->game_session == NULL);
|
||||
// ctx->game_session = (Game_Session *)calloc(1, sizeof(Game_Session));
|
||||
|
||||
// game_session_init(
|
||||
// ctx->game_session,
|
||||
// ctx->session_settings
|
||||
// );
|
||||
|
||||
// ctx->ingame_ctx->game_instance = ctx->game_instance;
|
||||
// presentation_state_machine_go_to(&presentation_state_ingame);
|
||||
// }
|
||||
// }
|
||||
{ // DEBUG
|
||||
if(IsKeyPressed(KEY_P)) {
|
||||
printf("Shortcut to singleplayer.\n");
|
||||
game_session_init_default_settings(false, &ctx->session_settings);
|
||||
ctx->session_settings.max_players = 1;
|
||||
|
||||
if(game_instance_host_session(ctx->game_instance, ctx->session_settings)) {
|
||||
ctx->ingame_ctx->game_instance = ctx->game_instance;
|
||||
presentation_state_machine_go_to(&presentation_state_ingame);
|
||||
}
|
||||
else {
|
||||
printf("Failed to play.\n");
|
||||
}
|
||||
}
|
||||
else if(IsKeyPressed(KEY_L)) {
|
||||
printf("Shortcut to local multiplayer (2 players).\n");
|
||||
game_session_init_default_settings(false, &ctx->session_settings);
|
||||
ctx->session_settings.max_players = 2;
|
||||
|
||||
if(game_instance_host_session(ctx->game_instance, ctx->session_settings)) {
|
||||
ctx->ingame_ctx->game_instance = ctx->game_instance;
|
||||
presentation_state_machine_go_to(&presentation_state_ingame);
|
||||
}
|
||||
else {
|
||||
printf("Failed to play.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void state_render(Presentation_State *state) {
|
||||
@@ -80,6 +75,8 @@ static void state_render(Presentation_State *state) {
|
||||
case Main_Menu_Mode_Singleplayer: {
|
||||
ctx->mode = Main_Menu_Mode_Game_Setup;
|
||||
game_session_init_default_settings(false, &ctx->session_settings);
|
||||
ctx->ingame_ctx->game_instance = ctx->game_instance;
|
||||
presentation_state_machine_go_to(&presentation_state_ingame);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user