From 452c77f30c2dbe6d6d08e45eb2bf6b3ed75e69c3 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 28 Feb 2013 19:29:47 +0000 Subject: [PATCH] [Add] Outfit information window. --- src/menu.c | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/menu.c b/src/menu.c index 3c4db9b..1b3e3cb 100644 --- a/src/menu.c +++ b/src/menu.c @@ -10,14 +10,17 @@ #include "player.h" #include "menu.h" -#define MENU_WIDTH 120 -#define MENU_HEIGHT 200 +#define MENU_WIDTH 120 +#define MENU_HEIGHT 200 -#define INFO_WIDTH 320 -#define INFO_HEIGHT 280 +#define INFO_WIDTH 320 +#define INFO_HEIGHT 280 -#define BUTTON_WIDTH 80 -#define BUTTON_HEIGHT 30 +#define OUTFITS_WIDTH 400 +#define OUTFITS_HEIGHT 200 + +#define BUTTON_WIDTH 80 +#define BUTTON_HEIGHT 30 #define MENU_SMALL (1<<0) #define MENU_INFO (1<<1) @@ -31,6 +34,8 @@ static void menu_small_close(char* str); static void edit_options(void); static void exit_game(void); static void info_menu_close(char* str); +static void info_outfits_menu(char* str); +static void info_outfits_menu_close(char* str); // Ze ingame menu. // Small ingame menu. @@ -106,7 +111,7 @@ void info_menu(void) { player->ship->name, "Ship", ship_view); window_addButton(wid, -20, (20 + BUTTON_HEIGHT)*3 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, - "btnOutfits", "Outfits", NULL); + "btnOutfits", "Outfits", info_outfits_menu); window_addButton(wid, -20, (20 + BUTTON_HEIGHT)*2 + 20, BUTTON_WIDTH, BUTTON_HEIGHT, "btnCargo", "Cargo", NULL); @@ -129,3 +134,34 @@ static void info_menu_close(char* str) { unpause(); } +static void info_outfits_menu(char* str) { + (void) str; + int i; + char buf[1024], buf2[64]; + unsigned int wid; + wid = window_create("Outfits", -1, -1, OUTFITS_WIDTH, OUTFITS_HEIGHT); + + window_addText(wid, 20, 0, 100, OUTFITS_HEIGHT-40, + 0, "txtLabel", &gl_smallFont, &cDConsole, + "Ship Outfits:"); + + buf[0] = '\0'; + if(player->noutfits > 0) + snprintf(buf, 1024, "%dx %s", + player->outfits[0].quantity, player->outfits[0].outfit->name); + + for(i = 1; i < player->noutfits; i++) { + snprintf(buf2, 64, ", %dx %s", + player->outfits[i].quantity, player->outfits[i].outfit->name); + strcat(buf, buf2); + } + + window_addButton(wid, -20, 20, + BUTTON_WIDTH, BUTTON_HEIGHT, + "closeOutfits", "Close", info_outfits_menu_close); +} + +static void info_outfits_menu_close(char* str) { + window_destroy(window_get(str+5)); // closeFoo -> Foo. +} +