diff --git a/code/controllers/subsystem/pai.dm b/code/controllers/subsystem/pai.dm
index 3549b64f1e55..7c6678e5c367 100644
--- a/code/controllers/subsystem/pai.dm
+++ b/code/controllers/subsystem/pai.dm
@@ -201,7 +201,7 @@ var/datum/subsystem/pai/SSpai
if(!C) return
asked.Add(C.key)
asked[C.key] = world.time
- var/response = alert(C, "Someone is requesting a pAI personality. Would you like to play as a personal AI?", "pAI Request", "Yes", "No", "Never for this round")
+ var/response = tgalert(C, "Someone is requesting a pAI personality. Would you like to play as a personal AI?", "pAI Request", "Yes", "No", "Never for this round", StealFocus=0, Timeout=askDelay)
if(!C) return //handle logouts that happen whilst the alert is waiting for a response.
if(response == "Yes")
recruitWindow(C.mob)
diff --git a/code/datums/browser.dm b/code/datums/browser.dm
index 2b24f33e52e5..e4b268c929c7 100644
--- a/code/datums/browser.dm
+++ b/code/datums/browser.dm
@@ -102,8 +102,10 @@
if (use_onclose)
spawn(0)
//winexists sleeps, so we don't need to.
- for (var/i = 0, !winexists(user, window_id) && i < 3, i++)
+ for (var/i in 1 to 10)
+ if (user && winexists(user, window_id))
onclose(user, window_id, ref)
+ break
/datum/browser/proc/close()
@@ -118,15 +120,18 @@
/datum/browser/alert/New(User,Message,Title,Button1="Ok",Button2,Button3,StealFocus = 1,Timeout=6000)
if (!User)
return
+
var/output = {"
[Message]
- [Button1]"}
+ "}
..(User, ckey("[User]-[Message]-[Title]-[world.time]-[rand(1,10000)]"), Title, 350, 150, src)
set_content(output)
@@ -147,11 +152,13 @@
//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 = 0, user && !winexists(user, window_id) && i < 10, i++)
- if (focusedwindow)
- winset(user, focusedwindow, "focus=true")
- else
- winset(user, "mapwindow", "focus=true")
+ 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)
spawn(timeout)
close()
@@ -175,7 +182,19 @@
opentime = 0
close()
+//designed as a drop in replacement for alert(); functions the same. (outside of needing User specified)
+/proc/tgalert(var/mob/User, Message, Title, Button1="Ok", Button2, Button3, StealFocus = 1, Timeout = 6000)
+ if (!User)
+ User = usr
+ switch(askuser(User, Message, Title, Button1, Button2, Button3, StealFocus, Timeout))
+ if (1)
+ return Button1
+ if (2)
+ return Button2
+ if (3)
+ return Button3
+//Same shit, but it returns the button number, could at some point support unlimited button amounts.
/proc/askuser(var/mob/User,Message, Title, Button1="Ok", Button2, Button3, StealFocus = 1, Timeout = 6000)
if (!istype(User))
if (istype(User, /client/))
@@ -189,18 +208,6 @@
if (A.selectedbutton)
return A.selectedbutton
-//designed as a drop in replacement for alert(); functions the same. (outside of needing User specified)
-/proc/tgalert(var/mob/User, Message, Title, Button1="Ok", Button2, Button3, StealFocus = 1, Timeout = 6000)
- if (!User)
- User = usr
- switch(askuser(User, Message, Title, Button1, Button2, Button3, StealFocus, Timeout))
- if (1)
- return Button1
- if (2)
- return Button2
- if (3)
- return Button3
-
// This will allow you to show an icon in the browse window
// This is added to mob so that it can be used without a reference to the browser object
// There is probably a better place for this...