Merge pull request #69 from munimunigamer/main
feat: Add configurable toggles for Narrator Mode and dice display
This commit is contained in:
@@ -331,6 +331,11 @@ async function initUI() {
|
|||||||
updateSectionVisibility();
|
updateSectionVisibility();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#rpg-toggle-narrator-mode').on('change', function() {
|
||||||
|
extensionSettings.narratorMode = $(this).prop('checked');
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
|
||||||
$('#rpg-toggle-inventory').on('change', function() {
|
$('#rpg-toggle-inventory').on('change', function() {
|
||||||
extensionSettings.showInventory = $(this).prop('checked');
|
extensionSettings.showInventory = $(this).prop('checked');
|
||||||
saveSettings();
|
saveSettings();
|
||||||
@@ -402,6 +407,12 @@ async function initUI() {
|
|||||||
toggleAnimations();
|
toggleAnimations();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#rpg-toggle-dice-display').on('change', function() {
|
||||||
|
extensionSettings.showDiceDisplay = $(this).prop('checked');
|
||||||
|
saveSettings();
|
||||||
|
updateDiceDisplay();
|
||||||
|
});
|
||||||
|
|
||||||
$('#rpg-manual-update').on('click', async function() {
|
$('#rpg-manual-update').on('click', async function() {
|
||||||
if (!extensionSettings.enabled) {
|
if (!extensionSettings.enabled) {
|
||||||
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
|
// 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-user-stats').prop('checked', extensionSettings.showUserStats);
|
||||||
$('#rpg-toggle-info-box').prop('checked', extensionSettings.showInfoBox);
|
$('#rpg-toggle-info-box').prop('checked', extensionSettings.showInfoBox);
|
||||||
$('#rpg-toggle-thoughts').prop('checked', extensionSettings.showCharacterThoughts);
|
$('#rpg-toggle-thoughts').prop('checked', extensionSettings.showCharacterThoughts);
|
||||||
|
$('#rpg-toggle-narrator-mode').prop('checked', extensionSettings.narratorMode);
|
||||||
$('#rpg-toggle-inventory').prop('checked', extensionSettings.showInventory);
|
$('#rpg-toggle-inventory').prop('checked', extensionSettings.showInventory);
|
||||||
$('#rpg-toggle-quests').prop('checked', extensionSettings.showQuests);
|
$('#rpg-toggle-quests').prop('checked', extensionSettings.showQuests);
|
||||||
$('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat);
|
$('#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-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-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-low').val(extensionSettings.statBarColorLow);
|
||||||
$('#rpg-stat-bar-color-high').val(extensionSettings.statBarColorHigh);
|
$('#rpg-stat-bar-color-high').val(extensionSettings.statBarColorHigh);
|
||||||
$('#rpg-theme-select').val(extensionSettings.theme);
|
$('#rpg-theme-select').val(extensionSettings.theme);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export let extensionSettings = {
|
|||||||
showInventory: true, // Show inventory section (v2 system)
|
showInventory: true, // Show inventory section (v2 system)
|
||||||
showQuests: true, // Show quests section
|
showQuests: true, // Show quests section
|
||||||
showThoughtsInChat: true, // Show thoughts overlay in chat
|
showThoughtsInChat: true, // Show thoughts overlay in chat
|
||||||
|
narratorMode: false, // Use character card as narrator instead of fixed character references
|
||||||
enableHtmlPrompt: false, // Enable immersive HTML prompt injection
|
enableHtmlPrompt: false, // Enable immersive HTML prompt injection
|
||||||
customHtmlPrompt: '', // Custom HTML prompt text (empty = use default)
|
customHtmlPrompt: '', // Custom HTML prompt text (empty = use default)
|
||||||
skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility)
|
skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility)
|
||||||
@@ -158,6 +159,7 @@ export let extensionSettings = {
|
|||||||
cha: 10
|
cha: 10
|
||||||
},
|
},
|
||||||
lastDiceRoll: null, // Store last dice roll result
|
lastDiceRoll: null, // Store last dice roll result
|
||||||
|
showDiceDisplay: true, // Show the "Last Roll" display in the panel
|
||||||
collapsedInventoryLocations: [], // Array of collapsed storage location names
|
collapsedInventoryLocations: [], // Array of collapsed storage location names
|
||||||
inventoryViewModes: {
|
inventoryViewModes: {
|
||||||
onPerson: 'list', // 'list' or 'grid' view mode for On Person section
|
onPerson: 'list', // 'list' or 'grid' view mode for On Person section
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
"template.settingsModal.display.showUserStats": "Show User Stats",
|
"template.settingsModal.display.showUserStats": "Show User Stats",
|
||||||
"template.settingsModal.display.showInfoBox": "Show Info Box",
|
"template.settingsModal.display.showInfoBox": "Show Info Box",
|
||||||
"template.settingsModal.display.showPresentCharacters": "Show Present Characters",
|
"template.settingsModal.display.showPresentCharacters": "Show Present Characters",
|
||||||
|
"template.settingsModal.display.narratorMode": "Narrator Mode",
|
||||||
|
"template.settingsModal.display.narratorModeNote": "Use character card as narrator. Infer characters from context instead of using fixed character references.",
|
||||||
"template.settingsModal.display.showInventory": "Show Inventory",
|
"template.settingsModal.display.showInventory": "Show Inventory",
|
||||||
"template.settingsModal.display.showQuests": "Show Quests",
|
"template.settingsModal.display.showQuests": "Show Quests",
|
||||||
"template.settingsModal.display.showThoughtsInChat": "Show Thoughts in Chat",
|
"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.enableAnimationsNote": "Smooth transitions for stats, content updates, and dice rolls",
|
||||||
"template.settingsModal.display.showPlotProgressionButtons": "Show Plot Progression Buttons",
|
"template.settingsModal.display.showPlotProgressionButtons": "Show Plot Progression Buttons",
|
||||||
"template.settingsModal.display.showPlotProgressionButtonsNote": "Display buttons above chat input for plot progression prompts",
|
"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.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.display.enableDebugModeNote": "Shows parser logs in a mobile-friendly UI panel. Useful for troubleshooting. Look for the red bug button.",
|
||||||
"template.settingsModal.advancedTitle": "Advanced",
|
"template.settingsModal.advancedTitle": "Advanced",
|
||||||
|
|||||||
@@ -85,6 +85,15 @@ export async function executeRollCommand(command) {
|
|||||||
* Updates the dice display in the sidebar.
|
* Updates the dice display in the sidebar.
|
||||||
*/
|
*/
|
||||||
export function updateDiceDisplay() {
|
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 lastRoll = extensionSettings.lastDiceRoll;
|
||||||
const label = i18n.getTranslation('template.mainPanel.lastRoll') || 'Last Roll: ';
|
const label = i18n.getTranslation('template.mainPanel.lastRoll') || 'Last Roll: ';
|
||||||
const noneValue = i18n.getTranslation('global.none') || 'None';
|
const noneValue = i18n.getTranslation('global.none') || 'None';
|
||||||
@@ -98,6 +107,7 @@ export function updateDiceDisplay() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the last dice roll.
|
* Clears the last dice roll.
|
||||||
|
* Called when the x button is clicked.
|
||||||
*/
|
*/
|
||||||
export function clearDiceRoll() {
|
export function clearDiceRoll() {
|
||||||
extensionSettings.lastDiceRoll = null;
|
extensionSettings.lastDiceRoll = null;
|
||||||
|
|||||||
@@ -23,6 +23,27 @@ export const DEFAULT_HTML_PROMPT = `If appropriate, include inline HTML, CSS, an
|
|||||||
async function getCharacterCardsInfo() {
|
async function getCharacterCardsInfo() {
|
||||||
let characterInfo = '';
|
let characterInfo = '';
|
||||||
|
|
||||||
|
// Narrator mode: use character card as narrator context, infer characters from story context
|
||||||
|
if (extensionSettings.narratorMode) {
|
||||||
|
if (this_chid !== undefined && characters && characters[this_chid]) {
|
||||||
|
const character = characters[this_chid];
|
||||||
|
characterInfo += 'You are acting as the narrator for this story. The narrator card provides context for the story tone and style:\n\n';
|
||||||
|
characterInfo += `<narrator>\n`;
|
||||||
|
|
||||||
|
if (character.description) {
|
||||||
|
characterInfo += `${character.description}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (character.personality) {
|
||||||
|
characterInfo += `${character.personality}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
|
characterInfo += `</narrator>\n\n`;
|
||||||
|
characterInfo += `Infer the identity and details of characters present in each scene from the story context below. Do not use fixed character references - instead, identify characters naturally based on their actions, dialogue, and descriptions in the narrative.\n\n`;
|
||||||
|
}
|
||||||
|
return characterInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if in group chat
|
// Check if in group chat
|
||||||
if (selected_group) {
|
if (selected_group) {
|
||||||
// Find the current group directly from the groups array
|
// Find the current group directly from the groups array
|
||||||
@@ -331,7 +352,11 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
|
|||||||
.join(' | ');
|
.join(' | ');
|
||||||
|
|
||||||
// Character block format
|
// Character block format
|
||||||
|
if (extensionSettings.narratorMode) {
|
||||||
|
instructions += `- [Character Name (infer from story context; do not include ${userName}; state "Unavailable" if no other characters are present in the scene)]\n`;
|
||||||
|
} else {
|
||||||
instructions += `- [Name (do not include ${userName}; state "Unavailable" if no major characters are present in the scene)]\n`;
|
instructions += `- [Name (do not include ${userName}; state "Unavailable" if no major characters are present in the scene)]\n`;
|
||||||
|
}
|
||||||
|
|
||||||
// Details line with emoji and custom fields
|
// Details line with emoji and custom fields
|
||||||
if (fieldPlaceholders) {
|
if (fieldPlaceholders) {
|
||||||
@@ -358,7 +383,11 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
|
|||||||
instructions += `${thoughtsName}: [${thoughtsDescription}]\n`;
|
instructions += `${thoughtsName}: [${thoughtsDescription}]\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extensionSettings.narratorMode) {
|
||||||
|
instructions += `- … (Repeat the format above for every other character present in the scene, inferred from story context)\n`;
|
||||||
|
} else {
|
||||||
instructions += `- … (Repeat the format above for every other present major character)\n`;
|
instructions += `- … (Repeat the format above for every other present major character)\n`;
|
||||||
|
}
|
||||||
|
|
||||||
instructions += codeBlockMarker + '\n\n';
|
instructions += codeBlockMarker + '\n\n';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,8 +441,8 @@ export function renderThoughts() {
|
|||||||
debugLog('[RPG Thoughts] ==================== BUILDING HTML ====================');
|
debugLog('[RPG Thoughts] ==================== BUILDING HTML ====================');
|
||||||
debugLog('[RPG Thoughts] Starting HTML generation for', presentCharacters.length + ' characters');
|
debugLog('[RPG Thoughts] Starting HTML generation for', presentCharacters.length + ' characters');
|
||||||
|
|
||||||
// If no characters parsed, show a placeholder editable card
|
// If no characters parsed, show a placeholder editable card (if narrator mode is disabled)
|
||||||
if (presentCharacters.length === 0) {
|
if (presentCharacters.length === 0 && !extensionSettings.narratorMode) {
|
||||||
debugLog('[RPG Thoughts] ⚠ No characters parsed - showing placeholder card');
|
debugLog('[RPG Thoughts] ⚠ No characters parsed - showing placeholder card');
|
||||||
// Get default character portrait
|
// Get default character portrait
|
||||||
let defaultPortrait = FALLBACK_AVATAR_DATA_URI;
|
let defaultPortrait = FALLBACK_AVATAR_DATA_URI;
|
||||||
|
|||||||
@@ -180,6 +180,14 @@
|
|||||||
<span data-i18n-key="template.settingsModal.display.showPresentCharacters">Show Present Characters</span>
|
<span data-i18n-key="template.settingsModal.display.showPresentCharacters">Show Present Characters</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label class="checkbox_label">
|
||||||
|
<input type="checkbox" id="rpg-toggle-narrator-mode" />
|
||||||
|
<span data-i18n-key="template.settingsModal.display.narratorMode">Narrator Mode</span>
|
||||||
|
</label>
|
||||||
|
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.display.narratorModeNote">
|
||||||
|
Use character card as narrator. Infer characters from context instead of using fixed character references.
|
||||||
|
</small>
|
||||||
|
|
||||||
<label class="checkbox_label">
|
<label class="checkbox_label">
|
||||||
<input type="checkbox" id="rpg-toggle-inventory" />
|
<input type="checkbox" id="rpg-toggle-inventory" />
|
||||||
<span data-i18n-key="template.settingsModal.display.showInventory">Show Inventory</span>
|
<span data-i18n-key="template.settingsModal.display.showInventory">Show Inventory</span>
|
||||||
@@ -222,6 +230,14 @@
|
|||||||
Display buttons above chat input for plot progression prompts
|
Display buttons above chat input for plot progression prompts
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
|
<label class="checkbox_label">
|
||||||
|
<input type="checkbox" id="rpg-toggle-dice-display" />
|
||||||
|
<span data-i18n-key="template.settingsModal.display.showDiceDisplay">Show Dice Roll Display</span>
|
||||||
|
</label>
|
||||||
|
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.display.showDiceDisplayNote">
|
||||||
|
Display the "Last Roll" indicator in the panel.
|
||||||
|
</small>
|
||||||
|
|
||||||
<label class="checkbox_label">
|
<label class="checkbox_label">
|
||||||
<input type="checkbox" id="rpg-toggle-debug-mode" />
|
<input type="checkbox" id="rpg-toggle-debug-mode" />
|
||||||
<span data-i18n-key="template.settingsModal.display.enableDebugMode">Enable Debug Mode</span>
|
<span data-i18n-key="template.settingsModal.display.enableDebugMode">Enable Debug Mode</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user