[Change] Secondary weapon greys out when you can't use it again.

This commit is contained in:
Allanis 2013-11-29 20:55:41 +00:00
parent 31f2a57fb3
commit 11bbd0854f
3 changed files with 18 additions and 4 deletions

View File

@ -64,7 +64,6 @@ static void pilot_calcCargo(Pilot* pilot);
void pilot_free(Pilot* p); void pilot_free(Pilot* p);
static Fleet* fleet_parse(const xmlNodePtr parent); static Fleet* fleet_parse(const xmlNodePtr parent);
static void pilot_dead(Pilot* p); static void pilot_dead(Pilot* p);
static int pilot_oquantity(Pilot* p, PilotOutfit* w);
/** /**
* @fn unsinged int pilot_getNextID(const unsigned int id) * @fn unsinged int pilot_getNextID(const unsigned int id)
@ -187,7 +186,7 @@ int pilot_getJumps(const Pilot* p) {
} }
/* Return quantity of a pilot outfit. */ /* Return quantity of a pilot outfit. */
static int pilot_oquantity(Pilot* p, PilotOutfit* w) { int pilot_oquantity(Pilot* p, PilotOutfit* w) {
return (outfit_isAmmo(w->outfit) && p->secondary) ? return (outfit_isAmmo(w->outfit) && p->secondary) ?
p->secondary->quantity : w->quantity; p->secondary->quantity : w->quantity;
} }

View File

@ -236,6 +236,7 @@ int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);
int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity); int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity);
char* pilot_getOutfits(Pilot* pilot); char* pilot_getOutfits(Pilot* pilot);
void pilot_calcStats(Pilot* pilot); void pilot_calcStats(Pilot* pilot);
int pilot_oquantity(Pilot* p, PilotOutfit* w);
/* Normal cargo. */ /* Normal cargo. */
int pilot_cargoUsed(Pilot* pilot); /* Get amount of cargo onboard. */ int pilot_cargoUsed(Pilot* pilot); /* Get amount of cargo onboard. */
int pilot_cargoFree(Pilot* p); /* Cargo space. */ int pilot_cargoFree(Pilot* p); /* Cargo space. */

View File

@ -838,6 +838,7 @@ void player_renderGUI(void) {
glFont* f; glFont* f;
StarSystem* sys; StarSystem* sys;
unsigned int t; unsigned int t;
int quantity, delay;
t = SDL_GetTicks(); t = SDL_GetTicks();
@ -962,6 +963,18 @@ void player_renderGUI(void) {
gui.weapon.y - 10 - gl_defFont.h, &cGrey, "None"); gui.weapon.y - 10 - gl_defFont.h, &cGrey, "None");
} else { } else {
f = &gl_defFont; f = &gl_defFont;
quantity = pilot_oquantity(player, player->secondary);
delay = outfit_delay(player->secondary->outfit);
/* Check to see if weapon is ready. */
if((player->secondary->timer > 0) &&
(SDL_GetTicks() - player->secondary->timer) < (unsigned int)(delay/quantity))
c = &cGrey;
else
c = &cConsole;
/* Launcher. */
if(outfit_isLauncher(player->secondary->outfit)) { if(outfit_isLauncher(player->secondary->outfit)) {
/* Use the ammunitions name. */ /* Use the ammunitions name. */
i = gl_printWidth(f, "%s", player->secondary->outfit->u.lau.ammo); i = gl_printWidth(f, "%s", player->secondary->outfit->u.lau.ammo);
@ -971,12 +984,13 @@ void player_renderGUI(void) {
gl_printMid(f, (int)gui.weapon.w, gui.weapon.x, gl_printMid(f, (int)gui.weapon.w, gui.weapon.x,
gui.weapon.y - 5, gui.weapon.y - 5,
&cConsole, "%s", player->secondary->outfit->u.lau.ammo); c, "%s", player->secondary->outfit->u.lau.ammo);
/* Print ammo underneath to the left. */ /* Print ammo underneath to the left. */
gl_printMid(&gl_smallFont, (int)gui.weapon.w, gui.weapon.x, gl_printMid(&gl_smallFont, (int)gui.weapon.w, gui.weapon.x,
gui.weapon.y - 10 - gl_defFont.h, gui.weapon.y - 10 - gl_defFont.h,
NULL, "%d", (player->ammo) ? player->ammo->quantity : 0); NULL, "%d", (player->ammo) ? player->ammo->quantity : 0);
/* Other. */
} else { } else {
/* Just print the item name. */ /* Just print the item name. */
i = gl_printWidth(f, "%s", player->secondary->outfit->name); i = gl_printWidth(f, "%s", player->secondary->outfit->name);
@ -985,7 +999,7 @@ void player_renderGUI(void) {
f = &gl_smallFont; f = &gl_smallFont;
gl_printMid(f, (int)gui.weapon.w, gl_printMid(f, (int)gui.weapon.w,
gui.weapon.x, gui.weapon.y - (gui.weapon.h - f->h)/2., gui.weapon.x, gui.weapon.y - (gui.weapon.h - f->h)/2.,
&cConsole, "%s", player->secondary->outfit->name); c, "%s", player->secondary->outfit->name);
} }
} }