Skip to content

Commit

Permalink
аывпавпы
Browse files Browse the repository at this point in the history
  • Loading branch information
Anorak2024 committed Aug 30, 2024
1 parent b45189a commit e39ff30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 56 deletions.
20 changes: 2 additions & 18 deletions code/game/machinery/customat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,6 @@

/obj/machinery/customat/ui_static_data(mob/user)
var/list/data = list()
data["products"] = list()
var/i = 1
for (var/datum/data/customat_product/product in products)
var/list/data_pr = list(
key = product.key,
name = product.name,
amount = product.amount,
is_hidden = FALSE,
inum = i
)
data["products"] += list(data_pr)
i++
return data

/obj/machinery/customat/ui_act(action, params)
Expand All @@ -504,12 +492,8 @@
if(panel_open)
to_chat(usr, span_warning("The vending machine cannot dispense products while its service panel is open!"))
return
var/key = text2num(params["inum"])
var/list/display_records = products
if(key < 1 || key > length(display_records))
to_chat(usr, span_warning("ERROR: invalid inum passed to vendor. Report this bug."))
return
var/datum/data/customat_product/product = display_records[key]
var/key = text2num(params["key"])
var/datum/data/customat_product/product = products[key]
if(!istype(product))
to_chat(usr, span_warning("ERROR: unknown vending_product record. Report this bug."))
return
Expand Down
43 changes: 6 additions & 37 deletions tgui/packages/tgui/interfaces/Customat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { useBackend } from '../backend';
import { Box, Button, Section, Stack, Table } from '../components';
import { Window } from '../layouts';

const VendingRow = (props, context) => {
const CustomatRow = (props, context) => {
const { act, data } = useBackend(context);
const { product, productStock, productImage } = props;
const {
chargesMoney,
user,
userMoney,
vend_ready,
inserted_item_name,
} = data;
const free = !chargesMoney || product.price === 0;
const free = product.price === 0;
let buttonText = 'ERROR!';
let rowIcon = '';
if (free) {
Expand Down Expand Up @@ -60,7 +58,7 @@ const VendingRow = (props, context) => {
textAlign="left"
onClick={() =>
act('vend', {
'inum': product.inum,
'key': product.key,
})
}
/>
Expand All @@ -69,18 +67,17 @@ const VendingRow = (props, context) => {
);
};


export const Customat = (props, context) => {
const { act, data } = useBackend(context);
const {
user,
guestNotice,
userMoney,
chargesMoney,
products = [],
user,
stock,
icons,
vend_ready,
inserted_item_name,
panel_open,
speaker,
} = data;
Expand All @@ -98,34 +95,6 @@ export const Customat = (props, context) => {
<Window.Content>
<Stack fill vertical>
<Stack.Item>
{!!chargesMoney && (
<Section title="User">
{(user && (
<Box>
Welcome, <b>{user.name}</b>,{' '}
<b>{user.job || 'Unemployed'}</b>
!
<br />
Your balance is <b>{userMoney} credits</b>.
</Box>
)) || <Box color="light-grey">{guestNotice}</Box>}
</Section>
)}
{!!inserted_item_name && (
<Section
title="Item"
buttons={
<Button
fluid
icon="eject"
content="Eject Item"
onClick={() => act('eject_item', {})}
/>
}
>
<Box>{inserted_item_name}</Box>
</Section>
)}
{!!panel_open && (
<Section title="Maintenance">
<Button
Expand All @@ -142,7 +111,7 @@ export const Customat = (props, context) => {
<Section title="Products" fill scrollable>
<Table>
{inventory.map((product) => (
<VendingRow
<CustomatRow
key={product.key}
product={product}
productStock={stock[product.key]}
Expand Down
2 changes: 1 addition & 1 deletion tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit e39ff30

Please sign in to comment.