mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-20 13:16:34 +01:00
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
/datum/browser/modal
|
|
var/opentime = 0
|
|
var/timeout
|
|
var/selectedbutton = 0
|
|
var/stealfocus
|
|
|
|
/datum/browser/modal/New(nuser, nwindow_id, ntitle = 0, nwidth = 0, nheight = 0, atom/nref = null, StealFocus = 1, Timeout = 6000)
|
|
..()
|
|
stealfocus = StealFocus
|
|
if (!StealFocus)
|
|
window_options += "focus=false;"
|
|
timeout = Timeout
|
|
|
|
/datum/browser/modal/close()
|
|
. =..()
|
|
opentime = 0
|
|
|
|
/datum/browser/modal/open(use_onclose)
|
|
set waitfor = 0
|
|
opentime = world.time
|
|
|
|
if (stealfocus)
|
|
. = ..(use_onclose = 1)
|
|
else
|
|
var/focusedwindow = winget(user, null, "focus")
|
|
. = ..(use_onclose = 1)
|
|
|
|
//waits for the window to show up client side before attempting to un-focus it
|
|
//winexists sleeps until it gets a reply from the client, so we don't need to bother sleeping
|
|
for (var/i in 1 to 10)
|
|
if (user && winexists(user, window_id))
|
|
if (focusedwindow)
|
|
winset(user, focusedwindow, "focus=true")
|
|
else
|
|
winset(user, "mapwindow", "focus=true")
|
|
break
|
|
if (timeout)
|
|
addtimer(CALLBACK(src, PROC_REF(close)), timeout)
|
|
|
|
/datum/browser/modal/proc/wait()
|
|
while (opentime && selectedbutton <= 0 && (!timeout || opentime+timeout > world.time))
|
|
stoplag(1)
|