@@ -0,0 +1,14 @@
|
||||
import * as z from 'zod';
|
||||
|
||||
const Entry = z.strictObject({
|
||||
home_story_trigger_id: z.int32(),
|
||||
new_flag: z.literal(0).or(z.literal(1)),
|
||||
});
|
||||
|
||||
export type Entry = z.infer<typeof Entry>;
|
||||
|
||||
export const Gallery = z.object({
|
||||
talk_gallery_list: z.array(Entry),
|
||||
});
|
||||
|
||||
export type Gallery = z.infer<typeof Gallery>;
|
||||
@@ -9,25 +9,51 @@
|
||||
requiredCharas,
|
||||
convoCharas,
|
||||
} from '$lib/data/convo';
|
||||
import * as talk from '$lib/umadump/talk';
|
||||
import CharaPick from '$lib/CharaPick.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import CharaIcon from '$lib/CharaIcon.svelte';
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
|
||||
let conversations: Conversation[] = $state([]);
|
||||
const convoMap = $derived(byChara(conversations));
|
||||
const popular = $derived(groupPopulars(conversations));
|
||||
let allConvos: Conversation[] = $state([]);
|
||||
const popular = $derived(groupPopulars(allConvos));
|
||||
let characters: Character[] = $state([]);
|
||||
const selCharas = $derived(characters.filter((c) => convoMap.has(c.chara_id)));
|
||||
const names = $derived(charaNames(characters));
|
||||
const minSuggest = 8;
|
||||
|
||||
onMount(async () => {
|
||||
[conversations, characters] = await Promise.all([conversation(), character()]);
|
||||
[allConvos, characters] = await Promise.all([conversation(), character()]);
|
||||
});
|
||||
|
||||
let chara: Character | undefined = $state();
|
||||
let convo = $state(1);
|
||||
|
||||
let talkFiles: FileList | undefined = $state();
|
||||
let readIDs = new SvelteSet<number>();
|
||||
let talkFileInvalid = $state(false);
|
||||
async function setRead(f: FileList) {
|
||||
talkFiles = f;
|
||||
readIDs.clear();
|
||||
talkFileInvalid = false;
|
||||
if (talkFiles == null || talkFiles.length === 0) {
|
||||
return;
|
||||
}
|
||||
const t = await talkFiles[0].text();
|
||||
const d = JSON.parse(t);
|
||||
const g = talk.Gallery.safeDecode(d);
|
||||
if (!g.success) {
|
||||
talkFileInvalid = true;
|
||||
console.warn(g.error);
|
||||
return;
|
||||
}
|
||||
for (const e of g.data.talk_gallery_list) {
|
||||
readIDs.add(e.home_story_trigger_id);
|
||||
}
|
||||
}
|
||||
const conversations = $derived(allConvos.filter((c) => !readIDs.has(c.id)));
|
||||
const convoMap = $derived(byChara(conversations));
|
||||
const selCharas = $derived(characters.filter((c) => convoMap.has(c.chara_id)));
|
||||
|
||||
const options = $derived(convoMap.get(chara?.chara_id ?? 0) ?? []);
|
||||
const cur = $derived(options.find((c) => c.number === convo));
|
||||
const charaIDs = $derived(cur != null ? convoCharas(cur) : []);
|
||||
@@ -47,12 +73,12 @@
|
||||
</script>
|
||||
|
||||
<h1 class="text-4xl">Lobby Conversations</h1>
|
||||
<div class="mx-auto mt-8 flex flex-col rounded-md text-center shadow-md ring md:max-w-xl md:flex-row">
|
||||
<div class="m-4 flex-1 md:mt-3">
|
||||
<div class="mx-auto mt-8 grid grid-cols-1 gap-4 rounded-md p-4 text-center shadow-md ring md:max-w-xl md:grid-cols-6">
|
||||
<div class="md:col-span-3">
|
||||
<label for="chara" class="hidden md:inline">Character</label>
|
||||
<CharaPick id="chara" characters={selCharas} class="w-full" bind:value={chara} required />
|
||||
</div>
|
||||
<div class="m-4 flex-1 md:mt-3">
|
||||
<div class="md:col-span-3">
|
||||
<label for="convo" class="hidden md:inline">Conversation</label>
|
||||
<select id="convo" bind:value={convo} class="w-full">
|
||||
{#each options as opt (opt.number)}
|
||||
@@ -60,6 +86,25 @@
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-span-full">
|
||||
<label for="talkgallery" class="block">
|
||||
Select <span class="inline-block font-mono">talk_gallery_data.json</span> to hide read conversations.
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
class="rounded-full p-4"
|
||||
accept="application/json"
|
||||
id="talkgallery"
|
||||
bind:files={() => talkFiles ?? new DataTransfer().files, setRead}
|
||||
/>
|
||||
<button
|
||||
class="ml-4 rounded-full bg-mist-300 p-2 hover:cursor-pointer dark:bg-mist-900"
|
||||
onclick={() => setRead(new DataTransfer().files)}>Reset</button
|
||||
>
|
||||
</div>
|
||||
{#if talkFileInvalid}
|
||||
<div class="col-span-full">Invalid File</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if cur}
|
||||
<div class="shadow-sm transition-shadow hover:shadow-md">
|
||||
|
||||
Reference in New Issue
Block a user