aotds-docks/src/routes/(editor)/export/print/PrintShip/index.svelte

158 lines
3.6 KiB
Svelte
Raw Normal View History

2023-05-08 19:20:17 +00:00
<div class="disclaimer">
Printing this page will only prints the ship sheet.
</div>
2023-04-25 18:50:15 +00:00
<div class="print-output">
2023-04-26 13:53:22 +00:00
<Identification {...identification} />
2023-04-25 18:50:15 +00:00
2023-05-12 14:48:53 +00:00
<div class="weapon-group">
{#each smrs as smr (smr.id)}
<SalvoMissileRack {...smr.specs} />
{/each}
</div>
<div class="weapon-group">
<HeavyMissiles {heavyMissiles} />
</div>
2023-05-11 20:18:19 +00:00
2023-05-14 21:51:26 +00:00
<div class="weapon-group">
{#each Object.keys(smls) as magId (magId)}
<SML
launchers={smls[magId].map(R.prop("specs"))}
magazine={magazines.find(({ id }) => id == magId)}
/>
{/each}
</div>
2023-05-08 19:20:17 +00:00
<Beams {beams} />
2023-04-28 15:18:31 +00:00
<Weapons {weapons} />
2023-04-27 16:17:08 +00:00
<div class="grid">
<div class="s6">
<Armor layers={structure?.armor?.layers} />
<Hull
2023-04-30 16:08:42 +00:00
shipMass={identification.reqs?.mass}
2023-04-27 16:17:08 +00:00
advanced={false}
rating={structure.hull?.rating}
/>
</div>
<div class="s6">
2023-05-08 19:20:17 +00:00
<div>
{#each pds as p (p.id)}
<PDS {...pds} />
{/each}
</div>
2023-04-28 15:18:31 +00:00
<Firecons {...firecons} />
2023-05-08 19:20:17 +00:00
<Screens {...screens} />
2023-04-27 16:17:08 +00:00
</div>
</div>
2023-04-26 13:35:46 +00:00
2023-04-26 13:53:22 +00:00
<MainSystems {...propulsion} />
2023-04-30 16:08:42 +00:00
<Cargo {...cargo} />
2023-04-25 18:50:15 +00:00
</div>
<script>
2023-05-08 19:20:17 +00:00
import u from "@yanick/updeep-remeda";
2023-04-26 13:53:22 +00:00
import Identification from "./Identification.svelte";
import MainSystems from "./MainSystems/index.svelte";
2023-04-26 20:11:49 +00:00
import Hull from "./Hull/index.svelte";
2023-04-27 16:17:08 +00:00
import Armor from "./Armor/index.svelte";
import Screens from "./Screens/index.svelte";
2023-04-28 15:18:31 +00:00
import Firecons from "./Firecons/index.svelte";
import Weapons from "./Weapons/index.svelte";
2023-04-30 16:08:42 +00:00
import Cargo from "./Cargo.svelte";
2023-05-08 19:20:17 +00:00
import PDS from "./Weapons/PDS.svelte";
import Beams from "./Weapons/Beams.svelte";
2023-05-11 20:18:19 +00:00
import HeavyMissiles from "./Weapons/HeavyMissiles.svelte";
2023-05-12 14:48:53 +00:00
import SalvoMissileRack from "./Weapons/SMR/index.svelte";
2023-05-14 21:51:26 +00:00
import SML from "./Weapons/SML/index.svelte";
import * as R from "remeda";
2023-04-25 18:50:15 +00:00
export let identification = {};
export let propulsion = {};
2023-04-26 20:11:49 +00:00
export let structure = {};
2023-04-28 15:18:31 +00:00
export let weaponry = {};
2023-04-27 16:17:08 +00:00
2023-04-30 16:08:42 +00:00
$: cargo = structure.cargo ?? {};
2023-04-27 16:17:08 +00:00
$: screens = structure?.screens ?? {};
2023-04-28 15:18:31 +00:00
$: firecons = weaponry?.firecons ?? {};
$: weapons = weaponry?.weapons ?? [];
2023-05-08 19:20:17 +00:00
$: weapons = u.reject(
weapons,
2023-05-11 20:18:19 +00:00
u.matches({
2023-05-12 14:48:53 +00:00
specs: {
2023-05-14 21:51:26 +00:00
type: (t) => ["sml", "smr", "pds", "beam", "heavyMissile"].includes(t),
2023-05-12 14:48:53 +00:00
},
2023-05-11 20:18:19 +00:00
})
2023-05-08 19:20:17 +00:00
);
2023-05-14 21:51:26 +00:00
$: magazines = weaponry.missileMagazines;
$: console.log({ magazines });
2023-05-08 19:20:17 +00:00
$: pds = (weaponry?.weapons ?? []).filter(
u.matches({ specs: { type: "pds" } })
);
$: beams = (weaponry?.weapons ?? []).filter(
u.matches({ specs: { type: "beam" } })
);
2023-05-11 20:18:19 +00:00
$: heavyMissiles = (weaponry?.weapons ?? []).filter(
2023-05-12 14:48:53 +00:00
u.matches({ specs: { type: "heavyMissile" } })
);
$: smrs = (weaponry?.weapons ?? []).filter(
u.matches({ specs: { type: "smr" } })
2023-05-11 20:18:19 +00:00
);
2023-05-14 21:51:26 +00:00
$: console.log(
(weaponry?.weapons ?? []).filter(u.matches({ specs: { type: "sml" } }))
);
$: smls = R.groupBy(
(weaponry?.weapons ?? []).filter(u.matches({ specs: { type: "sml" } })),
({ specs: { missileMagazineId } }) => missileMagazineId
);
$: console.log({ smls });
2023-04-25 18:50:15 +00:00
</script>
<style>
.print-output {
2023-05-08 19:20:17 +00:00
width: 5.5in;
height: 8.5in;
2023-04-25 18:50:15 +00:00
border: 1px solid black;
padding: 1em;
margin: 0px auto;
}
2023-04-26 13:53:22 +00:00
@media print {
:global(body > *) {
visibility: hidden;
}
2023-04-25 18:50:15 +00:00
2023-04-26 13:53:22 +00:00
.print-output {
visibility: visible;
2023-05-08 19:20:17 +00:00
width: inherit;
height: inherit;
2023-04-26 13:53:22 +00:00
}
}
2023-04-27 16:17:08 +00:00
.s6 {
display: flex;
flex-direction: column;
align-items: center;
}
2023-04-28 15:18:31 +00:00
.s6 :global(> div) {
margin-bottom: 1em;
}
2023-05-08 19:20:17 +00:00
.disclaimer {
text-align: center;
margin-bottom: 1rem;
}
2023-05-12 14:48:53 +00:00
.weapon-group {
display: flex;
justify-content: center;
margin-bottom: 1em;
}
2023-04-25 18:50:15 +00:00
</style>