Skip to content

Commit

Permalink
516 prep: fix chat window z-fighting and tgui-say escape key (#4615)
Browse files Browse the repository at this point in the history
* 516: fix chat window z-fighting and tgui-say escape key

Port of ParadiseSS13/Paradise#27676, which in turn is a port of VOREStation/VOREStation#16713 and VOREStation/VOREStation#16734

* revert a bad fix

* iffy but workable fix for topic spam bug

* possible true fix?

* some fixes

* add a 516 beta notic

* remove 515 experiment stuff

* Port my implementation from tgstation/tgstation#88624

* fix scrollbar

ports tgstation/tgstation#88617

* update experiments.dm to what /tg/ is doing

* remove those outdated comments

* Revert "fix scrollbar" (lmao UIs are huge)

This reverts commit 7c43266.

* update these two
  • Loading branch information
Absolucy authored Dec 25, 2024
1 parent e02822d commit f24cb08
Show file tree
Hide file tree
Showing 16 changed files with 849 additions and 711 deletions.
11 changes: 4 additions & 7 deletions code/_experiments.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
// Any flag you see here can be flipped with the `-D` CLI argument.
// For example, if you want to enable EXPERIMENT_MY_COOL_FEATURE, compile with -DEXPERIMENT_MY_COOL_FEATURE

// EXPERIMENT_515_QDEL_HARD_REFERENCE
// - Hold a hard reference for qdeleted items, and check ref_count, rather than using refs. Requires 515+.

// EXPERIMENT_515_DONT_CACHE_REF
// - Avoids `text_ref` caching, aided by improvements to ref() speed in 515.
// EXPERIMENT_MY_COOL_FEATURE
// - Does something really cool, just so neat, absolutely banging, gaming and chill

#if DM_VERSION < 515

Expand All @@ -20,6 +17,6 @@
#define EXPERIMENT_MY_COOL_FEATURE
#endif

#if DM_VERSION >= 516
#error "Remove all 515 experiments"
#if DM_VERSION >= 517
#error "Remove all 516 experiments"
#endif
3 changes: 2 additions & 1 deletion code/controllers/subsystem/statpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ SUBSYSTEM_DEF(statpanels)
return

/datum/controller/subsystem/statpanels/proc/set_status_tab(client/target)
var/static/list/beta_notice = list("", "You are on the BYOND 516 beta, various UIs and such may be broken!", "Please report issues, and switch back to BYOND 515 if things are causing too many issues for you.")
if(!global_data)//statbrowser hasnt fired yet and we were called from immediate_send_stat_data()
return

target.stat_panel.send_message("update_stat", list(
"global_data" = global_data,
"global_data" = (target.byond_version < 516) ? global_data : (global_data + beta_notice),
"ping_str" = "Ping: [round(target.lastping, 1)]ms (Average: [round(target.avgping, 1)]ms)",
"other_str" = target.mob?.get_status_tab_items(),
))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/holder2.dm
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ GLOBAL_PROTECT(href_token)
/datum/admins/proc/try_give_devtools()
if(!(rank_flags() & R_DEBUG) || owner.byond_version < 516)
return
winset(owner, null, "browser-options=byondstorage,find,devtools")
winset(owner, null, "browser-options=byondstorage,find,refresh,devtools")

/datum/admins/proc/try_give_profiling()
if (CONFIG_GET(flag/forbid_admin_profiling))
Expand Down
5 changes: 4 additions & 1 deletion code/modules/asset_cache/asset_cache_client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
var/job = ++last_asset_job
var/t = 0
var/timeout_time = timeout
src << browse({"<script>window.location.href="?asset_cache_confirm_arrival=[job]"</script>"}, "window=asset_cache_browser&file=asset_cache_send_verify.htm")
if(byond_version < 516)
src << browse({"<script>window.location.href="byond://?asset_cache_confirm_arrival=[job]"</script>"}, "window=asset_cache_browser&file=asset_cache_send_verify.htm")
else
src << browse({"<script>var xhr = new XMLHttpRequest(); xhr.open('GET', 'byond://?asset_cache_confirm_arrival=[job]', true); xhr.send(null);</script>"}, "window=asset_cache_browser&file=asset_cache_send_verify.htm")

while(!completed_asset_jobs["[job]"] && t < timeout_time) // Reception is handled in Topic()
stoplag(1) // Lock up the caller until this is received.
Expand Down
4 changes: 2 additions & 2 deletions code/modules/asset_cache/validate_assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//this is used over window.location because window.location has a character limit in IE.
function sendbyond(text) {
var xhr = new XMLHttpRequest();
xhr.open('GET', '?'+text, true);
xhr.open('GET', 'byond://?' + text, true);
xhr.send(null);
}
var xhr = new XMLHttpRequest();
Expand All @@ -24,6 +24,6 @@
};
xhr.send(null);
</script>

</body>
</html>
6 changes: 3 additions & 3 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
///////////

/client/New(TopicData)
if(byond_version >= 516) // Enable 516 compat browser storage mechanisms
winset(src, "", "browser-options=byondstorage,find")

var/tdata = TopicData //save this for later use
TopicData = null //Prevent calls to client.Topic from connect

Expand All @@ -237,6 +234,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
GLOB.clients += src
GLOB.directory[ckey] = src

if(byond_version >= 516)
winset(src, null, list("browser-options" = "find,refresh,byondstorage"))

// Instantiate stat panel
stat_panel = new(src, "statbrowser")
stat_panel.subscribe(src, PROC_REF(on_stat_panel_message))
Expand Down
14 changes: 3 additions & 11 deletions code/modules/tgui_panel/external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,19 @@
// Failed to fix, using tgalert as fallback
action = tgalert(src, "Did that work?", "", "Yes", "No, switch to old ui")
if (action == "No, switch to old ui")
winset(src, "output", "on-show=&is-disabled=0&is-visible=1")
winset(src, "browseroutput", "is-disabled=1;is-visible=0")
winset(src, "legacy_output_selector", "left=output_legacy")
log_tgui(src, "Failed to fix.", context = "verb/fix_tgui_panel")

/client/proc/nuke_chat()
// Catch all solution (kick the whole thing in the pants)
winset(src, "output", "on-show=&is-disabled=0&is-visible=1")
winset(src, "browseroutput", "is-disabled=1;is-visible=0")
winset(src, "legacy_output_selector", "left=output_legacy")
if(!tgui_panel || !istype(tgui_panel))
log_tgui(src, "tgui_panel datum is missing",
context = "verb/fix_tgui_panel")
tgui_panel = new(src)
tgui_panel.initialize(force = TRUE)
// Force show the panel to see if there are any errors
winset(src, "output", "is-disabled=1&is-visible=0")
winset(src, "browseroutput", "is-disabled=0;is-visible=1")
if(byond_version >= 516)
var/list/options = list("byondstorage", "find")
if(check_rights_for(src, R_DEBUG))
options += "devtools"
winset(src, null, "browser-options=[options.Join(",")]")
winset(src, "legacy_output_selector", "left=output_browser")

/client/verb/refresh_tgui()
set name = "Refresh TGUI"
Expand Down
42 changes: 36 additions & 6 deletions interface/skin.dmf
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ window "infowindow"
window "outputwindow"
elem "outputwindow"
type = MAIN
pos = 281,0
pos = 0,0
size = 640x480
anchor1 = -1,-1
anchor2 = -1,-1
Expand Down Expand Up @@ -285,22 +285,52 @@ window "outputwindow"
anchor2 = -1,-1
is-visible = false
saved-params = ""
elem "browseroutput"
type = BROWSER
elem "legacy_output_selector"
type = CHILD
pos = 0,0
size = 640x456
anchor1 = 0,0
anchor2 = 100,100
is-visible = false
is-disabled = true
saved-params = ""
saved-params = "splitter"
left = "output_legacy"
is-vert = false

window "output_legacy"
elem "output_legacy"
type = MAIN
pos = 0,0
size = 640x456
anchor1 = -1,-1
anchor2 = -1,-1
background-color = none
saved-params = "pos;size;is-minimized;is-maximized"
is-pane = true
elem "output"
type = OUTPUT
pos = 0,0
size = 640x456
anchor1 = 0,0
anchor2 = 100,100
is-default = true
saved-params = "max-lines"

window "output_browser"
elem "output_browser"
type = MAIN
pos = 0,0
size = 640x456
anchor1 = -1,-1
anchor2 = -1,-1
background-color = none
saved-params = "pos;size;is-minimized;is-maximized"
is-pane = true
elem "browseroutput"
type = BROWSER
pos = 0,0
size = 640x456
anchor1 = 0,0
anchor2 = 100,100
background-color = none
saved-params = ""

window "popupwindow"
Expand Down
19 changes: 19 additions & 0 deletions tgui/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ type ByondType = {
*/
TRIDENT: number | null;

/**
* Version of Blink engine of WebView2. Null if N/A.
*/
BLINK: number | null;

/**
* True if browser is IE8 or lower.
*/
Expand Down Expand Up @@ -162,6 +167,11 @@ type ByondType = {
*/
parseJson(text: string): any;

/**
* Downloads a blob, platform-agnostic
*/
saveBlob(blob: Blob, filename: string, ext: string): void;

/**
* Sends a message to `/datum/tgui_window` which hosts this window instance.
*/
Expand Down Expand Up @@ -205,4 +215,13 @@ interface Window {
Byond: ByondType;
__store__: Store<unknown, AnyAction>;
__augmentStack__: (store: Store) => StackAugmentor;

// IE IndexedDB stuff.
msIndexedDB: IDBFactory;
msIDBTransaction: IDBTransaction;

// 516 byondstorage API.
hubStorage: Storage;
domainStorage: Storage;
serverStorage: Storage;
}
18 changes: 17 additions & 1 deletion tgui/packages/common/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export enum KEY {
Down = 'Down',
End = 'End',
Enter = 'Enter',
Escape = 'Esc',
Esc = 'Esc',
Escape = 'Escape',
Home = 'Home',
Insert = 'Insert',
Left = 'Left',
Expand All @@ -37,3 +38,18 @@ export enum KEY {
Tab = 'Tab',
Up = 'Up',
}

/**
* ### isEscape
*
* Checks if the user has hit the 'ESC' key on their keyboard.
* There's a weirdness in BYOND where this could be either the string
* 'Escape' or 'Esc' depending on the browser. This function handles
* both cases.
*
* @param key - the key to check, typically from event.key
* @returns true if key is Escape or Esc, false otherwise
*/
export const isEscape = (key: string): boolean => {
return key === KEY.Esc || key === KEY.Escape;
};
Loading

0 comments on commit f24cb08

Please sign in to comment.