Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit b7b7ffa

Browse files
wahoo!
1 parent 188d1b6 commit b7b7ffa

File tree

14 files changed

+1518
-1218
lines changed

14 files changed

+1518
-1218
lines changed

code/__HELPERS/verbs.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
output_list[++output_list.len] = list(verb_to_add.category, verb_to_add.name)
4646
output_list = url_encode(json_encode(output_list))
4747

48-
target << output("[output_list];", "statbrowser:add_verb_list")
48+
target.stat_panel.send_message("add_verb_list", output_list)
4949

5050
/**
5151
* handles removing verb and sending it to browser to update, use this for removing verbs
@@ -93,4 +93,4 @@
9393
output_list[++output_list.len] = list(verb_to_remove.category, verb_to_remove.name)
9494
output_list = url_encode(json_encode(output_list))
9595

96-
target << output("[output_list];", "statbrowser:remove_verb_list")
96+
target.stat_panel.send_message("remove_verb_list", output_list)

code/_onclick/click.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@
364364
var/turf/T = get_turf(src)
365365
if(T && user.TurfAdjacent(T))
366366
user.listed_turf = T
367-
user.client << output("[url_encode(json_encode(T.name))];", "statbrowser:create_listedturf")
367+
user.client.stat_panel.send_message("create_listedturf", T.name)
368368

369369
// Use this instead of /mob/proc/AltClickOn(atom/A) where you only want turf content listing without additional atom alt-click interaction
370370
/atom/proc/AltClickNoInteract(mob/user, atom/A)
371371
var/turf/T = get_turf(A)
372372
if(T && user.TurfAdjacent(T))
373373
user.listed_turf = T
374-
user.client << output("[url_encode(json_encode(T.name))];", "statbrowser:create_listedturf")
374+
user.client.stat_panel.send_message("create_listedturf", T.name)
375375

376376
/mob/proc/TurfAdjacent(turf/T)
377377
return T.Adjacent(src)

code/controllers/subsystem/statpanel.dm

Lines changed: 77 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@ SUBSYSTEM_DEF(statpanels)
66
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
77
flags = SS_NO_INIT
88
var/list/currentrun = list()
9-
var/encoded_global_data
10-
var/mc_data_encoded
11-
var/list/cached_images = list()
9+
var/list/global_data
10+
var/list/mc_data
1211

12+
var/list/cached_images = list()
1313
///how many subsystem fires between most tab updates
1414
var/default_wait = 10
1515
///how many subsystem fires between updates of the status tab
1616
var/status_wait = 2
1717
///how many subsystem fires between updates of the MC tab
1818
var/mc_wait = 5
19+
/// how many subsystem fires between updates of the turf examine tab
20+
var/turf_wait = 2
1921
///how many full runs this subsystem has completed. used for variable rate refreshes.
2022
var/num_fires = 0
2123

2224
/datum/controller/subsystem/statpanels/fire(resumed = FALSE)
2325
if (!resumed)
2426
num_fires++
2527
var/datum/map_config/cached = SSmapping.next_map_config
26-
var/round_time = world.time - SSticker.round_start_time
2728

2829
var/storyteller = "Not Set"
2930
if(SSgamemode.storyteller)
@@ -35,13 +36,13 @@ SUBSYSTEM_DEF(statpanels)
3536
if(SSgamemode.secret_storyteller)
3637
storyteller = "Secret"
3738

38-
var/list/global_data = list(
39+
global_data = list(
3940
"Map: [SSmapping.config?.map_name || "Loading..."]",
4041
cached ? "Next Map: [cached.map_name]" : null,
4142
"Storyteller: [storyteller]",
4243
"Round ID: [GLOB.round_id ? GLOB.round_id : "NULL"]",
4344
"Server Time: [time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")]",
44-
"Round Time: [round_time > MIDNIGHT_ROLLOVER ? "[round(round_time/MIDNIGHT_ROLLOVER)]:[worldtime2text()]" : worldtime2text()]",
45+
"Round Time: [ROUND_TIME()]",
4546
"Station Time: [station_time_timestamp()]",
4647
"Time Dilation: [round(SStime_track.time_dilation_current,1)]% AVG:([round(SStime_track.time_dilation_avg_fast,1)]%, [round(SStime_track.time_dilation_avg,1)]%, [round(SStime_track.time_dilation_avg_slow,1)]%)"
4748
)
@@ -50,38 +51,43 @@ SUBSYSTEM_DEF(statpanels)
5051
var/ETA = SSshuttle.emergency.getModeStr()
5152
if(ETA)
5253
global_data += "[ETA] [SSshuttle.emergency.getTimerStr()]"
53-
encoded_global_data = url_encode(json_encode(global_data))
54+
5455
src.currentrun = GLOB.clients.Copy()
55-
mc_data_encoded = null
56+
mc_data = null
57+
5658
var/list/currentrun = src.currentrun
5759
while(length(currentrun))
5860
var/client/target = currentrun[length(currentrun)]
5961
currentrun.len--
60-
if(!target)
61-
continue
62-
if(!target.statbrowser_ready)
62+
63+
if(!target.stat_panel.is_ready())
6364
continue
65+
6466
if(target.stat_tab == "Status" && num_fires % status_wait == 0)
6567
set_status_tab(target)
68+
6669
if(!target.holder)
67-
target << output("", "statbrowser:remove_admin_tabs")
70+
target.stat_panel.send_message("remove_admin_tabs")
6871
else
69-
target << output("[!!(target.prefs.extra_toggles & SPLIT_ADMIN_TABS)]", "statbrowser:update_split_admin_tabs")
72+
target.stat_panel.send_message("update_split_admin_tabs", !!(target.prefs.extra_toggles & SPLIT_ADMIN_TABS))
73+
7074
if(!("MC" in target.panel_tabs))
71-
target << output("[url_encode(target.holder.href_token)]", "statbrowser:add_admin_tabs")
72-
73-
//if(target.stat_tab == "MC" && (num_fires % mc_wait == 0))
74-
if(target.stat_tab == "MC" && ((num_fires % mc_wait == 0) || (target?.prefs.extra_toggles & FAST_MC_REFRESH)))
75+
target.stat_panel.send_message("add_admin_tabs", target.holder.href_token)
76+
77+
if(target.stat_tab == "MC" && ((num_fires % mc_wait == 0)))
7578
set_MC_tab(target)
7679

7780
if(!length(GLOB.sdql2_queries) && ("SDQL2" in target.panel_tabs))
78-
target << output("", "statbrowser:remove_sdql2")
81+
target.stat_panel.send_message("remove_sdql2")
82+
7983
else if(length(GLOB.sdql2_queries) && (target.stat_tab == "SDQL2" || !("SDQL2" in target.panel_tabs)) && num_fires % default_wait == 0)
8084
set_SDQL2_tab(target)
85+
8186
if(target.mob)
8287
var/mob/target_mob = target.mob
8388

8489
// Handle the action panels of the stat panel
90+
8591
var/update_actions = FALSE
8692
// We're on a spell tab, update the tab so we can see cooldowns progressing and such
8793
if(target.stat_tab in target.spell_tabs)
@@ -95,30 +101,35 @@ SUBSYSTEM_DEF(statpanels)
95101
set_action_tabs(target, target_mob)
96102

97103
// Handle the examined turf of the stat panel
98-
99-
if(target_mob?.listed_turf && num_fires % default_wait == 0)
100-
if(!target_mob.TurfAdjacent(target_mob.listed_turf))
101-
target << output("", "statbrowser:remove_listedturf")
104+
if(target_mob?.listed_turf && num_fires % turf_wait == 0)
105+
if(!target_mob.TurfAdjacent(target_mob.listed_turf) || isnull(target_mob.listed_turf))
106+
target.stat_panel.send_message("remove_listedturf")
102107
target_mob.listed_turf = null
103108
else if(target.stat_tab == target_mob?.listed_turf.name || !(target_mob?.listed_turf.name in target.panel_tabs))
104109
set_turf_examine_tab(target, target_mob)
110+
105111
if(MC_TICK_CHECK)
106112
return
107113

108114
/datum/controller/subsystem/statpanels/proc/set_status_tab(client/target)
109-
if(!encoded_global_data)//statbrowser hasnt fired yet and we were called from immediate_send_stat_data()
115+
#if MIN_COMPILER_VERSION > 515
116+
#warn 516 is most certainly out of beta, remove this beta notice if you haven't already
117+
#endif
118+
var/static/list/beta_notice = list("", "You are on the BYOND 516 beta, various UIs and such may be broken!", "Please report issues, and switch back to BYOND 515 if things are causing too many issues for you.")
119+
if(!global_data)//statbrowser hasnt fired yet and we were called from immediate_send_stat_data()
110120
return
111-
112-
var/ping_str = url_encode("Ping: [round(target.lastping, 1)]ms (Average: [round(target.avgping, 1)]ms)")
113-
var/other_str = url_encode(json_encode(target.mob?.get_status_tab_items()))
114-
target << output("[encoded_global_data];[ping_str];[other_str]", "statbrowser:update")
121+
target.stat_panel.send_message("update_stat", list(
122+
"global_data" = (target.byond_version < 516) ? global_data : (global_data + beta_notice),
123+
"ping_str" = "Ping: [round(target.lastping, 1)]ms (Average: [round(target.avgping, 1)]ms)",
124+
"other_str" = target.mob?.get_status_tab_items(),
125+
))
115126

116127
/datum/controller/subsystem/statpanels/proc/set_MC_tab(client/target)
117128
var/turf/eye_turf = get_turf(target.eye)
118-
var/coord_entry = url_encode(COORD(eye_turf))
119-
if(!mc_data_encoded)
129+
var/coord_entry = COORD(eye_turf)
130+
if(!mc_data)
120131
generate_mc_data()
121-
target << output("[mc_data_encoded];[coord_entry]", "statbrowser:update_mc")
132+
target.stat_panel.send_message("update_mc", list("mc_data" = mc_data, "coord_entry" = coord_entry))
122133

123134
/datum/controller/subsystem/statpanels/proc/set_SDQL2_tab(client/target)
124135
var/list/sdql2A = list()
@@ -128,7 +139,7 @@ SUBSYSTEM_DEF(statpanels)
128139
sdql2B = query.generate_stat()
129140

130141
sdql2A += sdql2B
131-
target << output(url_encode(json_encode(sdql2A)), "statbrowser:update_sdql2")
142+
target.stat_panel.send_message("update_sdql2", sdql2A)
132143

133144
/// Set up the various action tabs.
134145
/datum/controller/subsystem/statpanels/proc/set_action_tabs(client/target, mob/target_mob)
@@ -138,7 +149,7 @@ SUBSYSTEM_DEF(statpanels)
138149
for(var/action_data in actions)
139150
target.spell_tabs |= action_data[1]
140151

141-
target << output("[url_encode(json_encode(target.spell_tabs))];[url_encode(json_encode(actions))]", "statbrowser:update_spells")
152+
target.stat_panel.send_message("update_spells", list(spell_tabs = target.spell_tabs, actions = actions))
142153

143154
/datum/controller/subsystem/statpanels/proc/set_turf_examine_tab(client/target, mob/target_mob)
144155
var/list/overrides = list()
@@ -175,37 +186,54 @@ SUBSYSTEM_DEF(statpanels)
175186
else
176187
turfitems[++turfitems.len] = list("[turf_content.name]", REF(turf_content))
177188

178-
turfitems = url_encode(json_encode(turfitems))
179-
target << output("[turfitems];", "statbrowser:update_listedturf")
189+
turfitems = turfitems
190+
target.stat_panel.send_message("update_listedturf", turfitems)
180191

181192
/datum/controller/subsystem/statpanels/proc/generate_mc_data()
182-
var/list/mc_data = list(
193+
mc_data = list(
183194
list("CPU:", world.cpu),
184195
list("Instances:", "[num2text(world.contents.len, 10)]"),
185196
list("World Time:", "[world.time]"),
186-
list("Globals:", GLOB.stat_entry(), "\ref[GLOB]"),
187-
list("[config]:", config.stat_entry(), "\ref[config]"),
197+
list("Globals:", GLOB.stat_entry(), text_ref(GLOB)),
198+
list("[config]:", config.stat_entry(), text_ref(config)),
188199
list("Byond:", "(FPS:[world.fps]) (TickCount:[world.time/world.tick_lag]) (TickDrift:[round(Master.tickdrift,1)]([round((Master.tickdrift/(world.time/world.tick_lag))*100,0.1)]%)) (Internal Tick Usage: [round(MAPTICK_LAST_INTERNAL_TICK_USAGE,0.1)]%)"),
189-
list("Master Controller:", Master.stat_entry(), "\ref[Master]"),
190-
list("Failsafe Controller:", Failsafe.stat_entry(), "\ref[Failsafe]"),
200+
list("Master Controller:", Master.stat_entry(), text_ref(Master)),
201+
list("Failsafe Controller:", Failsafe.stat_entry(), text_ref(Failsafe)),
191202
list("","")
192203
)
204+
#if defined(MC_TAB_TRACY_INFO) || defined(SPACEMAN_DMM)
205+
var/static/tracy_dll
206+
var/static/tracy_present
207+
if(isnull(tracy_dll))
208+
tracy_dll = TRACY_DLL_PATH
209+
tracy_present = fexists(tracy_dll)
210+
if(tracy_present)
211+
if(GLOB.tracy_initialized)
212+
mc_data.Insert(2, list(list("byond-tracy:", "Active (reason: [GLOB.tracy_init_reason || "N/A"])")))
213+
else if(GLOB.tracy_init_error)
214+
mc_data.Insert(2, list(list("byond-tracy:", "Errored ([GLOB.tracy_init_error])")))
215+
else if(fexists(TRACY_ENABLE_PATH))
216+
mc_data.Insert(2, list(list("byond-tracy:", "Queued for next round")))
217+
else
218+
mc_data.Insert(2, list(list("byond-tracy:", "Inactive")))
219+
else
220+
mc_data.Insert(2, list(list("byond-tracy:", "[tracy_dll] not present")))
221+
#endif
193222
for(var/datum/controller/subsystem/sub_system as anything in Master.subsystems)
194-
mc_data[++mc_data.len] = list("\[[sub_system.state_letter()]][sub_system.name]", sub_system.stat_entry(), "\ref[sub_system]")
195-
mc_data[++mc_data.len] = list("Camera Net", "Cameras: [GLOB.cameranet.cameras.len] | Chunks: [GLOB.cameranet.chunks.len]", "\ref[GLOB.cameranet]")
196-
mc_data_encoded = url_encode(json_encode(mc_data))
223+
mc_data[++mc_data.len] = list("\[[sub_system.state_letter()]][sub_system.name]", sub_system.stat_entry(), text_ref(sub_system))
224+
mc_data[++mc_data.len] = list("Camera Net", "Cameras: [GLOB.cameranet.cameras.len] | Chunks: [GLOB.cameranet.chunks.len]", text_ref(GLOB.cameranet))
197225

198226
///immediately update the active statpanel tab of the target client
199227
/datum/controller/subsystem/statpanels/proc/immediate_send_stat_data(client/target)
200-
if(!target.statbrowser_ready)
228+
if(!target.stat_panel.is_ready())
201229
return FALSE
202230

203231
if(target.stat_tab == "Status")
204232
set_status_tab(target)
205233
return TRUE
206234

207235
var/mob/target_mob = target.mob
208-
236+
209237
// Handle actions
210238

211239
var/update_actions = FALSE
@@ -220,10 +248,9 @@ SUBSYSTEM_DEF(statpanels)
220248
return TRUE
221249

222250
// Handle turfs
223-
224251
if(target_mob?.listed_turf)
225252
if(!target_mob.TurfAdjacent(target_mob.listed_turf))
226-
target << output("", "statbrowser:remove_listedturf")
253+
target.stat_panel.send_message("removed_listedturf")
227254
target_mob.listed_turf = null
228255

229256
else if(target.stat_tab == target_mob?.listed_turf.name || !(target_mob?.listed_turf.name in target.panel_tabs))
@@ -238,48 +265,13 @@ SUBSYSTEM_DEF(statpanels)
238265
return TRUE
239266

240267
if(!length(GLOB.sdql2_queries) && ("SDQL2" in target.panel_tabs))
241-
target << output("", "statbrowser:remove_sdql2")
268+
target.stat_panel.send_message("remove_sdql2")
242269

243270
else if(length(GLOB.sdql2_queries) && target.stat_tab == "SDQL2")
244271
set_SDQL2_tab(target)
245272

273+
/// Stat panel window declaration
274+
/client/var/datum/tgui_window/stat_panel
275+
246276
/atom/proc/remove_from_cache()
247277
SSstatpanels.cached_images -= REF(src)
248-
249-
/// verbs that send information from the browser UI
250-
/client/verb/set_tab(tab as text|null)
251-
set name = "Set Tab"
252-
set hidden = TRUE
253-
254-
stat_tab = tab
255-
SSstatpanels.immediate_send_stat_data(src)
256-
257-
/client/verb/send_tabs(tabs as text|null)
258-
set name = "Send Tabs"
259-
set hidden = TRUE
260-
261-
panel_tabs |= tabs
262-
263-
/client/verb/remove_tabs(tabs as text|null)
264-
set name = "Remove Tabs"
265-
set hidden = TRUE
266-
267-
panel_tabs -= tabs
268-
269-
/client/verb/reset_tabs()
270-
set name = "Reset Tabs"
271-
set hidden = TRUE
272-
273-
panel_tabs = list()
274-
275-
/client/verb/panel_ready()
276-
set name = "Panel Ready"
277-
set hidden = TRUE
278-
279-
init_verbs()
280-
281-
/client/verb/update_verbs()
282-
set name = "Update Verbs"
283-
set hidden = TRUE
284-
285-
init_verbs()

code/modules/admin/admin_verbs.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
851851
set name = "Debug Stat Panel"
852852
set category = "Misc.Server Debug"
853853

854-
src << output("", "statbrowser:create_debug")
854+
src.stat_panel.send_message("create_debug")
855855

856856
/// Debug verb for seeing at a glance what all spells have as set requirements
857857
/client/proc/debug_spell_requirements()

code/modules/client/client_defines.dm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@
130130
/// our current tab
131131
var/stat_tab
132132

133-
/// whether our browser is ready or not yet
134-
var/statbrowser_ready = FALSE
135-
136133
/// list of all tabs
137134
var/list/panel_tabs = list()
138135

0 commit comments

Comments
 (0)