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

Tweak Photocopier 2.0 #718

Merged
merged 7 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 5 additions & 1 deletion modular_ss220/bureaucracy/code/photocopier.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/obj/machinery/photocopier
toner = 30
/// Selected form's category
var/category = ""
/// Selected form's id
Expand Down Expand Up @@ -54,6 +55,8 @@
if("choose_category")
category = params["category"]
. = TRUE
if("copies")
copies = clamp(text2num(params["new"]), 0, maxcopies)

/obj/machinery/photocopier/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
Expand All @@ -68,7 +71,8 @@
var/list/data = list()

data["isAI"] = issilicon(user)
data["copynumber"] = copies
data["copies"] = copies
data["maxcopies"] = maxcopies
data["toner"] = toner
data["copyitem"] = (copyitem ? copyitem.name : null)
data["folder"] = (folder ? folder.name : null)
Expand Down
156 changes: 79 additions & 77 deletions tgui/packages/tgui/interfaces/Photocopier220.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useBackend, useLocalState } from '../backend';
import { Button, Section, Flex, Input } from '../components';
import {
Button,
Section,
Flex,
Input,
Slider,
ProgressBar,
} from '../components';
import { Window } from '../layouts';
import { filter, sortBy } from 'common/collections';
import { FlexItem } from '../components/Flex';
Expand All @@ -22,6 +29,8 @@ const selectForms = (forms, searchText = '') => {
export const Photocopier220 = (props, context) => {
const { act, data } = useBackend(context);

const { copies, maxcopies } = data;

const [searchText, setSearchText] = useLocalState(context, 'searchText', '');

const forms = selectForms(
Expand All @@ -34,6 +43,7 @@ export const Photocopier220 = (props, context) => {
categories.push(form.category);
}
}
const [number, setNumber] = useLocalState(context, 'number', 0);

let category;
if (data.category === '') {
Expand All @@ -46,22 +56,18 @@ export const Photocopier220 = (props, context) => {
<Window theme={data.ui_theme}>
<Window.Content scrollable display="flex">
<Flex direction="row" spacing={1}>
<Flex.Item width={24} shrink={0}>
<Flex.Item basis="35%">
<Section title="Статус">
<Flex>
<Flex.Item mr="20px" color="grey">
<Flex.Item width="50%" mt={0.8} color="grey">
Заряд тонера:
</Flex.Item>
<Flex.Item
mr="5px"
color={data.toner > 0 ? 'good' : 'bad'}
bold
>
{data.toner}
<Flex.Item width="50%" mt={0.5}>
<ProgressBar minValue={0} maxValue={30} value={data.toner} />
</Flex.Item>
</Flex>
<Flex>
<Flex.Item width="100%" mt="8px">
<Flex.Item width="100%" mt={2}>
<Button
fluid
textAlign="center"
Expand Down Expand Up @@ -91,7 +97,7 @@ export const Photocopier220 = (props, context) => {
</Section>
<Section title="Управление">
<Flex>
<Flex.Item width="60%" mr="3px">
<Flex.Item grow={1} basis={0} mr="2px">
<Button
fluid
textAlign="center"
Expand All @@ -101,7 +107,7 @@ export const Photocopier220 = (props, context) => {
onClick={() => act('copy')}
/>
</Flex.Item>
<Flex.Item width="40%" mr="3px">
<Flex.Item grow={1} basis={0} ml="2px">
<Button
fluid
textAlign="center"
Expand All @@ -127,102 +133,98 @@ export const Photocopier220 = (props, context) => {
</Flex.Item>
</Flex>
<Flex>
<Flex.Item mr="10px" mt="10px" color="grey">
<Flex.Item mr="10px" mt={1.2} color="grey">
Количество:
</Flex.Item>
<Flex.Item mr="15px" mt="10px">
{data.copynumber}
</Flex.Item>
<Flex.Item mr="3px" mt="8px">
<Button
fluid
icon="minus"
textAlign="center"
disabled={data.copynumber === 1}
content=""
onClick={() => act('minus')}
/>
</Flex.Item>
<Flex.Item mr="3px" mt="8px">
<Button
fluid
icon="plus"
textAlign="center"
disabled={data.copynumber >= data.toner}
content=""
onClick={() => act('add')}
/>
</Flex.Item>
<Slider
ml={3.25}
mt={0.75}
animated
minValue={1}
maxValue={maxcopies}
value={copies}
onChange={(e, value) =>
act('copies', {
new: value,
})
}
/>
</Flex>
</Section>
<Section title="Бюрократия">
<Flex>
<Flex.Item mr="20px" color="grey">
Форма:
</Flex.Item>
<FlexItem bold>
{data.form_id === '' ? 'Не выбрана' : data.form_id}
</FlexItem>
</Flex>
<Flex direction="column" mt={2}>
<Flex.Item>
<Button
fluid
icon="chevron-right"
content="Все формы"
selected={data.category === '' ? 'selected' : null}
onClick={() =>
act('choose_category', {
category: null,
})
}
mb={1}
/>
</Flex.Item>
{categories.map((category) => (
<Flex.Item key={category}>
<Flex.Item className="Layout__content--flexColumn" height="355px">
<Section title="Бюрократия" flexGrow="1">
<Flex>
<Flex.Item mr={2} color="grey">
Форма:
</Flex.Item>
<FlexItem bold>
{data.form_id === '' ? 'Не выбрана' : data.form_id}
</FlexItem>
</Flex>
<Flex direction="column" mt={2}>
<Flex.Item>
<Button
mb={1}
mt={0.5}
fluid
key={category}
icon="chevron-right"
content={category}
selected={data.category === category ? 'selected' : null}
content="Все формы"
selected={!data.category}
onClick={() =>
act('choose_category', {
category: category,
category: null,
})
}
mb={1}
/>
</Flex.Item>
))}
</Flex>
</Section>
{categories.map((category) => (
<Flex.Item key={category}>
<Button
mb={1}
fluid
key={category}
icon="chevron-right"
content={category}
selected={
data.category === category ? 'selected' : null
AyIong marked this conversation as resolved.
Show resolved Hide resolved
}
onClick={() =>
act('choose_category', {
category: category,
})
}
/>
</Flex.Item>
))}
</Flex>
</Section>
</Flex.Item>
</Flex.Item>
<Flex.Item width={35}>
<Section title={data.category === '' ? 'Все формы' : data.category}>
<Flex.Item basis="65%" className="Layout__content--flexColumn">
<Section
title={data.category === '' ? 'Все формы' : data.category}
AyIong marked this conversation as resolved.
Show resolved Hide resolved
flexGrow="1"
>
<Input
fluid
mb={1}
placeholder="Поиск формы"
onInput={(e, value) => setSearchText(value)}
/>
<Flex direction="column" mt={2}>
<Flex direction="column" mt={1.6} wrap="wrap">
{category.map((form) => (
<Flex.Item key={form.path}>
<Button
mb={1}
fluid
key={form.path}
content={form.id + ': ' + form.altername.trimLongStr(27)}
tooltip={form.id + ': ' + form.altername}
content={form.id + ': ' + form.altername.trimLongStr(37)}
selected={data.form_id === form.id ? 'selected' : null}
AyIong marked this conversation as resolved.
Show resolved Hide resolved
onClick={() =>
act('choose_form', {
path: form.path,
id: form.id,
})
}
mb={1}
/>
</Flex.Item>
))}
Expand Down
6 changes: 3 additions & 3 deletions tgui/packages/tgui/public/tgui.bundle.js

Large diffs are not rendered by default.