Merge pull request #12015 from kevinz000/typing_indicators

Typing Indicators (v2)
This commit is contained in:
Lin
2020-05-13 18:19:26 +00:00
committed by GitHub
15 changed files with 131 additions and 23 deletions
@@ -23,5 +23,4 @@
lay_down()
return
return ..()
@@ -104,6 +104,9 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
var/whitelist = list() //List the ckeys that can use this species, if it's whitelisted.: list("John Doe", "poopface666", "SeeALiggerPullTheTrigger") Spaces & capitalization can be included or ignored entirely for each key as it checks for both.
var/icon_limbs //Overrides the icon used for the limbs of this species. Mainly for downstream, and also because hardcoded icons disgust me. Implemented and maintained as a favor in return for a downstream's implementation of synths.
/// Our default override for typing indicator state
var/typing_indicator_state
///////////
// PROCS //
///////////
@@ -0,0 +1,2 @@
/mob/living/carbon/human/get_typing_indicator_icon_state()
return dna?.species?.typing_indicator_state || ..()
@@ -5,6 +5,8 @@
hud_possible = list(HEALTH_HUD,STATUS_HUD,ANTAG_HUD,NANITE_HUD,DIAG_NANITE_FULL_HUD,RAD_HUD)
pressure_resistance = 10
typing_indicator_enabled = TRUE
var/resize = 1 //Badminnery resize
var/lastattacker = null
var/lastattackerckey = null
@@ -1,6 +1,8 @@
/mob/living/Moved()
. = ..()
update_turf_movespeed(loc)
//Hide typing indicator if we move.
clear_typing_indicator()
if(is_shifted)
is_shifted = FALSE
pixel_x = get_standard_pixel_x_offset(lying)
+13
View File
@@ -130,3 +130,16 @@
var/siliconaccesstoggle = FALSE
var/voluntary_ghosted = FALSE //whether or not they voluntarily ghosted.
var/flavor_text = ""
var/flavor_text_2 = "" //version of the above that only lasts for the current round.
///////TYPING INDICATORS///////
/// Set to true if we want to show typing indicators.
var/typing_indicator_enabled = FALSE
/// Default icon_state of our typing indicator. Currently only supports paths (because anything else is, as of time of typing this, unnecesary.
var/typing_indicator_state = /obj/effect/overlay/typing_indicator
/// The timer that will remove our indicator for early aborts (like when an user finishes their message)
var/typing_indicator_timerid
/// Current state of our typing indicator. Used for cut overlay, DO NOT RUNTIME ASSIGN OTHER THAN FROM SHOW/CLEAR. Used to absolutely ensure we do not get stuck overlays.
var/typing_indicator_current
+47 -16
View File
@@ -1,12 +1,53 @@
//Speech verbs.
/mob/verb/say_verb(message as text)
set name = "Say"
// the _keybind verbs uses "as text" versus "as text|null" to force a popup when pressed by a keybind.
/mob/verb/say_typing_indicator()
set name = "say_indicator"
set hidden = TRUE
set category = "IC"
display_typing_indicator()
var/message = input(usr, "", "say") as text|null
// If they don't type anything just drop the message.
clear_typing_indicator() // clear it immediately!
if(!length(message))
return
return say_verb(message)
/mob/verb/say_verb(message as text)
set name = "say"
set category = "IC"
if(!length(message))
return
if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
return
if(message)
say(message)
clear_typing_indicator() // clear it immediately!
say(message)
/mob/verb/me_typing_indicator()
set name = "me_indicator"
set hidden = TRUE
set category = "IC"
display_typing_indicator()
var/message = input(usr, "", "me") as message|null
// If they don't type anything just drop the message.
clear_typing_indicator() // clear it immediately!
if(!length(message))
return
return me_verb(message)
/mob/verb/me_verb(message as message)
set name = "me"
set category = "IC"
if(!length(message))
return
if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
return
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
clear_typing_indicator() // clear it immediately!
usr.emote("me",1,message,TRUE)
/mob/say_mod(input, message_mode)
var/customsayverb = findtext(input, "*")
@@ -19,6 +60,8 @@
/mob/verb/whisper_verb(message as text)
set name = "Whisper"
set category = "IC"
if(!length(message))
return
if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
return
@@ -27,18 +70,6 @@
/mob/proc/whisper(message, datum/language/language=null)
say(message, language) //only living mobs actually whisper, everything else just talks
/mob/verb/me_verb(message as message)
set name = "Me"
set category = "IC"
if(GLOB.say_disabled) //This is here to try to identify lag problems
to_chat(usr, "<span class='danger'>Speech is currently admin-disabled.</span>")
return
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
usr.emote("me",1,message,TRUE)
/mob/proc/say_dead(var/message)
var/name = real_name
var/alt_name = ""
-1
View File
@@ -23,7 +23,6 @@ proc/get_top_level_mob(var/mob/S)
message = null
mob_type_blacklist_typecache = list(/mob/living/brain)
/datum/emote/living/subtle/proc/check_invalid(mob/user, input)
if(stop_bad_mime.Find(input, 1, 1))
to_chat(user, "<span class='danger'>Invalid emote.</span>")
+47
View File
@@ -0,0 +1,47 @@
/// state = overlay/image/object/type/whatever add_overlay will accept
GLOBAL_LIST_EMPTY(typing_indicator_overlays)
/// Fetches the typing indicator we'll use from GLOB.typing_indicator_overlays
/mob/proc/get_indicator_overlay(state)
. = GLOB.typing_indicator_overlays[state]
if(.)
return
// doesn't exist, make it and cache it
if(ispath(state))
. = GLOB.typing_indicator_overlays[state] = state
// We only support paths for now because anything else isn't necessary yet.
/// Gets the state we will use for typing indicators. Defaults to src.typing_indicator_state
/mob/proc/get_typing_indicator_icon_state()
return typing_indicator_state
/**
* Displays typing indicator.
* @param timeout_override - Sets how long until this will disappear on its own without the user finishing their message or logging out. Defaults to src.typing_indicator_timeout
* @param state_override - Sets the state that we will fetch. Defaults to src.get_typing_indicator_icon_state()
* @param force - shows even if src.typing_indcator_enabled is FALSE.
*/
/mob/proc/display_typing_indicator(timeout_override = TYPING_INDICATOR_TIMEOUT, state_override = get_typing_indicator_icon_state(), force = FALSE)
if((!typing_indicator_enabled && !force) || typing_indicator_current)
return
typing_indicator_current = state_override
add_overlay(state_override)
typing_indicator_timerid = addtimer(CALLBACK(src, .proc/clear_typing_indicator), timeout_override, TIMER_STOPPABLE)
/**
* Removes typing indicator.
*/
/mob/proc/clear_typing_indicator()
cut_overlay(typing_indicator_current)
typing_indicator_current = null
if(typing_indicator_timerid)
deltimer(typing_indicator_timerid)
typing_indicator_timerid = null
/// Default typing indicator
/obj/effect/overlay/typing_indicator
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
icon = 'icons/mob/talk.dmi'
icon_state = "normal_typing"
appearance_flags = RESET_COLOR | TILE_BOUND | PIXEL_SCALE
layer = ABOVE_FLY_LAYER