-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactors statpanel to use tgui API #66971
Conversation
https://github.com/tgstation/tgstation/blob/master/.github/guides/STANDARDS.md Make sure it is still possible to use HTML |
mothblocks concurs that unless MSO has a problem with it, utilizing |
(speaking of, @MrStonedOne you should look at this) |
I'm turning it into a draft since it needs some polish. TGUI rule does not apply here since this is a single page HTML with no assets. |
Things I'd like you to address: Instead of using one big Byond.subscribe and a bunch of separate functions, you should turn the callback function into this in-place construct, which makes it clear which functions are the actual functions, and which functions are callbacks to DM messages. Byond.subscribeTo(type, function (payload) {
// do not call an external function here
// but instead handle all logic in place
}); e.g. 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 == "SDQL2")
draw_sdql2();
} This would be better as: Byond.subscribeTo('update_sdql2', function (sdql2) {
if(sdql2.length > 0 && !verb_tabs.includes("SDQL2")) {
verb_tabs.push("SDQL2");
addPermanentTab("SDQL2");
}
if(current_tab == "SDQL2")
draw_sdql2();
}); Notice that you don't need to JSON.parse anything, nor do you need to manually json_encode it in DM, this is because objects that are sent via tgui message protocol are already json encoded, so you're basically json-encoding things twice, and there's no need to do that. What you send as payload is what you get in subscribe. So you need to rework both subscribe functions and json_encode things such as this: target.stat_panel.send_message("update_tickets", list(tickets = json_encode(ahelp_tickets))) You need to move JS to a separate file because it's a lot of code, it messes up git diffs, it will be more convenient that way. Currently I see that You should replace window.onload = function () {
setupSubscribe();
NotifyByondOnload();
};
function NotifyByondOnload() {
Byond.command("Panel-Ready")
} Byond.subscribe() and subscribeTo() are not dependent on the
/client/verb/panel_ready()
set name = "Panel Ready"
set hidden = TRUE
statbrowser_ready = TRUE
init_verbs() Ready check is already implemented as part of tgui and you already used Many statpanel verbs are used as remote functions, they're pretty much all hidden, so instead you can use /client/New()
...
stat_panel.subscribe(src, .proc/on_stat_panel_message)
/client/proc/on_stat_panel_message(type, payload)
... smth like that. |
na, this actually isn't fine. the chat box being tgui only makes it past my requirement because when tgui fails to load the chat box falls back to a byond output control. because of how we did browser stat panels, this can not be done for them. If tgui_panel didn't have the bluescreen stuff, or typescript, or any of the other cancerous "halt and break everything on 1 tiny error because thats what a good and proper:tm: modern:tm: language does" it could be workable for this usecase, but right now this is only gonna increase unreliability when before, on a minor script error, it would still try to keep chugging along. |
We can turn the bluescreen feature off for all panels as part of this PR, so non-issue. Good that you bring this up. 👍
This particular "tgui" doesn't have assets which is the primary reason why UIs can fail to load, so stat panel can't possibly "fail to load". |
The primary reason uis fail to load is because they timeout loading because byond on some computers will randomly take 60 seconds to create the Luckily it seems the html panel system used by tgui chat doesn't have the annoying (but sadly necessary) timeout system, but given that the pieces this interfaces uses exist in mostly plain javascript in the interface, i do want to ensure that react failing to init for any reason doesn't inappropriately block the interface from working. |
That's your assumption, because general tgui windows will appear as white while they're fetching assets, and this means they might be actually running scripts already, you just don't see it. (I wanted to make them show a spinner at some point to distinguish it from just a white screen, but anyway). I can guarantee with 99% probability it's caused by assets being slow or failing to download, which causes a retry (which is also invisible, until a certain point, then it fails with a blue screen).
Aye aye, cap'n! |
^ doesn't help with loading unloadable icons, and causes new bugs |
During Round 183219, I literally could not click any of the tabs to get the following changed (in order to see the contents of that tab). I had died and was revived at this point, so maybe something in relation to having the tabs+verbs available to me? Sometimes as I moved around, the contents of that above screenshot would flash away and actually show me what I wanted to see (the "Status" Panel), but only for a second at most. |
did the tgui log show anything? |
* tgui input hotfix tgstation/tgstation#64698 * changes how tgui handles static data tgstation/tgstation#64757 * tgstation/tgstation#64885 * tgstation/tgstation#65008 * cooldown check * read preferences doenst exist here * tgstation/tgstation#65378 * Adds support for embedding react components in tgui chat * tgstation/tgstation#65686 * tgstation/tgstation#65943 * previous part 2 * oops forgot * tgstation/tgstation#66220 * tgstation/tgstation#66299 * FUCk forgot 1 * tgstation/tgstation#59914 * tgstation/tgstation#66304 * tgstation/tgstation#66309 * tgstation/tgstation#66317 * tgstation/tgstation#66691 * tgstation/tgstation#66757 * small changes from 66933 * tgstation/tgstation#67137 * tgui part of tgstation/tgstation#67691 and tgstation/tgstation#66971 * forgot public html * tgstation/tgstation#67935 prewritepackages * after write packages * tgstation/tgstation#67937 * oops * tgstation/tgstation#68216 * tgstation/tgstation#68356 * tgstation/tgstation#68679 * tgstation/tgstation#68887 * prettier ignore outside * tgstation/tgstation#69219 * tgstation/tgstation#69459 * tgstation/tgstation#69527 * tgstation/tgstation#69735 * tgstation/tgstation#69786 * tgstation/tgstation#70779 * boop * Update code/modules/mob/living/silicon/ai/examine.dm * fix ? * io * yo * prettier * prettier + other stuff + tgui say etc * okay ? * webpack tguisay * ntoswindow * tguialert move * tgui say work ? * tgstation/tgstation#71037 * rollback tguisay * comment out tgui say * remove tguisay dm files * updates tgui folder * whytflinter * rerun * fixes stack trace on fullupdate * woops, removes \n from join() * balloon alert * timeleft shenanigan solve stack_trace * check if fix linter * add it back * woo linter
About The Pull Request
refactors the status panel to utilize the tgui/byond communication APIs instead of passing along href data, as well as converts the entirety of it into a
datum/tgui_window
Why It's Good For The Game
communication between DM and html has never been pretty: utilizing
location.href
to provide a maximum of 2048 characters of string typed data. the stat panel serves as a suitable test subject for this relatively new API