Science TGUI & More (#3901)

* Day 1

* Circuits, Bots, UAV

* Fixes

* Cleaning

* Finished Science

* e

* asdasd

* aesfesf

* Fix Medibots (including the bee one)

* Bleh

* Fixes RPD with some code improvements

* RCON Patch

* RCON PATCHES

* Rename popper.tsx to Popper.tsx

* Rename popper.stories.js to Popper.stories.js

* Yarn and Popper Updates

* I am going to shit bricks

* So Tired

* asdas

* Finally fixed tanks

* Radio is fixed

* Fixes Pipes

* RCD SCROLLING!

* Fixes Chat (because everyone uses hybrid???)

* Fixes bugged themes

* habhabahab - Fixes Air Alarm modes

* Fixes Medibot UI and UI Action Buttons

* Fixing say_emphasis missing on NIF messages

* a
This commit is contained in:
Zandario
2022-04-21 01:36:18 -07:00
committed by GitHub
parent 67c14c2bca
commit db6eecce0c
831 changed files with 18078 additions and 14335 deletions
@@ -3,7 +3,6 @@
// Here is where the base definition lives.
// Specific subtypes are in their own folder.
/obj/item/electronic_assembly
name = "electronic assembly"
desc = "It's a case, for building small electronics with."
@@ -46,88 +45,125 @@
if(!draw_power(IC.power_draw_idle))
IC.power_fail()
/obj/item/electronic_assembly/proc/resolve_nano_host()
return src
/obj/item/electronic_assembly/proc/check_interactivity(mob/user)
if(!CanInteract(user, physical_state))
return 0
return 1
return ui_status(user, GLOB.physical_state) == UI_INTERACTIVE
/obj/item/electronic_assembly/get_cell()
return battery
/obj/item/electronic_assembly/interact(mob/user)
if(!check_interactivity(user))
return
// TGUI
/obj/item/electronic_assembly/ui_state(mob/user)
return GLOB.physical_state
/obj/item/electronic_assembly/ui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ICAssembly", name, parent_ui)
ui.open()
/obj/item/electronic_assembly/ui_data(mob/user, datum/tgui/ui, datum/ui_state/state)
var/list/data = ..()
var/total_parts = 0
var/total_complexity = 0
for(var/obj/item/integrated_circuit/part in contents)
total_parts += part.size
total_complexity = total_complexity + part.complexity
var/HTML = list()
HTML += "<html><head><title>[src.name]</title></head><body>"
HTML += "<br><a href='?src=\ref[src]'>\[Refresh\]</a> | "
HTML += "<a href='?src=\ref[src];rename=1'>\[Rename\]</a><br>"
HTML += "[total_parts]/[max_components] ([round((total_parts / max_components) * 100, 0.1)]%) space taken up in the assembly.<br>"
HTML += "[total_complexity]/[max_complexity] ([round((total_complexity / max_complexity) * 100, 0.1)]%) maximum complexity.<br>"
if(battery)
HTML += "[round(battery.charge, 0.1)]/[battery.maxcharge] ([round(battery.percent(), 0.1)]%) cell charge. <a href='?src=\ref[src];remove_cell=1'>\[Remove\]</a><br>"
HTML += "Net energy: [format_SI(net_power / CELLRATE, "W")]."
else
HTML += "<span class='danger'>No powercell detected!</span>"
HTML += "<br><br>"
HTML += "Components:<hr>"
HTML += "Built in:<br>"
data["total_parts"] = total_parts
data["max_components"] = max_components
data["total_complexity"] = total_complexity
data["max_complexity"] = max_complexity
data["battery_charge"] = round(battery?.charge, 0.1)
data["battery_max"] = round(battery?.maxcharge, 0.1)
data["net_power"] = net_power / CELLRATE
//Put removable circuits in separate categories from non-removable
// This works because lists are always passed by reference in BYOND, so modifying unremovable_circuits
// after setting data["unremovable_circuits"] = unremovable_circuits also modifies data["unremovable_circuits"]
// Same for the removable one
var/list/unremovable_circuits = list()
data["unremovable_circuits"] = unremovable_circuits
var/list/removable_circuits = list()
data["removable_circuits"] = removable_circuits
for(var/obj/item/integrated_circuit/circuit in contents)
if(!circuit.removable)
HTML += "<a href=?src=\ref[circuit];examine=1;from_assembly=1>[circuit.displayed_name]</a> | "
HTML += "<a href=?src=\ref[circuit];rename=1;from_assembly=1>\[Rename\]</a> | "
HTML += "<a href=?src=\ref[circuit];scan=1;from_assembly=1>\[Scan with Debugger\]</a> | "
HTML += "<a href=?src=\ref[circuit];bottom=\ref[circuit];from_assembly=1>\[Move to Bottom\]</a>"
HTML += "<br>"
var/list/target = circuit.removable ? removable_circuits : unremovable_circuits
target.Add(list(list(
"name" = circuit.displayed_name,
"ref" = REF(circuit),
)))
HTML += "<hr>"
HTML += "Removable:<br>"
return data
for(var/obj/item/integrated_circuit/circuit in contents)
if(circuit.removable)
HTML += "<a href=?src=\ref[circuit];examine=1;from_assembly=1>[circuit.displayed_name]</a> | "
HTML += "<a href=?src=\ref[circuit];rename=1;from_assembly=1>\[Rename\]</a> | "
HTML += "<a href=?src=\ref[circuit];scan=1;from_assembly=1>\[Scan with Debugger\]</a> | "
HTML += "<a href=?src=\ref[circuit];remove=1;from_assembly=1>\[Remove\]</a> | "
HTML += "<a href=?src=\ref[circuit];bottom=\ref[circuit];from_assembly=1>\[Move to Bottom\]</a>"
HTML += "<br>"
HTML += "</body></html>"
user << browse(jointext(HTML,null), "window=assembly-\ref[src];size=600x350;border=1;can_resize=1;can_close=1;can_minimize=1")
/obj/item/electronic_assembly/Topic(href, href_list[])
/obj/item/electronic_assembly/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return 1
return TRUE
if(href_list["rename"])
rename(usr)
var/obj/held_item = usr.get_active_hand()
if(href_list["remove_cell"])
if(!battery)
to_chat(usr, "<span class='warning'>There's no power cell to remove from \the [src].</span>")
else
switch(action)
//Actual assembly actions
if("rename")
rename(usr)
return TRUE
if("remove_cell")
if(!battery)
to_chat(usr, SPAN_WARNING("There's no power cell to remove from \the [src]."))
return FALSE
var/turf/T = get_turf(src)
battery.forceMove(T)
playsound(T, 'sound/items/Crowbar.ogg', 50, 1)
to_chat(usr, "<span class='notice'>You pull \the [battery] out of \the [src]'s power supplier.</span>")
playsound(T, 'sound/items/Crowbar.ogg', 50, TRUE)
to_chat(usr, SPAN_NOTICE("You pull \the [battery] out of \the [src]'s power supplier."))
battery = null
return TRUE
interact(usr) // To refresh the UI.
// Circuit actions
if("open_circuit")
var/obj/item/integrated_circuit/C = locate(params["ref"]) in contents
if(!istype(C))
return
C.ui_interact(usr, null, ui)
return TRUE
if("rename_circuit")
var/obj/item/integrated_circuit/C = locate(params["ref"]) in contents
if(!istype(C))
return
C.rename_component(usr)
return TRUE
if("scan_circuit")
var/obj/item/integrated_circuit/C = locate(params["ref"]) in contents
if(!istype(C))
return
if(istype(held_item, /obj/item/integrated_electronics/debugger))
var/obj/item/integrated_electronics/debugger/D = held_item
if(D.accepting_refs)
D.afterattack(C, usr, TRUE)
else
to_chat(usr, SPAN_WARNING("The Debugger's 'ref scanner' needs to be on."))
else
to_chat(usr, SPAN_WARNING("You need a multitool/debugger set to 'ref' mode to do that."))
return TRUE
if("remove_circuit")
var/obj/item/integrated_circuit/C = locate(params["ref"]) in contents
if(!istype(C))
return
C.remove(usr)
return TRUE
if("bottom_circuit")
var/obj/item/integrated_circuit/C = locate(params["ref"]) in contents
if(!istype(C))
return
// Puts it at the bottom of our contents
// Note, this intentionally does *not* use forceMove, because forceMove will stop if it detects the same loc
C.loc = null
C.loc = src
return FALSE
// End TGUI
/obj/item/electronic_assembly/verb/rename()
set name = "Rename Circuit"
@@ -140,7 +176,7 @@
var/input = sanitizeSafe(input("What do you want to name this?", "Rename", src.name) as null|text, MAX_NAME_LEN)
if(src && input)
to_chat(M, "<span class='notice'>The machine now has a label reading '[input]'.</span>")
to_chat(M, SPAN_NOTICE("The machine now has a label reading '[input]'."))
name = input
/obj/item/electronic_assembly/proc/can_move()
@@ -173,10 +209,11 @@
/obj/item/electronic_assembly/examine(mob/user)
. = ..()
for(var/obj/item/integrated_circuit/IC in contents)
IC.external_examine(user)
if(opened)
interact(user)
if(Adjacent(user))
for(var/obj/item/integrated_circuit/IC in contents)
. += IC.external_examine(user)
if(opened)
ui_interact(user)
/obj/item/electronic_assembly/proc/get_part_complexity()
. = 0
@@ -191,21 +228,21 @@
// Returns true if the circuit made it inside.
/obj/item/electronic_assembly/proc/add_circuit(var/obj/item/integrated_circuit/IC, var/mob/user)
if(!opened)
to_chat(user, "<span class='warning'>\The [src] isn't opened, so you can't put anything inside. Try using a crowbar.</span>")
to_chat(user, SPAN_WARNING("\The [src] isn't opened, so you can't put anything inside. Try using a crowbar."))
return FALSE
if(IC.w_class > src.w_class)
to_chat(user, "<span class='warning'>\The [IC] is way too big to fit into \the [src].</span>")
to_chat(user, SPAN_WARNING("\The [IC] is way too big to fit into \the [src]."))
return FALSE
var/total_part_size = get_part_size()
var/total_complexity = get_part_complexity()
if((total_part_size + IC.size) > max_components)
to_chat(user, "<span class='warning'>You can't seem to add the '[IC.name]', as there's insufficient space.</span>")
to_chat(user, SPAN_WARNING("You can't seem to add the '[IC.name]', as there's insufficient space."))
return FALSE
if((total_complexity + IC.complexity) > max_complexity)
to_chat(user, "<span class='warning'>You can't seem to add the '[IC.name]', since this setup's too complicated for the case.</span>")
to_chat(user, SPAN_WARNING("You can't seem to add the '[IC.name]', since this setup's too complicated for the case."))
return FALSE
if(!IC.forceMove(src))
@@ -229,12 +266,12 @@
if(S.scan(target))
scanned = TRUE
if(scanned)
visible_message("<span class='notice'>\The [user] waves \the [src] around [target].</span>")
visible_message(SPAN_NOTICE("\The [user] waves \the [src] around [target]."))
/obj/item/electronic_assembly/attackby(var/obj/item/I, var/mob/user)
if(can_anchor && I.is_wrench())
anchored = !anchored
to_chat(user, span("notice", "You've [anchored ? "" : "un"]secured \the [src] to \the [get_turf(src)]."))
to_chat(user, SPAN_NOTICE("You've [anchored ? "" : "un"]secured \the [src] to \the [get_turf(src)]."))
if(anchored)
on_anchored()
else
@@ -246,24 +283,23 @@
if(!user.unEquip(I) && !istype(user, /mob/living/silicon/robot)) //Robots cannot de-equip items in grippers.
return FALSE
if(add_circuit(I, user))
to_chat(user, "<span class='notice'>You slide \the [I] inside \the [src].</span>")
to_chat(user, SPAN_NOTICE("You slide \the [I] inside \the [src]."))
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
interact(user)
ui_interact(user)
return TRUE
else if(I.is_crowbar())
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
opened = !opened
to_chat(user, "<span class='notice'>You [opened ? "opened" : "closed"] \the [src].</span>")
to_chat(user, SPAN_NOTICE("You [opened ? "opened" : "closed"] \the [src]."))
update_icon()
return TRUE
else if(istype(I, /obj/item/integrated_electronics/wirer) || istype(I, /obj/item/integrated_electronics/debugger) || I.is_screwdriver())
if(opened)
interact(user)
ui_interact(user)
else
to_chat(user, "<span class='warning'>\The [src] isn't opened, so you can't fiddle with the internal components. \
Try using a crowbar.</span>")
to_chat(user, SPAN_WARNING("\The [src] isn't opened, so you can't fiddle with the internal components. Try using a crowbar."))
else if(istype(I, /obj/item/integrated_electronics/detailer))
var/obj/item/integrated_electronics/detailer/D = I
@@ -272,20 +308,19 @@
else if(istype(I, /obj/item/cell/device))
if(!opened)
to_chat(user, "<span class='warning'>\The [src] isn't opened, so you can't put anything inside. Try using a crowbar.</span>")
to_chat(user, SPAN_WARNING("\The [src] isn't opened, so you can't put anything inside. Try using a crowbar."))
return FALSE
if(battery)
to_chat(user, "<span class='warning'>\The [src] already has \a [battery] inside. Remove it first if you want to replace it.</span>")
to_chat(user, SPAN_WARNING("\The [src] already has \a [battery] inside. Remove it first if you want to replace it."))
return FALSE
var/obj/item/cell/device/cell = I
user.drop_item(cell)
cell.forceMove(src)
battery = cell
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
to_chat(user, "<span class='notice'>You slot \the [cell] inside \the [src]'s power supplier.</span>")
interact(user)
to_chat(user, SPAN_NOTICE("You slot \the [cell] inside \the [src]'s power supplier."))
ui_interact(user)
return TRUE
else
return ..()
@@ -293,7 +328,7 @@
if(!check_interactivity(user))
return
if(opened)
interact(user)
ui_interact(user)
var/list/input_selection = list()
var/list/available_inputs = list()