Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phone Do not Disturb #4427

Merged
merged 4 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
38 changes: 35 additions & 3 deletions code/modules/cm_phone/phone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)
var/range = 7

var/enabled = TRUE
var/callable = TRUE
/// Whether or not the phone is receiving calls or not. Varies between on/off or forcibly on/off.
var/do_not_disturb = PHONE_DND_OFF
BeagleGaming1 marked this conversation as resolved.
Show resolved Hide resolved

var/base_icon_state

Expand All @@ -35,7 +36,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 +81,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 +129,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 +186,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 Expand Up @@ -543,12 +569,18 @@ GLOBAL_LIST_EMPTY_TYPED(transmitters, /obj/structure/transmitter)
UnregisterSignal(attached_to, COMSIG_MOVABLE_MOVED)
reset_tether()

/obj/structure/transmitter/no_dnd
do_not_disturb = PHONE_DND_FORBIDDEN

//rotary desk phones (need a touch tone handset at some point)
/obj/structure/transmitter/rotary
name = "rotary telephone"
icon_state = "rotary_phone"
desc = "The finger plate is a little stiff."

/obj/structure/transmitter/rotary/no_dnd
do_not_disturb = PHONE_DND_FORBIDDEN

/obj/structure/transmitter/touchtone
name = "touch-tone telephone"
icon_state = "rotary_phone"//placeholder
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 @@ -29757,7 +29757,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
18 changes: 9 additions & 9 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -7816,7 +7816,7 @@
pixel_y = 15
},
/obj/structure/machinery/light,
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Bravo Overwatch Telephone";
phone_category = "Command";
phone_id = "Bravo Overwatch"
Expand Down Expand Up @@ -8504,7 +8504,7 @@
pixel_y = -5;
req_one_access_txt = "1;4"
},
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Combat Information Center Telephone";
phone_category = "Command";
phone_id = "Combat Information Center";
Expand Down Expand Up @@ -8955,7 +8955,7 @@
/obj/structure/machinery/light{
dir = 1
},
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Charlie Overwatch Telephone";
phone_category = "Command";
phone_id = "Charlie Overwatch"
Expand Down Expand Up @@ -34204,7 +34204,7 @@
pixel_x = -17;
pixel_y = -17
},
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Delta Overwatch Telephone";
phone_category = "Command";
phone_id = "Delta Overwatch"
Expand Down Expand Up @@ -37365,11 +37365,11 @@
"gjL" = (
/obj/structure/surface/table/almayer,
/obj/structure/machinery/computer/crew/alt,
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Brig Cells Telephone";
phone_category = "Almayer";
phone_id = "Brig Cells";
pixel_x = 15
pixel_x = 15;
},
/turf/open/floor/almayer,
/area/almayer/shipboard/brig/processing)
Expand Down Expand Up @@ -38377,7 +38377,7 @@
pixel_x = -17;
pixel_y = 16
},
/obj/structure/transmitter/rotary{
/obj/structure/transmitter/rotary/no_dnd{
name = "Alpha Overwatch Telephone";
phone_category = "Command";
phone_id = "Alpha Overwatch"
Expand Down Expand Up @@ -64474,11 +64474,11 @@
/turf/open/floor/plating/plating_catwalk,
/area/almayer/hull/upper_hull/u_f_s)
"rTY" = (
/obj/structure/transmitter{
/obj/structure/transmitter/no_dnd{
name = "Requisition Telephone";
phone_category = "Almayer";
phone_id = "Requisition";
pixel_y = 30
pixel_y = 30;
},
/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