mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-24 12:37:50 +01:00
Update tgui-core and some backend tgui stuff (#17778)
* Update tgui-core and some backend tgui stuff * Fix digitigrade not showing in char menu
This commit is contained in:
@@ -28,6 +28,16 @@
|
||||
"%7b%22type%22%3a%22[type]%22%2c%22payload%22%3a[url_encode(json_encode(payload))]%7d" \
|
||||
)
|
||||
|
||||
/// 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"
|
||||
|
||||
/// Max length for Modal Input
|
||||
#define TGUI_MODAL_INPUT_MAX_LENGTH 1024
|
||||
/// Max length for Modal Input for names
|
||||
|
||||
+32
-15
@@ -37,8 +37,8 @@
|
||||
var/datum/tgui_state/state = null
|
||||
/// Rate limit client refreshes to prevent DoS.
|
||||
COOLDOWN_DECLARE(refresh_cooldown)
|
||||
/// Are byond mouse events beyond the window passed in to the ui
|
||||
var/mouse_hooked = FALSE
|
||||
/// The id of any ByondUi elements that we have opened
|
||||
var/list/open_byondui_elements
|
||||
/// The map z-level to display.
|
||||
var/map_z_level = 1
|
||||
/// The Parent UI
|
||||
@@ -50,6 +50,7 @@
|
||||
/// If the window should be closed with other windows when requested
|
||||
var/closeable = TRUE
|
||||
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
@@ -128,8 +129,6 @@
|
||||
window.send_message("update", get_payload(
|
||||
with_data = TRUE,
|
||||
with_static_data = TRUE))
|
||||
if(mouse_hooked)
|
||||
window.set_mouse_macro()
|
||||
SStgui.on_open(src)
|
||||
|
||||
return TRUE
|
||||
@@ -172,12 +171,29 @@
|
||||
window.close(can_be_suspended, logout)
|
||||
src_object.tgui_close(user)
|
||||
SStgui.on_close(src)
|
||||
|
||||
if(user.client)
|
||||
terminate_byondui_elements()
|
||||
|
||||
state = null
|
||||
if(parent_ui)
|
||||
parent_ui.children -= src
|
||||
parent_ui = 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
|
||||
*
|
||||
@@ -188,17 +204,6 @@
|
||||
/datum/tgui/proc/set_autoupdate(autoupdate)
|
||||
src.autoupdate = autoupdate
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Enable/disable passing through byond mouse events to the window
|
||||
*
|
||||
* required value bool Enable/disable hooking.
|
||||
*/
|
||||
/datum/tgui/proc/set_mouse_hook(value)
|
||||
src.mouse_hooked = value
|
||||
//Handle unhooking/hooking on already open windows ?
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
@@ -422,6 +427,18 @@
|
||||
log_tgui(user, "Fallback Triggered: [href_list["payload"]], Window: [window.id], Source: [src_object]")
|
||||
#endif
|
||||
src_object.tgui_fallback(payload)
|
||||
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)
|
||||
|
||||
@@ -27,19 +27,6 @@
|
||||
var/initial_inline_css
|
||||
|
||||
var/list/oversized_payloads = list()
|
||||
var/mouse_event_macro_set = FALSE
|
||||
|
||||
/**
|
||||
* Static list used to map in macros that will then emit execute events to the tgui window
|
||||
* A small disclaimer though I'm no tech wiz: I don't think it's possible to map in right or middle
|
||||
* clicks in the current state, as they're keywords rather than modifiers.
|
||||
*/
|
||||
var/static/list/byondToTguiEventMap = list(
|
||||
"MouseDown" = "byond/mousedown",
|
||||
"MouseUp" = "byond/mouseup",
|
||||
"Ctrl" = "byond/ctrldown",
|
||||
"Ctrl+UP" = "byond/ctrlup",
|
||||
)
|
||||
|
||||
/**
|
||||
* public
|
||||
@@ -235,8 +222,6 @@
|
||||
/datum/tgui_window/proc/close(can_be_suspended = TRUE)
|
||||
if(!client)
|
||||
return
|
||||
if(mouse_event_macro_set)
|
||||
remove_mouse_macro()
|
||||
if(can_be_suspended && can_be_suspended())
|
||||
#ifdef TGUI_DEBUGGING
|
||||
log_tgui(client, "[id]/close: suspending")
|
||||
@@ -441,32 +426,3 @@
|
||||
|
||||
/datum/tgui_window/proc/remove_oversized_payload(payload_id)
|
||||
oversized_payloads -= payload_id
|
||||
|
||||
|
||||
/datum/tgui_window/proc/set_mouse_macro()
|
||||
if(mouse_event_macro_set)
|
||||
return
|
||||
|
||||
for(var/mouseMacro in byondToTguiEventMap)
|
||||
var/command_template = ".output CONTROL PAYLOAD"
|
||||
var/event_message = TGUI_CREATE_MESSAGE(byondToTguiEventMap[mouseMacro], null)
|
||||
var target_control = is_browser \
|
||||
? "[id]:update" \
|
||||
: "[id].browser:update"
|
||||
var/with_id = replacetext(command_template, "CONTROL", target_control)
|
||||
var/full_command = replacetext(with_id, "PAYLOAD", event_message)
|
||||
|
||||
var/list/params = list()
|
||||
params["parent"] = "default" //Technically this is external to tgui but whatever
|
||||
params["name"] = mouseMacro
|
||||
params["command"] = full_command
|
||||
|
||||
winset(client, "[mouseMacro]Window[id]Macro", params)
|
||||
mouse_event_macro_set = TRUE
|
||||
|
||||
/datum/tgui_window/proc/remove_mouse_macro()
|
||||
if(!mouse_event_macro_set)
|
||||
stack_trace("Unsetting mouse macro on tgui window that has none")
|
||||
for(var/mouseMacro in byondToTguiEventMap)
|
||||
winset(client, null, "[mouseMacro]Window[id]Macro.parent=null")
|
||||
mouse_event_macro_set = FALSE
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
import { perf } from 'common/perf';
|
||||
import { createAction } from 'common/redux';
|
||||
import { globalEvents } from 'tgui-core/events';
|
||||
import type { BooleanLike } from 'tgui-core/react';
|
||||
|
||||
import { setupDrag } from './drag';
|
||||
@@ -97,14 +96,6 @@ export const backendReducer = (state = initialState, action) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'byond/ctrldown') {
|
||||
globalEvents.emit('byond/ctrldown');
|
||||
}
|
||||
|
||||
if (type === 'byond/ctrlup') {
|
||||
globalEvents.emit('byond/ctrlup');
|
||||
}
|
||||
|
||||
if (type === 'backend/suspendStart') {
|
||||
return {
|
||||
...state,
|
||||
@@ -154,22 +145,6 @@ export const backendMiddleware = (store) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'byond/mousedown') {
|
||||
globalEvents.emit('byond/mousedown');
|
||||
}
|
||||
|
||||
if (type === 'byond/mouseup') {
|
||||
globalEvents.emit('byond/mouseup');
|
||||
}
|
||||
|
||||
if (type === 'byond/ctrldown') {
|
||||
globalEvents.emit('byond/ctrldown');
|
||||
}
|
||||
|
||||
if (type === 'byond/ctrlup') {
|
||||
globalEvents.emit('byond/ctrlup');
|
||||
}
|
||||
|
||||
if (type === 'backend/suspendStart' && !suspendInterval) {
|
||||
logger.log(`suspending (${Byond.windowId})`);
|
||||
// Keep sending suspend messages until it succeeds.
|
||||
|
||||
@@ -121,17 +121,15 @@ export const SubtabBody = (props: {
|
||||
</Button>
|
||||
</LabeledList.Item>
|
||||
) : null}
|
||||
{
|
||||
<LabeledList.Item label="Digitigrade">
|
||||
<Button
|
||||
inline
|
||||
onClick={() => act('digitigrade')}
|
||||
selected={digitigrade}
|
||||
>
|
||||
{digitigrade ? 'Yes' : 'No'}
|
||||
</Button>
|
||||
</LabeledList.Item>
|
||||
}
|
||||
<LabeledList.Item label="Digitigrade">
|
||||
<Button
|
||||
inline
|
||||
onClick={() => act('digitigrade')}
|
||||
selected={digitigrade}
|
||||
>
|
||||
{digitigrade ? 'Yes' : 'No'}
|
||||
</Button>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Blood Type">
|
||||
<Button inline onClick={() => act('blood_type')}>
|
||||
{b_type}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"marked": "^4.3.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"tgui-core": "^4.0.1",
|
||||
"tgui-core": "^4.0.2",
|
||||
"tgui-dev-server": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
+8
-8
@@ -19925,20 +19925,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
|
||||
|
||||
@@ -19966,7 +19966,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
|
||||
@@ -19981,7 +19981,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
|
||||
@@ -20043,7 +20043,7 @@ __metadata:
|
||||
marked: "npm:^4.3.0"
|
||||
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