Prototyping stats trophies.
This commit is contained in:
parent
f867e793bd
commit
93dd00c785
|
@ -58,13 +58,17 @@
|
||||||
"id" : "FIRE_100000",
|
"id" : "FIRE_100000",
|
||||||
"title" : "Your name's on one of these!",
|
"title" : "Your name's on one of these!",
|
||||||
"description" : "Fire 100,000 shots",
|
"description" : "Fire 100,000 shots",
|
||||||
"value" : "TROPHY_SILVER"
|
"value" : "TROPHY_SILVER",
|
||||||
|
"stat" : "STAT_SHOTS_FIRED",
|
||||||
|
"statValue" : 10000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "MISSILE_1000",
|
"id" : "MISSILE_1000",
|
||||||
"title" : "Dodge this!",
|
"title" : "Dodge this!",
|
||||||
"description" : "Launch 1,000 missiles",
|
"description" : "Launch 1,000 missiles",
|
||||||
"value" : "TROPHY_SILVER"
|
"value" : "TROPHY_SILVER",
|
||||||
|
"stat" : "STAT_MISSILES_FIRED",
|
||||||
|
"statValue" : 1000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "ATAF_DESTROYED",
|
"id" : "ATAF_DESTROYED",
|
||||||
|
|
|
@ -52,52 +52,54 @@ static int hasRestrictions;
|
||||||
void initChallengeHome(void)
|
void initChallengeHome(void)
|
||||||
{
|
{
|
||||||
startSectionTransition();
|
startSectionTransition();
|
||||||
|
|
||||||
stopMusic();
|
stopMusic();
|
||||||
|
|
||||||
updateAllMissions();
|
updateAllMissions();
|
||||||
|
|
||||||
unlockChallenges();
|
unlockChallenges();
|
||||||
|
|
||||||
|
checkStatTrophies();
|
||||||
|
|
||||||
saveGame();
|
saveGame();
|
||||||
|
|
||||||
app.delegate.logic = &logic;
|
app.delegate.logic = &logic;
|
||||||
app.delegate.draw = &draw;
|
app.delegate.draw = &draw;
|
||||||
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
||||||
|
|
||||||
background = getTexture(getBackgroundTextureName(rand()));
|
background = getTexture(getBackgroundTextureName(rand()));
|
||||||
planetTexture = getTexture(getPlanetTextureName(rand()));
|
planetTexture = getTexture(getPlanetTextureName(rand()));
|
||||||
|
|
||||||
battle.camera.x = battle.camera.y = 0;
|
battle.camera.x = battle.camera.y = 0;
|
||||||
|
|
||||||
planet.x = rand() % SCREEN_WIDTH;
|
planet.x = rand() % SCREEN_WIDTH;
|
||||||
planet.y = rand() % SCREEN_HEIGHT;
|
planet.y = rand() % SCREEN_HEIGHT;
|
||||||
|
|
||||||
startIndex = 0;
|
startIndex = 0;
|
||||||
|
|
||||||
show = SHOW_CHALLENGES;
|
show = SHOW_CHALLENGES;
|
||||||
|
|
||||||
initBackground();
|
initBackground();
|
||||||
|
|
||||||
start = getWidget("start", "challenges");
|
start = getWidget("start", "challenges");
|
||||||
start->action = startChallengeMission;
|
start->action = startChallengeMission;
|
||||||
|
|
||||||
getWidget("resume", "challengesMenu")->action = resume;
|
getWidget("resume", "challengesMenu")->action = resume;
|
||||||
getWidget("stats", "challengesMenu")->action = stats;
|
getWidget("stats", "challengesMenu")->action = stats;
|
||||||
getWidget("options", "challengesMenu")->action = options;
|
getWidget("options", "challengesMenu")->action = options;
|
||||||
getWidget("quit", "challengesMenu")->action = quit;
|
getWidget("quit", "challengesMenu")->action = quit;
|
||||||
|
|
||||||
getWidget("ok", "stats")->action = statsOK;
|
getWidget("ok", "stats")->action = statsOK;
|
||||||
|
|
||||||
/* select first challenge if none chosen */
|
/* select first challenge if none chosen */
|
||||||
if (!game.currentMission)
|
if (!game.currentMission)
|
||||||
{
|
{
|
||||||
game.currentMission = game.challengeMissionHead.next;
|
game.currentMission = game.challengeMissionHead.next;
|
||||||
updateChallengeMissionData();
|
updateChallengeMissionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
endSectionTransition();
|
endSectionTransition();
|
||||||
|
|
||||||
playMusic("music/main/covert_operations.mp3");
|
playMusic("music/main/covert_operations.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,16 +107,16 @@ static void unlockChallenges(void)
|
||||||
{
|
{
|
||||||
Mission *m;
|
Mission *m;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = completedChallenges = totalChallenges = 0;
|
i = completedChallenges = totalChallenges = 0;
|
||||||
|
|
||||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||||
{
|
{
|
||||||
m->available = (i <= completedChallenges || dev.debug);
|
m->available = (i <= completedChallenges || dev.debug);
|
||||||
|
|
||||||
completedChallenges += m->completedChallenges;
|
completedChallenges += m->completedChallenges;
|
||||||
totalChallenges += m->totalChallenges;
|
totalChallenges += m->totalChallenges;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,41 +124,43 @@ static void unlockChallenges(void)
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
{
|
{
|
||||||
handleKeyboard();
|
handleKeyboard();
|
||||||
|
|
||||||
scrollBackground(-0.25, 0);
|
scrollBackground(-0.25, 0);
|
||||||
|
|
||||||
doStars(0.5, 0);
|
doStars(0.5, 0);
|
||||||
|
|
||||||
planet.x -= 0.25;
|
planet.x -= 0.25;
|
||||||
if (planet.x <= -200)
|
if (planet.x <= -200)
|
||||||
{
|
{
|
||||||
planet.x = SCREEN_WIDTH + 128 + (rand() % SCREEN_WIDTH);
|
planet.x = SCREEN_WIDTH + 128 + (rand() % SCREEN_WIDTH);
|
||||||
planet.y = (rand() % SCREEN_HEIGHT - 128);
|
planet.y = (rand() % SCREEN_HEIGHT - 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (show)
|
switch (show)
|
||||||
{
|
{
|
||||||
case SHOW_CHALLENGES:
|
case SHOW_CHALLENGES:
|
||||||
doChallenges();
|
doChallenges();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_MENU:
|
case SHOW_MENU:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_STATS:
|
case SHOW_STATS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doTrophies();
|
||||||
|
|
||||||
doWidgets();
|
doWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doChallenges(void)
|
static void doChallenges(void)
|
||||||
{
|
{
|
||||||
Mission *c;
|
Mission *c;
|
||||||
|
|
||||||
for (c = game.challengeMissionHead.next ; c != NULL ; c = c->next)
|
for (c = game.challengeMissionHead.next ; c != NULL ; c = c->next)
|
||||||
{
|
{
|
||||||
if (app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x, app.mouse.y, 3, 3, c->rect.x, c->rect.y, c->rect.w, c->rect.h))
|
if (app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x, app.mouse.y, 3, 3, c->rect.x, c->rect.y, c->rect.w, c->rect.h))
|
||||||
|
@ -164,14 +168,14 @@ static void doChallenges(void)
|
||||||
if (c->available)
|
if (c->available)
|
||||||
{
|
{
|
||||||
game.currentMission = c;
|
game.currentMission = c;
|
||||||
|
|
||||||
updateChallengeMissionData();
|
updateChallengeMissionData();
|
||||||
|
|
||||||
start->enabled = 1;
|
start->enabled = 1;
|
||||||
|
|
||||||
playSound(SND_GUI_CLICK);
|
playSound(SND_GUI_CLICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,9 +195,9 @@ static void addRestriction(char *buffer, int restricted, char *description)
|
||||||
{
|
{
|
||||||
strcat(buffer, ". ");
|
strcat(buffer, ". ");
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(buffer, description);
|
strcat(buffer, description);
|
||||||
|
|
||||||
hasRestrictions = 1;
|
hasRestrictions = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,51 +205,53 @@ static void addRestriction(char *buffer, int restricted, char *description)
|
||||||
static char *listRestrictions(void)
|
static char *listRestrictions(void)
|
||||||
{
|
{
|
||||||
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
||||||
|
|
||||||
memset(textBuffer, '\0', MAX_DESCRIPTION_LENGTH);
|
memset(textBuffer, '\0', MAX_DESCRIPTION_LENGTH);
|
||||||
|
|
||||||
hasRestrictions = 0;
|
hasRestrictions = 0;
|
||||||
|
|
||||||
addRestriction(textBuffer, game.currentMission->challengeData.noMissiles, _("No Missiles"));
|
addRestriction(textBuffer, game.currentMission->challengeData.noMissiles, _("No Missiles"));
|
||||||
addRestriction(textBuffer, game.currentMission->challengeData.noECM, _("No ECM"));
|
addRestriction(textBuffer, game.currentMission->challengeData.noECM, _("No ECM"));
|
||||||
addRestriction(textBuffer, game.currentMission->challengeData.noBoost, _("No Boost"));
|
addRestriction(textBuffer, game.currentMission->challengeData.noBoost, _("No Boost"));
|
||||||
addRestriction(textBuffer, game.currentMission->challengeData.noGuns, _("No Guns"));
|
addRestriction(textBuffer, game.currentMission->challengeData.noGuns, _("No Guns"));
|
||||||
|
|
||||||
return strlen(textBuffer) > 0 ? textBuffer : "-";
|
return strlen(textBuffer) > 0 ? textBuffer : "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(void)
|
static void draw(void)
|
||||||
{
|
{
|
||||||
drawBackground(background);
|
drawBackground(background);
|
||||||
|
|
||||||
blit(planetTexture, planet.x, planet.y, 1);
|
blit(planetTexture, planet.x, planet.y, 1);
|
||||||
|
|
||||||
drawStars();
|
drawStars();
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, _("Challenges"));
|
drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, _("Challenges"));
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", completedChallenges, totalChallenges);
|
drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", completedChallenges, totalChallenges);
|
||||||
|
|
||||||
drawChallenges();
|
drawChallenges();
|
||||||
|
|
||||||
switch (show)
|
switch (show)
|
||||||
{
|
{
|
||||||
case SHOW_CHALLENGES:
|
case SHOW_CHALLENGES:
|
||||||
drawWidgets("challenges");
|
drawWidgets("challenges");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_MENU:
|
case SHOW_MENU:
|
||||||
drawMenu();
|
drawMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_STATS:
|
case SHOW_STATS:
|
||||||
drawStats();
|
drawStats();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
drawOptions();
|
drawOptions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doTrophyAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawChallenges(void)
|
static void drawChallenges(void)
|
||||||
|
@ -254,23 +260,23 @@ static void drawChallenges(void)
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
int i, endIndex;
|
int i, endIndex;
|
||||||
|
|
||||||
r.x = 135;
|
r.x = 135;
|
||||||
r.y = 165;
|
r.y = 165;
|
||||||
r.w = r.h = 96;
|
r.w = r.h = 96;
|
||||||
|
|
||||||
endIndex = startIndex + MAX_ITEMS;
|
endIndex = startIndex + MAX_ITEMS;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||||
{
|
{
|
||||||
m->rect = r;
|
m->rect = r;
|
||||||
|
|
||||||
if (i >= startIndex && i <= endIndex)
|
if (i >= startIndex && i <= endIndex)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
|
|
||||||
if (game.currentMission == m)
|
if (game.currentMission == m)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(app.renderer, 64, 128, 200, SDL_ALPHA_OPAQUE);
|
SDL_SetRenderDrawColor(app.renderer, 64, 128, 200, SDL_ALPHA_OPAQUE);
|
||||||
|
@ -283,9 +289,9 @@ static void drawChallenges(void)
|
||||||
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawText(r.x + (r.w / 2), r.y + 28, 30, TA_CENTER, colors.white, "%d", i + 1);
|
drawText(r.x + (r.w / 2), r.y + 28, 30, TA_CENTER, colors.white, "%d", i + 1);
|
||||||
|
|
||||||
if (m->available)
|
if (m->available)
|
||||||
{
|
{
|
||||||
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, (m->completedChallenges < m->totalChallenges) ? colors.white : colors.green, "%d / %d", m->completedChallenges, m->totalChallenges);
|
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, (m->completedChallenges < m->totalChallenges) ? colors.white : colors.green, "%d / %d", m->completedChallenges, m->totalChallenges);
|
||||||
|
@ -294,54 +300,54 @@ static void drawChallenges(void)
|
||||||
{
|
{
|
||||||
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, colors.lightGrey, _("[Locked]"));
|
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, colors.lightGrey, _("[Locked]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
r.x += 150;
|
r.x += 150;
|
||||||
|
|
||||||
if (r.x > SCREEN_WIDTH - 200)
|
if (r.x > SCREEN_WIDTH - 200)
|
||||||
{
|
{
|
||||||
r.y += 165;
|
r.y += 165;
|
||||||
r.x = 135;
|
r.x = 135;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.y = SCREEN_HEIGHT - 245;
|
r.y = SCREEN_HEIGHT - 245;
|
||||||
r.x = 100;
|
r.x = 100;
|
||||||
r.w = SCREEN_WIDTH - 200;
|
r.w = SCREEN_WIDTH - 200;
|
||||||
r.h = 150;
|
r.h = 150;
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
|
|
||||||
r.y = 240;
|
r.y = 240;
|
||||||
|
|
||||||
if (game.currentMission)
|
if (game.currentMission)
|
||||||
{
|
{
|
||||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - r.y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - r.y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
||||||
|
|
||||||
r.y -= 50;
|
r.y -= 50;
|
||||||
c = game.currentMission->challengeData.challenges[0];
|
c = game.currentMission->challengeData.challenges[0];
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Craft: %s"), game.currentMission->craft);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Craft: %s"), game.currentMission->craft);
|
||||||
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "1. %s", getChallengeDescription(c));
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "1. %s", getChallengeDescription(c));
|
||||||
|
|
||||||
r.y -= 30;
|
r.y -= 30;
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Time Limit: %s"), timeLimit);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Time Limit: %s"), timeLimit);
|
||||||
|
|
||||||
c = game.currentMission->challengeData.challenges[1];
|
c = game.currentMission->challengeData.challenges[1];
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "2. %s", getChallengeDescription(c));
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "2. %s", getChallengeDescription(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
r.y -= 30;
|
r.y -= 30;
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, hasRestrictions ? colors.red : colors.white, _("Restrictions: %s"), restrictions);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, hasRestrictions ? colors.red : colors.white, _("Restrictions: %s"), restrictions);
|
||||||
|
|
||||||
c = game.currentMission->challengeData.challenges[2];
|
c = game.currentMission->challengeData.challenges[2];
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
|
@ -353,22 +359,22 @@ static void drawChallenges(void)
|
||||||
static void drawMenu(void)
|
static void drawMenu(void)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||||
SDL_RenderFillRect(app.renderer, NULL);
|
SDL_RenderFillRect(app.renderer, NULL);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
r.w = 400;
|
r.w = 400;
|
||||||
r.h = 400;
|
r.h = 400;
|
||||||
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
||||||
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
|
|
||||||
drawWidgets("challengesMenu");
|
drawWidgets("challengesMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,30 +386,30 @@ static void resume(void)
|
||||||
static void options(void)
|
static void options(void)
|
||||||
{
|
{
|
||||||
show = SHOW_OPTIONS;
|
show = SHOW_OPTIONS;
|
||||||
|
|
||||||
initOptions(returnFromOptions);
|
initOptions(returnFromOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stats(void)
|
static void stats(void)
|
||||||
{
|
{
|
||||||
selectWidget("ok", "stats");
|
selectWidget("ok", "stats");
|
||||||
|
|
||||||
show = SHOW_STATS;
|
show = SHOW_STATS;
|
||||||
|
|
||||||
initStatsDisplay();
|
initStatsDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void statsOK(void)
|
static void statsOK(void)
|
||||||
{
|
{
|
||||||
selectWidget("resume", "challengesMenu");
|
selectWidget("resume", "challengesMenu");
|
||||||
|
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void returnFromOptions(void)
|
static void returnFromOptions(void)
|
||||||
{
|
{
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
|
|
||||||
selectWidget("resume", "challengesMenu");
|
selectWidget("resume", "challengesMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,20 +429,20 @@ static void handleKeyboard(void)
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
playSound(SND_GUI_CLOSE);
|
playSound(SND_GUI_CLOSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_MENU:
|
case SHOW_MENU:
|
||||||
show = SHOW_CHALLENGES;
|
show = SHOW_CHALLENGES;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
case SHOW_STATS:
|
case SHOW_STATS:
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
selectWidget("resume", "challengesMenu");
|
selectWidget("resume", "challengesMenu");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
playSound(SND_GUI_CLOSE);
|
playSound(SND_GUI_CLOSE);
|
||||||
|
|
||||||
clearInput();
|
clearInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,6 +450,6 @@ static void handleKeyboard(void)
|
||||||
static void startChallengeMission(void)
|
static void startChallengeMission(void)
|
||||||
{
|
{
|
||||||
initBattle();
|
initBattle();
|
||||||
|
|
||||||
loadMission(game.currentMission->filename);
|
loadMission(game.currentMission->filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ 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 drawTrophyAlert(void);
|
||||||
|
extern void checkStatTrophies(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
|
|
@ -65,73 +65,75 @@ static Widget *startMissionButton;
|
||||||
void initGalacticMap(void)
|
void initGalacticMap(void)
|
||||||
{
|
{
|
||||||
show = SHOW_GALAXY;
|
show = SHOW_GALAXY;
|
||||||
|
|
||||||
startSectionTransition();
|
startSectionTransition();
|
||||||
|
|
||||||
stopMusic();
|
stopMusic();
|
||||||
|
|
||||||
app.delegate.logic = &logic;
|
app.delegate.logic = &logic;
|
||||||
app.delegate.draw = &draw;
|
app.delegate.draw = &draw;
|
||||||
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
||||||
|
|
||||||
background = getTexture("gfx/backgrounds/background02.jpg");
|
background = getTexture("gfx/backgrounds/background02.jpg");
|
||||||
|
|
||||||
starSystemTexture = getTexture("gfx/galaxy/starSystem.png");
|
starSystemTexture = getTexture("gfx/galaxy/starSystem.png");
|
||||||
|
|
||||||
arrowTexture = getTexture("gfx/galaxy/arrow.png");
|
arrowTexture = getTexture("gfx/galaxy/arrow.png");
|
||||||
|
|
||||||
selectedStarSystem = getStarSystem(game.selectedStarSystem);
|
selectedStarSystem = getStarSystem(game.selectedStarSystem);
|
||||||
|
|
||||||
centerOnSelectedStarSystem();
|
centerOnSelectedStarSystem();
|
||||||
|
|
||||||
updateAllMissions();
|
updateAllMissions();
|
||||||
|
|
||||||
updatePandoranAdvance();
|
updatePandoranAdvance();
|
||||||
|
|
||||||
|
checkStatTrophies();
|
||||||
|
|
||||||
saveGame();
|
saveGame();
|
||||||
|
|
||||||
pulseTimer = 0;
|
pulseTimer = 0;
|
||||||
|
|
||||||
arrowPulse = 0;
|
arrowPulse = 0;
|
||||||
|
|
||||||
/* clear the pulses */
|
/* clear the pulses */
|
||||||
destroyGalacticMap();
|
destroyGalacticMap();
|
||||||
|
|
||||||
initBackground();
|
initBackground();
|
||||||
|
|
||||||
startMissionButton = getWidget("startMission", "starSystem");
|
startMissionButton = getWidget("startMission", "starSystem");
|
||||||
startMissionButton->action = startMission;
|
startMissionButton->action = startMission;
|
||||||
|
|
||||||
getWidget("resume", "galacticMap")->action = resume;
|
getWidget("resume", "galacticMap")->action = resume;
|
||||||
getWidget("stats", "galacticMap")->action = stats;
|
getWidget("stats", "galacticMap")->action = stats;
|
||||||
getWidget("options", "galacticMap")->action = options;
|
getWidget("options", "galacticMap")->action = options;
|
||||||
getWidget("quit", "galacticMap")->action = quit;
|
getWidget("quit", "galacticMap")->action = quit;
|
||||||
|
|
||||||
getWidget("ok", "stats")->action = statsOK;
|
getWidget("ok", "stats")->action = statsOK;
|
||||||
|
|
||||||
getWidget("ok", "fallen")->action = fallenOK;
|
getWidget("ok", "fallen")->action = fallenOK;
|
||||||
|
|
||||||
endSectionTransition();
|
endSectionTransition();
|
||||||
|
|
||||||
playMusic("music/main/Pressure.ogg");
|
playMusic("music/main/Pressure.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updatePandoranAdvance(void)
|
static void updatePandoranAdvance(void)
|
||||||
{
|
{
|
||||||
StarSystem *starSystem, *fallenStarSystem;
|
StarSystem *starSystem, *fallenStarSystem;
|
||||||
|
|
||||||
fallenStarSystem = NULL;
|
fallenStarSystem = NULL;
|
||||||
|
|
||||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||||
{
|
{
|
||||||
if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0)
|
if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0)
|
||||||
{
|
{
|
||||||
starSystem->side = SIDE_PANDORAN;
|
starSystem->side = SIDE_PANDORAN;
|
||||||
|
|
||||||
fallenStarSystem = starSystem;
|
fallenStarSystem = starSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fallenStarSystem)
|
if (fallenStarSystem)
|
||||||
{
|
{
|
||||||
showOKDialog(&fallenOK, _("%s has fallen to the Pandorans"), fallenStarSystem->name);
|
showOKDialog(&fallenOK, _("%s has fallen to the Pandorans"), fallenStarSystem->name);
|
||||||
|
@ -141,9 +143,9 @@ static void updatePandoranAdvance(void)
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
{
|
{
|
||||||
handleKeyboard();
|
handleKeyboard();
|
||||||
|
|
||||||
handleMouse();
|
handleMouse();
|
||||||
|
|
||||||
switch (show)
|
switch (show)
|
||||||
{
|
{
|
||||||
case SHOW_GALAXY:
|
case SHOW_GALAXY:
|
||||||
|
@ -152,24 +154,26 @@ static void logic(void)
|
||||||
scrollBackground(-ssx, -ssy);
|
scrollBackground(-ssx, -ssy);
|
||||||
doStars(ssx, ssy);
|
doStars(ssx, ssy);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_STAR_SYSTEM:
|
case SHOW_STAR_SYSTEM:
|
||||||
doStarSystemView();
|
doStarSystemView();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
doPulses();
|
doPulses();
|
||||||
|
|
||||||
if (pulseTimer % FPS == 0)
|
if (pulseTimer % FPS == 0)
|
||||||
{
|
{
|
||||||
addPulses();
|
addPulses();
|
||||||
}
|
}
|
||||||
|
|
||||||
pulseTimer++;
|
pulseTimer++;
|
||||||
pulseTimer %= (FPS * 60);
|
pulseTimer %= (FPS * 60);
|
||||||
|
|
||||||
arrowPulse += 0.1;
|
arrowPulse += 0.1;
|
||||||
|
|
||||||
|
doTrophies();
|
||||||
|
|
||||||
doWidgets();
|
doWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,44 +181,44 @@ static void doStarSystems(void)
|
||||||
{
|
{
|
||||||
StarSystem *starSystem;
|
StarSystem *starSystem;
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
|
|
||||||
if (!scrollingMap)
|
if (!scrollingMap)
|
||||||
{
|
{
|
||||||
cx = app.mouse.x - 32;
|
cx = app.mouse.x - 32;
|
||||||
cy = app.mouse.y - 32;
|
cy = app.mouse.y - 32;
|
||||||
|
|
||||||
cameraMin.x = cameraMin.y = 99999;
|
cameraMin.x = cameraMin.y = 99999;
|
||||||
cameraMax.x = cameraMax.y = -99999;
|
cameraMax.x = cameraMax.y = -99999;
|
||||||
|
|
||||||
selectedStarSystem = NULL;
|
selectedStarSystem = NULL;
|
||||||
|
|
||||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||||
{
|
{
|
||||||
cameraMin.x = MIN(cameraMin.x, starSystem->x);
|
cameraMin.x = MIN(cameraMin.x, starSystem->x);
|
||||||
cameraMin.y = MIN(cameraMin.y, starSystem->y);
|
cameraMin.y = MIN(cameraMin.y, starSystem->y);
|
||||||
|
|
||||||
cameraMax.x = MAX(cameraMax.x, starSystem->x);
|
cameraMax.x = MAX(cameraMax.x, starSystem->x);
|
||||||
cameraMax.y = MAX(cameraMax.y, starSystem->y);
|
cameraMax.y = MAX(cameraMax.y, starSystem->y);
|
||||||
|
|
||||||
if (starSystem->availableMissions > 0 && collision(cx, cy, 64, 64, starSystem->x - camera.x, starSystem->y - camera.y, 4, 4))
|
if (starSystem->availableMissions > 0 && collision(cx, cy, 64, 64, starSystem->x - camera.x, starSystem->y - camera.y, 4, 4))
|
||||||
{
|
{
|
||||||
if (selectedStarSystem != starSystem)
|
if (selectedStarSystem != starSystem)
|
||||||
{
|
{
|
||||||
selectedStarSystem = starSystem;
|
selectedStarSystem = starSystem;
|
||||||
|
|
||||||
if (app.mouse.button[SDL_BUTTON_LEFT])
|
if (app.mouse.button[SDL_BUTTON_LEFT])
|
||||||
{
|
{
|
||||||
selectStarSystem();
|
selectStarSystem();
|
||||||
|
|
||||||
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cameraMin.x -= SCREEN_WIDTH / 2;
|
cameraMin.x -= SCREEN_WIDTH / 2;
|
||||||
cameraMin.y -= SCREEN_HEIGHT / 2;
|
cameraMin.y -= SCREEN_HEIGHT / 2;
|
||||||
|
|
||||||
cameraMax.x -= SCREEN_WIDTH / 2;
|
cameraMax.x -= SCREEN_WIDTH / 2;
|
||||||
cameraMax.y -= SCREEN_HEIGHT / 2;
|
cameraMax.y -= SCREEN_HEIGHT / 2;
|
||||||
}
|
}
|
||||||
|
@ -223,29 +227,29 @@ static void doStarSystems(void)
|
||||||
static void scrollGalaxy(void)
|
static void scrollGalaxy(void)
|
||||||
{
|
{
|
||||||
int lastX, lastY;
|
int lastX, lastY;
|
||||||
|
|
||||||
lastX = camera.x;
|
lastX = camera.x;
|
||||||
lastY = camera.y;
|
lastY = camera.y;
|
||||||
|
|
||||||
ssx = ssy = 0;
|
ssx = ssy = 0;
|
||||||
|
|
||||||
if (scrollingMap)
|
if (scrollingMap)
|
||||||
{
|
{
|
||||||
camera.x -= app.mouse.dx * 1.5;
|
camera.x -= app.mouse.dx * 1.5;
|
||||||
camera.y -= app.mouse.dy * 1.5;
|
camera.y -= app.mouse.dy * 1.5;
|
||||||
|
|
||||||
ssx = -(app.mouse.dx / 3);
|
ssx = -(app.mouse.dx / 3);
|
||||||
ssy = -(app.mouse.dy / 3);
|
ssy = -(app.mouse.dy / 3);
|
||||||
|
|
||||||
camera.x = MAX(cameraMin.x, MIN(camera.x, cameraMax.x));
|
camera.x = MAX(cameraMin.x, MIN(camera.x, cameraMax.x));
|
||||||
camera.y = MAX(cameraMin.y, MIN(camera.y, cameraMax.y));
|
camera.y = MAX(cameraMin.y, MIN(camera.y, cameraMax.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastX == camera.x)
|
if (lastX == camera.x)
|
||||||
{
|
{
|
||||||
ssx = 0;
|
ssx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastY == camera.y)
|
if (lastY == camera.y)
|
||||||
{
|
{
|
||||||
ssy = 0;
|
ssy = 0;
|
||||||
|
@ -255,7 +259,7 @@ static void scrollGalaxy(void)
|
||||||
static void doStarSystemView(void)
|
static void doStarSystemView(void)
|
||||||
{
|
{
|
||||||
Mission *mission;
|
Mission *mission;
|
||||||
|
|
||||||
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||||
{
|
{
|
||||||
if (mission->available && app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x - app.mouse.w / 2, app.mouse.y - app.mouse.h / 2, app.mouse.w, app.mouse.h, mission->rect.x, mission->rect.y, mission->rect.w, mission->rect.h))
|
if (mission->available && app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x - app.mouse.w / 2, app.mouse.y - app.mouse.h / 2, app.mouse.w, app.mouse.h, mission->rect.x, mission->rect.y, mission->rect.w, mission->rect.h))
|
||||||
|
@ -264,7 +268,7 @@ static void doStarSystemView(void)
|
||||||
{
|
{
|
||||||
playSound(SND_GUI_CLICK);
|
playSound(SND_GUI_CLICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
game.currentMission = mission;
|
game.currentMission = mission;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -275,18 +279,18 @@ static void addPulses(void)
|
||||||
{
|
{
|
||||||
Pulse *pulse;
|
Pulse *pulse;
|
||||||
StarSystem *starSystem;
|
StarSystem *starSystem;
|
||||||
|
|
||||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||||
{
|
{
|
||||||
if (starSystem->completedMissions < starSystem->availableMissions)
|
if (starSystem->completedMissions < starSystem->availableMissions)
|
||||||
{
|
{
|
||||||
pulse = malloc(sizeof(Pulse));
|
pulse = malloc(sizeof(Pulse));
|
||||||
memset(pulse, 0, sizeof(Pulse));
|
memset(pulse, 0, sizeof(Pulse));
|
||||||
|
|
||||||
pulse->x = starSystem->x;
|
pulse->x = starSystem->x;
|
||||||
pulse->y = starSystem->y;
|
pulse->y = starSystem->y;
|
||||||
pulse->life = 255;
|
pulse->life = 255;
|
||||||
|
|
||||||
if (!starSystem->isSol)
|
if (!starSystem->isSol)
|
||||||
{
|
{
|
||||||
pulse->r = 255;
|
pulse->r = 255;
|
||||||
|
@ -295,7 +299,7 @@ static void addPulses(void)
|
||||||
{
|
{
|
||||||
pulse->g = 255;
|
pulse->g = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
pulseTail->next = pulse;
|
pulseTail->next = pulse;
|
||||||
pulseTail = pulse;
|
pulseTail = pulse;
|
||||||
}
|
}
|
||||||
|
@ -305,26 +309,26 @@ static void addPulses(void)
|
||||||
static void doPulses(void)
|
static void doPulses(void)
|
||||||
{
|
{
|
||||||
Pulse *pulse, *prev;
|
Pulse *pulse, *prev;
|
||||||
|
|
||||||
prev = &pulseHead;
|
prev = &pulseHead;
|
||||||
|
|
||||||
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
||||||
{
|
{
|
||||||
pulse->size += 0.5;
|
pulse->size += 0.5;
|
||||||
pulse->life--;
|
pulse->life--;
|
||||||
|
|
||||||
if (pulse->life <= 0)
|
if (pulse->life <= 0)
|
||||||
{
|
{
|
||||||
if (pulse == pulseTail)
|
if (pulse == pulseTail)
|
||||||
{
|
{
|
||||||
pulseTail = prev;
|
pulseTail = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev->next = pulse->next;
|
prev->next = pulse->next;
|
||||||
free(pulse);
|
free(pulse);
|
||||||
pulse = prev;
|
pulse = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = pulse;
|
prev = pulse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,39 +336,41 @@ static void doPulses(void)
|
||||||
static void draw(void)
|
static void draw(void)
|
||||||
{
|
{
|
||||||
drawBackground(background);
|
drawBackground(background);
|
||||||
|
|
||||||
drawStars();
|
drawStars();
|
||||||
|
|
||||||
drawGalaxy();
|
drawGalaxy();
|
||||||
|
|
||||||
drawPulses();
|
drawPulses();
|
||||||
|
|
||||||
drawInfoBars();
|
drawInfoBars();
|
||||||
|
|
||||||
switch (show)
|
switch (show)
|
||||||
{
|
{
|
||||||
case SHOW_STAR_SYSTEM:
|
case SHOW_STAR_SYSTEM:
|
||||||
drawStarSystemDetail();
|
drawStarSystemDetail();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_MENU:
|
case SHOW_MENU:
|
||||||
drawMenu();
|
drawMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_STATS:
|
case SHOW_STATS:
|
||||||
drawStats();
|
drawStats();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
drawOptions();
|
drawOptions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawTrophyAlerts();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawPulses(void)
|
static void drawPulses(void)
|
||||||
{
|
{
|
||||||
Pulse *pulse;
|
Pulse *pulse;
|
||||||
|
|
||||||
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
||||||
{
|
{
|
||||||
drawCircle(pulse->x - camera.x, pulse->y - camera.y, pulse->size, pulse->r, pulse->g, pulse->b, pulse->life);
|
drawCircle(pulse->x - camera.x, pulse->y - camera.y, pulse->size, pulse->r, pulse->g, pulse->b, pulse->life);
|
||||||
|
@ -375,7 +381,7 @@ static void centerOnSelectedStarSystem(void)
|
||||||
{
|
{
|
||||||
camera.x = selectedStarSystem->x;
|
camera.x = selectedStarSystem->x;
|
||||||
camera.x -= SCREEN_WIDTH / 2;
|
camera.x -= SCREEN_WIDTH / 2;
|
||||||
|
|
||||||
camera.y = selectedStarSystem->y;
|
camera.y = selectedStarSystem->y;
|
||||||
camera.y -= SCREEN_HEIGHT / 2;
|
camera.y -= SCREEN_HEIGHT / 2;
|
||||||
}
|
}
|
||||||
|
@ -386,40 +392,40 @@ static void drawGalaxy(void)
|
||||||
StarSystem *starSystem;
|
StarSystem *starSystem;
|
||||||
SDL_Color color;
|
SDL_Color color;
|
||||||
float ax, ay, aa;
|
float ax, ay, aa;
|
||||||
|
|
||||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||||
{
|
{
|
||||||
r.x = starSystem->x - camera.x;
|
r.x = starSystem->x - camera.x;
|
||||||
r.y = starSystem->y - camera.y;
|
r.y = starSystem->y - camera.y;
|
||||||
|
|
||||||
blit(starSystemTexture, r.x, r.y, 1);
|
blit(starSystemTexture, r.x, r.y, 1);
|
||||||
|
|
||||||
switch (starSystem->side)
|
switch (starSystem->side)
|
||||||
{
|
{
|
||||||
case SIDE_CSN:
|
case SIDE_CSN:
|
||||||
color = colors.cyan;
|
color = colors.cyan;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIDE_UNF:
|
case SIDE_UNF:
|
||||||
color = colors.white;
|
color = colors.white;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIDE_PANDORAN:
|
case SIDE_PANDORAN:
|
||||||
color = colors.red;
|
color = colors.red;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawText(r.x, r.y + 12, 14, TA_CENTER, color, starSystem->name);
|
drawText(r.x, r.y + 12, 14, TA_CENTER, color, starSystem->name);
|
||||||
|
|
||||||
if (starSystem->completedMissions < starSystem->availableMissions)
|
if (starSystem->completedMissions < starSystem->availableMissions)
|
||||||
{
|
{
|
||||||
ax = r.x;
|
ax = r.x;
|
||||||
ay = r.y;
|
ay = r.y;
|
||||||
aa = -1;
|
aa = -1;
|
||||||
|
|
||||||
ax = MAX(MIN(SCREEN_WIDTH - 64, ax), 64);
|
ax = MAX(MIN(SCREEN_WIDTH - 64, ax), 64);
|
||||||
ay = MAX(MIN(SCREEN_HEIGHT - 64, ay), 64);
|
ay = MAX(MIN(SCREEN_HEIGHT - 64, ay), 64);
|
||||||
|
|
||||||
if (r.x < 0)
|
if (r.x < 0)
|
||||||
{
|
{
|
||||||
ax = 64 + (sin(arrowPulse) * 10);
|
ax = 64 + (sin(arrowPulse) * 10);
|
||||||
|
@ -440,7 +446,7 @@ static void drawGalaxy(void)
|
||||||
ay = SCREEN_HEIGHT - 64 + (sin(arrowPulse) * 10);
|
ay = SCREEN_HEIGHT - 64 + (sin(arrowPulse) * 10);
|
||||||
aa = 180;
|
aa = 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aa != -1)
|
if (aa != -1)
|
||||||
{
|
{
|
||||||
if (!starSystem->isSol)
|
if (!starSystem->isSol)
|
||||||
|
@ -451,7 +457,7 @@ static void drawGalaxy(void)
|
||||||
{
|
{
|
||||||
SDL_SetTextureColorMod(arrowTexture, 0, 255, 0);
|
SDL_SetTextureColorMod(arrowTexture, 0, 255, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
blitRotated(arrowTexture, ax, ay, aa);
|
blitRotated(arrowTexture, ax, ay, aa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,22 +467,22 @@ static void drawGalaxy(void)
|
||||||
static void drawInfoBars(void)
|
static void drawInfoBars(void)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
if (show != SHOW_STAR_SYSTEM && selectedStarSystem != NULL)
|
if (show != SHOW_STAR_SYSTEM && selectedStarSystem != NULL)
|
||||||
{
|
{
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = SCREEN_HEIGHT - 35;
|
r.y = SCREEN_HEIGHT - 35;
|
||||||
r.w = SCREEN_WIDTH;
|
r.w = SCREEN_WIDTH;
|
||||||
r.h = 35;
|
r.h = 35;
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 200);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 200);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, 18, TA_CENTER, colors.white, selectedStarSystem->description);
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, 18, TA_CENTER, colors.white, selectedStarSystem->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.w = SCREEN_WIDTH;
|
r.w = SCREEN_WIDTH;
|
||||||
|
@ -485,7 +491,7 @@ static void drawInfoBars(void)
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 200);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 200);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
drawText((SCREEN_WIDTH / 2), 5, 18, TA_CENTER, colors.white, _("Missions: %d / %d"), game.completedMissions, game.availableMissions);
|
drawText((SCREEN_WIDTH / 2), 5, 18, TA_CENTER, colors.white, _("Missions: %d / %d"), game.completedMissions, game.availableMissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,66 +511,66 @@ static void drawStarSystemDetail(void)
|
||||||
int y;
|
int y;
|
||||||
Mission *mission;
|
Mission *mission;
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
r.w = 900;
|
r.w = 900;
|
||||||
r.h = 600;
|
r.h = 600;
|
||||||
r.x = (SCREEN_WIDTH / 2) - (r.w / 2);
|
r.x = (SCREEN_WIDTH / 2) - (r.w / 2);
|
||||||
r.y = (SCREEN_HEIGHT / 2) - (r.h / 2);
|
r.y = (SCREEN_HEIGHT / 2) - (r.h / 2);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 225);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 225);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 200);
|
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 200);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
y = 70;
|
y = 70;
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.cyan, selectedStarSystem->name);
|
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.cyan, selectedStarSystem->name);
|
||||||
|
|
||||||
SDL_RenderDrawLine(app.renderer, r.x, 120, r.x + r.w - 1, 120);
|
SDL_RenderDrawLine(app.renderer, r.x, 120, r.x + r.w - 1, 120);
|
||||||
|
|
||||||
SDL_RenderDrawLine(app.renderer, 515, 120, 515, 660);
|
SDL_RenderDrawLine(app.renderer, 515, 120, 515, 660);
|
||||||
|
|
||||||
y += 80;
|
y += 80;
|
||||||
|
|
||||||
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||||
{
|
{
|
||||||
mission->rect.x = 200;
|
mission->rect.x = 200;
|
||||||
mission->rect.y = y - 2;
|
mission->rect.y = y - 2;
|
||||||
mission->rect.w = 300;
|
mission->rect.w = 300;
|
||||||
mission->rect.h = 40;
|
mission->rect.h = 40;
|
||||||
|
|
||||||
if (mission == game.currentMission)
|
if (mission == game.currentMission)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(app.renderer, 32, 64, 128, 255);
|
SDL_SetRenderDrawColor(app.renderer, 32, 64, 128, 255);
|
||||||
SDL_RenderFillRect(app.renderer, &mission->rect);
|
SDL_RenderFillRect(app.renderer, &mission->rect);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 64, 96, 196, 255);
|
SDL_SetRenderDrawColor(app.renderer, 64, 96, 196, 255);
|
||||||
SDL_RenderDrawRect(app.renderer, &mission->rect);
|
SDL_RenderDrawRect(app.renderer, &mission->rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mission->available)
|
if (mission->available)
|
||||||
{
|
{
|
||||||
drawText(210, y, 24, TA_LEFT, mission->completed ? colors.lightGrey : colors.yellow, mission->name);
|
drawText(210, y, 24, TA_LEFT, mission->completed ? colors.lightGrey : colors.yellow, mission->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 50;
|
y += 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.currentMission->available)
|
if (game.currentMission->available)
|
||||||
{
|
{
|
||||||
drawText(525, 135, 18, TA_LEFT, colors.lightGrey, _("Pilot: %s"), game.currentMission->pilot);
|
drawText(525, 135, 18, TA_LEFT, colors.lightGrey, _("Pilot: %s"), game.currentMission->pilot);
|
||||||
drawText(525, 160, 18, TA_LEFT, colors.lightGrey, _("Craft: %s"), game.currentMission->craft);
|
drawText(525, 160, 18, TA_LEFT, colors.lightGrey, _("Craft: %s"), game.currentMission->craft);
|
||||||
drawText(525, 185, 18, TA_LEFT, colors.lightGrey, _("Squadron: %s"), game.currentMission->squadron);
|
drawText(525, 185, 18, TA_LEFT, colors.lightGrey, _("Squadron: %s"), game.currentMission->squadron);
|
||||||
|
|
||||||
limitTextWidth(500);
|
limitTextWidth(500);
|
||||||
drawText(525, 230, 22, TA_LEFT, colors.white, game.currentMission->description);
|
drawText(525, 230, 22, TA_LEFT, colors.white, game.currentMission->description);
|
||||||
limitTextWidth(0);
|
limitTextWidth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.currentMission->completed)
|
if (game.currentMission->completed)
|
||||||
{
|
{
|
||||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.green, _("This mission has been completed."));
|
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.green, _("This mission has been completed."));
|
||||||
|
@ -573,16 +579,16 @@ static void drawStarSystemDetail(void)
|
||||||
{
|
{
|
||||||
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an Epic Mission."));
|
drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an Epic Mission."));
|
||||||
}
|
}
|
||||||
|
|
||||||
startMissionButton->enabled = (!game.currentMission->completed || selectedStarSystem->isSol);
|
startMissionButton->enabled = (!game.currentMission->completed || selectedStarSystem->isSol);
|
||||||
|
|
||||||
drawWidgets("starSystem");
|
drawWidgets("starSystem");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fallenOK(void)
|
static void fallenOK(void)
|
||||||
{
|
{
|
||||||
show = SHOW_GALAXY;
|
show = SHOW_GALAXY;
|
||||||
|
|
||||||
app.modalDialog.type = MD_NONE;
|
app.modalDialog.type = MD_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,24 +603,24 @@ static void handleKeyboard(void)
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
playSound(SND_GUI_CLOSE);
|
playSound(SND_GUI_CLOSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_STAR_SYSTEM:
|
case SHOW_STAR_SYSTEM:
|
||||||
show = SHOW_GALAXY;
|
show = SHOW_GALAXY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_MENU:
|
case SHOW_MENU:
|
||||||
show = SHOW_GALAXY;
|
show = SHOW_GALAXY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
case SHOW_STATS:
|
case SHOW_STATS:
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
selectWidget("resume", "galacticMap");
|
selectWidget("resume", "galacticMap");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
playSound(SND_GUI_CLOSE);
|
playSound(SND_GUI_CLOSE);
|
||||||
|
|
||||||
clearInput();
|
clearInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,29 +643,29 @@ static void handleMouse(void)
|
||||||
static void startMission(void)
|
static void startMission(void)
|
||||||
{
|
{
|
||||||
initBattle();
|
initBattle();
|
||||||
|
|
||||||
loadMission(game.currentMission->filename);
|
loadMission(game.currentMission->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawMenu(void)
|
static void drawMenu(void)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||||
SDL_RenderFillRect(app.renderer, NULL);
|
SDL_RenderFillRect(app.renderer, NULL);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
r.w = 400;
|
r.w = 400;
|
||||||
r.h = 400;
|
r.h = 400;
|
||||||
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
||||||
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
|
|
||||||
drawWidgets("galacticMap");
|
drawWidgets("galacticMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,30 +677,30 @@ static void resume(void)
|
||||||
static void options(void)
|
static void options(void)
|
||||||
{
|
{
|
||||||
show = SHOW_OPTIONS;
|
show = SHOW_OPTIONS;
|
||||||
|
|
||||||
initOptions(returnFromOptions);
|
initOptions(returnFromOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stats(void)
|
static void stats(void)
|
||||||
{
|
{
|
||||||
selectWidget("ok", "stats");
|
selectWidget("ok", "stats");
|
||||||
|
|
||||||
show = SHOW_STATS;
|
show = SHOW_STATS;
|
||||||
|
|
||||||
initStatsDisplay();
|
initStatsDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void statsOK(void)
|
static void statsOK(void)
|
||||||
{
|
{
|
||||||
selectWidget("resume", "galacticMap");
|
selectWidget("resume", "galacticMap");
|
||||||
|
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void returnFromOptions(void)
|
static void returnFromOptions(void)
|
||||||
{
|
{
|
||||||
show = SHOW_MENU;
|
show = SHOW_MENU;
|
||||||
|
|
||||||
selectWidget("resume", "galacticMap");
|
selectWidget("resume", "galacticMap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,13 +712,13 @@ static void quit(void)
|
||||||
void destroyGalacticMap(void)
|
void destroyGalacticMap(void)
|
||||||
{
|
{
|
||||||
Pulse *pulse;
|
Pulse *pulse;
|
||||||
|
|
||||||
while (pulseHead.next)
|
while (pulseHead.next)
|
||||||
{
|
{
|
||||||
pulse = pulseHead.next;
|
pulse = pulseHead.next;
|
||||||
pulseHead.next = pulse->next;
|
pulseHead.next = pulse->next;
|
||||||
free(pulse);
|
free(pulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
pulseTail = &pulseHead;
|
pulseTail = &pulseHead;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ 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 drawTrophyAlert(void);
|
||||||
|
extern void checkStatTrophies(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -159,6 +159,13 @@ static void loadTrophyData(char *filename)
|
||||||
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
t->value = lookup(cJSON_GetObjectItem(node, "value")->valuestring);
|
||||||
t->hidden = getJSONValue(node, "hidden", 0);
|
t->hidden = getJSONValue(node, "hidden", 0);
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
tail->next = t;
|
tail->next = t;
|
||||||
tail = t;
|
tail = t;
|
||||||
}
|
}
|
||||||
|
@ -166,3 +173,18 @@ static void loadTrophyData(char *filename)
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
free(text);
|
free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkStatTrophies(void)
|
||||||
|
{
|
||||||
|
Trophy *t;
|
||||||
|
|
||||||
|
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||||
|
{
|
||||||
|
if (!t->awarded && game.stats[t->stat] >= t->statValue)
|
||||||
|
{
|
||||||
|
t->awarded = 1;
|
||||||
|
t->awardDate = time(NULL);
|
||||||
|
t->notify = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -349,6 +349,8 @@ struct Trophy {
|
||||||
char description[MAX_DESCRIPTION_LENGTH];
|
char description[MAX_DESCRIPTION_LENGTH];
|
||||||
int value;
|
int value;
|
||||||
int hidden;
|
int hidden;
|
||||||
|
int stat;
|
||||||
|
int statValue;
|
||||||
int awarded;
|
int awarded;
|
||||||
unsigned long awardDate;
|
unsigned long awardDate;
|
||||||
int notify;
|
int notify;
|
||||||
|
|
Loading…
Reference in New Issue