Skip to content

Commit

Permalink
Do not Disturb
Browse files Browse the repository at this point in the history
  • Loading branch information
realforest2001 committed Sep 17, 2023
1 parent ed2dd26 commit a846368
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 10 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,8 @@ var/global/list/uniform_categories = list(
#define PHONE_MARINE "Marine"
#define PHONE_UPP_SOLDIER "Soldier"
#define PHONE_IO "IO"

#define PHONE_DND_FORCED 2
#define PHONE_DND_ON 1
#define PHONE_DND_OFF 0
#define PHONE_DND_FORBIDDEN -1
31 changes: 28 additions & 3 deletions code/modules/cm_phone/phone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)
var/range = 7

var/enabled = TRUE
var/callable = TRUE
var/do_not_disturb = PHONE_DND_OFF

var/base_icon_state

Expand All @@ -35,7 +35,7 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)
var/list/networks_transmit = list(FACTION_MARINE)

/obj/structure/transmitter/hidden
callable = FALSE
do_not_disturb = PHONE_DND_FORCED

/obj/structure/transmitter/Initialize(mapload, ...)
. = ..()
Expand Down Expand Up @@ -80,7 +80,11 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)

for(var/possible_phone in GLOB.transmitters)
var/obj/structure/transmitter/target_phone = possible_phone
if(TRANSMITTER_UNAVAILABLE(target_phone) || !target_phone.callable) // Phone not available
var/current_dnd = FALSE
switch(target_phone.do_not_disturb)
if(PHONE_DND_ON, PHONE_DND_FORCED)
current_dnd = TRUE
if(TRANSMITTER_UNAVAILABLE(target_phone) || current_dnd) // Phone not available
continue
var/net_link = FALSE
for(var/network in networks_transmit)
Expand Down Expand Up @@ -124,9 +128,18 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)
call_phone(user, params["phone_id"])
. = TRUE
SStgui.close_uis(src)
if("toggle_dnd")
toggle_dnd(user)

update_icon()

/obj/structure/transmitter/ui_data(mob/user)
var/list/data = list()

data["availability"] = do_not_disturb

return data

/obj/structure/transmitter/ui_static_data(mob/user)
. = list()

Expand Down Expand Up @@ -172,6 +185,18 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)

user.put_in_hands(attached_to)

/obj/structure/transmitter/proc/toggle_dnd(mob/living/carbon/human/user)
switch(do_not_disturb)
if(PHONE_DND_ON)
do_not_disturb = PHONE_DND_OFF
to_chat(user, SPAN_NOTICE("Do Not Disturb has been disabled. You can now receive calls."))
if(PHONE_DND_OFF)
do_not_disturb = PHONE_DND_ON
to_chat(user, SPAN_WARNING("Do Not Disturb has been enabled. No calls will be received."))
else
return FALSE
return TRUE

/obj/structure/transmitter/attack_hand(mob/user)
. = ..()

Expand Down
2 changes: 1 addition & 1 deletion maps/map_files/BigRed/BigRed.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -29752,7 +29752,7 @@
/area/bigredv2/outside/filtration_plant)
"htp" = (
/obj/structure/transmitter/colony_net{
callable = 0;
do_not_disturb = 1;
dir = 4;
phone_category = "Lambda Labs";
phone_color = "red";
Expand Down
11 changes: 9 additions & 2 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -7951,6 +7951,7 @@
/obj/structure/transmitter/rotary{
name = "Bravo Overwatch Telephone";
phone_category = "Command";
do_not_disturb = -1;
phone_id = "Bravo Overwatch"
},
/obj/structure/sign/safety/terminal{
Expand Down Expand Up @@ -8641,6 +8642,7 @@
name = "Combat Information Center Telephone";
phone_category = "Command";
phone_id = "Combat Information Center";
do_not_disturb = -1;
pixel_x = 5;
pixel_y = 4
},
Expand Down Expand Up @@ -9091,6 +9093,7 @@
/obj/structure/transmitter/rotary{
name = "Charlie Overwatch Telephone";
phone_category = "Command";
do_not_disturb = -1;
phone_id = "Charlie Overwatch"
},
/obj/structure/sign/safety/terminal{
Expand Down Expand Up @@ -34219,6 +34222,7 @@
/obj/structure/transmitter/rotary{
name = "Delta Overwatch Telephone";
phone_category = "Command";
do_not_disturb = -1;
phone_id = "Delta Overwatch"
},
/obj/structure/sign/safety/terminal{
Expand Down Expand Up @@ -37328,7 +37332,8 @@
name = "Brig Cells Telephone";
phone_category = "Almayer";
phone_id = "Brig Cells";
pixel_x = 15
pixel_x = 15;
do_not_disturb = -1
},
/turf/open/floor/almayer,
/area/almayer/shipboard/brig/processing)
Expand Down Expand Up @@ -38339,6 +38344,7 @@
/obj/structure/transmitter/rotary{
name = "Alpha Overwatch Telephone";
phone_category = "Command";
do_not_disturb = -1;
phone_id = "Alpha Overwatch"
},
/obj/structure/sign/safety/terminal{
Expand Down Expand Up @@ -64071,7 +64077,8 @@
name = "Requisition Telephone";
phone_category = "Almayer";
phone_id = "Requisition";
pixel_y = 30
pixel_y = 30;
do_not_disturb = -1
},
/turf/open/floor/almayer{
dir = 5;
Expand Down
2 changes: 1 addition & 1 deletion maps/templates/clf_ert_station.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@
name = "CLF Outpost";
phone_category = "CLF";
phone_id = "CLF Outpost";
callable = 0;
do_not_disturb = 2;
pixel_y = 10
},
/turf/open/floor/wood,
Expand Down
2 changes: 1 addition & 1 deletion maps/templates/upp_ert_station.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@
name = "UPP Station";
phone_category = "UPP";
phone_id = "UPP Station";
callable = 0
do_not_disturb = 2
},
/turf/open/floor/strata{
icon_state = "floor2"
Expand Down
4 changes: 2 additions & 2 deletions maps/templates/weyland_ert_station.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,7 @@
"Js" = (
/obj/structure/surface/table/reinforced/black,
/obj/structure/transmitter/rotary{
callable = 0;
do_not_disturb = 2;
name = "Weyland-Yutani Station CiC";
phone_category = "W-Y";
phone_id = "W-Y Station CiC"
Expand Down Expand Up @@ -3588,7 +3588,7 @@
"SE" = (
/obj/structure/surface/table/woodentable/fancy,
/obj/structure/transmitter/rotary{
callable = 0;
do_not_disturb = 2;
name = "Weyland-Yutani Station Meeting Room";
phone_category = "W-Y";
phone_id = "W-Y Station Meeting Room"
Expand Down
28 changes: 28 additions & 0 deletions tgui/packages/tgui/interfaces/PhoneMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const PhoneMenu = (props, context) => {

const GeneralPanel = (props, context) => {
const { act, data } = useBackend(context);
const { availability } = data;
const available_transmitters = Object.keys(data.available_transmitters);
const transmitters = data.transmitters.filter((val1) =>
available_transmitters.includes(val1.phone_id)
Expand Down Expand Up @@ -46,6 +47,21 @@ const GeneralPanel = (props, context) => {
categories[0]
);

let dnd_tooltip = 'Do Not Disturb is DISABLED';
let dnd_locked = 'No';
let dnd_icon = 'volume-high';
if (availability === 1) {
dnd_tooltip = 'Do Not Disturb is ENABLED';
dnd_icon = 'volume-xmark';
} else if (availability >= 2) {
dnd_tooltip = 'Do Not Disturb is ENABLED (LOCKED)';
dnd_locked = 'Yes';
dnd_icon = 'volume-xmark';
} else if (availability < 0) {
dnd_tooltip = 'Do Not Disturb is DISABLED (LOCKED)';
dnd_locked = 'Yes';
}

return (
<Section fill>
<Stack vertical fill>
Expand Down Expand Up @@ -115,6 +131,18 @@ const GeneralPanel = (props, context) => {
/>
</Stack.Item>
)}
<Stack.Item>
<Button
content="Do Not Disturb"
color="red"
tooltip={dnd_tooltip}
disabled={dnd_locked === 'Yes'}
icon={dnd_icon}
fluid
textAlign="center"
onClick={() => act('toggle_dnd')}
/>
</Stack.Item>
</Stack>
</Section>
);
Expand Down

0 comments on commit a846368

Please sign in to comment.