Files
Aurora.3/code/modules/modular_computers/computers/modular_computer/ui.dm
Matt Atlas 31956c7eb0 Rock the UI Away - Removes VueUI and adds TGUI (#16509)
* tgui the beginning

* binaries and the like

* Bring in the last of it

* Example radio UI

* delete example

* NTOS Main Menu, start on manifest, tgui states

* tasks.json

* gunnery ui pt 1

* okay

* fix everything

* scss update

* oops

* manifest gigablast

* downloader part 1

* download prt 2

* NTOSDownloader final

* mfw committing to_worlds

* gunnery console pt2

* i cooked

* targeting (finished)

* one vueui down

* voting ui almost done

* MY MIND FEELS LIKE AN ARCH ENEMYYYY

* voting ui down

* photocopier

* ntos config + download fixes

* photocopier 2

* refactor define

* NTOS client manager + fixes

* fax machine final (it also uses toner now)

* marching forwards... left behind...

* ntnrc part 1

* canister

* add quotes

* portable pumps pt1 + more backgrounds

* oops

* finish the portable pump

* freezers

so I'll keep on pushing forward... you haven't seen the last of me... oooooooh...

* doors ui pt1

* finish doors UI (forgive me wildkins it's a bit of shitcode)

* vitals monitor, make things use labeled lists, new backgrounds

* mais j'envoyé aucun mayday...

* maglock pt1

* pour ça je me suis perdu...

* infrared

* fix that

* prox sensor pt1

* prox sensor

* signaler (this was actually pretty hard)

* atmos control pt1

* atmos control pt1.1

* atmos pt 2

* fuel injector

* multitool UI

* jammer

* list viewer

* APC

* portgen

* targeting console updates + SMES ui

* new themes, shield generator

* supermatter

* Add ore detector and (shitty) NTNet Relay

* orderterminal pt1

* orderterminal pt2

* smartfridge

* Add (air-)tank GUI update ore detector size

* Adds Transfer Valves

* Add AtmoScrubber

* analyzer pt1

* weapons analyzer pt2

* bodyscanner pt1

* bodyscanner pt2

* fix this shitcode

* seed storage

* appearance changer

* appearance changer final

* sleeper pt1

* sleeper

* gps

* vehicles

* chem dispenser

* lily request

* holopad

* tgui modules pt1

* ppanel

* damage menu

* fixes

* im here too now

* follow menu, search bars

* quikpay

* quikpay fixes

* circuit printer

* ppanel

* ppanel updates

* pai

* turret controls (i want to kill myself)

* tweak

* remove the boardgame

* guntracker

* implant tracker

* penal mechs

come close to me, come close to me

* chem codex

* pai radio

* doorjack

* pai directives

* signaler removal, sensors

* ghost spawner

* spawnpoint

* fixes

* teleporter

* one more to the chopping block

* account database

* remove divider

* scanner, atmos

* latejoin ui pt1

* latejoin

* records pt1

* RECORDS UI DONE

* delete interpreter & records

* CHAT FUCKING CLIENT

* data updates

* fix some things

* final UI, log

* basic nanoui fix

* antag panel

* remove vueui

* atm update

* vending update

* warrants, cameras

* ntmonitor

* time comes for all

* preserve this legacy

* bring that back (oops)

* rcon, ui auto update for computer UIs, remove rcon computers

* alarm monitoring (a bit broke and also todo: add custom alarm monitoring programs to a few consoles)

* A LIKE SUPREME

* a

* power monitor

* lights on

* fuck this code, fuck nanoui modules, and fuck nanoui

* LEAVE IT OH SO FAR BEHIND

* fix alarm monitoring for synths

* I SAW IN YOU WHAT LIFE WAS MISSING

* comms console

* idcard and record updates

* turn the light on

* arcade

* pt2

* news browser

* static

* crusher

* f

* COULD I JUST SLEIGH THE GOLD FROM THE BALLS? I'M SO FRUSTRATED OH COULD YOU TELL? IF I HEAR ONE MORE VUEUI OR ONE NANOUI I'M GONNA LOSE IT SO LET ME GOOOOOOOOOOOOOOOOO

* codeowners & suit sensors

* html ui style removal

* make lint happy

* resist and disorder

* i slowly get up and turn off the noise, already fed up...

* pleaseeeeeeeeeeeeeee

* THE CREDIT LARP IS NECESSARY

* i hold the keys

* RISE UP

* fix that?

* harry's suggestions xoxo

* runtime fix pt2

* You are the only thing that I still care about

* adds build workflow

* Update update_tgui.yml

* adds some needed steps

* ATM

* misc fixes and tweaks

* fixes 2

* make newscasters usable and fix use power on freezers

* turret control is clearer

---------

Co-authored-by: John Wildkins <john.wildkins@gmail.com>
Co-authored-by: Matt Atlas <liermattia@gmail.com>
Co-authored-by: harryob <55142896+harryob@users.noreply.github.com>
Co-authored-by: Werner <Arrow768@users.noreply.github.com>
Co-authored-by: Geeves <ggrobler447@gmail.com>
Co-authored-by: harryob <me@harryob.live>
2023-06-25 19:03:33 +02:00

186 lines
5.1 KiB
Plaintext

/obj/item/modular_computer/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(ui && (!screen_on || !enabled || !computer_use_power()))
ui.close()
return
if(!hard_drive || !hard_drive.stored_files || !hard_drive.stored_files.len)
audible_message(SPAN_WARNING("\The [src] beeps three times, its screen displaying, \"DISK ERROR!\"."))
return // No HDD, No HDD files list or no stored files. Something is very broken.
if(!ui)
if(active_program)
ui = new(user, src, active_program.tgui_id, active_program.filedesc)
ui.autoupdate = active_program.ui_auto_update
else
ui = new(user, src, "NTOSMain")
ui.open()
return
var/old_open_ui = ui.interface
if(active_program)
ui.interface = active_program.tgui_id
ui.autoupdate = active_program.ui_auto_update
ui.title = active_program.filedesc
else
ui.interface = "NTOSMain"
if(old_open_ui != ui.interface)
// We've switched UIs!
update_static_data(user, ui)
ui.send_assets()
/obj/item/modular_computer/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/simple/ntos),
)
/obj/item/modular_computer/proc/get_header_data(list/data)
LAZYINITLIST(data)
data["PC_batteryicon"] = get_battery_icon()
data["PC_showbatteryicon"] = !!battery_module
data["PC_batterypercent"] = battery_module ? "[round(battery_module.battery.percent())] %" : "N/C"
data["PC_apclinkicon"] = (tesla_link?.enabled && apc_powered) ? "charging.gif" : ""
data["PC_device_theme"] = active_program ? active_program.tgui_theme : "scc"
data["PC_ntneticon"] = get_ntnet_status_icon()
data["PC_stationtime"] = worldtime2text()
data["PC_stationdate"] = "[time2text(world.realtime, "DDD, Month DD")], [game_year]"
data["PC_showexitprogram"] = !!active_program
data["PC_haslight"] = !!flashlight
data["PC_lighton"] = flashlight?.enabled ? TRUE : FALSE
data["PC_programheaders"] = list()
if(idle_threads.len)
var/list/program_headers = list()
for(var/datum/computer_file/program/P as anything in idle_threads)
if(!P.ui_header)
continue
program_headers.Add(list(list("icon" = P.ui_header)))
data["PC_programheaders"] = program_headers
return data
/obj/item/modular_computer/ui_static_data(mob/user)
var/list/data = ..()
if(active_program)
data += active_program.ui_static_data(user)
return data
return data
/obj/item/modular_computer/ui_data(mob/user)
var/list/data = get_header_data()
if(active_program)
data += active_program.ui_data(user)
return data
var/datum/computer_file/data/autorun = hard_drive.find_file_by_name("autorun")
data["programs"] = list()
data["services"] = list()
for(var/datum/computer_file/program/P in hard_drive.stored_files)
if(P.program_hidden())
continue
data["programs"] += list(list(
"filename" = P.filename,
"desc" = P.filedesc,
"autorun" = istype(autorun) && (autorun.stored_data == P.filename),
"running" = (P in idle_threads)
))
if(P.program_type & PROGRAM_SERVICE)
data["services"] += list(list(
"filename" = P.filename,
"desc" = P.filedesc,
"running" = (P in enabled_services) && (P.service_state > PROGRAM_STATE_KILLED)
))
return data
/obj/item/modular_computer/proc/get_battery_icon()
if(battery_module)
switch(battery_module.battery.percent())
if(80 to 200)
return "batt_100.gif"
if(60 to 80)
return "batt_80.gif"
if(40 to 60)
return "batt_60.gif"
if(20 to 40)
return "batt_40.gif"
if(5 to 20)
return "batt_20.gif"
return "batt_5.gif"
/obj/item/modular_computer/proc/get_ntnet_status_icon()
switch(get_ntnet_status())
if(0)
return "sig_none.gif"
if(1)
return "sig_low.gif"
if(2)
return "sig_high.gif"
if(3)
return "sig_lan.gif"
else
return ""
/obj/item/modular_computer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
if(active_program)
. = active_program.ui_act(action, params, ui, state)
if(action == "PC_exit")
kill_program()
return TRUE
if(action == "PC_toggle_component")
var/obj/item/computer_hardware/H = find_hardware_by_name(params["component"])
if(istype(H))
if(H.enabled)
H.disable()
else
H.enable()
. = TRUE
if(action == "PC_togglelight")
if(flashlight)
flashlight.toggle()
. = TRUE
if(action == "PC_shutdown")
shutdown_computer()
return TRUE
if(action == "PC_minimize")
var/mob/user = usr
if(user)
minimize_program(user)
. = TRUE
if(action == "PC_killprogram")
var/mob/user = usr
var/datum/computer_file/program/P
if(hard_drive)
P = hard_drive.find_file_by_name(params["filename"])
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
return TRUE
if(P.kill_program())
to_chat(user, SPAN_NOTICE("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
. = TRUE
if(action == "PC_runprogram")
run_program(params["filename"], usr)
. = TRUE
if(action == "PC_setautorun")
if(hard_drive)
set_autorun(params["filename"])
. = TRUE
if(action == "PC_register")
if(registered_id)
unregister_account()
else if(GetID())
register_account()
. = TRUE
if(action == "PC_toggleservice")
toggle_service(params["service_to_toggle"], usr)
. = TRUE
update_icon()