Change first message to chat dependent
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { ParseMarkdown, risuChatParser } from "src/ts/parser";
|
||||
import { DataBase, type Database, type character, type groupChat } from "src/ts/storage/database";
|
||||
import { CurrentVariablePointer, moduleBackgroundEmbedding, ReloadGUIPointer, selectedCharID } from "src/ts/stores";
|
||||
import { moduleBackgroundEmbedding, ReloadGUIPointer, selectedCharID } from "src/ts/stores";
|
||||
import { onDestroy } from "svelte";
|
||||
|
||||
let backgroundHTML = ''
|
||||
@@ -43,14 +43,12 @@
|
||||
|
||||
{#if backgroundHTML || $moduleBackgroundEmbedding}
|
||||
{#if $selectedCharID > -1}
|
||||
{#key $CurrentVariablePointer}
|
||||
{#key $ReloadGUIPointer}
|
||||
<div class="absolute top-0 left-0 w-full h-full">
|
||||
{#await ParseMarkdown(risuChatParser((backgroundHTML || '') + ($moduleBackgroundEmbedding || ''), {chara:currentChar}), currentChar, 'back') then md}
|
||||
{@html md}
|
||||
{/await}
|
||||
</div>
|
||||
{/key}
|
||||
{#key $ReloadGUIPointer}
|
||||
<div class="absolute top-0 left-0 w-full h-full">
|
||||
{#await ParseMarkdown(risuChatParser((backgroundHTML || '') + ($moduleBackgroundEmbedding || ''), {chara:currentChar}), currentChar, 'back') then md}
|
||||
{@html md}
|
||||
{/await}
|
||||
</div>
|
||||
{/key}
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -5,7 +5,7 @@
|
||||
import { alertConfirm, alertError, alertRequestData } from "../../ts/alert";
|
||||
import { language } from "../../lang";
|
||||
import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database";
|
||||
import { CurrentCharacter, CurrentChat, CurrentVariablePointer, HideIconStore, ReloadGUIPointer } from "../../ts/stores";
|
||||
import { CurrentCharacter, CurrentChat, HideIconStore, ReloadGUIPointer } from "../../ts/stores";
|
||||
import { translateHTML } from "../../ts/translator/translator";
|
||||
import { risuChatParser } from "src/ts/process/scripts";
|
||||
import { get, type Unsubscriber } from "svelte/store";
|
||||
@@ -146,9 +146,6 @@
|
||||
const unsubscribers:Unsubscriber[] = []
|
||||
|
||||
onMount(()=>{
|
||||
unsubscribers.push(CurrentVariablePointer.subscribe((v) => {
|
||||
displaya(message)
|
||||
}))
|
||||
unsubscribers.push(ReloadGUIPointer.subscribe((v) => {
|
||||
displaya(message)
|
||||
}))
|
||||
@@ -295,13 +292,11 @@
|
||||
style:line-height="{($DataBase.lineHeight ?? 1.25) * ($DataBase.zoomsize / 100)}rem"
|
||||
>
|
||||
{#key $ReloadGUIPointer}
|
||||
{#key $CurrentVariablePointer}
|
||||
{#await markParsing(msgDisplay, character, 'normal', idx, translated)}
|
||||
{@html lastParsed}
|
||||
{:then md}
|
||||
{@html md}
|
||||
{/await}
|
||||
{/key}
|
||||
{#await markParsing(msgDisplay, character, 'normal', idx, translated)}
|
||||
{@html lastParsed}
|
||||
{:then md}
|
||||
{@html md}
|
||||
{/await}
|
||||
{/key}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
@@ -601,32 +601,34 @@
|
||||
<Chat
|
||||
character={$CurrentSimpleCharacter}
|
||||
name={$CurrentCharacter.name}
|
||||
message={$CurrentCharacter.firstMsgIndex === -1 ? $CurrentCharacter.firstMessage :
|
||||
$CurrentCharacter.alternateGreetings[$CurrentCharacter.firstMsgIndex]}
|
||||
message={$CurrentChat.fmIndex === -1 ? $CurrentCharacter.firstMessage :
|
||||
$CurrentCharacter.alternateGreetings[$CurrentChat.fmIndex]}
|
||||
img={getCharImage($CurrentCharacter.image, 'css')}
|
||||
idx={-1}
|
||||
altGreeting={$CurrentCharacter.alternateGreetings.length > 0}
|
||||
largePortrait={$CurrentCharacter.largePortrait}
|
||||
onReroll={() => {
|
||||
const cha = $CurrentCharacter
|
||||
const chat = $CurrentChat
|
||||
if(cha.type !== 'group'){
|
||||
if (cha.firstMsgIndex >= (cha.alternateGreetings.length - 1)){
|
||||
cha.firstMsgIndex = -1
|
||||
if (chat.fmIndex >= (cha.alternateGreetings.length - 1)){
|
||||
chat.fmIndex = -1
|
||||
}
|
||||
else{
|
||||
cha.firstMsgIndex += 1
|
||||
chat.fmIndex += 1
|
||||
}
|
||||
}
|
||||
$CurrentCharacter = cha
|
||||
$CurrentChat = chat
|
||||
}}
|
||||
unReroll={() => {
|
||||
const cha = $CurrentCharacter
|
||||
const chat = $CurrentChat
|
||||
if(cha.type !== 'group'){
|
||||
if (cha.firstMsgIndex === -1){
|
||||
cha.firstMsgIndex = (cha.alternateGreetings.length - 1)
|
||||
if (chat.fmIndex === -1){
|
||||
chat.fmIndex = (cha.alternateGreetings.length - 1)
|
||||
}
|
||||
else{
|
||||
cha.firstMsgIndex -= 1
|
||||
chat.fmIndex -= 1
|
||||
}
|
||||
}
|
||||
$CurrentCharacter = cha
|
||||
|
||||
@@ -51,15 +51,6 @@
|
||||
let currentChar:character|groupChat = $CurrentCharacter;
|
||||
let messages:Message[] = []
|
||||
|
||||
if(currentChar.type !== 'group'){
|
||||
const firstMsg:string = currentChar.firstMsgIndex === -1 ? currentChar.firstMessage : currentChar.alternateGreetings[currentChar.firstMsgIndex]
|
||||
messages.push({
|
||||
role: 'char',
|
||||
data: await processScript(currentChar,
|
||||
replacePlaceholders(firstMsg, currentChar.name),
|
||||
'editprocess')
|
||||
})
|
||||
}
|
||||
messages = [...messages, ...currentChar.chats[currentChar.chatPage].message];
|
||||
let lastMessages:Message[] = messages.slice(Math.max(messages.length - 10, 0));
|
||||
if(lastMessages.length === 0)
|
||||
|
||||
Reference in New Issue
Block a user