Revert "All the features"
This commit is contained in:
+16
-43
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
import { i18n } from '../../core/i18n.js';
|
||||
import { extensionSettings } from '../../core/state.js';
|
||||
|
||||
/**
|
||||
* Sets up desktop tab navigation for organizing content.
|
||||
@@ -24,47 +23,34 @@ export function setupDesktopTabs() {
|
||||
const $userStats = $('#rpg-user-stats');
|
||||
const $infoBox = $('#rpg-info-box');
|
||||
const $thoughts = $('#rpg-thoughts');
|
||||
const $skills = $('#rpg-skills');
|
||||
const $inventory = $('#rpg-inventory');
|
||||
const $quests = $('#rpg-quests');
|
||||
|
||||
// If no sections exist, nothing to organize
|
||||
if ($userStats.length === 0 && $infoBox.length === 0 && $thoughts.length === 0 && $skills.length === 0 && $inventory.length === 0 && $quests.length === 0) {
|
||||
if ($userStats.length === 0 && $infoBox.length === 0 && $thoughts.length === 0 && $inventory.length === 0 && $quests.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create tab navigation - conditionally show skills, inventory and quests tabs based on settings
|
||||
const skillsLabel = extensionSettings.trackerConfig?.userStats?.skillsSection?.label || 'Skills';
|
||||
const skillsTabHtml = extensionSettings.showSkills ? `
|
||||
<button class="rpg-tab-btn" data-tab="skills">
|
||||
<i class="fa-solid fa-star"></i>
|
||||
<span>${skillsLabel}</span>
|
||||
</button>` : '';
|
||||
|
||||
const inventoryTabHtml = extensionSettings.showInventory ? `
|
||||
<button class="rpg-tab-btn" data-tab="inventory">
|
||||
<i class="fa-solid fa-box"></i>
|
||||
<span data-i18n-key="global.inventory">Inventory</span>
|
||||
</button>` : '';
|
||||
|
||||
const questsTabHtml = extensionSettings.showQuests ? `
|
||||
<button class="rpg-tab-btn" data-tab="quests">
|
||||
<i class="fa-solid fa-scroll"></i>
|
||||
<span data-i18n-key="global.quests">Quests</span>
|
||||
</button>` : '';
|
||||
|
||||
// Create tab navigation
|
||||
const $tabNav = $(`
|
||||
<div class="rpg-tabs-nav">
|
||||
<button class="rpg-tab-btn active" data-tab="status">
|
||||
<i class="fa-solid fa-chart-simple"></i>
|
||||
<span data-i18n-key="global.status">Status</span>
|
||||
</button>${skillsTabHtml}${inventoryTabHtml}${questsTabHtml}
|
||||
</button>
|
||||
<button class="rpg-tab-btn" data-tab="inventory">
|
||||
<i class="fa-solid fa-box"></i>
|
||||
<span data-i18n-key="global.inventory">Inventory</span>
|
||||
</button>
|
||||
<button class="rpg-tab-btn" data-tab="quests">
|
||||
<i class="fa-solid fa-scroll"></i>
|
||||
<span data-i18n-key="global.quests">Quests</span>
|
||||
</button>
|
||||
</div>
|
||||
`);
|
||||
|
||||
// Create tab content containers
|
||||
const $statusTab = $('<div class="rpg-tab-content active" data-tab-content="status"></div>');
|
||||
const $skillsTab = $('<div class="rpg-tab-content" data-tab-content="skills"></div>');
|
||||
const $inventoryTab = $('<div class="rpg-tab-content" data-tab-content="inventory"></div>');
|
||||
const $questsTab = $('<div class="rpg-tab-content" data-tab-content="quests"></div>');
|
||||
|
||||
@@ -81,15 +67,11 @@ export function setupDesktopTabs() {
|
||||
$statusTab.append($thoughts.detach());
|
||||
$thoughts.show();
|
||||
}
|
||||
if (extensionSettings.showSkills && $skills.length > 0) {
|
||||
$skillsTab.append($skills.detach());
|
||||
$skills.show();
|
||||
}
|
||||
if (extensionSettings.showInventory && $inventory.length > 0) {
|
||||
if ($inventory.length > 0) {
|
||||
$inventoryTab.append($inventory.detach());
|
||||
$inventory.show();
|
||||
}
|
||||
if (extensionSettings.showQuests && $quests.length > 0) {
|
||||
if ($quests.length > 0) {
|
||||
$questsTab.append($quests.detach());
|
||||
$quests.show();
|
||||
}
|
||||
@@ -101,7 +83,6 @@ export function setupDesktopTabs() {
|
||||
const $tabsContainer = $('<div class="rpg-tabs-container"></div>');
|
||||
$tabsContainer.append($tabNav);
|
||||
$tabsContainer.append($statusTab);
|
||||
$tabsContainer.append($skillsTab);
|
||||
$tabsContainer.append($inventoryTab);
|
||||
$tabsContainer.append($questsTab);
|
||||
|
||||
@@ -134,38 +115,32 @@ export function removeDesktopTabs() {
|
||||
const $userStats = $('#rpg-user-stats').detach();
|
||||
const $infoBox = $('#rpg-info-box').detach();
|
||||
const $thoughts = $('#rpg-thoughts').detach();
|
||||
const $skills = $('#rpg-skills').detach();
|
||||
const $inventory = $('#rpg-inventory').detach();
|
||||
const $quests = $('#rpg-quests').detach();
|
||||
|
||||
// Remove tabs container
|
||||
$('.rpg-tabs-container').remove();
|
||||
|
||||
// Get dividers (all 5 dividers in the template)
|
||||
// Get dividers
|
||||
const $dividerStats = $('#rpg-divider-stats');
|
||||
const $dividerInfo = $('#rpg-divider-info');
|
||||
const $dividerThoughts = $('#rpg-divider-thoughts');
|
||||
const $dividerSkills = $('#rpg-divider-skills');
|
||||
const $dividerInventory = $('#rpg-divider-inventory');
|
||||
|
||||
// Restore original sections to content box in correct order
|
||||
const $contentBox = $('.rpg-content-box');
|
||||
|
||||
// Re-insert sections in original order: User Stats, Info Box, Thoughts, Skills, Inventory, Quests
|
||||
// Each section goes before its corresponding divider
|
||||
// Re-insert sections in original order: User Stats, Info Box, Thoughts, Inventory, Quests
|
||||
if ($dividerStats.length) {
|
||||
$dividerStats.before($userStats);
|
||||
$dividerInfo.before($infoBox);
|
||||
$dividerThoughts.before($thoughts);
|
||||
$dividerSkills.before($skills);
|
||||
$dividerInventory.before($inventory);
|
||||
$contentBox.append($inventory);
|
||||
$contentBox.append($quests);
|
||||
} else {
|
||||
// Fallback if dividers don't exist
|
||||
$contentBox.append($userStats);
|
||||
$contentBox.append($infoBox);
|
||||
$contentBox.append($thoughts);
|
||||
$contentBox.append($skills);
|
||||
$contentBox.append($inventory);
|
||||
$contentBox.append($quests);
|
||||
}
|
||||
@@ -174,9 +149,7 @@ export function removeDesktopTabs() {
|
||||
$userStats.show();
|
||||
$infoBox.show();
|
||||
$thoughts.show();
|
||||
$skills.show();
|
||||
$inventory.show();
|
||||
$quests.show();
|
||||
$('.rpg-divider').show();
|
||||
|
||||
console.log('[RPG Desktop] Desktop tabs removed');
|
||||
|
||||
@@ -9,9 +9,7 @@ import {
|
||||
$userStatsContainer,
|
||||
$infoBoxContainer,
|
||||
$thoughtsContainer,
|
||||
$skillsContainer,
|
||||
$inventoryContainer,
|
||||
$questsContainer
|
||||
$inventoryContainer
|
||||
} from '../../core/state.js';
|
||||
import { i18n } from '../../core/i18n.js';
|
||||
|
||||
@@ -229,41 +227,25 @@ export function updateSectionVisibility() {
|
||||
$userStatsContainer.toggle(extensionSettings.showUserStats);
|
||||
$infoBoxContainer.toggle(extensionSettings.showInfoBox);
|
||||
$thoughtsContainer.toggle(extensionSettings.showCharacterThoughts);
|
||||
if ($skillsContainer) {
|
||||
$skillsContainer.toggle(extensionSettings.showSkills);
|
||||
}
|
||||
if ($inventoryContainer) {
|
||||
$inventoryContainer.toggle(extensionSettings.showInventory);
|
||||
}
|
||||
if ($questsContainer) {
|
||||
$questsContainer.toggle(extensionSettings.showQuests);
|
||||
}
|
||||
|
||||
// Show/hide dividers intelligently
|
||||
// Divider after User Stats: shown if User Stats is visible AND at least one section after it is visible
|
||||
const showDividerAfterStats = extensionSettings.showUserStats &&
|
||||
(extensionSettings.showInfoBox || extensionSettings.showCharacterThoughts || extensionSettings.showSkills || extensionSettings.showInventory || extensionSettings.showQuests);
|
||||
(extensionSettings.showInfoBox || extensionSettings.showCharacterThoughts || extensionSettings.showInventory);
|
||||
$('#rpg-divider-stats').toggle(showDividerAfterStats);
|
||||
|
||||
// Divider after Info Box: shown if Info Box is visible AND at least one section after it is visible
|
||||
const showDividerAfterInfo = extensionSettings.showInfoBox &&
|
||||
(extensionSettings.showCharacterThoughts || extensionSettings.showSkills || extensionSettings.showInventory || extensionSettings.showQuests);
|
||||
(extensionSettings.showCharacterThoughts || extensionSettings.showInventory);
|
||||
$('#rpg-divider-info').toggle(showDividerAfterInfo);
|
||||
|
||||
// Divider after Thoughts: shown if Thoughts is visible AND Skills, Inventory or Quests is visible
|
||||
// Divider after Thoughts: shown if Thoughts is visible AND Inventory is visible
|
||||
const showDividerAfterThoughts = extensionSettings.showCharacterThoughts &&
|
||||
(extensionSettings.showSkills || extensionSettings.showInventory || extensionSettings.showQuests);
|
||||
extensionSettings.showInventory;
|
||||
$('#rpg-divider-thoughts').toggle(showDividerAfterThoughts);
|
||||
|
||||
// Divider after Skills: shown if Skills is visible AND Inventory or Quests is visible
|
||||
const showDividerAfterSkills = extensionSettings.showSkills &&
|
||||
(extensionSettings.showInventory || extensionSettings.showQuests);
|
||||
$('#rpg-divider-skills').toggle(showDividerAfterSkills);
|
||||
|
||||
// Divider after Inventory: shown if Inventory is visible AND Quests is visible
|
||||
const showDividerAfterInventory = extensionSettings.showInventory &&
|
||||
extensionSettings.showQuests;
|
||||
$('#rpg-divider-inventory').toggle(showDividerAfterInventory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -727,6 +727,7 @@ export function removeMobileTabs() {
|
||||
*/
|
||||
export function setupMobileKeyboardHandling() {
|
||||
if (!window.visualViewport) {
|
||||
// console.log('[RPG Mobile] Visual Viewport API not supported');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -749,9 +750,12 @@ export function setupMobileKeyboardHandling() {
|
||||
// Keyboard just appeared
|
||||
keyboardVisible = true;
|
||||
$panel.addClass('rpg-keyboard-visible');
|
||||
// console.log('[RPG Mobile] Keyboard opened');
|
||||
} else if (!isKeyboardShowing && keyboardVisible) {
|
||||
// Keyboard just disappeared
|
||||
keyboardVisible = false;
|
||||
$panel.removeClass('rpg-keyboard-visible');
|
||||
// console.log('[RPG Mobile] Keyboard closed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import { saveSettings, saveChatData } from '../../core/persistence.js';
|
||||
import { renderUserStats } from '../rendering/userStats.js';
|
||||
import { updateChatThoughts } from '../rendering/thoughts.js';
|
||||
import { renderQuests } from '../rendering/quests.js';
|
||||
import { renderSkills } from '../rendering/skills.js';
|
||||
import {
|
||||
rollDice as rollDiceCore,
|
||||
clearDiceRoll as clearDiceRollCore,
|
||||
@@ -369,6 +368,7 @@ export function setupSettingsPopup() {
|
||||
const message = chat[i];
|
||||
if (message.extra && message.extra.rpg_companion_swipes) {
|
||||
delete message.extra.rpg_companion_swipes;
|
||||
// console.log('[RPG Companion] Cleared swipe data from message at index', i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,13 +390,7 @@ export function setupSettingsPopup() {
|
||||
arousal: 0,
|
||||
mood: '😐',
|
||||
conditions: 'None',
|
||||
inventory: {
|
||||
version: 2,
|
||||
onPerson: "None",
|
||||
stored: {},
|
||||
assets: "None"
|
||||
},
|
||||
skills: "None" // Legacy single-string skills (for Status section)
|
||||
inventory: 'None'
|
||||
};
|
||||
|
||||
// Reset classic stats (attributes) to defaults
|
||||
@@ -418,12 +412,6 @@ export function setupSettingsPopup() {
|
||||
optional: []
|
||||
};
|
||||
|
||||
// Reset skills data
|
||||
extensionSettings.skillsV2 = {};
|
||||
extensionSettings.skillsData = {};
|
||||
extensionSettings.skillAbilityLinks = {};
|
||||
extensionSettings.skills = { list: [], categories: {} }; // Legacy skills object
|
||||
|
||||
// Save everything
|
||||
saveChatData();
|
||||
saveSettings();
|
||||
@@ -433,7 +421,8 @@ export function setupSettingsPopup() {
|
||||
updateDiceDisplayCore();
|
||||
updateChatThoughts(); // Clear the thought bubble in chat
|
||||
renderQuests(); // Clear and re-render quests UI
|
||||
renderSkills();
|
||||
|
||||
// console.log('[RPG Companion] Chat cache cleared');
|
||||
});
|
||||
|
||||
return settingsModal;
|
||||
|
||||
+31
-151
@@ -8,7 +8,6 @@ import { saveSettings } from '../../core/persistence.js';
|
||||
import { renderUserStats } from '../rendering/userStats.js';
|
||||
import { renderInfoBox } from '../rendering/infoBox.js';
|
||||
import { renderThoughts } from '../rendering/thoughts.js';
|
||||
import { renderSkills } from '../rendering/skills.js';
|
||||
|
||||
let $editorModal = null;
|
||||
let activeTab = 'userStats';
|
||||
@@ -130,12 +129,12 @@ function resetToDefaults() {
|
||||
],
|
||||
showRPGAttributes: true,
|
||||
rpgAttributes: [
|
||||
{ id: 'str', name: 'STR', description: '', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', description: '', enabled: true },
|
||||
{ id: 'con', name: 'CON', description: '', enabled: true },
|
||||
{ id: 'int', name: 'INT', description: '', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', description: '', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', description: '', enabled: true }
|
||||
{ id: 'str', name: 'STR', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', enabled: true },
|
||||
{ id: 'con', name: 'CON', enabled: true },
|
||||
{ id: 'int', name: 'INT', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', enabled: true }
|
||||
],
|
||||
statusSection: {
|
||||
enabled: true,
|
||||
@@ -210,12 +209,10 @@ function renderUserStatsTab() {
|
||||
html += '<div class="rpg-editor-stats-list" id="rpg-editor-stats-list">';
|
||||
|
||||
config.customStats.forEach((stat, index) => {
|
||||
const statDesc = stat.description || '';
|
||||
html += `
|
||||
<div class="rpg-editor-stat-item rpg-editor-item-with-desc" data-index="${index}">
|
||||
<div class="rpg-editor-stat-item" data-index="${index}">
|
||||
<input type="checkbox" ${stat.enabled ? 'checked' : ''} class="rpg-stat-toggle" data-index="${index}">
|
||||
<input type="text" value="${stat.name}" class="rpg-stat-name" data-index="${index}" placeholder="Stat Name">
|
||||
<input type="text" value="${statDesc}" class="rpg-stat-desc" data-index="${index}" placeholder="Description for AI">
|
||||
<button class="rpg-stat-remove" data-index="${index}" title="Remove stat"><i class="fa-solid fa-trash"></i></button>
|
||||
</div>
|
||||
`;
|
||||
@@ -234,13 +231,6 @@ function renderUserStatsTab() {
|
||||
html += `<label for="rpg-show-rpg-attrs">${i18n.getTranslation('template.trackerEditorModal.userStatsTab.enableRpgAttributes')}</label>`;
|
||||
html += '</div>';
|
||||
|
||||
// Allow AI to update attributes toggle
|
||||
const allowAIUpdateAttributes = config.allowAIUpdateAttributes !== undefined ? config.allowAIUpdateAttributes : true;
|
||||
html += '<div class="rpg-editor-toggle-row">';
|
||||
html += `<input type="checkbox" id="rpg-allow-ai-update-attrs" ${allowAIUpdateAttributes ? 'checked' : ''}>`;
|
||||
html += `<label for="rpg-allow-ai-update-attrs">${i18n.getTranslation('template.trackerEditorModal.userStatsTab.allowAIUpdateAttributes')}</label>`;
|
||||
html += '</div>';
|
||||
|
||||
// Always send attributes toggle
|
||||
const alwaysSendAttributes = config.alwaysSendAttributes !== undefined ? config.alwaysSendAttributes : false;
|
||||
html += '<div class="rpg-editor-toggle-row">';
|
||||
@@ -254,12 +244,12 @@ function renderUserStatsTab() {
|
||||
// Ensure rpgAttributes exists in the actual config (not just local fallback)
|
||||
if (!config.rpgAttributes || config.rpgAttributes.length === 0) {
|
||||
config.rpgAttributes = [
|
||||
{ id: 'str', name: 'STR', description: '', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', description: '', enabled: true },
|
||||
{ id: 'con', name: 'CON', description: '', enabled: true },
|
||||
{ id: 'int', name: 'INT', description: '', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', description: '', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', description: '', enabled: true }
|
||||
{ id: 'str', name: 'STR', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', enabled: true },
|
||||
{ id: 'con', name: 'CON', enabled: true },
|
||||
{ id: 'int', name: 'INT', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', enabled: true }
|
||||
];
|
||||
// Save the defaults back to the actual config
|
||||
extensionSettings.trackerConfig.userStats.rpgAttributes = config.rpgAttributes;
|
||||
@@ -268,12 +258,10 @@ function renderUserStatsTab() {
|
||||
const rpgAttributes = config.rpgAttributes;
|
||||
|
||||
rpgAttributes.forEach((attr, index) => {
|
||||
const attrDesc = attr.description || '';
|
||||
html += `
|
||||
<div class="rpg-editor-stat-item rpg-editor-item-with-desc" data-index="${index}">
|
||||
<div class="rpg-editor-stat-item" data-index="${index}">
|
||||
<input type="checkbox" ${attr.enabled ? 'checked' : ''} class="rpg-attr-toggle" data-index="${index}">
|
||||
<input type="text" value="${attr.name}" class="rpg-attr-name" data-index="${index}" placeholder="Attribute Name">
|
||||
<input type="text" value="${attrDesc}" class="rpg-attr-desc" data-index="${index}" placeholder="Description for AI">
|
||||
<button class="rpg-attr-remove" data-index="${index}" title="Remove attribute"><i class="fa-solid fa-trash"></i></button>
|
||||
</div>
|
||||
`;
|
||||
@@ -299,47 +287,17 @@ function renderUserStatsTab() {
|
||||
|
||||
// Skills Section
|
||||
html += `<h4><i class="fa-solid fa-star"></i> ${i18n.getTranslation('template.trackerEditorModal.userStatsTab.skillsSectionTitle')}</h4>`;
|
||||
|
||||
// Check if skills are shown as separate section - if so, disable the toggle
|
||||
const skillsInSeparateTab = extensionSettings.showSkills;
|
||||
const skillsToggleDisabled = skillsInSeparateTab ? 'disabled' : '';
|
||||
const skillsToggleStyle = skillsInSeparateTab ? 'style="opacity: 0.5; cursor: not-allowed;"' : '';
|
||||
|
||||
html += `<div class="rpg-editor-toggle-row" ${skillsToggleStyle}>`;
|
||||
html += `<input type="checkbox" id="rpg-skills-enabled" ${config.skillsSection.enabled ? 'checked' : ''} ${skillsToggleDisabled}>`;
|
||||
html += '<div class="rpg-editor-toggle-row">';
|
||||
html += `<input type="checkbox" id="rpg-skills-enabled" ${config.skillsSection.enabled ? 'checked' : ''}>`;
|
||||
html += `<label for="rpg-skills-enabled">${i18n.getTranslation('template.trackerEditorModal.userStatsTab.enableSkillsSection')}</label>`;
|
||||
html += '</div>';
|
||||
|
||||
// Show note when skills are in separate tab
|
||||
if (skillsInSeparateTab) {
|
||||
html += `<small style="display: block; margin-top: -8px; margin-bottom: 12px; color: #888; font-size: 11px;" data-i18n-key="template.trackerEditorModal.userStatsTab.skillsInSeparateTabNote">${i18n.getTranslation('template.trackerEditorModal.userStatsTab.skillsInSeparateTabNote')}</small>`;
|
||||
}
|
||||
|
||||
html += `<label>${i18n.getTranslation('template.trackerEditorModal.userStatsTab.skillsLabelLabel')}</label>`;
|
||||
html += `<input type="text" id="rpg-skills-label" value="${config.skillsSection.label}" class="rpg-text-input" placeholder="Skills">`;
|
||||
|
||||
html += `<label>${i18n.getTranslation('template.trackerEditorModal.userStatsTab.skillsListLabel')}</label>`;
|
||||
html += '<div class="rpg-editor-stats-list" id="rpg-editor-skills-list">';
|
||||
|
||||
// Migration function handles string array → object array conversion on load
|
||||
const skillFields = config.skillsSection.customFields || [];
|
||||
skillFields.forEach((skill, index) => {
|
||||
const skillName = skill.name || '';
|
||||
const skillDesc = skill.description || '';
|
||||
const skillEnabled = skill.enabled !== false;
|
||||
|
||||
html += `
|
||||
<div class="rpg-editor-stat-item rpg-editor-skill-item" data-index="${index}">
|
||||
<input type="checkbox" ${skillEnabled ? 'checked' : ''} class="rpg-skill-toggle" data-index="${index}">
|
||||
<input type="text" value="${skillName}" class="rpg-skill-name" data-index="${index}" placeholder="Skill Category Name">
|
||||
<input type="text" value="${skillDesc}" class="rpg-skill-desc" data-index="${index}" placeholder="Description for AI">
|
||||
<button class="rpg-skill-remove" data-index="${index}" title="Remove skill category"><i class="fa-solid fa-trash"></i></button>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
html += '</div>';
|
||||
html += `<button class="rpg-btn-secondary" id="rpg-add-skill"><i class="fa-solid fa-plus"></i> ${i18n.getTranslation('template.trackerEditorModal.userStatsTab.addSkillButton') || 'Add Skill Category'}</button>`;
|
||||
html += `<input type="text" id="rpg-skills-fields" value="${skillFields.join(', ')}" class="rpg-text-input" placeholder="e.g., Stealth, Persuasion, Combat">`;
|
||||
|
||||
html += '</div>';
|
||||
|
||||
@@ -357,7 +315,6 @@ function setupUserStatsListeners() {
|
||||
extensionSettings.trackerConfig.userStats.customStats.push({
|
||||
id: newId,
|
||||
name: 'New Stat',
|
||||
description: '',
|
||||
enabled: true
|
||||
});
|
||||
// Initialize value if doesn't exist
|
||||
@@ -386,30 +343,23 @@ function setupUserStatsListeners() {
|
||||
extensionSettings.trackerConfig.userStats.customStats[index].name = $(this).val();
|
||||
});
|
||||
|
||||
// Update stat description
|
||||
$('.rpg-stat-desc').off('blur').on('blur', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.customStats[index].description = $(this).val();
|
||||
});
|
||||
|
||||
// Add attribute
|
||||
$('#rpg-add-attr').off('click').on('click', function() {
|
||||
// Ensure rpgAttributes array exists with defaults if needed
|
||||
if (!extensionSettings.trackerConfig.userStats.rpgAttributes || extensionSettings.trackerConfig.userStats.rpgAttributes.length === 0) {
|
||||
extensionSettings.trackerConfig.userStats.rpgAttributes = [
|
||||
{ id: 'str', name: 'STR', description: '', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', description: '', enabled: true },
|
||||
{ id: 'con', name: 'CON', description: '', enabled: true },
|
||||
{ id: 'int', name: 'INT', description: '', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', description: '', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', description: '', enabled: true }
|
||||
{ id: 'str', name: 'STR', enabled: true },
|
||||
{ id: 'dex', name: 'DEX', enabled: true },
|
||||
{ id: 'con', name: 'CON', enabled: true },
|
||||
{ id: 'int', name: 'INT', enabled: true },
|
||||
{ id: 'wis', name: 'WIS', enabled: true },
|
||||
{ id: 'cha', name: 'CHA', enabled: true }
|
||||
];
|
||||
}
|
||||
const newId = 'attr_' + Date.now();
|
||||
extensionSettings.trackerConfig.userStats.rpgAttributes.push({
|
||||
id: newId,
|
||||
name: 'NEW',
|
||||
description: '',
|
||||
enabled: true
|
||||
});
|
||||
// Initialize value in classicStats if doesn't exist
|
||||
@@ -438,25 +388,15 @@ function setupUserStatsListeners() {
|
||||
extensionSettings.trackerConfig.userStats.rpgAttributes[index].name = $(this).val();
|
||||
});
|
||||
|
||||
// Update attribute description
|
||||
$('.rpg-attr-desc').off('blur').on('blur', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.rpgAttributes[index].description = $(this).val();
|
||||
});
|
||||
|
||||
// Enable/disable RPG Attributes section toggle
|
||||
$('#rpg-show-rpg-attrs').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.showRPGAttributes = $(this).is(':checked');
|
||||
});
|
||||
|
||||
// Always send attributes toggle
|
||||
$('#rpg-always-send-attrs').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.alwaysSendAttributes = $(this).is(':checked');
|
||||
});
|
||||
|
||||
$('#rpg-allow-ai-update-attrs').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.allowAIUpdateAttributes = $(this).is(':checked');
|
||||
});
|
||||
$('#rpg-always-send-attrs').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.alwaysSendAttributes = $(this).is(':checked');
|
||||
});
|
||||
|
||||
// Status section toggles
|
||||
$('#rpg-status-enabled').off('change').on('change', function() {
|
||||
@@ -475,68 +415,16 @@ function setupUserStatsListeners() {
|
||||
// Skills section toggles
|
||||
$('#rpg-skills-enabled').off('change').on('change', function() {
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.enabled = $(this).is(':checked');
|
||||
saveSettings();
|
||||
// Re-render both user stats (if skills shown there) and skills section
|
||||
renderUserStats();
|
||||
renderSkills();
|
||||
});
|
||||
|
||||
$('#rpg-skills-label').off('blur').on('blur', function() {
|
||||
const newLabel = $(this).val();
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.label = newLabel;
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.label = $(this).val();
|
||||
saveSettings();
|
||||
renderUserStats();
|
||||
renderSkills();
|
||||
// Update the skills tab button text if it exists
|
||||
$('.rpg-tab-btn[data-tab="skills"] span').text(newLabel);
|
||||
});
|
||||
|
||||
// Add skill category
|
||||
$('#rpg-add-skill').off('click').on('click', function() {
|
||||
if (!extensionSettings.trackerConfig.userStats.skillsSection.customFields) {
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields = [];
|
||||
}
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields.push({
|
||||
id: 'skill_' + Date.now(),
|
||||
name: 'New Skill',
|
||||
description: '',
|
||||
enabled: true
|
||||
});
|
||||
renderUserStatsTab();
|
||||
saveSettings();
|
||||
renderSkills();
|
||||
});
|
||||
|
||||
// Remove skill category
|
||||
$('.rpg-skill-remove').off('click').on('click', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields.splice(index, 1);
|
||||
renderUserStatsTab();
|
||||
saveSettings();
|
||||
renderSkills();
|
||||
});
|
||||
|
||||
// Toggle skill category
|
||||
// Migration function handles string array → object array conversion on load
|
||||
$('.rpg-skill-toggle').off('change').on('change', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields[index].enabled = $(this).is(':checked');
|
||||
saveSettings();
|
||||
renderSkills();
|
||||
});
|
||||
|
||||
// Rename skill category
|
||||
$('.rpg-skill-name').off('blur').on('blur', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields[index].name = $(this).val();
|
||||
saveSettings();
|
||||
renderSkills();
|
||||
});
|
||||
|
||||
// Update skill description
|
||||
$('.rpg-skill-desc').off('blur').on('blur', function() {
|
||||
const index = $(this).data('index');
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields[index].description = $(this).val();
|
||||
$('#rpg-skills-fields').off('blur').on('blur', function() {
|
||||
const fields = $(this).val().split(',').map(f => f.trim()).filter(f => f);
|
||||
extensionSettings.trackerConfig.userStats.skillsSection.customFields = fields;
|
||||
saveSettings();
|
||||
});
|
||||
}
|
||||
@@ -756,15 +644,7 @@ function setupPresentCharactersListeners() {
|
||||
if (!extensionSettings.trackerConfig.presentCharacters.relationshipEmojis) {
|
||||
extensionSettings.trackerConfig.presentCharacters.relationshipEmojis = {};
|
||||
}
|
||||
|
||||
// Generate unique name to avoid overwriting existing "New Relationship" entries
|
||||
let newName = 'New Relationship';
|
||||
let counter = 1;
|
||||
while (extensionSettings.trackerConfig.presentCharacters.relationshipEmojis[newName]) {
|
||||
newName = `New Relationship ${counter}`;
|
||||
counter++;
|
||||
}
|
||||
extensionSettings.trackerConfig.presentCharacters.relationshipEmojis[newName] = '😊';
|
||||
extensionSettings.trackerConfig.presentCharacters.relationshipEmojis['New Relationship'] = '😊';
|
||||
|
||||
// Sync relationshipFields
|
||||
extensionSettings.trackerConfig.presentCharacters.relationshipFields =
|
||||
|
||||
Reference in New Issue
Block a user