Skip to content

Commit

Permalink
TGS Test Merge (#7123)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm13-github committed Sep 7, 2024
2 parents ccffead + dba26e8 commit 8056d4e
Show file tree
Hide file tree
Showing 21 changed files with 198 additions and 100 deletions.
13 changes: 12 additions & 1 deletion code/__DEFINES/client_prefs.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#define BE_ALIEN_AFTER_DEATH (1<<0)
#define BE_AGENT (1<<1)

/// Determines how abilities are activated, whether they're activated via middle click, shift click or right click.
#define XENO_ABILITY_CLICK_MIDDLE 1
#define XENO_ABILITY_CLICK_SHIFT 2
#define XENO_ABILITY_CLICK_RIGHT 3

/// Update this to whatever the largest value of the XENO_ABILITY_CLICK_* defines is.
#define XENO_ABILITY_CLICK_MAX 3

//toggle_prefs bits from /datum/preferences
#define TOGGLE_IGNORE_SELF (1<<0) // Determines whether you will not hurt yourself when clicking yourself
#define TOGGLE_HELP_INTENT_SAFETY (1<<1) // Determines whether help intent will be completely harmless
#define TOGGLE_MIDDLE_MOUSE_CLICK (1<<2) // This toggles whether selected ability for xeno uses middle mouse clicking or shift clicking
// Deprecated. Can't remove this or bitshift values down because it would fuck up the savefiles
// Feel free to replace this whatever you want, if you can find a useful toggle for it. Alternatively, don't because savefiles using flags
// Is a complete and utter mistake.
#define TOGGLE_FREE_PLACE_YOUR_OWN_TOGGLE_HERE (1<<2)
#define TOGGLE_DIRECTIONAL_ATTACK (1<<3) // This toggles whether attacks for xeno use directional attacks
#define TOGGLE_AUTO_EJECT_MAGAZINE_OFF (1<<4) // This toggles whether guns with auto ejectors will not auto eject their magazines
// MUTUALLY EXCLUSIVE TO TOGGLE_AUTO_EJECT_MAGAZINE_TO_HAND
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
if(isRemoteControlling(user))
return TRUE
// If the user is not a xeno (with active ability) with the shift click pref on, we examine. God forgive me for snowflake
if(user.client?.prefs && !(user.client?.prefs?.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK))
if(user.get_ability_mouse_key() == XENO_ABILITY_CLICK_SHIFT)
if(isxeno(user))
var/mob/living/carbon/xenomorph/X = user
if(X.selected_ability)
Expand Down
26 changes: 16 additions & 10 deletions code/_onclick/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@


/mob/living/carbon/human/click(atom/A, list/mods)
if(mods["shift"] && !mods["middle"])
if(selected_ability && client && client.prefs && !(client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK))
selected_ability.use_ability(A)
return TRUE

if(mods["middle"] && !mods["shift"])
if(selected_ability && client && client.prefs && client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK)
selected_ability.use_ability(A)
return TRUE
var/use_ability = FALSE
switch(get_ability_mouse_key())
if(XENO_ABILITY_CLICK_SHIFT)
if(mods[SHIFT_CLICK] && mods[LEFT_CLICK])
use_ability = TRUE
if(XENO_ABILITY_CLICK_MIDDLE)
if(mods[MIDDLE_CLICK] && !mods[SHIFT_CLICK])
use_ability = TRUE
if(XENO_ABILITY_CLICK_RIGHT)
if(mods[RIGHT_CLICK])
use_ability = TRUE

if(selected_ability && use_ability)
selected_ability.use_ability(A)
return TRUE

if(interactee)
var/result = interactee.handle_click(src, A, mods)
if(result != HANDLE_CLICK_PASS_THRU)
return result

if (mods["middle"] && !mods["shift"] && ishuman(A) && get_dist(src, A) <= 1)
if (mods[MIDDLE_CLICK] && !mods[SHIFT_CLICK] && ishuman(A) && get_dist(src, A) <= 1)
var/mob/living/carbon/human/H = A
H.receive_from(src)
return TRUE
Expand Down
25 changes: 18 additions & 7 deletions code/_onclick/xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ so that it doesn't double up on the delays) so that it applies the delay immedia
handle_queued_action(target)
return TRUE

var/alt_pressed = mods["alt"] == "1"
var/shift_pressed = mods["shift"] == "1"
var/middle_pressed = mods["middle"] == "1"
var/left_pressed = mods[LEFT_CLICK] == "1"
var/alt_pressed = mods[ALT_CLICK] == "1"
var/shift_pressed = mods[SHIFT_CLICK] == "1"
var/middle_pressed = mods[MIDDLE_CLICK] == "1"
var/right_pressed = mods[RIGHT_CLICK] == "1"

if(alt_pressed && shift_pressed)
if(istype(target, /mob/living/carbon/xenomorph))
Expand All @@ -126,15 +128,24 @@ so that it doesn't double up on the delays) so that it applies the delay immedia
next_move = world.time + 3 // Some minimal delay so this isn't crazy spammy
return TRUE

var/middle_pref = client.prefs && (client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK) != 0 // client is already tested to be non-null by caller
if(selected_ability && shift_pressed == !middle_pref && middle_pressed == middle_pref)
var/preference = get_ability_mouse_key() // client is already tested to be non-null by caller
var/activate_ability = FALSE
switch(preference)
if(XENO_ABILITY_CLICK_MIDDLE)
activate_ability = middle_pressed && !shift_pressed
if(XENO_ABILITY_CLICK_RIGHT)
activate_ability = right_pressed
if(XENO_ABILITY_CLICK_SHIFT)
activate_ability = left_pressed && shift_pressed

if(activate_ability && selected_ability)
if(istype(target, /atom/movable/screen))
// Click through the UI: Currently this won't attempt to sprite click any mob there, just the turf
var/turf/turf = params2turf(mods["screen-loc"], get_turf(client.eye), client)
if(turf)
target = turf
if(selected_ability.use_ability_wrapper(target, mods))
return TRUE
selected_ability.use_ability_wrapper(target, mods)
return TRUE

if(next_move >= world.time)
return FALSE
Expand Down
12 changes: 5 additions & 7 deletions code/game/objects/items/devices/binoculars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,16 @@
return
var/mob/living/carbon/human/human = owner
if(human.selected_ability == src)
to_chat(human, "You will no longer use [name] with \
[human.client && human.client.prefs && human.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(human, "You will no longer use [name] with [human.get_ability_mouse_name()].")
button.icon_state = "template"
human.selected_ability = null
human.set_selected_ability(null)
else
to_chat(human, "You will now use [name] with \
[human.client && human.client.prefs && human.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(human, "You will now use [name] with [human.get_ability_mouse_name()].")
if(human.selected_ability)
human.selected_ability.button.icon_state = "template"
human.selected_ability = null
human.set_selected_ability(null)
button.icon_state = "template_on"
human.selected_ability = src
human.set_selected_ability(src)

/datum/action/item_action/specialist/spotter_target/can_use_action()
var/mob/living/carbon/human/human = owner
Expand Down
14 changes: 6 additions & 8 deletions code/game/objects/items/hoverpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,16 @@
. = ..()
var/mob/living/carbon/human/H = owner
if(H.selected_ability == src)
to_chat(H, "You will no longer use [name] with \
[H.client && H.client.prefs && H.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(H, "You will no longer use [name] with [H.get_ability_mouse_name()].")
button.icon_state = "template"
H.selected_ability = null
H.set_selected_ability(null)
else
to_chat(H, "You will now use [name] with \
[H.client && H.client.prefs && H.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(H, "You will now use [name] with [H.get_ability_mouse_name()].")
if(H.selected_ability)
H.selected_ability.button.icon_state = "template"
H.selected_ability = null
H.set_selected_ability(null)
button.icon_state = "template_on"
H.selected_ability = src
H.set_selected_ability(src)

/datum/action/item_action/hover/update_button_icon()
var/obj/item/hoverpack/HP = holder_item
Expand All @@ -246,7 +244,7 @@
/datum/action/item_action/hover/remove_from(mob/living/carbon/human/H)
..()
if(H.selected_ability == src)
H.selected_ability = null
H.set_selected_ability(null)
update_button_icon()
button.icon_state = "template"

Expand Down
11 changes: 10 additions & 1 deletion code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list(
/client/proc/toggle_eject_to_hand,
/client/proc/toggle_automatic_punctuation,
/client/proc/toggle_ammo_display_type,
/client/proc/toggle_middle_mouse_click,
/client/proc/toggle_ability_deactivation,
/client/proc/toggle_clickdrag_override,
/client/proc/toggle_dualwield,
Expand Down Expand Up @@ -912,3 +911,13 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list(
return TRUE

return FALSE

/client/proc/set_right_click_menu_mode(shift_only)
if(shift_only)
winset(src, "mapwindow.map", "right-click=true")
winset(src, "ShiftUp", "is-disabled=false")
winset(src, "Shift", "is-disabled=false")
else
winset(src, "mapwindow.map", "right-click=false")
winset(src, "default.Shift", "is-disabled=true")
winset(src, "default.ShiftUp", "is-disabled=true")
32 changes: 28 additions & 4 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ GLOBAL_LIST_INIT(bgstate_options, list(
var/lastchangelog = "" // Saved changlog filesize to detect if there was a change
var/ooccolor
var/be_special = 0 // Special role selection
var/toggle_prefs = TOGGLE_MIDDLE_MOUSE_CLICK|TOGGLE_DIRECTIONAL_ATTACK|TOGGLE_MEMBER_PUBLIC|TOGGLE_AMBIENT_OCCLUSION|TOGGLE_VEND_ITEM_TO_HAND // flags in #define/mode.dm
var/toggle_prefs = TOGGLE_DIRECTIONAL_ATTACK|TOGGLE_MEMBER_PUBLIC|TOGGLE_AMBIENT_OCCLUSION|TOGGLE_VEND_ITEM_TO_HAND // flags in #define/mode.dm
var/xeno_ability_click_mode = XENO_ABILITY_CLICK_MIDDLE
var/auto_fit_viewport = FALSE
var/adaptive_zoom = 0
var/UI_style = "midnight"
Expand Down Expand Up @@ -604,6 +605,7 @@ GLOBAL_LIST_INIT(bgstate_options, list(
dat += "<b>Play Lobby Music:</b> <a href='?_src_=prefs;preference=lobby_music'><b>[(toggles_sound & SOUND_LOBBY) ? "Yes" : "No"]</b></a><br>"
dat += "<b>Play VOX Announcements:</b> <a href='?_src_=prefs;preference=sound_vox'><b>[(hear_vox) ? "Yes" : "No"]</b></a><br>"
dat += "<b>Default Ghost Night Vision Level:</b> <a href='?_src_=prefs;preference=ghost_vision_pref;task=input'><b>[ghost_vision_pref]</b></a><br>"
dat += "<b>Button To Activate Xenomorph Abilities:</b> <a href='?_src_=prefs;preference=mouse_button_activation;task=input'><b>[xeno_ability_mouse_pref_to_string(xeno_ability_click_mode)]</b></a><br>"
dat += "<a href='?src=\ref[src];action=proccall;procpath=/client/proc/receive_random_tip'>Read Random Tip of the Round</a><br>"
if(CONFIG_GET(flag/allow_Metadata))
dat += "<b>OOC Notes:</b> <a href='?_src_=prefs;preference=metadata;task=input'> Edit </a>"
Expand All @@ -615,8 +617,6 @@ GLOBAL_LIST_INIT(bgstate_options, list(
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_IGNORE_SELF]'><b>[toggle_prefs & TOGGLE_IGNORE_SELF ? "Off" : "On"]</b></a><br>"
dat += "<b>Toggle Help Intent Safety: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_HELP_INTENT_SAFETY]'><b>[toggle_prefs & TOGGLE_HELP_INTENT_SAFETY ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Middle Mouse Ability Activation: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_MIDDLE_MOUSE_CLICK]'><b>[toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "On" : "Off"]</b></a><br>"
dat += "<b>Toggle Ability Deactivation: \
</b> <a href='?_src_=prefs;preference=toggle_prefs;flag=[TOGGLE_ABILITY_DEACTIVATION_OFF]'><b>[toggle_prefs & TOGGLE_ABILITY_DEACTIVATION_OFF ? "Off" : "On"]</b></a><br>"
dat += "<b>Toggle Directional Assist: \
Expand Down Expand Up @@ -1249,7 +1249,31 @@ GLOBAL_LIST_INIT(bgstate_options, list(
if(!choice)
return
ghost_vision_pref = choice

if("mouse_button_activation")
var/static/list/mouse_button_list = list(
xeno_ability_mouse_pref_to_string(XENO_ABILITY_CLICK_MIDDLE) = XENO_ABILITY_CLICK_MIDDLE,
xeno_ability_mouse_pref_to_string(XENO_ABILITY_CLICK_SHIFT) = XENO_ABILITY_CLICK_SHIFT,
xeno_ability_mouse_pref_to_string(XENO_ABILITY_CLICK_RIGHT) = XENO_ABILITY_CLICK_RIGHT
)
var/choice = tgui_input_list(user, "Choose how you will activate your xenomorph and human abilities.", "Mouse Activation Button", mouse_button_list)
if(!choice)
return
xeno_ability_click_mode = mouse_button_list[choice]
// This isn't that great of a way to do it, but ability code is already not that modular considering
// the fact that we have two datums for xeno/human abilities. Might need to refactor abilities as a whole in the future
// so that the `activable` type is the parent of both xeno/human abilities - it would get rid of this headache in an instant.
if(isxeno(user))
var/mob/living/carbon/xenomorph/xeno = user
if(xeno.selected_ability)
var/datum/action/xeno_action/activable/ability = xeno.selected_ability
xeno.set_selected_ability(null)
xeno.set_selected_ability(ability)
if(ishuman(user))
var/mob/living/carbon/human/human = user
if(human.selected_ability)
var/datum/action/human_action/activable/ability = human.selected_ability
human.set_selected_ability(null)
human.set_selected_ability(ability)
if("synth_name")
var/raw_name = input(user, "Choose your Synthetic's name:", "Character Preference") as text|null
if(raw_name) // Check to ensure that the user entered text (rather than cancel.)
Expand Down
14 changes: 13 additions & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 25
#define SAVEFILE_VERSION_MAX 26

//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
Expand Down Expand Up @@ -152,6 +152,15 @@
S["nanotrasen_relation"] >> relation
S["weyland_yutani_relation"] << relation

if(savefile_version < 26)
// Removes TOGGLE_MIDDLE_MOUSE_CLICK (1<<2) and replaces it with a new pref
var/toggle_prefs = 0
S["toggle_prefs"] >> toggle_prefs
if(toggle_prefs & (1<<2))
S["xeno_ability_click_mode"] << XENO_ABILITY_CLICK_MIDDLE
else
S["xeno_ability_click_mode"] << XENO_ABILITY_CLICK_SHIFT

savefile_version = SAVEFILE_VERSION_MAX
return 1

Expand Down Expand Up @@ -197,6 +206,7 @@
S["toggles_langchat"] >> toggles_langchat
S["toggles_sound"] >> toggles_sound
S["toggle_prefs"] >> toggle_prefs
S["xeno_ability_click_mode"] >> xeno_ability_click_mode
S["dual_wield_pref"] >> dual_wield_pref
S["toggles_flashing"] >> toggles_flashing
S["toggles_ert"] >> toggles_ert
Expand Down Expand Up @@ -284,6 +294,7 @@
toggles_langchat = sanitize_integer(toggles_langchat, 0, SHORT_REAL_LIMIT, initial(toggles_langchat))
toggles_sound = sanitize_integer(toggles_sound, 0, SHORT_REAL_LIMIT, initial(toggles_sound))
toggle_prefs = sanitize_integer(toggle_prefs, 0, SHORT_REAL_LIMIT, initial(toggle_prefs))
xeno_ability_click_mode = sanitize_integer(xeno_ability_click_mode, 1, XENO_ABILITY_CLICK_MAX, initial(xeno_ability_click_mode))
dual_wield_pref = sanitize_integer(dual_wield_pref, 0, 2, initial(dual_wield_pref))
toggles_flashing= sanitize_integer(toggles_flashing, 0, SHORT_REAL_LIMIT, initial(toggles_flashing))
toggles_ert = sanitize_integer(toggles_ert, 0, SHORT_REAL_LIMIT, initial(toggles_ert))
Expand Down Expand Up @@ -399,6 +410,7 @@
S["toggles_langchat"] << toggles_langchat
S["toggles_sound"] << toggles_sound
S["toggle_prefs"] << toggle_prefs
S["xeno_ability_click_mode"] << xeno_ability_click_mode
S["dual_wield_pref"] << dual_wield_pref
S["toggles_flashing"] << toggles_flashing
S["toggles_ert"] << toggles_ert
Expand Down
9 changes: 0 additions & 9 deletions code/modules/client/preferences_toggles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_ammo_display_type'>Toggle Semi-Auto Ammo Counter</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_eject_to_hand'>Toggle 'Unload Weapon' Ejecting Magazines to Your Hands</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_automatic_punctuation'>Toggle Automatic Punctuation</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_middle_mouse_click'>Toggle Middle Mouse Ability Activation</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_ability_deactivation'>Toggle Ability Deactivation</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_clickdrag_override'>Toggle Combat Click-Drag Override</a><br>",
"<a href='?src=\ref[src];action=proccall;procpath=/client/proc/toggle_dualwield'>Toggle Alternate-Fire Dual Wielding</a><br>",
Expand Down Expand Up @@ -358,14 +357,6 @@
to_chat(src, SPAN_BOLDNOTICE("Your messages will no longer be automatically punctuated if they are not punctuated already."))
prefs.save_preferences()

/client/proc/toggle_middle_mouse_click() // Toggle whether abilities should use middle or shift clicking
prefs.toggle_prefs ^= TOGGLE_MIDDLE_MOUSE_CLICK
if (prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK)
to_chat(src, SPAN_NOTICE("Your selected ability will now be activated with middle clicking."))
else
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)
Expand Down
27 changes: 17 additions & 10 deletions code/modules/mob/living/carbon/human/human_abilities.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/mob/living/carbon/human/proc/set_selected_ability(datum/action/human_action/activable/ability)
if(!ability)
selected_ability = null
client?.set_right_click_menu_mode(shift_only = FALSE)
return
selected_ability = ability
if(get_ability_mouse_key() == XENO_ABILITY_CLICK_RIGHT)
client?.set_right_click_menu_mode(shift_only = TRUE)

/datum/action/human_action/update_button_icon()
if(action_cooldown_check())
button.color = rgb(120,120,120,200)
Expand Down Expand Up @@ -135,12 +144,12 @@

var/list/target_list = list()
for(var/mob/living/carbon/possible_target in view(7, human_owner))
if(possible_target == human_owner || !possible_target.client)
if(possible_target == human_owner || !possible_target.client)
continue
target_list += possible_target

var/mob/living/carbon/target_mob = tgui_input_list(human_owner, "Target", "Send a Psychic Whisper to whom?", target_list, theme = "hive_status")
if(!target_mob)
if(!target_mob)
return

human_owner.psychic_whisper(target_mob)
Expand All @@ -163,23 +172,21 @@ CULT
return
var/mob/living/carbon/human/H = owner
if(H.selected_ability == src)
to_chat(H, "You will no longer use [name] with \
[H.client && H.client.prefs && H.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(H, "You will no longer use [name] with [H.get_ability_mouse_name()].")
button.icon_state = "template"
H.selected_ability = null
H.set_selected_ability(null)
else
to_chat(H, "You will now use [name] with \
[H.client && H.client.prefs && H.client.prefs.toggle_prefs & TOGGLE_MIDDLE_MOUSE_CLICK ? "middle-click" : "shift-click"].")
to_chat(H, "You will now use [name] with [H.get_ability_mouse_name()].")
if(H.selected_ability)
H.selected_ability.button.icon_state = "template"
H.selected_ability = null
H.set_selected_ability(null)
button.icon_state = "template_on"
H.selected_ability = src
H.set_selected_ability(src)

/datum/action/human_action/activable/remove_from(mob/living/carbon/human/H)
..()
if(H.selected_ability == src)
H.selected_ability = null
H.set_selected_ability(null)

/datum/action/human_action/activable/proc/use_ability(mob/M)
return
Expand Down
5 changes: 4 additions & 1 deletion code/modules/mob/living/carbon/human/login.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/mob/living/carbon/human/Login()
..()
if(species) species.handle_login_special(src)
if(species)
species.handle_login_special(src)
if(selected_ability)
set_selected_ability(null)
Loading

0 comments on commit 8056d4e

Please sign in to comment.