[Add] You can jettison cargo now. :)
This commit is contained in:
parent
8cac584d45
commit
a0f6dec666
54
src/menu.c
54
src/menu.c
@ -255,8 +255,11 @@ static void info_outfits_menu(char* str) {
|
|||||||
(void) str;
|
(void) str;
|
||||||
char* buf;
|
char* buf;
|
||||||
unsigned int wid;
|
unsigned int wid;
|
||||||
|
|
||||||
|
/* Create the window. */
|
||||||
wid = window_create("Outfits", -1, -1, OUTFITS_WIDTH, OUTFITS_HEIGHT);
|
wid = window_create("Outfits", -1, -1, OUTFITS_WIDTH, OUTFITS_HEIGHT);
|
||||||
|
|
||||||
|
/* Text. */
|
||||||
window_addText(wid, 20, -40, 100, OUTFITS_HEIGHT-40,
|
window_addText(wid, 20, -40, 100, OUTFITS_HEIGHT-40,
|
||||||
0, "txtLabel", &gl_smallFont, &cDConsole,
|
0, "txtLabel", &gl_smallFont, &cDConsole,
|
||||||
"Ship Outfits:");
|
"Ship Outfits:");
|
||||||
@ -268,6 +271,7 @@ static void info_outfits_menu(char* str) {
|
|||||||
0, "txtOutfits", &gl_smallFont, &cBlack, buf);
|
0, "txtOutfits", &gl_smallFont, &cBlack, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
/* Buttons. */
|
||||||
window_addButton(wid, -20, 20,
|
window_addButton(wid, -20, 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT,
|
BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||||
"closeOutfits", "Close", menu_generic_close);
|
"closeOutfits", "Close", menu_generic_close);
|
||||||
@ -277,6 +281,9 @@ static void info_outfits_menu(char* str) {
|
|||||||
static void info_cargo_menu(char* str) {
|
static void info_cargo_menu(char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
unsigned int wid;
|
unsigned int wid;
|
||||||
|
char** buf;
|
||||||
|
int nbuf;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Create the window. */
|
/* Create the window. */
|
||||||
wid = window_create("Cargo", -1, -1, CARGO_WIDTH, CARGO_HEIGHT);
|
wid = window_create("Cargo", -1, -1, CARGO_WIDTH, CARGO_HEIGHT);
|
||||||
@ -287,6 +294,30 @@ static void info_cargo_menu(char* str) {
|
|||||||
window_addButton(wid, -40 - BUTTON_WIDTH, 20,
|
window_addButton(wid, -40 - BUTTON_WIDTH, 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", "Jettison",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnJettisonCargo", "Jettison",
|
||||||
cargo_jettison);
|
cargo_jettison);
|
||||||
|
window_disableButton(wid, "btnJettisonCargo");
|
||||||
|
|
||||||
|
/* List. */
|
||||||
|
if(player->ncommodities == 0) {
|
||||||
|
/* No cargo. */
|
||||||
|
buf = malloc(sizeof(char*));
|
||||||
|
buf[0] = strdup("None");
|
||||||
|
nbuf = 1;
|
||||||
|
} else {
|
||||||
|
/* List the players cargo. */
|
||||||
|
buf = malloc(sizeof(char*)*player->ncommodities);
|
||||||
|
for(i = 0; i < player->ncommodities; i++) {
|
||||||
|
buf[i] = malloc(sizeof(char)*128);
|
||||||
|
snprintf(buf[i], 128, "%s%s %d",
|
||||||
|
player->commodities[i].commodity->name,
|
||||||
|
(player->commodities[i].id != 0) ? "*" : "",
|
||||||
|
player->commodities[i].quantity);
|
||||||
|
}
|
||||||
|
nbuf = player->ncommodities;
|
||||||
|
}
|
||||||
|
|
||||||
|
window_addList(wid, 20, -40,
|
||||||
|
CARGO_WIDTH - 40, CARGO_HEIGHT - BUTTON_HEIGHT - 80,
|
||||||
|
"lstCargo", buf, nbuf, 0, cargo_update);
|
||||||
|
|
||||||
cargo_update(NULL);
|
cargo_update(NULL);
|
||||||
}
|
}
|
||||||
@ -294,14 +325,37 @@ static void info_cargo_menu(char* str) {
|
|||||||
static void cargo_update(char* str) {
|
static void cargo_update(char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
unsigned int wid;
|
unsigned int wid;
|
||||||
|
int pos;
|
||||||
|
|
||||||
|
if(player->ncommodities == 0) return; /* No cargo. */
|
||||||
|
|
||||||
wid = window_get("Cargo");
|
wid = window_get("Cargo");
|
||||||
|
pos = toolkit_getListPos(wid, "lstCargo");
|
||||||
|
|
||||||
|
/* Can jettison all but mission cargo when not landed. */
|
||||||
|
if(landed || (player->commodities[pos].id != 0))
|
||||||
window_disableButton(wid, "btnJettisonCargo");
|
window_disableButton(wid, "btnJettisonCargo");
|
||||||
|
else
|
||||||
|
window_enableButton(wid, "btnJettisonCargo");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cargo_jettison(char* str) {
|
static void cargo_jettison(char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
|
unsigned int wid;
|
||||||
|
int pos;
|
||||||
|
|
||||||
|
if(player->ncommodities == 0) return; /* No cargo, redundant check. */
|
||||||
|
|
||||||
|
wid = window_get("Cargo");
|
||||||
|
pos = toolkit_getListPos(wid, "lstCargo");
|
||||||
|
|
||||||
|
/* Remove the cargo. */
|
||||||
|
pilot_rmCargo(player, player->commodities[pos].commodity,
|
||||||
|
player->commodities[pos].quantity);
|
||||||
|
|
||||||
|
/* We reopen the menu to recreate the list now. */
|
||||||
|
menu_generic_close("closeCargo");
|
||||||
|
info_cargo_menu(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Show the player's active missions. */
|
/* Show the player's active missions. */
|
||||||
|
Loading…
Reference in New Issue
Block a user