Skip to content

Commit

Permalink
Ports 'Command bar typing indicators (client side html version)' (#3080)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Directly ports tgstation/tgstation#83081,
allowing typing indicators to trigger off of the command bar.
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
Typing indicators are there for a reason! It's helpful to know if
another player is cooking a message for thirty seconds or just staring
at you. However, a good chunk of our players exclusively use the command
bar to send messages, leaving us in the dark! This helps level the
playing field.
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
add: typing indicators now trigger off of the command bar
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Skies-Of-Blue authored Jul 14, 2024
1 parent e7e7ca9 commit d42c0e6
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion check_regex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ standards:

- exactly:
[
265,
266,
"non-bitwise << uses",
'(?<!\d)(?<!\d\s)(?<!<)<<(?!=|\s\d|\d|<|\/)',
]
Expand Down
5 changes: 5 additions & 0 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
cmd_admin_pm(href_list["priv_msg"],null)
return

if(href_list["commandbar_typing"])
handle_commandbar_typing(href_list)

switch(href_list["_src_"])
if("holder")
hsrc = holder
Expand Down Expand Up @@ -226,6 +229,8 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
// Instantiate tgui panel
tgui_panel = new(src, "browseroutput")

initialize_commandbar_spy()

GLOB.ahelp_tickets.client_login(src)
GLOB.interviews.client_login(src)
GLOB.requests.client_login(src)
Expand Down
28 changes: 28 additions & 0 deletions code/modules/client/verbs/typing.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#define IC_VERBS list("say", "me", "whisper")

/client/var/commandbar_thinking = FALSE
/client/var/commandbar_typing = FALSE

/client/proc/initialize_commandbar_spy()
src << output('html/typing_indicator.html', "commandbar_spy")

/client/proc/handle_commandbar_typing(href_list)
if (length(href_list["verb"]) < 1 || !(lowertext(href_list["verb"]) in IC_VERBS) || text2num(href_list["argument_length"]) < 1)
if (commandbar_typing)
commandbar_typing = FALSE
stop_typing()
return

if (!commandbar_typing)
commandbar_typing = TRUE
start_typing()

/client/proc/start_typing()
mob.set_typing_indicator(TRUE)

/client/proc/stop_typing()
if(isnull(mob))
return FALSE
mob.set_typing_indicator(FALSE)

#undef IC_VERBS
46 changes: 46 additions & 0 deletions html/typing_indicator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<script>
lastseentypedtext = "";
function getoutput() {
setTimeout(getoutput, 1000);
window.location = "byond://winget?callback=checkoutput&id=:Input&property=text";
}
function checkoutput(props) {
if (typeof props !== 'object')
return;

if (typeof props.text !== 'string' && !(props.text instanceof String))
return;

var text = props.text;

if (text == lastseentypedtext)
return;

lastseentypedtext = text;

var words = text.split(" ");
var verb = words[0];
var argument = "";
var argument_length = -1;

if (words.length >= 2) {
words.splice(0, 1)
argument = words.join(" ");
argument_length = argument.length;
}

if (argument_length > 0 && argument[0] == "\"")
argument_length -= 1;

window.location = "byond://?commandbar_typing=1&verb="+encodeURIComponent(verb)+"&argument_length="+argument_length;
}
setTimeout(getoutput, 2000);
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions interface/skin.dmf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ window "mainwindow"
background-color = #272727
is-visible = false
saved-params = ""
elem "commandbar_spy"
type = BROWSER
is-default = false
pos = 0,0
size = 200x200
anchor1 = -1,-1
anchor2 = -1,-1
is-visible = false
saved-params = ""

window "mapwindow"
elem "mapwindow"
Expand Down
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,7 @@
#include "code\modules\client\verbs\ooc.dm"
#include "code\modules\client\verbs\ping.dm"
#include "code\modules\client\verbs\reset_held_keys.dm"
#include "code\modules\client\verbs\typing.dm"
#include "code\modules\client\verbs\who.dm"
#include "code\modules\clothing\chameleon.dm"
#include "code\modules\clothing\clothing.dm"
Expand Down

0 comments on commit d42c0e6

Please sign in to comment.