Make respawn-on-fire configurable

Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/issues/162>
This commit is contained in:
Kp 2015-11-21 18:12:13 +00:00
parent 0fbccd609c
commit 63ca0eb87b
5 changed files with 30 additions and 5 deletions

View file

@ -90,10 +90,17 @@ enum class HudType : uint8_t
Hidden,
};
enum class RespawnPress : uint8_t
{
Any,
Fire,
};
struct player_config : prohibit_void_ptr<player_config>
{
ubyte ControlType;
HudType HudMode;
RespawnPress RespawnMode;
array<ubyte, MAX_PRIMARY_WEAPONS + 1> PrimaryOrder;
array<ubyte, MAX_SECONDARY_WEAPONS + 1> SecondaryOrder;
array<array<ubyte, MAX_CONTROLS>, 3> KeySettings;

View file

@ -427,13 +427,18 @@ static int HandleDeathInput(const d_event &event)
{
int key = event_key_get(event);
if (key == KEY_ESC)
if (ConsoleObject->flags & OF_EXPLODING)
if ((PlayerCfg.RespawnMode == RespawnPress::Any && Player_exploded && !key_isfunc(key) && key != KEY_PAUSE && key) ||
(key == KEY_ESC && ConsoleObject->flags & OF_EXPLODING))
Death_sequence_aborted = 1;
}
if (Player_exploded && (Controls.state.fire_primary || Controls.state.fire_secondary || Controls.state.fire_flare))
Death_sequence_aborted = 1;
if (Player_exploded)
{
if (PlayerCfg.RespawnMode == RespawnPress::Any
? (event.type == EVENT_JOYSTICK_BUTTON_UP || event.type == EVENT_MOUSE_BUTTON_UP)
: (Controls.state.fire_primary || Controls.state.fire_secondary || Controls.state.fire_flare))
Death_sequence_aborted = 1;
}
if (Death_sequence_aborted)
{

View file

@ -259,6 +259,6 @@ void player_dead_message(void)
if (HUD_color == -1)
HUD_color = BM_XRGB(0,28,0);
gr_set_fontcolor( HUD_color, -1);
gr_string(0x8000, GHEIGHT - LINE_SPACING, "Press fire key or button to continue...");
gr_string(0x8000, GHEIGHT - LINE_SPACING, PlayerCfg.RespawnMode == RespawnPress::Any ? TXT_PRESS_ANY_KEY : "Press fire key or button to continue...");
}
}

View file

@ -1226,6 +1226,10 @@ class input_config_menu_items
DXX_##VERB##_CHECK("Keep Keyboard/Mouse focus", opt_ic_grabinput, CGameCfg.Grabinput) \
DXX_##VERB##_CHECK("Mouse FlightSim Indicator", opt_ic_mousefsgauge, PlayerCfg.MouseFSIndicator) \
DXX_##VERB##_TEXT("", opt_label_blank_focus) \
DXX_##VERB##_TEXT("When dead, respawn by pressing:", opt_label_respawn_mode) \
DXX_##VERB##_RADIO("Any key", opt_respawn_any_key, PlayerCfg.RespawnMode == RespawnPress::Any, optgrp_respawn_mode) \
DXX_##VERB##_RADIO("Fire key (primary, secondary, flare)", opt_respawn_fire_key, PlayerCfg.RespawnMode == RespawnPress::Fire, optgrp_respawn_mode) \
DXX_##VERB##_TEXT("", opt_label_blank_respawn) \
DXX_##VERB##_MENU("GAME SYSTEM KEYS", opt_ic_help0) \
DXX_##VERB##_MENU("NETGAME SYSTEM KEYS", opt_ic_help1) \
DXX_##VERB##_MENU("DEMO SYSTEM KEYS", opt_ic_help2) \
@ -1234,6 +1238,7 @@ public:
enum
{
optgrp_mouse_control_type,
optgrp_respawn_mode,
};
enum
{
@ -1286,6 +1291,10 @@ int input_config_menu_items::menuset(newmenu *, const d_event &event, input_conf
CGameCfg.Grabinput = items[citem].value;
if (citem == opt_ic_mousefsgauge)
PlayerCfg.MouseFSIndicator = items[citem].value;
else if (citem == opt_respawn_any_key)
PlayerCfg.RespawnMode = RespawnPress::Any;
else if (citem == opt_respawn_fire_key)
PlayerCfg.RespawnMode = RespawnPress::Fire;
break;
}
case EVENT_NEWMENU_SELECTED:

View file

@ -165,6 +165,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define TOGGLES_CYCLEAUTOSELECTONLY_NAME_TEXT "cycleautoselectonly"
#define TOGGLES_FRIENDMISSILEVIEW_NAME_TEXT "friendmissileview"
#define TOGGLES_CLOAKINVULTIMER_NAME_TEXT "cloakinvultimer"
#define TOGGLES_RESPAWN_ANY_KEY "respawnkey"
#define GRAPHICS_HEADER_TEXT "[graphics]"
#define GRAPHICS_ALPHAEFFECTS_NAME_TEXT "alphaeffects"
#define GRAPHICS_DYNLIGHTCOLOR_NAME_TEXT "dynlightcolor"
@ -465,6 +466,8 @@ static void read_player_dxx(const char *filename)
PlayerCfg.CycleAutoselectOnly = atoi(value);
if(!strcmp(line,TOGGLES_CLOAKINVULTIMER_NAME_TEXT))
PlayerCfg.CloakInvulTimer = atoi(value);
else if (!strcmp(line, TOGGLES_RESPAWN_ANY_KEY))
PlayerCfg.RespawnMode = static_cast<RespawnPress>(atoi(value));
}
}
else if (!strcmp(line,GRAPHICS_HEADER_TEXT))
@ -759,6 +762,7 @@ static int write_player_dxx(const char *filename)
PHYSFSX_printf(fout,TOGGLES_NOFIREAUTOSELECT_NAME_TEXT "=%i\n",static_cast<unsigned>(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,TOGGLES_RESPAWN_ANY_KEY "=%i\n",static_cast<unsigned>(PlayerCfg.RespawnMode));
PHYSFSX_printf(fout,END_TEXT "\n");
PHYSFSX_printf(fout,GRAPHICS_HEADER_TEXT "\n");
PHYSFSX_printf(fout,GRAPHICS_ALPHAEFFECTS_NAME_TEXT "=%i\n",PlayerCfg.AlphaEffects);