- now stats, attributes, characters stats have a changeable id
- now all additional promts are stacked in 2 lines
This commit is contained in:
Alamion
2026-02-23 21:42:25 +03:00
parent 502646bb92
commit 4d0de8419c
5 changed files with 48 additions and 13 deletions
+1 -1
View File
@@ -6,6 +6,6 @@
"js": "index.js", "js": "index.js",
"css": "style.css", "css": "style.css",
"author": "Marinara", "author": "Marinara",
"version": "3.7.2", "version": "3.7.3",
"homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern" "homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern"
} }
+25 -4
View File
@@ -31,6 +31,7 @@ import { renderUserStats } from '../rendering/userStats.js';
import { renderInfoBox } from '../rendering/infoBox.js'; import { renderInfoBox } from '../rendering/infoBox.js';
import { renderThoughts } from '../rendering/thoughts.js'; import { renderThoughts } from '../rendering/thoughts.js';
import { updateFabWidgets } from './mobile.js'; import { updateFabWidgets } from './mobile.js';
import { safeToSnake } from '../../utils/transformations.js';
let $editorModal = null; let $editorModal = null;
let activeTab = 'userStats'; let activeTab = 'userStats';
@@ -38,6 +39,18 @@ let tempConfig = null; // Temporary config for cancel functionality
let tempAssociation = null; // Temporary association state: { presetId: string|null, entityKey: string|null } let tempAssociation = null; // Temporary association state: { presetId: string|null, entityKey: string|null }
let originalAssociation = null; // Original association when editor opened let originalAssociation = null; // Original association when editor opened
function set_ids_names(list_with_stats, index, value) {
list_with_stats[index].name = value;
const ids = list_with_stats.toSpliced(index, 1).map(stat => stat.id);
const snake_value = safeToSnake(value); // new id format
if (snake_value !== value && !ids.includes(snake_value)) { // check if this id already exists
list_with_stats[index].id = snake_value;
}
return list_with_stats;
}
/** /**
* Initialize the tracker editor modal * Initialize the tracker editor modal
*/ */
@@ -885,7 +898,9 @@ function setupUserStatsListeners() {
// Rename stat // Rename stat
$('.rpg-stat-name').off('blur').on('blur', function () { $('.rpg-stat-name').off('blur').on('blur', function () {
const index = $(this).data('index'); const index = $(this).data('index');
extensionSettings.trackerConfig.userStats.customStats[index].name = $(this).val(); const value = $(this).val();
const list_with_stats = extensionSettings.trackerConfig.userStats.customStats
set_ids_names(list_with_stats, index, value);
}); });
// Change stat max value // Change stat max value
@@ -943,7 +958,9 @@ function setupUserStatsListeners() {
// Rename attribute // Rename attribute
$('.rpg-attr-name').off('blur').on('blur', function () { $('.rpg-attr-name').off('blur').on('blur', function () {
const index = $(this).data('index'); const index = $(this).data('index');
extensionSettings.trackerConfig.userStats.rpgAttributes[index].name = $(this).val(); const value = $(this).val();
const list_with_stats = extensionSettings.trackerConfig.userStats.rpgAttributes
set_ids_names(list_with_stats, index, value);
}); });
// Enable/disable RPG Attributes section toggle // Enable/disable RPG Attributes section toggle
@@ -1394,7 +1411,9 @@ function setupPresentCharactersListeners() {
// Rename field // Rename field
$('.rpg-field-label').off('blur').on('blur', function () { $('.rpg-field-label').off('blur').on('blur', function () {
const index = $(this).data('index'); const index = $(this).data('index');
extensionSettings.trackerConfig.presentCharacters.customFields[index].name = $(this).val(); const value = $(this).val();
const list_with_stats = extensionSettings.trackerConfig.presentCharacters.customFields
set_ids_names(list_with_stats, index, value);
}); });
// Update description // Update description
@@ -1443,7 +1462,9 @@ function setupPresentCharactersListeners() {
// Rename character stat // Rename character stat
$('.rpg-char-stat-label').off('blur').on('blur', function () { $('.rpg-char-stat-label').off('blur').on('blur', function () {
const index = $(this).data('index'); const index = $(this).data('index');
extensionSettings.trackerConfig.presentCharacters.characterStats.customStats[index].name = $(this).val(); const value = $(this).val();
const list_with_stats = extensionSettings.trackerConfig.presentCharacters.characterStats.customStats
set_ids_names(list_with_stats, index, value);
}); });
} }
+11
View File
@@ -0,0 +1,11 @@
const toSnake = str => str
.replace(/[^a-zA-Z]/g, '_')
.replace(/([A-Z])/g, '_$1')
.toLowerCase()
.replace(/_+/g, '_')
.replace(/^_|_$/g, '');
export const safeToSnake = (str) => {
const res = toSnake(str);
return (res.length >= 2) ? res : str; // considering element with one symbol is too short to be safe
};
+9 -6
View File
@@ -10732,7 +10732,10 @@ body[data-theme="cyberpunk"] .rpg-music-widget-play {
/* Features row container */ /* Features row container */
.rpg-features-row { .rpg-features-row {
display: flex; display: grid;
grid-template-rows: repeat(2, 1fr);
grid-auto-flow: column;
grid-auto-columns: min-content;
gap: 8px; gap: 8px;
margin-bottom: 12px; margin-bottom: 12px;
overflow-x: auto; overflow-x: auto;
@@ -10743,11 +10746,11 @@ body[data-theme="cyberpunk"] .rpg-music-widget-play {
} }
/* Center items when they fit, allow scrolling when they don't */ /* Center items when they fit, allow scrolling when they don't */
.rpg-features-row::before, /*.rpg-features-row::before,*/
.rpg-features-row::after { /*.rpg-features-row::after {*/
content: ''; /* content: '';*/
margin: auto; /* margin: auto;*/
} /*}*/
/* Hide scrollbar for cleaner look while maintaining functionality */ /* Hide scrollbar for cleaner look while maintaining functionality */
.rpg-features-row::-webkit-scrollbar { .rpg-features-row::-webkit-scrollbar {