Merge pull request #15962 from SandPoot/contextual-screentips

Contextual screentips -- Screentips now show you what items/objects can do
This commit is contained in:
Timothy Teakettle
2023-02-15 23:04:54 +00:00
committed by GitHub
33 changed files with 1007 additions and 24 deletions
+10 -3
View File
@@ -62,7 +62,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/UI_style = null
var/outline_enabled = TRUE
var/outline_color = COLOR_THEME_MIDNIGHT
var/screentip_pref = TRUE
var/screentip_pref = SCREENTIP_PREFERENCE_ENABLED
var/screentip_color = "#ffd391"
var/buttons_locked = FALSE
var/hotkeys = FALSE
@@ -827,7 +827,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<b>UI Style:</b> <a href='?_src_=prefs;task=input;preference=ui'>[UI_style]</a><br>"
dat += "<b>Outline:</b> <a href='?_src_=prefs;preference=outline_enabled'>[outline_enabled ? "Enabled" : "Disabled"]</a><br>"
dat += "<b>Outline Color:</b> [outline_color ? "<span style='border:1px solid #161616; background-color: [outline_color];'>" : "Theme-based (null)"]&nbsp;&nbsp;&nbsp;</span> <a href='?_src_=prefs;preference=outline_color'>Change</a><BR>"
dat += "<b>Screentip:</b> <a href='?_src_=prefs;preference=screentip_pref'>[screentip_pref ? "Enabled" : "Disabled"]</a><br>"
dat += "<b>Screentip:</b> <a href='?_src_=prefs;preference=screentip_pref'>[screentip_pref]</a><br>"
dat += "<b>Screentip Color:</b> <span style='border:1px solid #161616; background-color: [screentip_color];'>&nbsp;&nbsp;&nbsp;</span> <a href='?_src_=prefs;preference=screentip_color'>Change</a><BR>"
dat += "<b>tgui Monitors:</b> <a href='?_src_=prefs;preference=tgui_lock'>[(tgui_lock) ? "Primary" : "All"]</a><br>"
dat += "<b>tgui Style:</b> <a href='?_src_=prefs;preference=tgui_fancy'>[(tgui_fancy) ? "Fancy" : "No Frills"]</a><br>"
@@ -2913,7 +2913,14 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(pickedOutlineColor != pickedOutlineColor)
outline_color = pickedOutlineColor // nullable
if("screentip_pref")
screentip_pref = !screentip_pref
var/choice = tgalert(user, "Choose your screentip preference", "Screentipping?", "Yes", "Context Only", "No")
switch(choice)
if("Yes")
screentip_pref = SCREENTIP_PREFERENCE_ENABLED
if("Context Only")
screentip_pref = SCREENTIP_PREFERENCE_CONTEXT_ONLY
else
screentip_pref = SCREENTIP_PREFERENCE_DISABLED
if("screentip_color")
var/pickedScreentipColor = input(user, "Choose your screentip color.", "General Preference", screentip_color) as color|null
if(pickedScreentipColor)
+7 -1
View File
@@ -5,7 +5,7 @@
// You do not need to raise this if you are adding new values that have sane defaults.
// Only raise this value when changing the meaning/format/name/layout of an existing value
// where you would want the updater procs below to run
#define SAVEFILE_VERSION_MAX 56
#define SAVEFILE_VERSION_MAX 57
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
@@ -56,6 +56,12 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
be_special -= "NO_ANTAGS"
for(var/be_special_type in be_special)
be_special[be_special_type] = 1
if(current_version < 57)
if(screentip_pref)
screentip_pref = SCREENTIP_PREFERENCE_ENABLED
else
// Let's give it a little chance okay, change if you don't like still.
screentip_pref = SCREENTIP_PREFERENCE_CONTEXT_ONLY
/datum/preferences/proc/update_character(current_version, savefile/S)
if(current_version < 19)
+1
View File
@@ -8,6 +8,7 @@
GLOB.carbon_list += src
blood_volume = (BLOOD_VOLUME_NORMAL * blood_ratio)
add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling)
register_context()
/mob/living/carbon/Destroy()
//This must be done first, so the mob ghosts correctly before DNA etc is nulled
@@ -0,0 +1,48 @@
/mob/living/carbon/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
. = ..()
if (!isnull(held_item))
return .
if (!ishuman(user))
return .
var/combat_mode = SEND_SIGNAL(user, COMSIG_COMBAT_MODE_CHECK, COMBAT_MODE_ACTIVE)
if(user == src)
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_HELP, "Check injuries")
else if(!lying)
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_HELP, "Comfort")
else if (health >= 0 && !HAS_TRAIT(src, TRAIT_FAKEDEATH))
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_HELP, "Shake")
else
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_HELP, "CPR")
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_DISARM, "Disarm")
if(combat_mode && (src != user))
LAZYSET(context[SCREENTIP_CONTEXT_RMB], INTENT_DISARM, "Shove")
if(src != user)
if (pulledby == user)
switch (user.grab_state)
if (GRAB_PASSIVE)
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_GRAB, "Grip")
if (GRAB_AGGRESSIVE)
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_GRAB, "Choke")
if (GRAB_NECK)
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_GRAB, "Strangle")
else
return .
else
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_GRAB, "Pull")
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_HARM, "Attack")
// Monkeys cannot be grabbed harder using ctrl-click, don't ask.
if((pulledby != user) && (src != user))
LAZYSET(context[SCREENTIP_CONTEXT_CTRL_LMB], INTENT_ANY, "Pull")
// Happens on any intent i believe
if((user == src) && combat_mode && lying)
LAZYSET(context[SCREENTIP_CONTEXT_RMB], INTENT_ANY, "Force to get up")
return CONTEXTUAL_SCREENTIP_SET
@@ -0,0 +1,36 @@
/mob/living/carbon/human/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
. = ..()
if (!ishuman(user))
return .
var/aim_for_mouth = user.zone_selected == "mouth"
var/target_on_help = a_intent == INTENT_HELP
var/target_aiming_for_mouth = zone_selected == "mouth"
var/target_restrained = restrained()
var/same_dir = (dir & user.dir)
var/aim_for_groin = user.zone_selected == "groin"
var/target_aiming_for_groin = zone_selected == "groin"
if(aim_for_mouth && (target_on_help || target_restrained || target_aiming_for_mouth))
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_DISARM, "Slap face")
else if(aim_for_groin && (src == user || lying || same_dir) && (target_on_help || target_restrained || target_aiming_for_groin))
LAZYSET(context[SCREENTIP_CONTEXT_LMB], INTENT_DISARM, "Slap ass")
// Humans can actually be upgrade grabbed using ctrl-click
if(src != user)
if (pulledby == user)
switch (user.grab_state)
if (GRAB_PASSIVE)
LAZYSET(context[SCREENTIP_CONTEXT_CTRL_LMB], INTENT_ANY, "Grip")
if (GRAB_AGGRESSIVE)
LAZYSET(context[SCREENTIP_CONTEXT_CTRL_LMB], INTENT_ANY, "Choke")
if (GRAB_NECK)
LAZYSET(context[SCREENTIP_CONTEXT_CTRL_LMB], INTENT_ANY, "Strangle")
else
return .
else
LAZYSET(context[SCREENTIP_CONTEXT_CTRL_LMB], INTENT_ANY, "Pull")
return CONTEXTUAL_SCREENTIP_SET
@@ -3,6 +3,8 @@
return
/mob/living/carbon/get_bodypart(zone)
RETURN_TYPE(/obj/item/bodypart)
if(!zone)
zone = BODY_ZONE_CHEST
for(var/X in bodyparts)