From 277092cdbcb2c7bdb6413bb6de9a7e56b88c5ab0 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 28 Dec 2015 13:44:57 +0000 Subject: [PATCH] Using arrow to indicate more weapons available on HUD. --- gfx/hud/nextGun.png | Bin 0 -> 214 bytes src/battle/hud.c | 15 +++++++++++++-- src/battle/hud.h | 1 + src/battle/player.c | 29 +++++++---------------------- src/draw/text.c | 4 ++-- src/structs.h | 3 +-- 6 files changed, 24 insertions(+), 28 deletions(-) create mode 100644 gfx/hud/nextGun.png diff --git a/gfx/hud/nextGun.png b/gfx/hud/nextGun.png new file mode 100644 index 0000000000000000000000000000000000000000..86bce1211055a949b45ab3c3ffb68c1ef80e899c GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCy8vk*`02d69!PN(ctjR6 zFmMZlFeAgPITAoY_7YEDSN8inGMxN8g*92?Kq1Kz*N775{M_8syb=cIqSVBa)D(sC z%#sWRcTeAd@J2q6B0EnP#}J9jb0?hSWl-Qb%;a49tZa&3>OPx*kca!HI?wbh7ZyBm zuvN6;gNVVMLrgX1o}o+EYF>V^-|*YKmk-&?%~yNM{7UTun#ADg>gTe~DWM4fw>~~` literal 0 HcmV?d00001 diff --git a/src/battle/hud.c b/src/battle/hud.c index 6761286..cac0267 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -39,6 +39,7 @@ static SDL_Texture *targetCircle; static SDL_Texture *smallFighter; static SDL_Texture *arrowLeft; static SDL_Texture *arrowRight; +static SDL_Texture *nextGun; static int numMessages; static char *gunName[] = {"", "Particle Cannon", "Plasma Cannon", "Laser Cannon", "Mag Cannon", "Rockets"}; @@ -52,6 +53,7 @@ void initHud(void) smallFighter = getTexture("gfx/hud/smallFighter.png"); arrowLeft = getTexture("gfx/widgets/optionsLeft.png"); arrowRight = getTexture("gfx/widgets/optionsRight.png"); + nextGun = getTexture("gfx/hud/nextGun.png"); } void doHud(void) @@ -258,11 +260,20 @@ static void drawBoostECMBar(int current, int max, int x, int y, int r, int g, in static void drawWeaponInfo(void) { + int w, h; + if (!player->combinedGuns) { - if (player->numGuns) + if (battle.numPlayerGuns) { - drawText(10, 70, 14, TA_LEFT, colors.white, "%s (%d / %d)", gunName[player->selectedGunType], player->selectedGun + 1, player->numGuns); + drawText(10, 70, 14, TA_LEFT, colors.white, gunName[player->selectedGunType]); + + if (battle.numPlayerGuns > 1) + { + textSize(gunName[player->selectedGunType], 14, &w, &h); + + blit(nextGun, 24 + w, 81, 1); + } } else { diff --git a/src/battle/hud.h b/src/battle/hud.h index 2e33c20..605c636 100644 --- a/src/battle/hud.h +++ b/src/battle/hud.h @@ -31,6 +31,7 @@ extern int getDistance(int x1, int y1, int x2, int y2); extern void drawRadar(void); extern void drawRadarRangeWarning(void); extern int getPercent(float current, float total); +extern void textSize(char *text, int size, int *w, int *h); extern App app; extern Battle battle; diff --git a/src/battle/player.c b/src/battle/player.c index 0535b53..a20e624 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -44,6 +44,8 @@ void initPlayer(void) memset(&availableGuns, 0, sizeof(int) * BT_MAX); + battle.numPlayerGuns = 0; + player->selectedGunType = -1; if (!player->combinedGuns) @@ -54,6 +56,11 @@ void initPlayer(void) if (n) { + if (!availableGuns[n]) + { + battle.numPlayerGuns++; + } + availableGuns[n] = 1; if (player->selectedGunType == -1) @@ -68,18 +75,6 @@ void initPlayer(void) player->selectedGunType = 0; } - player->numGuns = 0; - - for (i = 0 ; i < BT_MAX ; i++) - { - if (availableGuns[i]) - { - player->numGuns++; - } - } - - player->selectedGun = 0; - STRNCPY(player->name, "Player", MAX_NAME_LENGTH); player->action = NULL; @@ -411,16 +406,6 @@ static void switchGuns(void) } player->selectedGunType = i; - - player->selectedGun = 0; - - for (i = 0 ; i < player->selectedGunType ; i++) - { - if (availableGuns[i]) - { - player->selectedGun++; - } - } } static void selectTarget(void) diff --git a/src/draw/text.c b/src/draw/text.c index 3966657..962a507 100644 --- a/src/draw/text.c +++ b/src/draw/text.c @@ -26,7 +26,7 @@ static void cacheText(unsigned long hash, SDL_Texture *t); static unsigned long hashcode(const char *str, int size); static void drawTextNormal(int x, int y, int size, int align, SDL_Color c, char *text); static void drawTextSplit(int x, int y, int size, int align, SDL_Color c, char *text); -static void textSize(char *text, int size, int *w, int *h); +void textSize(char *text, int size, int *w, int *h); static char drawTextBuffer[MAX_DESCRIPTION_LENGTH]; static TTF_Font *font[MAX_FONTS]; @@ -175,7 +175,7 @@ int getWrappedTextHeight(char *text, int size) return y + h; } -static void textSize(char *text, int size, int *w, int *h) +void textSize(char *text, int size, int *w, int *h) { if (!font[size]) { diff --git a/src/structs.h b/src/structs.h index c6c9bf0..89acfeb 100644 --- a/src/structs.h +++ b/src/structs.h @@ -110,9 +110,7 @@ struct Entity { int maxShield; int reload; int reloadTime; - int selectedGun; int selectedGunType; - int numGuns; int combinedGuns; int shieldRecharge; int shieldRechargeRate; @@ -284,6 +282,7 @@ typedef struct { int boostTimer; int ecmTimer; int radarRange; + int numPlayerGuns; int numObjectivesComplete, numObjectivesTotal; Entity *missionTarget; Entity *extractionPoint;