import { classes } from 'common/react'; import { capitalize } from 'common/string'; import { useBackend, useLocalState } from '../backend'; import { Box, Button, ColorBox, Stack, LabeledList, Section, Tabs } from '../components'; import { Window } from '../layouts'; const ROOT_CATEGORIES = [ 'Atmospherics', 'Disposals', // 'Transit Tubes', ]; export const ICON_BY_CATEGORY_NAME = { 'Atmospherics': 'wrench', 'Disposals': 'trash-alt', 'Transit Tubes': 'bus', 'Pipes': 'grip-lines', 'Disposal Pipes': 'grip-lines', 'Devices': 'microchip', 'Heat Exchange': 'thermometer-half', 'Insulated pipes': 'snowflake', 'Station Equipment': 'microchip', }; const TOOLS = [ { name: 'Dispense', bitmask: 1, }, { name: 'Connect', bitmask: 2, }, { name: 'Destroy', bitmask: 4, }, { name: 'Paint', bitmask: 8, }, ]; const SelectionSection = (props, context) => { const { act, data } = useBackend(context); const { category: rootCategoryIndex, selected_color, mode } = data; return (
{ROOT_CATEGORIES.map((categoryName, i) => ( ))} {TOOLS.map((tool) => ( act('mode', { mode: tool.bitmask, }) } /> ))} {capitalize(selected_color)} {Object.keys(data.paint_colors).map((colorName) => ( act('color', { paint_color: colorName, }) } /> ))}
); }; const LayerSection = (props, context) => { const { act, data } = useBackend(context); const { category: rootCategoryIndex, piping_layer, pipe_layers } = data; const previews = data.preview_rows.flatMap((row) => row.previews); return (
{rootCategoryIndex === 0 && ( {Object.keys(pipe_layers).map((layer) => ( act('piping_layer', { piping_layer: pipe_layers[layer], }) } /> ))} )} {previews.map((preview) => ( ))}
); }; const PipeTypeSection = (props, context) => { const { act, data } = useBackend(context); const { categories = [] } = data; const [categoryName, setCategoryName] = useLocalState(context, 'categoryName'); const shownCategory = categories.find((category) => category.cat_name === categoryName) || categories[0]; return (
{categories.map((category, i) => ( setCategoryName(category.cat_name)}> {category.cat_name} ))} {shownCategory?.recipes.map((recipe) => ( act('pipe_type', { pipe_type: recipe.pipe_index, category: shownCategory.cat_name, }) } /> ))}
); }; export const RapidPipeDispenser = (props, context) => { const { act, data } = useBackend(context); const { category: rootCategoryIndex } = data; return ( ); };