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

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

View File

@@ -826,6 +826,7 @@ export interface character{
}>
defaultVariables?:string
lowLevelAccess?:boolean
hideChatIcon?:boolean
}
@@ -873,6 +874,7 @@ export interface groupChat{
nickname?:string
defaultVariables?:string
lowLevelAccess?:boolean
hideChatIcon?:boolean
}
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 type { simpleCharacterArgument } from "./parser";
import { sleep } from "./util";
import { getModules } from "./process/modules";
function updateSize(){
SizeStore.set({
@@ -39,6 +40,11 @@ export const CurrentVariablePointer = writable({} as {[key:string]: string|numbe
export const OpenRealmStore = writable(false)
export const ShowRealmFrameStore = writable('')
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){
if((!char) || char.type === 'group'){
@@ -133,6 +139,11 @@ async function preInit(){
if(data.showMemoryLimit !== get(CurrentShowMemoryLimit)){
CurrentShowMemoryLimit.set(data.showMemoryLimit)
}
if(!isEqual(data.enabledModules, lastGlobalEnabledModules)){
lastGlobalEnabledModules = data.enabledModules
onModuleUpdate()
return
}
})
selectedCharID.subscribe((id) => {
@@ -144,6 +155,11 @@ async function preInit(){
updateCurrentChat()
let db = get(DataBase)
let charId = get(selectedCharID)
if(char.hideChatIcon !== characterHideIcon){
characterHideIcon = char.hideChatIcon
HideIconStore.set(characterHideIcon || moduleHideIcon)
}
if(charId === -1 || charId > db.characters.length){
return
}
@@ -165,6 +181,12 @@ async function preInit(){
}
}
if(!isEqual(lastChatEnabledModules, chat?.modules)){
lastChatEnabledModules = chat?.modules
onModuleUpdate()
return
}
const variablePointer = get(CurrentVariablePointer)
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()
window.addEventListener("resize", updateSize);