[Change] Some minor tweaks.

This commit is contained in:
Allanis 2014-03-16 07:42:52 +00:00
parent 8f3cb968d3
commit 204978375c

View File

@ -13,14 +13,14 @@
#include "toolkit.h" #include "toolkit.h"
#include "options.h" #include "options.h"
#define KEYBINDS_WIDTH 400 /**< Options menu width. */ #define KEYBINDS_WIDTH 440 /**< Options menu width. */
#define KEYBINDS_HEIGHT 300 /**< Options menu height. */ #define KEYBINDS_HEIGHT 300 /**< Options menu height. */
#define BUTTON_WIDTH 90 /**< Button width, standard across menus. */ #define BUTTON_WIDTH 90 /**< Button width, standard across menus. */
#define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */ #define BUTTON_HEIGHT 30 /**< Button height, standard across menus. */
/* Extern. */ /* Extern. */
extern const char* keybindNames[]; extern const char* keybindNames[]; /* input.c */
static const char* modToText(SDLMod mod); static const char* modToText(SDLMod mod);
static void menuKeybinds_update(unsigned int wid, char* name); static void menuKeybinds_update(unsigned int wid, char* name);
@ -43,10 +43,10 @@ void opt_menuKeybinds(void) {
"btnClose", "Close", window_close); "btnClose", "Close", window_close);
/* Text stuff. */ /* Text stuff. */
window_addText(wid, 200, -40, KEYBINDS_WIDTH-220, 30, 1, "txtName", window_addText(wid, 240, -40, KEYBINDS_WIDTH-260, 30, 1, "txtName",
NULL, &cDConsole, NULL); NULL, &cDConsole, NULL);
window_addText(wid, 200, -90, window_addText(wid, 240, -90,
KEYBINDS_WIDTH-220, KEYBINDS_HEIGHT-70-60-BUTTON_HEIGHT, KEYBINDS_WIDTH-260, KEYBINDS_HEIGHT-70-60-BUTTON_HEIGHT,
0, "txtDesc", &gl_smallFont, NULL, NULL); 0, "txtDesc", &gl_smallFont, NULL, NULL);
/* Create the list. */ /* Create the list. */
@ -57,6 +57,7 @@ void opt_menuKeybinds(void) {
key = input_getKeybind(keybindNames[j], &type, &mod, &reverse); key = input_getKeybind(keybindNames[j], &type, &mod, &reverse);
switch(type) { switch(type) {
case KEYBIND_KEYBOARD: case KEYBIND_KEYBOARD:
/* SDL_GetKeyName returns lowercase which is ugly. */
if(isalpha(key)) if(isalpha(key))
snprintf(str[j], 64, "%s <%c>", keybindNames[j], toupper(key)); snprintf(str[j], 64, "%s <%c>", keybindNames[j], toupper(key));
else else
@ -73,7 +74,7 @@ void opt_menuKeybinds(void) {
break; break;
} }
} }
window_addList(wid, 20, -40, 160, KEYBINDS_HEIGHT-60, "lstKeybinds", window_addList(wid, 20, -40, 200, KEYBINDS_HEIGHT-60, "lstKeybinds",
str, i-1, 0, menuKeybinds_update); str, i-1, 0, menuKeybinds_update);
/* Update the list. */ /* Update the list. */
@ -82,6 +83,8 @@ void opt_menuKeybinds(void) {
/** /**
* @brief Gets the human readable version of mod. * @brief Gets the human readable version of mod.
* @brief mod Mod to get human readable version from.
* @return Human readable version of mod.
*/ */
static const char* modToText(SDLMod mod) { static const char* modToText(SDLMod mod) {
switch(mod) { switch(mod) {
@ -100,6 +103,8 @@ static const char* modToText(SDLMod mod) {
/** /**
* @brief Updates the keybindings menu. * @brief Updates the keybindings menu.
* @param wid Window to update.
* @param name Unused.
*/ */
static void menuKeybinds_update(unsigned int wid, char* name) { static void menuKeybinds_update(unsigned int wid, char* name) {
(void) name; (void) name;
@ -134,6 +139,7 @@ static void menuKeybinds_update(unsigned int wid, char* name) {
snprintf(bind, 64, "Not bound"); snprintf(bind, 64, "Not bound");
break; break;
case KEYBIND_KEYBOARD: case KEYBIND_KEYBOARD:
/* SDL_GetKeyName returns lowercase which is ugly. */
if(isalpha(key)) if(isalpha(key))
snprintf(bind, 32, "keyboard: %s%s%c", snprintf(bind, 32, "keyboard: %s%s%c",
(mod != KMOD_NONE) ? modToText(mod) : "", (mod != KMOD_NONE) ? modToText(mod) : "",
@ -152,6 +158,8 @@ static void menuKeybinds_update(unsigned int wid, char* name) {
snprintf(bind, 64, "joy button: <%d>", key); snprintf(bind, 64, "joy button: <%d>", key);
break; break;
} }
/* Update text. */
snprintf(buf, 1024, "%s\n\n%s\n", desc, bind); snprintf(buf, 1024, "%s\n\n%s\n", desc, bind);
window_modifyText(wid, "txtDesc", buf); window_modifyText(wid, "txtDesc", buf);
} }