Skip to content

Commit

Permalink
add ability to hide weapon talents
Browse files Browse the repository at this point in the history
  • Loading branch information
atomicptr committed Dec 10, 2024
1 parent 740a422 commit 8ff0b89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
54 changes: 32 additions & 22 deletions src/lib/components/TalentList.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { page } from "$app/stores";
import type { BuildWeapon } from "$lib/build/Build";
import { configViewWeaponTalents } from "$lib/state.svelte";
import { translatableString } from "$lib/utils/translatable-string";
import TalentOptionText from "./TalentOptionText.svelte";
Expand All @@ -11,35 +12,44 @@ interface Props {
const { selected }: Props = $props();
const weaponData = $derived(selected.id !== 0 ? $page.data.weapons[selected.id] : null);
const available = $derived(selected.talents.some((options) => options.some((v) => v)));
const toggleOpen = () => {
configViewWeaponTalents.set(!$configViewWeaponTalents);
};
</script>

{#if available}
<div>
<div class="text-xl mb-4">
Talents
<div class="flex flex-row justify-between text-xl mt-4">
<div>Talents</div>
<button class="btn btn-xs btn-ghost" onclick={toggleOpen}>
{#if $configViewWeaponTalents}-{:else}+{/if}
</button>
</div>
{#each selected.talents as row, rowIndex}
{#if selected.talents[rowIndex].some(v => v)}
<ul class="list-disc pl-4">
<li class="font-bold">
{#if weaponData.talents[rowIndex].name}
{translatableString(weaponData.talents[rowIndex].name)}
{:else}
Talent #{rowIndex + 1}
{/if}
</li>

{#if $configViewWeaponTalents}
{#each selected.talents as row, rowIndex}
{#if selected.talents[rowIndex].some(v => v)}
<ul class="list-disc pl-4">
{#each row as col, colIndex}
{#if col}
<li>
<TalentOptionText option={weaponData.talents[rowIndex].options[colIndex]} compact />
</li>
<li class="font-bold">
{#if weaponData.talents[rowIndex].name}
{translatableString(weaponData.talents[rowIndex].name)}
{:else}
Talent #{rowIndex + 1}
{/if}
{/each}
</li>

<ul class="list-disc pl-4">
{#each row as col, colIndex}
{#if col}
<li>
<TalentOptionText option={weaponData.talents[rowIndex].options[colIndex]} compact />
</li>
{/if}
{/each}
</ul>
</ul>
</ul>
{/if}
{/each}
{/if}
{/each}
{/if}
</div>
{/if}
1 change: 1 addition & 0 deletions src/lib/state.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ const storagable = <T>(key: string, defaultValue: T): Writable<T> => {
};

export let configViewWeaponAbilities = storagable<boolean>("config.builder.view-weapon-abilities", true);
export let configViewWeaponTalents = storagable<boolean>("config.builder.view-weapon-talents", true);

0 comments on commit 8ff0b89

Please sign in to comment.