add hidechaticon

This commit is contained in:
kwaroran
2024-07-10 16:17:33 +09:00
parent 98576eeae4
commit 0ee481d00d
7 changed files with 51 additions and 3 deletions

View File

@@ -668,4 +668,5 @@ export const languageEnglish = {
codeMode: "Code", codeMode: "Code",
blockMode: "Block", blockMode: "Block",
helpBlock: "Help", helpBlock: "Help",
hideChatIcon: "Hide Icon UI",
} }

View File

@@ -5,7 +5,7 @@
import { alertConfirm, alertError, alertRequestData } from "../../ts/alert"; import { alertConfirm, alertError, alertRequestData } from "../../ts/alert";
import { language } from "../../lang"; import { language } from "../../lang";
import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database"; import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database";
import { CurrentCharacter, CurrentChat, CurrentVariablePointer } from "../../ts/stores"; import { CurrentCharacter, CurrentChat, CurrentVariablePointer, HideIconStore } from "../../ts/stores";
import { translateHTML } from "../../ts/translator/translator"; import { translateHTML } from "../../ts/translator/translator";
import { risuChatParser } from "src/ts/process/scripts"; import { risuChatParser } from "src/ts/process/scripts";
import { get } from "svelte/store"; import { get } from "svelte/store";
@@ -144,7 +144,7 @@
</script> </script>
<div class="flex max-w-full justify-center risu-chat" style={isLastMemory ? `border-top:${$DataBase.memoryLimitThickness}px solid rgba(98, 114, 164, 0.7);` : ''}> <div class="flex max-w-full justify-center risu-chat" style={isLastMemory ? `border-top:${$DataBase.memoryLimitThickness}px solid rgba(98, 114, 164, 0.7);` : ''}>
<div class="text-textcolor mt-1 ml-4 mr-4 mb-1 p-2 bg-transparent flex-grow border-t-gray-900 border-opacity-30 border-transparent flexium items-start max-w-full" > <div class="text-textcolor mt-1 ml-4 mr-4 mb-1 p-2 bg-transparent flex-grow border-t-gray-900 border-opacity-30 border-transparent flexium items-start max-w-full" >
{#if !blankMessage} {#if !blankMessage && !$HideIconStore}
{#if $CurrentCharacter?.chaId === "§playground"} {#if $CurrentCharacter?.chaId === "§playground"}
<div class="shadow-lg border-textcolor2 border mt-2 flex justify-center items-center text-textcolor2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem;min-width:${$DataBase.iconsize * 3.5 / 100}rem`} <div class="shadow-lg border-textcolor2 border mt-2 flex justify-center items-center text-textcolor2" style={`height:${$DataBase.iconsize * 3.5 / 100}rem;width:${$DataBase.iconsize * 3.5 / 100}rem;min-width:${$DataBase.iconsize * 3.5 / 100}rem`}
class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons}> class:rounded-md={!$DataBase.roundIcons} class:rounded-full={$DataBase.roundIcons}>

View File

@@ -202,4 +202,8 @@
<Check bind:check={currentModule.lowLevelAccess} name={language.lowLevelAccess}/> <Check bind:check={currentModule.lowLevelAccess} name={language.lowLevelAccess}/>
<span> <Help key="lowLevelAccess" name={language.lowLevelAccess}/></span> <span> <Help key="lowLevelAccess" name={language.lowLevelAccess}/></span>
</div> </div>
{/if} {/if}
<div class="flex items-center mt-4">
<Check bind:check={currentModule.hideIcon} name={language.hideChatIcon}/>
</div>

View File

@@ -966,6 +966,10 @@
<span> <Help key="lowLevelAccess" name={language.lowLevelAccess}/></span> <span> <Help key="lowLevelAccess" name={language.lowLevelAccess}/></span>
</div> </div>
<div class="flex items-center mt-4">
<Check bind:check={currentChar.data.hideChatIcon} name={language.hideChatIcon}/>
</div>
<div class="flex items-center mt-4"> <div class="flex items-center mt-4">
<Check bind:check={currentChar.data.utilityBot} name={language.utilityBot}/> <Check bind:check={currentChar.data.utilityBot} name={language.utilityBot}/>
<span> <Help key="utilityBot" name={language.utilityBot}/></span> <span> <Help key="utilityBot" name={language.utilityBot}/></span>

View File

@@ -17,6 +17,7 @@ export interface RisuModule{
trigger?: triggerscript[] trigger?: triggerscript[]
id: string id: string
lowLevelAccess?: boolean lowLevelAccess?: boolean
hideIcon?: boolean
} }
export async function exportModule(module:RisuModule){ export async function exportModule(module:RisuModule){

View File

@@ -826,6 +826,7 @@ export interface character{
}> }>
defaultVariables?:string defaultVariables?:string
lowLevelAccess?:boolean lowLevelAccess?:boolean
hideChatIcon?:boolean
} }
@@ -873,6 +874,7 @@ export interface groupChat{
nickname?:string nickname?:string
defaultVariables?:string defaultVariables?:string
lowLevelAccess?:boolean lowLevelAccess?:boolean
hideChatIcon?:boolean
} }
export interface botPreset{ export interface botPreset{

View File

@@ -3,6 +3,7 @@ import { DataBase, type Chat, type character, type groupChat } from "./storage/d
import { isEqual } from "lodash"; import { isEqual } from "lodash";
import type { simpleCharacterArgument } from "./parser"; import type { simpleCharacterArgument } from "./parser";
import { sleep } from "./util"; import { sleep } from "./util";
import { getModules } from "./process/modules";
function updateSize(){ function updateSize(){
SizeStore.set({ SizeStore.set({
@@ -39,6 +40,11 @@ export const CurrentVariablePointer = writable({} as {[key:string]: string|numbe
export const OpenRealmStore = writable(false) export const OpenRealmStore = writable(false)
export const ShowRealmFrameStore = writable('') export const ShowRealmFrameStore = writable('')
export const PlaygroundStore = writable(0) export const PlaygroundStore = writable(0)
export const HideIconStore = writable(false)
let lastGlobalEnabledModules: string[] = []
let lastChatEnabledModules: string[] = []
let moduleHideIcon = false
let characterHideIcon = false
function createSimpleCharacter(char:character|groupChat){ function createSimpleCharacter(char:character|groupChat){
if((!char) || char.type === 'group'){ if((!char) || char.type === 'group'){
@@ -133,6 +139,11 @@ async function preInit(){
if(data.showMemoryLimit !== get(CurrentShowMemoryLimit)){ if(data.showMemoryLimit !== get(CurrentShowMemoryLimit)){
CurrentShowMemoryLimit.set(data.showMemoryLimit) CurrentShowMemoryLimit.set(data.showMemoryLimit)
} }
if(!isEqual(data.enabledModules, lastGlobalEnabledModules)){
lastGlobalEnabledModules = data.enabledModules
onModuleUpdate()
return
}
}) })
selectedCharID.subscribe((id) => { selectedCharID.subscribe((id) => {
@@ -144,6 +155,11 @@ async function preInit(){
updateCurrentChat() updateCurrentChat()
let db = get(DataBase) let db = get(DataBase)
let charId = get(selectedCharID) let charId = get(selectedCharID)
if(char.hideChatIcon !== characterHideIcon){
characterHideIcon = char.hideChatIcon
HideIconStore.set(characterHideIcon || moduleHideIcon)
}
if(charId === -1 || charId > db.characters.length){ if(charId === -1 || charId > db.characters.length){
return return
} }
@@ -165,6 +181,12 @@ async function preInit(){
} }
} }
if(!isEqual(lastChatEnabledModules, chat?.modules)){
lastChatEnabledModules = chat?.modules
onModuleUpdate()
return
}
const variablePointer = get(CurrentVariablePointer) const variablePointer = get(CurrentVariablePointer)
const currentState = structuredClone(chat?.scriptstate) const currentState = structuredClone(chat?.scriptstate)
@@ -174,6 +196,20 @@ async function preInit(){
}) })
} }
function onModuleUpdate(){
const m = getModules([
...lastGlobalEnabledModules, ...lastChatEnabledModules
])
let moduleHideIcon = false
m.forEach((module) => {
if(module.hideIcon){
moduleHideIcon = true
}
})
HideIconStore.set(characterHideIcon || moduleHideIcon)
}
updateSize() updateSize()
window.addEventListener("resize", updateSize); window.addEventListener("resize", updateSize);