Show additional stats.

This commit is contained in:
Steve 2018-03-02 08:09:04 +00:00
parent eb6e653837
commit 0a5d2d8cfb
10 changed files with 44 additions and 14 deletions

View File

@ -339,6 +339,7 @@ enum
enum
{
STAT_MISSIONS_COMPLETE,
STAT_KEYS_FOUND,
STAT_CELLS_FOUND,
STAT_HEARTS_FOUND,
@ -347,6 +348,7 @@ enum
STAT_DEATHS,
STAT_SHOTS_FIRED,
STAT_SHOTS_HIT,
STAT_SHOT_ACCURACY,
STAT_EYE_DROID_EXPLOSION_KILLS,
STAT_FLY_TIME,
STAT_SWIM_TIME,
@ -355,6 +357,7 @@ enum
STAT_WEAPONS_PICKED_UP,
STAT_ENEMIES_KILLED,
STAT_MISSIONS_PLAYED,
STAT_PERCENT_COMPLETE,
STAT_TIME_PLAYED,
STAT_MAX
};

View File

@ -35,6 +35,7 @@ void initStats(void)
maxPages /= STATS_PER_PAGE;
maxPages = ceil(maxPages);
statDescription[STAT_MISSIONS_COMPLETE] = _("Missions complete");
statDescription[STAT_KEYS_FOUND] = _("Keys found");
statDescription[STAT_CELLS_FOUND] = _("Power cells found");
statDescription[STAT_HEARTS_FOUND] = _("Hearts found");
@ -43,7 +44,8 @@ void initStats(void)
statDescription[STAT_DEATHS] = _("Deaths");
statDescription[STAT_SHOTS_FIRED] = _("Shots fired");
statDescription[STAT_SHOTS_HIT] = _("Shots hit");
statDescription[STAT_EYE_DROID_EXPLOSION_KILLS] = _("Eyedroid Explosion kills");
statDescription[STAT_SHOT_ACCURACY] = _("Accuracy");
statDescription[STAT_EYE_DROID_EXPLOSION_KILLS] = _("EyeDroid explosion kills");
statDescription[STAT_FLY_TIME] = _("Time spent flying");
statDescription[STAT_SWIM_TIME] = _("Time spent swimming");
statDescription[STAT_CHERRIES_PICKED_UP] = _("Cherries picked up");
@ -51,6 +53,7 @@ void initStats(void)
statDescription[STAT_WEAPONS_PICKED_UP] = _("Weapons picked up");
statDescription[STAT_ENEMIES_KILLED] = _("Enemies killed");
statDescription[STAT_MISSIONS_PLAYED] = _("Missions played");
statDescription[STAT_PERCENT_COMPLETE] = _("Percent complete");
statDescription[STAT_TIME_PLAYED] = _("Time played");
atlasTexture = getTexture("gfx/atlas/atlas.png");
@ -58,6 +61,18 @@ void initStats(void)
right = getImageFromAtlas("gfx/ui/right.png");
}
void initStatsDisplay(void)
{
int gameDone, gameTotal;
gameDone = game.stats[STAT_MISSIONS_COMPLETE] + game.stats[STAT_MIAS_RESCUED] + game.stats[STAT_TARGETS_DEFEATED] + game.stats[STAT_KEYS_FOUND] + game.stats[STAT_HEARTS_FOUND] + game.stats[STAT_CELLS_FOUND];
gameTotal = game.totalMissions + game.totalMIAs + game.totalTargets + game.totalKeys + game.totalHearts + game.totalCells;
game.stats[STAT_SHOT_ACCURACY] = getPercent(STAT_SHOTS_HIT, STAT_SHOTS_FIRED);
game.stats[STAT_PERCENT_COMPLETE] = getPercent(gameDone, gameTotal);
}
void doStats(void)
{
if (isControl(CONTROL_LEFT) || app.keyboard[SDL_SCANCODE_LEFT])
@ -124,6 +139,11 @@ void drawStats(void)
switch (i)
{
case STAT_SHOT_ACCURACY:
case STAT_PERCENT_COMPLETE:
drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%d%%", game.stats[i]);
break;
case STAT_SWIM_TIME:
case STAT_FLY_TIME:
drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%s", timeToString(game.stats[i] / FPS, 0));

View File

@ -34,6 +34,7 @@ extern Texture *getTexture(const char *filename);
extern int isControl(int type);
extern float limit(float i, float low, float high);
extern void playSound(int snd, int ch);
extern int getPercent(float current, float total);
extern char *timeToString(int seconds, int showHours);
extern App app;

View File

@ -55,8 +55,6 @@ static Atlas *clouds;
static Sprite *cursorSpr;
static Sprite *keySprites[MAX_KEY_TYPES];
static Texture *atlasTexture;
static int completedMissions;
static int numMissions;
static int unlockedMissions;
static PointF cursor;
static float blipSize;
@ -115,11 +113,11 @@ void initHub(void)
unlockAllLevels();
}
numMissions = 0;
game.totalMissions = 0;
unlockedMissions = 0;
completedMissions = 0;
game.stats[STAT_MISSIONS_COMPLETE] = 0;
unlockTeeka = 1;
@ -140,7 +138,7 @@ void initHub(void)
if (t->value.i == MS_COMPLETE)
{
completedMissions++;
game.stats[STAT_MISSIONS_COMPLETE]++;
}
}
@ -162,7 +160,7 @@ void initHub(void)
unlockTeeka = 0;
}
numMissions++;
game.totalMissions++;
}
for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next)
@ -411,7 +409,7 @@ static void drawInfoBar(void)
{
drawRect(0, 0, SCREEN_WIDTH, 32, 0, 0, 0, 192);
drawText(10, 5, 18, TA_LEFT, colors.white, "Missions : %d / %d", completedMissions, unlockedMissions);
drawText(10, 5, 18, TA_LEFT, colors.white, "Missions : %d / %d", game.stats[STAT_MISSIONS_COMPLETE], unlockedMissions);
drawText(210, 5, 18, TA_LEFT, colors.white, "MIAs : %d / %d", game.stats[STAT_MIAS_RESCUED], game.totalMIAs);
@ -526,11 +524,11 @@ static void unlockAllLevels(void)
static void unlockNeighbouringMission(HubMission *sourceMission)
{
HubMission *mission, *missions[numMissions];
HubMission *mission, *missions[game.totalMissions];
int i;
i = 0;
memset(missions, 0, sizeof(HubMission*) * numMissions);
memset(missions, 0, sizeof(HubMission*) * game.totalMissions);
for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next)
{
@ -626,6 +624,7 @@ static void options(void)
static void stats(void)
{
showing = SHOW_STATS;
initStatsDisplay();
showWidgetGroup("stats");
}
@ -743,13 +742,13 @@ static void awardMissionTrophies(void)
}
/* ignore training mission */
if (completedMissions == 2)
if (game.stats[STAT_MISSIONS_COMPLETE] == 2)
{
awardTrophy("CLEAN");
}
/* ignore Teeka's */
if (numMissions - completedMissions == 1)
if (game.totalMissions - game.stats[STAT_MISSIONS_COMPLETE] == 1)
{
awardTrophy("FULLY_CLEAN");
}

View File

@ -71,6 +71,7 @@ extern Widget *selectWidgetAt(int x, int y);
extern void showWidgetGroup(char *group);
extern void startSectionTransition(void);
extern void stopMusic(void);
extern void initStatsDisplay(void);
extern App app;
extern Colors colors;

View File

@ -367,6 +367,7 @@ typedef struct {
int totalCells;
int totalHearts;
int totalKeys;
int totalMissions;
unsigned int stats[STAT_MAX];
char worldId[MAX_NAME_LENGTH];
int isComplete;

View File

@ -68,6 +68,7 @@ void initLookups(void)
addLookup("TROPHY_GOLD", TROPHY_GOLD);
addLookup("TROPHY_PLATINUM", TROPHY_PLATINUM);
addLookup("STAT_MISSIONS_COMPLETE", STAT_MISSIONS_COMPLETE);
addLookup("STAT_KEYS_FOUND", STAT_KEYS_FOUND);
addLookup("STAT_CELLS_FOUND", STAT_CELLS_FOUND);
addLookup("STAT_HEARTS_FOUND", STAT_HEARTS_FOUND);
@ -84,6 +85,8 @@ void initLookups(void)
addLookup("STAT_WEAPONS_PICKED_UP", STAT_WEAPONS_PICKED_UP);
addLookup("STAT_ENEMIES_KILLED", STAT_ENEMIES_KILLED);
addLookup("STAT_MISSIONS_PLAYED", STAT_MISSIONS_PLAYED);
addLookup("STAT_SHOT_ACCURACY", STAT_SHOT_ACCURACY);
addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE);
addLookup("STAT_TIME_PLAYED", STAT_TIME_PLAYED);
}

View File

@ -24,12 +24,12 @@ void initAtlasTest(void)
{
int test;
dev.debug = 1;
dev.debug = 0;
dev.cheatStatic = 0;
dev.cheatBlind = 1;
dev.cheatNoEnemies = 0;
dev.cheatKeys = 0;
dev.cheatPower = 1;
dev.cheatPower = 0;
dev.cheatHealth = 0;
dev.cheatLevels = 0;
dev.takeScreenshots = 0;

View File

@ -802,6 +802,7 @@ static void options(void)
static void stats(void)
{
showing = SHOW_STATS;
initStatsDisplay();
showWidgetGroup("stats");
}

View File

@ -113,6 +113,7 @@ extern int rrnd(int low, int high);
extern void showWidgetGroup(char *group);
extern void startSectionTransition(void);
extern void stopMusic(void);
extern void initStatsDisplay(void);
extern App app;
extern Colors colors;