diff --git a/src/systems/dashboard/dashboardIntegration.js b/src/systems/dashboard/dashboardIntegration.js index a1d932e..7878c08 100644 --- a/src/systems/dashboard/dashboardIntegration.js +++ b/src/systems/dashboard/dashboardIntegration.js @@ -21,7 +21,7 @@ import { registerUserInfoWidget } from './widgets/userInfoWidget.js'; import { registerUserStatsWidget } from './widgets/userStatsWidget.js'; import { registerUserMoodWidget } from './widgets/userMoodWidget.js'; import { registerUserAttributesWidget } from './widgets/userAttributesWidget.js'; -import { registerCalendarWidget, registerWeatherWidget, registerTemperatureWidget, registerClockWidget, registerLocationWidget } from './widgets/infoBoxWidgets.js'; +import { registerCalendarWidget, registerWeatherWidget, registerTemperatureWidget, registerClockWidget, registerLocationWidget, registerRecentEventsWidget } from './widgets/infoBoxWidgets.js'; import { registerPresentCharactersWidget } from './widgets/presentCharactersWidget.js'; import { registerInventoryWidget } from './widgets/inventoryWidget.js'; import { registerQuestsWidget } from './widgets/questsWidget.js'; @@ -209,6 +209,7 @@ function registerAllWidgets(registry, dependencies) { registerTemperatureWidget(registry, dependencies); registerClockWidget(registry, dependencies); registerLocationWidget(registry, dependencies); + registerRecentEventsWidget(registry, dependencies); // Social widgets registerPresentCharactersWidget(registry, dependencies); diff --git a/src/systems/dashboard/dashboardManager.js b/src/systems/dashboard/dashboardManager.js index 82d07fa..2358e99 100644 --- a/src/systems/dashboard/dashboardManager.js +++ b/src/systems/dashboard/dashboardManager.js @@ -1681,6 +1681,7 @@ export class DashboardManager { 'temperature': 'tab-scene', 'clock': 'tab-scene', 'location': 'tab-scene', + 'recentEvents': 'tab-scene', 'presentCharacters': 'tab-scene', 'userStats': 'tab-status', 'userInfo': 'tab-status', @@ -1705,13 +1706,14 @@ export class DashboardManager { const widgetsToAdd = []; - // Check infoBox widgets (calendar, weather, temperature, clock, location) + // Check infoBox widgets (calendar, weather, temperature, clock, location, recentEvents) const infoBoxWidgetMap = { 'date': 'calendar', 'weather': 'weather', 'temperature': 'temperature', 'time': 'clock', - 'location': 'location' + 'location': 'location', + 'recentEvents': 'recentEvents' }; Object.entries(infoBoxWidgetMap).forEach(([fieldKey, widgetType]) => { @@ -1961,6 +1963,7 @@ export class DashboardManager { 'temperature': () => config.infoBox?.widgets?.temperature?.enabled === false, 'clock': () => config.infoBox?.widgets?.time?.enabled === false, 'location': () => config.infoBox?.widgets?.location?.enabled === false, + 'recentEvents': () => config.infoBox?.widgets?.recentEvents?.enabled === false, 'userStats': () => { const customStats = config.userStats?.customStats || []; return customStats.filter(s => s.enabled).length === 0; diff --git a/src/systems/dashboard/defaultLayout.js b/src/systems/dashboard/defaultLayout.js index c7dae26..092d169 100644 --- a/src/systems/dashboard/defaultLayout.js +++ b/src/systems/dashboard/defaultLayout.js @@ -143,12 +143,24 @@ export function generateDefaultDashboard() { h: 2, config: {} }, - // Row 4-6: Present Characters (full width, will expand with auto-layout) + // Row 4-5: Recent Events (notebook style, full width) + { + id: 'widget-recentevents', + type: 'recentEvents', + x: 0, + y: 4, + w: 2, + h: 2, + config: { + maxEvents: 3 + } + }, + // Row 6-8: Present Characters (full width, will expand with auto-layout) { id: 'widget-presentchars', type: 'presentCharacters', x: 0, - y: 4, + y: 6, w: 2, h: 3, config: { diff --git a/src/systems/dashboard/widgets/infoBoxWidgets.js b/src/systems/dashboard/widgets/infoBoxWidgets.js index 6a517b8..1ca8e78 100644 --- a/src/systems/dashboard/widgets/infoBoxWidgets.js +++ b/src/systems/dashboard/widgets/infoBoxWidgets.js @@ -24,7 +24,8 @@ function parseInfoBoxData(infoBoxText) { weatherEmoji: '', weatherForecast: '', temperature: '', tempValue: 0, timeStart: '', timeEnd: '', - location: '' + location: '', + recentEvents: [] }; } @@ -34,7 +35,8 @@ function parseInfoBoxData(infoBoxText) { weatherEmoji: '', weatherForecast: '', temperature: '', tempValue: 0, timeStart: '', timeEnd: '', - location: '' + location: '', + recentEvents: [] }; for (const line of lines) { @@ -87,6 +89,13 @@ function parseInfoBoxData(infoBoxText) { } } } + // Recent Events parsing + else if (line.startsWith('Recent Events:')) { + const eventsString = line.replace('Recent Events:', '').trim(); + if (eventsString) { + data.recentEvents = eventsString.split(',').map(e => e.trim()).filter(e => e); + } + } } return data; @@ -476,3 +485,244 @@ function attachSimpleEditHandlers(container, dependencies) { }); }); } + +/** + * Register Recent Events Widget + * @param {WidgetRegistry} registry - Widget registry instance + * @param {Object} dependencies - External dependencies + * @param {Function} dependencies.getExtensionSettings - Get extension settings + * @param {Function} dependencies.saveSettings - Save settings + */ +export function registerRecentEventsWidget(registry, dependencies) { + const { getExtensionSettings, saveSettings } = dependencies; + + registry.register('recentEvents', { + name: 'Recent Events', + icon: '📝', + description: 'Recent events notebook', + category: 'scene', + minSize: { w: 2, h: 2 }, + defaultSize: { w: 2, h: 2 }, + requiresSchema: false, + + /** + * Render widget content + * @param {HTMLElement} container - Widget container + * @param {Object} config - Widget configuration + */ + render(container, config = {}) { + const settings = getExtensionSettings(); + const infoBoxData = settings.committedTrackerData?.infoBox || ''; + const data = parseInfoBoxData(infoBoxData); + + // Merge default config with user config + const finalConfig = { + maxEvents: 3, + ...config + }; + + // Get events array (filter out placeholders) + let validEvents = data.recentEvents.filter(e => + e && e.trim() && + e !== 'Event 1' && e !== 'Event 2' && e !== 'Event 3' && + e !== 'Click to add event' && e !== 'Add event...' + ); + + // If no valid events, show at least one placeholder + if (validEvents.length === 0) { + validEvents = ['Click to add event']; + } + + // Build events HTML + let eventsHtml = ''; + + // Render existing events (max maxEvents) + for (let i = 0; i < Math.min(validEvents.length, finalConfig.maxEvents); i++) { + eventsHtml += ` +