Stats bug fixes.
This commit is contained in:
parent
c3785bcfce
commit
01ec3ceb7b
|
@ -62,10 +62,11 @@ static Widget *next;
|
|||
void initStatsDisplay(void)
|
||||
{
|
||||
page = 0;
|
||||
maxPages = (STAT_MAX / MAX_STAT_ITEMS);
|
||||
maxPages = ceil(STAT_TIME / MAX_STAT_ITEMS);
|
||||
|
||||
prev = getWidget("prev", "stats");
|
||||
prev->action = prevPage;
|
||||
prev->visible = 0;
|
||||
|
||||
next = getWidget("next", "stats");
|
||||
next->action = nextPage;
|
||||
|
@ -94,7 +95,7 @@ void drawStats(void)
|
|||
|
||||
drawText(SCREEN_WIDTH / 2, 70, 28, TA_CENTER, colors.white, "Stats");
|
||||
|
||||
drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, maxPages + 1);
|
||||
drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, maxPages);
|
||||
|
||||
y = 170;
|
||||
|
||||
|
@ -125,10 +126,16 @@ void drawStats(void)
|
|||
|
||||
static void nextPage(void)
|
||||
{
|
||||
page = MIN(page + 1, maxPages);
|
||||
page = MIN(page + 1, maxPages - 1);
|
||||
|
||||
next->visible = page < maxPages - 1;
|
||||
prev->visible = 1;
|
||||
}
|
||||
|
||||
static void prevPage(void)
|
||||
{
|
||||
page = MAX(0, page - 1);
|
||||
|
||||
next->visible = 1;
|
||||
prev->visible = page > 0;
|
||||
}
|
||||
|
|
|
@ -100,9 +100,15 @@ static void loadChallenges(Mission *mission, cJSON *challengesCJSON)
|
|||
static void loadStats(cJSON *stats)
|
||||
{
|
||||
int i;
|
||||
char *statName;
|
||||
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
{
|
||||
game.stats[i] = cJSON_GetObjectItem(stats, getLookupName("STAT_", i))->valueint;
|
||||
statName = getLookupName("STAT_", i);
|
||||
|
||||
if (statName && cJSON_GetObjectItem(stats, statName))
|
||||
{
|
||||
game.stats[i] = cJSON_GetObjectItem(stats, statName)->valueint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,8 @@ void initLookups(void)
|
|||
addLookup("STAT_MISSIONS_COMPLETED", STAT_MISSIONS_COMPLETED);
|
||||
addLookup("STAT_SHOTS_FIRED", STAT_SHOTS_FIRED);
|
||||
addLookup("STAT_SHOTS_HIT", STAT_SHOTS_HIT);
|
||||
addLookup("STAT_ROCKETS_FIRED", STAT_ROCKETS_FIRED);
|
||||
addLookup("STAT_ROCKETS_HIT", STAT_ROCKETS_HIT);
|
||||
addLookup("STAT_MISSILES_FIRED", STAT_MISSILES_FIRED);
|
||||
addLookup("STAT_MISSILES_HIT", STAT_MISSILES_HIT);
|
||||
addLookup("STAT_ENEMIES_KILLED", STAT_ENEMIES_KILLED);
|
||||
|
|
Loading…
Reference in New Issue