diff --git a/README.md b/README.md index 8ce9d82..82efc30 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ An immersive RPG extension for browsers that tracks character stats, scene infor ## 🆕 What's New -### v3.2.2 +### v3.2.3 -- Mobile UI fixes (WAKE ME UP INSIDE). +- Uploading avatars for generated characters is back. **Special thanks to all the other contributors for this project:** Paperboygold, Munimunigamer, Subarashimo, Lilminzyu, Claude, IDeathByte, Chungchandev, Joenunezb, and Amauragis. diff --git a/manifest.json b/manifest.json index 0c6947e..98d4183 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,6 @@ "js": "index.js", "css": "style.css", "author": "Marinara", - "version": "3.2.2", + "version": "3.2.3", "homePage": "https://github.com/SpicyMarinara/rpg-companion-sillytavern" } diff --git a/settings.html b/settings.html index 537b4d6..29eaf4d 100644 --- a/settings.html +++ b/settings.html @@ -48,7 +48,7 @@
- v3.2.1 + v3.2.3
diff --git a/src/systems/rendering/thoughts.js b/src/systems/rendering/thoughts.js index a808acf..4a16521 100644 --- a/src/systems/rendering/thoughts.js +++ b/src/systems/rendering/thoughts.js @@ -507,7 +507,7 @@ export function renderThoughts() { html += `
-
+
${char.name} ${hasRelationshipEnabled ? `
${relationshipBadge}
` : ''}
@@ -621,6 +621,48 @@ export function renderThoughts() { saveSettings(); }); + // Add event listener for avatar upload clicks + $thoughtsContainer.find('.rpg-avatar-upload').on('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + + const characterName = $(this).data('character'); + + // Create hidden file input + const fileInput = $(''); + + fileInput.on('change', function() { + const file = this.files[0]; + if (!file) return; + + // Read file as data URL + const reader = new FileReader(); + reader.onload = function(e) { + const imageUrl = e.target.result; + + // Store in npcAvatars + if (!extensionSettings.npcAvatars) { + extensionSettings.npcAvatars = {}; + } + extensionSettings.npcAvatars[characterName] = imageUrl; + + // Save settings + saveSettings(); + + // Update the avatar image immediately + const $avatar = $thoughtsContainer.find(`.rpg-avatar-upload[data-character="${characterName}"] img`); + $avatar.attr('src', imageUrl); + + console.log(`[RPG Companion] Avatar uploaded for ${characterName}`); + }; + + reader.readAsDataURL(file); + }); + + // Trigger file selection + fileInput.trigger('click'); + }); + // Remove updating class after animation if (extensionSettings.enableAnimations) { setTimeout(() => $thoughtsContainer.removeClass('rpg-content-updating'), 600);