diff --git a/code/__DEFINES/machines.dm b/code/__DEFINES/machines.dm index 7f27b195fc2..7781efc5eee 100644 --- a/code/__DEFINES/machines.dm +++ b/code/__DEFINES/machines.dm @@ -94,6 +94,13 @@ #define NUKESTATE_CORE_EXPOSED 1 #define NUKESTATE_CORE_REMOVED 0 +#define NUKEUI_AWAIT_DISK 0 +#define NUKEUI_AWAIT_CODE 1 +#define NUKEUI_AWAIT_TIMER 2 +#define NUKEUI_AWAIT_ARM 3 +#define NUKEUI_TIMING 4 +#define NUKEUI_EXPLODED 5 + #define NUKE_OFF_LOCKED 0 #define NUKE_OFF_UNLOCKED 1 #define NUKE_ON_TIMING 2 diff --git a/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm b/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm index 26a5a2f3717..ed40a87bf3c 100644 --- a/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm +++ b/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm @@ -8,15 +8,16 @@ resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF ui_style = "nanotrasen" - ui_x = 500 - ui_y = 600 + ui_x = 350 + ui_y = 442 var/timer_set = 90 - var/default_timer_set = 90 var/minimum_timer_set = 90 var/maximum_timer_set = 3600 var/numeric_input = "" + var/ui_mode = NUKEUI_AWAIT_DISK + var/timing = FALSE var/exploding = FALSE var/exploded = FALSE @@ -100,6 +101,8 @@ if(!user.transferItemToLoc(I, src)) return auth = I + update_ui_mode() + playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE) add_fingerprint(user) return @@ -235,6 +238,29 @@ var/volume = (get_time_left() <= 20 ? 30 : 5) playsound(loc, 'sound/items/timer.ogg', volume, FALSE) +/obj/machinery/nuclearbomb/proc/update_ui_mode() + if(exploded) + ui_mode = NUKEUI_EXPLODED + return + + if(!auth) + ui_mode = NUKEUI_AWAIT_DISK + return + + if(timing) + ui_mode = NUKEUI_TIMING + return + + if(!safety) + ui_mode = NUKEUI_AWAIT_ARM + return + + if(!yes_code) + ui_mode = NUKEUI_AWAIT_CODE + return + + ui_mode = NUKEUI_AWAIT_TIMER + /obj/machinery/nuclearbomb/ui_interact(mob/user, ui_key="main", datum/tgui/ui=null, force_open=0, datum/tgui/master_ui=null, datum/ui_state/state=GLOB.default_state) ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) if(!ui) @@ -245,104 +271,127 @@ /obj/machinery/nuclearbomb/ui_data(mob/user) var/list/data = list() data["disk_present"] = auth - data["code_approved"] = yes_code - var/first_status - if(auth) - if(yes_code) - first_status = timing ? "Func/Set" : "Functional" - else - first_status = "Auth S2." + + var/hidden_code = (ui_mode == NUKEUI_AWAIT_CODE && numeric_input != "ERROR") + + var/current_code = "" + if(hidden_code) + while(length(current_code) < length(numeric_input)) + current_code = "[current_code]*" else - if(timing) - first_status = "Set" - else - first_status = "Auth S1." - var/second_status = exploded ? "Warhead triggered, thanks for flying Nanotrasen" : (safety ? "Safe" : "Engaged") + current_code = numeric_input + while(length(current_code) < 5) + current_code = "[current_code]-" + + var/first_status + var/second_status + switch(ui_mode) + if(NUKEUI_AWAIT_DISK) + first_status = "DEVICE LOCKED" + if(timing) + second_status = "TIME: [get_time_left()]" + else + second_status = "AWAIT DISK" + if(NUKEUI_AWAIT_CODE) + first_status = "INPUT CODE" + second_status = "CODE: [current_code]" + if(NUKEUI_AWAIT_TIMER) + first_status = "INPUT TIME" + second_status = "TIME: [current_code]" + if(NUKEUI_AWAIT_ARM) + first_status = "DEVICE READY" + second_status = "TIME: [get_time_left()]" + if(NUKEUI_TIMING) + first_status = "DEVICE ARMED" + second_status = "TIME: [get_time_left()]" + if(NUKEUI_EXPLODED) + first_status = "DEVICE DEPLOYED" + second_status = "THANK YOU" + data["status1"] = first_status data["status2"] = second_status data["anchored"] = anchored - data["safety"] = safety - data["timing"] = timing - data["time_left"] = get_time_left() - - data["timer_set"] = timer_set - data["timer_is_not_default"] = timer_set != default_timer_set - data["timer_is_not_min"] = timer_set != minimum_timer_set - data["timer_is_not_max"] = timer_set != maximum_timer_set - - var/message = "AUTH" - if(auth) - message = "[numeric_input]" - if(yes_code) - message = "*****" - data["message"] = message return data /obj/machinery/nuclearbomb/ui_act(action, params) if(..()) return + playsound(src, "terminal_type", 20, FALSE) switch(action) if("eject_disk") if(auth && auth.loc == src) + playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE) + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) auth.forceMove(get_turf(src)) auth = null . = TRUE - if("insert_disk") - if(!auth) + else var/obj/item/I = usr.is_holding_item_of_type(/obj/item/disk/nuclear) if(I && disk_check(I) && usr.transferItemToLoc(I, src)) + playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE) + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) auth = I . = TRUE + update_ui_mode() if("keypad") if(auth) var/digit = params["digit"] switch(digit) - if("R") + if("C") + if(auth && ui_mode == NUKEUI_AWAIT_ARM) + set_safety() + yes_code = FALSE + playsound(src, 'sound/machines/nuke/confirm_beep.ogg', 50, FALSE) + update_ui_mode() + else + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) numeric_input = "" - yes_code = FALSE . = TRUE if("E") - if(numeric_input == r_code) - numeric_input = "" - yes_code = TRUE - . = TRUE - else - numeric_input = "ERROR" + switch(ui_mode) + if(NUKEUI_AWAIT_CODE) + if(numeric_input == r_code) + numeric_input = "" + yes_code = TRUE + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) + . = TRUE + else + playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE) + numeric_input = "ERROR" + if(NUKEUI_AWAIT_TIMER) + var/number_value = text2num(numeric_input) + if(number_value) + timer_set = CLAMP(number_value, minimum_timer_set, maximum_timer_set) + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) + set_safety() + . = TRUE + else + playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE) + update_ui_mode() if("0","1","2","3","4","5","6","7","8","9") if(numeric_input != "ERROR") numeric_input += digit if(length(numeric_input) > 5) numeric_input = "ERROR" + else + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) . = TRUE - if("timer") - if(auth && yes_code) - var/change = params["change"] - if(change == "reset") - timer_set = default_timer_set - else if(change == "decrease") - timer_set = max(minimum_timer_set, timer_set - 10) - else if(change == "increase") - timer_set = min(maximum_timer_set, timer_set + 10) - else if(change == "input") - var/user_input = input(usr, "Set time to detonation.", name) as null|num - if(!user_input) - return - var/N = text2num(user_input) - if(!N) - return - timer_set = CLAMP(N,minimum_timer_set,maximum_timer_set) - . = TRUE - if("safety") - if(auth && yes_code && !exploded) - set_safety() + else + playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE) + if("arm") + if(auth && yes_code && !safety && !exploded) + playsound(src, 'sound/machines/nuke/confirm_beep.ogg', 50, FALSE) + set_active() + update_ui_mode() + else + playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE) if("anchor") if(auth && yes_code) + playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE) set_anchor() - if("toggle_timer") - if(auth && yes_code && !safety && !exploded) - set_active() - + else + playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE) /obj/machinery/nuclearbomb/proc/set_anchor() if(isinspace() && !anchored) diff --git a/sound/machines/nuke/angry_beep.ogg b/sound/machines/nuke/angry_beep.ogg new file mode 100644 index 00000000000..547779de1be Binary files /dev/null and b/sound/machines/nuke/angry_beep.ogg differ diff --git a/sound/machines/nuke/confirm_beep.ogg b/sound/machines/nuke/confirm_beep.ogg new file mode 100644 index 00000000000..6b98ba8bd66 Binary files /dev/null and b/sound/machines/nuke/confirm_beep.ogg differ diff --git a/sound/machines/nuke/general_beep.ogg b/sound/machines/nuke/general_beep.ogg new file mode 100644 index 00000000000..c149eb300a0 Binary files /dev/null and b/sound/machines/nuke/general_beep.ogg differ diff --git a/tgui-next/packages/tgui/interfaces/NuclearBomb.js b/tgui-next/packages/tgui/interfaces/NuclearBomb.js new file mode 100644 index 00000000000..873a7715b14 --- /dev/null +++ b/tgui-next/packages/tgui/interfaces/NuclearBomb.js @@ -0,0 +1,147 @@ +import { act } from '../byond'; +import { Box, Button, Grid, Flex, Icon } from '../components'; +import { classes } from 'common/react'; + +// This ui is so many manual overrides and !important tags +// and hand made width sets that changing pretty much anything +// is going to require a lot of tweaking it get it looking correct again +// I'm sorry, but it looks bangin +const NukeKeypad = props => { + const { state } = props; + const { config, data } = state; + const { ref } = config; + const keypadKeys = [ + ["1", "4", "7", "C"], + ["2", "5", "8", "0"], + ["3", "6", "9", "E"], + ]; + return ( + + + {keypadKeys.map(keyColumn => ( + + {keyColumn.map(key => ( +