Added Cloak and Invulnerability Timers to Cockpit and Statusbar and made this feature optional (defaults to off)

This commit is contained in:
zico 2015-09-27 10:51:37 +02:00
parent a175812000
commit cbe0b4ec69
4 changed files with 42 additions and 3 deletions

View file

@ -120,6 +120,7 @@ struct player_config
ubyte AutomapFreeFlight;
ubyte NoFireAutoselect;
ubyte CycleAutoselectOnly;
int CloakInvulTimer;
union {
/* For now, manage all these choices in a single variable, but
* give them separate names to make them easier to find.

View file

@ -1496,7 +1496,10 @@ static void hud_show_cloak_invuln(void)
const fix64 effect_end = plr.cloak_time + CLOAK_TIME_MAX - gametime64;
if (effect_end > F1_0*3 || gametime64 & 0x8000)
{
gr_printf(fspacx1, base_y, "%s: %lu", TXT_CLOAKED, static_cast<unsigned long>(effect_end / F1_0));
if (PlayerCfg.CloakInvulTimer)
gr_printf(fspacx1, base_y, "%s: %lu", TXT_CLOAKED, static_cast<unsigned long>(effect_end / F1_0));
else
gr_string(fspacx1, base_y, TXT_CLOAKED);
}
}
@ -1505,10 +1508,12 @@ static void hud_show_cloak_invuln(void)
const fix64 effect_end = plr.invulnerable_time + INVULNERABLE_TIME_MAX - gametime64;
if (effect_end > F1_0*4 || gametime64 & 0x8000)
{
gr_printf(fspacx1, base_y - line_spacing, "%s: %lu", TXT_INVULNERABLE, static_cast<unsigned long>(effect_end / F1_0));
if (PlayerCfg.CloakInvulTimer)
gr_printf(fspacx1, base_y - line_spacing, "%s: %lu", TXT_INVULNERABLE, static_cast<unsigned long>(effect_end / F1_0));
else
gr_string(fspacx1, base_y - line_spacing, TXT_INVULNERABLE);
}
}
}
static void hud_show_shield(void)
@ -1914,6 +1919,19 @@ static void draw_player_ship(int cloak_state,int x, int y, const local_multires_
gr_rect(HUD_SCALE_X(x - 3), HUD_SCALE_Y(y - 3), HUD_SCALE_X(x + bm.bm_w + 3), HUD_SCALE_Y(y + bm.bm_h + 3));
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
gr_set_current_canvas( NULL );
// Show Cloak Timer if enabled
if (cloak_fade_value < GR_FADE_LEVELS/2 && PlayerCfg.CloakInvulTimer)
{
const fix64 effect_end = get_local_player().cloak_time + CLOAK_TIME_MAX - GameTime64;
char countdown[5];
int ow, oh, oaw;
int x = (PlayerCfg.CockpitMode[1]==CM_STATUS_BAR)?(grd_curscreen->get_screen_width() / 2.266):(grd_curscreen->get_screen_width() / 1.951);
snprintf(countdown, sizeof(countdown), "%lu", static_cast<unsigned long>(effect_end / F1_0));
gr_get_string_size(countdown,&ow,&oh,&oaw);
gr_set_fontcolor(BM_XRGB(31,31,31),-1 );
gr_printf(x-(ow/2), HUD_SCALE_Y(y + (bm.bm_h/2)), "%lu", static_cast<unsigned long>(effect_end / F1_0));
}
}
#define INV_FRAME_TIME (f1_0/10) //how long for each frame
@ -2412,6 +2430,20 @@ static void draw_invulnerable_ship(const local_multires_gauge_graphic multires_g
y = SHIELD_GAUGE_Y;
}
hud_gauge_bitblt(x, y, GAUGE_INVULNERABLE + old_invulnerable_frame, multires_gauge_graphic);
// Show Invulnerability Timer if enabled
if (PlayerCfg.CloakInvulTimer)
{
const fix64 effect_end = get_local_player().invulnerable_time + INVULNERABLE_TIME_MAX - GameTime64;
char countdown[5];
int ow, oh, oaw;
int x = (cmmode==CM_STATUS_BAR)?(grd_curscreen->get_screen_width() / 2.266):(grd_curscreen->get_screen_width() / 1.951);
snprintf(countdown, sizeof(countdown), "%lu", static_cast<unsigned long>(effect_end / F1_0));
gr_get_string_size(countdown,&ow,&oh,&oaw);
gr_set_fontcolor(BM_XRGB(31,31,31),-1 );
gr_printf(x-(ow/2), HUD_SCALE_Y(y), "%lu", static_cast<unsigned long>(effect_end / F1_0));
}
} else if (cmmode == CM_STATUS_BAR)
sb_draw_shield_bar(f2ir(get_local_player().shields), multires_gauge_graphic);
else

View file

@ -1330,6 +1330,7 @@ static void reticle_config()
DXX_##VERB##_CHECK("Screenshots without HUD",opt_screenshot,PlayerCfg.PRShot) \
DXX_##VERB##_CHECK("No redundant pickup messages",opt_redundant,PlayerCfg.NoRedundancy) \
DXX_##VERB##_CHECK("Show Player chat only (Multi)",opt_playerchat,PlayerCfg.MultiMessages) \
DXX_##VERB##_CHECK("Cloak/Invulnerability Timers",opt_cloakinvultimer,PlayerCfg.CloakInvulTimer) \
DXX_GAME_SPECIFIC_HUDOPTIONS(VERB) \
enum {

View file

@ -164,6 +164,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define TOGGLES_NOFIREAUTOSELECT_NAME_TEXT "nofireautoselect"
#define TOGGLES_CYCLEAUTOSELECTONLY_NAME_TEXT "cycleautoselectonly"
#define TOGGLES_FRIENDMISSILEVIEW_NAME_TEXT "friendmissileview"
#define TOGGLES_CLOAKINVULTIMER_NAME_TEXT "cloakinvultimer"
#define GRAPHICS_HEADER_TEXT "[graphics]"
#define GRAPHICS_ALPHAEFFECTS_NAME_TEXT "alphaeffects"
#define GRAPHICS_DYNLIGHTCOLOR_NAME_TEXT "dynlightcolor"
@ -253,6 +254,7 @@ int new_player_config()
PlayerCfg.AutomapFreeFlight = 0;
PlayerCfg.NoFireAutoselect = 0;
PlayerCfg.CycleAutoselectOnly = 0;
PlayerCfg.CloakInvulTimer = 0;
PlayerCfg.AlphaEffects = 0;
PlayerCfg.DynLightColor = 0;
@ -466,6 +468,8 @@ static int read_player_dxx(const char *filename)
PlayerCfg.NoFireAutoselect = atoi(value);
if(!strcmp(line,TOGGLES_CYCLEAUTOSELECTONLY_NAME_TEXT))
PlayerCfg.CycleAutoselectOnly = atoi(value);
if(!strcmp(line,TOGGLES_CLOAKINVULTIMER_NAME_TEXT))
PlayerCfg.CloakInvulTimer = atoi(value);
}
}
else if (!strcmp(line,GRAPHICS_HEADER_TEXT))
@ -761,6 +765,7 @@ static int write_player_dxx(const char *filename)
PHYSFSX_printf(fout,TOGGLES_AUTOMAPFREEFLIGHT_NAME_TEXT "=%i\n",PlayerCfg.AutomapFreeFlight);
PHYSFSX_printf(fout,TOGGLES_NOFIREAUTOSELECT_NAME_TEXT "=%i\n",PlayerCfg.NoFireAutoselect);
PHYSFSX_printf(fout,TOGGLES_CYCLEAUTOSELECTONLY_NAME_TEXT "=%i\n",PlayerCfg.CycleAutoselectOnly);
PHYSFSX_printf(fout,TOGGLES_CLOAKINVULTIMER_NAME_TEXT "=%i\n",PlayerCfg.CloakInvulTimer);
PHYSFSX_printf(fout,END_TEXT "\n");
PHYSFSX_printf(fout,GRAPHICS_HEADER_TEXT "\n");
PHYSFSX_printf(fout,GRAPHICS_ALPHAEFFECTS_NAME_TEXT "=%i\n",PlayerCfg.AlphaEffects);