[Add] Hellz yeah!! You can refuel when low now.
This commit is contained in:
parent
11aa5bf2c9
commit
6ec1a2a407
36
src/land.c
36
src/land.c
@ -107,6 +107,9 @@ static void misn_close(char* str);
|
|||||||
static void misn_accept(char* str);
|
static void misn_accept(char* str);
|
||||||
static void misn_genList(int first);
|
static void misn_genList(int first);
|
||||||
static void misn_update(char* str);
|
static void misn_update(char* str);
|
||||||
|
// Refuel.
|
||||||
|
static int refuel_price(void);
|
||||||
|
static void spaceport_refuel(char* str);
|
||||||
|
|
||||||
// The local market.
|
// The local market.
|
||||||
static void commodity_exchange(void) {
|
static void commodity_exchange(void) {
|
||||||
@ -923,8 +926,30 @@ static void misn_update(char* str) {
|
|||||||
window_enableButton(secondary_wid, "btnAcceptMission");
|
window_enableButton(secondary_wid, "btnAcceptMission");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return how much it will cost to refuel the player.
|
||||||
|
static int refuel_price(void) {
|
||||||
|
return (player->fuel_max - player->fuel)*3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refuel the player.
|
||||||
|
static void spaceport_refuel(char* str) {
|
||||||
|
(void)str;
|
||||||
|
|
||||||
|
if(player->credits < refuel_price()) {
|
||||||
|
dialogue_alert("Need more Scred",
|
||||||
|
"You seem to not have enough Scred to refuel your ship");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->credits -= refuel_price();
|
||||||
|
player->fuel = player->fuel_max;
|
||||||
|
window_destroyWidget(land_wid, "btnRefuel");
|
||||||
|
}
|
||||||
|
|
||||||
// Land the player.
|
// Land the player.
|
||||||
void land(Planet* p) {
|
void land(Planet* p) {
|
||||||
|
char buf[32], cred[16];
|
||||||
|
|
||||||
if(landed) return;
|
if(landed) return;
|
||||||
|
|
||||||
// Change music.
|
// Change music.
|
||||||
@ -957,6 +982,7 @@ void land(Planet* p) {
|
|||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits",
|
||||||
"Outfits", (void(*)(char*))outfits);
|
"Outfits", (void(*)(char*))outfits);
|
||||||
|
|
||||||
|
// Third column.
|
||||||
if(planet_hasService(land_planet, PLANET_SERVICE_BASIC)) {
|
if(planet_hasService(land_planet, PLANET_SERVICE_BASIC)) {
|
||||||
window_addButton(land_wid, 20, 20,
|
window_addButton(land_wid, 20, 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
|
||||||
@ -965,6 +991,16 @@ void land(Planet* p) {
|
|||||||
window_addButton(land_wid, 20, 20 + BUTTON_HEIGHT + 20,
|
window_addButton(land_wid, 20, 20 + BUTTON_HEIGHT + 20,
|
||||||
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar",
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar",
|
||||||
"Spaceport Bar", (void(*)(char*))spaceport_bar);
|
"Spaceport Bar", (void(*)(char*))spaceport_bar);
|
||||||
|
|
||||||
|
if(player->fuel < player->fuel_max) {
|
||||||
|
credits2str(cred, refuel_price(), 2);
|
||||||
|
snprintf(buf, 32, "Refuel %s", cred);
|
||||||
|
window_addButton(land_wid, -20, 20+2*(BUTTON_HEIGHT+20),
|
||||||
|
BUTTON_WIDTH, BUTTON_HEIGHT, "btnRefuel",
|
||||||
|
buf, spaceport_refuel);
|
||||||
|
if(player->credits < refuel_price()) // Not enough memory.
|
||||||
|
window_disableButton(land_wid, "btnRefuel");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,6 +581,7 @@ void window_destroyWidget(unsigned int wid, const char* wgtname) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(w->focus == i) w->focus = -1;
|
||||||
widget_cleanup(&w->widgets[i]);
|
widget_cleanup(&w->widgets[i]);
|
||||||
if(i < w->nwidgets-1)
|
if(i < w->nwidgets-1)
|
||||||
// This isn't the last widget.
|
// This isn't the last widget.
|
||||||
|
Loading…
Reference in New Issue
Block a user