diff --git a/src/battle/battle.c b/src/battle/battle.c index f37bbcc..4b1103c 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -115,10 +115,7 @@ static void logic(void) } } - if (battle.status != MS_IN_PROGRESS && battle.missionFinishedTimer <= -FPS * 2) - { - doTrophyAlerts(); - } + app.doTrophyAlerts = (battle.status != MS_IN_PROGRESS && battle.missionFinishedTimer <= -FPS * 2); } doWidgets(); @@ -258,11 +255,6 @@ static void draw(void) drawOptions(); break; } - - if (battle.status != MS_IN_PROGRESS && battle.status != MS_PAUSED && battle.missionFinishedTimer <= -FPS * 2) - { - drawTrophyAlert(); - } } static void drawMenu(void) diff --git a/src/battle/battle.h b/src/battle/battle.h index cebad5b..cc06a60 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -85,8 +85,6 @@ extern void updateAccuracyStats(unsigned int *stats); extern void clearInput(void); extern void runScriptFunction(const char *format, ...); extern void doSpawners(void); -extern void doTrophyAlerts(void); -extern void drawTrophyAlert(void); extern void cancelScript(void); extern void awardTrophy(char *id); extern void initCredits(void); diff --git a/src/challenges/challengeHome.c b/src/challenges/challengeHome.c index 81a9e70..3de4305 100644 --- a/src/challenges/challengeHome.c +++ b/src/challenges/challengeHome.c @@ -202,11 +202,9 @@ static void logic(void) break; } - doTrophyAlerts(); - doWidgets(); - doTrophies(); + app.doTrophyAlerts = 1; } static void doChallenges(void) @@ -313,8 +311,6 @@ static void draw(void) drawOptions(); break; } - - drawTrophyAlert(); } static void drawChallenges(void) diff --git a/src/challenges/challengeHome.h b/src/challenges/challengeHome.h index 51a9f88..40cb0fd 100644 --- a/src/challenges/challengeHome.h +++ b/src/challenges/challengeHome.h @@ -60,13 +60,10 @@ extern void playMusic(char *filename, int loop); extern char *timeToString(long millis, int showHours); extern char *getChallengeDescription(Challenge *c); extern void clearInput(void); -extern void doTrophyAlerts(void); -extern void drawTrophyAlert(void); extern void awardStatsTrophies(void); extern void awardChallengeTrophies(void); extern void initTrophiesDisplay(void); extern void drawTrophies(void); -extern void doTrophies(void); extern App app; extern Battle battle; diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index f9a4923..3397fff 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -181,9 +181,7 @@ static void logic(void) doWidgets(); - doTrophyAlerts(); - - doTrophies(); + app.doTrophyAlerts = 1; } static void doStarSystems(void) @@ -384,8 +382,6 @@ static void draw(void) drawOptions(); break; } - - drawTrophyAlert(); } static void drawPulses(void) diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 4ffd23c..a6f4ced 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -60,13 +60,10 @@ extern StarSystem *getStarSystem(char *name); extern void showOKDialog(void (*callback)(void), const char *format, ...); extern char *getTranslatedString(char *string); extern void clearInput(void); -extern void doTrophyAlerts(void); -extern void drawTrophyAlert(void); extern void awardCampaignTrophies(void); extern void awardStatsTrophies(void); extern void initTrophiesDisplay(void); extern void drawTrophies(void); -extern void doTrophies(void); extern App app; extern Colors colors; diff --git a/src/game/title.c b/src/game/title.c index 085c44b..f7e19c6 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -131,7 +131,7 @@ static void logic(void) doEffects(); - doTrophies(); + app.doTrophyAlerts = 1; doWidgets(); } diff --git a/src/game/title.h b/src/game/title.h index f57d351..35ed3d2 100644 --- a/src/game/title.h +++ b/src/game/title.h @@ -59,7 +59,6 @@ extern void updateAllMissions(void); extern void clearInput(void); extern void initTrophiesDisplay(void); extern void drawTrophies(void); -extern void doTrophies(void); extern App app; extern Battle battle; diff --git a/src/main.c b/src/main.c index 7c18481..c255950 100644 --- a/src/main.c +++ b/src/main.c @@ -108,10 +108,18 @@ int main(int argc, char *argv[]) while (td >= LOGIC_RATE) { + /* let the delegate decide during logic() */ + app.doTrophyAlerts = 0; + app.delegate.logic(); td -= LOGIC_RATE; + if (app.doTrophyAlerts) + { + doTrophyAlerts(); + } + if (app.resetTimeDelta) { td = 0; @@ -126,6 +134,11 @@ int main(int argc, char *argv[]) app.delegate.draw(); + if (app.doTrophyAlerts) + { + drawTrophyAlert(); + } + if (app.modalDialog.type != MD_NONE) { drawModalDialog(); diff --git a/src/main.h b/src/main.h index 0794787..dbe1d8d 100644 --- a/src/main.h +++ b/src/main.h @@ -52,6 +52,8 @@ extern int isControl(int type); extern void clearControl(int type); extern void saveGame(void); extern void initCredits(void); +extern void doTrophyAlerts(void); +extern void drawTrophyAlert(void); App app; Colors colors; diff --git a/src/structs.h b/src/structs.h index 87dc52a..58628ef 100644 --- a/src/structs.h +++ b/src/structs.h @@ -486,6 +486,7 @@ typedef struct { int fullscreen; int musicVolume; int soundVolume; + int doTrophyAlerts; Gameplay gameplay; Mouse mouse; int keyboard[MAX_KEYBOARD_KEYS];