diff --git a/code/game/machinery/firealarm.dm b/code/game/machinery/firealarm.dm index 3101a169bba..3e150af2290 100644 --- a/code/game/machinery/firealarm.dm +++ b/code/game/machinery/firealarm.dm @@ -20,6 +20,26 @@ ///looping sound datum for our fire alarm siren. var/datum/looping_sound/firealarm/soundloop +/obj/machinery/firealarm/Initialize(mapload, ndir = 0, building) + . = ..(mapload, ndir) + + update_icon() + + if(isContactLevel(z)) + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(set_security_level), (GLOB.security_level ? get_security_level() : "green")) + + soundloop = new(src, FALSE) + + var/area/A = get_area(src) + RegisterSignal(A, COMSIG_AREA_FIRE_ALARM, TYPE_PROC_REF(/atom, update_icon)) + + if(!mapload) + set_pixel_offsets() + +/obj/machinery/firealarm/Destroy() + QDEL_NULL(soundloop) + . = ..() + /obj/machinery/firealarm/get_examine_text(mob/user, distance, is_adjacent, infix, suffix) . = ..() if((stat & (NOPOWER|BROKEN)) || buildstage != 2) @@ -136,7 +156,7 @@ src.alarm() -/obj/machinery/firealarm/process()//Note: this processing was mostly phased out due to other code, and only runs when needed +/obj/machinery/firealarm/process(seconds_per_tick)//Note: this processing was mostly phased out due to other code, and only runs when needed if(stat & (NOPOWER|BROKEN)) return @@ -149,9 +169,7 @@ timing = FALSE . = PROCESS_KILL else - src.time = src.time - ((world.timeofday - last_process) / 10) - - updateDialog() + src.time = src.time - (((world.timeofday - last_process) / 10) * seconds_per_tick) last_process = world.timeofday @@ -159,41 +177,58 @@ ..() queue_icon_update() -/obj/machinery/firealarm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/ui_state/state = GLOB.default_state) - var/data[0] +/obj/machinery/firealarm/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "FireAlarm") + ui.open() + +/obj/machinery/firealarm/attack_hand(mob/user as mob) + if (buildstage != 2 || stat & (NOPOWER|BROKEN)) + return + + if(user.a_intent == I_HURT) + alarm() + else + ui_interact(user) + +/obj/machinery/firealarm/ui_data(mob/user) + var/list/data = list() + data["alertLevel"] = get_security_level() data["time"] = src.time + var/area/A = get_area(src) data["active"] = A.fire - ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open) - if (!ui) - ui = new(user, src, ui_key, "firealarm.tmpl", "Fire Alarm", 325, 325, state = state) - ui.set_initial_data(data) - ui.open() - ui.set_auto_update(1) + data["timing"] = src.timing -/obj/machinery/firealarm/attack_hand(mob/user as mob) - if (buildstage != 2 || stat & (NOPOWER|BROKEN)) + return data + +/obj/machinery/firealarm/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) return - ui_interact(user) - return + switch(action) + if("activate_alarm") + src.alarm() + if("reset_alarm") + src.reset() + if("set_timer") + var/input_time = text2num(params["set_timer"]) + if(!isnum(input_time)) + return -/obj/machinery/firealarm/Topic(href, href_list) - ..() + time = Clamp(input_time SECONDS, 1, 600) + + if("start_timer") + src.timing = 1 + START_PROCESSING_MACHINE(src, MACHINERY_PROCESS_SELF) + if("stop_timer") + src.timing = 0 - if (href_list["state"] == "active") - src.alarm() - else if (href_list["state"] == "inactive") - src.reset() - if (href_list["tmr"] == "set") - time = Clamp(input(usr, "Enter time delay", "Fire Alarm Delayed Activation", time) as num, 0, 600) - else if (href_list["tmr"] == "start") - src.timing = 1 - START_PROCESSING_MACHINE(src, MACHINERY_PROCESS_SELF) - else if (href_list["tmr"] == "stop") - src.timing = 0 + return TRUE /obj/machinery/firealarm/proc/reset() if (!( src.working )) @@ -219,26 +254,6 @@ if(seclevel != new_security_level) seclevel = new_security_level -/obj/machinery/firealarm/Initialize(mapload, ndir = 0, building) - . = ..(mapload, ndir) - - update_icon() - - if(isContactLevel(z)) - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(set_security_level), (GLOB.security_level ? get_security_level() : "green")) - - soundloop = new(src, FALSE) - - var/area/A = get_area(src) - RegisterSignal(A, COMSIG_AREA_FIRE_ALARM, TYPE_PROC_REF(/atom, update_icon)) - - if(!mapload) - set_pixel_offsets() - -/obj/machinery/firealarm/Destroy() - QDEL_NULL(soundloop) - . = ..() - /obj/machinery/firealarm/set_pixel_offsets() // Overwrite the mapped in values. pixel_x = ((dir & (NORTH|SOUTH)) ? 0 : (dir == EAST ? 22 : -22)) @@ -272,38 +287,3 @@ Just a object used in constructing fire alarms desc = "A circuit. It has a label on it, it says \"Can handle heat levels up to 40 degrees celsius!\"" w_class = ITEMSIZE_SMALL matter = list(DEFAULT_WALL_MATERIAL = 50, MATERIAL_GLASS = 50) - - -/obj/machinery/firealarm/partyalarm - name = "\improper PARTY BUTTON" - desc = "Cuban Pete is in the house!" - -/obj/machinery/firealarm/partyalarm/alarm(var/duration = 0) - if (!( working )) - return - var/area/A = get_area(src) - ASSERT(isarea(A)) - A.partyalert() - return - -/obj/machinery/firealarm/partyalarm/reset() - if (!( working )) - return - var/area/A = get_area(src) - ASSERT(isarea(A)) - A.partyreset() - return - -/obj/machinery/firealarm/partyalarm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/ui_state/state = GLOB.default_state) - var/data[0] - data["alertLevel"] = get_security_level() - data["time"] = src.time - var/area/A = get_area(src) - data["active"] = A.party - - ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open) - if (!ui) - ui = new(user, src, ui_key, "partyalarm.tmpl", "PARTY ALARM", 325, 325, state = state) - ui.set_initial_data(data) - ui.open() - ui.set_auto_update(1) diff --git a/html/changelogs/fluffyghost-firealarmtgui.yml b/html/changelogs/fluffyghost-firealarmtgui.yml new file mode 100644 index 00000000000..b93fea94ee6 --- /dev/null +++ b/html/changelogs/fluffyghost-firealarmtgui.yml @@ -0,0 +1,59 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Attacking a fire alarm with harm intent will trigger the fire alarm." + - refactor: "Refactored fire alarms from NanoUI to TGUI." diff --git a/nano/templates/firealarm.tmpl b/nano/templates/firealarm.tmpl deleted file mode 100644 index 4b2a4627d51..00000000000 --- a/nano/templates/firealarm.tmpl +++ /dev/null @@ -1,27 +0,0 @@ -The current alert level is: -{{if data.alertLevel == 'green'}} - Green -{{/if}} -{{if data.alertLevel == 'blue'}} - Blue -{{/if}} -{{if data.alertLevel == 'yellow'}} - Yellow -{{/if}} -{{if data.alertLevel == 'red'}} - Red -{{/if}} -{{if data.alertLevel == 'delta'}} - DELTA -{{/if}} -
-

State

-{{:helper.link('Normal', '', {'state': 'inactive'}, data.active ? null : 'selected')}} -{{:helper.link('Lockdown', '', {'state': 'active'}, data.active ? 'selected' : null)}} -

Timed Lockdown

-{{:helper.link('Set', '', {'tmr' : 'set'})}} -{{if data.timing}} -{{:helper.link('Stop', '', {'tmr' : 'stop'})}} -{{/if}} -{{if !(data.timing)}}{{:helper.link('Start', '', {'tmr' : 'start'})}}{{/if}}
-{{if data.time}}Time Left: {{:data.time}} seconds.{{/if}} \ No newline at end of file diff --git a/tgui/packages/tgui/interfaces/FireAlarm.tsx b/tgui/packages/tgui/interfaces/FireAlarm.tsx new file mode 100644 index 00000000000..ec92809b4e7 --- /dev/null +++ b/tgui/packages/tgui/interfaces/FireAlarm.tsx @@ -0,0 +1,56 @@ +import { BooleanLike } from '../../common/react'; +import { useBackend } from '../backend'; +import { Section, Button, Box } from '../components'; +import { Window } from '../layouts'; + +export type FireAlarmData = { + alertLevel: String; + time: number; + active: BooleanLike; + timing: BooleanLike; +}; + +export const FireAlarm = (props, context) => { + const { act, data } = useBackend(context); + return ( + + +
+ {data.alertLevel.toLocaleUpperCase()} +
+
+ + +
+
+ + {data.time > 1 + ? (data.time / 10).toFixed(0).toString() + ' seconds' + : 'Not Set'} + + { + act('set_timer', { + set_timer: value, + }); + }} + /> +
+ + +
+
+
+ ); +};