diff --git a/code/__DEFINES/wiremod.dm b/code/__DEFINES/wiremod.dm index 421650e3bf1..b606f938869 100644 --- a/code/__DEFINES/wiremod.dm +++ b/code/__DEFINES/wiremod.dm @@ -123,6 +123,8 @@ #define CIRCUIT_FLAG_REFUSE_MODULE (1<<5) /// This circuit component cannot be inserted into the same circuit multiple times. Only use this for major headaches. #define CIRCUIT_NO_DUPLICATES (1<<6) +/// This circuit component is currently disabled via configs +#define CIRCUIT_FLAG_DISABLED (1<<7) // Datatype flags /// The datatype supports manual inputs diff --git a/code/modules/wiremod/components/action/soundemitter.dm b/code/modules/wiremod/components/action/soundemitter.dm index 676ce874438..144a56295dd 100644 --- a/code/modules/wiremod/components/action/soundemitter.dm +++ b/code/modules/wiremod/components/action/soundemitter.dm @@ -33,11 +33,19 @@ var/list/options_map +/obj/item/circuit_component/soundemitter/Initialize(mapload) + if(CONFIG_GET(flag/disallow_circuit_sounds)) + update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED) + . = ..() + /obj/item/circuit_component/soundemitter/get_ui_notices() . = ..() . += create_ui_notice("Sound Cooldown: [DisplayTimeText(sound_cooldown)]", "orange", "stopwatch") if(CONFIG_GET(flag/disallow_circuit_sounds)) . += create_ui_notice("Non-functional", "red", "exclamation") + update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED) + else + update_ui_alerts(remove_flag=CIRCUIT_FLAG_DISABLED) /obj/item/circuit_component/soundemitter/populate_ports() @@ -79,10 +87,11 @@ /obj/item/circuit_component/soundemitter/input_received(datum/port/input/port) if(CONFIG_GET(flag/disallow_circuit_sounds)) - ui_color = "red" + // Without constantly checking the config 24/7 or sending a signal to every circuit, best we can do to update existing emitters is this. + update_ui_alerts(new_flag=CIRCUIT_FLAG_DISABLED) return else - ui_color = initial(ui_color) + update_ui_alerts(remove_flag=CIRCUIT_FLAG_DISABLED) if(!parent.shell) return diff --git a/code/modules/wiremod/core/component.dm b/code/modules/wiremod/core/component.dm index 07f3a5b55a3..7dda865fb64 100644 --- a/code/modules/wiremod/core/component.dm +++ b/code/modules/wiremod/core/component.dm @@ -64,6 +64,10 @@ /// The UI buttons of this circuit component. An assoc list that has this format: "button_icon" = "action_name" var/ui_buttons = null + /// The "important" UI tooltips of this circuit component. Used for important things like instant & disabled circuits, they're drawn next to the default tooltip icon. + /// An assoc list with the format ui_alerts["alert_icon"] = "alert_name". + var/ui_alerts = list() + /// Called when the option ports should be set up /obj/item/circuit_component/proc/populate_options() return @@ -86,8 +90,7 @@ trigger_input = add_input_port("Trigger", PORT_TYPE_SIGNAL, order = 2) if((circuit_flags & CIRCUIT_FLAG_OUTPUT_SIGNAL) && !trigger_output) trigger_output = add_output_port("Triggered", PORT_TYPE_SIGNAL, order = 2) - if(circuit_flags & CIRCUIT_FLAG_INSTANT) - ui_color = "orange" + update_ui_alerts() /obj/item/circuit_component/Destroy() if(parent) @@ -113,6 +116,21 @@ if(circuit_flags & CIRCUIT_FLAG_REFUSE_MODULE) . += span_notice("It's incompatible with module components.") +/// updates the ui alerts in the given component. new_flag adds flags, remove_flag removes them +/obj/item/circuit_component/proc/update_ui_alerts(new_flag, remove_flag) + if(new_flag) + circuit_flags |= new_flag + if(remove_flag) + circuit_flags &= ~remove_flag + if(circuit_flags & CIRCUIT_FLAG_INSTANT) + ui_alerts["tachometer-alt"] = "Instant" + else + ui_alerts -= "tachometer-alt" + if(circuit_flags & CIRCUIT_FLAG_DISABLED) + ui_alerts["exclamation"] = "Non-functional" + else + ui_alerts -= "exclamation" + /** * Called when a shell is registered from the component/the component is added to a circuit. * diff --git a/code/modules/wiremod/core/integrated_circuit.dm b/code/modules/wiremod/core/integrated_circuit.dm index 1023a59eb21..dfaef0abcaa 100644 --- a/code/modules/wiremod/core/integrated_circuit.dm +++ b/code/modules/wiremod/core/integrated_circuit.dm @@ -380,6 +380,8 @@ GLOBAL_LIST_EMPTY_TYPED(integrated_circuits, /obj/item/integrated_circuit) component_data["y"] = component.rel_y component_data["removable"] = component.removable component_data["color"] = component.ui_color + component_data["category"] = component.category + component_data["ui_alerts"] = component.ui_alerts component_data["ui_buttons"] = component.ui_buttons .["components"] += list(component_data) diff --git a/tgui/packages/tgui/interfaces/IntegratedCircuit/DisplayComponent.jsx b/tgui/packages/tgui/interfaces/IntegratedCircuit/DisplayComponent.jsx index b0251a09e64..23269cd1567 100644 --- a/tgui/packages/tgui/interfaces/IntegratedCircuit/DisplayComponent.jsx +++ b/tgui/packages/tgui/interfaces/IntegratedCircuit/DisplayComponent.jsx @@ -1,5 +1,6 @@ import { Component, createRef } from 'react'; import { Box, Button, Stack } from 'tgui-core/components'; +import { classes } from 'tgui-core/react'; import { noop } from './constants'; import { Port } from './Port'; @@ -39,24 +40,35 @@ export class DisplayComponent extends Component { render() { const { component, fixedSize, ...rest } = this.props; + const categoryClass = `ObjectComponent__Category__${component.category || 'Unassigned'}`; return (
{component.name} + {!!component.ui_alerts && + Object.keys(component.ui_alerts).map((icon) => ( + +