mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
refactors statpanel to use tgui API (#66971)
refactors the status panel to utilize the tgui/byond communication APIs instead of passing along href data, as well as converts the entirety of it into a datum/tgui_window Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
co-authored by
Aleksej Komarov
parent
b245c72994
commit
bea9387458
@@ -181,9 +181,6 @@
|
||||
/// our current tab
|
||||
var/stat_tab
|
||||
|
||||
/// whether our browser is ready or not yet
|
||||
var/statbrowser_ready = FALSE
|
||||
|
||||
/// list of all tabs
|
||||
var/list/panel_tabs = list()
|
||||
/// list of tabs containing spells and abilities
|
||||
|
||||
@@ -83,7 +83,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
if(href_list["reload_tguipanel"])
|
||||
nuke_chat()
|
||||
if(href_list["reload_statbrowser"])
|
||||
src << browse(file('html/statbrowser.html'), "window=statbrowser")
|
||||
stat_panel.reinitialize()
|
||||
// Log all hrefs
|
||||
log_href("[src] (usr:[usr]\[[COORD(usr)]\]) : [hsrc ? "[hsrc] " : ""][href]")
|
||||
|
||||
@@ -209,8 +209,12 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
GLOB.clients += src
|
||||
GLOB.directory[ckey] = src
|
||||
|
||||
// Instantiate stat panel
|
||||
stat_panel = new(src, "statbrowser")
|
||||
stat_panel.subscribe(src, .proc/on_stat_panel_message)
|
||||
|
||||
// Instantiate tgui panel
|
||||
tgui_panel = new(src)
|
||||
tgui_panel = new(src, "browseroutput")
|
||||
|
||||
set_right_click_menu_mode(TRUE)
|
||||
|
||||
@@ -335,9 +339,15 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
if(SSinput.initialized)
|
||||
set_macros()
|
||||
|
||||
// Initialize tgui panel
|
||||
src << browse(file('html/statbrowser.html'), "window=statbrowser")
|
||||
// Initialize stat panel
|
||||
stat_panel.initialize(
|
||||
inline_html = file2text('html/statbrowser.html'),
|
||||
inline_js = file2text('html/statbrowser.js'),
|
||||
inline_css = file2text('html/statbrowser.css'),
|
||||
)
|
||||
addtimer(CALLBACK(src, .proc/check_panel_loaded), 30 SECONDS)
|
||||
|
||||
// Initialize tgui panel
|
||||
tgui_panel.initialize()
|
||||
|
||||
if(alert_mob_dupe_login && !holder)
|
||||
@@ -1091,10 +1101,10 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
continue
|
||||
panel_tabs |= verb_to_init.category
|
||||
verblist[++verblist.len] = list(verb_to_init.category, verb_to_init.name)
|
||||
src << output("[url_encode(json_encode(panel_tabs))];[url_encode(json_encode(verblist))]", "statbrowser:init_verbs")
|
||||
src.stat_panel.send_message("init_verbs", list(panel_tabs = panel_tabs, verblist = verblist))
|
||||
|
||||
/client/proc/check_panel_loaded()
|
||||
if(statbrowser_ready)
|
||||
if(stat_panel.is_ready())
|
||||
return
|
||||
to_chat(src, span_userdanger("Statpanel failed to load, click <a href='?src=[REF(src)];reload_statbrowser=1'>here</a> to reload the panel "))
|
||||
|
||||
@@ -1144,6 +1154,23 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
else
|
||||
SSambience.remove_ambience_client(src)
|
||||
|
||||
/**
|
||||
* Handles incoming messages from the stat-panel TGUI.
|
||||
*/
|
||||
/client/proc/on_stat_panel_message(type, payload)
|
||||
switch(type)
|
||||
if("Update-Verbs")
|
||||
init_verbs()
|
||||
if("Remove-Tabs")
|
||||
panel_tabs -= payload["tab"]
|
||||
if("Send-Tabs")
|
||||
panel_tabs |= payload["tab"]
|
||||
if("Reset-Tabs")
|
||||
panel_tabs = list()
|
||||
if("Set-Tab")
|
||||
stat_tab = payload["tab"]
|
||||
SSstatpanels.immediate_send_stat_data(src)
|
||||
|
||||
/// Checks if this client has met the days requirement passed in, or if
|
||||
/// they are exempt from it.
|
||||
/// Returns the number of days left, or 0.
|
||||
|
||||
Reference in New Issue
Block a user