mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-31 20:53:34 +00:00
* [TGUI v6 Project] Remove `context` (#29086)
* [TGUI v6 Project] Remove `context`
* I forgot I had to do that.
* [TGUI v6 Project] Move to React (#29090)
* It compiles
* Last Inferno uses
* all works now
* Fixes
* [TGUI v6] Changes files extensions for interfaces from .js to .jsx, Deprecates Inferno State Hooks (#29094)
* Initial Commit
* Apply suggestions from code review
trust me bro
Co-authored-by: Aylong <69762909+AyIong@users.noreply.github.com>
Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>
---------
Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Aylong <69762909+AyIong@users.noreply.github.com>
* [TGUI v6] Replaces babel with swc, fixes realtive paths on a few files, new build (#29100)
* Initial commit
* Build
* webpack config and errors and rebuild
* export routingError, hopefully
* fix pda app routing
* pass current tab index to tab headers and content in nanobank
---------
Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
* fix dna modifier bluescreen and library computer tabs (#29108)
* TGUI parity with TG
Need to fix a bunch of things...
* Implement TGUI payload chunking backend
https://github.com/tgstation/tgstation/pull/90295
* Filx chan bottom scroll. Again
* Fix TGchat focus
* Fix rounding
* Fix inputs
* Upgrade deps
* More fixes
* Fix chat lineHeight
* Fix NanoMap
* Update `tgui-core`
* fix autolathe
* fix airlock electronics
* fix intercom
* fix compost bin height
* Fix chat preferences
* Move to TSX without types :clueless:
* test tiny meet your new brother test tgui
* Fix RCD
* fix stackcraft
* fix up beakercontents
* Fix MODsuits
* fix seed extractor
* Merge branch 'tgui-v6' of github.com:ParadiseSS13/Paradise into tgui-v6
* fix holodeck
* fix cookbook pda app
* fix remaining useState args
* Fix DNAModifier
* Fix Sleeper
* Fix SupermatterMonitor
* Remove `vitest`
* Update dev-server
* Fix `IconStack`
* Correct margin
* bundles, please don't break
* prettier
* Revert "Remove `vitest`"
This reverts commit 0609006abb.
* Re-add tests
* Prettier
* fix maplint for test_tgui
* TGchat shine effect
* TGUI Rebuildo
* Fix broken tabs, search boxes, sortable tables, and others (#29450)
* Replace KitchenSink theme state with a React context
* Remove last usage of useLocalState
* Rebind unbound useState calls
* Build and update /tg/ui
* Reformat /tg/ui
* [ci skip]
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
* Ports #29217 to tgui v6. Added tgui-setup to CI builds (#29787)
* Add tgui-setup to build scripts
* Fix CORS issue
* Build and update /tg/ui
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
* Add one missing word to comment
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix law manager
* Removes dangling references to `context` (#29793)
* Removes dangling references to `context`
* Build and update /tg/ui (#25)
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix messenger and atmos scanner
* swap out line break in examinate
* fix powermonitor
* Bump tgui-core from 3.1.5/3.1.4 to 4.3.4 (#29799)
* Bump tgui-core
* Build and update /tg/ui (#28)
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fixes additional examine text
* oopsie
* Small tgui v6 fixes (#29801)
* Remove flow
* Miscellaneous fixes
* Miscellaneous fixes
* Moved properties placed on the wrong element
* Migrate removed CSS attributes in JSX
* Build and update /tg/ui (#27)
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix carbon examine
* fix robot examine
* fix lint
* improve SMES appearance
* fix camera console name order
* more newline fixes
* fix boolean modal cancel not working
* fix random disabled access in RCD
* point tgui to correct passthrough verb names
* Fix missing 0 option for ERTs. (#29819)
* fix newlines in damage flavor
* Revert all changes related to newlines in DM
* fix the actual thing that was wrong with newlines
* fix ERT manager deny input
* [tgui-v6] Makes Agent Card UI more aesthethic, fixes input fields, fixes minimum age slider (#29832)
* agent card fixes and tweaks
* tgui bundle
* Reformat /tg/ui (#33) (#29838)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* restore camera console list appearance
* fixed pai ui paths (#29867)
* /tg/ui fixes no. 3 (#29868)
* Remove IconStack styles that conflict with styles added in tgstation/tgui-core#203
* Fix minesweeper icon
* DNA Modifier fixes
* Fix alignment of icons in PDA games menu
* Expand chem dispenser
* Fix pAI interfaces
* Build and update /tg/ui
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Toastical <20125180+Toastical@users.noreply.github.com>
* teleporter fix, bundle changes, test
* /tg/ui fixes no.4 (#29877)
* Fix translucent buttons
* Remove stories already present in tgui-core
* Make voting choices not transparent
* Build and update /tg/ui
* Fix size of set ringtone in PDA messenger
* Fix crew monitor highlight colors
* Fix ReagentsEditor search. Small style fixes
* tgui-say radio prefix has special color again
* Expand chameleon mask a little
* Fix search in chameleon mask
* Make list input modal slightly taller
* [ci skip]
* Build /tg/ui
---------
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
---------
Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Aylong <69762909+AyIong@users.noreply.github.com>
Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: Aylong <alexanderkitsa@gmail.com>
Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com>
Co-authored-by: Arthri <41360489+a@users.noreply.github.com>
Co-authored-by: /tg/ui Builder <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: Toastical <20125180+Toastical@users.noreply.github.com>
374 lines
10 KiB
Plaintext
374 lines
10 KiB
Plaintext
/**
|
|
* tgui subsystem
|
|
*
|
|
* Contains all tgui state and subsystem code.
|
|
*
|
|
* Copyright (c) 2020 Aleksej Komarov
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
SUBSYSTEM_DEF(tgui)
|
|
name = "tgui"
|
|
wait = 9
|
|
flags = SS_NO_INIT
|
|
priority = FIRE_PRIORITY_TGUI
|
|
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
|
|
|
|
/// A list of UIs scheduled to process
|
|
var/list/current_run = list()
|
|
/// A list of open UIs
|
|
var/list/open_uis = list()
|
|
/// A list of open UIs, grouped by src_object.
|
|
var/list/open_uis_by_src = list()
|
|
/// The HTML base used for all UIs.
|
|
var/basehtml
|
|
|
|
/datum/controller/subsystem/tgui/PreInit()
|
|
basehtml = file2text('tgui/public/tgui.html')
|
|
|
|
// Inject inline helper functions
|
|
var/helpers = file2text('tgui/public/helpers.min.js')
|
|
helpers = "<script type='text/javascript'>\n[helpers]\n</script>"
|
|
basehtml = replacetextEx(basehtml, "<!-- tgui:helpers -->", helpers)
|
|
|
|
// Inject inline ntos-error styles
|
|
var/ntos_error = file2text('tgui/public/ntos-error.min.css')
|
|
ntos_error = "<style type='text/css'>\n[ntos_error]\n</style>"
|
|
basehtml = replacetextEx(basehtml, "<!-- tgui:ntos-error -->", ntos_error)
|
|
|
|
/datum/controller/subsystem/tgui/can_vv_get(var_name)
|
|
if(var_name == "basehtml")
|
|
return FALSE // No security implication here, it just spams the fuck out of the UI
|
|
|
|
return ..()
|
|
|
|
|
|
/datum/controller/subsystem/tgui/Shutdown()
|
|
close_all_uis()
|
|
|
|
/datum/controller/subsystem/tgui/stat_entry(msg)
|
|
msg = "P:[length(open_uis)]"
|
|
return ..()
|
|
|
|
/datum/controller/subsystem/tgui/fire(resumed = FALSE)
|
|
if(!resumed)
|
|
src.current_run = open_uis.Copy()
|
|
// Cache for sanic speed (lists are references anyways)
|
|
var/list/current_run = src.current_run
|
|
while(length(current_run))
|
|
var/datum/tgui/ui = current_run[length(current_run)]
|
|
current_run.len--
|
|
// TODO: Move user/src_object check to process()
|
|
if(ui && ui.user && ui.src_object)
|
|
ui.process()
|
|
else
|
|
open_uis.Remove(ui)
|
|
if(MC_TICK_CHECK)
|
|
return
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Requests a usable tgui window from the pool.
|
|
* Returns null if pool was exhausted.
|
|
*
|
|
* required user mob
|
|
* return datum/tgui
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/request_pooled_window(mob/user)
|
|
if(!user.client)
|
|
return
|
|
var/list/windows = user.client.tgui_windows
|
|
var/window_id
|
|
var/datum/tgui_window/window
|
|
var/window_found = FALSE
|
|
// Find a usable window
|
|
for(var/i in 1 to TGUI_WINDOW_HARD_LIMIT)
|
|
window_id = TGUI_WINDOW_ID(i)
|
|
window = windows[window_id]
|
|
// As we are looping, create missing window datums
|
|
if(!window)
|
|
window = new(user.client, window_id, pooled = TRUE)
|
|
// Skip windows with acquired locks
|
|
if(window.locked)
|
|
continue
|
|
if(window.status == TGUI_WINDOW_READY)
|
|
return window
|
|
if(window.status == TGUI_WINDOW_CLOSED)
|
|
window.status = TGUI_WINDOW_LOADING
|
|
window_found = TRUE
|
|
break
|
|
if(!window_found)
|
|
log_tgui(user, "Error: Pool exhausted")
|
|
return
|
|
return window
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Force closes all tgui windows.
|
|
*
|
|
* required user mob
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/force_close_all_windows(mob/user)
|
|
log_tgui(user, "force_close_all_windows")
|
|
if(user.client)
|
|
user.client.tgui_windows = list()
|
|
for(var/i in 1 to TGUI_WINDOW_HARD_LIMIT)
|
|
var/window_id = TGUI_WINDOW_ID(i)
|
|
user << browse(null, "window=[window_id]")
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Force closes the tgui window by window_id.
|
|
*
|
|
* required user mob
|
|
* required window_id string
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/force_close_window(mob/user, window_id)
|
|
log_tgui(user, "force_close_window")
|
|
// Close all tgui datums based on window_id.
|
|
for(var/datum/tgui/ui in user.tgui_open_uis)
|
|
if(ui.window && ui.window.id == window_id)
|
|
ui.close(can_be_suspended = FALSE)
|
|
// Unset machine just to be sure.
|
|
user.unset_machine()
|
|
// Close window directly just to be sure.
|
|
user << browse(null, "window=[window_id]")
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Try to find an instance of a UI, and push an update to it.
|
|
*
|
|
* required user mob The mob who opened/is using the UI.
|
|
* required src_object datum The object/datum which owns the UI.
|
|
* optional ui datum/tgui The UI to be updated, if it exists.
|
|
* optional force_open bool If the UI should be re-opened instead of updated.
|
|
*
|
|
* return datum/tgui The found UI.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/try_update_ui(mob/user, datum/src_object, datum/tgui/ui, force_open = FALSE)
|
|
// Look up a UI if it wasn't passed
|
|
if(isnull(ui))
|
|
ui = get_open_ui(user, src_object)
|
|
// Couldn't find a UI.
|
|
if(isnull(ui))
|
|
return
|
|
var/data = src_object.ui_data(user) // Get data from the src_object.
|
|
if(force_open) // UI is already open; update it.
|
|
ui.send_full_update(data, TRUE)
|
|
return ui // We found the UI, return it
|
|
ui.process_status()
|
|
// UI ended up with the closed status
|
|
// or is actively trying to close itself.
|
|
// FIXME: Doesn't actually fix the paper bug.
|
|
if(ui.status <= UI_CLOSE)
|
|
ui.close()
|
|
return
|
|
ui.send_update()
|
|
return ui
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Get a open UI given a user and src_object.
|
|
*
|
|
* required user mob The mob who opened/is using the UI.
|
|
* required src_object datum The object/datum which owns the UI.
|
|
*
|
|
* return datum/tgui The found UI.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/get_open_ui(mob/user, datum/src_object)
|
|
var/key = "[src_object.UID()]"
|
|
// No UIs opened for this src_object
|
|
if(isnull(open_uis_by_src[key]) || !islist(open_uis_by_src[key]))
|
|
return
|
|
for(var/datum/tgui/ui in open_uis_by_src[key])
|
|
// Make sure we have the right user
|
|
if(ui.user == user)
|
|
return ui
|
|
return
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Update all UIs attached to src_object.
|
|
*
|
|
* required src_object datum The object/datum which owns the UIs.
|
|
*
|
|
* return int The number of UIs updated.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/update_uis(datum/src_object, full_update = FALSE)
|
|
var/count = 0
|
|
var/key = "[src_object.UID()]"
|
|
// No UIs opened for this src_object
|
|
if(isnull(open_uis_by_src[key]) || !islist(open_uis_by_src[key]))
|
|
return count
|
|
for(var/datum/tgui/ui in open_uis_by_src[key])
|
|
// Check if UI is valid.
|
|
if(ui && ui.src_object && ui.user && ui.src_object.ui_host(ui.user))
|
|
if(full_update)
|
|
ui.send_full_update(null, TRUE)
|
|
else
|
|
ui.process(force = TRUE)
|
|
count++
|
|
return count
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Close all UIs attached to src_object.
|
|
*
|
|
* required src_object datum The object/datum which owns the UIs.
|
|
*
|
|
* return int The number of UIs closed.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/close_uis(datum/src_object)
|
|
. = 0
|
|
var/key = "[src_object.UID()]"
|
|
// No UIs opened for this src_object
|
|
if(isnull(open_uis_by_src[key]) || !islist(open_uis_by_src[key]))
|
|
return
|
|
for(var/datum/tgui/ui in open_uis_by_src[key])
|
|
// Check if UI is valid.
|
|
if(ui && ui.src_object && ui.user && ui.src_object.ui_host(ui.user))
|
|
ui.close()
|
|
.++
|
|
return
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Close all UIs regardless of their attachment to src_object.
|
|
*
|
|
* return int The number of UIs closed.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/close_all_uis()
|
|
var/count = 0
|
|
for(var/key in open_uis_by_src)
|
|
for(var/datum/tgui/ui in open_uis_by_src[key])
|
|
// Check if UI is valid.
|
|
if(ui && ui.src_object && ui.user && ui.src_object.ui_host(ui.user))
|
|
ui.close()
|
|
count++
|
|
return count
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Update all UIs belonging to a user.
|
|
*
|
|
* required user mob The mob who opened/is using the UI.
|
|
* optional src_object datum If provided, only update UIs belonging this src_object.
|
|
*
|
|
* return int The number of UIs updated.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/update_user_uis(mob/user, datum/src_object)
|
|
var/count = 0
|
|
if(length(user?.tgui_open_uis) == 0)
|
|
return count
|
|
for(var/datum/tgui/ui in user.tgui_open_uis)
|
|
if(isnull(src_object) || ui.src_object == src_object)
|
|
ui.process(force = TRUE)
|
|
count++
|
|
return count
|
|
|
|
/**
|
|
* public
|
|
*
|
|
* Close all UIs belonging to a user.
|
|
*
|
|
* required user mob The mob who opened/is using the UI.
|
|
* optional src_object datum If provided, only close UIs belonging this src_object.
|
|
*
|
|
* return int The number of UIs closed.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/close_user_uis(mob/user, datum/src_object)
|
|
var/count = 0
|
|
if(length(user?.tgui_open_uis) == 0)
|
|
return count
|
|
for(var/datum/tgui/ui in user.tgui_open_uis)
|
|
if(isnull(src_object) || ui.src_object == src_object)
|
|
ui.close()
|
|
count++
|
|
return count
|
|
|
|
/**
|
|
* private
|
|
*
|
|
* Add a UI to the list of open UIs.
|
|
*
|
|
* required ui datum/tgui The UI to be added.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/on_open(datum/tgui/ui)
|
|
var/key = "[ui.src_object.UID()]"
|
|
if(isnull(open_uis_by_src[key]) || !islist(open_uis_by_src[key]))
|
|
open_uis_by_src[key] = list()
|
|
ui.user.tgui_open_uis |= ui
|
|
var/list/uis = open_uis_by_src[key]
|
|
uis |= ui
|
|
open_uis |= ui
|
|
|
|
/**
|
|
* private
|
|
*
|
|
* Remove a UI from the list of open UIs.
|
|
*
|
|
* required ui datum/tgui The UI to be removed.
|
|
*
|
|
* return bool If the UI was removed or not.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/on_close(datum/tgui/ui)
|
|
var/key = "[ui.src_object.UID()]"
|
|
if(isnull(open_uis_by_src[key]) || !islist(open_uis_by_src[key]))
|
|
return FALSE
|
|
// Remove it from the list of processing UIs.
|
|
open_uis.Remove(ui)
|
|
// If the user exists, remove it from them too.
|
|
if(ui.user)
|
|
ui.user.tgui_open_uis.Remove(ui)
|
|
var/list/uis = open_uis_by_src[key]
|
|
uis.Remove(ui)
|
|
if(length(uis) == 0)
|
|
open_uis_by_src.Remove(key)
|
|
return TRUE
|
|
|
|
/**
|
|
* private
|
|
*
|
|
* Handle client logout, by closing all their UIs.
|
|
*
|
|
* required user mob The mob which logged out.
|
|
*
|
|
* return int The number of UIs closed.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/on_logout(mob/user)
|
|
close_user_uis(user)
|
|
|
|
/**
|
|
* private
|
|
*
|
|
* Handle clients switching mobs, by transferring their UIs.
|
|
*
|
|
* required user source The client's original mob.
|
|
* required user target The client's new mob.
|
|
*
|
|
* return bool If the UIs were transferred.
|
|
*/
|
|
/datum/controller/subsystem/tgui/proc/on_transfer(mob/source, mob/target)
|
|
// The old mob had no open UIs.
|
|
if(length(source?.tgui_open_uis) == 0)
|
|
return FALSE
|
|
if(isnull(target.tgui_open_uis) || !istype(target.tgui_open_uis, /list))
|
|
target.tgui_open_uis = list()
|
|
// Transfer all the UIs.
|
|
for(var/datum/tgui/ui in source.tgui_open_uis)
|
|
// Inform the UIs of their new owner.
|
|
ui.user = target
|
|
target.tgui_open_uis.Add(ui)
|
|
// Clear the old list.
|
|
source.tgui_open_uis.Cut()
|
|
return TRUE
|