From c73260b2c68b082184ce6a05a42cec93cb6b6806 Mon Sep 17 00:00:00 2001 From: munimunigamer Date: Thu, 25 Dec 2025 18:27:28 -0800 Subject: [PATCH] Added placeholder and dice config options --- index.js | 13 +++++++++++++ src/core/state.js | 2 ++ src/i18n/en.json | 4 ++++ src/systems/features/dice.js | 10 ++++++++++ src/systems/rendering/thoughts.js | 4 ++-- template.html | 16 ++++++++++++++++ 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ce7e8b2..580842b 100644 --- a/index.js +++ b/index.js @@ -331,6 +331,11 @@ async function initUI() { updateSectionVisibility(); }); + $('#rpg-toggle-placeholder-card').on('change', function() { + extensionSettings.showPlaceholderCharacterCard = $(this).prop('checked'); + saveSettings(); + }); + $('#rpg-toggle-inventory').on('change', function() { extensionSettings.showInventory = $(this).prop('checked'); saveSettings(); @@ -402,6 +407,12 @@ async function initUI() { toggleAnimations(); }); + $('#rpg-toggle-dice-display').on('change', function() { + extensionSettings.showDiceDisplay = $(this).prop('checked'); + saveSettings(); + updateDiceDisplay(); + }); + $('#rpg-manual-update').on('click', async function() { if (!extensionSettings.enabled) { // console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.'); @@ -482,6 +493,7 @@ async function initUI() { $('#rpg-toggle-user-stats').prop('checked', extensionSettings.showUserStats); $('#rpg-toggle-info-box').prop('checked', extensionSettings.showInfoBox); $('#rpg-toggle-thoughts').prop('checked', extensionSettings.showCharacterThoughts); + $('#rpg-toggle-placeholder-card').prop('checked', extensionSettings.showPlaceholderCharacterCard); $('#rpg-toggle-inventory').prop('checked', extensionSettings.showInventory); $('#rpg-toggle-quests').prop('checked', extensionSettings.showQuests); $('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat); @@ -493,6 +505,7 @@ async function initUI() { $('#rpg-toggle-plot-buttons').prop('checked', extensionSettings.enablePlotButtons); $('#rpg-toggle-plot-buttons').prop('checked', extensionSettings.enablePlotButtons); $('#rpg-toggle-plot-buttons').prop('checked', extensionSettings.enablePlotButtons); $('#rpg-toggle-animations').prop('checked', extensionSettings.enableAnimations); + $('#rpg-toggle-dice-display').prop('checked', extensionSettings.showDiceDisplay); $('#rpg-stat-bar-color-low').val(extensionSettings.statBarColorLow); $('#rpg-stat-bar-color-high').val(extensionSettings.statBarColorHigh); $('#rpg-theme-select').val(extensionSettings.theme); diff --git a/src/core/state.js b/src/core/state.js index bc7e59f..993ab9a 100644 --- a/src/core/state.js +++ b/src/core/state.js @@ -21,6 +21,7 @@ export let extensionSettings = { showInventory: true, // Show inventory section (v2 system) showQuests: true, // Show quests section showThoughtsInChat: true, // Show thoughts overlay in chat + showPlaceholderCharacterCard: true, // Show placeholder character card when no characters detected enableHtmlPrompt: false, // Enable immersive HTML prompt injection customHtmlPrompt: '', // Custom HTML prompt text (empty = use default) skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility) @@ -158,6 +159,7 @@ export let extensionSettings = { cha: 10 }, lastDiceRoll: null, // Store last dice roll result + showDiceDisplay: true, // Show the "Last Roll" display in the panel collapsedInventoryLocations: [], // Array of collapsed storage location names inventoryViewModes: { onPerson: 'list', // 'list' or 'grid' view mode for On Person section diff --git a/src/i18n/en.json b/src/i18n/en.json index 47a4f22..fe2a5f2 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -29,6 +29,8 @@ "template.settingsModal.display.showUserStats": "Show User Stats", "template.settingsModal.display.showInfoBox": "Show Info Box", "template.settingsModal.display.showPresentCharacters": "Show Present Characters", + "template.settingsModal.display.showPlaceholderCharacterCard": "Show Placeholder Character Card", + "template.settingsModal.display.showPlaceholderCharacterCardNote": "When no characters are detected, show a placeholder character card. Disable for narrator-only stories.", "template.settingsModal.display.showInventory": "Show Inventory", "template.settingsModal.display.showQuests": "Show Quests", "template.settingsModal.display.showThoughtsInChat": "Show Thoughts in Chat", @@ -39,6 +41,8 @@ "template.settingsModal.display.enableAnimationsNote": "Smooth transitions for stats, content updates, and dice rolls", "template.settingsModal.display.showPlotProgressionButtons": "Show Plot Progression Buttons", "template.settingsModal.display.showPlotProgressionButtonsNote": "Display buttons above chat input for plot progression prompts", + "template.settingsModal.display.showDiceDisplay": "Show Dice Roll Display", + "template.settingsModal.display.showDiceDisplayNote": "Display the \"Last Roll\" indicator in the panel.", "template.settingsModal.display.enableDebugMode": "Enable Debug Mode", "template.settingsModal.display.enableDebugModeNote": "Shows parser logs in a mobile-friendly UI panel. Useful for troubleshooting. Look for the red bug button.", "template.settingsModal.advancedTitle": "Advanced", diff --git a/src/systems/features/dice.js b/src/systems/features/dice.js index fe5a0c4..0f8bbb9 100644 --- a/src/systems/features/dice.js +++ b/src/systems/features/dice.js @@ -85,6 +85,15 @@ export async function executeRollCommand(command) { * Updates the dice display in the sidebar. */ export function updateDiceDisplay() { + // Hide the entire dice display if showDiceDisplay is false + const $display = $('#rpg-dice-display'); + if (!extensionSettings.showDiceDisplay) { + $display.hide(); + return; + } else { + $display.show(); + } + const lastRoll = extensionSettings.lastDiceRoll; const label = i18n.getTranslation('template.mainPanel.lastRoll') || 'Last Roll: '; const noneValue = i18n.getTranslation('global.none') || 'None'; @@ -98,6 +107,7 @@ export function updateDiceDisplay() { /** * Clears the last dice roll. + * Called when the x button is clicked. */ export function clearDiceRoll() { extensionSettings.lastDiceRoll = null; diff --git a/src/systems/rendering/thoughts.js b/src/systems/rendering/thoughts.js index 84c5498..80d5289 100644 --- a/src/systems/rendering/thoughts.js +++ b/src/systems/rendering/thoughts.js @@ -441,8 +441,8 @@ export function renderThoughts() { debugLog('[RPG Thoughts] ==================== BUILDING HTML ===================='); debugLog('[RPG Thoughts] Starting HTML generation for', presentCharacters.length + ' characters'); - // If no characters parsed, show a placeholder editable card - if (presentCharacters.length === 0) { + // If no characters parsed, show a placeholder editable card (if enabled) + if (presentCharacters.length === 0 && extensionSettings.showPlaceholderCharacterCard) { debugLog('[RPG Thoughts] ⚠ No characters parsed - showing placeholder card'); // Get default character portrait let defaultPortrait = FALLBACK_AVATAR_DATA_URI; diff --git a/template.html b/template.html index 9fb899d..bad2229 100644 --- a/template.html +++ b/template.html @@ -180,6 +180,14 @@ Show Present Characters + + + When no characters are detected, show a placeholder character card. Disable for narrator-only stories. + +