|
|
@@ -9,25 +9,51 @@
|
|
|
|
requiredCharas,
|
|
|
|
requiredCharas,
|
|
|
|
convoCharas,
|
|
|
|
convoCharas,
|
|
|
|
} from '$lib/data/convo';
|
|
|
|
} from '$lib/data/convo';
|
|
|
|
|
|
|
|
import * as talk from '$lib/umadump/talk';
|
|
|
|
import CharaPick from '$lib/CharaPick.svelte';
|
|
|
|
import CharaPick from '$lib/CharaPick.svelte';
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
import CharaIcon from '$lib/CharaIcon.svelte';
|
|
|
|
import CharaIcon from '$lib/CharaIcon.svelte';
|
|
|
|
|
|
|
|
import { SvelteSet } from 'svelte/reactivity';
|
|
|
|
|
|
|
|
|
|
|
|
let conversations: Conversation[] = $state([]);
|
|
|
|
let allConvos: Conversation[] = $state([]);
|
|
|
|
const convoMap = $derived(byChara(conversations));
|
|
|
|
const popular = $derived(groupPopulars(allConvos));
|
|
|
|
const popular = $derived(groupPopulars(conversations));
|
|
|
|
|
|
|
|
let characters: Character[] = $state([]);
|
|
|
|
let characters: Character[] = $state([]);
|
|
|
|
const selCharas = $derived(characters.filter((c) => convoMap.has(c.chara_id)));
|
|
|
|
|
|
|
|
const names = $derived(charaNames(characters));
|
|
|
|
const names = $derived(charaNames(characters));
|
|
|
|
const minSuggest = 8;
|
|
|
|
const minSuggest = 8;
|
|
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
onMount(async () => {
|
|
|
|
[conversations, characters] = await Promise.all([conversation(), character()]);
|
|
|
|
[allConvos, characters] = await Promise.all([conversation(), character()]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let chara: Character | undefined = $state();
|
|
|
|
let chara: Character | undefined = $state();
|
|
|
|
let convo = $state(1);
|
|
|
|
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 options = $derived(convoMap.get(chara?.chara_id ?? 0) ?? []);
|
|
|
|
const cur = $derived(options.find((c) => c.number === convo));
|
|
|
|
const cur = $derived(options.find((c) => c.number === convo));
|
|
|
|
const charaIDs = $derived(cur != null ? convoCharas(cur) : []);
|
|
|
|
const charaIDs = $derived(cur != null ? convoCharas(cur) : []);
|
|
|
@@ -47,12 +73,12 @@
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<h1 class="text-4xl">Lobby Conversations</h1>
|
|
|
|
<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="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="m-4 flex-1 md:mt-3">
|
|
|
|
<div class="md:col-span-3">
|
|
|
|
<label for="chara" class="hidden md:inline">Character</label>
|
|
|
|
<label for="chara" class="hidden md:inline">Character</label>
|
|
|
|
<CharaPick id="chara" characters={selCharas} class="w-full" bind:value={chara} required />
|
|
|
|
<CharaPick id="chara" characters={selCharas} class="w-full" bind:value={chara} required />
|
|
|
|
</div>
|
|
|
|
</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>
|
|
|
|
<label for="convo" class="hidden md:inline">Conversation</label>
|
|
|
|
<select id="convo" bind:value={convo} class="w-full">
|
|
|
|
<select id="convo" bind:value={convo} class="w-full">
|
|
|
|
{#each options as opt (opt.number)}
|
|
|
|
{#each options as opt (opt.number)}
|
|
|
@@ -60,6 +86,29 @@
|
|
|
|
{/each}
|
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-span-full">
|
|
|
|
|
|
|
|
<label for="talkgallery" class="block">
|
|
|
|
|
|
|
|
Select
|
|
|
|
|
|
|
|
<a href="https://werseter.github.io/umadump/" target="_blank" rel="noopener noreferrer">
|
|
|
|
|
|
|
|
<span class="inline-block font-mono">talk_gallery_data.json</span>
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
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>
|
|
|
|
</div>
|
|
|
|
{#if cur}
|
|
|
|
{#if cur}
|
|
|
|
<div class="shadow-sm transition-shadow hover:shadow-md">
|
|
|
|
<div class="shadow-sm transition-shadow hover:shadow-md">
|
|
|
|