mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
fixes the tgui blacksquare issue (#91389)
## About The Pull Request the black squares appear when the byondui process is exited without time to 1) unmount the component 2) hit the "blur" event 3) hit the "beforeunload" event this occurs when being killed by windows, such as alt+f4, the close window button (in non-fancy mode), or any other way of killing the window ~~this requires a tgui-core pr (and bump) which is here https://github.com/tgstation/tgui-core/pull/176~~ ## Why It's Good For The Game ominous black square bad fixes #90559 ## Changelog 🆑 fix: fixes the ominous black squares appearing over tgui windows, sometimes /🆑 --------- Co-authored-by: harryob <55142896+harryob@users.noreply.github.com>
This commit is contained in:
@@ -24,6 +24,16 @@
|
||||
/// Window is free and ready to receive data
|
||||
#define TGUI_WINDOW_READY 2
|
||||
|
||||
/// Though not the maximum renderable ByondUis within tgui, this is the maximum that the server will manage per-UI
|
||||
#define TGUI_MANAGED_BYONDUI_LIMIT 10
|
||||
|
||||
// These are defines instead of being inline, as they're being sent over
|
||||
// from tgui-core, so can't be easily played with
|
||||
#define TGUI_MANAGED_BYONDUI_TYPE_RENDER "renderByondUi"
|
||||
#define TGUI_MANAGED_BYONDUI_TYPE_UNMOUNT "unmountByondUi"
|
||||
|
||||
#define TGUI_MANAGED_BYONDUI_PAYLOAD_ID "renderByondUi"
|
||||
|
||||
/// Get a window id based on the provided pool index
|
||||
#define TGUI_WINDOW_ID(index) "tgui-window-[index]"
|
||||
/// Get a pool index of the provided window id
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
/// Rate limit client refreshes to prevent DoS.
|
||||
COOLDOWN_DECLARE(refresh_cooldown)
|
||||
|
||||
/// The id of any ByondUi elements that we have opened
|
||||
var/list/open_byondui_elements
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
@@ -142,9 +145,26 @@
|
||||
window.close(can_be_suspended)
|
||||
src_object.ui_close(user)
|
||||
SStgui.on_close(src)
|
||||
|
||||
if(user.client)
|
||||
terminate_byondui_elements()
|
||||
|
||||
state = null
|
||||
qdel(src)
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Closes all ByondUI elements, left dangling by a forceful TGUI exit,
|
||||
* such as via Alt+F4, closing in non-fancy mode, or terminating the process
|
||||
*
|
||||
*/
|
||||
/datum/tgui/proc/terminate_byondui_elements()
|
||||
set waitfor = FALSE
|
||||
|
||||
for(var/byondui_element in open_byondui_elements)
|
||||
winset(user.client, byondui_element, list("parent" = ""))
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
@@ -341,6 +361,18 @@
|
||||
LAZYINITLIST(src_object.tgui_shared_states)
|
||||
src_object.tgui_shared_states[href_list["key"]] = href_list["value"]
|
||||
SStgui.update_uis(src_object)
|
||||
if(TGUI_MANAGED_BYONDUI_TYPE_RENDER)
|
||||
var/byond_ui_id = payload[TGUI_MANAGED_BYONDUI_PAYLOAD_ID]
|
||||
if(!byond_ui_id || LAZYLEN(open_byondui_elements) > TGUI_MANAGED_BYONDUI_LIMIT)
|
||||
return
|
||||
|
||||
LAZYOR(open_byondui_elements, byond_ui_id)
|
||||
if(TGUI_MANAGED_BYONDUI_TYPE_UNMOUNT)
|
||||
var/byond_ui_id = payload[TGUI_MANAGED_BYONDUI_PAYLOAD_ID]
|
||||
if(!byond_ui_id)
|
||||
return
|
||||
|
||||
LAZYREMOVE(open_byondui_elements, byond_ui_id)
|
||||
|
||||
/// Wrapper for behavior to potentially wait until the next tick if the server is overloaded
|
||||
/datum/tgui/proc/on_act_message(act_type, payload, state)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"tgui": "workspace:*",
|
||||
"tgui-core": "^4.0.1"
|
||||
"tgui-core": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.0",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"tgui": "workspace:*",
|
||||
"tgui-core": "^4.0.1",
|
||||
"tgui-core": "^4.0.2",
|
||||
"tgui-dev-server": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"tgui": "workspace:*",
|
||||
"tgui-core": "^4.0.1"
|
||||
"tgui-core": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.0",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"marked-smartypants": "^1.1.9",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"tgui-core": "^4.0.1",
|
||||
"tgui-core": "^4.0.2",
|
||||
"tgui-dev-server": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -9783,20 +9783,20 @@ __metadata:
|
||||
react: "npm:^19.1.0"
|
||||
react-dom: "npm:^19.1.0"
|
||||
tgui: "workspace:*"
|
||||
tgui-core: "npm:^4.0.1"
|
||||
tgui-core: "npm:^4.0.2"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"tgui-core@npm:^4.0.1":
|
||||
version: 4.0.1
|
||||
resolution: "tgui-core@npm:4.0.1"
|
||||
"tgui-core@npm:^4.0.2":
|
||||
version: 4.0.2
|
||||
resolution: "tgui-core@npm:4.0.2"
|
||||
dependencies:
|
||||
"@floating-ui/react": "npm:^0.27.8"
|
||||
"@nozbe/microfuzz": "npm:^1.0.0"
|
||||
peerDependencies:
|
||||
react: ^19.1.0
|
||||
react-dom: ^19.1.0
|
||||
checksum: 10c0/dc15e1f615395fb62dc7445a68b5bb5b1a102993f5fbf2efe38c190e2608c13da7e78246e328bd5461059f554471ecd08e72719c7d409e5a79f8e2e96ddb81b3
|
||||
checksum: 10c0/685b933d0083a1bf2349d8a86aa8b16ca8da0d0ac83cd0e287f7450b88c08bb41a53140561c77269ad73de030401742dae3fd011113c38e07fbc3f233ddcb1af
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -9824,7 +9824,7 @@ __metadata:
|
||||
react: "npm:^19.1.0"
|
||||
react-dom: "npm:^19.1.0"
|
||||
tgui: "workspace:*"
|
||||
tgui-core: "npm:^4.0.1"
|
||||
tgui-core: "npm:^4.0.2"
|
||||
tgui-dev-server: "workspace:*"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -9839,7 +9839,7 @@ __metadata:
|
||||
react: "npm:^19.1.0"
|
||||
react-dom: "npm:^19.1.0"
|
||||
tgui: "workspace:*"
|
||||
tgui-core: "npm:^4.0.1"
|
||||
tgui-core: "npm:^4.0.2"
|
||||
vitest: "npm:^3.1.1"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -9899,7 +9899,7 @@ __metadata:
|
||||
marked-smartypants: "npm:^1.1.9"
|
||||
react: "npm:^19.1.0"
|
||||
react-dom: "npm:^19.1.0"
|
||||
tgui-core: "npm:^4.0.1"
|
||||
tgui-core: "npm:^4.0.2"
|
||||
tgui-dev-server: "workspace:*"
|
||||
vitest: "npm:^3.1.1"
|
||||
languageName: unknown
|
||||
|
||||
Reference in New Issue
Block a user