some more 516 compat fixes (#89766)

Ports the helpers from
https://github.com/BeeStation/BeeStation-Hornet/pull/12240

This should fix some more of the 516 issues that I've seen while giving
a quick check through the code

The remaining browse should work now.

Also fixing another sass warning while being on it.

## About The Pull Request
## Why It's Good For The Game
## Changelog
🆑
fix: tgui say 516 will no longer change channels when the button is used
to drag it
fix: tgui say 516 will no longer leak radio messages into the wrong
channel
fix: runechat flickering when faded up messages fade out
/🆑
This commit is contained in:
Kashargul
2025-03-03 15:15:07 +01:00
committed by Roxy
parent b469a272fb
commit 68b687b13f
14 changed files with 57 additions and 33 deletions

View File

@@ -0,0 +1,5 @@
#define HTML_SKELETON_INTERNAL(head, body) \
"<!DOCTYPE html><html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'>[head]</head><body>[body]</body></html>"
#define HTML_SKELETON_TITLE(title, body) HTML_SKELETON_INTERNAL("<title>[title]</title>", body)
#define HTML_SKELETON(body) HTML_SKELETON_INTERNAL("", body)

View File

@@ -9,7 +9,7 @@
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"
if (user)
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[REF(stats)]")]")
user << browse(HTML_SKELETON("<ol><li>[lines.Join("</li><li>")]</li></ol>"), "window=[url_encode("stats:[REF(stats)]")]")
. = lines.Join("\n")

View File

@@ -394,7 +394,7 @@ SUBSYSTEM_DEF(dynamic)
if(!check_rights(R_ADMIN))
return
var/list/out = list("<TITLE>Threat Log</TITLE><B><font size='3'>Threat Log</font></B><br><B>Starting Threat:</B> [threat_level]<BR>")
var/list/out = list("<B><font size='3'>Threat Log</font></B><br><B>Starting Threat:</B> [threat_level]<BR>")
for(var/entry in threat_log)
if(istext(entry))
@@ -402,7 +402,7 @@ SUBSYSTEM_DEF(dynamic)
out += "<B>Remaining threat/threat_level:</B> [mid_round_budget]/[threat_level]"
usr << browse(out.Join(), "window=threatlog;size=700x500")
usr << browse(HTML_SKELETON_TITLE("Threat Log", out.Join()), "window=threatlog;size=700x500")
/// Generates the threat level using lorentz distribution and assigns peaceful_percentage.
/datum/controller/subsystem/dynamic/proc/generate_threat()

View File

@@ -224,13 +224,16 @@
// When choosing to update the remaining time we have to be careful not to update the
// scheduled time once the EOL has been executed.
var/continuing = 0
if (time_spent >= time_before_fade)
if(m.message.pixel_y < starting_height)
var/max_height = m.message.pixel_y + m.approx_lines * CHAT_MESSAGE_APPROX_LHEIGHT - starting_height
if(max_height > 0)
animate(m.message, pixel_y = m.message.pixel_y + max_height, time = CHAT_MESSAGE_SPAWN_TIME, flags = ANIMATION_PARALLEL)
animate(m.message, pixel_y = m.message.pixel_y + max_height, time = CHAT_MESSAGE_SPAWN_TIME, flags = continuing | ANIMATION_PARALLEL)
continuing |= ANIMATION_CONTINUE
else if(mheight + starting_height >= m.message.pixel_y)
animate(m.message, pixel_y = m.message.pixel_y + mheight, time = CHAT_MESSAGE_SPAWN_TIME, flags = ANIMATION_PARALLEL)
animate(m.message, pixel_y = m.message.pixel_y + mheight, time = CHAT_MESSAGE_SPAWN_TIME, flags = continuing | ANIMATION_PARALLEL)
continuing |= ANIMATION_CONTINUE
continue
var/remaining_time = time_before_fade * (CHAT_MESSAGE_EXP_DECAY ** idx++) * (CHAT_MESSAGE_HEIGHT_DECAY ** combined_height)
@@ -239,23 +242,29 @@
if(remaining_time > 0)
if(time_spent < CHAT_MESSAGE_SPAWN_TIME)
// We haven't even had the time to fade in yet!
animate(m.message, alpha = 255, CHAT_MESSAGE_SPAWN_TIME - time_spent)
animate(m.message, alpha = 255, CHAT_MESSAGE_SPAWN_TIME - time_spent, flags=continuing)
continuing |= ANIMATION_CONTINUE
// Stay faded in for a while, then
animate(m.message, alpha = 255, remaining_time, flags=ANIMATION_CONTINUE)
animate(m.message, alpha = 255, time = remaining_time, flags=continuing)
continuing |= ANIMATION_CONTINUE
// Fade out
animate(alpha = 0, time = CHAT_MESSAGE_EOL_FADE)
animate(m.message, alpha = 0, time = CHAT_MESSAGE_EOL_FADE, flags=continuing)
continuing |= ANIMATION_CONTINUE
m.animate_lifespan = remaining_time + CHAT_MESSAGE_EOL_FADE
else
// Your time has come my son
animate(alpha = 0, time = CHAT_MESSAGE_EOL_FADE)
animate(m.message, alpha = 0, time = CHAT_MESSAGE_EOL_FADE, flags=continuing)
continuing |= ANIMATION_CONTINUE
// We run this after the alpha animate, because we don't want to interrup it, but also don't want to block it by running first
// Sooo instead we do this. bit messy but it fuckin works
if(m.message.pixel_y < starting_height)
var/max_height = m.message.pixel_y + m.approx_lines * CHAT_MESSAGE_APPROX_LHEIGHT - starting_height
if(max_height > 0)
animate(m.message, pixel_y = m.message.pixel_y + max_height, time = CHAT_MESSAGE_SPAWN_TIME, flags = ANIMATION_PARALLEL)
animate(m.message, pixel_y = m.message.pixel_y + max_height, time = CHAT_MESSAGE_SPAWN_TIME, flags = continuing | ANIMATION_PARALLEL)
continuing |= ANIMATION_CONTINUE
else if(mheight + starting_height >= m.message.pixel_y)
animate(m.message, pixel_y = m.message.pixel_y + mheight, time = CHAT_MESSAGE_SPAWN_TIME, flags = ANIMATION_PARALLEL)
animate(m.message, pixel_y = m.message.pixel_y + mheight, time = CHAT_MESSAGE_SPAWN_TIME, flags = continuing | ANIMATION_PARALLEL)
continuing |= ANIMATION_CONTINUE
// Reset z index if relevant
if (current_z_idx >= CHAT_LAYER_MAX_Z)

View File

@@ -171,21 +171,15 @@ GLOBAL_DATUM_INIT(known_alts, /datum/known_alts, new)
known_alts_html += "<a href='byond://?src=[REF(src)];[HrefToken()];action=delete;id=[known_alt[4]]'>\[-\] Delete</a> <b>[known_alt[1]]</b> is an alt of <b>[known_alt[2]]</b> (added by <b>[known_alt[3]]</b>)."
var/html = {"
<head>
<title>Known Alts</title>
</head>
<body>
<p>Any two ckeys in this panel will not show in "banned connection history".</p>
<p>Sometimes players switch account, and it's customary to perma-ban the old one.</p>
<h2>All Known Alts:</h2> <a href='byond://?src=[REF(src)];[HrefToken()];action=add'>\[+\] Add</a><hr>
[known_alts_html.Join("<br />")]
</body>
"}
client << browse(html, "window=known_alts;size=700x400")
client << browse(HTML_SKELETON_TITLE("Known Alts", html), "window=known_alts;size=700x400")
ADMIN_VERB(known_alts_panel, R_ADMIN, "Known Alts Panel", "View a panel of known alts.", ADMIN_CATEGORY_MAIN)
GLOB.known_alts.show_panel(user)

View File

@@ -533,7 +533,7 @@ GLOBAL_DATUM_INIT(sdql2_vv_statobj, /obj/effect/statclick/sdql2_vv_all, new(null
if(length(select_text))
var/text = islist(select_text)? select_text.Join() : select_text
var/static/result_offset = 0
showmob << browse(text, "window=SDQL-result-[result_offset++]")
showmob << browse(HTML_SKELETON(text), "window=SDQL-result-[result_offset++]")
show_next_to_key = null
if(qdel_on_finish)
qdel(src)

View File

@@ -634,6 +634,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
if (related_ticket.id == id)
continue
dat += "[related_ticket.TicketHref("#[related_ticket.id]")] ([related_ticket.ticket_status()]): [related_ticket.name]<br/>"
dat += "</html>"
usr << browse(dat.Join(), "window=ahelp[id];size=750x480")

View File

@@ -16,7 +16,7 @@ ADMIN_VERB(get_current_logs, R_ADMIN, "Get Current Logs", "View or retrieve logf
message_admins("[key_name_admin(src)] accessed file: [path]")
switch(tgui_alert(usr,"View (in game), Open (in your system's text editor), or Download?", path, list("View", "Open", "Download")))
if ("View")
src << browse("<pre style='word-wrap: break-word;'>[html_encode(file2text(file(path)))]</pre>", list2params(list("window" = "viewfile.[path]")))
src << browse(HTML_SKELETON("<pre style='word-wrap: break-word;'>[html_encode(file2text(file(path)))]</pre>"), list2params(list("window" = "viewfile.[path]")))
if ("Open")
src << run(file(path))
if ("Download")

View File

@@ -61,7 +61,7 @@ ADMIN_VERB(sec_camera_report, R_DEBUG, "Camera Report", "Get a printout of all c
output += "<li><font color='red'>Camera not connected to wall at [ADMIN_VERBOSEJMP(C1)] Network: [json_encode(C1.network)]</font></li>"
output += "</ul>"
user << browse(output,"window=airreport;size=1000x500")
user << browse(HTML_SKELETON(output),"window=airreport;size=1000x500")
BLACKBOX_LOG_ADMIN_VERB("Show Camera Report")
ADMIN_VERB_VISIBILITY(intercom_view, ADMIN_VERB_VISIBLITY_FLAG_MAPPING_DEBUG)
@@ -86,7 +86,7 @@ ADMIN_VERB(show_map_reports, R_DEBUG, "Show Map Reports", "Displays a list of ma
for(var/datum/map_report/report as anything in GLOB.map_reports)
dat += "[report.tag] ([report.original_path]) - <a href='byond://?src=[REF(report)];[HrefToken()];show=1'>View</a><br>"
user << browse(dat, "window=map_reports")
user << browse(HTML_SKELETON(dat), "window=map_reports")
ADMIN_VERB_VISIBILITY(cmd_show_at_list, ADMIN_VERB_VISIBLITY_FLAG_MAPPING_DEBUG)
ADMIN_VERB(cmd_show_at_list, R_DEBUG, "Show roundstart AT list", "Displays a list of active turfs coordinates at roundstart.", ADMIN_CATEGORY_MAPPING)
@@ -98,7 +98,7 @@ ADMIN_VERB(cmd_show_at_list, R_DEBUG, "Show roundstart AT list", "Displays a lis
dat += "[ADMIN_VERBOSEJMP(T)]\n"
dat += "<br>"
user << browse(dat, "window=at_list")
user << browse(HTML_SKELETON(dat), "window=at_list")
BLACKBOX_LOG_ADMIN_VERB("Show Roundstart Active Turfs")

View File

@@ -455,7 +455,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
msg += "Your version: [byond_version].[byond_build]<br>"
msg += "Required version to remove this message: [warn_version].[warn_build] or later<br>"
msg += "Visit <a href=\"https://secure.byond.com/download\">BYOND's website</a> to get the latest version of BYOND.<br>"
src << browse(msg, "window=warning_popup")
src << browse(HTML_SKELETON(msg), "window=warning_popup")
else
to_chat(src, span_danger("<b>Your version of byond may be getting out of date:</b>"))
to_chat(src, CONFIG_GET(string/client_warn_message))

View File

@@ -20,7 +20,7 @@ GLOBAL_PROTECT(poll_options)
continue
output += "<tr bgcolor='#e2e2e2'><td><a href='byond://?src=[rs];viewpoll=[REF(poll)]'><b>[poll.question]</b></a></td></tr>"
output += "</table>"
src << browse(jointext(output, ""),"window=playerpolllist;size=500x300")
src << browse(HTML_SKELETON(jointext(output, "")),"window=playerpolllist;size=500x300")
/**
* Redirects a player to the correct poll window based on poll type.
@@ -86,7 +86,7 @@ GLOBAL_PROTECT(poll_options)
if(!voted_option_id || poll.allow_revoting)
output += "<p><input type='submit' value='Vote'></form>"
output += "</div>"
src << browse(jointext(output, ""),"window=playerpoll;size=500x250")
src << browse(HTML_SKELETON(jointext(output, "")),"window=playerpoll;size=500x250")
/**
* Shows voting window for a text response type poll, listing its relevant details.
@@ -123,7 +123,7 @@ GLOBAL_PROTECT(poll_options)
else
output += "[reply_text]"
output += "</div>"
src << browse(jointext(output, ""),"window=playerpoll;size=500x500")
src << browse(HTML_SKELETON(jointext(output, "")),"window=playerpoll;size=500x500")
/**
* Shows voting window for a rating type poll, listing its options and relevant details.
@@ -178,7 +178,7 @@ GLOBAL_PROTECT(poll_options)
if(!length(voted_ratings) || poll.allow_revoting)
output += "<p><input type='submit' value='Submit'></form>"
output += "</div>"
src << browse(jointext(output, ""),"window=playerpoll;size=500x500")
src << browse(HTML_SKELETON(jointext(output, "")),"window=playerpoll;size=500x500")
/**
* Shows voting window for a multiple choice type poll, listing its options and relevant details.
@@ -222,7 +222,7 @@ GLOBAL_PROTECT(poll_options)
if(!length(voted_for) || poll.allow_revoting)
output += "<p><input type='submit' value='Vote'></form>"
output += "</div>"
src << browse(jointext(output, ""),"window=playerpoll;size=500x300")
src << browse(HTML_SKELETON(jointext(output, "")),"window=playerpoll;size=500x300")
/**
* Shows voting window for an IRV type poll, listing its options and relevant details.
@@ -307,7 +307,7 @@ GLOBAL_PROTECT(poll_options)
output += "</ol><b><center>Least Preferred</center></b><br>"
if(!length(voted_for) || poll.allow_revoting)
output += "<p><input type='submit' value='Vote'></form>"
output += "</div>"
output += "</div></html>"
src << browse(jointext(output, ""),"window=playerpoll;size=500x500")
/**

View File

@@ -110,6 +110,7 @@
#include "code\__DEFINES\guardian_defines.dm"
#include "code\__DEFINES\holiday.dm"
#include "code\__DEFINES\holopads.dm"
#include "code\__DEFINES\html_assistant.dm"
#include "code\__DEFINES\hud.dm"
#include "code\__DEFINES\icon_smoothing.dm"
#include "code\__DEFINES\id_cards.dm"

View File

@@ -42,6 +42,7 @@ export function TguiSay() {
const [size, setSize] = useState(WindowSize.Small);
const [maxLength, setMaxLength] = useState(1024);
const [lightMode, setLightMode] = useState(false);
const [position, setPosition] = useState([window.screenX, window.screenY]);
const [value, setValue] = useState('');
function handleArrowKeys(direction: KEY.Up | KEY.Down): void {
@@ -128,6 +129,9 @@ export function TguiSay() {
}
function handleIncrementChannel(): void {
const xPos = window.screenX;
const yPos = window.screenY;
if (JSON.stringify(position) !== JSON.stringify([xPos, yPos])) return;
const iterator = channelIterator.current;
iterator.next();
@@ -137,6 +141,7 @@ export function TguiSay() {
}
function handleInput(event: FormEvent<HTMLTextAreaElement>): void {
const iterator = channelIterator.current;
let newValue = event.currentTarget.value;
let newPrefix = getPrefix(newValue) || currentPrefix;
@@ -145,6 +150,7 @@ export function TguiSay() {
setButtonContent(RADIO_PREFIXES[newPrefix]);
setCurrentPrefix(newPrefix);
newValue = newValue.slice(3);
iterator.set('Say');
if (newPrefix === ':b ') {
Byond.sendMessage('thinking', { visible: false });
@@ -191,6 +197,13 @@ export function TguiSay() {
}
}
function handleButtonDrag(e: React.MouseEvent<Element, MouseEvent>): void {
const xPos = window.screenX;
const yPos = window.screenY;
setPosition([xPos, yPos]);
dragStartHandler(e);
}
function handleOpen(data: ByondOpen): void {
setTimeout(() => {
innerRef.current?.focus();
@@ -261,7 +274,7 @@ export function TguiSay() {
<button
className={`button button-${theme}`}
onClick={handleIncrementChannel}
onMouseDown={dragStartHandler}
onMouseDown={handleButtonDrag}
type="button"
>
{buttonContent}

View File

@@ -1,3 +1,4 @@
@use 'sass:map';
@use '../colors.scss';
@use '../base.scss';
@@ -128,7 +129,7 @@ $category-colors: (
@each $category-name, $values in $category-colors {
.ObjectComponent__Category__#{$category-name} {
background-color: map-get($values, bg);
color: map-get($values, contrast);
background-color: map.get($values, bg);
color: map.get($values, contrast);
}
}