mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
Now indicator will disappear if for 30 seconds contents of chatbar didn't change. Moved all relevant vars to the typing_indicator.dm Added 'typing' var, as 'if(!(typing_indicator in overlays))' didn't work and overlays kept being added forever. Fixed preference toggle feedback being backwards. Fixed wrong verb called in hotkeys mode.
77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
#define TYPING_INDICATOR_LIFETIME 30 * 10 //grace period after which typing indicator disappears regardless of text in chatbar
|
|
|
|
mob/var/hud_typing = 0 //set when typing in an input window instead of chatline
|
|
mob/var/typing
|
|
mob/var/last_typed
|
|
mob/var/last_typed_time
|
|
|
|
var/global/image/typing_indicator
|
|
|
|
/mob/proc/set_typing_indicator(var/state)
|
|
if(client)
|
|
if(!(client.prefs.toggles & SHOW_TYPING))
|
|
if(!typing_indicator)
|
|
typing_indicator = image('icons/mob/talk.dmi',null,"typing")
|
|
if(state)
|
|
if(!typing)
|
|
overlays += typing_indicator
|
|
typing = 1
|
|
else
|
|
if(typing)
|
|
overlays -= typing_indicator
|
|
typing = 0
|
|
return state
|
|
|
|
/mob/verb/say_wrapper()
|
|
set name = ".Say"
|
|
set hidden = 1
|
|
|
|
set_typing_indicator(1)
|
|
hud_typing = 1
|
|
var/message = input("","say (text)") as text
|
|
hud_typing = 0
|
|
set_typing_indicator(0)
|
|
if(message)
|
|
say_verb(message)
|
|
|
|
/mob/verb/me_wrapper()
|
|
set name = ".Me"
|
|
set hidden = 1
|
|
|
|
set_typing_indicator(1)
|
|
hud_typing = 1
|
|
var/message = input("","me (text)") as text
|
|
hud_typing = 0
|
|
set_typing_indicator(0)
|
|
if(message)
|
|
me_verb(message)
|
|
|
|
/mob/proc/handle_typing_indicator()
|
|
if(client)
|
|
if(!(client.prefs.toggles & SHOW_TYPING) && !hud_typing)
|
|
var/temp = winget(client, "input", "text")
|
|
|
|
if (temp != last_typed)
|
|
last_typed = temp
|
|
last_typed_time = world.time
|
|
|
|
if (world.time > last_typed_time + TYPING_INDICATOR_LIFETIME)
|
|
set_typing_indicator(0)
|
|
return
|
|
if(length(temp) > 5 && findtext(temp, "Say \"", 1, 7))
|
|
set_typing_indicator(1)
|
|
else if(length(temp) > 3 && findtext(temp, "Me ", 1, 5))
|
|
set_typing_indicator(1)
|
|
|
|
else
|
|
set_typing_indicator(0)
|
|
|
|
/client/verb/typing_indicator()
|
|
set name = "Show/Hide Typing Indicator"
|
|
set category = "Preferences"
|
|
set desc = "Toggles showing an indicator when you are typing emote or say message."
|
|
prefs.toggles ^= SHOW_TYPING
|
|
prefs.save_preferences()
|
|
src << "You will [(prefs.toggles & CHAT_OOC) ? "no longer" : "now"] display typing indicator."
|
|
feedback_add_details("admin_verb","TID") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|