mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 07:27:57 +01:00
Add AI/Cyborg support for login components
This commit is contained in:
@@ -92,3 +92,8 @@
|
||||
// Firelock states
|
||||
#define FD_OPEN 1
|
||||
#define FD_CLOSED 2
|
||||
|
||||
// Computer login types
|
||||
#define LOGIN_TYPE_NORMAL 1
|
||||
#define LOGIN_TYPE_AI 2
|
||||
#define LOGIN_TYPE_ROBOT 3
|
||||
|
||||
@@ -94,8 +94,11 @@
|
||||
data["temp"] = temp
|
||||
data["scan"] = scan ? scan.name : null
|
||||
data["authenticated"] = authenticated
|
||||
data["rank"] = rank
|
||||
data["screen"] = screen
|
||||
data["printing"] = printing
|
||||
data["isAI"] = isAI(user)
|
||||
data["isRobot"] = isrobot(user)
|
||||
if(authenticated)
|
||||
switch(screen)
|
||||
if(MED_DATA_R_LIST)
|
||||
@@ -211,17 +214,18 @@
|
||||
I.forceMove(src)
|
||||
scan = I
|
||||
if("login")
|
||||
if(isAI(usr))
|
||||
authenticated = usr.name
|
||||
rank = "AI"
|
||||
else if(isrobot(usr))
|
||||
authenticated = usr.name
|
||||
var/mob/living/silicon/robot/R = usr
|
||||
rank = "[R.modtype] [R.braintype]"
|
||||
else if(istype(scan, /obj/item/card/id))
|
||||
var/login_type = text2num(params["login_type"])
|
||||
if(login_type == LOGIN_TYPE_NORMAL && istype(scan))
|
||||
if(check_access(scan))
|
||||
authenticated = scan.registered_name
|
||||
rank = scan.assignment
|
||||
else if(login_type == LOGIN_TYPE_AI && isAI(usr))
|
||||
authenticated = usr.name
|
||||
rank = "AI"
|
||||
else if(login_type == LOGIN_TYPE_ROBOT && isrobot(usr))
|
||||
authenticated = usr.name
|
||||
var/mob/living/silicon/robot/R = usr
|
||||
rank = "[R.modtype] [R.braintype]"
|
||||
if(authenticated)
|
||||
active1 = null
|
||||
active2 = null
|
||||
|
||||
@@ -2,7 +2,8 @@ import { useBackend } from '../../backend';
|
||||
import { Box, Button, NoticeBox } from '../../components';
|
||||
|
||||
/**
|
||||
* Displays a notice box showing the `scan` data field if it exists.
|
||||
* Displays a notice box showing the
|
||||
* `authenticated` and `rank` data fields if they exist.
|
||||
*
|
||||
* Also gives an option to log off (calls `logout` TGUI action)
|
||||
* @param {object} _properties
|
||||
@@ -11,7 +12,8 @@ import { Box, Button, NoticeBox } from '../../components';
|
||||
export const LoginInfo = (_properties, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
scan,
|
||||
authenticated,
|
||||
rank,
|
||||
} = data;
|
||||
if (!data) {
|
||||
return;
|
||||
@@ -19,7 +21,7 @@ export const LoginInfo = (_properties, context) => {
|
||||
return (
|
||||
<NoticeBox info>
|
||||
<Box display="inline-block" verticalAlign="middle">
|
||||
Logged in as: {scan}
|
||||
Logged in as: {authenticated} ({rank})
|
||||
</Box>
|
||||
<Button
|
||||
icon="sign-out-alt"
|
||||
|
||||
@@ -4,13 +4,21 @@ import { Box, Button, Flex, Icon, Section } from '../../components';
|
||||
/**
|
||||
* Displays a login screen that users can interact with
|
||||
* using an ID card in their hand.
|
||||
* Requires a `scan` data field in the DM side, corresponding
|
||||
* to the name on the card.
|
||||
* Required data fields:
|
||||
* * `scan` — The name of the currently inserted ID
|
||||
* * `isAI` — Whether the user is an AI. If true, shows "Login as AI"
|
||||
* * `isRobot` — Whether the user is a robot. If true, shows "Login as Cyborg"
|
||||
*
|
||||
* Clicking the main button calls the `scan` TGUI act.
|
||||
* Clicking either the AI or normal login button calls
|
||||
* the `login` TGUI act with the a `login_type` parameter with the value:
|
||||
* * 1 (LOGIN_TYPE_NORMAL) if it's an ID login
|
||||
* * 2 (LOGIN_TYPE_AI) if it's an AI login
|
||||
* * 3 (LOGIN_TYPE_ROBOT) if it's a robot login
|
||||
*
|
||||
* Clicking the login button calls the `login` TGUI act.
|
||||
* Only available when `scan` is not null
|
||||
* You will have to handle the AI login case in the same action.
|
||||
* The normal login button is only available when `scan` is not null.
|
||||
* The AI and robot login buttons are only visible if the user is one
|
||||
* @param {object} _properties
|
||||
* @param {object} context
|
||||
*/
|
||||
@@ -18,6 +26,8 @@ export const LoginScreen = (_properties, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
scan,
|
||||
isAI,
|
||||
isRobot,
|
||||
} = data;
|
||||
return (
|
||||
<Section title="Welcome" height="100%" stretchContents>
|
||||
@@ -45,8 +55,28 @@ export const LoginScreen = (_properties, context) => {
|
||||
icon="sign-in-alt"
|
||||
disabled={!scan}
|
||||
content="Login"
|
||||
onClick={() => act('login')}
|
||||
onClick={() => act('login', {
|
||||
login_type: 1,
|
||||
})}
|
||||
/>
|
||||
{!!isAI && (
|
||||
<Button
|
||||
icon="sign-in-alt"
|
||||
content="Login as AI"
|
||||
onClick={() => act('login', {
|
||||
login_type: 2,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
{!!isRobot && (
|
||||
<Button
|
||||
icon="sign-in-alt"
|
||||
content="Login as Cyborg"
|
||||
onClick={() => act('login', {
|
||||
login_type: 3,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
</Section>
|
||||
|
||||
Reference in New Issue
Block a user