diff --git a/code/modules/tgui/tgui.dm b/code/modules/tgui/tgui.dm
index b09b5ec759..74d16a2e33 100644
--- a/code/modules/tgui/tgui.dm
+++ b/code/modules/tgui/tgui.dm
@@ -95,6 +95,7 @@
window.acquire_lock(src)
if(!window.is_ready())
window.initialize(
+ strict_mode = TRUE,
fancy = user.client.prefs.tgui_fancy,
assets = list(
get_asset_datum(/datum/asset/simple/tgui),
@@ -347,4 +348,4 @@
#ifdef TGUI_DEBUGGING
log_tgui(user, "Fallback Triggered: [href_list["payload"]], Window: [window.id], Source: [src_object]")
#endif
- src_object.tgui_fallback(payload)
\ No newline at end of file
+ src_object.tgui_fallback(payload)
diff --git a/code/modules/tgui/tgui_window.dm b/code/modules/tgui/tgui_window.dm
index 2e1b64bac1..43e4204127 100644
--- a/code/modules/tgui/tgui_window.dm
+++ b/code/modules/tgui/tgui_window.dm
@@ -18,6 +18,7 @@
var/message_queue
var/sent_assets = list()
// Vars passed to initialize proc (and saved for later)
+ var/initial_strict_mode
var/initial_fancy
var/initial_assets
var/initial_inline_html
@@ -48,11 +49,15 @@
* state. You can begin sending messages right after initializing. Messages
* will be put into the queue until the window finishes loading.
*
- * optional assets list List of assets to inline into the html.
- * optional inline_html string Custom HTML to inject.
- * optional fancy bool If TRUE, will hide the window titlebar.
+ * optional strict_mode bool - Enables strict error handling and BSOD.
+ * optional fancy bool - If TRUE and if this is NOT a panel, will hide the window titlebar.
+ * optional assets list - List of assets to load during initialization.
+ * optional inline_html string - Custom HTML to inject.
+ * optional inline_js string - Custom JS to inject.
+ * optional inline_css string - Custom CSS to inject.
*/
/datum/tgui_window/proc/initialize(
+ strict_mode = FALSE,
fancy = FALSE,
assets = list(),
inline_html = "",
@@ -80,6 +85,7 @@
// Generate page html
var/html = SStgui.basehtml
html = replacetextEx(html, "\[tgui:windowId]", id)
+ html = replacetextEx(html, "\[tgui:strictMode]", strict_mode)
// Inject assets
var/inline_assets_str = ""
for(var/datum/asset/asset in assets)
@@ -100,7 +106,7 @@
html = replacetextEx(html, "", inline_html)
// Inject inline JS
if (inline_js)
- inline_js = ""
+ inline_js = ""
html = replacetextEx(html, "", inline_js)
// Inject inline CSS
if (inline_css)
@@ -114,6 +120,20 @@
if(!is_browser)
winset(client, id, "on-close=\"uiclose [id]\"")
+/**
+ * public
+ *
+ * Reinitializes the panel with previous data used for initialization.
+ */
+/datum/tgui_window/proc/reinitialize()
+ initialize(
+ strict_mode = initial_strict_mode,
+ fancy = initial_fancy,
+ assets = initial_assets,
+ inline_html = initial_inline_html,
+ inline_js = initial_inline_js,
+ inline_css = initial_inline_css)
+
/**
* public
*
@@ -353,12 +373,7 @@
client << link(href_list["url"])
if("cacheReloaded")
// Reinitialize
- initialize(
- fancy = initial_fancy,
- assets = initial_assets,
- inline_html = initial_inline_html,
- inline_js = initial_inline_js,
- inline_css = initial_inline_css)
+ reinitialize()
// Resend the assets
for(var/asset in sent_assets)
- send_asset(asset)
\ No newline at end of file
+ send_asset(asset)
diff --git a/tgui/global.d.ts b/tgui/global.d.ts
index 348cb9c516..6e28fc9be1 100644
--- a/tgui/global.d.ts
+++ b/tgui/global.d.ts
@@ -64,6 +64,18 @@ type ByondType = {
*/
IS_LTE_IE11: boolean;
+ /**
+ * If `true`, unhandled errors and common mistakes result in a blue screen
+ * of death, which stops this window from handling incoming messages and
+ * closes the active instance of tgui datum if there was one.
+ *
+ * It can be defined in window.initialize() in DM, or changed in runtime
+ * here via this property to `true` or `false`.
+ *
+ * It is recommended that you keep this ON to detect hard to find bugs.
+ */
+ strictMode: boolean;
+
/**
* Makes a BYOND call.
*
diff --git a/tgui/public/tgui.html b/tgui/public/tgui.html
index b5fc63f0c8..7b34780128 100644
--- a/tgui/public/tgui.html
+++ b/tgui/public/tgui.html
@@ -6,6 +6,7 @@
+