Update grid components for editing support
This commit is contained in:
parent
c9bd155ed6
commit
7e862ed56a
3 changed files with 42 additions and 82 deletions
|
|
@ -1,39 +1,23 @@
|
||||||
|
<svelte:options runes={true} />
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GridCharacterItemView } from '$lib/api/schemas/party'
|
import type { GridCharacter } from '$lib/types/api/party'
|
||||||
|
|
||||||
export let characters: GridCharacterItemView[] = []
|
interface Props {
|
||||||
export let mainWeaponElement: number | null | undefined = undefined
|
characters?: GridCharacter[]
|
||||||
export let partyElement: number | null | undefined = undefined
|
mainWeaponElement?: number | null | undefined
|
||||||
|
partyElement?: number | null | undefined
|
||||||
function displayName(input: any): string {
|
|
||||||
if (!input) return '—'
|
|
||||||
const maybe = input.name ?? input
|
|
||||||
if (typeof maybe === 'string') return maybe
|
|
||||||
if (maybe && typeof maybe === 'object') return maybe.en || maybe.ja || '—'
|
|
||||||
return '—'
|
|
||||||
}
|
}
|
||||||
function characterImageUrl(c?: GridCharacterItemView): string {
|
|
||||||
const id = (c as any)?.object?.granblueId
|
|
||||||
if (!id) return '/images/placeholders/placeholder-weapon-grid.png'
|
|
||||||
|
|
||||||
const uncap = (c as any)?.uncapLevel ?? 0
|
let {
|
||||||
const transStep = (c as any)?.transcendenceStep ?? 0
|
characters = [],
|
||||||
let suffix = '01'
|
mainWeaponElement = undefined,
|
||||||
if (transStep > 0) suffix = '04'
|
partyElement = undefined
|
||||||
else if (uncap >= 5) suffix = '03'
|
}: Props = $props()
|
||||||
else if (uncap > 2) suffix = '02'
|
|
||||||
|
|
||||||
// Lyria special case (3030182000): append element
|
|
||||||
if (String(id) === '3030182000') {
|
|
||||||
let element = mainWeaponElement || partyElement || 1
|
|
||||||
suffix = `${suffix}_0${element}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return `/images/character-main/${id}_${suffix}.jpg`
|
|
||||||
}
|
|
||||||
|
|
||||||
import CharacterUnit from '$lib/components/units/CharacterUnit.svelte'
|
import CharacterUnit from '$lib/components/units/CharacterUnit.svelte'
|
||||||
const grid = Array.from({ length: 5 }, (_, i) => characters.find((c) => c.position === i))
|
|
||||||
|
let grid = $derived(Array.from({ length: 5 }, (_, i) => characters.find((c) => c.position === i)))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,20 @@
|
||||||
|
<svelte:options runes={true} />
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GridSummonItemView } from '$lib/api/schemas/party'
|
import type { GridSummon } from '$lib/types/api/party'
|
||||||
|
|
||||||
export let summons: GridSummonItemView[] = []
|
interface Props {
|
||||||
|
summons?: GridSummon[]
|
||||||
|
}
|
||||||
|
|
||||||
function displayName(input: any): string {
|
let { summons = [] }: Props = $props()
|
||||||
if (!input) return '—'
|
|
||||||
const maybe = input.name ?? input
|
|
||||||
if (typeof maybe === 'string') return maybe
|
|
||||||
if (maybe && typeof maybe === 'object') return maybe.en || maybe.ja || '—'
|
|
||||||
return '—'
|
|
||||||
}
|
|
||||||
function summonImageUrl(s?: GridSummonItemView): string {
|
|
||||||
const id = (s as any)?.object?.granblueId
|
|
||||||
const isMain = s?.main || s?.position === -1 || s?.friend || s?.position === 6
|
|
||||||
if (!id) return isMain ? '/images/placeholders/placeholder-summon-main.png' : '/images/placeholders/placeholder-summon-grid.png'
|
|
||||||
const folder = isMain ? 'summon-main' : 'summon-grid'
|
|
||||||
return `/images/${folder}/${id}.jpg`
|
|
||||||
}
|
|
||||||
|
|
||||||
import SummonUnit from '$lib/components/units/SummonUnit.svelte'
|
import SummonUnit from '$lib/components/units/SummonUnit.svelte'
|
||||||
import ExtraSummons from '$lib/components/extra/ExtraSummonsGrid.svelte'
|
import ExtraSummons from '$lib/components/extra/ExtraSummonsGrid.svelte'
|
||||||
const main = summons.find((s) => s.main || s.position === -1)
|
|
||||||
const friend = summons.find((s) => s.friend || s.position === 6)
|
let main = $derived(summons.find((s) => s.main || s.position === -1))
|
||||||
const grid = Array.from({ length: 4 }, (_, i) => summons.find((s) => s.position === i))
|
let friend = $derived(summons.find((s) => s.friend || s.position === 6))
|
||||||
|
let grid = $derived(Array.from({ length: 4 }, (_, i) => summons.find((s) => s.position === i)))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,28 @@
|
||||||
|
<svelte:options runes={true} />
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GridWeaponItemView } from '$lib/api/schemas/party'
|
import type { GridWeapon } from '$lib/types/api/party'
|
||||||
|
|
||||||
export let weapons: GridWeaponItemView[] = []
|
interface Props {
|
||||||
export let raidExtra: boolean | undefined = undefined
|
weapons?: GridWeapon[]
|
||||||
export let showGuidebooks: boolean | undefined = undefined
|
raidExtra?: boolean
|
||||||
export let guidebooks: Record<string, any> | undefined = undefined
|
showGuidebooks?: boolean
|
||||||
|
guidebooks?: Record<string, any>
|
||||||
function displayName(input: any): string {
|
|
||||||
if (!input) return '—'
|
|
||||||
const maybe = input.name ?? input
|
|
||||||
if (typeof maybe === 'string') return maybe
|
|
||||||
if (maybe && typeof maybe === 'object') return maybe.en || maybe.ja || '—'
|
|
||||||
return '—'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function weaponImageUrl(w?: GridWeaponItemView): string {
|
let {
|
||||||
const id = (w as any)?.object?.granblueId
|
weapons = [],
|
||||||
const isMain = !!(w && ((w as any).mainhand || (w as any).position === -1))
|
raidExtra = undefined,
|
||||||
if (!id) return isMain
|
showGuidebooks = undefined,
|
||||||
? '/images/placeholders/placeholder-weapon-main.png'
|
guidebooks = undefined
|
||||||
: '/images/placeholders/placeholder-weapon-grid.png'
|
}: Props = $props()
|
||||||
|
|
||||||
const folder = isMain ? 'weapon-main' : 'weapon-grid'
|
|
||||||
|
|
||||||
// Neutral element override: if object.element == 0 and instance element present, append _<element>
|
|
||||||
const objElement = (w as any)?.object?.element
|
|
||||||
const instElement = (w as any)?.element
|
|
||||||
if (objElement === 0 && instElement) {
|
|
||||||
return `/images/${folder}/${id}_${instElement}.jpg`
|
|
||||||
}
|
|
||||||
|
|
||||||
// For local static images, transcendence variants are not split by suffix; use base
|
|
||||||
return `/images/${folder}/${id}.jpg`
|
|
||||||
}
|
|
||||||
|
|
||||||
import WeaponUnit from '$lib/components/units/WeaponUnit.svelte'
|
import WeaponUnit from '$lib/components/units/WeaponUnit.svelte'
|
||||||
import ExtraWeapons from '$lib/components/extra/ExtraWeaponsGrid.svelte'
|
import ExtraWeapons from '$lib/components/extra/ExtraWeaponsGrid.svelte'
|
||||||
import Guidebooks from '$lib/components/extra/GuidebooksGrid.svelte'
|
import Guidebooks from '$lib/components/extra/GuidebooksGrid.svelte'
|
||||||
const mainhand = weapons.find((w) => (w as any).mainhand || w.position === -1)
|
|
||||||
const grid = Array.from({ length: 9 }, (_, i) => weapons.find((w) => w.position === i))
|
let mainhand = $derived(weapons.find((w) => (w as any).mainhand || w.position === -1))
|
||||||
|
let grid = $derived(Array.from({ length: 9 }, (_, i) => weapons.find((w) => w.position === i)))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue