Various graphics fixes.
This commit is contained in:
parent
6d8cb00e3e
commit
934b2a6d67
|
@ -224,6 +224,8 @@ static void draw(void)
|
|||
|
||||
drawBackground(battle.background);
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blitScaled(battle.planetTexture, battle.planet.x, battle.planet.y, battle.planetWidth, battle.planetHeight, 0);
|
||||
|
||||
if (battle.destroyTorelli)
|
||||
|
|
|
@ -90,6 +90,7 @@ extern void awardTrophy(char *id);
|
|||
extern void initCredits(void);
|
||||
extern void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...);
|
||||
extern char *getTranslatedString(char *string);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -139,8 +139,10 @@ void drawEffects(void)
|
|||
{
|
||||
SDL_SetRenderDrawColor(app.renderer, e->r, e->g, e->b, e->a);
|
||||
|
||||
SDL_SetTextureBlendMode(e->texture->texture, SDL_BLENDMODE_ADD);
|
||||
SDL_SetTextureAlphaMod(e->texture->texture, e->a);
|
||||
if (e->texture != NULL)
|
||||
{
|
||||
SDL_SetTextureBlendMode(e->texture->texture, SDL_BLENDMODE_ADD);
|
||||
}
|
||||
|
||||
switch (e->type)
|
||||
{
|
||||
|
@ -153,23 +155,25 @@ void drawEffects(void)
|
|||
break;
|
||||
|
||||
case EFFECT_TEXTURE:
|
||||
SDL_SetTextureColorMod(e->texture->texture, e->r, e->g, e->b);
|
||||
setAtlasColor(e->r, e->g, e->b, e->a);
|
||||
blitScaled(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->size, e->size, 0);
|
||||
break;
|
||||
|
||||
case EFFECT_HALO:
|
||||
SDL_SetTextureColorMod(e->texture->texture, e->r, e->g, e->b);
|
||||
setAtlasColor(e->r, e->g, e->b, e->a);
|
||||
blitScaled(e->texture, e->x - battle.camera.x - (e->size / 2), e->y - battle.camera.y - (e->size / 2), e->size, e->size, 0);
|
||||
break;
|
||||
|
||||
case EFFECT_ECM:
|
||||
SDL_SetTextureColorMod(e->texture->texture, e->r, e->g, e->b);
|
||||
setAtlasColor(e->r, e->g, e->b, e->a);
|
||||
blitScaled(e->texture, SCREEN_WIDTH / 2 - (e->size / 2), SCREEN_HEIGHT / 2 - (e->size / 2), e->size, e->size, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_SetTextureAlphaMod(e->texture->texture, 255);
|
||||
SDL_SetTextureBlendMode(e->texture->texture, SDL_BLENDMODE_BLEND);
|
||||
if (e->texture != NULL)
|
||||
{
|
||||
SDL_SetTextureBlendMode(e->texture->texture, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||
|
|
|
@ -27,6 +27,7 @@ extern AtlasImage *getAtlasImage(char *name);
|
|||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
extern void *resize(void *array, int oldSize, int newSize);
|
||||
extern int isOnBattleScreen(int x, int y, int w, int h);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -420,21 +420,21 @@ void drawEntities(void)
|
|||
|
||||
static void drawEntity(Entity *e)
|
||||
{
|
||||
SDL_SetTextureColorMod(e->texture->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
if (e->armourHit > 0)
|
||||
{
|
||||
SDL_SetTextureColorMod(e->texture->texture, 255, 255 - e->armourHit, 255 - e->armourHit);
|
||||
setAtlasColor(255, 255 - e->armourHit, 255 - e->armourHit, 255);
|
||||
}
|
||||
|
||||
if (e->systemHit > 0)
|
||||
{
|
||||
SDL_SetTextureColorMod(e->texture->texture, 255 - e->systemHit, 255, 255);
|
||||
setAtlasColor(255 - e->systemHit, 255, 255, 255);
|
||||
}
|
||||
|
||||
if (e->flags & EF_DISABLED)
|
||||
{
|
||||
SDL_SetTextureColorMod(e->texture->texture, disabledGlow, disabledGlow, 255);
|
||||
setAtlasColor(disabledGlow, disabledGlow, 255, 255);
|
||||
}
|
||||
|
||||
blitRotated(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->angle);
|
||||
|
@ -443,8 +443,6 @@ static void drawEntity(Entity *e)
|
|||
{
|
||||
drawShieldHitEffect(e);
|
||||
}
|
||||
|
||||
SDL_SetTextureColorMod(e->texture->texture, 255, 255, 255);
|
||||
}
|
||||
|
||||
static void drawHealthBar(Entity *e)
|
||||
|
|
|
@ -39,6 +39,7 @@ extern int isOnBattleScreen(int x, int y, int w, int h);
|
|||
extern long lookup(char *name);
|
||||
extern void awardTrophy(char *id);
|
||||
extern void resetFighter(Entity *e);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -928,12 +928,11 @@ static void addFighterStat(char *key)
|
|||
|
||||
t = malloc(sizeof(Tuple));
|
||||
memset(t, 0, sizeof(Tuple));
|
||||
tail->next = t;
|
||||
|
||||
STRNCPY(t->key, key, MAX_NAME_LENGTH);
|
||||
t->value = 0;
|
||||
|
||||
tail->next = t;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Added '%s' to fighter stats", key);
|
||||
}
|
||||
|
||||
|
@ -1079,6 +1078,12 @@ void destroyFighterDefs(void)
|
|||
{
|
||||
e = defHead.next;
|
||||
defHead.next = e->next;
|
||||
|
||||
if (e->description)
|
||||
{
|
||||
free(e->description);
|
||||
}
|
||||
|
||||
free(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,6 +223,8 @@ static void drawHealthBars(void)
|
|||
g = 200;
|
||||
}
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blit(armour, 6, 9, 0);
|
||||
drawHealthShieldBar(player->health, player->maxHealth, 30, 10, r, g, b, 1);
|
||||
|
||||
|
@ -273,6 +275,8 @@ static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g
|
|||
|
||||
static void drawAbilityBars(void)
|
||||
{
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blit(boost, 6, 49, 0);
|
||||
drawBoostECMBar(battle.boostTimer, BOOST_RECHARGE_TIME, 30, 50, 128, 128, 255);
|
||||
|
||||
|
@ -320,6 +324,8 @@ static void drawWeaponInfo(void)
|
|||
{
|
||||
int i, y;
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
if (!player->combinedGuns)
|
||||
{
|
||||
if (battle.numPlayerGuns)
|
||||
|
@ -367,19 +373,19 @@ static void drawPlayerTargeter(void)
|
|||
{
|
||||
if (player->target)
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle->texture, 255, 0, 0);
|
||||
setAtlasColor(255, 0, 0, 255);
|
||||
}
|
||||
else if (battle.missionTarget)
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle->texture, 0, 255, 0);
|
||||
setAtlasColor(0, 255, 0, 255);
|
||||
}
|
||||
else if (battle.messageSpeaker)
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle->texture, 255, 255, 0);
|
||||
setAtlasColor(255, 255, 0, 255);
|
||||
}
|
||||
|
||||
blit(targetCircle, player->x - battle.camera.x, player->y - battle.camera.y, 1);
|
||||
|
@ -394,7 +400,7 @@ static void drawPlayerTargeter(void)
|
|||
x += sin(TO_RAIDANS(angle)) * 45;
|
||||
y += -cos(TO_RAIDANS(angle)) * 45;
|
||||
|
||||
SDL_SetTextureColorMod(targetPointer->texture, 255, 0, 0);
|
||||
setAtlasColor(255, 0, 0, 255);
|
||||
|
||||
blitRotated(targetPointer, x - battle.camera.x, y - battle.camera.y, angle);
|
||||
}
|
||||
|
@ -408,7 +414,7 @@ static void drawPlayerTargeter(void)
|
|||
x += sin(TO_RAIDANS(angle)) * 45;
|
||||
y += -cos(TO_RAIDANS(angle)) * 45;
|
||||
|
||||
SDL_SetTextureColorMod(targetPointer->texture, 0, 255, 0);
|
||||
setAtlasColor(0, 255, 0, 255);
|
||||
|
||||
blitRotated(targetPointer, x - battle.camera.x, y - battle.camera.y, angle);
|
||||
}
|
||||
|
@ -422,7 +428,7 @@ static void drawPlayerTargeter(void)
|
|||
x += sin(TO_RAIDANS(angle)) * 45;
|
||||
y += -cos(TO_RAIDANS(angle)) * 45;
|
||||
|
||||
SDL_SetTextureColorMod(targetPointer->texture, 255, 255, 0);
|
||||
setAtlasColor(255, 255, 0, 255);
|
||||
|
||||
blitRotated(targetPointer, x - battle.camera.x, y - battle.camera.y, angle);
|
||||
}
|
||||
|
@ -436,7 +442,7 @@ static void drawPlayerTargeter(void)
|
|||
x += sin(TO_RAIDANS(angle)) * 45;
|
||||
y += -cos(TO_RAIDANS(angle)) * 45;
|
||||
|
||||
SDL_SetTextureColorMod(targetPointer->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blitRotated(targetPointer, x - battle.camera.x, y - battle.camera.y, angle);
|
||||
}
|
||||
|
@ -445,12 +451,12 @@ static void drawPlayerTargeter(void)
|
|||
static void drawNumFighters(void)
|
||||
{
|
||||
/* Allies */
|
||||
SDL_SetTextureColorMod(smallFighter->texture, 150, 200, 255);
|
||||
setAtlasColor(150, 200, 255, 255);
|
||||
blit(smallFighter, 400, 15, 0);
|
||||
drawText(425, 11, 14, TA_LEFT, colors.white, battle.numAllies < 1000 ? "(%d)" : "(999+)", battle.numAllies);
|
||||
|
||||
/* Enemies */
|
||||
SDL_SetTextureColorMod(smallFighter->texture, 255, 100, 100);
|
||||
setAtlasColor(255, 100, 100, 255);
|
||||
blit(smallFighter, SCREEN_WIDTH - 410, 15, 0);
|
||||
drawText(SCREEN_WIDTH - 420, 11, 14, TA_RIGHT, colors.white, !battle.unlimitedEnemies ? "(%d)" : "(999+)", battle.numEnemies);
|
||||
}
|
||||
|
@ -459,6 +465,8 @@ static void drawObjectives(void)
|
|||
{
|
||||
int timeRemaining;
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
if (!game.currentMission->challengeData.isChallenge)
|
||||
{
|
||||
blit(objectives, (SCREEN_WIDTH / 2) - 50, 14, 0);
|
||||
|
@ -608,7 +616,7 @@ static void drawPlayerSelect(void)
|
|||
SDL_RenderFillRect(app.renderer, NULL);
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||
|
||||
SDL_SetTextureColorMod(targetCircle->texture, 0, 200, 255);
|
||||
setAtlasColor(0, 200, 255, 255);
|
||||
|
||||
blit(targetCircle, player->x - battle.camera.x, player->y - battle.camera.y, 1);
|
||||
|
||||
|
@ -619,6 +627,8 @@ static void drawPlayerSelect(void)
|
|||
drawText(SCREEN_WIDTH / 2, 540, 20, TA_CENTER, colors.white, "%s (%d%% / %d%%)", player->defName, getPercent(player->health, player->maxHealth), getPercent(player->shield, player->maxShield));
|
||||
}
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blit(arrowLeft, (SCREEN_WIDTH / 2) - 200, 520, 1);
|
||||
blit(arrowRight, (SCREEN_WIDTH / 2) + 200, 520, 1);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ extern int playerHasGun(int type);
|
|||
extern char *getTranslatedString(char *string);
|
||||
extern char *timeToString(long millis, int showHours);
|
||||
extern int jumpgateEnabled(void);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -552,19 +552,21 @@ static void drawGalaxy(void)
|
|||
switch (starSystem->type)
|
||||
{
|
||||
case SS_NORMAL:
|
||||
SDL_SetTextureColorMod(arrowTexture->texture, 255, 0, 0);
|
||||
setAtlasColor(255, 0, 0, 255);
|
||||
break;
|
||||
|
||||
case SS_SOL:
|
||||
SDL_SetTextureColorMod(arrowTexture->texture, 0, 255, 0);
|
||||
setAtlasColor(0, 255, 0, 255);
|
||||
break;
|
||||
|
||||
case SS_PANDORAN:
|
||||
SDL_SetTextureColorMod(arrowTexture->texture, 64, 128, 255);
|
||||
setAtlasColor(64, 128, 255, 255);
|
||||
break;
|
||||
}
|
||||
|
||||
blitRotated(arrowTexture, ax, ay, aa);
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +698,7 @@ static void drawStarSystemDetail(void)
|
|||
drawText(525, 160, 18, TA_LEFT, colors.lightGrey, CRAFT_TEXT, game.currentMission->craft);
|
||||
drawText(525, 185, 18, TA_LEFT, colors.lightGrey, SQUADRON_TEXT, game.currentMission->squadron);
|
||||
|
||||
app.textWidth = 500;
|
||||
app.textWidth = 550;
|
||||
|
||||
drawText(525, 230, 22, TA_LEFT, colors.white, game.currentMission->description);
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ extern void doFighterDatabase(void);
|
|||
extern void initFighterDatabaseDisplay(void);
|
||||
extern void drawFighterDatabase(void);
|
||||
extern void autoSizeWidgetButtons(char *group, int recenter);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -182,7 +182,7 @@ static void draw(void)
|
|||
|
||||
drawStars();
|
||||
|
||||
SDL_SetTextureColorMod(earthTexture->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blit(earthTexture, earth.x, earth.y, 1);
|
||||
|
||||
|
@ -190,7 +190,7 @@ static void draw(void)
|
|||
|
||||
drawEffects();
|
||||
|
||||
SDL_SetTextureColorMod(logo[0]->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
blit(logo[0], (SCREEN_WIDTH / 2) - logo[0]->rect.w, 30, 0);
|
||||
blit(logo[1], (SCREEN_WIDTH / 2), 30, 0);
|
||||
|
@ -228,10 +228,10 @@ static void drawFighters(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
for (i = 0 ; i < NUM_FIGHTERS ; i++)
|
||||
{
|
||||
SDL_SetTextureColorMod(fighters[i].texture->texture, 255, 255, 255);
|
||||
|
||||
blit(fighters[i].texture, fighters[i].x, fighters[i].y, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ extern void drawFighterDatabase(void);
|
|||
extern void initFighterDatabaseDisplay(void);
|
||||
extern void doFighterDatabase(void);
|
||||
extern void autoSizeWidgetButtons(char *group, int recenter);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -171,7 +171,7 @@ void drawTrophies(void)
|
|||
blitRotated(sparkle, x + 32, y + 32, sparkleAngle);
|
||||
blitRotated(sparkle, x + 32, y + 32, -sparkleAngle);
|
||||
|
||||
SDL_SetTextureColorMod(trophyIcons[t->value]->texture, 255, 255, 255);
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
blitScaled(trophyIcons[t->value], x, y, 64, 64, 0);
|
||||
drawText(x + 85, y - 10, 20, TA_LEFT, colors.yellow, t->title);
|
||||
drawText(x + 85, y + 20, 18, TA_LEFT, colors.white, t->description);
|
||||
|
@ -512,19 +512,19 @@ static void setSparkleColor(Trophy *t)
|
|||
switch (t->value)
|
||||
{
|
||||
case TROPHY_BRONZE:
|
||||
SDL_SetTextureColorMod(sparkle->texture, 255, 128, 0);
|
||||
setAtlasColor(255, 128, 0, 255);
|
||||
break;
|
||||
|
||||
case TROPHY_SILVER:
|
||||
SDL_SetTextureColorMod(sparkle->texture, 192, 192, 192);
|
||||
setAtlasColor(192, 192, 192, 255);
|
||||
break;
|
||||
|
||||
case TROPHY_GOLD:
|
||||
SDL_SetTextureColorMod(sparkle->texture, 255, 255, 0);
|
||||
setAtlasColor(255, 255, 0, 255);
|
||||
break;
|
||||
|
||||
case TROPHY_PLATINUM:
|
||||
SDL_SetTextureColorMod(sparkle->texture, 0, 128, 255);
|
||||
setAtlasColor(0, 128, 255, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ extern char *timeToDate(long millis);
|
|||
extern void calcTextDimensions(char *text, int size, int *w, int *h);
|
||||
extern void awardPandoranCraftTrophy(void);
|
||||
extern float mod(float n, float x);
|
||||
extern void setAtlasColor(int r, int g, int b, int a);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
54
src/main.c
54
src/main.c
|
@ -28,7 +28,6 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
long then, lastFrameTime, frames;
|
||||
float remainder;
|
||||
SDL_Event event;
|
||||
|
||||
memset(&app, 0, sizeof(App));
|
||||
memset(&dev, 0, sizeof(Dev));
|
||||
|
@ -65,51 +64,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
capFrameRate(&then, &remainder);
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_MOUSEMOTION:
|
||||
doMouseMotion(&event.motion);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
doMouseWheel(&event.wheel);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
doMouseDown(&event.button);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
doMouseUp(&event.button);
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
doKeyDown(&event.key);
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
doKeyUp(&event.key);
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
musicSetPlaying(1);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
musicSetPlaying(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
doInput();
|
||||
|
||||
if (app.modalDialog.type != MD_NONE)
|
||||
{
|
||||
|
@ -209,7 +164,7 @@ static void handleLoggingArgs(int argc, char *argv[])
|
|||
{
|
||||
int i;
|
||||
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
{
|
||||
|
@ -220,11 +175,6 @@ static void handleLoggingArgs(int argc, char *argv[])
|
|||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "-warn") == 0)
|
||||
{
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "-info") == 0)
|
||||
{
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
|
|
@ -54,7 +54,7 @@ extern void saveGame(void);
|
|||
extern void initCredits(void);
|
||||
extern void doTrophyAlerts(void);
|
||||
extern void drawTrophyAlert(void);
|
||||
extern void musicSetPlaying(int playing);
|
||||
extern void doInput(void);
|
||||
|
||||
App app;
|
||||
Colors colors;
|
||||
|
|
|
@ -34,6 +34,12 @@ void initAtlas(void)
|
|||
loadAtlasData();
|
||||
}
|
||||
|
||||
void setAtlasColor(int r, int g, int b, int a)
|
||||
{
|
||||
SDL_SetTextureColorMod(atlasTexture, r, g, b);
|
||||
SDL_SetTextureAlphaMod(atlasTexture, a);
|
||||
}
|
||||
|
||||
AtlasImage *getAtlasImage(char *filename)
|
||||
{
|
||||
AtlasImage *a;
|
||||
|
|
|
@ -188,10 +188,16 @@ void scrollBackground(float x, float y)
|
|||
void drawBackground(SDL_Texture *texture)
|
||||
{
|
||||
int i;
|
||||
SDL_Rect dstRect;
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
{
|
||||
/*blitScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH, SCREEN_HEIGHT, 0);*/
|
||||
dstRect.x = backgroundPoint[i].x;
|
||||
dstRect.y = backgroundPoint[i].y;
|
||||
dstRect.w = SCREEN_WIDTH;
|
||||
dstRect.h = SCREEN_HEIGHT;
|
||||
|
||||
SDL_RenderCopy(app.renderer, texture, NULL, &dstRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,57 @@ void drawMouse(void)
|
|||
blit(mousePointer, app.mouse.x, app.mouse.y, 1);
|
||||
}
|
||||
|
||||
void doInput(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_MOUSEMOTION:
|
||||
doMouseMotion(&event.motion);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
doMouseWheel(&event.wheel);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
doMouseDown(&event.button);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
doMouseUp(&event.button);
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
doKeyDown(&event.key);
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
doKeyUp(&event.key);
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event)
|
||||
{
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
musicSetPlaying(1);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
musicSetPlaying(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearInput(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
|
|
@ -22,5 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern AtlasImage *getAtlasImage(char *filename);
|
||||
extern void blit(AtlasImage *atlasImage, int x, int y, int centered);
|
||||
extern void musicSetPlaying(int playing);
|
||||
|
||||
extern App app;
|
||||
|
|
|
@ -154,6 +154,8 @@ static void loadFighterStats(cJSON *fighterStatsJSON)
|
|||
Tuple *t, *tail;
|
||||
cJSON *fighterStatJSON;
|
||||
|
||||
destroyFighterStats();
|
||||
|
||||
tail = &game.fighterStatHead;
|
||||
|
||||
if (fighterStatsJSON)
|
||||
|
|
|
@ -30,5 +30,6 @@ extern char *getSaveFilePath(char *filename);
|
|||
extern char *getLookupName(char *prefix, long num);
|
||||
extern StarSystem *getStarSystem(char *name);
|
||||
extern Trophy *getTrophy(char *id);
|
||||
extern void destroyFighterStats(void);
|
||||
|
||||
extern Game game;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2015-2016 Parallel Realities
|
||||
Copyright (C) 2015-2018 Parallel Realities
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -24,6 +24,51 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
$UPDATE_FILES = false;
|
||||
|
||||
function funcSort($a, $b)
|
||||
{
|
||||
$a = str_replace("*", "", $a);
|
||||
$b = str_replace("*", "", $b);
|
||||
|
||||
$aParts = explode(" ", $a);
|
||||
$bParts = explode(" ", $b);
|
||||
|
||||
return strcmp($aParts[2], $bParts[2]);
|
||||
}
|
||||
|
||||
function updateExterns($header, $defines, $functions, $structs)
|
||||
{
|
||||
asort($defines);
|
||||
usort($functions, "funcSort");
|
||||
asort($structs);
|
||||
|
||||
$newHeader = [];
|
||||
|
||||
foreach ($header as $line)
|
||||
{
|
||||
$newHeader[] = $line;
|
||||
}
|
||||
|
||||
if (count($defines) > 0)
|
||||
{
|
||||
$newHeader[] = "\n";
|
||||
$newHeader = array_merge($newHeader, $defines);
|
||||
}
|
||||
|
||||
if (count($functions) > 0)
|
||||
{
|
||||
$newHeader[] = "\n";
|
||||
$newHeader = array_merge($newHeader, $functions);
|
||||
}
|
||||
|
||||
if (count($structs) > 0)
|
||||
{
|
||||
$newHeader[] = "\n";
|
||||
$newHeader = array_merge($newHeader, $structs);
|
||||
}
|
||||
|
||||
return $newHeader;
|
||||
}
|
||||
|
||||
function cleanHeader($headerFile)
|
||||
{
|
||||
global $UPDATE_FILES;
|
||||
|
@ -39,22 +84,28 @@ function cleanHeader($headerFile)
|
|||
{
|
||||
$header = file($headerFile);
|
||||
$body = file_get_contents($bodyFile);
|
||||
$isMain = strpos($body, "int main(int argc, char *argv[])");
|
||||
$lines = [];
|
||||
$defines = [];
|
||||
$functions = [];
|
||||
$structs = [];
|
||||
|
||||
$i = 0;
|
||||
$hasChanges = false;
|
||||
|
||||
foreach ($header as $line)
|
||||
{
|
||||
if (preg_match("/extern|define/", $line) && strstr($line, "getTranslatedString") === FALSE)
|
||||
if ((preg_match("/extern|define/", $line) || preg_match("/;$/", $line)) && strstr($line, "getTranslatedString") === FALSE)
|
||||
{
|
||||
preg_match($func_pattern, $line, $matches);
|
||||
|
||||
if (count($matches) == 3)
|
||||
{
|
||||
unset($header[$i]);
|
||||
|
||||
$extern = $matches[2];
|
||||
|
||||
if (!preg_match_all("/\b[(]?${extern}[\\(;,)\\n]/", $body))
|
||||
if (!preg_match_all("/\b${extern}\b/", $body))
|
||||
{
|
||||
if (!$hasChanges)
|
||||
{
|
||||
|
@ -62,22 +113,10 @@ function cleanHeader($headerFile)
|
|||
$hasChanges = true;
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
}
|
||||
|
||||
if (!in_array($line, $lines))
|
||||
else if (!in_array($line, $lines))
|
||||
{
|
||||
$lines[] = $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$hasChanges)
|
||||
{
|
||||
echo "$headerFile\n";
|
||||
$hasChanges = true;
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
$functions[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,34 +124,31 @@ function cleanHeader($headerFile)
|
|||
|
||||
if (count($matches) == 2)
|
||||
{
|
||||
unset($header[$i]);
|
||||
|
||||
$extern = $matches[1];
|
||||
|
||||
$externs[] = $extern;
|
||||
|
||||
if (!preg_match_all("/\b${extern}[\\.\\-\\)]/", $body))
|
||||
if (!$isMain)
|
||||
{
|
||||
if (!$hasChanges)
|
||||
if (!preg_match_all("/\b${extern}\b/", $body))
|
||||
{
|
||||
echo "$headerFile\n";
|
||||
$hasChanges = true;
|
||||
if (!$hasChanges)
|
||||
{
|
||||
echo "$headerFile\n";
|
||||
$hasChanges = true;
|
||||
}
|
||||
echo "\t- $line";
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
}
|
||||
|
||||
if (!in_array($line, $lines))
|
||||
{
|
||||
$lines[] = $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$hasChanges)
|
||||
else if (!in_array($line, $lines))
|
||||
{
|
||||
echo "$headerFile\n";
|
||||
$hasChanges = true;
|
||||
$structs[] = $line;
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
}
|
||||
else if (!in_array($line, $lines))
|
||||
{
|
||||
$structs[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +156,8 @@ function cleanHeader($headerFile)
|
|||
|
||||
if (count($matches) == 2)
|
||||
{
|
||||
unset($header[$i]);
|
||||
|
||||
$extern = $matches[1];
|
||||
|
||||
$externs[] = $extern;
|
||||
|
@ -132,22 +170,10 @@ function cleanHeader($headerFile)
|
|||
$hasChanges = true;
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
}
|
||||
|
||||
if (!in_array($line, $lines))
|
||||
else if (!in_array($line, $lines))
|
||||
{
|
||||
$lines[] = $line;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$hasChanges)
|
||||
{
|
||||
echo "$headerFile\n";
|
||||
$hasChanges = true;
|
||||
}
|
||||
echo "\t- $line";
|
||||
unset($header[$i]);
|
||||
$defines[] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +181,25 @@ function cleanHeader($headerFile)
|
|||
$i++;
|
||||
}
|
||||
|
||||
if ($UPDATE_FILES && $hasChanges)
|
||||
do
|
||||
{
|
||||
$wasBlank = false;
|
||||
$line = trim(end($header));
|
||||
if (strlen($line) == 0)
|
||||
{
|
||||
array_pop($header);
|
||||
$wasBlank = true;
|
||||
}
|
||||
}
|
||||
while ($wasBlank);
|
||||
|
||||
$defines = array_unique($defines);
|
||||
$functions = array_unique($functions);
|
||||
$structs = array_unique($structs);
|
||||
|
||||
$header = updateExterns($header, $defines, $functions, $structs);
|
||||
|
||||
if ($UPDATE_FILES)
|
||||
{
|
||||
file_put_contents($headerFile, $header);
|
||||
}
|
||||
|
@ -174,7 +218,7 @@ function recurseDir($dir)
|
|||
{
|
||||
recurseDir("$dir/$file");
|
||||
}
|
||||
else if (strstr($file, ".h") !== FALSE)
|
||||
else if (strstr($file, ".h") !== FALSE && $file != 'i18n.h')
|
||||
{
|
||||
cleanHeader("$dir/$file");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue