Trophy integration updates.

This commit is contained in:
Steve 2016-04-24 18:11:02 +01:00
parent 3ce51feb9c
commit 134acf7a3d
22 changed files with 348 additions and 57 deletions

View File

@ -12,49 +12,49 @@
"value" : "TROPHY_BRONZE" "value" : "TROPHY_BRONZE"
}, },
{ {
"id" : "CAMPAIGN_10", "id" : "_CAMPAIGN_10",
"title" : "1st Lieutenant", "title" : "1st Lieutenant",
"description" : "Complete 10%% of all missions", "description" : "Complete 10%% of all missions",
"value" : "TROPHY_BRONZE" "value" : "TROPHY_BRONZE"
}, },
{ {
"id" : "CAMPAIGN_20", "id" : "_CAMPAIGN_20",
"title" : "Lieutenant Commander", "title" : "Lieutenant Commander",
"description" : "Complete 20%% of all missions", "description" : "Complete 20%% of all missions",
"value" : "TROPHY_BRONZE" "value" : "TROPHY_BRONZE"
}, },
{ {
"id" : "CAMPAIGN_40", "id" : "_CAMPAIGN_40",
"title" : "Commander", "title" : "Commander",
"description" : "Complete 40%% of all missions", "description" : "Complete 40%% of all missions",
"value" : "TROPHY_BRONZE" "value" : "TROPHY_BRONZE"
}, },
{ {
"id" : "CAMPAIGN_50", "id" : "_CAMPAIGN_50",
"title" : "Captain", "title" : "Captain",
"description" : "Complete 50%% of all missions", "description" : "Complete 50%% of all missions",
"value" : "TROPHY_SILVER" "value" : "TROPHY_SILVER"
}, },
{ {
"id" : "CAMPAIGN_60", "id" : "_CAMPAIGN_60",
"title" : "Commodore", "title" : "Commodore",
"description" : "Complete 60%% of all missions", "description" : "Complete 60%% of all missions",
"value" : "TROPHY_SILVER" "value" : "TROPHY_SILVER"
}, },
{ {
"id" : "CAMPAIGN_80", "id" : "_CAMPAIGN_80",
"title" : "Rear Admiral", "title" : "Rear Admiral",
"description" : "Complete 80%% of all missions", "description" : "Complete 80%% of all missions",
"value" : "TROPHY_SILVER" "value" : "TROPHY_SILVER"
}, },
{ {
"id" : "CAMPAIGN_90", "id" : "_CAMPAIGN_90",
"title" : "Admiral", "title" : "Admiral",
"description" : "Complete 90%% of all missions", "description" : "Complete 90%% of all missions",
"value" : "TROPHY_GOLD" "value" : "TROPHY_GOLD"
}, },
{ {
"id" : "CAMPAIGN_100", "id" : "_CAMPAIGN_100",
"title" : "Fleet Admiral", "title" : "Fleet Admiral",
"description" : "Complete all campaign missions", "description" : "Complete all campaign missions",
"value" : "TROPHY_GOLD" "value" : "TROPHY_GOLD"
@ -94,8 +94,8 @@
"hidden" : 1 "hidden" : 1
}, },
{ {
"id" : "CAMPAIGN_MACE", "id" : "_CAMPAIGN_MACE",
"title" : "Going out with a bang.", "title" : "Going out with a bang",
"description" : "Complete all missions at Mace", "description" : "Complete all missions at Mace",
"value" : "TROPHY_SILVER", "value" : "TROPHY_SILVER",
"hidden" : 1 "hidden" : 1
@ -145,19 +145,19 @@
"value" : "TROPHY_SILVER" "value" : "TROPHY_SILVER"
}, },
{ {
"id" : "CHALLENGE_25", "id" : "_CHALLENGE_25",
"title" : "", "title" : "",
"description" : "Complete 25%% of all challenges", "description" : "Complete 25%% of all challenges",
"value" : "TROPHY_BRONZE" "value" : "TROPHY_BRONZE"
}, },
{ {
"id" : "CHALLENGE_50", "id" : "_CHALLENGE_50",
"title" : "", "title" : "",
"description" : "Complete 50%% of all challenges", "description" : "Complete 50%% of all challenges",
"value" : "TROPHY_SILVER" "value" : "TROPHY_SILVER"
}, },
{ {
"id" : "CHALLENGE_100", "id" : "_CHALLENGE_100",
"title" : "", "title" : "",
"description" : "Complete 100%% of all challenges", "description" : "Complete 100%% of all challenges",
"value" : "TROPHY_GOLD" "value" : "TROPHY_GOLD"
@ -221,7 +221,7 @@
}, },
{ {
"id" : "ATAF_DESTROYED", "id" : "ATAF_DESTROYED",
"title" : "Almost indestructable. Almost.", "title" : "Almost indestructable. Almost",
"description" : "Be destroyed while piloting an ATAF", "description" : "Be destroyed while piloting an ATAF",
"value" : "TROPHY_BRONZE", "value" : "TROPHY_BRONZE",
"hidden" : 1 "hidden" : 1

View File

@ -5,7 +5,7 @@
"type" : "WT_BUTTON", "type" : "WT_BUTTON",
"text" : "Campaign", "text" : "Campaign",
"x" : -1, "x" : -1,
"y" : 225, "y" : 200,
"w" : 200, "w" : 200,
"h": 34 "h": 34
}, },
@ -15,7 +15,17 @@
"type" : "WT_BUTTON", "type" : "WT_BUTTON",
"text" : "Challenges", "text" : "Challenges",
"x" : -1, "x" : -1,
"y" : 325, "y" : 290,
"w" : 200,
"h": 34
},
{
"name" : "trophies",
"group" : "title",
"type" : "WT_BUTTON",
"text" : "Trophies",
"x" : -1,
"y" : 380,
"w" : 200, "w" : 200,
"h": 34 "h": 34
}, },
@ -25,7 +35,7 @@
"type" : "WT_BUTTON", "type" : "WT_BUTTON",
"text" : "Stats", "text" : "Stats",
"x" : -1, "x" : -1,
"y" : 425, "y" : 470,
"w" : 200, "w" : 200,
"h": 34 "h": 34
}, },
@ -35,7 +45,7 @@
"type" : "WT_BUTTON", "type" : "WT_BUTTON",
"text" : "Options", "text" : "Options",
"x" : -1, "x" : -1,
"y" : 525, "y" : 560,
"w" : 200, "w" : 200,
"h": 34 "h": 34
}, },
@ -45,7 +55,7 @@
"type" : "WT_BUTTON", "type" : "WT_BUTTON",
"text" : "Quit", "text" : "Quit",
"x" : -1, "x" : -1,
"y" : 625, "y" : 650,
"w" : 200, "w" : 200,
"h": 34 "h": 34
} }

View File

@ -0,0 +1,32 @@
[
{
"name" : "ok",
"group" : "trophies",
"type" : "WT_BUTTON",
"text" : "OK",
"x" : -1,
"y" : 665,
"w" : 150,
"h": 34
},
{
"name" : "prev",
"group" : "trophies",
"type" : "WT_IMG_BUTTON",
"x" : 540,
"y" : 110,
"w" : 150,
"h": 34,
"texture" : "gfx/widgets/optionsLeft.png"
},
{
"name" : "next",
"group" : "trophies",
"type" : "WT_IMG_BUTTON",
"x" : 720,
"y" : 110,
"w" : 150,
"h": 34,
"texture" : "gfx/widgets/optionsRight.png"
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

BIN
gfx/trophies/sparkle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
gfx/trophies/unearned.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -160,7 +160,7 @@ static void logic(void)
break; break;
} }
doTrophies(); doTrophyAlerts();
doWidgets(); doWidgets();
} }

View File

@ -60,7 +60,7 @@ extern void playMusic(char *filename);
extern char *timeToString(long millis, int showHours); extern char *timeToString(long millis, int showHours);
extern char *getChallengeDescription(Challenge *c); extern char *getChallengeDescription(Challenge *c);
extern void clearInput(void); extern void clearInput(void);
extern void doTrophies(void); extern void doTrophyAlerts(void);
extern void drawTrophyAlert(void); extern void drawTrophyAlert(void);
extern void awardStatsTrophies(void); extern void awardStatsTrophies(void);
extern void awardChallengeTrophies(void); extern void awardChallengeTrophies(void);

View File

@ -367,5 +367,6 @@ enum
TROPHY_SILVER, TROPHY_SILVER,
TROPHY_GOLD, TROPHY_GOLD,
TROPHY_PLATINUM, TROPHY_PLATINUM,
TROPHY_UNEARNED,
TROPHY_MAX TROPHY_MAX
}; };

View File

@ -176,7 +176,7 @@ static void logic(void)
doWidgets(); doWidgets();
doTrophies(); doTrophyAlerts();
} }
static void doStarSystems(void) static void doStarSystems(void)

View File

@ -60,7 +60,7 @@ extern StarSystem *getStarSystem(char *name);
extern void showOKDialog(void (*callback)(void), const char *format, ...); extern void showOKDialog(void (*callback)(void), const char *format, ...);
extern char *getTranslatedString(char *string); extern char *getTranslatedString(char *string);
extern void clearInput(void); extern void clearInput(void);
extern void doTrophies(void); extern void doTrophyAlerts(void);
extern void drawTrophyAlert(void); extern void drawTrophyAlert(void);
extern void awardCampaignTrophies(void); extern void awardCampaignTrophies(void);
extern void awardStatsTrophies(void); extern void awardStatsTrophies(void);

View File

@ -28,8 +28,9 @@ static void doFighters(void);
static void drawFighters(void); static void drawFighters(void);
static void campaign(void); static void campaign(void);
static void challenges(void); static void challenges(void);
static void trophies(void);
static void stats(void); static void stats(void);
static void statsOK(void); static void ok(void);
static void options(void); static void options(void);
static void quit(void); static void quit(void);
static void returnFromOptions(void); static void returnFromOptions(void);
@ -78,11 +79,13 @@ void initTitle(void)
getWidget("campaign", "title")->action = campaign; getWidget("campaign", "title")->action = campaign;
getWidget("challenges", "title")->action = challenges; getWidget("challenges", "title")->action = challenges;
getWidget("trophies", "title")->action = trophies;
getWidget("stats", "title")->action = stats; getWidget("stats", "title")->action = stats;
getWidget("options", "title")->action = options; getWidget("options", "title")->action = options;
getWidget("quit", "title")->action = quit; getWidget("quit", "title")->action = quit;
getWidget("ok", "stats")->action = statsOK; getWidget("ok", "stats")->action = ok;
getWidget("ok", "trophies")->action = ok;
show = SHOW_TITLE; show = SHOW_TITLE;
@ -128,6 +131,8 @@ static void logic(void)
doEffects(); doEffects();
doTrophies();
doWidgets(); doWidgets();
} }
@ -190,6 +195,10 @@ static void draw(void)
case SHOW_OPTIONS: case SHOW_OPTIONS:
drawOptions(); drawOptions();
break; break;
case SHOW_TROPHIES:
drawTrophies();
break;
} }
} }
@ -226,6 +235,15 @@ static void challenges(void)
initChallengeHome(); initChallengeHome();
} }
static void trophies(void)
{
selectWidget("ok", "trophies");
show = SHOW_TROPHIES;
initTrophyDisplay();
}
static void options(void) static void options(void)
{ {
selectWidget("ok", "options"); selectWidget("ok", "options");
@ -244,7 +262,7 @@ static void stats(void)
initStatsDisplay(); initStatsDisplay();
} }
static void statsOK(void) static void ok(void)
{ {
selectWidget("stats", "title"); selectWidget("stats", "title");

View File

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SHOW_TITLE 0 #define SHOW_TITLE 0
#define SHOW_STATS 1 #define SHOW_STATS 1
#define SHOW_OPTIONS 2 #define SHOW_OPTIONS 2
#define SHOW_TROPHIES 3
#define NUM_FIGHTERS 12 #define NUM_FIGHTERS 12
@ -56,6 +57,9 @@ extern void selectWidget(const char *name, const char *group);
extern void drawStats(void); extern void drawStats(void);
extern void updateAllMissions(void); extern void updateAllMissions(void);
extern void clearInput(void); extern void clearInput(void);
extern void initTrophyDisplay(void);
extern void drawTrophies(void);
extern void doTrophies(void);
extern App app; extern App app;
extern Battle battle; extern Battle battle;

View File

@ -20,15 +20,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "trophies.h" #include "trophies.h"
static void prevPage(void);
static void nextPage(void);
static void loadTrophyData(char *filename); static void loadTrophyData(char *filename);
static void resetAlert(void); static void resetAlert(void);
static void awardCraftTrophy(void); static void awardCraftTrophy(void);
static void setSparkleColor(Trophy *t);
static void nextAlert(void);
static Trophy *alertTrophy; static Trophy *alertTrophy;
static SDL_Texture *trophyIcons[TROPHY_MAX]; static SDL_Texture *trophyIcons[TROPHY_MAX];
static SDL_Texture *sparkle;
static SDL_Texture *alertSphere;
static SDL_Rect alertRect; static SDL_Rect alertRect;
static float alertDX; static float alertDX;
static int alertTimer; static int alertTimer;
static int page;
static int awarded;
static int total;
static int boxWidth;
static float sparkleAngle;
static float maxPages;
static Widget *prev;
static Widget *next;
void initTrophies(void) void initTrophies(void)
{ {
@ -38,10 +52,155 @@ void initTrophies(void)
trophyIcons[TROPHY_SILVER] = getTexture("gfx/trophies/silver.png"); trophyIcons[TROPHY_SILVER] = getTexture("gfx/trophies/silver.png");
trophyIcons[TROPHY_GOLD] = getTexture("gfx/trophies/gold.png"); trophyIcons[TROPHY_GOLD] = getTexture("gfx/trophies/gold.png");
trophyIcons[TROPHY_PLATINUM] = getTexture("gfx/trophies/platinum.png"); trophyIcons[TROPHY_PLATINUM] = getTexture("gfx/trophies/platinum.png");
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;
resetAlert(); resetAlert();
} }
void initTrophyDisplay(void)
{
int w, h;
Trophy *t;
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;
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;
}
}
void drawTrophies(void)
{
Trophy *t;
SDL_Rect r;
int start, 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;
i = 0;
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
{
if (i >= start && i < start + TROPHIES_PER_PAGE)
{
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.white, t->title);
drawText(x + 85, y + 20, 18, TA_LEFT, colors.lightGrey, t->description);
drawText(x + 85, y + 48, 18, TA_LEFT, colors.yellow, t->awardDateStr);
}
else
{
blitScaled(trophyIcons[TROPHY_UNEARNED], x, y, 64, 64);
if (!t->hidden)
{
drawText(x + 85, y - 10, 20, TA_LEFT, colors.white, t->title);
drawText(x + 85, y + 20, 18, TA_LEFT, colors.lightGrey, t->description);
drawText(x + 85, y + 48, 18, TA_LEFT, colors.lightGrey, "-");
}
else
{
drawText(x + 85, y + 20, 20, TA_LEFT, colors.darkGrey, _("[Hidden]"));
}
}
y += 120;
}
i++;
}
drawWidgets("trophies");
}
void awardTrophy(char *id) void awardTrophy(char *id)
{ {
Trophy *t; Trophy *t;
@ -57,20 +216,14 @@ void awardTrophy(char *id)
} }
} }
void doTrophies(void) void doTrophyAlerts(void)
{ {
Trophy *t; if (!alertTrophy)
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
{ {
if (t->notify) nextAlert();
{
if (alertTrophy != t)
{
alertTrophy = t;
playSound(SND_TROPHY);
} }
else if (alertTrophy)
{
alertRect.x += alertDX; alertRect.x += alertDX;
if (alertRect.x > -150) if (alertRect.x > -150)
@ -82,28 +235,53 @@ void doTrophies(void)
if (alertTimer <= 0) if (alertTimer <= 0)
{ {
t->notify = 0; alertTrophy->notify = 0;
resetAlert(); resetAlert();
} }
return; /* do the sparkle rotation */
doTrophies();
} }
}
static void nextAlert(void)
{
int h;
Trophy *t;
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
{
if (t->notify)
{
if (!alertTrophy || t->awardDate < alertTrophy->awardDate)
{
alertTrophy = t;
}
}
}
if (alertTrophy)
{
playSound(SND_TROPHY);
textSize(t->title, 30, &alertRect.w, &h);
alertRect.w += 125;
alertRect.w = MAX(alertRect.w, 500);
alertRect.x = -alertRect.w;
} }
} }
static void resetAlert(void) static void resetAlert(void)
{ {
alertRect.w = 500;
alertRect.h = 90;
alertRect.x = -alertRect.w;
alertRect.y = 10;
alertDX = 12; alertDX = 12;
alertTimer = FPS * 3; alertTimer = FPS * 3;
alertTrophy = NULL;
} }
void drawTrophyAlert(void) void drawTrophyAlert(void)
{ {
int x, y;
if (alertTrophy) if (alertTrophy)
{ {
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
@ -115,12 +293,16 @@ void drawTrophyAlert(void)
drawText(alertRect.x + 15, alertRect.y + 5, 30, TA_LEFT, colors.white, alertTrophy->title); 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->shortDescription); drawText(alertRect.x + 15, alertRect.y + 45, 20, TA_LEFT, colors.white, alertTrophy->shortDescription);
blitScaled(trophyIcons[alertTrophy->value], alertRect.x + alertRect.w - 64, alertRect.y + 16, 48, 48); setSparkleColor(alertTrophy);
}
}
void drawTrophies(void) 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);
}
} }
Trophy *getTrophy(char *id) Trophy *getTrophy(char *id)
@ -272,3 +454,25 @@ static void awardCraftTrophy(void)
awardTrophy(trophyId); awardTrophy(trophyId);
} }
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;
}
}

View File

@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define SHORT_DESCRIPTION_LENGTH 40 #define SHORT_DESCRIPTION_LENGTH 40
#define TROPHIES_PER_PAGE 4
#include "../common.h" #include "../common.h"
#include "../json/cJSON.h" #include "../json/cJSON.h"
@ -30,10 +31,16 @@ extern char *readFile(char *filename);
extern int getJSONValue(cJSON *node, char *name, int defValue); extern int getJSONValue(cJSON *node, char *name, int defValue);
extern int getPercent(float current, float total); extern int getPercent(float current, float total);
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
extern void blit(SDL_Texture *texture, int x, int y, int centered);
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
extern void blitScaled(SDL_Texture *t, int x, int y, int w, int h); extern void blitScaled(SDL_Texture *t, int x, int y, int w, int h);
extern char *getTranslatedString(char *string); extern char *getTranslatedString(char *string);
extern SDL_Texture *getTexture(char *filename); extern SDL_Texture *getTexture(char *filename);
extern void playSound(int id); extern void playSound(int id);
extern Widget *getWidget(const char *name, const char *group);
extern void drawWidgets(char *groupName);
extern char *timeToDate(long millis);
extern void textSize(char *text, int size, int *w, int *h);
extern App app; extern App app;
extern Colors colors; extern Colors colors;

View File

@ -371,6 +371,7 @@ struct Trophy {
char title[MAX_DESCRIPTION_LENGTH]; char title[MAX_DESCRIPTION_LENGTH];
char description[MAX_DESCRIPTION_LENGTH]; char description[MAX_DESCRIPTION_LENGTH];
char shortDescription[MAX_DESCRIPTION_LENGTH]; char shortDescription[MAX_DESCRIPTION_LENGTH];
char awardDateStr[MAX_NAME_LENGTH];
int value; int value;
int hidden; int hidden;
int stat; int stat;

View File

@ -128,6 +128,19 @@ char *timeToString(long millis, int showHours)
return TIME; return TIME;
} }
char *timeToDate(long millis)
{
static char DATE[MAX_NAME_LENGTH];
struct tm *timeinfo;
timeinfo = localtime(&millis);
strftime(DATE, MAX_NAME_LENGTH, "%d %b %Y, %H:%M", timeinfo);
return DATE;
}
char *getJSONValueStr(cJSON *node, char *name, char *defValue) char *getJSONValueStr(cJSON *node, char *name, char *defValue)
{ {
cJSON *child; cJSON *child;

View File

@ -20,3 +20,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h" #include "../common.h"
#include "../json/cJSON.h" #include "../json/cJSON.h"
#include "time.h"