[TGUI] Minor Fixes/Tweaks To Various Machines (#15365)

* comms computer fixes/refactor

* card computer tweaks

* IDcomputer: colorize departments in list

* faxmachine: aghosts no longer see log out when not logged in

* Fixes #14591

Co-authored-by: Kyep <Kyep@users.noreply.github.com>
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
Kyep
2021-01-28 19:06:18 +00:00
committed by GitHub
co-authored by Kyep AffectedArc07
parent fc128af66c
commit 36674f05f1
8 changed files with 95 additions and 79 deletions
+12 -11
View File
@@ -97,12 +97,12 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
return formatted
/obj/machinery/computer/card/proc/format_job_slots()
/obj/machinery/computer/card/proc/format_job_slots(check_department, is_admin)
var/list/formatted = list()
for(var/datum/job/job in SSjobs.occupations)
if(job_blacklisted_full(job))
continue
if(!job_in_department(job))
if(check_department && !job_in_department(job))
continue
formatted.Add(list(list(
"title" = job.title,
@@ -110,7 +110,8 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
"total_positions" = job.total_positions,
"can_open" = can_open_job(job),
"can_close" = can_close_job(job),
"can_prioritize" = can_prioritize_job(job)
"can_prioritize" = can_prioritize_job(job, is_admin),
"is_priority" = (job in SSjobs.prioritized_jobs)
)))
return formatted
@@ -212,11 +213,11 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
return TRUE
return FALSE
/obj/machinery/computer/card/proc/can_prioritize_job(datum/job/job)
/obj/machinery/computer/card/proc/can_prioritize_job(datum/job/job, is_admin)
if(job)
if(job_blacklisted_full(job))
return FALSE
if(!job_in_department(job, FALSE))
if(!is_admin && !job_in_department(job, FALSE))
return FALSE
if(job in SSjobs.prioritized_jobs)
return TRUE // because this also lets us un-prioritize the job
@@ -319,8 +320,10 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
data["scan_rank"] = scan ? scan.rank : FALSE
data["authenticated"] = is_authenticated(user) ? TRUE : FALSE
data["auth_or_ghost"] = data["authenticated"] || isobserver(user)
data["target_dept"] = target_dept
data["iscentcom"] = is_centcom() ? TRUE : FALSE
data["isadmin"] = user.can_admin_interact()
switch(mode)
if(IDCOMPUTER_SCREEN_TRANSFER) // JOB TRANSFER
@@ -348,7 +351,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
data["all_centcom_skins"] = is_centcom() ? format_card_skins(get_centcom_card_skins()) : FALSE
if(IDCOMPUTER_SCREEN_SLOTS) // JOB SLOTS
data["job_slots"] = format_job_slots()
data["job_slots"] = format_job_slots(!isobserver(user), data["isadmin"])
data["priority_jobs"] = list()
for(var/datum/job/a in SSjobs.prioritized_jobs)
data["priority_jobs"] += a.title
@@ -690,17 +693,15 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
var/datum/job/j = SSjobs.GetJob(priority_target)
if(!j)
return FALSE
if(!job_in_department(j))
if(!can_prioritize_job(j, usr.can_admin_interact()))
return FALSE
var/priority = TRUE
if(j in SSjobs.prioritized_jobs)
SSjobs.prioritized_jobs -= j
priority = FALSE
else if(SSjobs.prioritized_jobs.len < 3)
SSjobs.prioritized_jobs += j
else
return FALSE
log_game("[key_name(usr)] ([scan.assignment]) [priority ? "prioritized" : "unprioritized"] the job \"[j.title]\".")
SSjobs.prioritized_jobs += j
log_game("[key_name(usr)] ([scan ? scan.assignment : "ADMIN"]) [priority ? "prioritized" : "unprioritized"] the job \"[j.title]\".")
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0)
return
+27 -25
View File
@@ -3,8 +3,9 @@
#define COMM_SCREEN_MESSAGES 3
#define COMM_AUTHENTICATION_NONE 0
#define COMM_AUTHENTICATION_MIN 1
#define COMM_AUTHENTICATION_MAX 2
#define COMM_AUTHENTICATION_HEAD 1
#define COMM_AUTHENTICATION_CAPT 2
#define COMM_AUTHENTICATION_AGHOST 3
#define COMM_MSGLEN_MINIMUM 6
#define COMM_CCMSGLEN_MINIMUM 20
@@ -45,16 +46,15 @@
crew_announcement.newscast = 0
/obj/machinery/computer/communications/proc/is_authenticated(var/mob/user, var/message = 1)
if(authenticated == COMM_AUTHENTICATION_MAX)
return COMM_AUTHENTICATION_MAX
else if(user.can_admin_interact())
return COMM_AUTHENTICATION_MAX
else if(authenticated)
return COMM_AUTHENTICATION_MIN
else
if(message)
to_chat(user, "<span class='warning'>Access denied.</span>")
return COMM_AUTHENTICATION_NONE
if(user.can_admin_interact())
return COMM_AUTHENTICATION_AGHOST
if(authenticated == COMM_AUTHENTICATION_CAPT)
return COMM_AUTHENTICATION_CAPT
if(authenticated)
return COMM_AUTHENTICATION_HEAD
if(message)
to_chat(user, "<span class='warning'>Access denied.</span>")
return COMM_AUTHENTICATION_NONE
/obj/machinery/computer/communications/proc/change_security_level(var/new_level)
tmp_alertlevel = new_level
@@ -80,7 +80,7 @@
if(action == "auth")
if(!ishuman(usr))
to_chat(usr, "<span class='warning'>Access denied.</span>")
to_chat(usr, "<span class='warning'>Access denied, no humanoid lifesign detected.</span>")
return FALSE
// Logout function.
if(authenticated != COMM_AUTHENTICATION_NONE)
@@ -91,15 +91,15 @@
// Login function.
var/list/access = usr.get_access()
if(allowed(usr))
authenticated = COMM_AUTHENTICATION_MIN
authenticated = COMM_AUTHENTICATION_HEAD
if(ACCESS_CAPTAIN in access)
authenticated = COMM_AUTHENTICATION_MAX
authenticated = COMM_AUTHENTICATION_CAPT
var/mob/living/carbon/human/H = usr
var/obj/item/card/id = H.get_idcard(TRUE)
if(istype(id))
crew_announcement.announcer = GetNameAndAssignmentFromId(id)
if(authenticated == COMM_AUTHENTICATION_NONE)
to_chat(usr, "<span class='warning'>You need to wear your ID.</span>")
to_chat(usr, "<span class='warning'>You need to wear a command or Captain-level ID.</span>")
return
// All functions below this point require authentication.
@@ -133,12 +133,12 @@
to_chat(usr, "<span class='warning'>You need to wear your ID.</span>")
if("announce")
if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)
if(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT)
if(message_cooldown > world.time)
to_chat(usr, "<span class='warning'>Please allow at least one minute to pass between announcements.</span>")
return
var/input = input(usr, "Please write a message to announce to the station crew.", "Priority Announcement")
if(!input || message_cooldown > world.time || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX))
if(!input || message_cooldown > world.time || ..() || !(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT))
return
if(length(input) < COMM_MSGLEN_MINIMUM)
to_chat(usr, "<span class='warning'>Message '[input]' is too short. [COMM_MSGLEN_MINIMUM] character minimum.</span>")
@@ -217,12 +217,12 @@
setMenuState(usr, COMM_SCREEN_STAT)
if("nukerequest")
if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)
if(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT)
if(centcomm_message_cooldown > world.time)
to_chat(usr, "<span class='warning'>Arrays recycling. Please stand by.</span>")
return
var/input = stripped_input(usr, "Please enter the reason for requesting the nuclear self-destruct codes. Misuse of the nuclear request system will not be tolerated under any circumstances. Transmission does not guarantee a response.", "Self Destruct Code Request.","")
if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX))
if(!input || ..() || !(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT))
return
if(length(input) < COMM_CCMSGLEN_MINIMUM)
to_chat(usr, "<span class='warning'>Message '[input]' is too short. [COMM_CCMSGLEN_MINIMUM] character minimum.</span>")
@@ -235,12 +235,12 @@
setMenuState(usr, COMM_SCREEN_MAIN)
if("MessageCentcomm")
if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)
if(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT)
if(centcomm_message_cooldown > world.time)
to_chat(usr, "<span class='warning'>Arrays recycling. Please stand by.</span>")
return
var/input = stripped_input(usr, "Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "")
if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX))
if(!input || ..() || !(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT))
return
if(length(input) < COMM_CCMSGLEN_MINIMUM)
to_chat(usr, "<span class='warning'>Message '[input]' is too short. [COMM_CCMSGLEN_MINIMUM] character minimum.</span>")
@@ -254,12 +254,12 @@
// OMG SYNDICATE ...LETTERHEAD
if("MessageSyndicate")
if((is_authenticated(usr) == COMM_AUTHENTICATION_MAX) && (src.emagged))
if((is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT) && (src.emagged))
if(centcomm_message_cooldown > world.time)
to_chat(usr, "Arrays recycling. Please stand by.")
return
var/input = stripped_input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "")
if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX))
if(!input || ..() || !(is_authenticated(usr) >= COMM_AUTHENTICATION_CAPT))
return
if(length(input) < COMM_CCMSGLEN_MINIMUM)
to_chat(usr, "<span class='warning'>Message '[input]' is too short. [COMM_CCMSGLEN_MINIMUM] character minimum.</span>")
@@ -320,10 +320,12 @@
/obj/machinery/computer/communications/ui_data(mob/user)
var/list/data = list()
data["is_ai"] = isAI(user) || isrobot(user)
data["noauthbutton"] = !ishuman(user)
data["menu_state"] = data["is_ai"] ? ai_menu_state : menu_state
data["emagged"] = emagged
data["authenticated"] = is_authenticated(user, 0)
data["authmax"] = data["authenticated"] == COMM_AUTHENTICATION_MAX ? TRUE : FALSE
data["authhead"] = data["authenticated"] >= COMM_AUTHENTICATION_HEAD && (data["authenticated"] == COMM_AUTHENTICATION_AGHOST || !isobserver(user))
data["authcapt"] = data["authenticated"] >= COMM_AUTHENTICATION_CAPT && (data["authenticated"] == COMM_AUTHENTICATION_AGHOST || !isobserver(user))
data["stat_display"] = list(
"type" = display_type,
+4
View File
@@ -510,6 +510,10 @@
if(ishuman(user))
H = user
C = H.get_idcard(TRUE)
if(!C && istype(H.wear_pda, /obj/item/pda))
var/obj/item/pda/P = H.wear_pda
if(istype(P.id, /obj/item/card/id))
C = P.id
var/obj/item/stack/spacecash/S = H.get_active_hand()
if(istype(S))
data["userMoney"] = S.amount
+2
View File
@@ -104,7 +104,9 @@ GLOBAL_LIST_EMPTY(fax_blacklist)
/obj/machinery/photocopier/faxmachine/ui_data(mob/user)
var/list/data = list()
data["authenticated"] = is_authenticated(user)
data["realauth"] = authenticated
data["scan_name"] = scan ? scan.name : FALSE
data["nologin"] = !data["scan_name"] && !data["realauth"]
if(!data["authenticated"])
data["network"] = "Disconnected"
else if(!emagged)
+20 -16
View File
@@ -3,11 +3,13 @@ import { useBackend } from '../backend';
import { Button, LabeledList, Box, Section, Table, Tabs } from '../components';
import { Window } from '../layouts';
import { AccessList } from './common/AccessList';
import { COLORS } from '../constants';
const deptCols = COLORS.department;
export const CardComputer = (props, context) => {
const { act, data } = useBackend(context);
let menuBlock = (
<Tabs>
<Tabs.Tab
@@ -174,7 +176,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Engineering">
<LabeledList.Item label="Engineering" labelColor={deptCols.engineering}>
{data.jobs_engineering.map(v => (
<Button
key={v} content={v}
@@ -182,7 +184,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Medical">
<LabeledList.Item label="Medical" labelColor={deptCols.medical}>
{data.jobs_medical.map(v => (
<Button
key={v} content={v}
@@ -190,7 +192,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Science">
<LabeledList.Item label="Science" labelColor={deptCols.science}>
{data.jobs_science.map(v => (
<Button
key={v} content={v}
@@ -198,7 +200,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Security">
<LabeledList.Item label="Security" labelColor={deptCols.security}>
{data.jobs_security.map(v => (
<Button
selected={v === data.modify_rank}
@@ -207,7 +209,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Service">
<LabeledList.Item label="Service" labelColor={deptCols.service}>
{data.jobs_service.map(v => (
<Button
selected={v === data.modify_rank}
@@ -216,7 +218,7 @@ export const CardComputer = (props, context) => {
onClick={() => act("assign", { assign_target: v })} />
))}
</LabeledList.Item>
<LabeledList.Item label="Supply">
<LabeledList.Item label="Supply" labelColor={deptCols.supply}>
{data.jobs_supply.map(v => (
<Button
selected={v === data.modify_rank}
@@ -244,7 +246,7 @@ export const CardComputer = (props, context) => {
))}
</LabeledList.Item>
{!!data.iscentcom && (
<LabeledList.Item label="CentCom">
<LabeledList.Item label="CentCom" labelColor={deptCols.centcom}>
{data.jobs_centcom.map(v => (
<Button
selected={v === data.modify_rank}
@@ -299,7 +301,7 @@ export const CardComputer = (props, context) => {
}
break;
case 1: // job slot management
if (!data.authenticated || !data.scan_name) {
if (!data.auth_or_ghost) {
bodyBlock = (
<Section title="Warning" color="red">
Not logged in.
@@ -313,8 +315,6 @@ export const CardComputer = (props, context) => {
{data.cooldown_time ? data.cooldown_time : "Now"}
</Section>
<Section title="Job Slots">
<Table>
<Table.Row>
<Table.Cell bold textAlign="center">Title</Table.Cell>
@@ -328,7 +328,11 @@ export const CardComputer = (props, context) => {
{data.job_slots.map(slotData => (
<Table.Row key={slotData.title}>
<Table.Cell textAlign="center">
{slotData.title}
<Box color={slotData.is_priority
? "green"
: ""}>
{slotData.title}
</Box>
</Table.Cell>
<Table.Cell textAlign="center">
{slotData.current_positions}
@@ -372,10 +376,10 @@ export const CardComputer = (props, context) => {
</Box>
) || (
<Button
content="Priority"
selected={
data.priority_jobs.indexOf(slotData.title) > -1
}
content={slotData.is_priority
? "Yes"
: "No"}
selected={slotData.is_priority}
disabled={
data.cooldown_time || !slotData.can_prioritize
}
@@ -7,14 +7,16 @@ export const CommunicationsComputer = (props, context) => {
const { act, data } = useBackend(context);
let authReadable;
let authSpecial = false;
if (!data.authenticated) {
authReadable = "Not Logged In";
} else if (data.is_ai) {
authReadable = "AI";
} else if (data.authenticated === 1) {
authReadable = "Command";
} else if (data.authenticated === 2) {
authReadable = "Captain";
} else if (data.authenticated === 3) {
authReadable = "CentComm Secure Connection";
authSpecial = true;
} else {
authReadable = "ERROR: Report This Bug!";
}
@@ -23,15 +25,16 @@ export const CommunicationsComputer = (props, context) => {
<Fragment>
<Section title="Authentication">
<LabeledList>
{data.is_ai && (
<LabeledList.Item label="Access Level">
AI
{authSpecial && (
<LabeledList.Item label="Access">
{authReadable}
</LabeledList.Item>
) || (
<LabeledList.Item label="Actions">
<Button
icon={data.authenticated ? 'sign-out-alt' : 'id-card'}
selected={data.authenticated}
disabled={data.noauthbutton}
content={data.authenticated
? "Log Out (" + authReadable + ")"
: 'Log In'}
@@ -53,7 +56,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="rocket"
content="Call Shuttle"
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('callshuttle')} />
</LabeledList.Item>
)}
@@ -62,7 +65,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="times"
content="Recall Shuttle"
disabled={!data.authenticated || data.is_ai}
disabled={!data.authhead || data.is_ai}
onClick={() => act('cancelshuttle')} />
</LabeledList.Item>
)}
@@ -93,7 +96,7 @@ export const CommunicationsComputer = (props, context) => {
key={slevel.name}
icon={slevel.icon}
content={slevel.name}
disabled={!data.authmax
disabled={!data.authcapt
|| slevel.id === data.security_level}
onClick={() => act('newalertlevel', { level: slevel.id })} />
);
@@ -104,7 +107,7 @@ export const CommunicationsComputer = (props, context) => {
key={pb.name}
content={pb.label}
selected={pb.name === data.stat_display.type}
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('setstat', { statdisp: pb.name })} />
);
});
@@ -114,7 +117,7 @@ export const CommunicationsComputer = (props, context) => {
key={ib.alert}
content={ib.label}
selected={ib.alert === data.stat_display.icon}
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('setstat',
{ statdisp: "alert", alert: ib.alert })} />
);
@@ -126,7 +129,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="times"
content="Return To Message List"
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('messagelist')} />
}>
<Box>
@@ -141,13 +144,13 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="eye"
content="View"
disabled={!data.authenticated
disabled={!data.authhead
|| data.current_message_title === m.title}
onClick={() => act('messagelist', { msgid: m.id })} />
<Button
icon="times"
content="Delete"
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('delmessage', { msgid: m.id })} />
</LabeledList.Item>
);
@@ -185,7 +188,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="bullhorn"
content={announceText}
disabled={!data.authmax || data.msg_cooldown > 0}
disabled={!data.authcapt || data.msg_cooldown > 0}
onClick={() => act('announce')} />
</LabeledList.Item>
{!!data.emagged && (
@@ -194,12 +197,12 @@ export const CommunicationsComputer = (props, context) => {
icon="broadcast-tower"
color="red"
content={ccMessageText}
disabled={!data.authmax || data.cc_cooldown > 0}
disabled={!data.authcapt || data.cc_cooldown > 0}
onClick={() => act('MessageSyndicate')} />
<Button
icon="sync-alt"
content="Reset Relays"
disabled={!data.authmax}
disabled={!data.authcapt}
onClick={() => act('RestoreBackup')} />
</LabeledList.Item>
) || (
@@ -207,7 +210,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="broadcast-tower"
content={ccMessageText}
disabled={!data.authmax || data.cc_cooldown > 0}
disabled={!data.authcapt || data.cc_cooldown > 0}
onClick={() => act('MessageCentcomm')} />
</LabeledList.Item>
)}
@@ -215,7 +218,7 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="bomb"
content={nukeRequestText}
disabled={!data.authmax || data.cc_cooldown > 0}
disabled={!data.authcapt || data.cc_cooldown > 0}
onClick={() => act('nukerequest')} />
</LabeledList.Item>
</LabeledList>
@@ -226,21 +229,21 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="tv"
content="Change Status Displays"
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('status')} />
</LabeledList.Item>
<LabeledList.Item label="Incoming Messages">
<Button
icon="folder-open"
content={reportText}
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('messagelist')} />
</LabeledList.Item>
<LabeledList.Item label="Misc">
<Button
icon="sync-alt"
content="Restart Nano-Mob Hunter GO! Server"
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('RestartNanoMob')} />
</LabeledList.Item>
</LabeledList>
@@ -273,14 +276,14 @@ export const CommunicationsComputer = (props, context) => {
<Button
icon="pencil-alt"
content={data.stat_display.line_1}
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('setmsg1')} />
</LabeledList.Item>
<LabeledList.Item label="Message Line 2">
<Button
icon="pencil-alt"
content={data.stat_display.line_2}
disabled={!data.authenticated}
disabled={!data.authhead}
onClick={() => act('setmsg2')} />
</LabeledList.Item>
</LabeledList>
+2 -2
View File
@@ -21,8 +21,8 @@ export const FaxMachine = (props, context) => {
<Button
icon={data.authenticated ? 'sign-out-alt' : 'id-card'}
selected={data.authenticated}
disabled={!data.scan_name && !data.authenticated}
content={data.authenticated ? 'Log Out' : 'Log In'}
disabled={data.nologin}
content={data.realauth ? 'Log Out' : 'Log In'}
onClick={() => act("auth")} />
</LabeledList.Item>
</LabeledList>
File diff suppressed because one or more lines are too long