Add Acceleration Segment + Improved Thrust calculation

This commit is contained in:
Neshura 2024-05-24 12:37:31 +02:00
parent 90085dd87a
commit 986cf8453e
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
9 changed files with 288 additions and 138 deletions
src/lib/cards

View file

@ -0,0 +1,50 @@
<svelte:options runes />
<script>
import {applyUnits, Localization} from "$lib/constants";
import {Separator} from "$lib/components/ui/separator";
import NewInventory from "$lib/components/NewInventory.svelte";
import InventoryList from "$lib/components/InventoryList.svelte";
import {Label} from "$lib/components/ui/label";
import {Input} from "$lib/components/ui/input";
import * as Card from "$lib/components/ui/card";
import NewThruster from "$lib/components/NewThruster.svelte";
import ThrusterList from "$lib/components/ThrusterList.svelte";
let { i18n = new Localization("en-GB"), ship, atmosphericDensity, onAddThruster, onRemoveThruster } = $props();
let valid = $derived.by(() => {
let valids = [];
valids[0] = typeof ship !== "undefined";
valids[1] = typeof atmosphericDensity !== "undefined";
valids[2] = typeof onAddThruster !== "undefined";
valids[3] = typeof onRemoveThruster !== "undefined";
return !valids.includes(false);
});
</script>
{#if valid}
<Card.Root class="flex-1 flex flex-col flex-grow">
<Card.Header>
<Card.Title>{i18n.localize("thrusterSettings")}</Card.Title>
</Card.Header>
<Card.Content class="flex flex-col flex-grow gap-3">
<Separator />
<Card.Root>
<Card.Content class="flex flex-col gap-3 pt-6">
<NewThruster i18n={i18n} {onAddThruster} />
</Card.Content>
</Card.Root>
<Card.Root class="flex flex-col h-60 flex-grow">
<Card.Header>
<Card.Title>{i18n.localize("thrusters")} ({applyUnits(i18n, ship.getTotalThrust(atmosphericDensity), "N")})</Card.Title>
</Card.Header>
<Card.Content class="flex flex-col gap-3 overflow-hidden">
<Separator />
<ThrusterList i18n={i18n} thrusters={ship.thrusters} {onRemoveThruster} grid={ship.grid} atmosphere={atmosphericDensity}/>
</Card.Content>
</Card.Root>
</Card.Content>
</Card.Root>
{/if}