Skip to content

Commit

Permalink
Optimizes and declutters the requests panel (#16245)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ldip999 committed Jul 6, 2024
1 parent d5c5fd6 commit 6bddc24
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
33 changes: 26 additions & 7 deletions code/modules/reqs/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/cost = 0
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
packs += SP.type
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["requests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
.["deniedrequests"] = list()
Expand All @@ -345,7 +348,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/cost = 0
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
packs += SP.type
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["deniedrequests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
.["approvedrequests"] = list()
Expand All @@ -355,8 +361,12 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
continue
var/list/packs = list()
var/cost = 0
for(var/datum/supply_packs/SP AS in SO.pack)
packs += SP.type
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["approvedrequests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
.["awaiting_delivery"] = list()
Expand Down Expand Up @@ -537,7 +547,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/cost = 0
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
packs += SP.type
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["requests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
.["deniedrequests"] = list()
Expand All @@ -549,7 +562,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/cost = 0
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
packs += SP.type
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["deniedrequests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
.["approvedrequests"] = list()
Expand All @@ -561,7 +577,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list(
var/cost = 0
for(var/P in SO.pack)
var/datum/supply_packs/SP = P
packs += SP.type
if(packs[SP.type])
packs[SP.type] += 1
else
packs[SP.type] = 1
cost += SP.cost
.["approvedrequests"] += list(list("id" = SO.id, "orderer" = SO.orderer, "orderer_rank" = SO.orderer_rank, "reason" = SO.reason, "cost" = cost, "packs" = packs, "authed_by" = SO.authorised_by))
if(!SSpoints.request_shopping_cart[user.ckey])
Expand Down
19 changes: 11 additions & 8 deletions tgui/packages/tgui/interfaces/Cargo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Cargo = (props) => {
: null;

return (
<Window width={900} height={700}>
<Window width={1100} height={700}>
<Flex height="650px" align="stretch">
<Flex.Item width="280px">
<Menu />
Expand Down Expand Up @@ -309,18 +309,21 @@ const Packs = (props) => {
const { act, data } = useBackend();
const { packs } = props;

return packs.map((pack) => <Pack pack={pack} key={pack} />);
return Object.keys(packs).map((pack) => (
<Pack pack={pack} key={pack} amount={packs[pack]} />
));
};

const Pack = (props) => {
const { act, data } = useBackend();
const { pack } = props;
const { pack, amount } = props;
const { supplypackscontents } = data;
const { name, cost, contains } = supplypackscontents[pack];

return !!contains && contains.constructor === Object ? (
<Collapsible
color="gray"
title={<PackName cost={cost} name={name} pl={0} />}
title={<PackName cost={cost} name={name} pl={0} amount={amount} />}
>
<Table>
<PackContents contains={contains} />
Expand All @@ -332,12 +335,12 @@ const Pack = (props) => {
};

const PackName = (props) => {
const { cost, name, pl } = props;

const { cost, name, pl, amount } = props;
return (
<Box inline pl={pl}>
<Box textAlign="right" inline width="65px">
{cost} points
<Box textAlign="right" inline width="140px">
{amount ? amount + 'x' : ''}
{cost} points {amount ? '(' + amount * cost + ')' : ''}
</Box>
<Box width="15px" inline />
<Box inline>{name}</Box>
Expand Down

0 comments on commit 6bddc24

Please sign in to comment.