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

Optimizes and declutters the requests panel #16245

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -535,7 +545,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 @@ -547,7 +560,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 @@ -559,7 +575,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
Loading