From 91f851870cd3fa8de7898b696d3909ddd571f0a7 Mon Sep 17 00:00:00 2001 From: Allanis Date: Mon, 10 Mar 2014 00:42:46 +0000 Subject: [PATCH] [Add] Began adding first stages of options menu. [Change] Updated TODO. [Change] Made --help options a little more explicit. [Remove] Removed warning about differing Lephisto data between versions. --- TODO | 3 ++- src/conf.c | 6 +++--- src/lephisto.c | 6 ++++-- src/menu.c | 39 ++++++++++++++++++++++++++++++++++++--- src/menu.h | 2 ++ src/options.c | 25 +++++++++++++++++++++++++ src/options.h | 4 ++++ 7 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/options.c create mode 100644 src/options.h diff --git a/TODO b/TODO index b570e3b..14451cd 100644 --- a/TODO +++ b/TODO @@ -49,7 +49,8 @@ Minor: -- Objects always in sight (depending on resolution). -- Allow creating collision masks to make collision more realistic. -- Improve font system to handle unicode. - -- Possibly use Queso CGL + -- Mission improvements. + -- Allow creation of OSD (On Screen Displays). SOMEDAY!! MAYBE...: -- 3d models (not actually a 3D perspective, just no sprites). diff --git a/src/conf.c b/src/conf.c index c97727b..afb185c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -63,10 +63,10 @@ static void print_usage(char** argv); /* Print usage. */ static void print_usage(char** argv) { - LOG("USAGE: %s [OPTION]", argv[0]); + LOG("USAGE: %s [OPTIONS]", argv[0]); LOG("Options are:"); - LOG(" -f, --fullscreen - Fullscreen"); - LOG(" -F, --fps - Limit frames per second"); + LOG(" -f, --fullscreen - Activate fullscreen"); + LOG(" -F, --fps - Limit frames per second to n"); LOG(" -V, --vsync - Enable vsync"); LOG(" -d s, --data s - Set the data file to be s"); LOG(" -W n - Set width to n"); diff --git a/src/lephisto.c b/src/lephisto.c index 347ad1f..40a01d3 100644 --- a/src/lephisto.c +++ b/src/lephisto.c @@ -603,8 +603,10 @@ static void data_name(void) { buf = pack_readfile(DATA, VERSION_FILE, &bufsize); if(strncmp(buf, version, bufsize) != 0) { - WARN("Lephisto version and data module version differ!"); - WARN("Lephisto is v%s, data is for v%s", version, buf); + /* 0.3.4 release will use 0.3.3 ldata, we don't to warn. + DEBUG("Lephisto version and data module version differ!"); + DEBUG("Lephisto is v%s, data is for v%s", version, buf); + */ } free(buf); diff --git a/src/menu.c b/src/menu.c index 6c08428..cdd299f 100644 --- a/src/menu.c +++ b/src/menu.c @@ -43,6 +43,8 @@ #define DEATH_WIDTH 130 /**< Death menu width. */ #define DEATH_HEIGHT 150 /**< Death menu height. */ +#define OPTIONS_WIDTH 130 /**< Options menu width. */ +#define OPTIONS_HEIGHT 150 /**< Options menu height. */ #define BUTTON_WIDTH 90 /**< Button width, standard across menus. */ #define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */ @@ -75,6 +77,8 @@ static void mission_menu_genList(unsigned int wid, int first); static void mission_menu_update(unsigned int wid, char* str); /* Death menu. */ static void menu_death_main(unsigned int parent, char* str); +/* Options menu. */ +static void menu_options_close(unsigned int parent, char* str); /** * @fn void menu_main(void) @@ -108,7 +112,7 @@ void menu_main(void) { "btnNew", "New Game", menu_main_new); window_addButton(wid, 20, 20 + (BUTTON_HEIGHT+20), BUTTON_WIDTH, BUTTON_HEIGHT, - "btnOptions", "Options", NULL); + "btnOptions", "Options", (void(*)(unsigned int,char*))menu_options); window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit", menu_main_exit); @@ -205,7 +209,7 @@ void menu_small(void) { window_addButton(wid, 20, 20 + BUTTON_HEIGHT + 20, BUTTON_WIDTH, BUTTON_HEIGHT, - "btnOptions", "Options", NULL); + "btnOptions", "Options", (void(*)(unsigned int,char*))menu_options); window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnExit", "Exit", menu_small_exit); @@ -278,7 +282,7 @@ void menu_info(void) { unsigned int wid; /* Can't open menu twise. */ - if(menu_isOpen(MENU_INFO)) return; + if(menu_isOpen(MENU_INFO) || dialogue_isOpen()) return; wid = window_create("Info", -1, -1, INFO_WIDTH, INFO_HEIGHT); @@ -612,3 +616,32 @@ static void menu_death_main(unsigned int parent, char* str) { menu_main(); } +/** + * @brief Opens the options menu. + */ +void menu_options(void) { + unsigned int wid; + + wid = window_create("Options", -1, -1, OPTIONS_WIDTH, OPTIONS_HEIGHT); + window_addButton(wid, 20, 20, BUTTON_WIDTH, BUTTON_HEIGHT, + "btnClose", "Close", menu_options_close); + window_addButton(wid, 20, 20+(BUTTON_HEIGHT+20), + BUTTON_WIDTH, BUTTON_HEIGHT, + "btnKeybinds", "Keybindings", NULL); + menu_Open(MENU_OPTIONS); +} + +/** + * @brief Closes the options menu. + * @param str Unused. + */ +static void menu_options_close(unsigned int parent, char* str) { + (void)parent; + (void)str; + unsigned int wid; + + wid = window_get("Options"); + window_destroy(wid); + menu_Close(MENU_OPTIONS); +} + diff --git a/src/menu.h b/src/menu.h index 6e34cd7..768a519 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,6 +4,7 @@ #define MENU_SMALL (1<<1) /**< Small ingame menu. */ #define MENU_INFO (1<<2) /**< Player information menu. */ #define MENU_DEATH (1<<3) /**< Player death menu. */ +#define MENU_OPTIONS (1<<4) /**< Player's options menu. */ #define menu_isOpen(f) (menu_open & (f)) /**< Check if a certain menu is opened. */ extern int menu_open; @@ -12,4 +13,5 @@ void menu_main(void); void menu_small(void); void menu_info(void); void menu_death(void); +void menu_options(void); diff --git a/src/options.c b/src/options.c new file mode 100644 index 0000000..1b332a2 --- /dev/null +++ b/src/options.c @@ -0,0 +1,25 @@ +/** + * @file menu.h + * + * @brief Handle the important game menus. + */ + +#include +#include + +#include "log.h" +#include "lephisto.h" +#include "input.h" +#include "toolkit.h" +#include "options.h" + +#define KEYBIND_WIDTH 130 /**< Options menu width. */ +#define KEYBIND_HEIGHT 150 /**< Options menu height. */ + +#define BUTTON_WIDTH 90 /**< Button width, standard across menus. */ +#define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */ + +void opt_menuKeybinds(void) { + +} + diff --git a/src/options.h b/src/options.h new file mode 100644 index 0000000..7a06f46 --- /dev/null +++ b/src/options.h @@ -0,0 +1,4 @@ +#pragma once + +void opt_menuKeybinds(void); +