2016-03-03 19:03:07 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2015-2016 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "trophies.h"
|
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
static void prevPage(void);
|
|
|
|
static void nextPage(void);
|
2016-03-03 19:03:07 +01:00
|
|
|
static void loadTrophyData(char *filename);
|
2016-03-09 12:51:26 +01:00
|
|
|
static void resetAlert(void);
|
2016-03-12 19:28:43 +01:00
|
|
|
static void awardCraftTrophy(void);
|
2016-05-15 09:19:26 +02:00
|
|
|
static void setSparkleColor(Trophy *t);
|
|
|
|
static void nextAlert(void);
|
2016-03-09 12:51:26 +01:00
|
|
|
|
|
|
|
static Trophy *alertTrophy;
|
|
|
|
static SDL_Texture *trophyIcons[TROPHY_MAX];
|
2016-05-15 09:19:26 +02:00
|
|
|
static SDL_Texture *sparkle;
|
|
|
|
static SDL_Texture *alertSphere;
|
2016-03-09 12:51:26 +01:00
|
|
|
static SDL_Rect alertRect;
|
|
|
|
static int alertTimer;
|
2016-05-15 09:19:26 +02:00
|
|
|
static int page;
|
|
|
|
static int awarded;
|
|
|
|
static int total;
|
|
|
|
static int boxWidth;
|
|
|
|
static float sparkleAngle;
|
|
|
|
static float maxPages;
|
|
|
|
static Widget *prev;
|
|
|
|
static Widget *next;
|
2016-03-03 19:03:07 +01:00
|
|
|
|
|
|
|
void initTrophies(void)
|
|
|
|
{
|
|
|
|
loadTrophyData("data/trophies/trophies.json");
|
2016-03-09 12:51:26 +01:00
|
|
|
|
|
|
|
trophyIcons[TROPHY_BRONZE] = getTexture("gfx/trophies/bronze.png");
|
|
|
|
trophyIcons[TROPHY_SILVER] = getTexture("gfx/trophies/silver.png");
|
|
|
|
trophyIcons[TROPHY_GOLD] = getTexture("gfx/trophies/gold.png");
|
|
|
|
trophyIcons[TROPHY_PLATINUM] = getTexture("gfx/trophies/platinum.png");
|
2016-05-15 09:19:26 +02:00
|
|
|
trophyIcons[TROPHY_UNEARNED] = getTexture("gfx/trophies/unearned.png");
|
|
|
|
sparkle = getTexture("gfx/trophies/sparkle.png");
|
|
|
|
alertSphere = getTexture("gfx/trophies/alertSphere.png");
|
|
|
|
|
|
|
|
alertRect.h = 90;
|
|
|
|
alertRect.y = 10;
|
2016-03-09 12:51:26 +01:00
|
|
|
|
|
|
|
resetAlert();
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
void initTrophiesDisplay(void)
|
2016-03-03 19:03:07 +01:00
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
int w, h;
|
2016-03-03 19:03:07 +01:00
|
|
|
Trophy *t;
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
boxWidth = total = awarded = 0;
|
|
|
|
|
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
|
|
|
{
|
|
|
|
total++;
|
|
|
|
|
|
|
|
if (t->awarded)
|
|
|
|
{
|
|
|
|
awarded++;
|
|
|
|
|
|
|
|
STRNCPY(t->awardDateStr, timeToDate(t->awardDate), MAX_NAME_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
textSize(t->description, 18, &w, &h);
|
|
|
|
|
|
|
|
boxWidth = MAX(boxWidth, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
boxWidth += 125;
|
|
|
|
|
|
|
|
page = 0;
|
|
|
|
|
|
|
|
maxPages = total;
|
|
|
|
maxPages /= TROPHIES_PER_PAGE;
|
|
|
|
maxPages = ceil(maxPages);
|
|
|
|
|
|
|
|
prev = getWidget("prev", "trophies");
|
|
|
|
prev->action = prevPage;
|
|
|
|
prev->visible = 0;
|
|
|
|
|
|
|
|
next = getWidget("next", "trophies");
|
|
|
|
next->action = nextPage;
|
|
|
|
next->visible = 1;
|
|
|
|
|
|
|
|
sparkleAngle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nextPage(void)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void doTrophies(void)
|
|
|
|
{
|
|
|
|
sparkleAngle += 0.25;
|
|
|
|
if (sparkleAngle >= 360)
|
|
|
|
{
|
|
|
|
sparkleAngle = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-03-03 19:03:07 +01:00
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
void drawTrophies(void)
|
|
|
|
{
|
|
|
|
Trophy *t;
|
|
|
|
SDL_Rect r;
|
|
|
|
int start, end, i, x, y;
|
|
|
|
|
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
|
|
|
SDL_RenderFillRect(app.renderer, NULL);
|
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
|
|
|
|
|
|
|
r.w = boxWidth;
|
|
|
|
r.h = 650;
|
|
|
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
|
|
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
|
|
|
SDL_RenderFillRect(app.renderer, &r);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &r);
|
|
|
|
|
|
|
|
drawText(SCREEN_WIDTH / 2, 40, 28, TA_CENTER, colors.white, _("Trophies"));
|
|
|
|
drawText(SCREEN_WIDTH / 2, 83, 16, TA_CENTER, colors.lightGrey, _("Awarded : %d / %d"), awarded, total);
|
|
|
|
drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, _("Page : %d / %d"), page + 1, (int)maxPages);
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
|
|
|
|
SDL_RenderDrawLine(app.renderer, r.x, 150, r.x + r.w, 150);
|
|
|
|
|
|
|
|
x = r.x + 15;
|
|
|
|
y = 180;
|
|
|
|
start = page * TROPHIES_PER_PAGE;
|
|
|
|
end = start + TROPHIES_PER_PAGE;
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
|
|
|
{
|
|
|
|
if (i >= start && i < end)
|
|
|
|
{
|
|
|
|
if (t->awarded)
|
|
|
|
{
|
|
|
|
setSparkleColor(t);
|
|
|
|
blitRotated(sparkle, x + 32, y + 32, sparkleAngle);
|
|
|
|
blitRotated(sparkle, x + 32, y + 32, -sparkleAngle);
|
|
|
|
|
|
|
|
blitScaled(trophyIcons[t->value], x, y, 64, 64);
|
|
|
|
drawText(x + 85, y - 10, 20, TA_LEFT, colors.yellow, t->title);
|
|
|
|
drawText(x + 85, y + 20, 18, TA_LEFT, colors.white, t->description);
|
|
|
|
drawText(x + 85, y + 48, 18, TA_LEFT, colors.white, t->awardDateStr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
blitScaled(trophyIcons[TROPHY_UNEARNED], x, y, 64, 64);
|
|
|
|
|
|
|
|
if (!t->hidden)
|
|
|
|
{
|
|
|
|
drawText(x + 85, y - 10, 20, TA_LEFT, colors.lightGrey, t->title);
|
|
|
|
drawText(x + 85, y + 20, 18, TA_LEFT, colors.darkGrey, t->description);
|
|
|
|
drawText(x + 85, y + 48, 18, TA_LEFT, colors.darkGrey, "-");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drawText(x + 85, y + 20, 20, TA_LEFT, colors.darkGrey, _("[Hidden]"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
y += 120;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawWidgets("trophies");
|
|
|
|
}
|
|
|
|
|
|
|
|
void awardTrophy(char *id)
|
|
|
|
{
|
|
|
|
Trophy *t;
|
|
|
|
int numRemaining;
|
|
|
|
|
|
|
|
numRemaining = 0;
|
|
|
|
|
2016-03-03 19:03:07 +01:00
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
|
|
|
{
|
|
|
|
if (!t->awarded && strcmp(t->id, id) == 0)
|
|
|
|
{
|
|
|
|
t->awarded = 1;
|
|
|
|
t->awardDate = time(NULL);
|
|
|
|
t->notify = 1;
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Awarding trophy '%s'", t->id);
|
|
|
|
|
|
|
|
app.saveGame = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!t->awarded)
|
|
|
|
{
|
|
|
|
numRemaining++;
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
}
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
/* the Platinum will always be the last trophy to unlock */
|
|
|
|
if (numRemaining == 1)
|
|
|
|
{
|
|
|
|
awardTrophy("PLATINUM");
|
|
|
|
}
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
void doTrophyAlerts(void)
|
|
|
|
{
|
|
|
|
if (!alertTrophy)
|
|
|
|
{
|
|
|
|
nextAlert();
|
|
|
|
}
|
|
|
|
else if (alertTrophy)
|
|
|
|
{
|
|
|
|
alertRect.x = MIN(alertRect.x + 24, -1);
|
|
|
|
|
|
|
|
if (alertRect.x > -150)
|
|
|
|
{
|
|
|
|
alertTimer--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alertTimer <= 0)
|
|
|
|
{
|
|
|
|
alertTrophy->notify = 0;
|
|
|
|
resetAlert();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do the sparkle rotation */
|
|
|
|
doTrophies();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nextAlert(void)
|
2016-03-03 19:03:07 +01:00
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
int w, h;
|
2016-03-03 19:03:07 +01:00
|
|
|
Trophy *t;
|
|
|
|
|
2016-03-09 12:51:26 +01:00
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
2016-03-03 19:03:07 +01:00
|
|
|
{
|
2016-03-09 12:51:26 +01:00
|
|
|
if (t->notify)
|
2016-03-03 19:03:07 +01:00
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
if (!alertTrophy || t->awardDate < alertTrophy->awardDate)
|
2016-03-09 12:51:26 +01:00
|
|
|
{
|
|
|
|
alertTrophy = t;
|
|
|
|
}
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
}
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
if (alertTrophy)
|
|
|
|
{
|
|
|
|
playSound(SND_TROPHY);
|
|
|
|
|
|
|
|
textSize(alertTrophy->title, 30, &alertRect.w, &h);
|
|
|
|
textSize(alertTrophy->description, 20, &w, &h);
|
|
|
|
|
|
|
|
alertRect.w = MAX(alertRect.w, w);
|
|
|
|
alertRect.w += 125;
|
|
|
|
alertRect.x = -alertRect.w;
|
|
|
|
}
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 12:51:26 +01:00
|
|
|
static void resetAlert(void)
|
|
|
|
{
|
|
|
|
alertTimer = FPS * 3;
|
2016-05-15 09:19:26 +02:00
|
|
|
alertTrophy = NULL;
|
2016-03-09 12:51:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void drawTrophyAlert(void)
|
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
int x, y;
|
|
|
|
|
2016-03-09 12:51:26 +01:00
|
|
|
if (alertTrophy)
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderFillRect(app.renderer, &alertRect);
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &alertRect);
|
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
drawText(alertRect.x + 15, alertRect.y + 5, 30, TA_LEFT, colors.white, alertTrophy->title);
|
|
|
|
drawText(alertRect.x + 15, alertRect.y + 45, 20, TA_LEFT, colors.white, alertTrophy->description);
|
|
|
|
|
|
|
|
setSparkleColor(alertTrophy);
|
|
|
|
|
|
|
|
x = alertRect.x + alertRect.w - 72;
|
|
|
|
y = alertRect.y + 20;
|
|
|
|
|
|
|
|
blit(alertSphere, x + 24, y + 24, 1);
|
|
|
|
blitRotated(sparkle, x + 24, y + 24, sparkleAngle);
|
|
|
|
blitRotated(sparkle, x + 24, y + 24, -sparkleAngle);
|
|
|
|
blitScaled(trophyIcons[alertTrophy->value], x, y, 48, 48);
|
2016-03-09 12:51:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-03 19:03:07 +01:00
|
|
|
Trophy *getTrophy(char *id)
|
|
|
|
{
|
|
|
|
Trophy *t;
|
|
|
|
|
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
|
|
|
{
|
|
|
|
if (strcmp(t->id, id) == 0)
|
|
|
|
{
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loadTrophyData(char *filename)
|
|
|
|
{
|
|
|
|
cJSON *root, *node;
|
|
|
|
char *text;
|
|
|
|
Trophy *t, *tail;
|
|
|
|
|
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
|
|
|
|
2016-03-04 15:29:50 +01:00
|
|
|
text = readFile(filename);
|
2016-03-03 19:03:07 +01:00
|
|
|
root = cJSON_Parse(text);
|
|
|
|
|
|
|
|
tail = &game.trophyHead;
|
|
|
|
|
|
|
|
for (node = root->child ; node != NULL ; node = node->next)
|
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
if (cJSON_GetObjectItem(node, "id")->valuestring[0] != '_')
|
2016-03-09 13:31:33 +01:00
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
t = malloc(sizeof(Trophy));
|
|
|
|
memset(t, 0, sizeof(Trophy));
|
|
|
|
|
|
|
|
STRNCPY(t->id, cJSON_GetObjectItem(node, "id")->valuestring, MAX_NAME_LENGTH);
|
|
|
|
STRNCPY(t->title, _(cJSON_GetObjectItem(node, "title")->valuestring), MAX_DESCRIPTION_LENGTH);
|
|
|
|
STRNCPY(t->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH);
|
|
|
|
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
|
|
|
t->hidden = getJSONValue(node, "hidden", 0);
|
|
|
|
|
|
|
|
t->stat = -1;
|
|
|
|
|
|
|
|
/* can't use the getJSONValue here, as it could lead to false positives */
|
|
|
|
if (cJSON_GetObjectItem(node, "stat"))
|
|
|
|
{
|
|
|
|
t->stat = lookup(cJSON_GetObjectItem(node, "stat")->valuestring);
|
|
|
|
t->statValue = cJSON_GetObjectItem(node, "statValue")->valueint;
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
tail->next = t;
|
|
|
|
tail = t;
|
|
|
|
}
|
2016-03-03 19:03:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cJSON_Delete(root);
|
|
|
|
free(text);
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-09 16:53:56 +01:00
|
|
|
void awardStatsTrophies(void)
|
2016-03-09 13:31:33 +01:00
|
|
|
{
|
|
|
|
Trophy *t;
|
|
|
|
|
|
|
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
|
|
|
{
|
2016-05-15 09:19:26 +02:00
|
|
|
if (t->stat != -1 && !t->awarded && (game.stats[t->stat] + battle.stats[t->stat]) >= t->statValue)
|
2016-03-09 13:31:33 +01:00
|
|
|
{
|
|
|
|
t->awarded = 1;
|
|
|
|
t->awardDate = time(NULL);
|
|
|
|
t->notify = 1;
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Awarding trophy '%s'", t->id);
|
|
|
|
|
|
|
|
app.saveGame = 1;
|
2016-03-09 13:31:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-09 16:53:56 +01:00
|
|
|
|
|
|
|
void awardCampaignTrophies(void)
|
|
|
|
{
|
|
|
|
char trophyId[MAX_NAME_LENGTH];
|
|
|
|
char name[MAX_NAME_LENGTH];
|
2016-05-15 09:19:26 +02:00
|
|
|
int i, len;
|
2016-03-10 19:02:19 +01:00
|
|
|
StarSystem *starSystem;
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
if (game.completedMissions)
|
|
|
|
{
|
|
|
|
awardTrophy("CAMPAIGN_1");
|
|
|
|
}
|
2016-03-09 16:53:56 +01:00
|
|
|
|
|
|
|
/* check if all star system missions are completed */
|
|
|
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
|
|
|
{
|
|
|
|
if (starSystem->totalMissions && starSystem->completedMissions == starSystem->totalMissions)
|
|
|
|
{
|
|
|
|
memset(name, '\0', MAX_NAME_LENGTH);
|
|
|
|
|
|
|
|
len = strlen(starSystem->name);
|
|
|
|
|
|
|
|
for (i = 0 ; i < len ; i++)
|
|
|
|
{
|
|
|
|
name[i] = toupper(starSystem->name[i]);
|
|
|
|
}
|
2016-05-15 09:19:26 +02:00
|
|
|
|
2016-03-09 16:53:56 +01:00
|
|
|
sprintf(trophyId, "CAMPAIGN_%s", name);
|
|
|
|
awardTrophy(trophyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-10 13:04:04 +01:00
|
|
|
|
2016-03-12 19:28:43 +01:00
|
|
|
void awardChallengeTrophies(void)
|
|
|
|
{
|
|
|
|
char trophyId[MAX_NAME_LENGTH];
|
|
|
|
int completed;
|
|
|
|
|
2016-05-15 09:19:26 +02:00
|
|
|
/* check % of challenges completed - 25% increments*/
|
|
|
|
completed = (getPercent(game.completedChallenges, game.totalChallenges) / 25) * 25;
|
2016-03-12 19:28:43 +01:00
|
|
|
sprintf(trophyId, "CHALLENGE_%d", completed);
|
|
|
|
awardTrophy(trophyId);
|
|
|
|
}
|
|
|
|
|
2016-03-10 13:04:04 +01:00
|
|
|
void awardPostMissionTrophies(void)
|
|
|
|
{
|
2016-03-12 19:28:43 +01:00
|
|
|
awardCraftTrophy();
|
|
|
|
|
|
|
|
if (game.currentMission->epic)
|
|
|
|
{
|
|
|
|
awardTrophy("EPIC");
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
if (battle.stats[STAT_PLAYER_KILLED] == 0)
|
|
|
|
{
|
|
|
|
awardTrophy("SURVIVOR");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Must be a non-challenge mission, a fighter-type (has guns and missiles), must not be Sol, and must not have fired any shots or missiles
|
|
|
|
*/
|
|
|
|
if (!game.currentMission->challengeData.isChallenge && player->guns[0].type && player->missiles && strcmp(game.selectedStarSystem, "Sol") && !battle.stats[STAT_SHOTS_FIRED] && !battle.stats[STAT_MISSILES_FIRED])
|
|
|
|
{
|
|
|
|
awardTrophy("PACIFIST");
|
2016-03-12 19:28:43 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-10 13:04:04 +01:00
|
|
|
|
2016-03-12 19:28:43 +01:00
|
|
|
/* the player is known as "Player", so we need to check the craft they were assigned to */
|
|
|
|
static void awardCraftTrophy(void)
|
|
|
|
{
|
|
|
|
char trophyId[MAX_NAME_LENGTH];
|
2016-03-27 12:21:23 +02:00
|
|
|
int len, i;
|
2016-03-12 19:28:43 +01:00
|
|
|
|
|
|
|
memset(trophyId, '\0', MAX_NAME_LENGTH);
|
|
|
|
|
|
|
|
len = strlen(game.currentMission->craft);
|
|
|
|
|
|
|
|
for (i = 0 ; i < len ; i++)
|
|
|
|
{
|
|
|
|
trophyId[i] = toupper(game.currentMission->craft[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
awardTrophy(trophyId);
|
2016-03-10 13:04:04 +01:00
|
|
|
}
|
2016-05-15 09:19:26 +02:00
|
|
|
|
|
|
|
static void setSparkleColor(Trophy *t)
|
|
|
|
{
|
|
|
|
switch (t->value)
|
|
|
|
{
|
|
|
|
case TROPHY_BRONZE:
|
|
|
|
SDL_SetTextureColorMod(sparkle, 255, 128, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TROPHY_SILVER:
|
|
|
|
SDL_SetTextureColorMod(sparkle, 192, 192, 192);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TROPHY_GOLD:
|
|
|
|
SDL_SetTextureColorMod(sparkle, 255, 255, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TROPHY_PLATINUM:
|
|
|
|
SDL_SetTextureColorMod(sparkle, 0, 128, 255);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|