Commit Graph

181 Commits

Author SHA1 Message Date
Lucas 'Paperboy' Rose-Winters 5dd7dcb27b feat(dashboard): improve widget scaling and fix attribute scrollbar
Implement responsive scaling for info widgets and fix sizing issues:

**1. Container-Responsive Info Widgets (style.css)**

**Calendar Widget:**
- Add flexbox layout (height: 100%, flex-direction: column)
- Change font sizes from vw to rem for better scaling
- Calendar day now uses clamp(1.5rem, 2.5rem, 3.5rem) to fill space
- Add flex-shrink: 0 to top/year, flex: 1 to day

**Weather Widget:**
- Add container wrapper (height: 100%, justify-content: space-around)
- Weather icon scales with container: clamp(2rem, 8vh, 4rem)
- Forecast text uses rem instead of vw
- Both elements marked flex-shrink: 0

**Temperature Widget:**
- Container fills height with flexbox centering
- Thermometer scales: clamp(4rem, 60%, 8rem) height
- Tube/bulb use percentages (40% width, 70% height)
- Text value uses rem units

**Clock Widget:**
- Container with space-around layout
- Clock scales with container: clamp(3rem, 60%, 6rem)
- Clock hands use percentages of clock size
- Time text uses rem units

**Location Widget:**
- Container flexbox with column layout
- Map background uses flex: 1 (was fixed 1.875rem)
- Map marker scales: clamp(1.5rem, 4vh, 3rem)
- Location text uses rem units

**2. Fix Attributes Widget Scrollbar (style.css)**
- Line 966: Change grid-auto-rows: 1fr to grid-auto-rows: minmax(0, 1fr)
- Allows rows to shrink below natural size to fit container
- Prevents overflow when widget manually positioned after auto-arrange

**3. Widget Size Constraints (widget files)**
- userAttributesWidget.js: Change minSize from {w:1, h:2} to {w:2, h:2}
  - Enforces 2x2 minimum as requested
  - Prevents cramped 1-column layout
- infoBoxWidgets.js: Change location minSize from {w:2, h:2} to {w:1, h:2}
  - Allows narrow 1x2 layout for space-constrained dashboards
  - Only widget that didn't fit on desktop screen

**Technical Details:**
- All info widgets now use rem units instead of vw for text
- Flexbox scaling ensures widgets fill their containers beautifully
- Percentage-based sizing for thermometer/clock internal elements
- clamp() used for min/preferred/max sizing across resolutions
- minmax(0, 1fr) fixes classic CSS grid overflow issue

**User-Reported Issues Fixed:**
 Info widgets scale to fill containers instead of fixed sizes
 Attributes widget no longer shows scrollbar in 2x2 (manual or auto-arranged)
 Location widget works in both 1x2 and 2x2 layouts
 All widgets maintain readability across different panel widths

Related: Dashboard v2, Epic 2, Phase 3.2
2025-10-23 18:33:01 +11:00
Lucas 'Paperboy' Rose-Winters b3a86d4609 feat(dashboard): implement smart widget collision and category-aware layout
Complete dashboard v2 improvements for better UX and visual consistency:

**1. Push-Aside Drag/Drop (dragDrop.js)**
- Replace swap/revert logic with intelligent reflow algorithm
- When widgets collide on drag, automatically push overlapping widgets down
- All affected widgets repositioned after reflow completes
- Eliminates widget overlap issues

**2. Unified Widget Styling (style.css)**
- Add consistent .rpg-widget container styling for all widgets
- Background: rgba(0,0,0,0.2) for visual separation
- Border-left: 3px highlight for category identification
- Box-shadow and border-radius for depth and polish
- Maintain individual widget decorative styles

**3. Logical Default Layout (defaultLayout.js)**
- Reorganize widgets into semantic clusters with clear comments:
  - USER CLUSTER (top): userInfo → userStats → userMood + userAttributes
  - SCENE CLUSTER (middle): calendar + weather → temp + clock → location
  - SOCIAL CLUSTER (bottom): presentCharacters
- userInfo widget now at top (y=0) as expected
- All positions use rem units for responsive scaling

**4. Category-Aware Auto-Layout (dashboardManager.js)**
- Implement sortWidgetsByCategory() with priority ordering:
  user → scene → social → inventory
- Within user category, specific ordering:
  userInfo → userStats → userMood → userAttributes
- Add preserveOrder option to gridEngine.autoLayout()
- Auto-arrange now uses logical grouping instead of random bin-packing

**5. Multi-Tab Auto-Distribution (dashboardManager.js)**
- Add estimateLayoutHeight() to detect when content exceeds threshold
- Implement distributeWidgetsByCategory() for automatic tab creation:
  - "Status" tab: user + scene widgets
  - "Social" tab: social widgets (if any)
  - "Inventory" tab: inventory widgets (if any)
- Each tab gets category-aware auto-layout
- 80rem height threshold for single-tab limit

**6. Widget Category Metadata (widgets/)**
- Add category field to all widget definitions:
  - userInfo, userStats, userMood, userAttributes: 'user'
  - calendar, weather, temperature, clock, location: 'scene'
  - presentCharacters: 'social'
  - inventory: 'inventory'

**7. Integration Improvements (dashboardIntegration.js)**
- Set default layout on initialization for reset functionality
- Add reset layout button to dashboard header
- Wire up reset button event handler

**8. Core State Management (index.js)**
- Add getInfoBoxData() and setInfoBoxData() to state API
- Ensure info box data persists across sessions

**Technical Details:**
- Rem units throughout for 1080p→4K→mobile responsive scaling
- Reflow algorithm leverages existing gridEngine collision detection
- Category-aware sorting preserves logical relationships
- Multi-tab distribution prevents single-page scroll fatigue
- All changes maintain backwards compatibility with existing layouts

Fixes dashboard issues after rem unit conversion introduced massive positioning bugs.
Users reported widgets overlapping on drag, visual inconsistency, and random auto-arrange behavior.

Related: Epic 2 (Dashboard v2), Phase 3.2
2025-10-23 18:06:44 +11:00
Lucas 'Paperboy' Rose-Winters 264ea2fc4c fix(dashboard): fix resize, drag-drop, overflow, and add auto-migration
Multiple critical fixes for dashboard v2:

**1. ResizeHandler error - updateContainerWidth is not a function**
- resizeHandler.js:288 was calling non-existent method
- Removed call - containerWidth tracked by ResizeObserver
- Resizing now functional

**2. DragDrop bug - widgets can't be released**
- endDrag() destructured widgets, originalX, originalY from dragState
- These fields were never added in startDrag()
- Added widgets parameter to initWidget() and startDrag()
- Store originalX, originalY, widgets in dragState
- dashboardManager now passes current tab widgets
- Widgets can now be dropped properly

**3. Widget content overflow**
- Added base .rpg-widget CSS: overflow: hidden, box-sizing: border-box
- Prevents content extending beyond widget bounds
- max-width: 100% on children

**4. Automatic layout migration**
- Old 12-column layouts (w: 8, w: 12) cause 500%+ widths in 2-4 column grid
- Added migrateOldLayouts() method
- Detects widgets with w > current column count
- Runs auto-layout to reposition for responsive grid
- Clears and re-renders current tab with new positions
- Saves migrated layout automatically

**5. Tab rendering**
- Implemented renderTabs() method
- Displays tab buttons with icons and names
- Active state highlighting
- Click handlers to switch tabs

**6. Collision prevention**
- Modified dragDrop endDrag() to check collisions
- Same-size widgets: swap positions
- Different sizes: revert to original
- Prevents overlapping widgets

**7. Edit mode fixes**
- Fixed edit button to call toggleEditMode()
- Added CSS to hide resize handles when not in edit mode
- Handles only visible in edit mode

**8. Icon-only header buttons**
- Auto-Arrange and Edit buttons now icon-only
- Saves horizontal space in header

All issues from user testing resolved.
2025-10-23 14:49:33 +11:00
Lucas 'Paperboy' Rose-Winters 29afefb76e fix(dashboard): anchor Refresh and Settings buttons to bottom
Fixed panel layout to properly position bottom buttons:

**Changes:**
1. #rpg-panel-content: Changed overflow-y from 'hidden' to 'auto'
   - Allows panel to scroll when needed

2. .rpg-dashboard-container: Added flex properties
   - flex: 1 - Grows to fill available space
   - overflow-y: auto - Scrolls internally when content overflows
   - min-height: 0 - Allows shrinking in flex context

**Result:**
Creates proper flex layout where:
- Dice display stays at top (fixed size)
- Dashboard container fills middle and scrolls (flex: 1)
- Toggle/Refresh/Settings buttons anchor at bottom (fixed size)

Fixes issue where buttons appeared in middle of panel instead of bottom.
2025-10-23 14:16:45 +11:00
Lucas 'Paperboy' Rose-Winters 2c37318798 fix(dashboard): add CSS for header and container layout
Added missing CSS for dashboard v2 header and container:
- .rpg-dashboard-container: Flexbox column layout with gap
- .rpg-dashboard-header: Flexbox row with space-between
- .rpg-dashboard-header-left/right: Flex containers for button groups
- .rpg-dashboard-btn: Button styling with theme variables
- .rpg-dashboard-grid: Grid container styling

Also fixed dashboardManager.js to preserve template structure:
- Changed createContainerStructure() to query existing elements first
- Only creates elements if template didn't provide them
- Prevents clearing the entire container and losing the header

This fixes the issue where all components (header, buttons, widgets)
were stacking on top of each other due to missing layout CSS.
2025-10-23 14:12:42 +11:00
Lucas 'Paperboy' Rose-Winters 122bb3194a feat(dashboard): add auto-layout button with smart widget packing
Implements intelligent auto-layout system that efficiently arranges widgets to maximize space usage while respecting panel width constraints.

**Key Features:**
- Smart packing algorithm that sorts by widget area and finds optimal positions
- Respects responsive column count (2-4 columns based on panel width)
- Prefers full-width widgets when possible to eliminate gaps
- Fallback to narrower widths for better vertical packing
- Maintains minimum widget sizes

**Implementation:**
- GridEngine.autoLayout() - Core packing algorithm with collision detection
- DashboardManager.autoLayoutWidgets() - High-level API that re-renders after layout
- Auto-Arrange button in dashboard header (uses fa-table-cells-large icon)
- Event handler wired to call autoLayoutWidgets with preferFullWidth=true

**Algorithm Strategy:**
1. Sort widgets by area (largest first) for efficient packing
2. For each widget, try full-width placement first
3. Find first available position using row-by-row scan
4. If position is too far down, try narrower widths
5. Mark cells as occupied to prevent overlaps

**Testing Notes:**
- Works with current responsive column system (2-4 columns)
- Respects minimum sizes and column constraints
- Re-renders all widgets after repositioning
- Auto-saves layout changes

Part of Epic 2: Dashboard Widget Library
2025-10-23 14:00:00 +11:00
Lucas 'Paperboy' Rose-Winters 27e1c30ea0 fix: only show mobile refresh FAB when panel open AND in Separate mode
The mobile refresh button was always visible on mobile. It should only
appear when BOTH conditions are met:
- RPG panel is open
- Generation mode is Separate (not Together)

Changes:
- Added opacity: 0 and pointer-events: none to base .rpg-mobile-refresh
- CSS shows button when panel open AND not .rpg-hidden-mode class
- Updated updateGenerationModeUI() to toggle .rpg-hidden-mode on mobile button
- Together mode: adds .rpg-hidden-mode class (keeps button hidden)
- Separate mode: removes .rpg-hidden-mode class (allows CSS to show it)

Result: Mobile refresh FAB only appears when panel is open AND in
Separate mode. Stays hidden when panel closed OR in Together mode.
2025-10-22 11:06:30 +11:00
Lucas 'Paperboy' Rose-Winters ea2231f6ba fix: restore proper spinning animation for mobile refresh FAB
Reverted HTML replacement approach and restored the cleaner CSS-based
animation from commit 1855085.

Previous (wrong) approach:
- Replaced button HTML with spinner
- Modified both desktop and mobile buttons in apiClient.js
- Messy and inconsistent

Restored (correct) approach:
- Add/remove .spinning CSS class in click handler
- CSS animates only the icon inside the button
- Button itself stays unchanged
- Much cleaner implementation

Changes:
- Reverted apiClient.js changes from commit 9a49433
- Added .spinning CSS class and @keyframes rpg-spin
- Updated index.js click handler to bind both buttons
- Uses addClass/removeClass for clean animation control
- Includes drag detection to prevent accidental clicks

Now the mobile FAB icon spins smoothly when refreshing!
2025-10-22 10:47:09 +11:00
Lucas 'Paperboy' Rose-Winters e2393fa73c fix: add missing CSS for mobile refresh FAB button
Mobile refresh button was created in HTML but had no CSS styling,
making it invisible. Desktop refresh button was showing on mobile
with wrong sizing.

Changes:
- Added .rpg-mobile-refresh FAB styles (44px, draggable, etc.)
- Show mobile refresh FAB on mobile viewports
- Hide desktop #rpg-manual-update button on mobile
- Added responsive icon sizing for mobile refresh button

Fixes issue where users only saw the desktop refresh button with
incorrect DPI/sizing on mobile devices.
2025-10-22 10:29:04 +11:00
Paperboy 5ac034438c Merge branch 'main' into fix/user-parsing-issues 2025-10-22 09:59:27 +11:00
Spicy_Marinara 83576a9073 Revert "Merge pull request #16 from paperboygold/main"
This reverts commit c1b2520fa1, reversing
changes made to c6a1352aae.
2025-10-22 00:52:43 +02:00
Lucas 'Paperboy' Rose-Winters f7d8597f24 feat: add reset button positions to settings
PROBLEM:
- Existing users with saved off-screen FAB positions can't see buttons
- No way to reset positions without clearing all extension settings
- Salixfire and other users on Xiaomi/other devices need safe positions

SOLUTION:
Added "Reset Button Positions" button in Advanced settings section

IMPLEMENTATION:

1. template.html (lines 241-249):
   - Added reset button in Advanced section after Clear Cache button
   - Blue-styled button with rotate icon
   - Help text explains it resets FAB positions to top-left

2. index.js (lines 361-390):
   - Added click handler for reset button
   - Resets all 3 FAB positions to safe top-left defaults:
     * Mobile toggle: top + 20px, left: 12px
     * Refresh: top + 80px, left: 12px
     * Debug: top + 140px, left: 12px
   - Saves settings immediately
   - Applies CSS positions to visible buttons (no page refresh needed)
   - Shows success toast notification

3. style.css (lines 2057-2083, 4123-4125):
   - Added .rpg-btn-reset-fab styles matching clear cache pattern
   - Blue color scheme (vs red for destructive clear cache)
   - Same sizing, padding, transitions as other buttons
   - Mobile responsive font-size with clamp()

USAGE:
Users experiencing off-screen buttons can now:
1. Open RPG Companion settings (gear icon)
2. Scroll to Advanced section
3. Click "Reset Button Positions"
4. All FAB buttons instantly move to safe top-left positions

This fixes the issue for Salixfire and any other users who:
- Have buttons saved in off-screen positions
- Can't scroll to find buttons
- Need to reset without clearing all settings

Works immediately without page refresh or extension reload.
2025-10-22 09:22:12 +11:00
Lucas 'Paperboy' Rose-Winters d4491a4705 fix: add debug toggle as draggable mobile FAB button
PROBLEM:
- Debug logs only accessible via browser console (impractical on mobile)
- User (Salixfire) reporting parsing issues but can't debug on mobile device
- Need mobile-friendly debug mode for troubleshooting data display issues

SOLUTION:
Implemented debug toggle FAB button following exact pattern of existing mobile FABs:

Files Changed:
- src/core/state.js: Added debugFabPosition and debugMode to extensionSettings
- src/core/config.js: Added debugFabPosition to defaultSettings (reference)
- index.js: Created debug toggle button, imported setupDebugButtonDrag
- style.css: Added debug toggle CSS matching mobile FAB pattern (44px, grab cursor, theme colors)
- src/systems/ui/mobile.js: Added setupDebugButtonDrag() with drag-to-reposition
- src/systems/ui/debug.js: Removed button creation, added just-dragged check, updated visibility control

Implementation Details:
- Button created in index.js (not debug.js) following mobile FAB pattern
- CSS matches mobile toggle/refresh buttons (44px, theme colors, grab cursor, user-select: none)
- Drag support with touch/mouse handlers, 200ms/10px threshold
- Position saved to extensionSettings.debugFabPosition
- Just-dragged flag prevents accidental clicks after drag
- Mobile (≤1000px): slide from right with rpg-mobile-open/closing classes
- Desktop (>1000px): slide from bottom with rpg-debug-open class
- Event delegation for reliable click handling
- Default position: bottom 140px, left 20px (below other FABs)

Bug Fix:
- Initial implementation had debugFabPosition only in config.js
- extensionSettings uses state.js as source, not config.js
- Without debugFabPosition in state.js, button had no position and was invisible
- Now properly initialized in both files

The debug button is hidden by default (debugMode: false) and shown when user enables debug mode in RPG Companion settings. This allows Salixfire to view parser logs on mobile and troubleshoot the data display issues.
2025-10-22 08:29:58 +11:00
Lucas 'Paperboy' Rose-Winters 44240e6840 fix: debug panel close button not working
Added event.preventDefault() and event.stopPropagation() to close button handler
to prevent any interference from parent elements.

Also added pointer-events: none to button icons to ensure clicks on the icon
register on the button itself, not the <i> element.

Changes:
- src/systems/ui/debug.js: Added e.preventDefault/stopPropagation to close handler
- src/systems/ui/debug.js: Added console.log for debugging
- style.css: Added pointer-events: none to .rpg-debug-actions button i
2025-10-22 07:33:30 +11:00
Lucas 'Paperboy' Rose-Winters b5d35ac2b0 feat: add mobile-friendly debug mode for parser troubleshooting
Add comprehensive debug logging system that's accessible on mobile devices
where browser console is impractical.

**New Features:**
- Debug mode toggle in extension settings (🔍 Debug Mode)
- Mobile-friendly debug panel with slide-up UI
- Red bug FAB button to toggle debug log viewer
- Copy logs to clipboard functionality
- Auto-scrolling log display with timestamps
- Stores last 100 log entries to prevent memory issues

**Parser Enhancements:**
- All parser logs now use debugLog() helper function
- Logs only appear in UI when debug mode is enabled
- Console.log still works for desktop debugging
- Full visibility into parsing pipeline:
  - Raw AI response preview
  - Code blocks found and matched
  - Stats extraction (health, energy, mood, etc.)
  - Inventory parsing (v1 and v2)
  - Final values saved to settings

**UI Components:**
- src/systems/ui/debug.js: Debug panel creation and management
- style.css: Mobile-first debug panel styles (FAB + slide-up panel)
- Desktop view: Smaller panel in bottom-right corner

**Settings:**
- src/core/config.js: Added debugMode default (false)
- src/core/state.js: Added debug logs storage array
- settings.html: Added debug mode checkbox
- index.js: Wire up debug toggle and initialize UI

**Usage for Mobile Users:**
1. Enable "Debug Mode" in RPG Companion settings
2. Red bug button appears (bottom-left)
3. Tap bug button to view logs
4. Use "Copy" to share logs for troubleshooting
5. Logs show exactly what AI generated and how parser handled it

This addresses the issue where users on mobile can't access browser
console to diagnose parsing problems (vanishing attributes, placeholder
characters, etc.). Now they can view and share logs directly.
2025-10-22 07:22:28 +11:00
Spicy Marinara c1b2520fa1 Merge pull request #16 from paperboygold/main
fix: refresh button placement (mobile)
2025-10-21 21:07:41 +02:00
Lucas 'Paperboy' Rose-Winters cc48f9ed54 fix: reduce mood box vertical height on mobile
- Reduced gap from 6px to 3px for more compact display
- Reduced vertical padding to 4px (from clamp(4px, 0.6vh, 6px))
- Tightened line-height from 1.3 to 1.2
- Reduced emoji size slightly (clamp(14px, 3.5vw, 18px))
- Frees up vertical space for attribute boxes and avatar on mobile
2025-10-21 22:05:11 +11:00
Lucas 'Paperboy' Rose-Winters 95d2031e4f fix: increase calendar day box height and padding on mobile
- Added min-height: 3em to rpg-calendar-day on mobile
- Increased vertical padding to 0.75em (from 0.25em default)
- Added line-height: 1.2 for tighter text
- Prevents date text from being pushed too high and cutting into box above
- Flexbox centering now has enough space to properly center content
2025-10-21 22:03:25 +11:00
Lucas 'Paperboy' Rose-Winters 1855085d2c fix: copy mobile toggle pattern for refresh button
- Moved refresh button creation from template.html to index.js (appended to body)
- Created new CSS class .rpg-mobile-refresh (exact copy of .rpg-mobile-toggle pattern)
- Uses opacity for show/hide instead of display (CSS controls visibility based on panel state)
- Show when panel open (body:has(.rpg-panel.rpg-mobile-open))
- Hide when panel closed (opacity: 0, pointer-events: none)
- Updated constrainFabToViewport() to accept optional button parameter
- Automatically detects which button and uses correct settings (mobileFabPosition or mobileRefreshPosition)
- Simplified updateGenerationModeUI() - CSS handles visibility
- Kept full drag functionality with touch and mouse support
- Button positioned via JavaScript with saved position
- z-index: 1001 (above panel, below toggle at 10002)
2025-10-21 21:57:37 +11:00
Lucas 'Paperboy' Rose-Winters 711f3feb00 fix: increase refresh button z-index to appear above panel
- Changed z-index from 99 to 1001
- Now properly layers: panel (1000) < refresh button (1001) < FAB toggle (10002)
- Refresh button is now visible when panel is open
2025-10-21 21:44:58 +11:00
Lucas 'Paperboy' Rose-Winters 8e913031f1 fix: remove excessive vertical padding from level value on mobile
- Changed .rpg-level-value padding from clamp(1px, 0.2vh, 2px) 0.375em to 0 0.375em
- Added mobile-specific override to prevent level value from inheriting large touch-friendly padding
- Level value now stays compact and properly aligned on mobile (no min-height, no vertical padding)
- Fixes misalignment and unwanted vertical space below level value
2025-10-21 21:42:03 +11:00
Lucas 'Paperboy' Rose-Winters e345715090 feat: add draggable mobile refresh button with improved UX
- Repositioned mobile refresh button to bottom-right (80px from bottom)
- Implemented full drag-to-reposition functionality
  * Touch and mouse support with 200ms/10px threshold
  * RequestAnimationFrame for smooth dragging
  * Position saved to extensionSettings.mobileRefreshPosition
  * Viewport constraints with 10px padding
- Fixed sticky tap highlight issue
  * Added -webkit-tap-highlight-color: transparent
  * Added blur() on click to remove focus
  * Set user-select: none and touch-action: none
- Show/hide based on panel state
  * Only visible when panel is expanded (rpg-mobile-open)
  * Listens to rpg-panel-toggled events
  * Auto-hides when panel closes
- Prevent accidental refresh after drag
  * just-dragged flag prevents click for 100ms
  * Click handler checks flag before executing
- Changed from absolute to fixed positioning for viewport-wide dragging
- Added mobileRefreshPosition to default settings (bottom: 80px, right: 20px)
- z-index: 99 (below FAB toggle at 100)
2025-10-21 21:39:56 +11:00
Lucas 'Paperboy' Rose-Winters dd392e50d1 fix(mobile): improve refresh button - float over all tabs, add animation, fix focus
**Changes:**
1. Move button to float over all tabs (not just Stats)
   - Removed from userStats.js HTML
   - Added to template.html as floating absolute element
   - Now visible on Status, Info, and Inventory tabs

2. Fix sticky black focus state
   - Added :focus { outline: none } to CSS
   - Call blur() after click to clear focus immediately

3. Add refresh animation
   - Button spins during updateRPGData() call
   - Smooth 0.8s rotation with @keyframes
   - Uses .spinning class added/removed in JS

4. Improve theming and positioning
   - Positioned absolute top-right (10px, 10px)
   - Increased to 44px for better touch target
   - z-index: 100 to float above content
   - Already uses theme colors (--rpg-highlight, --rpg-text)

Mobile UX now:
 Button visible on all tabs (floating)
 Spins smoothly when refreshing
 No sticky black state after tap
 Properly themed across all themes
2025-10-21 21:27:20 +11:00
Lucas 'Paperboy' Rose-Winters 577010e2aa fix(mobile): move refresh button to top-right icon, fix tiny text issue
- Add compact 36px circular icon button in user stats header (mobile only)
- Hide full-width bottom button on mobile (<=1000px)
- Fixes 1.1vw font-size being ~4px on mobile viewports
- Fixes button blocking attributes at bottom
- Desktop unchanged: keeps full-width button at bottom

Mobile: [Avatar] [Name] | LVL [5] [🔄]
Desktop: [🔄 Refresh RPG Info] at bottom
2025-10-21 21:21:39 +11:00
IDeathByte 8fd08bfc28 Fix fir fix
miss height =\
2025-10-20 23:31:44 +05:00
IDeathByte 60a8c2f21f Fix user icon/fonts scaling
scaling fix again :)
2025-10-20 23:18:06 +05:00
Spicy_Marinara 776d0823a2 Fix parser to support both text and emoji formats for Info Box and Present Characters trackers 2025-10-20 14:49:30 +02:00
Spicy Marinara 599356fafb Merge pull request #13 from paperboygold/feature/inventory-bugfixes
feat: inventory bugfixes, status polish, editable inventory fields
2025-10-20 02:03:06 +02:00
Lucas 'Paperboy' Rose-Winters 5ec12cbf10 feat(ui): add centered 'Add Item' button to all storage locations
- Added persistent '+ Add Item' button at bottom of each storage location
- Button is centered and always visible (whether location has 0 or many items)
- Removed redundant '+ Add' button from storage location header (kept trash button)
- Reverted empty state to simple message instead of special button
- Added CSS for .rpg-storage-add-item-container to center button with margin
- Matches UI pattern from On Person and Assets tabs
- Removed debug logging from inventoryActions.js
2025-10-20 08:43:49 +11:00
Lucas 'Paperboy' Rose-Winters d9b784d745 fix(init): add defensive error handling for edge cases
Added comprehensive error handling to prevent extension initialization failures:

- Added settings validation in loadSettings() to detect corrupt data
- Improved error recovery in main initialization with granular try-catch blocks
- Enhanced HTML regex import with structure validation and detailed error logging
- Added detection for conflicting old manual formatting regex scripts
- Added user-friendly toastr notifications for initialization errors and conflicts
- Each init step now has independent error handling to prevent cascade failures

This fixes issues where invalid extension_settings could prevent the extension
from loading entirely. The extension will now gracefully handle corrupt data,
warn about conflicts, and fall back to defaults when necessary.

Related to user report where extension wouldn't load with certain settings.json
configurations containing old manual formatting regexes or malformed data.
2025-10-18 16:01:10 +11:00
Lucas 'Paperboy' Rose-Winters 0f2e19fc91 fix(ui): adjust thought bubble sizing for desktop and mobile
- Desktop: reduce max-width by 30% (350px → 245px) to fit within circles
- Mobile: increase content font size (clamp(9px,1.2vw,11px) → clamp(12px,3.5vw,16px))
- Mobile: increase thought icon size by 20% (2.25rem → 2.7rem)
- Mobile: adjust icon font size proportionally (1.85vw → 2.2vw)
2025-10-17 17:52:58 +11:00
Lucas 'Paperboy' Rose-Winters de43e84cd0 style(inventory): improve view toggle and storage name contrast
- Changed storage location names to black for better visibility on colored background
- Updated view toggle buttons to have dark background with proper border outline
- Removed wrapper background from view toggle, individual buttons now standalone
2025-10-17 17:33:58 +11:00
Lucas 'Paperboy' Rose-Winters 73050a085b feat(inventory): add list/grid view modes with individual item management
Implemented comprehensive individual item management system with toggleable view modes:

- Added item parsing utilities (parseItems/serializeItems) for comma-separated strings
- Implemented list view (full-width rows) and grid view (responsive cards)
- Added view mode toggle buttons per inventory section (onPerson, stored, assets)
- View preferences persist per-section in settings
- Replaced text-based editing with add/remove item controls
- Added inline forms for adding new items (matching existing UX patterns)
- Applied theme accent color (--rpg-highlight) to all outlines and active states
- Updated all tabs (desktop/mobile/inventory subtabs) with theme-consistent styling

Technical improvements:
- Created itemParser.js utility module for item string manipulation
- Enhanced inventory rendering with conditional list/grid HTML generation
- Added switchViewMode handler with settings persistence
- Fixed [object Object] display bug with comprehensive type checking
- All buttons and items now use transparent backgrounds with theme accent borders
2025-10-17 17:30:57 +11:00
Lucas 'Paperboy' Rose-Winters 26acee3a70 fix(mobile): prevent Info tab from rendering over other tabs
Changed selector from .rpg-mobile-tab-content[data-tab-content="info"]
to include .active class, preventing the info tab from always being
visible regardless of which tab is selected.

The display: flex !important was overriding the base tab switching
logic (.rpg-mobile-tab-content { display: none; }), causing the info
tab to render on top of all other tabs.
2025-10-17 16:59:45 +11:00
Lucas 'Paperboy' Rose-Winters b3ca2960d8 fix(mobile): center avatar without breaking mood layout
Changed selector from .rpg-stats-left > div to :first-child to only
target the avatar wrapper, preventing the mood emoji from stretching
into the attributes column.

The previous fix made all direct children of .rpg-stats-left span the
full width, which incorrectly affected the mood div. Now only the
first child (avatar wrapper) spans both columns and is centered.
2025-10-17 16:47:26 +11:00
Lucas 'Paperboy' Rose-Winters 0608bc6280 fix(ui): make info box compact to give stats section more space
Changed .rpg-info-section from flex: 1 to flex: 0 0 auto so it only
takes the vertical space needed by its content (calendar/weather/
location widgets) rather than expanding equally with other sections.

Previously, all .rpg-section elements had flex: 1, causing them to
equally share vertical space. This forced the info box to expand
beyond its content needs, creating excessive bottom padding.

With this change:
- Info box is now compact (no wasted space)
- Stats section expands to fill more vertical space
- Overall layout is more balanced with stats getting priority
2025-10-17 16:38:42 +11:00
Lucas 'Paperboy' Rose-Winters 97dc87062f feat(inventory): replace prompt dialogs with inline editing
Replaced all prompt() and confirm() dialogs with contenteditable fields
and inline UI components for a better user experience.

Changes:
- Made inventory fields (On Person, Stored items, Assets) contenteditable
  with blur-to-save functionality
- Replaced "Add Location" prompt with inline form (hidden by default)
- Replaced "Remove Location" confirm with inline confirmation UI
- Added CSS styling for inline editing states (hover, focus, empty)
- Added CSS for inline forms, buttons, and confirmation UI
- Fixed bug where inventory sub-tabs were unclickable due to
  incorrect container ID in toggleLocationCollapse() and
  switchInventoryTab() functions

All inline edits now save automatically on blur, matching the UX
pattern used elsewhere in the extension (mood/conditions fields).
2025-10-17 16:27:59 +11:00
Lucas 'Paperboy' Rose-Winters f560bb543b feat(ui): add tab navigation system for desktop and mobile
Desktop (2 tabs):
- Status tab: User Stats + Info Box + Character Thoughts
- Inventory tab: Inventory system (dedicated space)

Mobile (3 tabs):
- Stats tab: User Stats only
- Info tab: Info Box + Character Thoughts
- Inventory tab: Inventory only

Features:
- Created desktop.js module for desktop tab management
- Updated mobile.js to use 3-tab structure (more breathing room on small screens)
- Added CSS styling for desktop tabs (hover states, active indicators)
- Implemented viewport transition handlers (desktop ↔ mobile)
- Tabs replace dividers (cleaner visual separation)
- Character thoughts can now expand to fill vertical space

This resolves the cramped 4-section panel issue by organizing content into logical tabs on both desktop and mobile.
2025-10-17 16:18:47 +11:00
Lucas 'Paperboy' Rose-Winters 790cf995b4 feat(inventory): add v2 UI rendering with tabbed interface
Create complete inventory UI rendering system:

**NEW: inventory.js rendering module (252 lines):**
- renderInventorySubTabs() - Navigation tabs (On Person, Stored, Assets)
- renderOnPersonView() - Display items currently carried/worn
- renderStoredView() - Collapsible storage locations with edit/remove actions
- renderAssetsView() - Vehicles, property, and major possessions
- renderInventory() - Main rendering function with v1/v2 compatibility
- updateInventoryDisplay() - DOM update helper
- Includes HTML escaping for XSS prevention

**Tab System:**
- Three sub-tabs: On Person, Stored, Assets
- Smooth tab switching with active state highlighting
- Each view shows relevant inventory section

**On Person View:**
- Shows items currently carried/worn
- Edit button to modify items
- Clean text display

**Stored View:**
- Collapsible location sections
- Each location shows: name, items, edit/remove buttons
- "Add Location" button for new storage spots
- Empty state message when no locations exist
- Toggle icons (chevron-down/chevron-right)

**Assets View:**
- Display of vehicles, property, equipment
- Edit button to modify assets
- Helpful hint text explaining asset categories

**Removed old inventory UI from userStats.js:**
- Deleted rpg-inventory-box HTML (5 lines)
- Deleted inventory editing event listener (13 lines)
- Inventory now has dedicated tab instead of inline display
- Maintains backward compatibility for data tracking

**NEW: Inventory CSS styles (242 lines):**
- .rpg-inventory-container - Main layout
- .rpg-inventory-subtabs - Tab navigation styling
- .rpg-inventory-section - Content area styling
- .rpg-storage-location - Collapsible location cards
- Button styles (edit, add, remove) with hover states
- Mobile responsive breakpoints for touch-friendly UI
- Theme-aware using SillyTavern CSS variables
- Font size: 0.9rem for readability

**Design Features:**
- Clean, modern card-based layout
- Smooth transitions and hover effects
- Collapsible sections to reduce clutter
- Consistent with existing RPG Companion theme system
- Mobile-first responsive design
- Touch-friendly button sizes on mobile

Changes:
- NEW: src/systems/rendering/inventory.js (252 lines)
- MODIFIED: src/systems/rendering/userStats.js (-18 lines, removed old UI)
- MODIFIED: style.css (+242 lines, inventory styles)

Part of inventory system v2 implementation
Dependencies: v2 types, migration, parsing, generation
2025-10-17 15:14:02 +11:00
Lucas 'Paperboy' Rose-Winters 658b911d12 style: integrate upstream font-size and layout improvements
Folds in changes from commits 6d97992, cc53c69, 6987c0c:
- Update stat label/value font sizes (clamp 0.9-1vw → 0.5-0.7vw)
- Update inventory items font size (clamp 0.4-0.6vw → 0.7-0.6vw)
- Center dice save button with auto margins
- Add debug console.log for committedTrackerData
- Comment out verbose console logs for plot progression and persona avatar
- Clarify prompt instruction to remove brackets
2025-10-17 14:35:55 +11:00
Lucas 'Paperboy' Rose-Winters bb952aecec fix(ui): correct dice roller 'Save Roll' button positioning
The Save Roll button was appearing at the bottom left of the container
instead of being centered below the result.

Added flexbox layout to .rpg-dice-result container:
- display: flex
- flex-direction: column
- align-items: center

This ensures the button is properly centered and positioned below
the dice result value and details.
2025-10-17 13:05:41 +11:00
Lucas 'Paperboy' Rose-Winters 871f187f40 fix(mobile): improve Settings UI and button readability
Convert Settings UI font sizes from viewport units to responsive clamp()
values with pixel minimums. Desktop vw values (1.1-1.85vw) were rendering
as 4-7px on 390px mobile screens, making settings controls unreadable.

UI Buttons (2 overrides):
- Settings button: clamp(14px, 3.6vw, 18px) - was 1.1vw (4.29px)
- Mobile toggle dice icon: clamp(20px, 5.1vw, 26px) - was 1.85vw (7.22px)

Settings Popup (6 overrides):
- Popup title (h3): clamp(16px, 4.1vw, 20px) - was ~5.85px
- Group headers (h4): clamp(14px, 3.6vw, 18px) - was 1.5vw (5.85px)
- Setting labels: clamp(12px, 3.1vw, 16px) - was 1.2vw (4.68px)
- Dropdowns/inputs: clamp(13px, 3.3vw, 17px) - was 1.3vw (5.07px)
- Helper text (small): clamp(10px, 2.6vw, 13px) - was ~3.9px
- Clear cache button: clamp(13px, 3.3vw, 17px) - was 1.2vw (4.68px)

Mobile toggle button size remains unchanged (44px), only icon scaled up.
2025-10-17 12:18:50 +11:00
Lucas 'Paperboy' Rose-Winters 8b6ae6e68d fix(mobile): improve Info dashboard, stat bars, and dice display
Convert mobile font sizes from viewport units to responsive clamp() values
with pixel minimums to ensure readability on small screens. Desktop vw values
(0.4-1.3vw) were rendering as 1.5-5px on 390px mobile screens.

Info Screen Improvements:
- Calendar: month (8-10px), weekday (11-14px), year (7-10px)
- Weather forecast: 9-11px
- Temperature value: 10-13px
- Clock time: 10-13px
- Location text: 11-14px (unchanged)
- Map marker emoji: 16-20px

Stats Screen Improvements:
- Stats grid: min-height 180px for better vertical fill
- Stat labels: clamp(11px, 2.8vw, 14px)
- Stat values: clamp(12px, 3.1vw, 16px)
- Increased gap between stat rows: clamp(8px, 2vw, 12px)

Dice Display Improvements:
- Container text: clamp(12px, 3.1vw, 16px)
- Dice icon: clamp(18px, 4.6vw, 24px)
- Clear button: clamp(18px, 4.6vw, 24px) text, 28-36px size
- Min-height: 44px (touch-friendly)
- Increased padding and gap for better visibility

All improvements maintain desktop appearance while ensuring mobile usability.
2025-10-17 12:06:05 +11:00
Lucas 'Paperboy' Rose-Winters 0aee477b52 fix(mobile): improve text readability and layout on mobile devices
Convert mobile font sizes from fixed pixels to responsive viewport units
with pixel minimums using clamp() to ensure readability on small screens.
Previously, desktop vw values (0.4-0.8vw) rendered as 1.5-3px on mobile,
making text unreadable.

Mobile Font Size Updates:
- Collapse toggle icon: clamp(20px, 5.1vw, 24px)
- Mobile tab buttons: clamp(14px, 3.6vw, 18px)
- Mobile tab icons: clamp(16px, 4.1vw, 20px)
- Classic stat labels: clamp(9px, 2.3vw, 12px)
- Classic stat values: clamp(14px, 3.6vw, 18px)
- Stat +/- buttons: clamp(14px, 3.6vw, 18px)
- Relationship badges: clamp(10px, 2.6vw, 13px)
- Inventory items: clamp(11px, 2.8vw, 14px)
- Mood conditions: clamp(11px, 2.8vw, 14px)
- Character emoji: clamp(16px, 4.1vw, 20px)
- Character names: clamp(12px, 3.1vw, 16px)
- Character traits: clamp(11px, 2.8vw, 14px)

Mobile Layout Improvements:
- Expand inventory box horizontally using flex: 1 to fill available space
- Force avatar+inventory flex container to full width in grid cell
- Reposition mood section to align with attributes top (grid-row: 4/6)
- Update grid structure to 5 rows for better vertical organization
- Remove desktop width restrictions on inventory box

These changes follow IDeathByte's commit 733c606 approach of using
viewport-responsive units, adapted specifically for mobile screen sizes.
2025-10-17 11:48:36 +11:00
IDeathByte 733c6060bd replace all font-size properties to vw for normal screen scaling 2025-10-16 19:32:53 +05:00
Spicy_Marinara 74e76ff224 Fix multiple issues: persona avatar loading, together mode tracker persistence, CSS responsive scaling, and weather widget
- Fixed persona avatar loading for custom user profile folders with fallback
- Added dynamic persona avatar updates when user switches personas
- Fixed together mode bug where committedTrackerData wasn't persisting after first generation
- Together mode now mirrors separate mode logic for swipes vs new messages
- Converted all CSS font-sizes from rem to vw for proper responsive scaling
- Fixed weather widget scaling issues at high zoom levels
- Added image generation detection to skip tracker injection for quietImage requests
- Removed CHARACTER_MESSAGE_RENDERED listener to fix race condition in together mode
2025-10-16 14:50:52 +02:00
Paperboy 54ead0ed0c Merge branch 'main' into feat/mobile-ux-improvements 2025-10-16 14:45:26 +11:00
Lucas 'Paperboy' Rose-Winters 58b7ea4d21 feat: add mobile keyboard handling to prevent layout squashing
Implemented Visual Viewport API integration to detect and handle mobile
keyboard appearance, preventing contenteditable fields from squashing
the panel layout when the keyboard appears.

**JavaScript Changes (index.js:1886-1948, 522-523):**
- Created setupMobileKeyboardHandling() function:
  * Uses Visual Viewport API to monitor viewport height changes
  * Detects keyboard appearance (viewport < 75% of window height)
  * Adds .rpg-keyboard-visible class when keyboard shows
  * Removes class when keyboard dismisses
  * Gracefully falls back if API not supported
- Created setupContentEditableScrolling() function:
  * Uses event delegation for all contenteditable fields
  * Automatically scrolls focused field into view with 300ms delay
  * Centers field in viewport using scrollIntoView with 'center' block
  * Smooth scrolling animation for better UX
- Added both function calls to initUI() for automatic setup

**CSS Changes (style.css:3232-3252):**
- Added .rpg-keyboard-visible state styling:
  * 20px bottom padding to prevent content being pushed too far up
  * Compact section padding (8px 12px) for stats/info/thoughts
  * Reduced stat bar gap (4px) to maintain layout integrity
- Scoped to mobile viewport only (@media max-width: 1000px)

**Benefits:**
- No layout squashing when keyboard appears on mobile
- Stat bars and charts remain intact and visible
- Focused fields automatically scroll into view
- Smooth animations for professional UX
- Works with all contenteditable fields:
  * Stats (health, energy, hygiene, sustenance, arousal)
  * Inventory and mood/conditions
  * Info box widgets (date, weather, time, location, temperature)
  * Character traits and relationship badges
  * Character thoughts
- Backward compatible (graceful fallback)
- Desktop users completely unaffected

**How It Works:**
1. Visual Viewport API monitors viewport height changes
2. When height drops below 75% threshold, keyboard detected
3. Panel gets .rpg-keyboard-visible class for compact styling
4. Tapped contenteditable field smoothly scrolls to center
5. When keyboard dismisses, layout returns to normal

**Testing Completed:**
- Inventory field editing works without squashing
- Stat values editable with keyboard visible
- Info box widget editing maintains layout
- Character traits and thoughts remain accessible
- No layout breaks or chart distortion
- Smooth scrolling and transitions verified
2025-10-16 14:37:43 +11:00
Lucas 'Paperboy' Rose-Winters 644e893a3d fix: redesign attributes as ultra-compact 2x3 grid for mobile
Completely redesigned the classic stats (STR, DEX, CON, INT, WIS, CHA)
section for mobile with 1/3 size reduction and vertical stack layout.

**CSS Changes (style.css:3510-3587):**
- Changed from vertical flex list to 2x3 CSS grid layout
- Reduced all dimensions by ~66% for ultra-compact mobile view:
  * Labels: 9px (was 12px)
  * Values: 14px (was 20px)
  * Buttons: 24x24px (was 36x36px)
  * Padding: 4px 6px (was 8px 10px)
  * Gaps: 2-4px (was 6-8px)
- Vertical stack layout within each stat box:
  * Row 1: Label (left) | Value (right)
  * Row 2: Minus button (left) | Plus button (right)
- Fixed button visibility:
  * Added explicit background, border, and color styles
  * Added display: flex !important to ensure rendering
  * Added hover and active states
- Fixed right-side cutoff:
  * Added 5px padding-right to stats grid
  * Adjusted margins for proper spacing
- Centered all elements using justify-self: center
- Removed conflicting @media (max-width: 768px) rule that enlarged buttons

**JavaScript Changes (index.js:518, 985-1011):**
- Created setupClassicStatsButtons() function with delegated event listeners
- Moved event handlers from renderUserStats() to setup function
- Used jQuery .on() delegation to persist across re-renders
- Prevents duplicate handlers and ensures buttons always work
- Called in initUI() during extension initialization

**Benefits:**
- Attributes take up 1/3 the vertical space on mobile
- No vertical overflow in mobile Stats tab
- All 6 attributes fit comfortably in 2x3 grid
- +/- buttons visible and properly aligned
- Buttons fully functional with delegation pattern
- Desktop layout completely unaffected (>1000px)

**Layout:**
```
┌────────────┐ ┌────────────┐
│ STR    13  │ │ DEX    16  │
│  -      +  │ │  -      +  │
└────────────┘ └────────────┘
┌────────────┐ ┌────────────┐
│ CON    14  │ │ INT    18  │
│  -      +  │ │  -      +  │
└────────────┘ └────────────┘
┌────────────┐ ┌────────────┐
│ WIS    13  │ │ CHA    15  │
│  -      +  │ │  -      +  │
└────────────┘ └────────────┘
```
2025-10-16 14:15:44 +11:00
Lucas 'Paperboy' Rose-Winters f70ac827aa feat: redesign settings popup modal for mobile compatibility
Completely refactored the RPG Companion settings popup with professional
ES6 architecture and mobile-first CSS, matching the dice roller redesign.

**CSS Changes (style.css:2585-2773):**
- Mobile-first responsive design with clamp() and min() functions
- CSS custom properties for fluid scaling across viewports
- min-height: 0 on flex children for proper max-height constraints
- ::before pseudo-element for backdrop (removed overlay div)
- State-based animations with .is-open and .is-closing classes
- 75vh max-height with proper viewport centering
- Touch-friendly 44px minimum tap targets
- Neutral 80% opaque background for visibility

**HTML Changes (template.html:71-214):**
- Added ARIA attributes: role="dialog", aria-modal="true", aria-labelledby
- Semantic <header> element for settings header
- aria-hidden="true" on all decorative icons
- Removed .rpg-settings-popup-overlay div (now CSS ::before)
- Improved accessibility throughout

**JavaScript Changes (index.js:985-1142):**
- Created SettingsModal ES6 class with state management
- open() and close() methods with animation control
- updateTheme() for real-time theme switching
- Private _applyCustomTheme() and _clearCustomTheme() methods
- isAnimating flag prevents double-clicks
- Focus management for accessibility
- Backwards compatible wrapper functions preserve existing API
- Updated event handlers with backdrop click support
- Removed obsolete overlay click handler

**Benefits:**
- Settings modal now fully functional on mobile devices
- Proper scrolling with content overflow
- Smooth open/close animations
- Professional class-based architecture
- Complete accessibility support
- Theme support maintained
- No breaking changes to existing code
2025-10-16 13:59:41 +11:00