(#1193) Use 'menu' console command instead of 'Esc' key
parent
1688c4bbcd
commit
8e7916334c
20
src/game.c
20
src/game.c
|
@ -19,14 +19,6 @@
|
|||
#include "game/settings.h"
|
||||
#include "game/credits.h"
|
||||
|
||||
typedef enum Game_state {
|
||||
GAME_STATE_LEVEL = 0,
|
||||
GAME_STATE_LEVEL_PICKER,
|
||||
GAME_STATE_LEVEL_EDITOR,
|
||||
GAME_STATE_CREDITS,
|
||||
GAME_STATE_SETTINGS,
|
||||
GAME_STATE_QUIT
|
||||
} Game_state;
|
||||
|
||||
typedef struct Game {
|
||||
Lt *lt;
|
||||
|
@ -46,7 +38,6 @@ typedef struct Game {
|
|||
int console_enabled;
|
||||
} Game;
|
||||
|
||||
static
|
||||
void game_switch_state(Game *game, Game_state state)
|
||||
{
|
||||
game->camera = create_camera(game->renderer, game->font);
|
||||
|
@ -368,7 +359,6 @@ static int game_event_level_picker(Game *game, const SDL_Event *event)
|
|||
return -1;
|
||||
}
|
||||
|
||||
level_picker_clean_selection(game->level_picker);
|
||||
game_switch_state(game, GAME_STATE_LEVEL);
|
||||
} break;
|
||||
|
||||
|
@ -462,15 +452,6 @@ int game_event(Game *game, const SDL_Event *event)
|
|||
} break;
|
||||
}
|
||||
} break;
|
||||
case SDL_KEYDOWN: {
|
||||
switch (event->key.keysym.sym) {
|
||||
case SDLK_ESCAPE: {
|
||||
if (game->state == GAME_STATE_LEVEL) {
|
||||
game_switch_state(game, GAME_STATE_LEVEL_PICKER);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,7 +575,6 @@ int game_load_level(Game *game, const char *level_filename)
|
|||
return -1;
|
||||
}
|
||||
|
||||
level_picker_clean_selection(game->level_picker);
|
||||
game_switch_state(game, GAME_STATE_LEVEL);
|
||||
|
||||
return 0;
|
||||
|
|
10
src/game.h
10
src/game.h
|
@ -24,6 +24,16 @@ int game_input(Game *game,
|
|||
|
||||
int game_over_check(const Game *game);
|
||||
|
||||
typedef enum Game_state {
|
||||
GAME_STATE_LEVEL = 0,
|
||||
GAME_STATE_LEVEL_PICKER,
|
||||
GAME_STATE_LEVEL_EDITOR,
|
||||
GAME_STATE_CREDITS,
|
||||
GAME_STATE_SETTINGS,
|
||||
GAME_STATE_QUIT
|
||||
} Game_state;
|
||||
|
||||
void game_switch_state(Game *game, Game_state state);
|
||||
int game_load_level(Game *game, const char *filepath);
|
||||
|
||||
// defined in main.c. is there a better place for this to be declared?
|
||||
|
|
|
@ -170,6 +170,10 @@ static int console_eval_input(Console *console)
|
|||
if (game_load_level(console->game, level_name) < 0) {
|
||||
console_log_push_line(console->console_log, "Could not load level", NULL, CONSOLE_ERROR);
|
||||
}
|
||||
} else if (token_equals_str(command, "menu")) {
|
||||
console_log_push_line(console->console_log, "Loading menu", NULL, CONSOLE_FOREGROUND);
|
||||
level_picker_clean_selection(console->game->level_picker);
|
||||
game_switch_state(console->game, GAME_STATE_LEVEL_PICKER);
|
||||
} else {
|
||||
console_log_push_line(console->console_log, "Unknown command", NULL, CONSOLE_ERROR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue