Merge branch 'master' of https://github.com/VOREStation/VOREStation into tgui-update

This commit is contained in:
ItsSelis
2022-06-18 17:15:39 +02:00
439 changed files with 9767 additions and 3065 deletions
+31 -1
View File
@@ -1,3 +1,5 @@
#define SMES_PER_PAGE 4
/datum/tgui_module/rcon
name = "Power RCON"
tgui_id = "RCON"
@@ -5,17 +7,41 @@
var/list/known_SMESs = null
var/list/known_breakers = null
var/filtered_smeslist = list()
var/current_page = 1
var/number_pages = 0
/datum/tgui_module/rcon/proc/filter_smeslist(var/page)
number_pages = known_SMESs.len / SMES_PER_PAGE
if(number_pages != round(number_pages))
number_pages = round(number_pages) + 1
var/page_index = page - 1
var/lower_bound = page_index * SMES_PER_PAGE + 1
var/upper_bound = (page_index + 1) * SMES_PER_PAGE
upper_bound = min(upper_bound, known_SMESs.len)
filtered_smeslist = list()
for(var/index = lower_bound, index <= upper_bound, index++)
filtered_smeslist += known_SMESs[index]
/datum/tgui_module/rcon/tgui_data(mob/user)
FindDevices() // Update our devices list
var/list/data = ..()
filter_smeslist(current_page)
// SMES DATA (simplified view)
var/list/smeslist[0]
for(var/obj/machinery/power/smes/buildable/SMES in known_SMESs)
for(var/obj/machinery/power/smes/buildable/SMES in filtered_smeslist)
var/list/smes_data = SMES.tgui_data()
smes_data["RCON_tag"] = SMES.RCon_tag
smeslist.Add(list(smes_data))
data["pages"] = number_pages + 1
data["current_page"] = current_page
data["smes_info"] = sortByKey(smeslist, "RCON_tag")
// BREAKER DATA (simplified view)
@@ -34,6 +60,10 @@
return TRUE
switch(action)
if("set_smes_page")
var/page = params["index"]
current_page = page
. = TRUE
if("smes_in_toggle")
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(params["smes"])
if(SMES)
+3 -4
View File
@@ -92,10 +92,9 @@
if(!window.is_ready())
window.initialize(
fancy = user.client.prefs.tgui_fancy,
inline_assets = list(
get_asset_datum(/datum/asset/simple/tgui_common),
get_asset_datum(/datum/asset/simple/tgui)
))
assets = list(
get_asset_datum(/datum/asset/simple/tgui),
))
else
window.send_message("ping")
window.send_asset(get_asset_datum(/datum/asset/simple/fontawesome))
+45 -12
View File
@@ -18,8 +18,11 @@
var/message_queue
var/sent_assets = list()
// Vars passed to initialize proc (and saved for later)
var/inline_assets
var/fancy
var/initial_fancy
var/initial_assets
var/initial_inline_html
var/initial_inline_js
var/initial_inline_css
/**
* public
@@ -45,21 +48,26 @@
* state. You can begin sending messages right after initializing. Messages
* will be put into the queue until the window finishes loading.
*
* optional inline_assets list List of assets to inline into the html.
* 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.
*/
/datum/tgui_window/proc/initialize(
inline_assets = list(),
fancy = FALSE,
assets = list(),
inline_html = "",
fancy = FALSE)
inline_js = "",
inline_css = "")
#ifdef TGUI_DEBUGGING
log_tgui(client, "[id]/initiailize ([src])")
#endif
if(!client)
return
src.inline_assets = inline_assets
src.fancy = fancy
src.initial_fancy = fancy
src.initial_assets = assets
src.initial_inline_html = inline_html
src.initial_inline_js = inline_js
src.initial_inline_css = inline_css
status = TGUI_WINDOW_LOADING
fatally_errored = FALSE
// Build window options
@@ -72,9 +80,9 @@
// Generate page html
var/html = SStgui.basehtml
html = replacetextEx(html, "\[tgui:windowId]", id)
// Inject inline assets
// Inject assets
var/inline_assets_str = ""
for(var/datum/asset/asset in inline_assets)
for(var/datum/asset/asset in assets)
var/mappings = asset.get_url_mappings()
for(var/name in mappings)
var/url = mappings[name]
@@ -87,8 +95,17 @@
if(length(inline_assets_str))
inline_assets_str = "<script>\n" + inline_assets_str + "</script>\n"
html = replacetextEx(html, "<!-- tgui:assets -->\n", inline_assets_str)
// Inject custom HTML
html = replacetextEx(html, "<!-- tgui:html -->\n", inline_html)
// Inject inline HTML
if (inline_html)
html = replacetextEx(html, "<!-- tgui:inline-html -->", inline_html)
// Inject inline JS
if (inline_js)
inline_js = "<script>\n[inline_js]\n</script>"
html = replacetextEx(html, "<!-- tgui:inline-js -->", inline_js)
// Inject inline CSS
if (inline_css)
inline_css = "<style>\n[inline_css]\n</style>"
html = replacetextEx(html, "<!-- tgui:inline-css -->", inline_css)
// Open the window
client << browse(html, "window=[id];[options]")
// Detect whether the control is a browser
@@ -281,6 +298,17 @@
: "[id].browser:update")
message_queue = null
/**
* public
*
* Replaces the inline HTML content.
*
* required inline_html string HTML to inject
*/
/datum/tgui_window/proc/replace_html(inline_html = "")
client << output(url_encode(inline_html), is_browser \
? "[id]:replaceHtml" \
: "[id].browser:replaceHtml")
/**
* private
@@ -325,7 +353,12 @@
client << link(href_list["url"])
if("cacheReloaded")
// Reinitialize
initialize(inline_assets = inline_assets, fancy = fancy)
initialize(
fancy = initial_fancy,
assets = initial_assets,
inline_html = initial_inline_html,
inline_js = initial_inline_js,
inline_css = initial_inline_css)
// Resend the assets
for(var/asset in sent_assets)
send_asset(asset)