mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add debug functions menu
This commit is contained in:
@ -13,7 +13,8 @@ import {
|
||||
getCurrentChatId,
|
||||
printCharacters,
|
||||
setCharacterId,
|
||||
setEditedMessageId
|
||||
setEditedMessageId,
|
||||
renderTemplate,
|
||||
} from "../script.js";
|
||||
import { isMobile, initMovingUI } from "./RossAscends-mods.js";
|
||||
import {
|
||||
@ -232,6 +233,7 @@ const storage_keys = {
|
||||
};
|
||||
|
||||
let browser_has_focus = true;
|
||||
const debug_functions = [];
|
||||
|
||||
function playMessageSound() {
|
||||
if (!power_user.play_message_sound) {
|
||||
@ -653,6 +655,22 @@ async function applyMovingUIPreset(name) {
|
||||
loadMovingUIState()
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function to be executed when the debug menu is opened.
|
||||
* @param {string} functionId Unique ID for the function.
|
||||
* @param {string} name Name of the function.
|
||||
* @param {string} description Description of the function.
|
||||
* @param {function} func Function to be executed.
|
||||
*/
|
||||
export function registerDebugFunction(functionId, name, description, func) {
|
||||
debug_functions.push({ functionId, name, description, func });
|
||||
}
|
||||
|
||||
function showDebugMenu() {
|
||||
const template = renderTemplate('debug', { functions: debug_functions });
|
||||
callPopup(template, 'text', '', { wide: true, large: true });
|
||||
}
|
||||
|
||||
switchUiMode();
|
||||
applyFontScale('forced');
|
||||
applyThemeColor();
|
||||
@ -2113,6 +2131,21 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#debug_menu').on('click', function () {
|
||||
showDebugMenu();
|
||||
});
|
||||
|
||||
$(document).on('click', '#debug_table [data-debug-function]', function () {
|
||||
const functionId = $(this).data('debug-function');
|
||||
const functionRecord = debug_functions.find(f => f.functionId === functionId);
|
||||
|
||||
if (functionRecord) {
|
||||
functionRecord.func();
|
||||
} else {
|
||||
console.warn(`Debug function ${functionId} not found`);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on('focus', function () {
|
||||
browser_has_focus = true;
|
||||
});
|
||||
|
Reference in New Issue
Block a user