From 1464f5ec56f832b271e2f26cfe39698a3354f8e6 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:11:49 +0200 Subject: [PATCH] [MIRROR] Added further limitations on the sound emitter circuit component [MDB IGNORE] (#14401) * Added further limitations on the sound emitter circuit component (#67540) Added limitations on the sound emitter component Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * Added further limitations on the sound emitter circuit component Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> --- .../configuration/entries/game_options.dm | 1 + .../wiremod/components/action/soundemitter.dm | 30 ++++- code/modules/wiremod/core/admin_panel.dm | 7 + config/game_options.txt | 3 + .../tgui/interfaces/CircuitAdminPanel.tsx | 122 ++++++++++-------- 5 files changed, 108 insertions(+), 55 deletions(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 529dff4ad24..8228853074d 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -401,3 +401,4 @@ min_val = 0 integer = FALSE +/datum/config_entry/flag/disallow_circuit_sounds diff --git a/code/modules/wiremod/components/action/soundemitter.dm b/code/modules/wiremod/components/action/soundemitter.dm index 1ca4f3db588..ea43e937711 100644 --- a/code/modules/wiremod/components/action/soundemitter.dm +++ b/code/modules/wiremod/components/action/soundemitter.dm @@ -15,22 +15,35 @@ /// Volume of the sound when played var/datum/port/input/volume + /// Whether to play the sound backwards + var/datum/port/input/backwards + /// Frequency of the sound when played var/datum/port/input/frequency /// The cooldown for this component of how often it can play sounds. var/sound_cooldown = 2 SECONDS + /// The maximum pitch this component can play sounds at. + var/max_pitch = 50 + /// The minimum pitch this component can play sounds at. + var/min_pitch = -50 + /// The maximum volume this component can play sounds at. + var/max_volume = 30 + var/list/options_map /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") /obj/item/circuit_component/soundemitter/populate_ports() volume = add_input_port("Volume", PORT_TYPE_NUMBER, default = 35) frequency = add_input_port("Frequency", PORT_TYPE_NUMBER, default = 0) + backwards = add_input_port("Play Backwards", PORT_TYPE_NUMBER, default = 0) /obj/item/circuit_component/soundemitter/populate_options() var/static/component_options = list( @@ -61,9 +74,16 @@ /obj/item/circuit_component/soundemitter/pre_input_received(datum/port/input/port) volume.set_value(clamp(volume.value, 0, 100)) - frequency.set_value(clamp(frequency.value, -100, 100)) + frequency.set_value(clamp(frequency.value, min_pitch, max_pitch)) + backwards.set_value(clamp(backwards.value, 0, 1)) /obj/item/circuit_component/soundemitter/input_received(datum/port/input/port) + if(CONFIG_GET(flag/disallow_circuit_sounds)) + ui_color = "red" + return + else + ui_color = initial(ui_color) + if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER)) return @@ -71,6 +91,12 @@ if(!sound_to_play) return - playsound(src, sound_to_play, volume.value, frequency != 0, frequency = frequency.value) + var/actual_frequency = 1 + (frequency.value/100) + var/actual_volume = max_volume * (volume.value/100) + + if(backwards.value) + actual_frequency = -actual_frequency + + playsound(src, sound_to_play, actual_volume, TRUE, frequency = actual_frequency) TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown) diff --git a/code/modules/wiremod/core/admin_panel.dm b/code/modules/wiremod/core/admin_panel.dm index 33af02f5140..74e72ad5efe 100644 --- a/code/modules/wiremod/core/admin_panel.dm +++ b/code/modules/wiremod/core/admin_panel.dm @@ -29,6 +29,13 @@ if (.) return . + switch(action) + if ("disable_circuit_sound") + CONFIG_SET(flag/disallow_circuit_sounds, !CONFIG_GET(flag/disallow_circuit_sounds)) + message_admins("[key_name_admin(usr)] has toggled all circuit sounds [CONFIG_GET(flag/disallow_circuit_sounds)? "off" : "on"].") + log_admin("[key_name(usr)] has toggled all circuit sounds [CONFIG_GET(flag/disallow_circuit_sounds)? "off" : "on"].") + return TRUE + if (!istext(params["circuit"])) return FALSE diff --git a/config/game_options.txt b/config/game_options.txt index 0ef639a2738..4135e43c5e6 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -514,6 +514,9 @@ MAXFINE 2000 ## Whether native FoV is enabled for all people. #NATIVE_FOV +## Whether circuit sounds are allowed to be played or not. +#DISALLOW_CIRCUIT_SOUNDS + ## Comment if you wish to enable title music playing at the lobby screen. This flag is disabled by default to facilitate better code testing on local machines. ## Do keep in mind that this flag will not affect individual player's preferences: if they opt-out on your server, it will never play for them. DISALLOW_TITLE_MUSIC diff --git a/tgui/packages/tgui/interfaces/CircuitAdminPanel.tsx b/tgui/packages/tgui/interfaces/CircuitAdminPanel.tsx index 814a147fc10..c97cf24ce0c 100644 --- a/tgui/packages/tgui/interfaces/CircuitAdminPanel.tsx +++ b/tgui/packages/tgui/interfaces/CircuitAdminPanel.tsx @@ -1,6 +1,6 @@ import { BooleanLike } from "common/react"; import { useBackend } from "../backend"; -import { Button, Table } from "../components"; +import { Button, Stack, Table } from "../components"; import { Window } from "../layouts"; type CircuitAdminPanelData = { @@ -18,67 +18,83 @@ export const CircuitAdminPanel = (props, context) => { return ( - - - - Circuit name - - - - Creator - - - - Actions - - - - {data.circuits.map(circuit => { - const createAct = (action: string) => () => { - act(action, { circuit: circuit.ref }); - }; - - return ( - + + + + + + + + + + +
+ - {circuit.name} + Circuit name - {circuit.creator} + Creator - - - - - - - - - - - {!!circuit.has_inserter && ( - - )} + Actions - ); - })} -
+ + {data.circuits.map(circuit => { + const createAct = (action: string) => () => { + act(action, { circuit: circuit.ref }); + }; + + return ( + + + {circuit.name} + + + + {circuit.creator} + + + + + + + + + + + + + + {!!circuit.has_inserter && ( + + )} + + + ); + })} + + +
);