add a "shoot by default" setting

This commit is contained in:
Andrei Alexeyev 2017-10-31 11:48:30 +02:00
parent 56bfa76afe
commit e978d97614
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
5 changed files with 25 additions and 11 deletions

View file

@ -86,6 +86,7 @@
CONFIGDEF_FLOAT (TEXT_QUALITY, "text_quality", 1.0) \
CONFIGDEF_FLOAT (FG_QUALITY, "fg_quality", 1.0) \
CONFIGDEF_FLOAT (BG_QUALITY, "bg_quality", 1.0) \
CONFIGDEF_INT (SHOT_INVERTED, "shot_inverted", 0) \
KEYDEFS \
CONFIGDEF_INT (GAMEPAD_ENABLED, "gamepad_enabled", 0) \
CONFIGDEF_STRING (GAMEPAD_DEVICE, "gamepad_device", "default") \

View file

@ -632,15 +632,20 @@ void create_options_menu(MenuData *m) {
add_menu_entry(m, "Save replays", do_nothing,
b = bind_option(CONFIG_SAVE_RPY, bind_common_onoffplus_get, bind_common_onoffplus_set)
); bind_addvalue(b, "on");
bind_addvalue(b, "off");
); bind_addvalue(b, "always");
bind_addvalue(b, "never");
bind_addvalue(b, "ask");
add_menu_entry(m, "Auto-restart in spell practice mode", do_nothing,
add_menu_entry(m, "Auto-restart in Spell Practice", do_nothing,
b = bind_option(CONFIG_SPELLSTAGE_AUTORESTART, bind_common_onoff_get,
bind_common_onoff_set)
); bind_onoff(b);
add_menu_entry(m, "Shoot by default", do_nothing,
b = bind_option(CONFIG_SHOT_INVERTED, bind_common_onoff_get,
bind_common_onoff_set)
); bind_onoff(b);
add_menu_separator(m);
add_menu_entry(m, "SFX Volume", do_nothing,

View file

@ -485,9 +485,10 @@ static bool player_set_axis(int *aptr, uint16_t value) {
return true;
}
void player_event(Player *plr, uint8_t type, uint16_t value, bool warn, bool *out_useful, bool *out_cheat) {
void player_event(Player *plr, uint8_t type, uint16_t value, bool *out_useful, bool *out_cheat) {
bool useful = true;
bool cheat = false;
bool is_replay = global.replaymode == REPLAY_PLAY;
switch(type) {
case EV_PRESS:
@ -555,13 +556,10 @@ void player_event(Player *plr, uint8_t type, uint16_t value, bool warn, bool *ou
default:
log_warn("Can not handle event: [%i:%02x:%04x]", global.frames, type, value);
useful = false;
warn = false;
break;
}
if(warn) {
assert(global.replaymode == REPLAY_PLAY);
if(is_replay) {
if(!useful) {
log_warn("Useless event in replay: [%i:%02x:%04x]", global.frames, type, value);
}
@ -594,7 +592,12 @@ void player_event(Player *plr, uint8_t type, uint16_t value, bool warn, bool *ou
bool player_event_with_replay(Player *plr, uint8_t type, uint16_t value) {
bool useful, cheat;
assert(global.replaymode == REPLAY_RECORD);
player_event(plr, type, value, false, &useful, &cheat);
if(config_get_int(CONFIG_SHOT_INVERTED) && value == KEY_SHOT && (type == EV_PRESS || type == EV_RELEASE)) {
type = type == EV_PRESS ? EV_RELEASE : EV_PRESS;
}
player_event(plr, type, value, &useful, &cheat);
if(useful) {
replay_stage_event(global.replay_stage, global.frames, type, value);
@ -694,6 +697,7 @@ void player_fix_input(Player *plr) {
// usually because the pause menu ate them up
PlrInputFlag newflags = plr->inputflags;
bool invert_shot = config_get_int(CONFIG_SHOT_INVERTED);
for(KeyIndex key = KEYIDX_FIRST; key <= KEYIDX_LAST; ++key) {
int flag = key_to_inflag(key);
@ -702,6 +706,10 @@ void player_fix_input(Player *plr) {
bool flagset = plr->inputflags & flag;
bool keyheld = gamekeypressed(key);
if(invert_shot && key == KEY_SHOT) {
keyheld = !keyheld;
}
if(flagset && !keyheld) {
newflags &= ~flag;
} else if(!flagset && keyheld) {

View file

@ -133,7 +133,7 @@ void player_realdeath(Player*);
void player_death(Player*);
void player_graze(Player*, complex, int);
void player_event(Player *plr, uint8_t type, uint16_t value, bool warn, bool *out_useful, bool *out_cheat);
void player_event(Player *plr, uint8_t type, uint16_t value, bool *out_useful, bool *out_cheat);
bool player_event_with_replay(Player *plr, uint8_t type, uint16_t value);
void player_applymovement(Player* plr);
void player_fix_input(Player *plr);

View file

@ -356,7 +356,7 @@ void replay_input(void) {
break;
default: {
player_event(&global.plr, e->type, (int16_t)e->value, true, NULL, NULL);
player_event(&global.plr, e->type, (int16_t)e->value, NULL, NULL);
break;
}
}