From a34003d4f64d461eb2072aac32bc07ff98e93d67 Mon Sep 17 00:00:00 2001
From: magatsuchi <88991542+magatsuchi@users.noreply.github.com>
Date: Thu, 26 May 2022 22:13:01 -0500
Subject: [PATCH] adds the "refresh TGUI" debug verb (#67265)
About The Pull Request
adds the Refresh TGUI verb to the debug category OOC category, but it isn't locked behind any permissions. i'd put it in OOC, but.. eeeeeeh? there's not real much use for this verb other for debuggers. i put it in the OOC category
Why It's Good For The Game
debug purposes mostly
not player facing lole
---
code/modules/client/client_procs.dm | 6 +++---
code/modules/tgui/tgui_window.dm | 13 ++++++-------
code/modules/tgui_panel/external.dm | 9 +++++++++
tgui/docs/tgui-for-custom-html-popups.md | 6 +++---
4 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index fad493d9ee4..73520d79de7 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -344,9 +344,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
// Initialize stat panel
stat_panel.initialize(
- inline_html = file2text('html/statbrowser.html'),
- inline_js = file2text('html/statbrowser.js'),
- inline_css = file2text('html/statbrowser.css'),
+ inline_html = file("html/statbrowser.html"),
+ inline_js = file("html/statbrowser.js"),
+ inline_css = file("html/statbrowser.css"),
)
addtimer(CALLBACK(src, .proc/check_panel_loaded), 30 SECONDS)
diff --git a/code/modules/tgui/tgui_window.dm b/code/modules/tgui/tgui_window.dm
index d0fb91db0cc..ded443f37a0 100644
--- a/code/modules/tgui/tgui_window.dm
+++ b/code/modules/tgui/tgui_window.dm
@@ -102,14 +102,14 @@
html = replacetextEx(html, "\n", inline_assets_str)
// Inject inline HTML
if (inline_html)
- html = replacetextEx(html, "", inline_html)
+ html = replacetextEx(html, "", isfile(inline_html) ? file2text(inline_html) : inline_html)
// Inject inline JS
if (inline_js)
- inline_js = ""
+ inline_js = ""
html = replacetextEx(html, "", inline_js)
// Inject inline CSS
if (inline_css)
- inline_css = ""
+ inline_css = ""
html = replacetextEx(html, "", inline_css)
// Open the window
client << browse(html, "window=[id];[options]")
@@ -132,6 +132,9 @@
inline_html = initial_inline_html,
inline_js = initial_inline_js,
inline_css = initial_inline_css)
+ // Resend assets
+ for(var/datum/asset/asset in sent_assets)
+ send_asset(asset)
/**
* public
@@ -365,11 +368,7 @@
if("openLink")
client << link(href_list["url"])
if("cacheReloaded")
- // Reinitialize
reinitialize()
- // 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) && ..()
diff --git a/code/modules/tgui_panel/external.dm b/code/modules/tgui_panel/external.dm
index e5b3602e868..ddc3c0e97d5 100644
--- a/code/modules/tgui_panel/external.dm
+++ b/code/modules/tgui_panel/external.dm
@@ -35,3 +35,12 @@
// Force show the panel to see if there are any errors
winset(src, "output", "is-disabled=1&is-visible=0")
winset(src, "browseroutput", "is-disabled=0;is-visible=1")
+
+/client/verb/refresh_tgui()
+ set name = "Refresh TGUI"
+ set category = "OOC"
+
+ message_admins("start")
+ for(var/window_id in tgui_windows)
+ var/datum/tgui_window/window = tgui_windows[window_id]
+ window.reinitialize()
diff --git a/tgui/docs/tgui-for-custom-html-popups.md b/tgui/docs/tgui-for-custom-html-popups.md
index 5fe0e8ff78c..ad563a693b0 100644
--- a/tgui/docs/tgui-for-custom-html-popups.md
+++ b/tgui/docs/tgui-for-custom-html-popups.md
@@ -85,9 +85,9 @@ You can also do the same by splitting your code into separate files, and then le
```dm
window.initialize(
- inline_html = file2text('code/modules/thing/thing.html'),
- inline_js = file2text('code/modules/thing/thing.js'),
- inline_css = file2text('code/modules/thing/thing.css'),
+ inline_html = file("code/modules/thing/thing.html"),
+ inline_js = file("code/modules/thing/thing.js"),
+ inline_css = file("code/modules/thing/thing.css"),
)
```