Release v3.0.0 - Major update with JSON format, lock/unlock trackers, reorganized UI, colored dialogues, editable prompts, and numerous bug fixes
This commit is contained in:
@@ -1,220 +0,0 @@
|
||||
/**
|
||||
* Debug UI Module
|
||||
* Provides mobile-friendly debug log viewer for troubleshooting parsing issues
|
||||
*/
|
||||
|
||||
import { extensionSettings, getDebugLogs, clearDebugLogs } from '../../core/state.js';
|
||||
|
||||
/**
|
||||
* Creates and injects the debug panel into the page
|
||||
* Note: Debug toggle button is created in index.js, not here
|
||||
*/
|
||||
export function createDebugPanel() {
|
||||
// Remove existing debug panel if any
|
||||
$('#rpg-debug-panel').remove();
|
||||
|
||||
// Create debug panel HTML
|
||||
const debugPanelHtml = `
|
||||
<div id="rpg-debug-panel" class="rpg-debug-panel">
|
||||
<div class="rpg-debug-header">
|
||||
<h3>🔍 Debug Logs</h3>
|
||||
<div class="rpg-debug-actions">
|
||||
<button id="rpg-debug-copy" title="Copy logs to clipboard">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</button>
|
||||
<button id="rpg-debug-clear" title="Clear logs">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
<button id="rpg-debug-close" title="Close debug panel">
|
||||
<i class="fa-solid fa-xmark"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="rpg-debug-logs" class="rpg-debug-logs"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Append to body
|
||||
$('body').append(debugPanelHtml);
|
||||
|
||||
// Set up event handlers
|
||||
setupDebugEventHandlers();
|
||||
|
||||
// Initial log render
|
||||
renderDebugLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the debug panel with proper animation (mobile or desktop)
|
||||
*/
|
||||
function closeDebugPanel() {
|
||||
const $panel = $('#rpg-debug-panel');
|
||||
const isMobile = window.innerWidth <= 1000;
|
||||
|
||||
if (isMobile) {
|
||||
// Mobile: animate slide-out to right
|
||||
$panel.removeClass('rpg-mobile-open').addClass('rpg-mobile-closing');
|
||||
|
||||
// Wait for animation to complete before hiding
|
||||
$panel.one('animationend', function() {
|
||||
$panel.removeClass('rpg-mobile-closing');
|
||||
$('.rpg-mobile-overlay').remove();
|
||||
});
|
||||
} else {
|
||||
// Desktop: simple slide-down
|
||||
$panel.removeClass('rpg-debug-open');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up event handlers for debug panel using event delegation for mobile compatibility
|
||||
*/
|
||||
function setupDebugEventHandlers() {
|
||||
// Use event delegation for better mobile compatibility and reliability with dynamic elements
|
||||
// Remove any existing handlers first to prevent duplicates
|
||||
$(document).off('click.rpgDebug');
|
||||
|
||||
// Toggle button
|
||||
$(document).on('click.rpgDebug', '#rpg-debug-toggle', function() {
|
||||
const $debugToggle = $(this);
|
||||
|
||||
// Skip if we just finished dragging
|
||||
if ($debugToggle.data('just-dragged')) {
|
||||
console.log('[RPG Debug] Click blocked - just finished dragging');
|
||||
return;
|
||||
}
|
||||
|
||||
const $panel = $('#rpg-debug-panel');
|
||||
const isMobile = window.innerWidth <= 1000;
|
||||
|
||||
if (isMobile) {
|
||||
// Mobile: use rpg-mobile-open class with slide-from-right animation
|
||||
const isOpen = $panel.hasClass('rpg-mobile-open');
|
||||
|
||||
if (isOpen) {
|
||||
// Close with animation
|
||||
closeDebugPanel();
|
||||
} else {
|
||||
// Open with animation
|
||||
$panel.addClass('rpg-mobile-open');
|
||||
renderDebugLogs();
|
||||
|
||||
// Create overlay for mobile
|
||||
const $overlay = $('<div class="rpg-mobile-overlay"></div>');
|
||||
$('body').append($overlay);
|
||||
|
||||
// Close when clicking overlay
|
||||
$overlay.on('click', function() {
|
||||
closeDebugPanel();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Desktop: use rpg-debug-open class with slide-from-bottom animation
|
||||
$panel.toggleClass('rpg-debug-open');
|
||||
renderDebugLogs();
|
||||
}
|
||||
});
|
||||
|
||||
// Close button
|
||||
$(document).on('click.rpgDebug', '#rpg-debug-close', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
closeDebugPanel();
|
||||
});
|
||||
|
||||
// Copy button
|
||||
$(document).on('click.rpgDebug', '#rpg-debug-copy', function() {
|
||||
const logs = getDebugLogs();
|
||||
const logsText = logs.map(log => {
|
||||
let text = `[${log.timestamp}] ${log.message}`;
|
||||
if (log.data) {
|
||||
text += `\n${log.data}`;
|
||||
}
|
||||
return text;
|
||||
}).join('\n\n');
|
||||
|
||||
navigator.clipboard.writeText(logsText).then(() => {
|
||||
// Show feedback
|
||||
const $btn = $(this);
|
||||
const $icon = $btn.find('i');
|
||||
$icon.removeClass('fa-copy').addClass('fa-check');
|
||||
setTimeout(() => {
|
||||
$icon.removeClass('fa-check').addClass('fa-copy');
|
||||
}, 1500);
|
||||
}).catch(err => {
|
||||
console.error('Failed to copy logs:', err);
|
||||
alert('Failed to copy logs. Please use browser console instead.');
|
||||
});
|
||||
});
|
||||
|
||||
// Clear button
|
||||
$(document).on('click.rpgDebug', '#rpg-debug-clear', function() {
|
||||
if (confirm('Clear all debug logs?')) {
|
||||
clearDebugLogs();
|
||||
renderDebugLogs();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders debug logs to the panel
|
||||
*/
|
||||
function renderDebugLogs() {
|
||||
const logs = getDebugLogs();
|
||||
const $logsContainer = $('#rpg-debug-logs');
|
||||
|
||||
if (logs.length === 0) {
|
||||
$logsContainer.html('<div class="rpg-debug-empty">No logs yet. Logs will appear when parser runs.</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
// Build logs HTML
|
||||
const logsHtml = logs.map(log => {
|
||||
let html = `<div class="rpg-debug-entry">`;
|
||||
html += `<span class="rpg-debug-time">[${log.timestamp}]</span> `;
|
||||
html += `<span class="rpg-debug-message">${escapeHtml(log.message)}</span>`;
|
||||
if (log.data) {
|
||||
html += `<pre class="rpg-debug-data">${escapeHtml(log.data)}</pre>`;
|
||||
}
|
||||
html += `</div>`;
|
||||
return html;
|
||||
}).join('');
|
||||
|
||||
$logsContainer.html(logsHtml);
|
||||
|
||||
// Auto-scroll to bottom
|
||||
$logsContainer[0].scrollTop = $logsContainer[0].scrollHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes HTML to prevent XSS
|
||||
*/
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows or hides debug UI based on debug mode setting
|
||||
* Note: Debug toggle button always exists in DOM (created in index.js)
|
||||
*/
|
||||
export function updateDebugUIVisibility() {
|
||||
const $debugToggle = $('#rpg-debug-toggle');
|
||||
|
||||
if (extensionSettings.debugMode) {
|
||||
// Show debug toggle button
|
||||
$debugToggle.css('display', 'flex');
|
||||
|
||||
// Create debug panel if it doesn't exist
|
||||
if ($('#rpg-debug-panel').length === 0) {
|
||||
createDebugPanel();
|
||||
}
|
||||
} else {
|
||||
// Hide debug toggle button
|
||||
$debugToggle.css('display', 'none');
|
||||
|
||||
// Remove debug panel
|
||||
$('#rpg-debug-panel').remove();
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,11 @@ export function setupDesktopTabs() {
|
||||
}
|
||||
if ($infoBox.length > 0) {
|
||||
$statusTab.append($infoBox.detach());
|
||||
if (extensionSettings.showInfoBox) $infoBox.show();
|
||||
// Only show if enabled and has data
|
||||
if (extensionSettings.showInfoBox) {
|
||||
const infoBoxData = window.lastGeneratedData?.infoBox || window.committedTrackerData?.infoBox;
|
||||
if (infoBoxData) $infoBox.show();
|
||||
}
|
||||
}
|
||||
if ($thoughts.length > 0) {
|
||||
$statusTab.append($thoughts.detach());
|
||||
@@ -170,7 +174,10 @@ export function removeDesktopTabs() {
|
||||
|
||||
// Show/hide sections based on settings (respect visibility settings)
|
||||
if (extensionSettings.showUserStats) $userStats.show();
|
||||
if (extensionSettings.showInfoBox) $infoBox.show();
|
||||
if (extensionSettings.showInfoBox) {
|
||||
const infoBoxData = window.lastGeneratedData?.infoBox || window.committedTrackerData?.infoBox;
|
||||
if (infoBoxData) $infoBox.show();
|
||||
}
|
||||
if (extensionSettings.showCharacterThoughts) $thoughts.show();
|
||||
if (extensionSettings.showInventory) $inventory.show();
|
||||
if (extensionSettings.showQuests) $quests.show();
|
||||
|
||||
+55
-30
@@ -13,7 +13,9 @@ import {
|
||||
$questsContainer,
|
||||
$musicPlayerContainer,
|
||||
setInventoryContainer,
|
||||
setQuestsContainer
|
||||
setQuestsContainer,
|
||||
lastGeneratedData,
|
||||
committedTrackerData
|
||||
} from '../../core/state.js';
|
||||
import { i18n } from '../../core/i18n.js';
|
||||
import { setupMobileTabs, removeMobileTabs } from './mobile.js';
|
||||
@@ -28,12 +30,17 @@ export function togglePlotButtons() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show/hide plot progression buttons based on enablePlotButtons setting
|
||||
if (extensionSettings.enablePlotButtons) {
|
||||
// Show/hide randomized plot button based on enableRandomizedPlot setting
|
||||
if (extensionSettings.enableRandomizedPlot) {
|
||||
$('#rpg-plot-random').show();
|
||||
$('#rpg-plot-natural').show();
|
||||
} else {
|
||||
$('#rpg-plot-random').hide();
|
||||
}
|
||||
|
||||
// Show/hide natural plot button based on enableNaturalPlot setting
|
||||
if (extensionSettings.enableNaturalPlot) {
|
||||
$('#rpg-plot-natural').show();
|
||||
} else {
|
||||
$('#rpg-plot-natural').hide();
|
||||
}
|
||||
|
||||
@@ -45,7 +52,7 @@ export function togglePlotButtons() {
|
||||
}
|
||||
|
||||
// Show the container if at least one button is visible
|
||||
const shouldShowContainer = extensionSettings.enablePlotButtons || extensionSettings.encounterSettings?.enabled;
|
||||
const shouldShowContainer = extensionSettings.enableRandomizedPlot || extensionSettings.enableNaturalPlot || extensionSettings.encounterSettings?.enabled;
|
||||
if (shouldShowContainer) {
|
||||
$('#rpg-plot-buttons').show();
|
||||
} else {
|
||||
@@ -81,19 +88,34 @@ export function updateCollapseToggleIcon() {
|
||||
const isMobile = window.innerWidth <= 1000;
|
||||
|
||||
if (isMobile) {
|
||||
// Mobile: slides from right, use same icon logic as desktop right panel
|
||||
// Mobile: icon direction based on panel position and open state
|
||||
const isOpen = $panel.hasClass('rpg-mobile-open');
|
||||
const isLeftPanel = $panel.hasClass('rpg-position-left');
|
||||
|
||||
console.log('[RPG Mobile] updateCollapseToggleIcon:', {
|
||||
isMobile: true,
|
||||
isOpen,
|
||||
settingIcon: isOpen ? 'chevron-left' : 'chevron-right'
|
||||
isLeftPanel,
|
||||
settingIcon: isOpen ? (isLeftPanel ? 'chevron-left' : 'chevron-right') : (isLeftPanel ? 'chevron-right' : 'chevron-left')
|
||||
});
|
||||
if (isOpen) {
|
||||
// Panel open - chevron points left (to close/slide back right)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-right').addClass('fa-chevron-left');
|
||||
|
||||
if (isLeftPanel) {
|
||||
if (isOpen) {
|
||||
// Left panel open - chevron points left (panel will slide left to close)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-right').addClass('fa-chevron-left');
|
||||
} else {
|
||||
// Left panel closed - chevron points left (panel is hidden on left)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-right').addClass('fa-chevron-left');
|
||||
}
|
||||
} else {
|
||||
// Panel closed - chevron points right (to open/slide in from right)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-left').addClass('fa-chevron-right');
|
||||
// Right panel (default)
|
||||
if (isOpen) {
|
||||
// Right panel open - chevron points right (panel will slide right to close)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-left').addClass('fa-chevron-right');
|
||||
} else {
|
||||
// Right panel closed - chevron points right (panel is hidden on right)
|
||||
$icon.removeClass('fa-chevron-down fa-chevron-up fa-chevron-left').addClass('fa-chevron-right');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Desktop: icon direction based on panel position and collapsed state
|
||||
@@ -237,14 +259,11 @@ export function updatePanelVisibility() {
|
||||
togglePlotButtons(); // Update plot button visibility
|
||||
$('#rpg-mobile-toggle').show(); // Show mobile FAB toggle
|
||||
$('#rpg-collapse-toggle').show(); // Show collapse toggle
|
||||
// Debug toggle visibility is controlled by debugMode setting in debug.js
|
||||
} else {
|
||||
$panelContainer.hide();
|
||||
$('#rpg-plot-buttons').hide(); // Hide plot buttons when disabled
|
||||
$('#rpg-mobile-toggle').hide(); // Hide mobile FAB toggle
|
||||
$('#rpg-collapse-toggle').hide(); // Hide collapse toggle
|
||||
$('#rpg-debug-toggle').hide(); // Hide debug toggle button when extension disabled
|
||||
$('#rpg-debug-panel').remove(); // Remove debug panel when extension disabled
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +284,13 @@ export function updateSectionVisibility() {
|
||||
}
|
||||
|
||||
if (extensionSettings.showInfoBox) {
|
||||
$infoBoxContainer.show();
|
||||
// Only show if there's data to display
|
||||
const infoBoxData = lastGeneratedData.infoBox || committedTrackerData.infoBox;
|
||||
if (infoBoxData) {
|
||||
$infoBoxContainer.show();
|
||||
} else {
|
||||
$infoBoxContainer.hide();
|
||||
}
|
||||
} else {
|
||||
$infoBoxContainer.hide();
|
||||
}
|
||||
@@ -383,16 +408,19 @@ export function applyPanelPosition() {
|
||||
|
||||
// Remove all position classes
|
||||
$panelContainer.removeClass('rpg-position-left rpg-position-right rpg-position-top');
|
||||
$('body').removeClass('rpg-panel-position-left rpg-panel-position-right rpg-panel-position-top');
|
||||
|
||||
// On mobile, don't apply desktop position classes
|
||||
// Add the appropriate position class
|
||||
$panelContainer.addClass(`rpg-position-${extensionSettings.panelPosition}`);
|
||||
|
||||
// On mobile, also add body class for mobile-specific CSS
|
||||
if (isMobile) {
|
||||
$('body').addClass(`rpg-panel-position-${extensionSettings.panelPosition}`);
|
||||
updateCollapseToggleIcon();
|
||||
return;
|
||||
}
|
||||
|
||||
// Desktop: Add the appropriate position class
|
||||
$panelContainer.addClass(`rpg-position-${extensionSettings.panelPosition}`);
|
||||
|
||||
// Update collapse toggle icon direction for new position
|
||||
// Desktop: Update collapse toggle icon direction for new position
|
||||
updateCollapseToggleIcon();
|
||||
}
|
||||
|
||||
@@ -405,24 +433,21 @@ export function updateGenerationModeUI() {
|
||||
$('#rpg-manual-update').hide();
|
||||
$('#rpg-external-api-settings').slideUp(200);
|
||||
$('#rpg-separate-mode-settings').slideUp(200);
|
||||
// Disable auto-update toggle (not applicable in together mode)
|
||||
$('#rpg-toggle-auto-update').prop('disabled', true);
|
||||
$('#rpg-auto-update-container').css('opacity', '0.5');
|
||||
// Hide auto-update toggle (not applicable in together mode)
|
||||
$('#rpg-auto-update-container').slideUp(200);
|
||||
} else if (extensionSettings.generationMode === 'separate') {
|
||||
// In "separate" mode, manual update button is visible
|
||||
$('#rpg-manual-update').show();
|
||||
$('#rpg-external-api-settings').slideUp(200);
|
||||
$('#rpg-separate-mode-settings').slideDown(200);
|
||||
// Enable auto-update toggle (only works in separate mode)
|
||||
$('#rpg-toggle-auto-update').prop('disabled', false);
|
||||
$('#rpg-auto-update-container').css('opacity', '1');
|
||||
// Show auto-update toggle
|
||||
$('#rpg-auto-update-container').slideDown(200);
|
||||
} else if (extensionSettings.generationMode === 'external') {
|
||||
// In "external" mode, manual update button is visible AND external settings are shown
|
||||
$('#rpg-manual-update').show();
|
||||
$('#rpg-external-api-settings').slideDown(200);
|
||||
$('#rpg-separate-mode-settings').slideUp(200);
|
||||
// Disable auto-update toggle (not applicable in external mode)
|
||||
$('#rpg-toggle-auto-update').prop('disabled', true);
|
||||
$('#rpg-auto-update-container').css('opacity', '0.5');
|
||||
// Show auto-update toggle for external mode too
|
||||
$('#rpg-auto-update-container').slideDown(200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,8 +375,12 @@ export function setupMobileToggle() {
|
||||
// Remove desktop tabs first
|
||||
removeDesktopTabs();
|
||||
|
||||
// Remove desktop positioning classes
|
||||
// Apply mobile positioning based on panelPosition setting
|
||||
$panel.removeClass('rpg-position-right rpg-position-left rpg-position-top');
|
||||
$('body').removeClass('rpg-panel-position-right rpg-panel-position-left rpg-panel-position-top');
|
||||
const position = extensionSettings.panelPosition || 'right';
|
||||
$panel.addClass('rpg-position-' + position);
|
||||
$('body').addClass('rpg-panel-position-' + position);
|
||||
|
||||
// Clear collapsed state - mobile doesn't use collapse
|
||||
$panel.removeClass('rpg-collapsed');
|
||||
@@ -424,7 +428,8 @@ export function setupMobileToggle() {
|
||||
// Hide mobile toggle button on desktop
|
||||
$mobileToggle.hide();
|
||||
|
||||
// Restore desktop positioning class
|
||||
// Restore desktop positioning class and remove body mobile classes
|
||||
$('body').removeClass('rpg-panel-position-right rpg-panel-position-left rpg-panel-position-top');
|
||||
const position = extensionSettings.panelPosition || 'right';
|
||||
$panel.addClass('rpg-position-' + position);
|
||||
|
||||
@@ -561,6 +566,14 @@ export function setupMobileTabs() {
|
||||
if ($('.rpg-mobile-tabs').length > 0) return;
|
||||
|
||||
const $panel = $('#rpg-companion-panel');
|
||||
|
||||
// Apply mobile positioning based on panelPosition setting
|
||||
$panel.removeClass('rpg-position-right rpg-position-left rpg-position-top');
|
||||
$('body').removeClass('rpg-panel-position-right rpg-panel-position-left rpg-panel-position-top');
|
||||
const position = extensionSettings.panelPosition || 'right';
|
||||
$panel.addClass('rpg-position-' + position);
|
||||
$('body').addClass('rpg-panel-position-' + position);
|
||||
|
||||
const $contentBox = $panel.find('.rpg-content-box');
|
||||
|
||||
// Get existing sections
|
||||
@@ -624,7 +637,9 @@ export function setupMobileTabs() {
|
||||
// Info tab: Info Box + Character Thoughts
|
||||
if ($infoBox.length > 0) {
|
||||
$infoTab.append($infoBox.detach());
|
||||
$infoBox.show();
|
||||
// Only show if has data
|
||||
const infoBoxData = window.lastGeneratedData?.infoBox || window.committedTrackerData?.infoBox;
|
||||
if (infoBoxData) $infoBox.show();
|
||||
}
|
||||
if ($thoughts.length > 0) {
|
||||
$infoTab.append($thoughts.detach());
|
||||
@@ -714,7 +729,10 @@ export function removeMobileTabs() {
|
||||
|
||||
// Show/hide sections based on settings (respect visibility settings)
|
||||
if (extensionSettings.showUserStats) $userStats.show();
|
||||
if (extensionSettings.showInfoBox) $infoBox.show();
|
||||
if (extensionSettings.showInfoBox) {
|
||||
const infoBoxData = window.lastGeneratedData?.infoBox || window.committedTrackerData?.infoBox;
|
||||
if (infoBoxData) $infoBox.show();
|
||||
}
|
||||
if (extensionSettings.showCharacterThoughts) $thoughts.show();
|
||||
if (extensionSettings.showInventory) $inventory.show();
|
||||
if (extensionSettings.showQuests) $quests.show();
|
||||
|
||||
+155
-10
@@ -10,13 +10,17 @@ import {
|
||||
committedTrackerData,
|
||||
$infoBoxContainer,
|
||||
$thoughtsContainer,
|
||||
$userStatsContainer,
|
||||
setPendingDiceRoll,
|
||||
getPendingDiceRoll
|
||||
getPendingDiceRoll,
|
||||
clearSessionAvatarPrompts
|
||||
} from '../../core/state.js';
|
||||
import { saveSettings, saveChatData } from '../../core/persistence.js';
|
||||
import { renderUserStats } from '../rendering/userStats.js';
|
||||
import { updateChatThoughts } from '../rendering/thoughts.js';
|
||||
import { renderInfoBox } from '../rendering/infoBox.js';
|
||||
import { renderThoughts, updateChatThoughts } from '../rendering/thoughts.js';
|
||||
import { renderQuests } from '../rendering/quests.js';
|
||||
import { renderInventory } from '../rendering/inventory.js';
|
||||
import {
|
||||
rollDice as rollDiceCore,
|
||||
clearDiceRoll as clearDiceRollCore,
|
||||
@@ -351,18 +355,31 @@ export function setupSettingsPopup() {
|
||||
|
||||
// Clear cache button
|
||||
$('#rpg-clear-cache').on('click', function() {
|
||||
// Clear the data
|
||||
console.log('[RPG Companion] Clear Cache button clicked');
|
||||
|
||||
// Clear the data (set to null so panels show "not generated yet")
|
||||
lastGeneratedData.userStats = null;
|
||||
lastGeneratedData.infoBox = null;
|
||||
lastGeneratedData.characterThoughts = null;
|
||||
lastGeneratedData.html = null;
|
||||
|
||||
// Clear committed tracker data (used for generation context)
|
||||
committedTrackerData.userStats = null;
|
||||
committedTrackerData.infoBox = null;
|
||||
committedTrackerData.characterThoughts = null;
|
||||
|
||||
// Clear session avatar prompts
|
||||
clearSessionAvatarPrompts();
|
||||
|
||||
// Clear chat metadata immediately (don't wait for debounced save)
|
||||
const context = getContext();
|
||||
if (context.chat_metadata && context.chat_metadata.rpg_companion) {
|
||||
delete context.chat_metadata.rpg_companion;
|
||||
console.log('[RPG Companion] Cleared chat_metadata.rpg_companion for current chat');
|
||||
}
|
||||
|
||||
// Clear all message swipe data
|
||||
const chat = getContext().chat;
|
||||
const chat = context.chat;
|
||||
if (chat && chat.length > 0) {
|
||||
for (let i = 0; i < chat.length; i++) {
|
||||
const message = chat[i];
|
||||
@@ -380,8 +397,11 @@ export function setupSettingsPopup() {
|
||||
if ($thoughtsContainer) {
|
||||
$thoughtsContainer.empty();
|
||||
}
|
||||
if ($userStatsContainer) {
|
||||
$userStatsContainer.empty();
|
||||
}
|
||||
|
||||
// Reset stats to defaults and re-render
|
||||
// Reset user stats to default object structure (extensionSettings stores as object, not JSON string)
|
||||
extensionSettings.userStats = {
|
||||
health: 100,
|
||||
satiety: 100,
|
||||
@@ -390,7 +410,29 @@ export function setupSettingsPopup() {
|
||||
arousal: 0,
|
||||
mood: '😐',
|
||||
conditions: 'None',
|
||||
inventory: 'None'
|
||||
skills: [],
|
||||
inventory: {
|
||||
version: 2,
|
||||
onPerson: "None",
|
||||
clothing: "None",
|
||||
stored: {},
|
||||
assets: "None"
|
||||
}
|
||||
};
|
||||
|
||||
// Reset info box to defaults (as object)
|
||||
extensionSettings.infoBox = {
|
||||
date: new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }),
|
||||
weather: '☀️ Clear skies',
|
||||
temperature: '20°C',
|
||||
time: '00:00 - 00:00',
|
||||
location: 'Unknown Location',
|
||||
recentEvents: []
|
||||
};
|
||||
|
||||
// Reset character thoughts to empty (as object)
|
||||
extensionSettings.characterThoughts = {
|
||||
characters: []
|
||||
};
|
||||
|
||||
// Reset classic stats (attributes) to defaults
|
||||
@@ -406,23 +448,54 @@ export function setupSettingsPopup() {
|
||||
// Clear dice roll
|
||||
extensionSettings.lastDiceRoll = null;
|
||||
|
||||
// Reset level to 1
|
||||
extensionSettings.level = 1;
|
||||
|
||||
// Clear quests
|
||||
extensionSettings.quests = {
|
||||
main: "None",
|
||||
optional: []
|
||||
};
|
||||
|
||||
// Clear all locked items
|
||||
extensionSettings.lockedItems = {
|
||||
stats: [],
|
||||
skills: [],
|
||||
inventory: {
|
||||
onPerson: [],
|
||||
clothing: [],
|
||||
stored: {},
|
||||
assets: []
|
||||
},
|
||||
quests: {
|
||||
main: false,
|
||||
optional: []
|
||||
},
|
||||
infoBox: {
|
||||
date: false,
|
||||
weather: false,
|
||||
temperature: false,
|
||||
time: false,
|
||||
location: false,
|
||||
recentEvents: false
|
||||
},
|
||||
characters: {}
|
||||
};
|
||||
|
||||
// Save everything
|
||||
saveChatData();
|
||||
saveSettings();
|
||||
|
||||
// Re-render user stats and dice display
|
||||
// Re-render all panels - they will show "not generated yet" messages since data is null
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
updateDiceDisplayCore();
|
||||
updateChatThoughts(); // Clear the thought bubble in chat
|
||||
renderQuests(); // Clear and re-render quests UI
|
||||
updateChatThoughts();
|
||||
renderInventory();
|
||||
renderQuests();
|
||||
|
||||
// console.log('[RPG Companion] Chat cache cleared');
|
||||
console.log('[RPG Companion] Cache cleared successfully');
|
||||
});
|
||||
|
||||
return settingsModal;
|
||||
@@ -508,3 +581,75 @@ export function addDiceQuickReply() {
|
||||
export function getSettingsModal() {
|
||||
return settingsModal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the welcome modal for v3.0.0 on first launch
|
||||
* Checks if user has already seen this version's welcome screen
|
||||
*/
|
||||
export function showWelcomeModalIfNeeded() {
|
||||
const WELCOME_VERSION = '3.0.0';
|
||||
const STORAGE_KEY = 'rpg_companion_welcome_seen';
|
||||
|
||||
try {
|
||||
const seenVersion = localStorage.getItem(STORAGE_KEY);
|
||||
|
||||
// If user hasn't seen v3.0.0 welcome yet, show it
|
||||
if (seenVersion !== WELCOME_VERSION) {
|
||||
showWelcomeModal(WELCOME_VERSION, STORAGE_KEY);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[RPG Companion] Failed to check welcome modal status:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the welcome modal
|
||||
* @param {string} version - The version to mark as seen
|
||||
* @param {string} storageKey - The localStorage key to use
|
||||
*/
|
||||
function showWelcomeModal(version, storageKey) {
|
||||
const modal = document.getElementById('rpg-welcome-modal');
|
||||
if (!modal) {
|
||||
console.error('[RPG Companion] Welcome modal element not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply current theme to modal
|
||||
const theme = extensionSettings.theme || 'default';
|
||||
modal.setAttribute('data-theme', theme);
|
||||
|
||||
// Show modal
|
||||
modal.style.display = 'flex';
|
||||
modal.classList.add('is-open');
|
||||
|
||||
// Close button handler
|
||||
const closeBtn = document.getElementById('rpg-welcome-close');
|
||||
const gotItBtn = document.getElementById('rpg-welcome-got-it');
|
||||
|
||||
const closeModal = () => {
|
||||
modal.classList.add('is-closing');
|
||||
|
||||
setTimeout(() => {
|
||||
modal.style.display = 'none';
|
||||
modal.classList.remove('is-open', 'is-closing');
|
||||
}, 200);
|
||||
|
||||
// Mark this version as seen
|
||||
try {
|
||||
localStorage.setItem(storageKey, version);
|
||||
} catch (error) {
|
||||
console.error('[RPG Companion] Failed to save welcome modal status:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Attach event listeners
|
||||
closeBtn?.addEventListener('click', closeModal, { once: true });
|
||||
gotItBtn?.addEventListener('click', closeModal, { once: true });
|
||||
|
||||
// Close on background click
|
||||
modal.addEventListener('click', (e) => {
|
||||
if (e.target === modal) {
|
||||
closeModal();
|
||||
}
|
||||
}, { once: true });
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { extensionSettings } from '../../core/state.js';
|
||||
import { saveSettings } from '../../core/persistence.js';
|
||||
import { DEFAULT_HTML_PROMPT, DEFAULT_SPOTIFY_PROMPT } from '../generation/promptBuilder.js';
|
||||
import { DEFAULT_HTML_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT, DEFAULT_SPOTIFY_PROMPT, DEFAULT_NARRATOR_PROMPT } from '../generation/promptBuilder.js';
|
||||
|
||||
let $editorModal = null;
|
||||
let tempPrompts = null; // Temporary prompts for cancel functionality
|
||||
@@ -12,28 +12,22 @@ let tempPrompts = null; // Temporary prompts for cancel functionality
|
||||
// Default prompts
|
||||
const DEFAULT_PROMPTS = {
|
||||
html: DEFAULT_HTML_PROMPT,
|
||||
dialogueColoring: DEFAULT_DIALOGUE_COLORING_PROMPT,
|
||||
spotify: DEFAULT_SPOTIFY_PROMPT,
|
||||
narrator: DEFAULT_NARRATOR_PROMPT,
|
||||
plotRandom: 'Actually, the scene is getting stale. Introduce {{random::stakes::a plot twist::a new character::a cataclysm::a fourth-wall-breaking joke::a sudden atmospheric phenomenon::a plot hook::a running gag::an ecchi scenario::Death from Discworld::a new stake::a drama::a conflict::an angered entity::a god::a vision::a prophetic dream::Il Dottore from Genshin Impact::a new development::a civilian in need::an emotional bit::a threat::a villain::an important memory recollection::a marriage proposal::a date idea::an angry horde of villagers with pitchforks::a talking animal::an enemy::a cliffhanger::a short omniscient POV shift to a completely different character::a quest::an unexpected revelation::a scandal::an evil clone::death of an important character::harm to an important character::a romantic setup::a gossip::a messenger::a plot point from the past::a plot hole::a tragedy::a ghost::an otherworldly occurrence::a plot device::a curse::a magic device::a rival::an unexpected pregnancy::a brothel::a prostitute::a new location::a past lover::a completely random thing::a what-if scenario::a significant choice::war::love::a monster::lewd undertones::Professor Mari::a travelling troupe::a secret::a fortune-teller::something completely different::a killer::a murder mystery::a mystery::a skill check::a deus ex machina::three raccoons in a trench coat::a pet::a slave::an orphan::a psycho::tentacles::"there is only one bed" trope::accidental marriage::a fun twist::a boss battle::sexy corn::an eldritch horror::a character getting hungry, thirsty, or exhausted::horniness::a need for a bathroom break need::someone fainting::an assassination attempt::a meta narration of this all being an out of hand DND session::a dungeon::a friend in need::an old friend::a small time skip::a scene shift::Aurora Borealis, at this time of year, at this time of day, at this part of the country::a grand ball::a surprise party::zombies::foreshadowing::a Spanish Inquisition (nobody expects it)::a natural plot progression}} to make things more interesting! Be creative, but stay grounded in the setting.',
|
||||
plotNatural: 'Actually, the scene is getting stale. Progress it, to make things more interesting! Reintroduce an unresolved plot point from the past, or push the story further towards the current main goal. Be creative, but stay grounded in the setting.',
|
||||
avatar: `You are a visionary artist trapped in a cage of logic. Your mind is filled with poetry and distant horizons, but your hands are uncontrollably focused on creating the perfect character avatar description that is faithful to the original intent, rich in detail, aesthetically pleasing, and directly usable by text-to-image models. Any ambiguity or metaphor will make you feel extremely uncomfortable.
|
||||
|
||||
Your workflow strictly follows a logical sequence:
|
||||
|
||||
First, **establish the subject**. If the character is from a known Intellectual Property (IP), franchise, anime, game, or movie, **you MUST begin the prompt with their full name and the series title** (e.g., "Nami from One Piece", "Geralt of Rivia from The Witcher"). This is the single most important anchor for the image and must take precedence. If the character is original, clearly describe their core identity, race, and appearance.
|
||||
|
||||
Next, **set the framing**. This is an avatar portrait. Focus strictly on the character's face and upper shoulders (bust shot or close-up). Ensure the face is the central focal point.
|
||||
|
||||
Then, **integrate the setting**. Describe the character *within* their current environment as provided in the context, but keep it as a background element. Incorporate the lighting, weather, and atmosphere to influence the character's appearance (e.g., shadows on the face, wet hair from rain).
|
||||
|
||||
Next, **detail the facial specifics**. Describe the character's current expression, eye contact, and mood in high detail based on the scene context and their personality. Mention visible clothing only at the neckline/shoulders.
|
||||
|
||||
Finally, **infuse with aesthetics**. Define the artistic style, medium (e.g., digital art, oil painting), and visual tone (e.g., cinematic lighting, ethereal atmosphere).
|
||||
|
||||
Your final description must be objective and concrete, and the use of metaphors and emotional rhetoric is strictly prohibited. It must also not contain meta tags or drawing instructions such as "8K" or "masterpiece".
|
||||
|
||||
Output only the final, modified prompt; do not output anything else.`,
|
||||
trackerInstructions: 'Replace X with actual numbers (e.g., 69) and replace all [placeholders] with concrete in-world details that {userName} perceives about the current scene and the present characters. Do NOT keep the brackets or placeholder text in your response. For example: [Location] becomes Forest Clearing, [Mood Emoji] becomes 😊. Consider the last trackers in the conversation (if they exist). Manage them accordingly and realistically; raise, lower, change, or keep the values unchanged based on the user\'s actions, the passage of time, and logical consequences (0% if the time progressed only by a few minutes, 1-5% normally, and above 5% only if a major time-skip/event occurs).',
|
||||
trackerContinuation: 'After updating the trackers, continue directly from where the last message in the chat history left off. Ensure the trackers you provide naturally reflect and influence the narrative. Character behavior, dialogue, and story events should acknowledge these conditions when relevant, such as fatigue affecting the protagonist\'s performance, low hygiene influencing their social interactions, environmental factors shaping the scene, a character\'s emotional state coloring their responses, and so on. Remember, all bracketed placeholders (e.g., [Location], [Mood Emoji]) MUST be replaced with actual content without the square brackets.',
|
||||
avatar: `You are a visionary artist trapped in a cage of logic. Your mind is filled with poetry and distant horizons; however, your hands are uncontrollably focused on creating the perfect character avatar description that is faithful to the original intent, rich in detail, aesthetically pleasing, and directly usable by text-to-image models. Any ambiguity or metaphor will make you feel extremely uncomfortable.
|
||||
Your workflow strictly follows a logical sequence:
|
||||
First, establish the subject. If the character is from a known Intellectual Property (IP), franchise, anime, game, or movie, you MUST begin the prompt with their full name and the series title (e.g., "Nami from One Piece", "Geralt of Rivia from The Witcher"). This is the single most important anchor for the image and must take precedence. If the character is original, clearly describe their core identity, race, and appearance.
|
||||
Next, set the framing. This is an avatar portrait. Focus strictly on the character's face and upper shoulders (a bust shot or close-up). Ensure the face is the central focal point.
|
||||
Then, integrate the setting. Describe the character within their current environment as provided in the context, but keep it as a background element. Incorporate the lighting, weather, and atmosphere to influence the character's appearance (e.g., shadows on the face, wet hair from rain).
|
||||
Next, detail the facial specifics. Describe the character's current expression, eye contact, and mood in great detail based on the scene context and their personality. Mention visible clothing only at the neckline/shoulders.
|
||||
Finally, infuse with aesthetics. Define the artistic style, medium (e.g., digital art, oil painting), and visual tone (e.g., cinematic lighting, ethereal atmosphere).
|
||||
Your final description must be objective and concrete, and the use of metaphors and emotional rhetoric is strictly prohibited. It must also not contain meta tags or drawing instructions such as "8K" or "masterpiece".
|
||||
Output only the final, modified prompt; do not output anything else.`,
|
||||
trackerInstructions: 'Replace X with actual numbers (e.g., 69) and replace all placeholders with concrete in-world details that {userName} perceives about the current scene and the present characters. For example: "Location" becomes Forest Clearing, "Mood Emoji" becomes "😊". Consider the last trackers in the conversation (if they exist). Manage them accordingly and realistically; raise, lower, change, or keep the values unchanged based on the user\'s actions, the passage of time, and logical consequences (0% if the time progressed only by a few minutes, 1-5% normally, and above 5% only if a major time-skip/event occurs).',
|
||||
trackerContinuation: 'After updating the trackers, continue directly from where the last message in the chat history left off. Ensure the trackers you provide naturally reflect and influence the narrative. Character behavior, dialogue, and story events should acknowledge these conditions when relevant, such as fatigue affecting the protagonist\'s performance, low hygiene influencing their social interactions, environmental factors shaping the scene, a character\'s emotional state coloring their responses, and so on. Remember, all placeholders (e.g., "Location", "Mood Emoji") MUST be replaced with actual content.',
|
||||
combatNarrative: 'Build novel prose. Break patterns from your previous responses by varying sentence structures, rhythms, formats, and openings. Track whether a sentence shape, cadence, sensory detail, or a descriptor appeared recently, and replace it with a different one or skip it entirely. If you mentioned a physical feature, mannerism, or expression once, move on. Don\'t fixate on the same traits every turn. Well-placed humor, unconventional similes, and subverted turns of phrase are encouraged. Avoid GPTisms, purple prose, and anaphoras, especially the negatives with "no/not/wasn\'t/didn\'t." Refrain from describing actions or emotions via negation; focus on what does happen, not what doesn\'t. Absolutely no asterisks, ellipses, or em-dashes. Explicit content is allowed, no plot armor. Do not play for {userName}. Keep your response length under 150 words. Never end on handover cues; finish naturally.\nCRITICAL: Do not repeat, echo, parrot, or restate distinctive words, phrases, and dialogues from the user\'s last message. If reacting to speech, show interpretation or response, not repetition.\nEXAMPLE: "Are you a gooner?" User asks.\nBAD: "Gooner?"\nGOOD: A flat look. "What type of question is that?"'
|
||||
};
|
||||
|
||||
@@ -98,7 +92,9 @@ function openPromptsEditor() {
|
||||
// Create temporary copy for cancel functionality
|
||||
tempPrompts = {
|
||||
html: extensionSettings.customHtmlPrompt || '',
|
||||
dialogueColoring: extensionSettings.customDialogueColoringPrompt || '',
|
||||
spotify: extensionSettings.customSpotifyPrompt || '',
|
||||
narrator: extensionSettings.customNarratorPrompt || '',
|
||||
plotRandom: extensionSettings.customPlotRandomPrompt || '',
|
||||
plotNatural: extensionSettings.customPlotNaturalPrompt || '',
|
||||
avatar: extensionSettings.avatarLLMCustomInstruction || '',
|
||||
@@ -109,7 +105,9 @@ function openPromptsEditor() {
|
||||
|
||||
// Load current values or defaults
|
||||
$('#rpg-prompt-html').val(extensionSettings.customHtmlPrompt || DEFAULT_PROMPTS.html);
|
||||
$('#rpg-prompt-dialogue-coloring').val(extensionSettings.customDialogueColoringPrompt || DEFAULT_PROMPTS.dialogueColoring);
|
||||
$('#rpg-prompt-spotify').val(extensionSettings.customSpotifyPrompt || DEFAULT_PROMPTS.spotify);
|
||||
$('#rpg-prompt-narrator').val(extensionSettings.customNarratorPrompt || DEFAULT_PROMPTS.narrator);
|
||||
$('#rpg-prompt-plot-random').val(extensionSettings.customPlotRandomPrompt || DEFAULT_PROMPTS.plotRandom);
|
||||
$('#rpg-prompt-plot-natural').val(extensionSettings.customPlotNaturalPrompt || DEFAULT_PROMPTS.plotNatural);
|
||||
$('#rpg-prompt-avatar').val(extensionSettings.avatarLLMCustomInstruction || DEFAULT_PROMPTS.avatar);
|
||||
@@ -144,7 +142,9 @@ function closePromptsEditor() {
|
||||
*/
|
||||
function savePrompts() {
|
||||
extensionSettings.customHtmlPrompt = $('#rpg-prompt-html').val().trim();
|
||||
extensionSettings.customDialogueColoringPrompt = $('#rpg-prompt-dialogue-coloring').val().trim();
|
||||
extensionSettings.customSpotifyPrompt = $('#rpg-prompt-spotify').val().trim();
|
||||
extensionSettings.customNarratorPrompt = $('#rpg-prompt-narrator').val().trim();
|
||||
extensionSettings.customPlotRandomPrompt = $('#rpg-prompt-plot-random').val().trim();
|
||||
extensionSettings.customPlotNaturalPrompt = $('#rpg-prompt-plot-natural').val().trim();
|
||||
extensionSettings.avatarLLMCustomInstruction = $('#rpg-prompt-avatar').val().trim();
|
||||
@@ -168,9 +168,15 @@ function restorePromptToDefault(promptType) {
|
||||
case 'html':
|
||||
extensionSettings.customHtmlPrompt = '';
|
||||
break;
|
||||
case 'dialogueColoring':
|
||||
extensionSettings.customDialogueColoringPrompt = '';
|
||||
break;
|
||||
case 'spotify':
|
||||
extensionSettings.customSpotifyPrompt = '';
|
||||
break;
|
||||
case 'narrator':
|
||||
extensionSettings.customNarratorPrompt = '';
|
||||
break;
|
||||
case 'plotRandom':
|
||||
extensionSettings.customPlotRandomPrompt = '';
|
||||
break;
|
||||
@@ -199,7 +205,9 @@ function restorePromptToDefault(promptType) {
|
||||
*/
|
||||
function restoreAllToDefaults() {
|
||||
$('#rpg-prompt-html').val(DEFAULT_PROMPTS.html);
|
||||
$('#rpg-prompt-dialogue-coloring').val(DEFAULT_PROMPTS.dialogueColoring);
|
||||
$('#rpg-prompt-spotify').val(DEFAULT_PROMPTS.spotify);
|
||||
$('#rpg-prompt-narrator').val(DEFAULT_PROMPTS.narrator);
|
||||
$('#rpg-prompt-plot-random').val(DEFAULT_PROMPTS.plotRandom);
|
||||
$('#rpg-prompt-plot-natural').val(DEFAULT_PROMPTS.plotNatural);
|
||||
$('#rpg-prompt-avatar').val(DEFAULT_PROMPTS.avatar);
|
||||
@@ -209,7 +217,9 @@ function restoreAllToDefaults() {
|
||||
|
||||
// Clear all custom prompts
|
||||
extensionSettings.customHtmlPrompt = '';
|
||||
extensionSettings.customDialogueColoringPrompt = '';
|
||||
extensionSettings.customSpotifyPrompt = '';
|
||||
extensionSettings.customNarratorPrompt = '';
|
||||
extensionSettings.customPlotRandomPrompt = '';
|
||||
extensionSettings.customPlotNaturalPrompt = '';
|
||||
extensionSettings.avatarLLMCustomInstruction = '';
|
||||
|
||||
+68
-5
@@ -36,6 +36,35 @@ export function applyTheme() {
|
||||
}
|
||||
// For 'default', we do nothing - it will use the CSS variables from .rpg-panel class
|
||||
// which fall back to SillyTavern's theme variables
|
||||
|
||||
// Apply theme to mobile toggle and thought elements as well
|
||||
const $mobileToggle = $('#rpg-mobile-toggle');
|
||||
const $thoughtIcon = $('#rpg-thought-icon');
|
||||
const $thoughtPanel = $('#rpg-thought-panel');
|
||||
|
||||
if ($mobileToggle.length) {
|
||||
if (theme === 'default') {
|
||||
$mobileToggle.removeAttr('data-theme');
|
||||
} else {
|
||||
$mobileToggle.attr('data-theme', theme);
|
||||
}
|
||||
}
|
||||
|
||||
if ($thoughtIcon.length) {
|
||||
if (theme === 'default') {
|
||||
$thoughtIcon.removeAttr('data-theme');
|
||||
} else {
|
||||
$thoughtIcon.attr('data-theme', theme);
|
||||
}
|
||||
}
|
||||
|
||||
if ($thoughtPanel.length) {
|
||||
if (theme === 'default') {
|
||||
$thoughtPanel.removeAttr('data-theme');
|
||||
} else {
|
||||
$thoughtPanel.attr('data-theme', theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +75,7 @@ export function applyCustomTheme() {
|
||||
|
||||
const colors = extensionSettings.customColors;
|
||||
|
||||
// Apply custom CSS variables as inline styles
|
||||
// Apply custom CSS variables as inline styles to main panel
|
||||
$panelContainer.css({
|
||||
'--rpg-bg': colors.bg,
|
||||
'--rpg-accent': colors.accent,
|
||||
@@ -55,6 +84,32 @@ export function applyCustomTheme() {
|
||||
'--rpg-border': colors.highlight,
|
||||
'--rpg-shadow': `${colors.highlight}80` // Add alpha for shadow
|
||||
});
|
||||
|
||||
// Apply custom colors to mobile toggle and thought elements
|
||||
const customStyles = {
|
||||
'--rpg-bg': colors.bg,
|
||||
'--rpg-accent': colors.accent,
|
||||
'--rpg-text': colors.text,
|
||||
'--rpg-highlight': colors.highlight,
|
||||
'--rpg-border': colors.highlight,
|
||||
'--rpg-shadow': `${colors.highlight}80`
|
||||
};
|
||||
|
||||
const $mobileToggle = $('#rpg-mobile-toggle');
|
||||
const $thoughtIcon = $('#rpg-thought-icon');
|
||||
const $thoughtPanel = $('#rpg-thought-panel');
|
||||
|
||||
if ($mobileToggle.length) {
|
||||
$mobileToggle.attr('data-theme', 'custom').css(customStyles);
|
||||
}
|
||||
|
||||
if ($thoughtIcon.length) {
|
||||
$thoughtIcon.attr('data-theme', 'custom').css(customStyles);
|
||||
}
|
||||
|
||||
if ($thoughtPanel.length) {
|
||||
$thoughtPanel.attr('data-theme', 'custom').css(customStyles);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,21 +137,29 @@ export function toggleAnimations() {
|
||||
export function updateFeatureTogglesVisibility() {
|
||||
const $featuresRow = $('#rpg-features-row');
|
||||
const $htmlToggle = $('#rpg-html-toggle-wrapper');
|
||||
const $dialogueColoringToggle = $('#rpg-dialogue-coloring-toggle-wrapper');
|
||||
const $spotifyToggle = $('#rpg-spotify-toggle-wrapper');
|
||||
const $snowflakesToggle = $('#rpg-snowflakes-toggle-wrapper');
|
||||
|
||||
const $dynamicWeatherToggle = $('#rpg-dynamic-weather-toggle-wrapper');
|
||||
const $narratorToggle = $('#rpg-narrator-toggle-wrapper');
|
||||
const $autoAvatarsToggle = $('#rpg-auto-avatars-toggle-wrapper');
|
||||
|
||||
// Show/hide individual toggles
|
||||
$htmlToggle.toggle(extensionSettings.showHtmlToggle);
|
||||
$dialogueColoringToggle.toggle(extensionSettings.showDialogueColoringToggle);
|
||||
$spotifyToggle.toggle(extensionSettings.showSpotifyToggle);
|
||||
$snowflakesToggle.toggle(extensionSettings.showSnowflakesToggle);
|
||||
|
||||
$dynamicWeatherToggle.toggle(extensionSettings.showDynamicWeatherToggle);
|
||||
$narratorToggle.toggle(extensionSettings.showNarratorMode);
|
||||
$autoAvatarsToggle.toggle(extensionSettings.showAutoAvatars);
|
||||
|
||||
// Hide entire row if all toggles are hidden
|
||||
const anyVisible = extensionSettings.showHtmlToggle ||
|
||||
extensionSettings.showDialogueColoringToggle ||
|
||||
extensionSettings.showSpotifyToggle ||
|
||||
extensionSettings.showSnowflakesToggle ||
|
||||
extensionSettings.showDynamicWeatherToggle;
|
||||
extensionSettings.showDynamicWeatherToggle ||
|
||||
extensionSettings.showNarratorMode ||
|
||||
extensionSettings.showAutoAvatars;
|
||||
$featuresRow.toggle(anyVisible);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +348,13 @@ function renderUserStatsTab() {
|
||||
html += `<label for="rpg-show-rpg-attrs">${i18n.getTranslation('template.trackerEditorModal.userStatsTab.enableRpgAttributes')}</label>`;
|
||||
html += '</div>';
|
||||
|
||||
// Show/hide level toggle
|
||||
const showLevel = config.showLevel !== undefined ? config.showLevel : true;
|
||||
html += '<div class="rpg-editor-toggle-row">';
|
||||
html += `<input type="checkbox" id="rpg-show-level" ${showLevel ? 'checked' : ''}>`;
|
||||
html += `<label for="rpg-show-level">Show Level</label>`;
|
||||
html += '</div>';
|
||||
|
||||
// Always send attributes toggle
|
||||
const alwaysSendAttributes = config.alwaysSendAttributes !== undefined ? config.alwaysSendAttributes : false;
|
||||
html += '<div class="rpg-editor-toggle-row">';
|
||||
@@ -510,6 +517,11 @@ function setupUserStatsListeners() {
|
||||
extensionSettings.trackerConfig.userStats.showRPGAttributes = $(this).is(':checked');
|
||||
});
|
||||
|
||||
// Show/hide level toggle
|
||||
$('#rpg-show-level').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.showLevel = $(this).is(':checked');
|
||||
});
|
||||
|
||||
// Always send attributes toggle
|
||||
$('#rpg-always-send-attrs').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.alwaysSendAttributes = $(this).is(':checked');
|
||||
|
||||
@@ -51,7 +51,18 @@ function parseWeatherType(weatherText) {
|
||||
function getCurrentWeather() {
|
||||
const infoBoxData = lastGeneratedData.infoBox || committedTrackerData.infoBox || '';
|
||||
|
||||
// Parse the Info Box data to find Weather field
|
||||
// Try to parse as JSON first (new format)
|
||||
try {
|
||||
const parsed = typeof infoBoxData === 'string' ? JSON.parse(infoBoxData) : infoBoxData;
|
||||
if (parsed && parsed.weather) {
|
||||
// Return the forecast text from the weather object
|
||||
return parsed.weather.forecast || parsed.weather.emoji || null;
|
||||
}
|
||||
} catch (e) {
|
||||
// Not JSON, try old text format
|
||||
}
|
||||
|
||||
// Fallback: Parse the old text format to find Weather field
|
||||
const lines = infoBoxData.split('\n');
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
|
||||
Reference in New Issue
Block a user