import { toTitleCase } from 'common/string'; import { Fragment } from 'inferno'; import { useBackend, useLocalState, useSharedState } from '../backend'; import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Section, Tabs, Input, NumberInput, Table, Divider } from '../components'; import { Window } from '../layouts'; const ResearchConsoleViewResearch = (props, context) => { const { act, data } = useBackend(context); const { tech } = data; return (
act('print', { print: 1 })}> Print This Page }> {tech.map((thing) => ( {thing.name} - Level {thing.level} {thing.desc} ))}
); }; const PaginationTitle = (props, context) => { const { data } = useBackend(context); const { title, target } = props; let page = data[target]; if (typeof page === 'number') { return title + ' - Page ' + (page + 1); } return title; }; const PaginationChevrons = (props, context) => { const { act } = useBackend(context); const { target } = props; return ( { || null} }> act('search', { search: v })} mb={1} /> {(designs && designs.length && ( {designs.map((design) => ( {design.desc} ))} )) || No designs found.} ); }; const TechDisk = (props, context) => { const { act, data } = useBackend(context); const { tech } = data; const { disk } = props; if (!disk || !disk.present) { return null; } const [saveDialog, setSaveDialog] = useSharedState(context, 'saveDialogTech', false); if (saveDialog) { return (
setSaveDialog(false)} />}> {tech.map((level) => ( ))}
); } return ( (Technology Data Disk) {(disk.stored && ( {disk.name} Level: {disk.level} Description: {disk.desc} )) || ( This disk has no data stored on it. )} ); }; const DataDisk = (props, context) => { const { act, data } = useBackend(context); const { designs } = data.info; const { disk } = props; if (!disk || !disk.present) { return null; } const [saveDialog, setSaveDialog] = useSharedState(context, 'saveDialogData', false); if (saveDialog) { return (
} buttons={ ))}
); } return ( {(disk.stored && ( {disk.name} {disk.build_type} {Object.keys(disk.materials).map((mat) => ( {mat} x {disk.materials[mat]} ))} )) || ( This disk has no data stored on it. )} ); }; const ResearchConsoleDisk = (props, context) => { const { act, data } = useBackend(context); const { d_disk, t_disk } = data.info; if (!d_disk.present && !t_disk.present) { return
No disk inserted.
; } return (
); }; const ResearchConsoleDestructiveAnalyzer = (props, context) => { const { act, data } = useBackend(context); const { linked_destroy } = data.info; if (!linked_destroy.present) { return
No destructive analyzer found.
; } const { loaded_item, origin_tech } = linked_destroy; return (
{(loaded_item && ( {loaded_item} {(origin_tech.length && origin_tech.map((tech) => ( {tech.level}  {tech.current && '(Current: ' + tech.current + ')'} ))) || No origin tech found.} )) || No Item Loaded. Standing-by...}
); }; const ResearchConsoleBuildMenu = (props, context) => { const { act, data } = useBackend(context); const { target, designs, buildName, buildFiveName } = props; if (!target) { return Error; } return (
} buttons={}> act('search', { search: v })} mb={1} /> {designs && designs.length ? ( designs.map((design) => ( {design.name} {buildFiveName && ( )} {design.mat_list.join(' ')} {design.chem_list.join(' ')} )) ) : ( No items could be found matching the parameters (page or search). )}
); }; /* Lathe + Circuit Imprinter all in one */ const ResearchConsoleConstructor = (props, context) => { const { act, data } = useBackend(context); const { name } = props; let linked = null; let designs = null; if (name === 'Protolathe') { linked = data.info.linked_lathe; designs = data.lathe_designs; } else { linked = data.info.linked_imprinter; designs = data.imprinter_designs; } if (!linked || !linked.present) { return
No {name} found.
; } const { total_materials, max_materials, total_volume, max_volume, busy, mats, reagents, queue } = linked; const [protoTab, setProtoTab] = useSharedState(context, 'protoTab', 0); let queueColor = 'transparent'; let queueSpin = false; let queueIcon = 'layer-group'; if (busy) { queueIcon = 'hammer'; queueColor = 'average'; queueSpin = true; } else if (queue && queue.length) { queueIcon = 'sync'; queueColor = 'green'; queueSpin = true; } // Proto vs Circuit differences let removeQueueAction = name === 'Protolathe' ? 'removeP' : 'removeI'; let ejectSheetAction = name === 'Protolathe' ? 'lathe_ejectsheet' : 'imprinter_ejectsheet'; let ejectChemAction = name === 'Protolathe' ? 'disposeP' : 'disposeI'; let ejectAllChemAction = name === 'Protolathe' ? 'disposeallP' : 'disposeallI'; return (
) || null}> {total_materials} cm³ / {max_materials} cm³ {total_volume}u / {max_volume}u setProtoTab(0)}> Build setProtoTab(1)}> Queue setProtoTab(2)}> Mat Storage setProtoTab(3)}> Chem Storage {(protoTab === 0 && ( )) || (protoTab === 1 && ( {(queue.length && queue.map((item) => { if (item.index === 1) { return ( {!busy ? ( (Awaiting Materials) ) : ( )} ); } return ( ); })) || Queue Empty.} )) || (protoTab === 2 && ( {mats.map((mat) => { const [ejectAmt, setEjectAmt] = useLocalState(context, 'ejectAmt' + mat.name, 0); return ( setEjectAmt(val)} /> }> {mat.amount} cm³ ); })} )) || (protoTab === 3 && ( {(reagents.length && reagents.map((chem) => ( {chem.volume}u ))) || No chems detected} )) || Error}
); }; const ResearchConsoleSettings = (props, context) => { const { act, data } = useBackend(context); const { sync, linked_destroy, linked_imprinter, linked_lathe } = data.info; const [settingsTab, setSettingsTab] = useSharedState(context, 'settingsTab', 0); return (
setSettingsTab(0)} selected={settingsTab === 0}> General setSettingsTab(1)} selected={settingsTab === 1}> Device Linkages {(settingsTab === 0 && ( {(sync && ( )) || ( )} )) || (settingsTab === 1 && ( {(linked_destroy.present && ( )) || null} {(linked_lathe.present && ( )) || null} {(linked_imprinter.present && ( )) || null} )) || Error}
); }; const menus = [ { name: 'Protolathe', icon: 'wrench', template: }, { name: 'Circuit Imprinter', icon: 'digital-tachograph', template: , }, { name: 'Destructive Analyzer', icon: 'eraser', template: }, { name: 'Settings', icon: 'cog', template: }, { name: 'Research List', icon: 'flask', template: }, { name: 'Design List', icon: 'file', template: }, { name: 'Disk Operations', icon: 'save', template: }, ]; export const ResearchConsole = (props, context) => { const { act, data } = useBackend(context); const { busy_msg, locked } = data; const [menu, setMenu] = useSharedState(context, 'rdmenu', 0); let allTabsDisabled = false; if (busy_msg || locked) { allTabsDisabled = true; } return ( {menus.map((obj, i) => ( setMenu(i)}> {obj.name} ))} {(busy_msg &&
{busy_msg}
) || (locked && (
)) || menus[menu].template}
); };