Clockwerkslab

Doesnt work yet.
This commit is contained in:
Artur
2020-05-06 21:23:12 +03:00
parent 2ec9068cbf
commit f3ee184672
3 changed files with 159 additions and 138 deletions

View File

@@ -1,144 +1,165 @@
import { map } from 'common/collections';
import { Fragment } from 'inferno'; import { Fragment } from 'inferno';
import { useBackend, useSharedState } from '../backend'; import { useBackend } from '../backend';
import { Button, Flex, LabeledList, NoticeBox, Section, Tabs } from '../components'; import { Button, LabeledList, Section, Tabs, Input } from '../components';
import { Window } from '../layouts';
export const ClockworkSlab = (props, context) => {
const { act, data } = useBackend(context); export const ClockworkSlab = props => {
const { act, data } = useBackend(props);
const { const {
detail_view, recollection,
disk, rec_text,
has_disk, recollection_categories,
has_program, rec_section,
scriptures = {}, rec_binds,
} = data; } = data;
const [
selectedCategory,
setSelectedCategory,
] = useSharedState(context, 'category');
const scriptureInCategory = scriptures
&& scriptures[selectedCategory]
|| [];
return ( return (
<Window resizable> <Fragment theme="syndicate">
<Window.Content scrollable> <Section>
<Section
title="Program Disk"
buttons={(
<Fragment>
<Button <Button
icon="eject" content={recollection ? "Recital" : "Recollection"}
content="Eject" onClick={() => act('toggle')}
onClick={() => act('eject')} /> />
<Button
icon="minus-circle"
content="Delete Program"
onClick={() => act('clear')} />
</Fragment>
)}>
{has_disk ? (
has_program ? (
<LabeledList>
<LabeledList.Item label="Program Name">
{disk.name}
</LabeledList.Item>
<LabeledList.Item label="Description">
{disk.desc}
</LabeledList.Item>
</LabeledList>
) : (
<NoticeBox>
No Program Installed
</NoticeBox>
)
) : (
<NoticeBox>
Insert Disk
</NoticeBox>
)}
</Section> </Section>
<Section {!!recollection && (
title="Scripture" <Section title="Recollection">
buttons={( {rec_text}
<Fragment> {recollection_categories.map(categories => {
<Button
icon={detail_view ? 'info' : 'list'}
content={detail_view ? 'Detailed' : 'Compact'}
onClick={() => act('toggle_details')} />
<Button
icon="sync"
content="Sync Research"
onClick={() => act('refresh')} />
</Fragment>
)}>
{scriptures !== null ? (
<Flex>
<Flex.Item minWidth="110px">
<Tabs vertical>
{map((cat_contents, category) => {
const progs = cat_contents || [];
// Backend was sending stupid data that would have been
// annoying to fix
const tabLabel = category
.substring(0, category.length - 8);
return ( return (
<Tabs.Tab <Fragment key={categories.name} >
key={category} <br />
selected={category === selectedCategory} <Button
onClick={() => setSelectedCategory(category)}> content={`${categories.name} - ${categories.desc}`}
{tabLabel} onClick={() => act('rec_category', {
</Tabs.Tab> "category": categories.name,
})} />
</Fragment>
); );
})(scriptures)} })}
</Tabs> {rec_section}
</Flex.Item> {rec_binds}
<Flex.Item grow={1} basis={0}>
{detail_view ? (
scriptureInCategory.map(program => (
<Section
key={program.id}
title={program.name}
level={2}
buttons={(
<Button
icon="download"
content="Download"
disabled={!has_disk}
onClick={() => act('download', {
program_id: program.id,
})} />
)}>
{program.desc}
</Section> </Section>
)) )}
) : ( {recollection && (
<Fragment>
<Section title="Power">
{data.power}
</Section>
<Section title="Recital">
{data.tier_info}
{data.scripturecolors}
<Tabs>
<Tabs.Tab
key="driver"
label="Driver">
{() => (
<Section>
<LabeledList> <LabeledList>
{scriptureInCategory.map(program => ( {data.scripture.driver.map(script => {
return (
<LabeledList.Item <LabeledList.Item
key={program.id} key={script.name}
label={program.name} label={script.name}
buttons={( buttons={(
<Fragment>
<Button <Button
icon="download" content={`Recite (${script.required} W)`}
content="Download" onClick={() => act('recite', {
disabled={!has_disk} 'category': script.name,
onClick={() => act('download', {
program_id: program.id,
})} /> })} />
)} /> <Button
))} content={
script.quickbind
? `Unbind ${script.quickbind}`
: 'Quickbind'
}
onClick={() => act('bind', {
'category': script.name,
})} />
</Fragment>
)}>
{`${script.descname} ${script.invokers}`}
</LabeledList.Item>
);
})}
</LabeledList> </LabeledList>
)}
</Flex.Item>
</Flex>
) : (
<NoticeBox>
No nanite scriptures are currently researched.
</NoticeBox>
)}
</Section> </Section>
</Window.Content> )}
</Window> </Tabs.Tab>
<Tabs.Tab
key="script"
label="Script">
{() => (
<Section>
<LabeledList>
{data.scripture.script.map(script => {
return (
<LabeledList.Item
key={script.name}
label={script.name}
buttons={(
<Fragment>
<Button
content={`Recite (${script.required} W)`}
onClick={() => act('recite', {
'category': script.name,
})} />
<Button
content={script.quickbind
? `Unbind ${script.quickbind}`
: 'Quickbind'}
onClick={() => act('bind', {
'category': script.name,
})} />
</Fragment>
)}>
{`${script.descname} ${script.invokers}`}
</LabeledList.Item>
);
})}
</LabeledList>
</Section>
)}
</Tabs.Tab>
<Tabs.Tab
key="application"
label="Application">
{() => (
<Section>
<LabeledList>
{data.scripture.application.map(script => {
return (
<LabeledList.Item
key={script.name}
label={script.name}
buttons={(
<Fragment>
<Button
content={`Recite (${script.required} W)`}
onClick={() => act('recite', {
'category': script.name,
})} />
<Button
content={script.quickbind
? `Unbind ${script.quickbind}`
: 'Quickbind'}
onClick={() => act('bind', {
'category': script.name,
})} />
</Fragment>
)}>
{`${script.descname} ${script.invokers}`}
</LabeledList.Item>
);
})}
</LabeledList>
</Section>
)}
</Tabs.Tab>
</Tabs>
</Section>
</Fragment>
)}
</Fragment>
); );
}; };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long