-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
605 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<script lang="ts"> | ||
import { CheckCircle2Icon, Globe, XIcon } from "lucide-svelte"; | ||
import { language } from "src/lang"; | ||
import Button from "src/lib/UI/GUI/Button.svelte"; | ||
import { DataBase } from "src/ts/storage/database"; | ||
import { CurrentChat } from "src/ts/stores"; | ||
import { SettingsMenuIndex, settingsOpen } from "src/ts/stores"; | ||
export let close = () => {} | ||
</script> | ||
|
||
|
||
<div class="absolute w-full h-full z-40 bg-black bg-opacity-50 flex justify-center items-center"> | ||
<div class="bg-darkbg p-4 break-any rounded-md flex flex-col max-w-3xl w-full max-h-full overflow-y-auto"> | ||
<div class="flex items-center text-textcolor"> | ||
<h2 class="mt-0 mb-0 text-lg">{language.modules}</h2> | ||
<div class="flex-grow flex justify-end"> | ||
<button class="text-textcolor2 hover:text-green-500 mr-2 cursor-pointer items-center" on:click={close}> | ||
<XIcon size={24}/> | ||
</button> | ||
</div> | ||
</div> | ||
<span class="text-sm text-textcolor2">{language.chatModulesInfo}</span> | ||
|
||
<div class="contain w-full max-w-full mt-4 flex flex-col border-selected border-1 rounded-md"> | ||
{#if $DataBase.modules.length === 0} | ||
<div class="text-textcolor2 p-3">{language.noModules}</div> | ||
{:else} | ||
{#each $DataBase.modules as rmodule, i} | ||
{#if i !== 0} | ||
<div class="border-t-1 border-selected"></div> | ||
{/if} | ||
<div class="pl-3 pt-3 text-left flex"> | ||
<span class="text-lg">{rmodule.name}</span> | ||
<div class="flex-grow flex justify-end"> | ||
{#if $DataBase.enabledModules.includes(rmodule.id)} | ||
<button class="mr-2 cursor-pointer text-blue-500"> | ||
<Globe size={18}/> | ||
</button> | ||
{:else} | ||
<button class={(!$CurrentChat.modules.includes(rmodule.id)) ? | ||
"text-textcolor2 hover:text-green-500 mr-2 cursor-pointer" : | ||
"mr-2 cursor-pointer text-blue-500" | ||
} on:click={async (e) => { | ||
e.stopPropagation() | ||
if($CurrentChat.modules.includes(rmodule.id)){ | ||
$CurrentChat.modules.splice($CurrentChat.modules.indexOf(rmodule.id), 1) | ||
} | ||
else{ | ||
$CurrentChat.modules.push(rmodule.id) | ||
} | ||
$CurrentChat.modules = $CurrentChat.modules | ||
}}> | ||
<CheckCircle2Icon size={18}/> | ||
</button> | ||
{/if} | ||
</div> | ||
</div> | ||
<div class="mt-1 mb-3 pl-3"> | ||
<span class="text-sm text-textcolor2">{rmodule.description || 'No description provided'}</span> | ||
</div> | ||
{/each} | ||
{/if} | ||
</div> | ||
<div> | ||
<Button className="mt-4 flex-grow-0" size="sm" on:click={() => { | ||
$SettingsMenuIndex = 14 | ||
$settingsOpen = true | ||
close() | ||
}}>{language.edit}</Button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.break-any{ | ||
word-break: normal; | ||
overflow-wrap: anywhere; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<script type="ts" lang="ts"> | ||
import { language } from "src/lang"; | ||
import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte"; | ||
import TextInput from "src/lib/UI/GUI/TextInput.svelte"; | ||
import LoreBookData from "src/lib/SideBars/LoreBook/LoreBookData.svelte"; | ||
import type { RisuModule } from "src/ts/process/modules"; | ||
import { PlusIcon } from "lucide-svelte"; | ||
import { alertConfirm } from "src/ts/alert"; | ||
import RegexList from "src/lib/SideBars/Scripts/RegexList.svelte"; | ||
import TriggerList from "src/lib/SideBars/Scripts/TriggerList.svelte"; | ||
export let currentModule:RisuModule | ||
async function toggleLorebook(){ | ||
if(!Array.isArray(currentModule.lorebook)){ | ||
currentModule.lorebook = [] | ||
} | ||
else if(currentModule.lorebook.length > 0){ | ||
const conf = await alertConfirm(language.confirmRemoveModuleFeature) | ||
if(conf){ | ||
currentModule.lorebook = undefined | ||
} | ||
} | ||
else{ | ||
currentModule.lorebook = undefined | ||
} | ||
} | ||
async function toggleRegex(){ | ||
if(!Array.isArray(currentModule.regex)){ | ||
currentModule.regex = [] | ||
} | ||
else if(currentModule.regex.length > 0){ | ||
const conf = await alertConfirm(language.confirmRemoveModuleFeature) | ||
if(conf){ | ||
currentModule.regex = undefined | ||
} | ||
} | ||
else{ | ||
currentModule.regex = undefined | ||
} | ||
} | ||
async function toggleTrigger(){ | ||
if(!Array.isArray(currentModule.trigger)){ | ||
currentModule.trigger = [] | ||
} | ||
else if(currentModule.trigger.length > 0){ | ||
const conf = await alertConfirm(language.confirmRemoveModuleFeature) | ||
if(conf){ | ||
currentModule.trigger = undefined | ||
} | ||
} | ||
else{ | ||
currentModule.trigger = undefined | ||
} | ||
} | ||
function addLorebook(){ | ||
if(Array.isArray(currentModule.lorebook)){ | ||
currentModule.lorebook.push({ | ||
key: '', | ||
comment: `New Lore`, | ||
content: '', | ||
mode: 'normal', | ||
insertorder: 100, | ||
alwaysActive: false, | ||
secondkey: "", | ||
selective: false | ||
}) | ||
currentModule.lorebook = currentModule.lorebook | ||
} | ||
} | ||
function addRegex(){ | ||
if(Array.isArray(currentModule.regex)){ | ||
currentModule.regex.push({ | ||
comment: "", | ||
in: "", | ||
out: "", | ||
type: "editinput" | ||
}) | ||
currentModule.regex = currentModule.regex | ||
} | ||
} | ||
function addTrigger(){ | ||
if(Array.isArray(currentModule.trigger)){ | ||
currentModule.trigger.push({ | ||
conditions: [], | ||
type: 'start', | ||
comment: '', | ||
effect: [] | ||
}) | ||
currentModule.trigger = currentModule.trigger | ||
} | ||
} | ||
</script> | ||
|
||
<span class="mt-4 text-xl">{language.basicInfo}</span> | ||
<TextInput bind:value={currentModule.name} additionalClass="mt-1" placeholder={language.name}/> | ||
<TextInput bind:value={currentModule.description} additionalClass="mt-1" placeholder={language.description} size="sm"/> | ||
<span class="mt-6 text-xl">{language.moduleContent}</span> | ||
<div class="grid grid-cols-2 border-selected border rounded-md"> | ||
<button class={(!Array.isArray(currentModule.lorebook)) ? 'p-4' : "p-4 bg-selected rounded-tl-md"} on:click={toggleLorebook}> | ||
{language.loreBook} | ||
</button> | ||
<button class={(!Array.isArray(currentModule.regex)) ? 'p-4' : "p-4 bg-selected rounded-tr-md"} on:click={toggleRegex}> | ||
{language.regexScript} | ||
</button> | ||
<button class={(!Array.isArray(currentModule.trigger)) ? 'p-4' : "p-4 bg-selected rounded-tr-md"} on:click={toggleTrigger}> | ||
{language.triggerScript} | ||
</button> | ||
<button class="p-4"> | ||
|
||
</button> | ||
</div> | ||
|
||
{#if (Array.isArray(currentModule.lorebook))} | ||
<span class="mt-8 text-xl">{language.loreBook}</span> | ||
<div class="border border-selected p-2 flex flex-col rounded-md mt-2"> | ||
{#each currentModule.lorebook as lore, i} | ||
<LoreBookData bind:value={currentModule.lorebook[i]} idx={i} onRemove={() => { | ||
currentModule.lorebook.splice(i, 1) | ||
currentModule.lorebook = currentModule.lorebook | ||
}}/> | ||
{/each} | ||
</div> | ||
<button on:click={() => {addLorebook()}} class="hover:text-textcolor cursor-pointer"> | ||
<PlusIcon /> | ||
</button> | ||
{/if} | ||
|
||
{#if (Array.isArray(currentModule.regex))} | ||
<span class="mt-8 text-xl">{language.regexScript}</span> | ||
<RegexList bind:value={currentModule.regex}/> | ||
<button on:click={() => {addRegex()}} class="hover:text-textcolor cursor-pointer"> | ||
<PlusIcon /> | ||
</button> | ||
{/if} | ||
|
||
{#if (Array.isArray(currentModule.trigger))} | ||
<span class="mt-8 text-xl">{language.triggerScript}</span> | ||
<TriggerList bind:value={currentModule.trigger}/> | ||
<button on:click={() => {addTrigger()}} class="hover:text-textcolor cursor-pointer"> | ||
<PlusIcon /> | ||
</button> | ||
{/if} |
Oops, something went wrong.