From f0873b9aed8658573cb582ed23ac2da4f45d4f89 Mon Sep 17 00:00:00 2001 From: Drathek <76988376+Drulikar@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:25:56 -0700 Subject: [PATCH] Added preference to disallow de-activation of your current ability (#3904) # About the pull request This PR adds a xeno preference where you can disallow the deactivation of your currently selected ability when re-selecting it again. The default state of this toggle will still allow ability deactivation since that is the old behavior. Locally testing no preferences seem to save so I couldn't confirm that was working correctly; but I did not introduce a new field to be saved, just added to the existing one. Maybe they require a DB? # Explain why it's good for the game This can help xeno players not accidentally deactivate an ability if they have no need to deactivate an ability. Generally it should be the case there is no need to, but maybe someone has multi-binded MMB or wants to still examine with shift click (if they use shift click preference). # Testing Photographs and Procedure
Screenshots & Videos ![image](https://github.com/cmss13-devs/cmss13/assets/76988376/4324860f-80cd-46ec-9310-dbea6ecbe804) ![image](https://github.com/cmss13-devs/cmss13/assets/76988376/fe8744cb-8a2a-495b-8d96-282417fcacbc) ![image](https://github.com/cmss13-devs/cmss13/assets/76988376/bfde2f29-2e02-4878-97a8-017fedaeb40b)
# Changelog :cl: Drathek qol: Added a preference to disable xeno ability deactivation when re-selecting the same ability /:cl: --- code/__DEFINES/client_prefs.dm | 1 + code/modules/client/client_procs.dm | 1 + code/modules/client/preferences.dm | 4 +++- code/modules/client/preferences_toggles.dm | 13 +++++++++++-- .../carbon/xenomorph/abilities/xeno_action.dm | 2 ++ .../mob/living/carbon/xenomorph/xeno_verbs.dm | 15 +++++++++++++++ 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/client_prefs.dm b/code/__DEFINES/client_prefs.dm index ef5ff00e4ed6..b1e194354555 100644 --- a/code/__DEFINES/client_prefs.dm +++ b/code/__DEFINES/client_prefs.dm @@ -22,6 +22,7 @@ #define TOGGLE_VEND_ITEM_TO_HAND (1<<15) // This toggles whether items from vendors will be automatically put into your hand. #define TOGGLE_START_JOIN_CURRENT_SLOT (1<<16) // Whether joining at roundstart ignores assigned character slot for the job and uses currently selected slot. #define TOGGLE_LATE_JOIN_CURRENT_SLOT (1<<17) //Whether joining during the round ignores assigned character slot for the job and uses currently selected slot. +#define TOGGLE_ABILITY_DEACTIVATION_OFF (1<<18) // This toggles whether selecting the same ability again can toggle it off #define JOB_SLOT_RANDOMISED_SLOT -1 #define JOB_SLOT_CURRENT_SLOT 0 diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index c700a226295e..f42f350eea16 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -46,6 +46,7 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( /client/proc/toggle_eject_to_hand, /client/proc/toggle_automatic_punctuation, /client/proc/toggle_middle_mouse_click, + /client/proc/toggle_ability_deactivation, /client/proc/toggle_clickdrag_override, /client/proc/toggle_dualwield, /client/proc/toggle_middle_mouse_swap_hands, diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index d2d69d095dbd..5698c30c0acf 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -595,6 +595,8 @@ var/const/MAX_SAVE_SLOTS = 10 [toggle_prefs & TOGGLE_HELP_INTENT_SAFETY ? "On" : "Off"]
" dat += "Toggle Middle Mouse Ability Activation: \ [toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "On" : "Off"]
" + dat += "Toggle Ability Deactivation: \ + [toggle_prefs & TOGGLE_ABILITY_DEACTIVATION_OFF ? "Off" : "On"]
" dat += "Toggle Directional Assist: \ [toggle_prefs & TOGGLE_DIRECTIONAL_ATTACK ? "On" : "Off"]
" dat += "Toggle Magazine Auto-Ejection: \ @@ -1229,7 +1231,7 @@ var/const/MAX_SAVE_SLOTS = 10 predator_gender = predator_gender == MALE ? FEMALE : MALE if("pred_age") var/new_predator_age = tgui_input_number(user, "Choose your Predator's age(175 to 3000):", "Character Preference", 1234, 3000, 175) - if(new_predator_age) + if(new_predator_age) predator_age = max(min( round(text2num(new_predator_age)), 3000),175) if("pred_trans_type") var/new_translator_type = tgui_input_list(user, "Choose your translator type.", "Translator Type", PRED_TRANSLATORS) diff --git a/code/modules/client/preferences_toggles.dm b/code/modules/client/preferences_toggles.dm index 9e3d9eb33766..b81411a26440 100644 --- a/code/modules/client/preferences_toggles.dm +++ b/code/modules/client/preferences_toggles.dm @@ -205,7 +205,7 @@ set name = "Toggle SpecialRole Candidacy" set category = "Preferences" set desc = "Toggles which special roles you would like to be a candidate for, during events." - + var/list/be_special_flags = list( "Xenomorph after unrevivable death" = BE_ALIEN_AFTER_DEATH, "Agent" = BE_AGENT, @@ -274,6 +274,7 @@ "Toggle 'Unload Weapon' Ejecting Magazines to Your Hands
", "Toggle Automatic Punctuation
", "Toggle Middle Mouse Ability Activation
", + "Toggle Ability Deactivation
", "Toggle Combat Click-Drag Override
", "Toggle Alternate-Fire Dual Wielding
", "Toggle Middle Mouse Swapping Hands
", @@ -287,7 +288,7 @@ for (var/pref_button in pref_buttons) dat += "[pref_button]\n" - var/height = 50+22*length(pref_buttons) + var/height = 50+24*length(pref_buttons) show_browser(src, dat, "Toggle Preferences", "togglepreferences", "size=475x[height]") @@ -355,6 +356,14 @@ to_chat(src, SPAN_NOTICE("Your selected ability will now be activated with shift clicking.")) prefs.save_preferences() +/client/proc/toggle_ability_deactivation() // Toggle whether the current ability can be deactivated when re-selected + prefs.toggle_prefs ^= TOGGLE_ABILITY_DEACTIVATION_OFF + if (prefs.toggle_prefs & TOGGLE_ABILITY_DEACTIVATION_OFF) + to_chat(src, SPAN_NOTICE("Your current ability can no longer be toggled off when re-selected.")) + else + to_chat(src, SPAN_NOTICE("Your current ability can be toggled off when re-selected.")) + prefs.save_preferences() + /client/proc/toggle_clickdrag_override() //Toggle whether mousedown clicks immediately when on disarm or harm intent to prevent click-dragging from 'eating' attacks. prefs.toggle_prefs ^= TOGGLE_COMBAT_CLICKDRAG_OVERRIDE if(prefs.toggle_prefs & TOGGLE_COMBAT_CLICKDRAG_OVERRIDE) diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/xeno_action.dm b/code/modules/mob/living/carbon/xenomorph/abilities/xeno_action.dm index 60fdda450df3..f4d4628e41f2 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/xeno_action.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/xeno_action.dm @@ -158,6 +158,8 @@ if(xeno.selected_ability == src) if(xeno.deselect_timer > world.time) return // We clicked the same ability in a very short time + if(xeno.client && xeno.client.prefs && xeno.client.prefs.toggle_prefs & TOGGLE_ABILITY_DEACTIVATION_OFF) + return to_chat(xeno, "You will no longer use [ability_name] with \ [xeno.client && xeno.client.prefs && xeno.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].") button.icon_state = "template" diff --git a/code/modules/mob/living/carbon/xenomorph/xeno_verbs.dm b/code/modules/mob/living/carbon/xenomorph/xeno_verbs.dm index 20c170b72e4e..6b37145ad7a1 100644 --- a/code/modules/mob/living/carbon/xenomorph/xeno_verbs.dm +++ b/code/modules/mob/living/carbon/xenomorph/xeno_verbs.dm @@ -111,6 +111,21 @@ else to_chat(src, SPAN_NOTICE("The selected xeno ability will now be activated with shift clicking.")) +/mob/living/carbon/xenomorph/verb/ability_deactivation_toggle() + set name = "Toggle Ability Deactivation" + set desc = "Toggles whether you can deactivate your currently active ability when re-selecting it." + set category = "Alien" + + if (!client || !client.prefs) + return + + client.prefs.toggle_prefs ^= TOGGLE_ABILITY_DEACTIVATION_OFF + client.prefs.save_preferences() + if (client.prefs.toggle_prefs & TOGGLE_ABILITY_DEACTIVATION_OFF) + to_chat(src, SPAN_NOTICE("Your current ability can no longer be toggled off when re-selected.")) + else + to_chat(src, SPAN_NOTICE("Your current ability can be toggled off when re-selected.")) + /mob/living/carbon/xenomorph/verb/directional_attack_toggle() set name = "Toggle Directional Attacks" set desc = "Toggles the use of directional assist attacks."