[feat] private characters
This commit is contained in:
@@ -104,6 +104,7 @@
|
|||||||
|
|
||||||
let assetFileExtensions:string[] = []
|
let assetFileExtensions:string[] = []
|
||||||
let assetFilePath:string[] = []
|
let assetFilePath:string[] = []
|
||||||
|
let licensed = (currentChar.type === 'character') ? currentChar.data.license : ''
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if(database.characters[$selectedCharID].chaId === currentChar.data.chaId){
|
if(database.characters[$selectedCharID].chaId === currentChar.data.chaId){
|
||||||
@@ -133,34 +134,38 @@
|
|||||||
|
|
||||||
onDestroy(unsub);
|
onDestroy(unsub);
|
||||||
|
|
||||||
|
|
||||||
|
$:licensed = (currentChar.type === 'character') ? currentChar.data.license : ''
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex gap-2 mb-2">
|
{#if licensed !== 'private'}
|
||||||
<button class={subMenu === 0 ? 'text-gray-200 ' : 'text-gray-500'} on:click={() => {subMenu = 0}}>
|
<div class="flex gap-2 mb-2">
|
||||||
<UserIcon />
|
<button class={subMenu === 0 ? 'text-gray-200 ' : 'text-gray-500'} on:click={() => {subMenu = 0}}>
|
||||||
</button>
|
<UserIcon />
|
||||||
<button class={subMenu === 1 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 1}}>
|
|
||||||
<SmileIcon />
|
|
||||||
</button>
|
|
||||||
<button class={subMenu === 3 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 3}}>
|
|
||||||
<BookIcon />
|
|
||||||
</button>
|
|
||||||
{#if currentChar.type === 'character'}
|
|
||||||
<button class={subMenu === 5 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 5}}>
|
|
||||||
<Volume2Icon />
|
|
||||||
</button>
|
</button>
|
||||||
<button class={subMenu === 4 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 4}}>
|
<button class={subMenu === 1 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 1}}>
|
||||||
<CurlyBraces />
|
<SmileIcon />
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
<button class={subMenu === 3 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 3}}>
|
||||||
<button class={subMenu === 2 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 2}}>
|
<BookIcon />
|
||||||
<ActivityIcon />
|
</button>
|
||||||
</button>
|
{#if currentChar.type === 'character'}
|
||||||
</div>
|
<button class={subMenu === 5 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 5}}>
|
||||||
|
<Volume2Icon />
|
||||||
|
</button>
|
||||||
|
<button class={subMenu === 4 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 4}}>
|
||||||
|
<CurlyBraces />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
<button class={subMenu === 2 ? 'text-gray-200' : 'text-gray-500'} on:click={() => {subMenu = 2}}>
|
||||||
|
<ActivityIcon />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
{#if subMenu === 0}
|
{#if subMenu === 0}
|
||||||
{#if currentChar.type !== 'group'}
|
{#if currentChar.type !== 'group' && licensed !== 'private'}
|
||||||
<TextInput size="xl" marginBottom placeholder="Character Name" bind:value={currentChar.data.name} />
|
<TextInput size="xl" marginBottom placeholder="Character Name" bind:value={currentChar.data.name} />
|
||||||
<span class="text-neutral-200">{language.description} <Help key="charDesc"/></span>
|
<span class="text-neutral-200">{language.description} <Help key="charDesc"/></span>
|
||||||
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.desc}></TextAreaInput>
|
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.desc}></TextAreaInput>
|
||||||
@@ -169,7 +174,7 @@
|
|||||||
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.firstMessage}></TextAreaInput>
|
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.firstMessage}></TextAreaInput>
|
||||||
<span class="text-gray-400 mb-6 text-sm">{tokens.firstMsg} {language.tokens}</span>
|
<span class="text-gray-400 mb-6 text-sm">{tokens.firstMsg} {language.tokens}</span>
|
||||||
|
|
||||||
{:else}
|
{:else if licensed !== 'private' && currentChar.type === 'group'}
|
||||||
<TextInput size="xl" marginBottom placeholder="Group Name" bind:value={currentChar.data.name} />
|
<TextInput size="xl" marginBottom placeholder="Group Name" bind:value={currentChar.data.name} />
|
||||||
<span class="text-neutral-200">{language.character}</span>
|
<span class="text-neutral-200">{language.character}</span>
|
||||||
<div class="p-4 gap-2 bg-bgcolor rounded-lg char-grid">
|
<div class="p-4 gap-2 bg-bgcolor rounded-lg char-grid">
|
||||||
@@ -237,6 +242,29 @@
|
|||||||
<Check bind:check={currentChar.data.orderByOrder} name={language.orderByOrder}/>
|
<Check bind:check={currentChar.data.orderByOrder} name={language.orderByOrder}/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if licensed === 'private'}
|
||||||
|
<Button on:click={async () => {
|
||||||
|
const conf = await alertConfirm(language.removeConfirm + currentChar.data.name)
|
||||||
|
if(!conf){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const conf2 = await alertConfirm(language.removeConfirm2 + currentChar.data.name)
|
||||||
|
if(!conf2){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let chars = $DataBase.characters
|
||||||
|
chars.splice($selectedCharID, 1)
|
||||||
|
checkCharOrder()
|
||||||
|
$selectedCharID = -1
|
||||||
|
$DataBase.characters = chars
|
||||||
|
|
||||||
|
}} className="mt-2" size="sm">{ currentChar.type === 'group' ? language.removeGroup : language.removeCharacter}</Button>
|
||||||
|
{/if}
|
||||||
|
{:else if licensed === 'private'}
|
||||||
|
<span>You are not allowed</span>
|
||||||
|
{(() => {
|
||||||
|
subMenu = 0
|
||||||
|
})()}
|
||||||
{:else if subMenu === 1}
|
{:else if subMenu === 1}
|
||||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.characterDisplay}</h2>
|
<h2 class="mb-2 text-2xl font-bold mt-2">{language.characterDisplay}</h2>
|
||||||
<span class="text-neutral-200 mt-2 mb-2">{currentChar.type !== 'group' ? language.charIcon : language.groupIcon}</span>
|
<span class="text-neutral-200 mt-2 mb-2">{currentChar.type !== 'group' ? language.charIcon : language.groupIcon}</span>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
}}>
|
}}>
|
||||||
<img alt="creative commons" class="cc" src="https://i.creativecommons.org/l/{CCLicenseData[license][0]}/4.0/88x31.png" />
|
<img alt="creative commons" class="cc" src="https://i.creativecommons.org/l/{CCLicenseData[license][0]}/4.0/88x31.png" />
|
||||||
<span class="text-gray-500">
|
<span class="text-gray-500">
|
||||||
Licensed with {license}
|
Licensed with {CCLicenseData[license][2]}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
<SelectInput bind:value={license}>
|
<SelectInput bind:value={license}>
|
||||||
<OptionInput value="">None</OptionInput>
|
<OptionInput value="">None</OptionInput>
|
||||||
{#each Object.keys(CCLicenseData) as ccl}
|
{#each Object.keys(CCLicenseData) as ccl}
|
||||||
<OptionInput value={ccl}>{ccl} ({CCLicenseData[ccl][1]})</OptionInput>
|
<OptionInput value={ccl}>{CCLicenseData[ccl][2]} ({CCLicenseData[ccl][1]})</OptionInput>
|
||||||
{/each}
|
{/each}
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ function convertOldTavernAndJSON(charaData:OldTavernChar, imgp:string|undefined
|
|||||||
scenario:charaData.scenario ?? '',
|
scenario:charaData.scenario ?? '',
|
||||||
firstMsgIndex: -1,
|
firstMsgIndex: -1,
|
||||||
replaceGlobalNote: "",
|
replaceGlobalNote: "",
|
||||||
triggerscript: []
|
triggerscript: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +345,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array, mode?:'hub'|'
|
|||||||
replaceGlobalNote: data.post_history_instructions ?? '',
|
replaceGlobalNote: data.post_history_instructions ?? '',
|
||||||
backgroundHTML: data?.extensions?.risuai?.backgroundHTML,
|
backgroundHTML: data?.extensions?.risuai?.backgroundHTML,
|
||||||
license: data?.extensions?.risuai?.license,
|
license: data?.extensions?.risuai?.license,
|
||||||
triggerscript: data?.extensions?.risuai?.triggerscript ?? []
|
triggerscript: data?.extensions?.risuai?.triggerscript ?? [],
|
||||||
|
private: data?.extensions?.risuai?.private ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
db.characters.push(char)
|
db.characters.push(char)
|
||||||
@@ -557,7 +558,7 @@ export async function shareRisuHub(char:character, arg:{
|
|||||||
img: Buffer.from(img).toString('base64'),
|
img: Buffer.from(img).toString('base64'),
|
||||||
resources: resources,
|
resources: resources,
|
||||||
token: get(DataBase)?.account?.token,
|
token: get(DataBase)?.account?.token,
|
||||||
apiver: 2
|
apiver: 3
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -623,7 +624,7 @@ export async function downloadRisuHub(id:string) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
id: id,
|
id: id,
|
||||||
apiver: 2
|
apiver: 3
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if(res.status !== 200){
|
if(res.status !== 200){
|
||||||
@@ -689,6 +690,7 @@ type CharacterCardV2 = {
|
|||||||
backgroundHTML?:string,
|
backgroundHTML?:string,
|
||||||
license?:string,
|
license?:string,
|
||||||
triggerscript?:triggerscript[]
|
triggerscript?:triggerscript[]
|
||||||
|
private?:boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
export const CCLicenseData = {
|
export const CCLicenseData = {
|
||||||
"CC BY 4.0": ["by", "Requires Attribution"],
|
"CC BY 4.0": ["by", "Requires Attribution", "CC BY 4.0"],
|
||||||
"CC BY-NC 4.0": ["by-nc", "Requires Attribution and Non Commercial"],
|
"CC BY-NC 4.0": ["by-nc", "Requires Attribution and Non Commercial", "CC BY-NC 4.0"],
|
||||||
"CC BY-NC-SA 4.0": ["by-nc-sa", "Requires Attribution, Non Commercial and Share Alike"],
|
"CC BY-NC-SA 4.0": ["by-nc-sa", "Requires Attribution, Non Commercial and Share Alike", "CC BY-NC-SA 4.0"],
|
||||||
"CC BY-SA 4.0": ["by-sa", "Requires Attribution and Share Alike"],
|
"CC BY-SA 4.0": ["by-sa", "Requires Attribution and Share Alike", "CC BY-SA 4.0"],
|
||||||
"CC BY-ND 4.0": ["by-nd", "Requires Attribution and No Derivatives"],
|
"CC BY-ND 4.0": ["by-nd", "Requires Attribution and No Derivatives", "CC BY-ND 4.0"],
|
||||||
"CC BY-NC-ND 4.0": ["by-nc-nd", "Requires Attribution, Non Commercial and No Derivatives"],
|
"CC BY-NC-ND 4.0": ["by-nc-nd", "Requires Attribution, Non Commercial and No Derivatives", "CC BY-NC-ND 4.0"],
|
||||||
|
"private": ["by-nc-nd", "Requires Attribution, Non Commercial and No Derivatives + Private Prompts", "CC BY-NC-ND 4.0 + Private"],
|
||||||
}
|
}
|
||||||
@@ -375,6 +375,7 @@ export interface character{
|
|||||||
reloadKeys?:number
|
reloadKeys?:number
|
||||||
backgroundCSS?:string
|
backgroundCSS?:string
|
||||||
license?:string
|
license?:string
|
||||||
|
private?:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user