[MIRROR] Fix various issues with browser statpanel (#580)

* Fix various issues with browser statpanel

* a

Co-authored-by: Tad Hardesty <tad@platymuus.com>
Co-authored-by: Azarak <azarak10@gmail.com>
This commit is contained in:
SkyratBot
2020-09-02 02:42:40 +02:00
committed by GitHub
co-authored by Tad Hardesty Azarak
parent 582c843bbf
commit c4c9dfabf6
15 changed files with 85 additions and 72 deletions
@@ -52,7 +52,7 @@
LoadMOTD()
LoadPolicy()
LoadChatFilter()
if (Master)
Master.OnConfigLoad()
@@ -186,10 +186,9 @@
var/list/banned_edits = list(NAMEOF(src, entries_by_type), NAMEOF(src, entries), NAMEOF(src, directory))
return !(var_name in banned_edits) && ..()
/datum/controller/configuration/stat_entry()
if(!statclick)
statclick = new/obj/effect/statclick/debug(null, "Edit", src)
stat("[name]:", statclick)
/datum/controller/configuration/stat_entry(msg)
msg = "Edit"
return msg
/datum/controller/configuration/proc/Get(entry_type)
var/datum/config_entry/E = entry_type
+1 -1
View File
@@ -16,4 +16,4 @@
/datum/controller/proc/Recover()
/datum/controller/proc/stat_entry()
/datum/controller/proc/stat_entry(msg)
+3 -5
View File
@@ -95,8 +95,6 @@ GLOBAL_REAL(Failsafe, /datum/controller/failsafe)
/datum/controller/failsafe/proc/defcon_pretty()
return defcon
/datum/controller/failsafe/stat_entry()
if(!statclick)
statclick = new/obj/effect/statclick/debug(null, "Initializing...", src)
stat("Failsafe Controller:", statclick.update("Defcon: [defcon_pretty()] (Interval: [Failsafe.processing_interval] | Iteration: [Failsafe.master_iteration])"))
/datum/controller/failsafe/stat_entry(msg)
msg = "Defcon: [defcon_pretty()] (Interval: [Failsafe.processing_interval] | Iteration: [Failsafe.master_iteration])"
return msg
+3 -5
View File
@@ -25,11 +25,9 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars)
SHOULD_CALL_PARENT(FALSE)
return QDEL_HINT_IWILLGC
/datum/controller/global_vars/stat_entry()
if(!statclick)
statclick = new/obj/effect/statclick/debug(null, "Initializing...", src)
stat("Globals:", statclick.update("Edit"))
/datum/controller/global_vars/stat_entry(msg)
msg = "Edit"
return msg
/datum/controller/global_vars/vv_edit_var(var_name, var_value)
if(gvars_datum_protected_varlist[var_name])
+3 -6
View File
@@ -601,12 +601,9 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
skip_ticks = 1
/datum/controller/master/stat_entry()
if(!statclick)
statclick = new/obj/effect/statclick/debug(null, "Initializing...", src)
stat("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)]%)")
stat("Master Controller:", statclick.update("(TickRate:[Master.processing]) (Iteration:[Master.iteration]) (TickLimit: [round(Master.current_ticklimit, 0.1)])"))
/datum/controller/master/stat_entry(msg)
msg = "(TickRate:[Master.processing]) (Iteration:[Master.iteration]) (TickLimit: [round(Master.current_ticklimit, 0.1)])"
return msg
/datum/controller/master/StartLoadingMap()
+1 -1
View File
@@ -12,7 +12,7 @@ SUBSYSTEM_DEF(profiler)
/datum/controller/subsystem/profiler/stat_entry(msg)
msg += "F:[round(fetch_cost,1)]ms"
msg += "|W:[round(write_cost,1)]ms"
..(msg)
return msg
/datum/controller/subsystem/profiler/Initialize()
if(CONFIG_GET(flag/auto_profile))
+2 -1
View File
@@ -40,7 +40,8 @@ SUBSYSTEM_DEF(runechat)
bucket_resolution = world.tick_lag
/datum/controller/subsystem/runechat/stat_entry(msg)
..("ActMsgs:[bucket_count] SecQueue:[length(second_queue)]")
msg = "ActMsgs:[bucket_count] SecQueue:[length(second_queue)]"
return msg
/datum/controller/subsystem/runechat/fire(resumed = FALSE)
// Store local references to datum vars as it is faster to access them this way
+9 -5
View File
@@ -32,11 +32,11 @@ SUBSYSTEM_DEF(statpanels)
list("CPU:", world.cpu),
list("Instances:", "[num2text(world.contents.len, 10)]"),
list("World Time:", "[world.time]"),
list("Globals:", "Edit", "\ref[GLOB]"),
list("[config]:", "Edit", "\ref[config]"),
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)]%))"),
list("Master Controller:", Master ? "(TickRate:[Master.processing]) (Iteration:[Master.iteration])" : "ERROR", "\ref[Master]"),
list("Failsafe Controller:", Failsafe ? "Defcon: [Failsafe.defcon_pretty()] (Interval: [Failsafe.processing_interval] | Iteration: [Failsafe.master_iteration])" : "ERROR", "\ref[Failsafe]"),
list("Globals:", GLOB.stat_entry(), "\ref[GLOB]"),
list("[config]:", config.stat_entry(), "\ref[config]"),
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)]%)"),
list("Master Controller:", Master.stat_entry(), "\ref[Master]"),
list("Failsafe Controller:", Failsafe.stat_entry(), "\ref[Failsafe]"),
list("","")
)
for(var/ss in Master.subsystems)
@@ -94,6 +94,10 @@ SUBSYSTEM_DEF(statpanels)
if(!target_image.loc || target_image.loc.loc != target_mob.listed_turf || !target_image.override)
continue
overrides += target_image.loc
if(!(REF(target_mob.listed_turf) in cached_images))
target << browse_rsc(getFlatIcon(target_mob.listed_turf, no_anim = TRUE), "[REF(target_mob.listed_turf)].png")
cached_images += REF(target_mob.listed_turf)
turfitems[++turfitems.len] = list("[target_mob.listed_turf]", REF(target_mob.listed_turf), "[REF(target_mob.listed_turf)].png")
for(var/tc in target_mob.listed_turf)
var/atom/movable/turf_content = tc
if(turf_content.mouse_opacity == MOUSE_OPACITY_TRANSPARENT)
+2 -2
View File
@@ -39,7 +39,7 @@
new_ai = select_active_ai(R, R.z)
R.notify_ai(DISCONNECT)
if(new_ai && (new_ai != R.connected_ai))
R.connected_ai = new_ai
R.set_connected_ai(new_ai)
if(R.shell)
R.undeploy() //If this borg is an AI shell, disconnect the controlling AI and assign ti to a new AI
R.notify_ai(AI_SHELL)
@@ -68,7 +68,7 @@
R.notify_ai(DISCONNECT)
if(R.shell)
R.undeploy()
R.connected_ai = null
R.set_connected_ai(null)
if(WIRE_LAWSYNC) // Cut the law wire, and the borg will no longer receive law updates from its AI. Repair and it will re-sync.
if(mend)
if(!R.emagged)
+1 -1
View File
@@ -96,7 +96,7 @@
// So he can't jump out the gate right away.
R.SetLockdown()
if(masterAI)
R.connected_ai = masterAI
R.set_connected_ai(masterAI)
R.lawsync()
R.lawupdate = 1
addtimer(CALLBACK(src, .proc/unlock_new_robot, R), 50)
+4 -4
View File
@@ -267,11 +267,11 @@
O.locked = panel_locked
if(!aisync)
lawsync = FALSE
O.connected_ai = null
O.set_connected_ai(null)
else
O.notify_ai(NEW_BORG)
if(forced_ai)
O.connected_ai = forced_ai
O.set_connected_ai(forced_ai)
if(!lawsync)
O.lawupdate = FALSE
if(M.laws.id == DEFAULT_AI_LAWID)
@@ -324,10 +324,10 @@
if(!aisync)
lawsync = FALSE
O.connected_ai = null
O.set_connected_ai(null)
else
if(forced_ai)
O.connected_ai = forced_ai
O.set_connected_ai(forced_ai)
O.notify_ai(AI_SHELL)
if(!lawsync)
O.lawupdate = FALSE
+2 -2
View File
@@ -199,7 +199,7 @@
borg.notify_ai(DISCONNECT)
if(borg.shell)
borg.undeploy()
borg.connected_ai = newai
borg.set_connected_ai(newai)
borg.notify_ai(TRUE)
message_admins("[key_name_admin(user)] slaved [ADMIN_LOOKUPFLW(borg)] to the AI [ADMIN_LOOKUPFLW(newai)].")
log_admin("[key_name(user)] slaved [key_name(borg)] to the AI [key_name(newai)].")
@@ -207,7 +207,7 @@
borg.notify_ai(DISCONNECT)
if(borg.shell)
borg.undeploy()
borg.connected_ai = null
borg.set_connected_ai(null)
message_admins("[key_name_admin(user)] freed [ADMIN_LOOKUPFLW(borg)] from being slaved to an AI.")
log_admin("[key_name(user)] freed [key_name(borg)] from being slaved to an AI.")
if (borg.lawupdate)
+15 -7
View File
@@ -181,7 +181,7 @@
stack_trace("Borg MMI lacked a brainmob")
mmi = null
if(connected_ai)
connected_ai.connected_robots -= src
set_connected_ai(null)
if(shell)
GLOB.available_ai_shells -= src
else
@@ -461,9 +461,7 @@
gib()
/mob/living/silicon/robot/proc/UnlinkSelf()
if(src.connected_ai)
connected_ai.connected_robots -= src
src.connected_ai = null
set_connected_ai(null)
lawupdate = FALSE
set_lockcharge(FALSE)
scrambledcodes = TRUE
@@ -956,7 +954,7 @@
builtInCamera.c_tag = real_name //update the camera name too
mainframe = AI
deployed = TRUE
connected_ai = mainframe
set_connected_ai(mainframe)
mainframe.connected_robots |= src
lawupdate = TRUE
lawsync()
@@ -1069,9 +1067,8 @@
/mob/living/silicon/robot/proc/TryConnectToAI()
connected_ai = select_active_ai_with_fewest_borgs(z)
set_connected_ai(select_active_ai_with_fewest_borgs(z))
if(connected_ai)
connected_ai.connected_robots += src
lawsync()
lawupdate = TRUE
return TRUE
@@ -1092,3 +1089,14 @@
cell.charge = min(cell.charge + amount, cell.maxcharge)
if(repairs)
heal_bodypart_damage(repairs, repairs - 1)
/mob/living/silicon/robot/proc/set_connected_ai(new_ai)
if(connected_ai == new_ai)
return
. = connected_ai
connected_ai = new_ai
if(.)
var/mob/living/silicon/ai/old_ai = .
old_ai.connected_robots -= src
if(connected_ai)
connected_ai.connected_robots |= src
@@ -341,7 +341,7 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
SetEmagged(1)
SetStun(60) //Borgs were getting into trouble because they would attack the emagger before the new laws were shown
lawupdate = FALSE
connected_ai = null
set_connected_ai(null)
message_admins("[ADMIN_LOOKUPFLW(user)] emagged cyborg [ADMIN_LOOKUPFLW(src)]. Laws overridden.")
log_game("[key_name(user)] emagged cyborg [key_name(src)]. Laws overridden.")
var/time = time2text(world.realtime,"hh:mm:ss")
+34 -26
View File
@@ -9,8 +9,8 @@
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 12px !important;
margin: 5px !important;
padding: 2px !important;
margin: 0 !important;
padding: 0 !important;
}
body.dark {
background-color: #131313;
@@ -19,11 +19,18 @@ body.dark {
#menu {
background-color: white;
position: fixed;
padding: 7px;
width: 100%;
}
.dark #menu {
background-color: #131313;
}
#statcontent {
padding: 0 7px 7px 7px;
}
a {
color: black;
text-decoration: none
@@ -142,6 +149,7 @@ li a:hover:not(.active) {
</head>
<body>
<ul id="menu" class="button-container"></ul>
<div id="under_menu"></div>
<div id="statcontent"></div>
<script>
// Polyfills and compatibility ------------------------------------------------
@@ -173,10 +181,14 @@ if (window.location) {
if(e.which) {
if(!anti_spam[e.which]) {
anti_spam[e.which] = true;
var href = "?__keydown=" + e.which;
if(e.ctrlKey === false) href += "&ctrlKey=0"
else if(e.ctrlKey === true) href += "&ctrlKey=1"
window.location.href = href;
var key = String.fromCharCode(e.which);
if(key == "t")
window.location.href = "byond://winset?command=Say"
else if(key == "o")
window.location.href = "byond://winset?command=OOC"
else if(key == "m")
window.location.href = "byond://winset?command=Me"
window.location.href = "byond://winset?command=keyDown " + key;
}
}
});
@@ -187,10 +199,8 @@ if (window.location) {
return;
if(e.which) {
anti_spam[e.which] = false;
var href = "?__keyup=" + e.which;
if(e.ctrlKey === false) href += "&ctrlKey=0"
else if(e.ctrlKey === true) href += "&ctrlKey=1"
window.location.href = href;
var key = String.fromCharCode(e.which);
window.location.href = "byond://winset?command=keyUp " + key;
}
});
}
@@ -220,6 +230,7 @@ var permanent_tabs = []; // tabs that won't be cleared by wipes
var turfcontents = [];
var turfname = "";
var menu = document.querySelector('#menu');
var under_menu = document.querySelector('#under_menu');
function createStatusTab(name) {
if(document.getElementById(name) || name.trim() == "")
@@ -227,7 +238,10 @@ function createStatusTab(name) {
if(!verb_tabs.includes(name) && !permanent_tabs.includes(name))
return;
var B = document.createElement("BUTTON");
B.onclick = function() {tab_change(name)};
B.onclick = function() {
tab_change(name);
this.blur();
};
B.id = name;
B[textContentKey] = name;
B.className = "button";
@@ -241,6 +255,7 @@ function createStatusTab(name) {
}
//END ORDERING
menu.appendChild(B);
under_menu.style.height = menu.clientHeight + 'px';
}
function removeStatusTab(name) {
@@ -252,10 +267,15 @@ function removeStatusTab(name) {
}
}
menu.removeChild(document.getElementById(name));
under_menu.style.height = menu.clientHeight + 'px';
if(document.getElementById(name)) // repeat for duplicates
removeStatusTab(name);
}
window.onresize = function () {
under_menu.style.height = menu.clientHeight + 'px';
}
function addPermanentTab(name) {
if(!permanent_tabs.includes(name))
permanent_tabs.push(name);
@@ -276,21 +296,6 @@ function checkStatusTab() {
if(!verb_tabs.includes(menu.children[i].id) && !permanent_tabs.includes(menu.children[i].id))
removeStatusTab(menu.children[i].id);
}
function add_verb(v) {
var to_add = JSON.parse(v);
var cat = "";
cat = to_add[0];
if(verb_tabs.includes(cat)){ // we have the category already
verbs.push(to_add); // add it to verb list and we done
} else if(cat.trim() != "") { // we don't have the category
verb_tabs.push(cat);
verbs.push(to_add); // add verb
createStatusTab(cat); // create the category
}
if(current_tab == cat) {
draw_verbs(cat); // redraw if we added a verb to the tab we're currently in
}
}
function remove_verb(v) {
var verb_to_remove = v; // to_remove = [verb:category, verb:name]
for(var i = verbs.length - 1; i >= 0; i--){
@@ -345,6 +350,9 @@ function add_verb_list(v) {
for(var i = 0; i < to_add.length; i++) {
var part = to_add[i];
if(verb_tabs.includes(part[0])){
if(verbs.includes(part)){
continue;
}
verbs.push(part);
if(current_tab == part[0]) {
draw_verbs(part[0]); // redraw if we added a verb to the tab we're currently in