From 1ae475fcdf97276526011b9a8c12a5b302ea5d05 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 21 Mar 2013 23:02:40 +0000 Subject: [PATCH] [Add] Show free cargo space in commodity window. --- src/land.c | 24 +++++++++++++++--------- src/pilot.h | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/land.c b/src/land.c index 12efd47..860af8d 100644 --- a/src/land.c +++ b/src/land.c @@ -89,15 +89,17 @@ static void commodity_exchange(void) { (BUTTON_WIDTH-20)/2, BUTTON_HEIGHT, "btnCommoditySell", "Sell", commodity_sell); - window_addText(secondary_wid, -20, -40, BUTTON_WIDTH, 20, 0, + window_addText(secondary_wid, -20, -40, BUTTON_WIDTH, 60, 0, "txtSInfo", &gl_smallFont, &cDConsole, "You have:\n" - "Market price:\n"); + "Market price:\n" + "\n" + "Free Space:\n"); - window_addText(secondary_wid, -20, -40, BUTTON_WIDTH/2, 20, 0, + window_addText(secondary_wid, -20, -40, BUTTON_WIDTH/2, 60, 0, "txtDInfo", &gl_smallFont, &cBlack, NULL); - window_addText(secondary_wid, -40, -80, BUTTON_WIDTH-20, + window_addText(secondary_wid, -40, -100, BUTTON_WIDTH-20, BUTTON_WIDTH, 0, "txtDesc", &gl_smallFont, &cBlack, NULL); goods = malloc(sizeof(char*)*planet->ncommodities); @@ -126,10 +128,13 @@ static void commodity_update(char* str) { com = commodity_get(comname); snprintf(buf, 128, - "%d\n" - "%d Screds/ton\n", - player_cargoOwned(comname), - com->medium); + "%d tons\n" + "%d Scred\n" + "\n" + "%d tons\n", + player_cargoOwned(comname), + com->medium, + player->cargo_free); window_modifyText(secondary_wid, "txtDInfo", buf); window_modifyText(secondary_wid, "txtDesc", com->description); @@ -201,7 +206,8 @@ static void outfits(void) { window_addImage(secondary_wid, -20-128, -50-128, "imgOutfit", NULL); window_addCust(secondary_wid, -40-BUTTON_WIDTH, 60+2*BUTTON_HEIGHT, - BUTTON_WIDTH, BUTTON_HEIGHT, "cstMod", 0, outfits_renderMod, NULL); + BUTTON_WIDTH, BUTTON_HEIGHT, + "cstMod", 0, outfits_renderMod, NULL); window_addText(secondary_wid, 40+200+20, -60, 80, 96, 0, "txtSDesc", &gl_smallFont, &cDConsole, diff --git a/src/pilot.h b/src/pilot.h index 048c692..7d69d27 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -12,9 +12,9 @@ #define HYPERSPACE_ENGINE_DELAY 3000 // Warm up the engines. #define HYPERSPACE_FLY_DELAY 5000 // Time taken to hyperspace. -#define HYPERSPACE_STARS_BLUR 2000 // Time stars blur. -#define HYPERSPACE_STARS_LENGTH 1000 // Length the stars blur to at max. -#define HYPERSPACE_FADEOUT 1000 // Time fadeout. +#define HYPERSPACE_STARS_BLUR 2000 // Time stars blur. +#define HYPERSPACE_STARS_LENGTH 1000 // Length the stars blur to at max. +#define HYPERSPACE_FADEOUT 1000 // Time fadeout. // Aproximation for pilot size. #define PILOT_SIZE_APROX 0.8 @@ -30,11 +30,11 @@ // Dynamic. #define PILOT_HOSTILE (1<<1) // Pilot is hostile to the player. #define PILOT_COMBAT (1<<2) // Pilot is engaged in combat. -#define PILOT_AFTERBURNER (1<<3) // Pilot has her afterburner activated. +#define PILOT_AFTERBURNER (1<<3) // Pilot has her afterburner activated. #define PILOT_HYP_PREP (1<<5) // Pilot is getting ready for hyperspace. #define PILOT_HYP_BEGIN (1<<6) // Pilot is starting engines. #define PILOT_HYPERSPACE (1<<7) // Pilot is in hyperspace. -#define PILOT_BOARDED (1<<8) // Pilot has been boarded already! +#define PILOT_BOARDED (1<<8) // Pilot has been boarded already! #define PILOT_DISABLED (1<<9) // Pilot is disabled. #define PILOT_DEAD (1<<10) // Pilot is on it's death bed. #define PILOT_EXPLODED (1<<11) // Pilot did final death explosion. @@ -57,15 +57,15 @@ typedef struct PilotCommodity_ { // Primary pilot structure. typedef struct Pilot_ { - unsigned int id; // Pilots id. - char* name; // Pilot's name (if unique). + unsigned int id; // Pilots id. + char* name; // Pilot's name (if unique). Faction* faction; // Object characteristics. Ship* ship; // Pilots ship. Solid* solid; // Associated solid (physics). - int tsx, tsy; // Current sprite, calculated on update. + int tsx, tsy; // Current sprite, calculated on update. double thrust, turn, speed; @@ -82,8 +82,8 @@ typedef struct Pilot_ { // Outfit management. PilotOutfit* outfits; int noutfits; - PilotOutfit* secondary; // Secondary weapon. - PilotOutfit* ammo; // Secondary ammo (if needed). + PilotOutfit* secondary; // Secondary weapon. + PilotOutfit* ammo; // Secondary ammo (if needed). PilotOutfit* afterburner; // Ze afterburner. // Cargo.