Using arrow to indicate more weapons available on HUD.

This commit is contained in:
Steve 2015-12-28 13:44:57 +00:00
parent 38e4564aae
commit 277092cdbc
6 changed files with 24 additions and 28 deletions

BIN
gfx/hud/nextGun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

View File

@ -39,6 +39,7 @@ static SDL_Texture *targetCircle;
static SDL_Texture *smallFighter; static SDL_Texture *smallFighter;
static SDL_Texture *arrowLeft; static SDL_Texture *arrowLeft;
static SDL_Texture *arrowRight; static SDL_Texture *arrowRight;
static SDL_Texture *nextGun;
static int numMessages; static int numMessages;
static char *gunName[] = {"", "Particle Cannon", "Plasma Cannon", "Laser Cannon", "Mag Cannon", "Rockets"}; 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"); smallFighter = getTexture("gfx/hud/smallFighter.png");
arrowLeft = getTexture("gfx/widgets/optionsLeft.png"); arrowLeft = getTexture("gfx/widgets/optionsLeft.png");
arrowRight = getTexture("gfx/widgets/optionsRight.png"); arrowRight = getTexture("gfx/widgets/optionsRight.png");
nextGun = getTexture("gfx/hud/nextGun.png");
} }
void doHud(void) 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) static void drawWeaponInfo(void)
{ {
int w, h;
if (!player->combinedGuns) 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 else
{ {

View File

@ -31,6 +31,7 @@ extern int getDistance(int x1, int y1, int x2, int y2);
extern void drawRadar(void); extern void drawRadar(void);
extern void drawRadarRangeWarning(void); extern void drawRadarRangeWarning(void);
extern int getPercent(float current, float total); extern int getPercent(float current, float total);
extern void textSize(char *text, int size, int *w, int *h);
extern App app; extern App app;
extern Battle battle; extern Battle battle;

View File

@ -44,6 +44,8 @@ void initPlayer(void)
memset(&availableGuns, 0, sizeof(int) * BT_MAX); memset(&availableGuns, 0, sizeof(int) * BT_MAX);
battle.numPlayerGuns = 0;
player->selectedGunType = -1; player->selectedGunType = -1;
if (!player->combinedGuns) if (!player->combinedGuns)
@ -54,6 +56,11 @@ void initPlayer(void)
if (n) if (n)
{ {
if (!availableGuns[n])
{
battle.numPlayerGuns++;
}
availableGuns[n] = 1; availableGuns[n] = 1;
if (player->selectedGunType == -1) if (player->selectedGunType == -1)
@ -68,18 +75,6 @@ void initPlayer(void)
player->selectedGunType = 0; 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); STRNCPY(player->name, "Player", MAX_NAME_LENGTH);
player->action = NULL; player->action = NULL;
@ -411,16 +406,6 @@ static void switchGuns(void)
} }
player->selectedGunType = i; player->selectedGunType = i;
player->selectedGun = 0;
for (i = 0 ; i < player->selectedGunType ; i++)
{
if (availableGuns[i])
{
player->selectedGun++;
}
}
} }
static void selectTarget(void) static void selectTarget(void)

View File

@ -26,7 +26,7 @@ static void cacheText(unsigned long hash, SDL_Texture *t);
static unsigned long hashcode(const char *str, int size); 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 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 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 char drawTextBuffer[MAX_DESCRIPTION_LENGTH];
static TTF_Font *font[MAX_FONTS]; static TTF_Font *font[MAX_FONTS];
@ -175,7 +175,7 @@ int getWrappedTextHeight(char *text, int size)
return y + h; 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]) if (!font[size])
{ {

View File

@ -110,9 +110,7 @@ struct Entity {
int maxShield; int maxShield;
int reload; int reload;
int reloadTime; int reloadTime;
int selectedGun;
int selectedGunType; int selectedGunType;
int numGuns;
int combinedGuns; int combinedGuns;
int shieldRecharge; int shieldRecharge;
int shieldRechargeRate; int shieldRechargeRate;
@ -284,6 +282,7 @@ typedef struct {
int boostTimer; int boostTimer;
int ecmTimer; int ecmTimer;
int radarRange; int radarRange;
int numPlayerGuns;
int numObjectivesComplete, numObjectivesTotal; int numObjectivesComplete, numObjectivesTotal;
Entity *missionTarget; Entity *missionTarget;
Entity *extractionPoint; Entity *extractionPoint;