Skip to content

Commit bd76a4c

Browse files
authored
Merge pull request #9 from mordachai/dev
Dev
2 parents 1e08c1b + 4d6b5c2 commit bd76a4c

9 files changed

Lines changed: 248 additions & 256 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
![image](https://github.com/user-attachments/assets/c39f24ce-467d-4593-bcde-156685089401)
88

9-
Check the video on YouTube: https://www.youtube.com/watch?v=c95AF7TEV7E
10-
119
## Installation
1210

1311
In Foundry VTT, go to the Add-on Modules tab and click Install Module. Then:
@@ -25,7 +23,6 @@ https://github.com/mordachai/sleek-chat/raw/main/module.json
2523

2624
### The Sleek Chat will appear only when you collapse the Foundry sidebar.
2725

28-
- **Enable Drag and Drop:** Allow the Sleek Chat interface to be repositioned on the screen.
2926
- **Sleek Chat Opacity:** Adjust the overall opacity of the Sleek Chat interface (0.1 to 1.0).
3027
- **Hide Navigation Menus:** You can occult the selected navigation buttons in the sidebar to help lessen the cluttering, keeping only the ones your players need.
3128
- **Hide Always:** Keep the selected menus hidden even when the sidebar is expanded.

module.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "sleek-chat",
33
"title": "Sleek Chat",
44
"description": "A minimalist dice rolling toolbar that integrates seamlessly with the Foundry VTT chat, focusing on a clean and uncluttered interface.",
5-
"version": "1.3.1",
5+
"version": "1.4.0",
66
"compatibility": {
77
"minimum": "12",
88
"verified": "12"
@@ -20,8 +20,7 @@
2020
"scripts/settings.js",
2121
"scripts/sleek-chat-debug.js",
2222
"scripts/main.js",
23-
"scripts/recent-message-display.js",
24-
"scripts/drag-pos.js"
23+
"scripts/recent-message-display.js"
2524
],
2625
"url": "https://github.com/mordachai/sleek-chat",
2726
"manifest": "https://github.com/mordachai/sleek-chat/raw/main/module.json",

scripts/drag-pos.js

Lines changed: 0 additions & 102 deletions
This file was deleted.

scripts/main.js

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { debugLog } from './sleek-chat-debug.js';
22
import './settings.js';
33
import { RecentMessageDisplay } from './recent-message-display.js';
4-
import { updateDragAndDropState } from './drag-pos.js';
5-
import { getDragPosition, setDragPosition } from './drag-pos.js';
64

75
function parseDiceRanges() {
86
const ranges = {};
@@ -30,6 +28,34 @@ function parseDiceRanges() {
3028
return ranges;
3129
}
3230

31+
export function applyChatBaseContainerOpacity() {
32+
const chatBaseContainer = document.querySelector('.chat-base-container');
33+
const sleekChatOpacity = game.settings.get("sleek-chat", "sleekChatOpacity");
34+
35+
if (chatBaseContainer) {
36+
// Set initial opacity to the setting value
37+
chatBaseContainer.style.opacity = sleekChatOpacity;
38+
39+
// Add hover event listeners
40+
chatBaseContainer.addEventListener('mouseenter', () => {
41+
chatBaseContainer.style.opacity = '1.0';
42+
debugLog("Chat base container opacity set to 1.0 on hover");
43+
});
44+
45+
chatBaseContainer.addEventListener('mouseleave', () => {
46+
// Start fade out timer
47+
setTimeout(() => {
48+
chatBaseContainer.style.opacity = sleekChatOpacity;
49+
debugLog(`Chat base container opacity reset to ${sleekChatOpacity} after mouse leave`);
50+
}, game.settings.get("sleek-chat", "messageFadeOutTime") * 1000);
51+
});
52+
53+
debugLog("Chat base container opacity events set up");
54+
} else {
55+
debugLog("Chat base container not found");
56+
}
57+
}
58+
3359
function getResultClass(result, ranges) {
3460
if (result >= ranges[0].min && result <= ranges[0].max) {
3561
return 'fumble';
@@ -59,17 +85,6 @@ export function applySeeOnlyChat(seeOnlyChat) {
5985
Hooks.once("ready", () => {
6086
const seeOnlyChat = game.settings.get("sleek-chat", "seeOnlyChat");
6187
applySeeOnlyChat(seeOnlyChat);
62-
63-
// Set the initial position of the sleek chat container
64-
const sleekChatContainer = document.querySelector('.sleek-chat-container');
65-
if (sleekChatContainer) {
66-
const savedPosition = getDragPosition('sleek-chat');
67-
sleekChatContainer.style.left = savedPosition.left;
68-
sleekChatContainer.style.top = savedPosition.top;
69-
}
70-
71-
// Initialize drag and drop
72-
updateDragAndDropState(game.settings.get("sleek-chat", "enableDragAndDrop"));
7388
});
7489

7590
// Function to apply navigation button hiding based on settings
@@ -126,6 +141,7 @@ export function applyNavButtonHiding() {
126141
// Observe changes in the sidebar state
127142
const observer = new MutationObserver(() => {
128143
updateButtonVisibility();
144+
cleanupSleekChat();
129145
});
130146

131147
observer.observe(document.getElementById('sidebar'), { attributes: true, attributeFilter: ['class'] });
@@ -290,9 +306,10 @@ Hooks.on("renderChatLog", async (app, html, data) => {
290306
const recentMessageContainer = document.querySelector('.recent-message-container');
291307
const navButtonsContainer = document.querySelector('.nav-buttons-container');
292308
const sleekChatContainer = document.querySelector('.sleek-chat-container');
293-
309+
const chatBaseContainer = document.querySelector('.chat-base-container');
310+
294311
debugLog("Sidebar is collapsed:", isCollapsed);
295-
312+
296313
if (toolbar) {
297314
toolbar.style.display = isCollapsed ? 'flex' : 'none';
298315
debugLog("Toolbar visibility set to:", isCollapsed ? 'flex' : 'none');
@@ -308,6 +325,9 @@ Hooks.on("renderChatLog", async (app, html, data) => {
308325
if (sleekChatContainer) {
309326
sleekChatContainer.style.display = isCollapsed ? 'block' : 'none';
310327
}
328+
if (chatBaseContainer && isCollapsed) {
329+
applyChatBaseContainerOpacity();
330+
}
311331
};
312332

313333
updateVisibility();
@@ -486,13 +506,12 @@ Hooks.on('ready', () => {
486506
$('.sleek-chat').css('opacity', sleekChatOpacity);
487507
debugLog("Sleek Chat Opacity set to:", sleekChatOpacity);
488508

509+
applyChatBaseContainerOpacity();
510+
489511
// Apply the dice color filter on startup
490512
const diceColorFilter = game.settings.get("sleek-chat", "diceColorFilter");
491513
applyDiceColorFilter(diceColorFilter);
492514

493-
// Initialize drag and drop
494-
updateDragAndDropState(game.settings.get("sleek-chat", "enableDragAndDrop"));
495-
496515
const hideAdvDisadv = game.settings.get("sleek-chat", "hideAdvDisadv");
497516
if (hideAdvDisadv) {
498517
$('#advantage-toggle').hide();
@@ -518,6 +537,16 @@ Hooks.on('ready', () => {
518537

519538
});
520539

540+
function cleanupSleekChat() {
541+
const existingContainers = document.querySelectorAll('.sleek-chat-container');
542+
if (existingContainers.length > 1) {
543+
// Remove all but the most recently created container
544+
for (let i = 0; i < existingContainers.length - 1; i++) {
545+
existingContainers[i].remove();
546+
}
547+
}
548+
}
549+
521550
// Function to apply dice color filter based on settings
522551
export function applyDiceColorFilter(color) {
523552
let filter;

scripts/recent-message-display.js

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ export class RecentMessageDisplay {
113113

114114
this.updateButtonStates();
115115
}, 5); // 5ms delay to ensure the DOM is updated
116-
}
117-
116+
}
118117

119-
static navigateMessages(direction) {
118+
static navigateMessages(direction) {
120119
debugLog("RecentMessageDisplay: Navigating messages with direction:", direction);
121120
this.currentMessageIndex += direction;
122121
if (this.currentMessageIndex < 0) {
@@ -166,20 +165,58 @@ export class RecentMessageDisplay {
166165
}
167166

168167
static startFadeOutTimer() {
169-
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000; // Convert seconds to milliseconds
168+
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000;
170169
const fadeOutOpacity = game.settings.get("sleek-chat", "messageFadeOutOpacity");
171-
172-
// Log the value of fadeOutTime to the console
170+
const sleekChatOpacity = game.settings.get("sleek-chat", "sleekChatOpacity");
171+
173172
debugLog(`RecentMessageDisplay: Calculated fadeOutTime is ${fadeOutTime} milliseconds.`);
173+
174+
const container = this.recentMessageContainer;
175+
const chatBaseContainer = document.querySelector('.chat-base-container');
176+
177+
// First, wait for the fadeOutTime delay
178+
setTimeout(() => {
179+
debugLog("RecentMessageDisplay: Starting fade out after specified delay.");
180+
181+
// Add the faded class to recent message container
182+
$(container).addClass('faded');
183+
184+
// Apply opacity to chat base container
185+
if (chatBaseContainer && !chatBaseContainer.matches(':hover')) {
186+
chatBaseContainer.style.opacity = sleekChatOpacity;
187+
debugLog(`Chat base container opacity set to ${sleekChatOpacity}`);
188+
}
189+
}, fadeOutTime);
190+
}
174191

175-
const container = this.recentMessageContainer; // Target the container instead of message-display
192+
static setupHoverEffect() {
193+
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000;
194+
const container = this.recentMessageContainer;
176195

177-
// First, wait for the fadeOutTime delay
196+
// Mouse enter: instantly restore full opacity by removing the faded class
197+
container.addEventListener('mouseover', () => {
198+
$(container).removeClass('faded');
199+
debugLog("RecentMessageDisplay: Mouse over - container opacity restored.");
200+
});
201+
202+
// Mouse leave: start the fade-out after the specified delay
203+
container.addEventListener('mouseleave', () => {
204+
setTimeout(() => {
205+
$(container).addClass('faded');
206+
debugLog("RecentMessageDisplay: Mouse leave - reapplied fade effect to container.");
207+
}, fadeOutTime);
208+
});
209+
}
210+
211+
static applyFadeOutEffect(element) {
212+
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000;
213+
214+
// Start the fade-out effect after the specified delay
178215
setTimeout(() => {
179216
debugLog("RecentMessageDisplay: Starting fade out after specified delay.");
180-
$(container).fadeTo(1000, fadeOutOpacity); // 1 second fade-out
217+
$(element).addClass('faded');
181218
}, fadeOutTime);
182-
}
219+
}
183220

184221
static setupHoverEffect() {
185222
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000;
@@ -291,26 +328,6 @@ export class RecentMessageDisplay {
291328
// Update the state of navigation buttons
292329
this.updateButtonStates();
293330
}
294-
295-
static applyFadeOutEffect(element) {
296-
const fadeOutTime = game.settings.get("sleek-chat", "messageFadeOutTime") * 1000; // Convert to milliseconds
297-
const fadeOutOpacity = game.settings.get("sleek-chat", "messageFadeOutOpacity");
298-
299-
// Start the fade-out effect after the specified delay
300-
setTimeout(() => {
301-
debugLog("RecentMessageDisplay: Starting fade out after specified delay.");
302-
$(element).fadeTo(1000, fadeOutOpacity); // 1 second fade-out
303-
}, fadeOutTime);
304-
}
305-
306-
static applyMessageFadeOutSettings() {
307-
debugLog("RecentMessageDisplay: Applying message fade out settings.");
308-
const messageElements = document.querySelectorAll('.recent-message');
309-
messageElements.forEach(element => {
310-
// Reapply the fade-out effect with updated settings
311-
RecentMessageDisplay.applyFadeOutEffect(element);
312-
});
313-
}
314331
}
315332

316333
// Export the function correctly

0 commit comments

Comments
 (0)