From 91769c265812271e3d44a34dc13c6ad56def2bb0 Mon Sep 17 00:00:00 2001 From: Lucy Date: Sat, 16 Nov 2024 01:30:33 -0500 Subject: [PATCH 1/3] some more basic 516 prep --- code/modules/client/client_procs.dm | 3 + code/modules/photography/photos/photo.dm | 2 +- code/modules/tgui_panel/external.dm | 2 + html/browser/common.css | 3 +- html/statbrowser.css | 10 ++ tgui/packages/common/storage.js | 55 ++++--- tgui/packages/tgui-panel/chat/renderer.jsx | 4 +- tgui/packages/tgui-panel/panelFocus.js | 2 +- tgui/packages/tgui-say/TguiSay.tsx | 12 +- tgui/packages/tgui-say/index.tsx | 20 +-- tgui/packages/tgui-say/styles/button.scss | 7 + tgui/packages/tgui-say/styles/colors.scss | 1 + tgui/packages/tgui/backend.ts | 4 +- .../tgui/components/BodyZoneSelector.tsx | 3 + .../tgui/interfaces/AntagInfoBloodsucker.tsx | 1 + .../tgui/interfaces/ArmamentStation.jsx | 1 + .../tgui/interfaces/CargoImportConsole.jsx | 1 + tgui/packages/tgui/interfaces/FishingRod.tsx | 1 + .../tgui/interfaces/GreyscaleModifyMenu.tsx | 15 +- .../tgui/interfaces/NtosEmojipedia.jsx | 1 + .../tgui/interfaces/NtosPortraitPrinter.jsx | 1 + .../packages/tgui/interfaces/OutfitEditor.jsx | 2 + .../tgui/interfaces/PortraitPicker.jsx | 1 + .../tgui/interfaces/SelectEquipment.jsx | 1 + tgui/packages/tgui/interfaces/StripMenu.tsx | 1 + tgui/packages/tgui/interfaces/Trophycase.jsx | 1 + tgui/packages/tgui/interfaces/Vendatray.tsx | 1 + .../packages/tgui/stories/ByondUi.stories.jsx | 2 +- .../tgui/styles/interfaces/Fishing.scss | 2 + .../tgui/styles/interfaces/NtosMessenger.scss | 2 + .../styles/interfaces/PreferencesMenu.scss | 1 + tgui/packages/tgui/styles/themes/ntos.scss | 5 + .../tgui/styles/themes/syndicate.scss | 5 + tgui/public/tgui.html | 136 ++++++++++-------- 34 files changed, 190 insertions(+), 119 deletions(-) diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 8595f23aa727..4695e236c692 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -224,6 +224,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( /////////// /client/New(TopicData) + if(byond_version >= 516) // Enable 516 compat browser storage mechanisms + winset(src, "", "browser-options=byondstorage,find") + var/tdata = TopicData //save this for later use TopicData = null //Prevent calls to client.Topic from connect diff --git a/code/modules/photography/photos/photo.dm b/code/modules/photography/photos/photo.dm index 94ade197e2f1..e2b8212785ba 100644 --- a/code/modules/photography/photos/photo.dm +++ b/code/modules/photography/photos/photo.dm @@ -92,7 +92,7 @@ user << browse_rsc(picture.picture_image, "tmp_photo.png") user << browse("[name]" \ + "" \ - + "" \ + + "" \ + "[scribble ? "
Written on the back:
[scribble]" : ""]"\ + "", "window=photo_showing;size=480x608") onclose(user, "[name]") diff --git a/code/modules/tgui_panel/external.dm b/code/modules/tgui_panel/external.dm index 3e7dbc3178f2..2cd550d237b3 100644 --- a/code/modules/tgui_panel/external.dm +++ b/code/modules/tgui_panel/external.dm @@ -35,6 +35,8 @@ // Force show the panel to see if there are any errors winset(src, "output", "is-disabled=1&is-visible=0") winset(src, "browseroutput", "is-disabled=0;is-visible=1") + if(byond_version >= 516) + winset(src, null, "browser-options=byondstorage,find") /client/verb/refresh_tgui() set name = "Refresh TGUI" diff --git a/html/browser/common.css b/html/browser/common.css index 6a37b98039e5..43bb7290bbd2 100644 --- a/html/browser/common.css +++ b/html/browser/common.css @@ -11,7 +11,8 @@ body hr { background-color: #40628a; - height: 1px; + height: 2px; + border: 0; } a, button, a:link, a:visited, a:active, .linkOn, .linkOff diff --git a/html/statbrowser.css b/html/statbrowser.css index dc693f42f756..85aebe339c4b 100644 --- a/html/statbrowser.css +++ b/html/statbrowser.css @@ -1,3 +1,8 @@ +.light:root { + --scrollbar-base: #f2f2f2; + --scrollbar-thumb: #a7a7a7; +} + body { font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 12px !important; @@ -7,6 +12,11 @@ body { overflow-y: scroll; } +.dark:root { + --scrollbar-base: #181818; + --scrollbar-thumb: #363636; +} + body.dark { background-color: #131313; color: #b2c4dd; diff --git a/tgui/packages/common/storage.js b/tgui/packages/common/storage.js index acf842f64083..eb8c130ab0f4 100644 --- a/tgui/packages/common/storage.js +++ b/tgui/packages/common/storage.js @@ -7,7 +7,7 @@ */ export const IMPL_MEMORY = 0; -export const IMPL_LOCAL_STORAGE = 1; +export const IMPL_HUB_STORAGE = 1; export const IMPL_INDEXED_DB = 2; const INDEXED_DB_VERSION = 1; @@ -25,14 +25,11 @@ const testGeneric = (testFn) => () => { } }; -// Localstorage can sometimes throw an error, even if DOM storage is not -// disabled in IE11 settings. -// See: https://superuser.com/questions/1080011 -// prettier-ignore -const testLocalStorage = testGeneric(() => ( - window.localStorage && window.localStorage.getItem -)); +const testHubStorage = testGeneric( + () => window.hubStorage && window.hubStorage.getItem, +); +// TODO: Remove with 516 // prettier-ignore const testIndexedDb = testGeneric(() => ( (window.indexedDB || window.msIndexedDB) @@ -45,49 +42,50 @@ class MemoryBackend { this.store = {}; } - get(key) { + async get(key) { return this.store[key]; } - set(key, value) { + async set(key, value) { this.store[key] = value; } - remove(key) { + async remove(key) { this.store[key] = undefined; } - clear() { + async clear() { this.store = {}; } } -class LocalStorageBackend { +class HubStorageBackend { constructor() { - this.impl = IMPL_LOCAL_STORAGE; + this.impl = IMPL_HUB_STORAGE; } - get(key) { - const value = localStorage.getItem(key); + async get(key) { + const value = await window.hubStorage.getItem('paradise-' + key); if (typeof value === 'string') { return JSON.parse(value); } } set(key, value) { - localStorage.setItem(key, JSON.stringify(value)); + window.hubStorage.setItem('paradise-' + key, JSON.stringify(value)); } remove(key) { - localStorage.removeItem(key); + window.hubStorage.removeItem('paradise-' + key); } clear() { - localStorage.clear(); + window.hubStorage.clear(); } } class IndexedDbBackend { + // TODO: Remove with 516 constructor() { this.impl = IMPL_INDEXED_DB; /** @type {Promise} */ @@ -108,7 +106,7 @@ class IndexedDbBackend { }); } - getStore(mode) { + async getStore(mode) { // prettier-ignore return this.dbPromise.then((db) => db .transaction(INDEXED_DB_STORE_NAME, mode) @@ -125,13 +123,6 @@ class IndexedDbBackend { } async set(key, value) { - // The reason we don't _save_ null is because IE 10 does - // not support saving the `null` type in IndexedDB. How - // ironic, given the bug below! - // See: https://github.com/mozilla/localForage/issues/161 - if (value === null) { - value = undefined; - } // NOTE: We deliberately make this operation transactionless const store = await this.getStore(READ_WRITE); store.put(value, key); @@ -157,6 +148,10 @@ class IndexedDbBackend { class StorageProxy { constructor() { this.backendPromise = (async () => { + if (!Byond.TRIDENT && testHubStorage()) { + return new HubStorageBackend(); + } + // TODO: Remove with 516 if (testIndexedDb()) { try { const backend = new IndexedDbBackend(); @@ -164,9 +159,9 @@ class StorageProxy { return backend; } catch {} } - if (testLocalStorage()) { - return new LocalStorageBackend(); - } + console.warn( + 'No supported storage backend found. Using in-memory storage.', + ); return new MemoryBackend(); })(); } diff --git a/tgui/packages/tgui-panel/chat/renderer.jsx b/tgui/packages/tgui-panel/chat/renderer.jsx index 8a9fea109eb4..e23ed85a1102 100644 --- a/tgui/packages/tgui-panel/chat/renderer.jsx +++ b/tgui/packages/tgui-panel/chat/renderer.jsx @@ -163,7 +163,7 @@ class ChatRenderer { // Find scrollable parent this.scrollNode = findNearestScrollableParent(this.rootNode); this.scrollNode.addEventListener('scroll', this.handleScroll); - setImmediate(() => { + setTimeout(() => { this.scrollToBottom(); }); // Flush the queue @@ -473,7 +473,7 @@ class ChatRenderer { this.rootNode.appendChild(fragment); } if (this.scrollTracking) { - setImmediate(() => this.scrollToBottom()); + setTimeout(() => this.scrollToBottom()); } } // Notify listeners that we have processed the batch diff --git a/tgui/packages/tgui-panel/panelFocus.js b/tgui/packages/tgui-panel/panelFocus.js index b7cea2293149..8cff4a361b3e 100644 --- a/tgui/packages/tgui-panel/panelFocus.js +++ b/tgui/packages/tgui-panel/panelFocus.js @@ -15,7 +15,7 @@ import { focusMap } from 'tgui/focus'; // text you can select with the mouse. const MIN_SELECTION_DISTANCE = 10; -const deferredFocusMap = () => setImmediate(() => focusMap()); +const deferredFocusMap = () => setTimeout(() => focusMap()); export const setupPanelFocusHacks = () => { let focusStolen = false; diff --git a/tgui/packages/tgui-say/TguiSay.tsx b/tgui/packages/tgui-say/TguiSay.tsx index 22a51e7de561..7db1cfc8123b 100644 --- a/tgui/packages/tgui-say/TguiSay.tsx +++ b/tgui/packages/tgui-say/TguiSay.tsx @@ -24,6 +24,13 @@ type State = { const CHANNEL_REGEX = /^[:.]\w\s/; +const ROWS: Record = { + small: 1, + medium: 2, + large: 3, + width: 1, // not used +} as const; + export class TguiSay extends Component<{}, State> { private channelIterator: ChannelIterator; private chatHistory: ChatHistory; @@ -325,13 +332,16 @@ export class TguiSay extends Component<{}, State> { type="button" > {this.state.buttonContent} - +