From 100c605d6bcf8fefd01c6c254179157e21c958c0 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 19 Feb 2013 23:23:15 +0000 Subject: [PATCH] [Add] Preleminary pause menu. --- src/input.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/input.c b/src/input.c index 16d899f..fcfb883 100644 --- a/src/input.c +++ b/src/input.c @@ -3,6 +3,7 @@ #include "player.h" #include "pause.h" #include "toolkit.h" +#include "menu.h" #include "input.h" #define KEY_PRESS ( 1.) @@ -24,7 +25,8 @@ const char* keybindNames[] = { "accel", "left", "right", "reverse", // Movement. "primary", "target", "target_nearest", "face", "board", // Combat. "secondary", "secondary_next", // Secondary weapons. "target_planet", "land", // Navigation. - "mapzoomin", "mapzoomout", "screenshot", "pause", "end" }; // Misc. + "mapzoomin", "mapzoomout", "screenshot", "pause", "menu", // Misc. + "end" }; // Must terminate at the end. // From player.c extern double player_turn; extern double player_acc; @@ -59,6 +61,8 @@ void input_setDefault(void) { input_setKeybind("mapzoomout", KEYBIND_KEYBOARD, SDLK_DOWN, 0); input_setKeybind("screenshot", KEYBIND_KEYBOARD, SDLK_F12, 0); input_setKeybind("pause", KEYBIND_KEYBOARD, SDLK_F1, 0); + input_setKeybind("menu", KEYBIND_KEYBOARD, SDLK_ESCAPE, 0); + } // Initialization/exit functions (does not assign keys). @@ -218,6 +222,11 @@ static void input_key(int keynum, double value, int abs) { } else pause(); } } + // Opens a menu. + else if(KEY("menu")) { + if(value == KEY_PRESS) + menu_small(); + } } // --Events-- @@ -270,13 +279,6 @@ static void input_keydown(SDLKey key) { input_key(i, KEY_PRESS, 0); return; } - - // Fire Escape. - SDL_Event quit; - if(key == SDLK_ESCAPE) { - quit.type = SDL_QUIT; - SDL_PushEvent(&quit); - } } // Key up.