Skip to content

Commit

Permalink
tgui stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
meemofcourse committed Sep 1, 2023
1 parent 8212a32 commit aebdbbc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 38 deletions.
6 changes: 6 additions & 0 deletions code/modules/paperwork/fax.dm
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
loaded_item_ref = null
update_icon()
return TRUE

if("send")
var/obj/item/loaded = loaded_item_ref?.resolve()
if(!loaded)
Expand All @@ -320,13 +321,16 @@
loaded_item_ref = null
update_icon()
return TRUE

if("send_special")
var/obj/item/paper/fax_paper = loaded_item_ref?.resolve()
if(!istype(fax_paper))
to_chat(usr, icon2html(src.icon, usr) + "<span class='warning'>ERROR: Failed to send fax.</span>")
return

fax_paper.request_state = TRUE
fax_paper.loc = null

INVOKE_ASYNC(src, PROC_REF(animate_object_travel), fax_paper, "fax_receive", find_overlay_state(fax_paper, "send"))
history_add("Send", params["name"])

Expand All @@ -340,10 +344,12 @@
fax.receive(fax_paper, fax_name)
break
update_appearance()

if("history_clear")
history_clear()
return TRUE


/**
* Records logs of bureacratic action
* Arguments:
Expand Down
97 changes: 80 additions & 17 deletions tgui/packages/tgui/interfaces/AdminFax.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { useBackend, useLocalState } from '../backend';
import { Section, Box, Dropdown, Button, Input, TextArea, Divider, NumberInput, Tooltip, Knob } from '../components';
import {
Section,
Box,
Dropdown,
Button,
Input,
TextArea,
Divider,
NumberInput,
Tooltip,
Knob,
} from '../components';
import { Window } from '../layouts';

export const AdminFax = (props, context) => {
Expand All @@ -21,8 +32,16 @@ export const FaxMainPanel = (props, context) => {
const [fromWho, setFromWho] = useLocalState(context, 'fromWho', '');
const [rawText, setRawText] = useLocalState(context, 'rawText', '');
const [stamp, setStamp] = useLocalState(context, 'stampType', '');
const [stampCoordX, setStampCoordX] = useLocalState(context, 'stampCoordX', 0);
const [stampCoordY, setStampCoordY] = useLocalState(context, 'stampCoordY', 0);
const [stampCoordX, setStampCoordX] = useLocalState(
context,
'stampCoordX',
0
);
const [stampCoordY, setStampCoordY] = useLocalState(
context,
'stampCoordY',
0
);
const [stampAngle, setStampAngle] = useLocalState(context, 'stampAngle', 0);
if (stamp && data.stamps[0] !== 'None') {
data.stamps.unshift('None');
Expand All @@ -40,11 +59,13 @@ export const FaxMainPanel = (props, context) => {
act('follow', {
faxName: fax,
})
}>
}
>
Follow
</Button>
</Box>
}>
}
>
<Box fontSize="13px">
<Dropdown
textAlign="center"
Expand All @@ -67,28 +88,62 @@ export const FaxMainPanel = (props, context) => {
act('preview', {
faxName: fax,
})
}>
}
>
Preview
</Button>
}>
}
>
<Box fontSize="14px">
<Input mb="5px" placeholder="Paper name..." value={paperName} width="100%" onChange={(_, v) => setPaperName(v)} />
<Button color="blue" fluid textAlign="center" onClick={() => setPaperName('Central Command Report')}>
<Input
mb="5px"
placeholder="Paper name..."
value={paperName}
width="100%"
onChange={(_, v) => setPaperName(v)}
/>
<Button
color="blue"
fluid
textAlign="center"
onClick={() => setPaperName('Central Command Report')}
>
Central Command Report
</Button>
<Button color="red" fluid textAlign="center" onClick={() => setPaperName('Syndicate Report')}>
<Button
color="red"
fluid
textAlign="center"
onClick={() => setPaperName('Syndicate Report')}
>
Syndicate Report
</Button>
</Box>
<Divider />
<Box fontSize="14px" mt="5px">
<Tooltip content="This is shown in the fax log.">
<Input mb="5px" placeholder="From who..." value={fromWho} width="100%" onChange={(_, v) => setFromWho(v)} />
<Input
mb="5px"
placeholder="From who..."
value={fromWho}
width="100%"
onChange={(_, v) => setFromWho(v)}
/>
</Tooltip>
<Button color="blue" fluid textAlign="center" onClick={() => setFromWho('Central Command')}>
<Button
color="blue"
fluid
textAlign="center"
onClick={() => setFromWho('Central Command')}
>
Central Command
</Button>
<Button color="red" fluid textAlign="center" onClick={() => setFromWho('Syndicate')}>
<Button
color="red"
fluid
textAlign="center"
onClick={() => setFromWho('Syndicate')}
>
Syndicate
</Button>
</Box>
Expand Down Expand Up @@ -133,7 +188,12 @@ export const FaxMainPanel = (props, context) => {

<h4>
Y Coordinate:{' '}
<NumberInput width="45px" minValue={0} value={stampCoordY} onChange={(_, v) => setStampCoordY(v)} />
<NumberInput
width="45px"
minValue={0}
value={stampCoordY}
onChange={(_, v) => setStampCoordY(v)}
/>
</h4>

<Box textAlign="center">
Expand Down Expand Up @@ -161,7 +221,8 @@ export const FaxMainPanel = (props, context) => {
act('send', {
faxName: fax,
})
}>
}
>
Send Fax
</Button>
<Button
Expand All @@ -180,7 +241,8 @@ export const FaxMainPanel = (props, context) => {
stampAngle: stampAngle,
fromWho: fromWho,
});
}}>
}}
>
Save Changes
</Button>
<Button
Expand All @@ -190,7 +252,8 @@ export const FaxMainPanel = (props, context) => {
act('createPaper', {
faxName: fax,
})
}>
}
>
Create Paper
</Button>
</Box>
Expand Down
12 changes: 6 additions & 6 deletions tgui/packages/tgui/interfaces/Fax.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type FaxData = {
fax_name: string;
visible: boolean;
has_paper: string;
frontier_network: boolean;
syndicate_network: boolean;
fax_history: FaxHistory[];
special_faxes: FaxSpecial[];
};
Expand All @@ -19,7 +19,7 @@ type FaxInfo = {
fax_id: string;
visible: boolean;
has_paper: boolean;
syndicate_network: boolean;
frontier_network: boolean;
};

type FaxHistory = {
Expand All @@ -40,11 +40,11 @@ export const Fax = (props, context) => {
const { data } = useBackend<FaxData>(context);
const faxes = data.faxes
? sortBy((sortFax: FaxInfo) => sortFax.fax_name)(
data.frontier_network
data.syndicate_network
? data.faxes.filter((filterFax: FaxInfo) => filterFax.visible)
: data.faxes.filter(
(filterFax: FaxInfo) =>
filterFax.visible && !filterFax.syndicate_network
filterFax.visible && !filterFax.frontier_network
)
)
: [];
Expand Down Expand Up @@ -82,7 +82,7 @@ export const Fax = (props, context) => {
<Section title="Send">
{faxes.length !== 0 ? (
<Box mt={0.4}>
{(data.frontier_network
{(data.syndicate_network
? data.special_faxes
: data.special_faxes.filter(
(fax: FaxSpecial) => !fax.emag_needed
Expand All @@ -108,7 +108,7 @@ export const Fax = (props, context) => {
key={fax.fax_id}
title={fax.fax_name}
disabled={!data.has_paper}
color={fax.syndicate_network ? 'red' : 'blue'}
color={fax.frontier_network ? 'red' : 'blue'}
onClick={() =>
act('send', {
id: fax.fax_id,
Expand Down
27 changes: 17 additions & 10 deletions tgui/packages/tgui/interfaces/RequestManager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @file
* @copyright 2021 bobbahbrown (https://github.com/bobbahbrown)
* @license MIT
*/
* @file
* @copyright 2021 bobbahbrown (https://github.com/bobbahbrown)
* @license MIT
*/

import { decodeHtmlEntities } from 'common/string';
import { useBackend, useLocalState } from '../backend';
Expand Down Expand Up @@ -32,8 +32,8 @@ export const RequestManager = (props, context) => {
(request) =>
decodeHtmlEntities(request.message)
.toLowerCase()
.includes(filterText)
|| request.owner_name.toLowerCase().includes(filterText)
.includes(filterText) ||
request.owner_name.toLowerCase().includes(filterText)
);
}

Expand All @@ -52,7 +52,8 @@ export const RequestManager = (props, context) => {
/>
<FilterPanel />
</>
}>
}
>
{displayedRequests.map((request) => (
<div className="RequestManager__row" key={request.id}>
<div className="RequestManager__rowContents">
Expand Down Expand Up @@ -84,6 +85,7 @@ const displayTypeMap = {
'request_centcom': 'CENTCOM',
'request_syndicate': 'SYNDICATE',
'request_nuke': 'NUKE CODE',
'request_fax': 'FAX',
};

const RequestType = (props) => {
Expand Down Expand Up @@ -117,6 +119,9 @@ const RequestControls = (props, context) => {
SETCODE
</Button>
)}
{request.req_type === 'request_fax' && (
<Button onClick={() => act('show', { id: request.id })}>SHOW</Button>
)}
</div>
);
};
Expand Down Expand Up @@ -145,7 +150,8 @@ const FilterPanel = (_, context) => {
className="RequestManager__filterPanel"
style={{
display: filterVisible ? 'block' : 'none',
}}>
}}
>
<Table width="0">
{Object.keys(displayTypeMap).map((type) => {
return (
Expand All @@ -168,10 +174,11 @@ const FilterPanel = (_, context) => {
})}
</Table>
</div>
}>
}
>
<Button icon="cog" onClick={() => setFilterVisible(!filterVisible)}>
Type Filter
</Button>
</Popper>
);
};
};
5 changes: 0 additions & 5 deletions tgui/packages/tgui/styles/interfaces/RequestManager.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ $color-centcom: colors.bg(colors.$yellow) !default;
$color-syndicate: colors.bg(colors.$red) !default;
$color-nuke: colors.bg(colors.$yellow) !default;
$color-fax: colors.bg(colors.$green) !default;
$color-music: colors.bg(colors.$teal) !default;
$color-muted: colors.bg(colors.$label) !default;
$color-header: colors.bg(colors.$label) !default;
$background-color: base.$color-bg-section !default;
Expand Down Expand Up @@ -45,10 +44,6 @@ $text-color: base.$color-fg !default;
color: $color-fax;
}

.RequestManager__request_internet_sound {
color: $color-music;
}

.RequestManager__header {
line-height: 1.375rem;
min-height: 1.375rem;
Expand Down

0 comments on commit aebdbbc

Please sign in to comment.