fixes:
- now stats, attributes, characters stats have a changeable id - now all additional promts are stacked in 2 lines
This commit is contained in:
+1
-1
@@ -6,6 +6,6 @@
|
||||
"js": "index.js",
|
||||
"css": "style.css",
|
||||
"author": "Marinara",
|
||||
"version": "3.7.2",
|
||||
"version": "3.7.3",
|
||||
"homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern"
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import { renderUserStats } from '../rendering/userStats.js';
|
||||
import { renderInfoBox } from '../rendering/infoBox.js';
|
||||
import { renderThoughts } from '../rendering/thoughts.js';
|
||||
import { updateFabWidgets } from './mobile.js';
|
||||
import { safeToSnake } from '../../utils/transformations.js';
|
||||
|
||||
let $editorModal = null;
|
||||
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 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
|
||||
*/
|
||||
@@ -885,7 +898,9 @@ function setupUserStatsListeners() {
|
||||
// Rename stat
|
||||
$('.rpg-stat-name').off('blur').on('blur', function () {
|
||||
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
|
||||
@@ -943,7 +958,9 @@ function setupUserStatsListeners() {
|
||||
// Rename attribute
|
||||
$('.rpg-attr-name').off('blur').on('blur', function () {
|
||||
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
|
||||
@@ -1394,7 +1411,9 @@ function setupPresentCharactersListeners() {
|
||||
// Rename field
|
||||
$('.rpg-field-label').off('blur').on('blur', function () {
|
||||
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
|
||||
@@ -1443,7 +1462,9 @@ function setupPresentCharactersListeners() {
|
||||
// Rename character stat
|
||||
$('.rpg-char-stat-label').off('blur').on('blur', function () {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
@@ -10732,7 +10732,10 @@ body[data-theme="cyberpunk"] .rpg-music-widget-play {
|
||||
|
||||
/* Features row container */
|
||||
.rpg-features-row {
|
||||
display: flex;
|
||||
display: grid;
|
||||
grid-template-rows: repeat(2, 1fr);
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: min-content;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
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 */
|
||||
.rpg-features-row::before,
|
||||
.rpg-features-row::after {
|
||||
content: '';
|
||||
margin: auto;
|
||||
}
|
||||
/*.rpg-features-row::before,*/
|
||||
/*.rpg-features-row::after {*/
|
||||
/* content: '';*/
|
||||
/* margin: auto;*/
|
||||
/*}*/
|
||||
|
||||
/* Hide scrollbar for cleaner look while maintaining functionality */
|
||||
.rpg-features-row::-webkit-scrollbar {
|
||||
|
||||
Reference in New Issue
Block a user