diff --git a/src/lang/en.ts b/src/lang/en.ts index 4c66623d..bb58cff0 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -567,4 +567,7 @@ export const languageEnglish = { antiClaudeOverload: "Anti-Claude Overload", activeTabChange: "Current tab is inactivated since other tab is active. to activate this tab, click OK", maxSupaChunkSize: "Max SupaMemory Chunk Size", + addCharacter: "Add Character", + importFromRealm: "Choose from RisuRealm", + importFromRealmDesc: "Choose over 1000 characters in RisuRealm", } \ No newline at end of file diff --git a/src/lib/Others/AlertComp.svelte b/src/lib/Others/AlertComp.svelte index 1c278c21..4e4d4163 100644 --- a/src/lib/Others/AlertComp.svelte +++ b/src/lib/Others/AlertComp.svelte @@ -4,7 +4,7 @@ import { getCharImage } from '../../ts/characters'; import { ParseMarkdown } from '../../ts/parser'; import BarIcon from '../SideBars/BarIcon.svelte'; - import { User } from 'lucide-svelte'; + import { ChevronRightIcon, User } from 'lucide-svelte'; import { hubURL } from 'src/ts/characterCards'; import TextInput from '../UI/GUI/TextInput.svelte'; import { openURL } from 'src/ts/storage/globalApi'; @@ -75,7 +75,7 @@
You should accept RisuRealm's { openURL('https://sv.risuai.xyz/hub/tos') }}>Terms of Service to continue
- {:else if $alertStore.type !== 'select' && $alertStore.type !== 'requestdata'} + {:else if $alertStore.type !== 'select' && $alertStore.type !== 'requestdata' && $alertStore.type !== 'addchar'} {$alertStore.msg} {#if $alertStore.submsg} {$alertStore.submsg} @@ -225,6 +225,73 @@ {/if} {/await} {/if} + {:else if $alertStore.type === 'addchar'} +
+ + + + + + +
{/if} diff --git a/src/lib/SideBars/Sidebar.svelte b/src/lib/SideBars/Sidebar.svelte index a974821c..c508c5d4 100644 --- a/src/lib/SideBars/Sidebar.svelte +++ b/src/lib/SideBars/Sidebar.svelte @@ -7,7 +7,10 @@ settingsOpen, sideBarClosing, sideBarStore, - CurrentCharacter + CurrentCharacter, + + OpenRealmStore + } from "../../ts/stores"; import { DataBase, setDatabase, type folder } from "../../ts/storage/database"; import BarIcon from "./BarIcon.svelte"; @@ -44,7 +47,7 @@ import { BotCreator } from "src/ts/creation/creator"; import Button from "../UI/GUI/Button.svelte"; import { fly } from "svelte/transition"; - import { alertInput, alertSelect } from "src/ts/alert"; + import { alertAddCharacter, alertInput, alertSelect } from "src/ts/alert"; import SideChatList from "./SideChatList.svelte"; import { joinMultiuserRoom } from "src/ts/sync/multiuser"; let openPresetList = false; @@ -564,13 +567,22 @@ {/each}
{ - if (sideBarMode === 1) { - reseter(); - sideBarMode = 0; - } else { - reseter(); - sideBarMode = 1; + onClick={async () => { + const r = await alertAddCharacter() + switch(r){ + case 'createfromScratch': + createScratch() + break + case 'importCharacter': + createImport() + break + case 'createGroup': + createGroup() + break + case 'importFromRealm': + selectedCharID.set(-1) + OpenRealmStore.set(true) + break } }} >
- {#if !openHub} + {#if !$OpenRealmStore} {#if (!isTauri) && (!isNodeServer)} <h3 class="text-textcolor2 mt-1">Version {appVer}{webAppSubVer}</h3> @@ -46,7 +45,7 @@ {/if} {/if} <div class="w-full flex p-4 flex-col text-textcolor max-w-4xl"> - {#if !openHub} + {#if !$OpenRealmStore} <div class="grid grid-cols-1 gap-4 md:grid-cols-2"> <button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => { openURL("https://github.com/kwaroran/RisuAI/wiki") @@ -61,7 +60,7 @@ </div> <div class="mt-4 mb-4 w-full border-t border-t-selected"></div> <h1 class="text-2xl font-bold">Recently Uploaded<button class="text-base font-medium float-right p-1 bg-darkbg rounded-md hover:ring" on:click={() => { - openHub = true + $OpenRealmStore = true }}>Get More</button></h1> {#if !$DataBase.hideRealm} {#await getRisuHub({ @@ -73,7 +72,7 @@ {#if charas.length > 0} <div class="w-full flex gap-4 p-2 flex-wrap justify-center"> {#each charas as chara} - <RisuHubIcon onClick={() => {openHub = true}} chara={chara} /> + <RisuHubIcon onClick={() => {$OpenRealmStore = true}} chara={chara} /> {/each} </div> {:else} @@ -85,7 +84,7 @@ {/if} {:else} <div class="flex items-center mt-4"> - <button class="mr-2 text-textcolor2 hover:text-green-500" on:click={() => (openHub = false)}> + <button class="mr-2 text-textcolor2 hover:text-green-500" on:click={() => ($OpenRealmStore = false)}> <ArrowLeft/> </button> </div> diff --git a/src/ts/alert.ts b/src/ts/alert.ts index 4b031768..36d5e6d8 100644 --- a/src/ts/alert.ts +++ b/src/ts/alert.ts @@ -6,7 +6,7 @@ import { Capacitor } from "@capacitor/core" import { DataBase, type MessageGenerationInfo } from "./storage/database" interface alertData{ - type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata' + type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata'|'addchar' msg: string, submsg?: string } @@ -57,6 +57,21 @@ export async function alertNormalWait(msg:string){ } } +export async function alertAddCharacter() { + alertStore.set({ + 'type': 'addchar', + 'msg': language.addCharacter + }) + while(true){ + if (get(alertStore).type === 'none'){ + break + } + await sleep(10) + } + + return get(alertStore).msg +} + export async function alertLogin(){ alertStore.set({ 'type': 'login', diff --git a/src/ts/stores.ts b/src/ts/stores.ts index a85c6159..81ee6e31 100644 --- a/src/ts/stores.ts +++ b/src/ts/stores.ts @@ -39,6 +39,7 @@ export const CurrentShowMemoryLimit = writable(db.showMemoryLimit) export const ShowVN = writable(false) export const SettingsMenuIndex = writable(-1) export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean}) +export const OpenRealmStore = writable(false) function createSimpleCharacter(char:character|groupChat){ if((!char) || char.type === 'group'){