mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
[MIRROR] refactors statpanel to use tgui API [MDB IGNORE] (#13646)
* refactors statpanel to use tgui API * fix Co-authored-by: magatsuchi <88991542+magatsuchi@users.noreply.github.com> Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
This commit is contained in:
co-authored by
magatsuchi
Tom
parent
2856b73bc9
commit
a079903ecb
@@ -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
|
||||
|
||||
@@ -87,7 +87,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]")
|
||||
|
||||
@@ -213,8 +213,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)
|
||||
|
||||
@@ -344,9 +348,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)
|
||||
@@ -1129,10 +1139,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 "))
|
||||
|
||||
@@ -1182,6 +1192,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