mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
TGUI Update Hotfix
This commit is contained in:
committed by
CHOMPStation2
parent
f5ab670839
commit
4b70e7dbd3
@@ -37,6 +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 map z-level to display.
|
||||
var/map_z_level = 1
|
||||
/// The Parent UI
|
||||
@@ -108,6 +110,8 @@
|
||||
window.send_message("update", get_payload(
|
||||
with_data = TRUE,
|
||||
with_static_data = TRUE))
|
||||
if(mouse_hooked)
|
||||
window.set_mouse_macro()
|
||||
SStgui.on_open(src)
|
||||
|
||||
/**
|
||||
@@ -147,6 +151,17 @@
|
||||
/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
|
||||
*
|
||||
@@ -328,7 +343,7 @@
|
||||
if(initialized)
|
||||
send_full_update()
|
||||
initialized = TRUE
|
||||
if("pingReply")
|
||||
if("ping/reply")
|
||||
initialized = TRUE
|
||||
if("suspend")
|
||||
close(can_be_suspended = TRUE)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
var/initial_inline_html
|
||||
var/initial_inline_js
|
||||
var/initial_inline_css
|
||||
var/mouse_event_macro_set = FALSE
|
||||
|
||||
/**
|
||||
* public
|
||||
@@ -215,6 +216,8 @@
|
||||
/datum/tgui_window/proc/close(can_be_suspended = TRUE, logout = FALSE)
|
||||
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")
|
||||
@@ -364,7 +367,7 @@
|
||||
// If not locked, handle these message types
|
||||
switch(type)
|
||||
if("ping")
|
||||
send_message("pingReply", payload)
|
||||
send_message("ping/reply", payload)
|
||||
if("suspend")
|
||||
close(can_be_suspended = TRUE)
|
||||
if("close")
|
||||
@@ -377,3 +380,44 @@
|
||||
// Resend the assets
|
||||
for(var/asset in sent_assets)
|
||||
send_asset(asset)
|
||||
|
||||
/datum/tgui_window/vv_edit_var(var_name, var_value)
|
||||
return var_name != NAMEOF(src, id) && ..()
|
||||
|
||||
|
||||
/datum/tgui_window/proc/set_mouse_macro()
|
||||
if(mouse_event_macro_set)
|
||||
return
|
||||
|
||||
var/list/byondToTguiEventMap = list(
|
||||
"MouseDown" = "byond/mousedown",
|
||||
"MouseUp" = "byond/mouseup"
|
||||
)
|
||||
|
||||
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")
|
||||
var/list/byondToTguiEventMap = list(
|
||||
"MouseDown" = "byond/mousedown",
|
||||
"MouseUp" = "byond/mouseup"
|
||||
)
|
||||
for(var/mouseMacro in byondToTguiEventMap)
|
||||
winset(client, null, "[mouseMacro]Window[id]Macro.parent=null")
|
||||
mouse_event_macro_set = FALSE
|
||||
|
||||
Reference in New Issue
Block a user