Skip to content

Commit

Permalink
Merge pull request #68 from Starfly-13/Ports-'Command-bar-typing-indi…
Browse files Browse the repository at this point in the history
…cators-(client-side-html-version)

Ports-'Command-bar-typing-indicators-(client-side-html-version)
  • Loading branch information
lectronyx authored Jun 13, 2024
2 parents f165b98 + 8863410 commit 44764d9
Show file tree
Hide file tree
Showing 5 changed files with 89 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:
[
269,
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

0 comments on commit 44764d9

Please sign in to comment.