mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/BlipRanger/SillyTavern into feature/stats
This commit is contained in:
@@ -58,11 +58,6 @@ export const chat_styles = {
|
||||
DOCUMENT: 2,
|
||||
}
|
||||
|
||||
const sheld_width = {
|
||||
DEFAULT: 0,
|
||||
w1000px: 1,
|
||||
}
|
||||
|
||||
const pygmalion_options = {
|
||||
DISABLED: -1,
|
||||
AUTO: 0,
|
||||
@@ -117,7 +112,7 @@ let power_user = {
|
||||
fast_ui_mode: true,
|
||||
avatar_style: avatar_styles.ROUND,
|
||||
chat_display: chat_styles.DEFAULT,
|
||||
sheld_width: sheld_width.DEFAULT,
|
||||
chat_width: 50,
|
||||
never_resize_avatars: false,
|
||||
show_card_avatar_urls: false,
|
||||
play_message_sound: false,
|
||||
@@ -143,9 +138,11 @@ let power_user = {
|
||||
waifuMode: false,
|
||||
movingUI: false,
|
||||
movingUIState: {},
|
||||
movingUIPreset: '',
|
||||
noShadows: false,
|
||||
theme: 'Default (Dark) 1.7.1',
|
||||
|
||||
|
||||
auto_swipe: false,
|
||||
auto_swipe_minimum_length: 0,
|
||||
auto_swipe_blacklist: [],
|
||||
@@ -193,13 +190,14 @@ let power_user = {
|
||||
};
|
||||
|
||||
let themes = [];
|
||||
let movingUIPresets = [];
|
||||
let instruct_presets = [];
|
||||
|
||||
const storage_keys = {
|
||||
fast_ui_mode: "TavernAI_fast_ui_mode",
|
||||
avatar_style: "TavernAI_avatar_style",
|
||||
chat_display: "TavernAI_chat_display",
|
||||
sheld_width: "TavernAI_sheld_width",
|
||||
chat_width: "chat_width",
|
||||
font_scale: "TavernAI_font_scale",
|
||||
|
||||
main_text_color: "TavernAI_main_text_color",
|
||||
@@ -406,18 +404,11 @@ function applyChatDisplay() {
|
||||
}
|
||||
}
|
||||
|
||||
function applySheldWidth() {
|
||||
//disabled due to 50vw conversion
|
||||
return
|
||||
power_user.sheld_width = Number(localStorage.getItem(storage_keys.sheld_width) ?? chat_styles.DEFAULT);
|
||||
$("body").toggleClass("w1000px", power_user.sheld_width === sheld_width.w1000px);
|
||||
function applyChatWidth() {
|
||||
power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
|
||||
let r = document.documentElement;
|
||||
if (power_user.sheld_width === 1) {
|
||||
r.style.setProperty('--sheldWidth', '1000px');
|
||||
} else {
|
||||
r.style.setProperty('--sheldWidth', '800px');
|
||||
}
|
||||
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
||||
r.style.setProperty('--sheldWidth', `${power_user.chat_width}vw`);
|
||||
$('#chat_width_slider').val(power_user.chat_width);
|
||||
}
|
||||
|
||||
async function applyThemeColor(type) {
|
||||
@@ -542,10 +533,10 @@ async function applyTheme(name) {
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'sheld_width',
|
||||
key: 'chat_width',
|
||||
action: async () => {
|
||||
localStorage.setItem(storage_keys.sheld_width, power_user.sheld_width);
|
||||
applySheldWidth();
|
||||
localStorage.setItem(storage_keys.chat_width, power_user.chat_width);
|
||||
applyChatWidth();
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -594,10 +585,25 @@ async function applyTheme(name) {
|
||||
console.log('theme applied: ' + name);
|
||||
}
|
||||
|
||||
async function applyMovingUIPreset(name) {
|
||||
resetMovablePanels('quiet')
|
||||
const movingUIPreset = movingUIPresets.find(x => x.name == name);
|
||||
|
||||
if (!movingUIPreset) {
|
||||
return;
|
||||
}
|
||||
|
||||
power_user.movingUIState = movingUIPreset.movingUIState;
|
||||
|
||||
|
||||
console.log('MovingUI Preset applied: ' + name);
|
||||
loadMovingUIState()
|
||||
}
|
||||
|
||||
switchUiMode();
|
||||
applyFontScale();
|
||||
applyThemeColor();
|
||||
applySheldWidth();
|
||||
applyChatWidth();
|
||||
applyAvatarStyle();
|
||||
applyBlurStrength();
|
||||
applyShadowWidth();
|
||||
@@ -618,6 +624,10 @@ function loadPowerUserSettings(settings, data) {
|
||||
themes = data.themes;
|
||||
}
|
||||
|
||||
if (data.movingUIPresets !== undefined) {
|
||||
movingUIPresets = data.movingUIPresets;
|
||||
}
|
||||
|
||||
if (data.instruct !== undefined) {
|
||||
instruct_presets = data.instruct;
|
||||
}
|
||||
@@ -639,7 +649,7 @@ function loadPowerUserSettings(settings, data) {
|
||||
power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == "true";
|
||||
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
|
||||
//power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT);
|
||||
power_user.sheld_width = Number(localStorage.getItem(storage_keys.sheld_width) ?? sheld_width.DEFAULT);
|
||||
power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
|
||||
power_user.font_scale = Number(localStorage.getItem(storage_keys.font_scale) ?? 1);
|
||||
power_user.blur_strength = Number(localStorage.getItem(storage_keys.blur_strength) ?? 10);
|
||||
|
||||
@@ -706,7 +716,7 @@ function loadPowerUserSettings(settings, data) {
|
||||
$("#prefer_character_jailbreak").prop("checked", power_user.prefer_character_jailbreak);
|
||||
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
||||
$(`#chat_display option[value=${power_user.chat_display}]`).attr("selected", true).trigger('change');
|
||||
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
||||
$('#chat_width_slider').val(power_user.chat_width);
|
||||
$("#token_padding").val(power_user.token_padding);
|
||||
|
||||
$("#font_scale").val(power_user.font_scale);
|
||||
@@ -735,6 +745,15 @@ function loadPowerUserSettings(settings, data) {
|
||||
$("#themes").append(option);
|
||||
}
|
||||
|
||||
for (const movingUIPreset of movingUIPresets) {
|
||||
const option = document.createElement('option');
|
||||
option.value = movingUIPreset.name;
|
||||
option.innerText = movingUIPreset.name;
|
||||
option.selected = movingUIPreset.name == power_user.movingUIPreset;
|
||||
$("#movingUIPresets").append(option);
|
||||
}
|
||||
|
||||
|
||||
$(`#character_sort_order option[data-order="${power_user.sort_order}"][data-field="${power_user.sort_field}"]`).prop("selected", true);
|
||||
sortCharactersList();
|
||||
reloadMarkdownProcessor(power_user.render_formulas);
|
||||
@@ -917,6 +936,10 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1,
|
||||
|
||||
const sortFunc = (a, b) => power_user.sort_order == 'asc' ? compareFunc(a, b) : compareFunc(b, a);
|
||||
const compareFunc = (first, second) => {
|
||||
if (power_user.sort_order == 'random') {
|
||||
return Math.random() > 0.5 ? 1 : -1;
|
||||
}
|
||||
|
||||
switch (power_user.sort_rule) {
|
||||
case 'boolean':
|
||||
const a = first[power_user.sort_field];
|
||||
@@ -999,7 +1022,7 @@ async function saveTheme() {
|
||||
avatar_style: power_user.avatar_style,
|
||||
chat_display: power_user.chat_display,
|
||||
noShadows: power_user.noShadows,
|
||||
sheld_width: power_user.sheld_width,
|
||||
chat_width: power_user.chat_width,
|
||||
timer_enabled: power_user.timer_enabled,
|
||||
timestamps_enabled: power_user.timestamps_enabled,
|
||||
mesIDDisplay_enabled: power_user.mesIDDisplay_enabled,
|
||||
@@ -1034,6 +1057,48 @@ async function saveTheme() {
|
||||
}
|
||||
}
|
||||
|
||||
async function saveMovingUI() {
|
||||
const name = await callPopup('Enter a name for the MovingUI Preset:', 'input');
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
const movingUIPreset = {
|
||||
name,
|
||||
movingUIState: power_user.movingUIState
|
||||
}
|
||||
console.log(movingUIPreset)
|
||||
|
||||
const response = await fetch('/savemovingui', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify(movingUIPreset)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const movingUIPresetIndex = movingUIPresets.findIndex(x => x.name == name);
|
||||
|
||||
if (movingUIPresetIndex == -1) {
|
||||
movingUIPresets.push(movingUIPreset);
|
||||
const option = document.createElement('option');
|
||||
option.selected = true;
|
||||
option.value = name;
|
||||
option.innerText = name;
|
||||
$('#movingUIPresets').append(option);
|
||||
}
|
||||
else {
|
||||
movingUIPresets[movingUIPresetIndex] = movingUIPreset;
|
||||
$(`#movingUIPresets option[value="${name}"]`).attr('selected', true);
|
||||
}
|
||||
|
||||
power_user.movingUIPreset = name;
|
||||
saveSettingsDebounced();
|
||||
} else {
|
||||
toastr.warning('failed to save MovingUI state.')
|
||||
}
|
||||
}
|
||||
|
||||
async function resetMovablePanels(type) {
|
||||
const panelIds = [
|
||||
'sheld',
|
||||
@@ -1072,13 +1137,25 @@ async function resetMovablePanels(type) {
|
||||
await delay(50)
|
||||
|
||||
power_user.movingUIState = {};
|
||||
|
||||
//if user manually resets panels, deselect the current preset
|
||||
if (type !== 'quiet' && type !== 'resize') {
|
||||
power_user.movingUIPreset = 'Default'
|
||||
$(`#movingUIPresets option[value="Default"]`).prop('selected', true);
|
||||
}
|
||||
|
||||
saveSettingsDebounced();
|
||||
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
|
||||
|
||||
eventSource.once(event_types.SETTINGS_UPDATED, () => {
|
||||
$(".resizing").removeClass('resizing');
|
||||
if (type === 'resize') {
|
||||
//if happening as part of preset application, do it quietly.
|
||||
if (type === 'quiet') {
|
||||
return
|
||||
//if happening due to resize, tell user.
|
||||
} else if (type === 'resize') {
|
||||
toastr.warning('Panel positions reset due to zoom/resize');
|
||||
//if happening due to manual button press
|
||||
} else {
|
||||
toastr.success('Panel positions reset');
|
||||
}
|
||||
@@ -1578,11 +1655,10 @@ $(document).ready(() => {
|
||||
|
||||
});
|
||||
|
||||
$(`input[name="sheld_width"]`).on('input', function (e) {
|
||||
power_user.sheld_width = Number(e.target.value);
|
||||
localStorage.setItem(storage_keys.sheld_width, power_user.sheld_width);
|
||||
//console.log("sheld width changing now");
|
||||
applySheldWidth();
|
||||
$('#chat_width_slider').on('input', function (e) {
|
||||
power_user.chat_width = Number(e.target.value);
|
||||
localStorage.setItem(storage_keys.chat_width, power_user.chat_width);
|
||||
applyChatWidth();
|
||||
});
|
||||
|
||||
$(`input[name="font_scale"]`).on('input', async function (e) {
|
||||
@@ -1655,7 +1731,17 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#movingUIPresets").on('change', async function () {
|
||||
console.log('saw MUI preset change')
|
||||
const movingUIPresetSelected = $(this).find(':selected').val();
|
||||
power_user.movingUIPreset = movingUIPresetSelected;
|
||||
applyMovingUIPreset(movingUIPresetSelected);
|
||||
saveSettingsDebounced();
|
||||
|
||||
});
|
||||
|
||||
$("#ui-preset-save-button").on('click', saveTheme);
|
||||
$("#movingui-preset-save-button").on('click', saveMovingUI);
|
||||
|
||||
$("#never_resize_avatars").on('input', function () {
|
||||
power_user.never_resize_avatars = !!$(this).prop('checked');
|
||||
|
||||
Reference in New Issue
Block a user