[Add] Licences are viewable through outfits menu.

This commit is contained in:
Allanis 2014-04-09 21:33:30 +01:00
parent d11385b452
commit 8a183c2e22
3 changed files with 50 additions and 1 deletions

View File

@ -36,6 +36,9 @@
#define OUTFITS_WIDTH 400 /**< Outfit menu width. */ #define OUTFITS_WIDTH 400 /**< Outfit menu width. */
#define OUTFITS_HEIGHT 200 /**< Outfit menu height. */ #define OUTFITS_HEIGHT 200 /**< Outfit menu height. */
#define LICENSES_WIDTH 300 /**< Licenses menu width. */
#define LICENSES_HEIGHT 300 /**< Licenses menu height. */
#define CARGO_WIDTH 300 /**< Cargo menu width. */ #define CARGO_WIDTH 300 /**< Cargo menu width. */
#define CARGO_HEIGHT 300 /**< Cargo menu height. */ #define CARGO_HEIGHT 300 /**< Cargo menu height. */
@ -45,7 +48,7 @@
#define DEATH_WIDTH 130 /**< Death menu width. */ #define DEATH_WIDTH 130 /**< Death menu width. */
#define DEATH_HEIGHT 150 /**< Death menu height. */ #define DEATH_HEIGHT 150 /**< Death menu height. */
#define OPTIONS_WIDTH 260 /**< Options menu width. */ #define OPTIONS_WIDTH 360 /**< Options menu width. */
#define OPTIONS_HEIGHT 90 /**< Options menu height. */ #define OPTIONS_HEIGHT 90 /**< Options menu height. */
#define BUTTON_WIDTH 90 /**< Button width, standard across menus. */ #define BUTTON_WIDTH 90 /**< Button width, standard across menus. */
@ -68,6 +71,8 @@ static void exit_game(void);
static void menu_info_close(unsigned int wid, char* str); static void menu_info_close(unsigned int wid, char* str);
/* Outfits submenu. */ /* Outfits submenu. */
static void info_outfits_menu(unsigned int parent, char* str); static void info_outfits_menu(unsigned int parent, char* str);
/* Licences submenu. */
static void info_licenses_menu(unsigned int parent, char* str);
/* Cargo submenu. */ /* Cargo submenu. */
static void info_cargo_menu(unsigned int parent, char* str); static void info_cargo_menu(unsigned int parent, char* str);
static void cargo_update(unsigned int wid, char* str); static void cargo_update(unsigned int wid, char* str);
@ -381,6 +386,39 @@ static void info_outfits_menu(unsigned int parent, char* str) {
window_addButton(wid, -20, 20, window_addButton(wid, -20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, BUTTON_WIDTH, BUTTON_HEIGHT,
"closeOutfits", "Close", window_close); "closeOutfits", "Close", window_close);
window_addButton(wid, -20-BUTTON_WIDTH-20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT,
"btnLicenses", "Licenses", info_licenses_menu);
}
/**
* @brief Open the licences menu.
*/
static void info_licenses_menu(unsigned int parent, char* str) {
(void)str;
(void)parent;
unsigned int wid;
char** licenses;
int nlicenses;
int i;
char** buf;
/* Create window. */
wid = window_create("Licenses", -1, -1, LICENSES_WIDTH, LICENSES_HEIGHT);
/* List. */
buf = player_getLicenses(&nlicenses);
licenses = malloc(sizeof(char*)*nlicenses);
for(i = 0; i < nlicenses; i++)
licenses[i] = strdup(buf[i]);
window_addList(wid, 20, -40, LICENSES_WIDTH-40, LICENSES_HEIGHT-80-BUTTON_HEIGHT,
"lstLicenses", licenses, nlicenses, 0, NULL);
/* Buttons. */
window_addButton(wid, -20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT,
"closeLicenses", "Close", window_close);
} }
/** /**

View File

@ -2362,6 +2362,16 @@ void player_addLicense(char* license) {
player_licenses[player_nlicenses-1] = strdup(license); player_licenses[player_nlicenses-1] = strdup(license);
} }
/**
* @brief Get the players licenses.
* @param nlicenses Amount of licenses the player has.
* @return Name of the licenses she has.
*/
char** player_getLicenses(int* nlicenses) {
*nlicenses = player_nlicenses;
return player_licenses;
}
/* Save the player in a freaking xmlfile. */ /* Save the player in a freaking xmlfile. */
int player_save(xmlTextWriterPtr writer) { int player_save(xmlTextWriterPtr writer) {
int i; int i;

View File

@ -74,6 +74,7 @@ int player_missionAlreadyDone(int id);
/* Licenses. */ /* Licenses. */
void player_addLicense(char* license); void player_addLicense(char* license);
int player_hasLicense(char* license); int player_hasLicense(char* license);
char** player_getLicenses(int* nlicenses);
/* Keybind actions. */ /* Keybind actions. */
void player_targetHostile(void); void player_targetHostile(void);