This commit is contained in:
Archie
2021-11-05 02:09:29 -03:00
parent 9795d0c50b
commit 9cb19194c6
5 changed files with 124 additions and 45 deletions
+1
View File
@@ -117,6 +117,7 @@
#define FIRE_PRIORITY_TGUI 110
#define FIRE_PRIORITY_TICKER 200
#define FIRE_PRIORITY_ATMOS_ADJACENCY 300
#define FIRE_PRIORITY_STATPANEL 390
#define FIRE_PRIORITY_CHAT 400
#define FIRE_PRIORITY_OVERLAYS 500
#define FIRE_PRIORITY_INPUT 1000 // This must always always be the max highest priority. Player input must never be lost.
+40 -7
View File
@@ -2,6 +2,7 @@ SUBSYSTEM_DEF(statpanels)
name = "Stat Panels"
wait = 4
init_order = INIT_ORDER_STATPANELS
priority = FIRE_PRIORITY_STATPANEL
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
var/list/currentrun = list()
var/encoded_global_data
@@ -62,13 +63,13 @@ SUBSYSTEM_DEF(statpanels)
var/list/ahelp_tickets = GLOB.ahelp_tickets.stat_entry()
target << output("[url_encode(json_encode(ahelp_tickets))];", "statbrowser:update_tickets")
if(!length(GLOB.sdql2_queries))
target << output("", "statbrowser:remove_sqdl2")
target << output("", "statbrowser:remove_sdql2")
else
var/list/sqdl2A = list()
sqdl2A[++sqdl2A.len] = list("", "Access Global SDQL2 List", REF(GLOB.sdql2_vv_statobj))
var/list/sqdl2B = list()
sqdl2A += sqdl2B
target << output(url_encode(json_encode(sqdl2A)), "statbrowser:update_sqdl2")
var/list/sdql2A = list()
sdql2A[++sdql2A.len] = list("", "Access Global SDQL2 List", REF(GLOB.sdql2_vv_statobj))
var/list/sdql2B = list()
sdql2A += sdql2B
target << output(url_encode(json_encode(sdql2A)), "statbrowser:update_sdql2")
var/list/proc_holders = target.mob.get_proc_holders()
target.spell_tabs.Cut()
for(var/phl in proc_holders)
@@ -115,4 +116,36 @@ SUBSYSTEM_DEF(statpanels)
turfitems = url_encode(json_encode(turfitems))
target << output("[turfitems];", "statbrowser:update_listedturf")
if(MC_TICK_CHECK)
return
return
/// verbs that send information from the browser UI
/client/verb/set_tab(tab as text|null)
set name = "Set Tab"
set hidden = TRUE
stat_tab = tab
/client/verb/send_tabs(tabs as text|null)
set name = "Send Tabs"
set hidden = TRUE
panel_tabs |= tabs
/client/verb/remove_tabs(tabs as text|null)
set name = "Remove Tabs"
set hidden = TRUE
panel_tabs -= tabs
/client/verb/reset_tabs()
set name = "Reset Tabs"
set hidden = TRUE
panel_tabs = list()
/client/verb/panel_ready()
set name = "Panel Ready"
set hidden = TRUE
statbrowser_ready = TRUE
init_verbs()
+9
View File
@@ -30,6 +30,15 @@
/// 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
var/list/spell_tabs = list()
/// list of tabs containing verbs
@@ -630,7 +630,7 @@
name = "marshmallow"
desc = "A marshmallow filled with fluffy marshmallow fluff."
icon_state = "marshmallow"
list_reagents = list("sugar" = 5, "nutriment" = 2)
list_reagents = list(/datum/reagent/consumable/sugar = 5, /datum/reagent/consumable/nutriment = 2)
filling_color = "#fafafa"
w_class = WEIGHT_CLASS_TINY
tastes = list("marshmallow" = 2)
+73 -37
View File
@@ -282,17 +282,16 @@ var spells = [];
var spell_tabs = [];
var verb_tabs = [];
var verbs = [["", ""]]; // list with a list inside
var inner = "";
var tickets = [];
var sqdl2 = [];
var sdql2 = [];
var permanent_tabs = []; // tabs that won't be cleared by wipes
var turfcontents = [];
var turfname = "";
var imageRetryDelay = 50;
var imageRetryDelay = 500;
var imageRetryLimit = 50;
var menu = document.querySelector('#menu');
var under_menu = document.querySelector('#under_menu');
var statcontentdiv = document.getElementById('statcontent');
var statcontentdiv = document.querySelector('#statcontent');
var storedimages = [];
function createStatusTab(name) {
@@ -318,6 +317,7 @@ function createStatusTab(name) {
}
//END ORDERING
menu.appendChild(B);
SendTabToByond(name);
under_menu.style.height = menu.clientHeight + 'px';
}
@@ -330,9 +330,8 @@ function removeStatusTab(name) {
}
}
menu.removeChild(document.getElementById(name));
TakeTabFromByond(name);
under_menu.style.height = menu.clientHeight + 'px';
if(document.getElementById(name)) // repeat for duplicates
removeStatusTab(name);
}
window.onresize = function () {
@@ -357,7 +356,7 @@ function removePermanentTab(name) {
function checkStatusTab() {
for(var i=0; i < menu.children.length; i++)
if(!verb_tabs.includes(menu.children[i].id) && !permanent_tabs.includes(menu.children[i].id))
removeStatusTab(menu.children[i].id);
menu.removeChild(menu.children[i]);
}
function remove_verb(v) {
@@ -410,6 +409,14 @@ function findVerbindex(name, verblist) {
}
}
function findVerbindex(name, verblist) {
for(var i = 0; i < verblist.length; i++) {
var part = verblist[i];
if(part[1] == name)
return i;
}
}
function wipe_verbs() {
verbs = [["", ""]];
verb_tabs = [];
@@ -470,6 +477,24 @@ function init_verbs(c, v) {
draw_verbs(current_tab);
}
}
SendTabToByond();
}
function SendTabsToByond(){
var tabstosend = [];
tabstosend = tabstosend.concat(permanent_tabs, verb_tabs);
for(var i=0; i < tabstosend.length; i++){
SendTabToByond(tabstosend[i]);
}
}
function SendTabToByond(tab) {
window.location.href = "byond://winset?command=Send-Tabs " + tab;
}
//Byond can't have this tab anymore since we're removing it
function TakeTabFromByond(tab) {
window.location.href = "byond://winset?command=Remove-Tabs " + tab;
}
function update(global_data, ping_entry, other_entries) {
@@ -484,10 +509,9 @@ function update(global_data, ping_entry, other_entries) {
draw_debug();
}
function update_mc(global_mc_data, coords_entry, ht) {
function update_mc(global_mc_data, coords_entry) {
mc_tab_parts = JSON.parse(global_mc_data);
mc_tab_parts.splice(0,0,["Location:",coords_entry]);
href_token = ht;
if(!verb_tabs.includes("MC"))
verb_tabs.push("MC");
createStatusTab("MC");
@@ -557,6 +581,7 @@ function tab_change(tab) {
if(document.getElementById(current_tab))
document.getElementById(current_tab).className = "button"; // disable active on last button
current_tab = tab;
set_byond_tab(tab);
if(document.getElementById(tab))
document.getElementById(tab).className = "button active"; // make current button active
var spell_tabs_thingy = (spell_tabs.includes(tab));
@@ -573,21 +598,23 @@ function tab_change(tab) {
draw_debug();
} else if(tab == "Tickets") {
draw_tickets();
} else if(tab == "SQDL2") {
draw_sqdl2();
} else if(tab == "SDQL2") {
draw_sdql2();
} else if(tab == "Examine") {
draw_examine();
}else if(tab == turfname) {
draw_listedturf();
} else {
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "loading...";
}
window.location.href = "byond://winset?statbrowser.is-visible=true";
}
function set_byond_tab(tab){
window.location.href = "byond://winset?command=Set-Tab " + tab;
}
function draw_debug() {
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "";
var wipeverbstabs = document.createElement("div");
var link = document.createElement("a");
@@ -646,12 +673,11 @@ function draw_debug() {
}
function draw_status() {
var statcontentdiv = document.getElementById("statcontent");
if(!document.getElementById("Status")) {
createStatusTab("Status");
current_tab = "Status";
}
statcontentdiv[textContentKey] = inner;
statcontentdiv[textContentKey] = '';
for(var i = 0; i < status_tab_parts.length; i++) {
if(status_tab_parts[i].trim() == "") {
document.getElementById("statcontent").appendChild(document.createElement("br"));
@@ -668,7 +694,6 @@ function draw_status() {
}
function draw_mc() {
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "";
var table = document.createElement("table");
for(var i = 0; i < mc_tab_parts.length; i++) {
@@ -716,21 +741,21 @@ function update_tickets(T){
if(current_tab == "Tickets")
draw_tickets();
}
function update_sqdl2(S) {
sqdl2 = JSON.parse(S);
if(sqdl2.length > 0 && !verb_tabs.includes("SQDL2")) {
verb_tabs.push("SQDL2");
addPermanentTab("SQDL2");
function update_sdql2(S) {
sdql2 = JSON.parse(S);
if(sdql2.length > 0 && !verb_tabs.includes("SDQL2")) {
verb_tabs.push("SDQL2");
addPermanentTab("SDQL2");
}
if(current_tab == "SQDL2")
draw_sqdl2();
if(current_tab == "SDQL2")
draw_sdql2();
}
function remove_sqdl2() {
if(sqdl2) {
sqdl2 = [];
removePermanentTab("SQDL2");
if(current_tab == "SQDL2")
function remove_sdql2() {
if(sdql2) {
sdql2 = [];
removePermanentTab("SDQL2");
if(current_tab == "SDQL2")
tab_change("Status");
}
checkStatusTab();
@@ -747,9 +772,16 @@ function remove_tickets() {
}
// removes MC, Tickets and MC tabs.
function remove_admin_tabs() {
href_token = null;
remove_mc();
remove_tickets();
remove_sqdl2();
remove_sdql2();
}
function add_admin_tabs(ht) {
href_token = ht;
addPermanentTab("MC");
addPermanentTab("Tickets");
}
//mob examine
@@ -781,7 +813,7 @@ function update_listedturf(TC) {
draw_listedturf();
}
function iconError(E) {
function iconError() {
var that = this;
setTimeout(function() {
var current_attempts = that.id; // a bit of a hack, change this if we need to call on img id's later
@@ -854,12 +886,11 @@ function remove_listedturf() {
if(current_tab == turfname)
tab_change("Status");
}
function draw_sqdl2(){
var statcontentdiv = document.getElementById("statcontent");
function draw_sdql2(){
statcontentdiv[textContentKey] = "";
var table = document.createElement("table");
for(var i = 0; i < sqdl2.length; i++) {
var part = sqdl2[i];
for(var i = 0; i < sdql2.length; i++) {
var part = sdql2[i];
var tr = document.createElement("tr");
var td1 = document.createElement("td");
td1[textContentKey] = part[0];
@@ -880,7 +911,6 @@ function draw_sqdl2(){
}
function draw_tickets() {
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "";
var table = document.createElement("table");
if(!tickets)
@@ -912,7 +942,6 @@ function draw_tickets() {
}
function draw_spells(cat) {
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "";
var table = document.createElement("table");
for(var i = 0; i < spells.length; i++) {
@@ -938,7 +967,6 @@ function draw_spells(cat) {
}
function draw_verbs(cat){
var statcontentdiv = document.getElementById("statcontent");
statcontentdiv[textContentKey] = "";
var table = document.createElement("newdiv");
table.className = "grid-container";
@@ -1013,6 +1041,14 @@ if(!current_tab) {
tab_change("Status");
}
window.onload = function() {
NotifyByondOnload();
};
function NotifyByondOnload() {
window.location.href = "byond://winset?command=Panel-Ready";
}
function create_debug(){
if(!document.getElementById("Debug Stat Panel")) {
addPermanentTab("Debug Stat Panel");