Files
Bubberstation/code/__HELPERS/stat_tracking.dm
Kashargul 68b687b13f some more 516 compat fixes (#89766)
Ports the helpers from
https://github.com/BeeStation/BeeStation-Hornet/pull/12240

This should fix some more of the 516 issues that I've seen while giving
a quick check through the code

The remaining browse should work now.

Also fixing another sass warning while being on it.

## About The Pull Request
## Why It's Good For The Game
## Changelog
🆑
fix: tgui say 516 will no longer change channels when the button is used
to drag it
fix: tgui say 516 will no longer leak radio messages into the wrong
channel
fix: runechat flickering when faded up messages fade out
/🆑
2025-03-12 17:10:23 -04:00

42 lines
1.2 KiB
Plaintext

// For use with the stopwatch defines
/proc/render_stats(list/stats, user, sort = GLOBAL_PROC_REF(cmp_generic_stat_item_time))
sortTim(stats, sort, TRUE)
var/list/lines = list()
for (var/entry in stats)
var/list/data = stats[entry]
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"
if (user)
user << browse(HTML_SKELETON("<ol><li>[lines.Join("</li><li>")]</li></ol>"), "window=[url_encode("stats:[REF(stats)]")]")
. = lines.Join("\n")
// For use with the set_cost defines
/proc/stat_tracking_export_to_json_later(filename, costs, counts)
if (IsAdminAdvancedProcCall())
return
var/list/output = list()
for (var/key in costs)
output[key] = list(
"cost" = costs[key],
"count" = counts[key],
)
rustg_file_write(json_encode(output), "[GLOB.log_directory]/[filename]")
/proc/stat_tracking_export_to_csv_later(filename, costs, counts)
if (IsAdminAdvancedProcCall())
return
var/list/output = list()
output += "key, cost, count"
for (var/key in costs)
output += "[replacetext(key, ",", "")], [costs[key]], [counts[key]]"
rustg_file_write(output.Join("\n"), "[GLOB.log_directory]/[filename]")