Refactor character creation
This commit is contained in:
@@ -29,9 +29,8 @@
|
||||
WrenchIcon,
|
||||
} from "lucide-svelte";
|
||||
import {
|
||||
characterFormatUpdate,
|
||||
createNewCharacter,
|
||||
createNewGroup,
|
||||
addCharacter,
|
||||
changeChar,
|
||||
getCharImage,
|
||||
} from "../../ts/characters";
|
||||
import { importCharacter } from "src/ts/characterCards";
|
||||
@@ -60,42 +59,6 @@
|
||||
let devTool = false
|
||||
export let openGrid = () => {};
|
||||
|
||||
function createScratch() {
|
||||
reseter();
|
||||
createNewCharacter();
|
||||
let db = get(DataBase)
|
||||
if(db.characters[db.characters.length-1]){
|
||||
changeChar(db.characters.length-1)
|
||||
}
|
||||
}
|
||||
function createGroup() {
|
||||
reseter();
|
||||
createNewGroup();
|
||||
let db = get(DataBase)
|
||||
if(db.characters[db.characters.length-1]){
|
||||
changeChar(db.characters.length-1)
|
||||
}
|
||||
}
|
||||
async function createImport() {
|
||||
reseter();
|
||||
await importCharacter();
|
||||
let db = get(DataBase)
|
||||
if(db.characters[db.characters.length-1]){
|
||||
changeChar(db.characters.length-1)
|
||||
}
|
||||
}
|
||||
|
||||
function changeChar(index: number) {
|
||||
if($doingChat){
|
||||
return
|
||||
}
|
||||
reseter();
|
||||
characterFormatUpdate(index, {
|
||||
updateInteraction: true,
|
||||
});
|
||||
selectedCharID.set(index);
|
||||
}
|
||||
|
||||
function reseter() {
|
||||
menuMode = 0;
|
||||
sideBarMode = 0;
|
||||
@@ -426,13 +389,13 @@
|
||||
<div
|
||||
on:click={() => {
|
||||
if(char.type === "normal"){
|
||||
changeChar(char.index);
|
||||
changeChar(char.index, {reseter});
|
||||
}
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
if(char.type === "normal"){
|
||||
changeChar(char.index);
|
||||
changeChar(char.index, {reseter});
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -537,13 +500,13 @@
|
||||
<div
|
||||
on:click={() => {
|
||||
if(char2.type === "normal"){
|
||||
changeChar(char2.index);
|
||||
changeChar(char2.index, {reseter});
|
||||
}
|
||||
}}
|
||||
on:keydown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
if(char2.type === "normal"){
|
||||
changeChar(char2.index);
|
||||
changeChar(char2.index, {reseter});
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -587,22 +550,7 @@
|
||||
<div class="flex flex-col items-center space-y-2 px-2">
|
||||
<BaseRoundedButton
|
||||
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
|
||||
}
|
||||
addCharacter({reseter})
|
||||
}}
|
||||
><svg viewBox="0 0 24 24" width="1.2em" height="1.2em"
|
||||
><path
|
||||
@@ -703,38 +651,6 @@
|
||||
<SideChatList bind:chara={ $CurrentCharacter} />
|
||||
{/if}
|
||||
{/if}
|
||||
{:else if sideBarMode === 1}
|
||||
<Button
|
||||
on:click={createScratch}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.createfromScratch}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={createImport}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.importCharacter}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={createGroup}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.createGroup}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={BotCreator.createBotFromWeb}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.createBotwithAI}
|
||||
</Button>
|
||||
{:else if sideBarMode === 2}
|
||||
<Button
|
||||
on:click={joinMultiuserRoom}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.joinMultiUserRoom}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user