Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaroran authored Feb 6, 2024
2 parents 51dc0b1 + e414b31 commit 28bdea7
Show file tree
Hide file tree
Showing 19 changed files with 605 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/etc/patchNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getPatchNote(version: string){
if(patchNote.version.split(".")[1] === version.split(".")[1] && patchNote.version.split(".")[0] === version.split(".")[0]){
return patchNote
}
return {
return {
version: version.split(".")[0] + "." + version.split(".")[1],
content: ""
}
Expand Down
13 changes: 13 additions & 0 deletions src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,17 @@ export const languageEnglish = {
licenseDesc: "You can choose license for the downloaders to limit the usages of your card's prompt.",
passwordDesc: "You can set a password to protect your card from unauthorized access.",
largePersonaPortrait: "Persona Portrait",
module: "Module",
modules: "Modules",
noModules: "No modules has been installed.",
createModule: "Create Module",
basicInfo: "Basic Info",
moduleContent: "Module Content",
confirmRemoveModuleFeature: "Do you really want to remove this feature? This action cannot be undone.",
editModule: "Edit Module",
importModule: "Import Module",
download: "Download",
edit: "Edit",
enableGlobal: "Enable Globally",
chatModulesInfo: "You can enable or disable modules for this chat.",
}
10 changes: 7 additions & 3 deletions src/lib/ChatScreens/ChatScreen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import BackgroundDom from "./BackgroundDom.svelte";
import SideBarArrow from "../UI/GUI/SideBarArrow.svelte";
import VisualNovelMain from "../VisualNovel/VisualNovelMain.svelte";
import ModuleChatMenu from "../Setting/Pages/Module/ModuleChatMenu.svelte";
let openChatList = false
let openModuleList = false
const wallPaper = `background: url(${defaultWallpaper})`
const externalStyles =
Expand Down Expand Up @@ -40,7 +42,7 @@
<ResizeBox />
{/if}
{/if}
<DefaultChatScreen customStyle={bgImg.length > 2 ? `${externalStyles}`: ''} bind:openChatList/>
<DefaultChatScreen customStyle={bgImg.length > 2 ? `${externalStyles}`: ''} bind:openChatList bind:openModuleList/>
</div>
</div>
{:else if $DataBase.theme === 'waifu'}
Expand All @@ -55,7 +57,7 @@
{/if}
{/if}
<div class="h-full w-2xl" style:width="{42 * ($DataBase.waifuWidth / 100)}rem" class:halfwp={$selectedCharID >= 0 && $CurrentCharacter.viewScreen !== 'none'}>
<DefaultChatScreen customStyle={`${externalStyles}backdrop-filter: blur(4px);`} bind:openChatList/>
<DefaultChatScreen customStyle={`${externalStyles}backdrop-filter: blur(4px);`} bind:openChatList bind:openModuleList/>
</div>
</div>
{:else if $DataBase.theme === 'waifuMobile'}
Expand All @@ -66,7 +68,7 @@
class:per33={$selectedCharID >= 0 && $CurrentCharacter.viewScreen !== 'none'}
class:h-full={!($selectedCharID >= 0 && $CurrentCharacter.viewScreen !== 'none')}
>
<DefaultChatScreen customStyle={`${externalStyles}backdrop-filter: blur(4px);`} bind:openChatList/>
<DefaultChatScreen customStyle={`${externalStyles}backdrop-filter: blur(4px);`} bind:openChatList bind:openModuleList/>
</div>
{#if $selectedCharID >= 0}
{#if $CurrentCharacter.viewScreen !== 'none'}
Expand All @@ -79,6 +81,8 @@
{/if}
{#if openChatList}
<ChatList close={() => {openChatList = false}}/>
{:else if openModuleList}
<ModuleChatMenu close={() => {openModuleList = false}}/>
{/if}

<style>
Expand Down
17 changes: 12 additions & 5 deletions src/lib/ChatScreens/DefaultChatScreen.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Suggestion from './Suggestion.svelte';
import { CameraIcon, DatabaseIcon, DicesIcon, GlobeIcon, ImagePlusIcon, LanguagesIcon, Laugh, MenuIcon, MicOffIcon, RefreshCcwIcon, ReplyIcon, Send, StepForwardIcon } from "lucide-svelte";
import { CameraIcon, DatabaseIcon, DicesIcon, GlobeIcon, ImagePlusIcon, LanguagesIcon, Laugh, MenuIcon, MicOffIcon, PackageIcon, RefreshCcwIcon, ReplyIcon, Send, StepForwardIcon } from "lucide-svelte";
import { CurrentCharacter, CurrentChat, CurrentUsername, selectedCharID, CurrentUserIcon, CurrentShowMemoryLimit,CurrentSimpleCharacter } from "../../ts/stores";
import Chat from "./Chat.svelte";
import { DataBase, type Message, type character, type groupChat } from "../../ts/storage/database";
Expand Down Expand Up @@ -36,6 +36,7 @@
let doingChatInputTranslate = false
let currentCharacter:character|groupChat = $CurrentCharacter
let toggleStickers:boolean = false
export let openModuleList = false
export let openChatList:boolean = false
async function send(){
Expand Down Expand Up @@ -582,7 +583,7 @@
{/if}

{#if openMenu}
<div class="absolute right-2 bottom-16 p-5 bg-darkbg flex flex-col gap-3 text-textcolor" on:click={(e) => {
<div class="absolute right-2 bottom-16 p-5 bg-darkbg flex flex-col gap-3 text-textcolor rounded-md" on:click={(e) => {
e.stopPropagation()
}}>
{#if $CurrentCharacter.type === 'group'}
Expand Down Expand Up @@ -664,9 +665,15 @@
<ReplyIcon />
<span class="ml-2">{language.autoSuggest}</span>
</div>
<div class="flex items-center cursor-pointer hover:text-green-500 transition-colors" on:click={reroll}>
<RefreshCcwIcon />
<span class="ml-2">{language.reroll}</span>


<div class="flex items-center cursor-pointer hover:text-green-500 transition-colors" on:click={() => {
$CurrentChat.modules ??= []
openModuleList = true
openMenu = false
}}>
<PackageIcon />
<span class="ml-2">{language.modules}</span>
</div>
</div>

Expand Down
80 changes: 80 additions & 0 deletions src/lib/Setting/Pages/Module/ModuleChatMenu.svelte
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>
153 changes: 153 additions & 0 deletions src/lib/Setting/Pages/Module/ModuleMenu.svelte
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}
Loading

0 comments on commit 28bdea7

Please sign in to comment.