Show number of fighters destroyed.

This commit is contained in:
Steve 2017-08-12 07:42:58 +01:00
parent ba11fe1e81
commit f49c77f193
2 changed files with 30 additions and 0 deletions

View File

@ -23,9 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void prevFighter(void);
static void nextFighter(void);
static int countFighterGuns(Entity *fighter, int type);
static void setNumDestroyed(void);
static int page;
static int maxPages;
static int numDestroyed;
static Widget *prev;
static Widget *next;
static char *DB_TEXT;
@ -66,6 +68,8 @@ void initFighterDatabaseDisplay(void)
next = getWidget("next", "fighterDB");
next->action = nextFighter;
setNumDestroyed();
}
void doFighterDatabase(void)
@ -104,6 +108,8 @@ void drawFighterDatabase(void)
blitRotated(fighter->texture, r.x + (r.w / 2), 250, rotation);
drawText(r.x + (r.w / 2), 290, 18, TA_CENTER, colors.lightGrey, "Destroyed: %d", numDestroyed);
drawText(r.x + 25, 200, 22, TA_LEFT, colors.white, "Affiliation: %s", fighter->affiliation);
drawText(r.x + 25, 240, 22, TA_LEFT, colors.white, "Armour: %d", fighter->health);
drawText(r.x + 25, 280, 22, TA_LEFT, colors.white, "Shield: %d", fighter->shield);
@ -156,9 +162,32 @@ static int countFighterGuns(Entity *fighter, int type)
static void prevFighter(void)
{
page = mod(page - 1, maxPages);
setNumDestroyed();
}
static void nextFighter(void)
{
page = mod(page + 1, maxPages);
setNumDestroyed();
}
static void setNumDestroyed(void)
{
Tuple *t;
Entity *fighter;
fighter = dbFighters[page];
numDestroyed = 0;
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
{
if (strcmp(t->key, fighter->name) == 0)
{
numDestroyed = t->value;
return;
}
}
}

View File

@ -31,3 +31,4 @@ extern void limitTextWidth(int width);
extern App app;
extern Colors colors;
extern Game game;