-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
646931a
commit 34e4e78
Showing
16 changed files
with
357 additions
and
135 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { SETTINGS } from "../settings"; | ||
import { CONSTANTS } from "../shared/constants"; | ||
|
||
/** | ||
* Abstract feature | ||
*/ | ||
export default class BaseFeature { | ||
/** | ||
* @param {string} hookName hook to fire | ||
*/ | ||
hookName = ""; | ||
|
||
/** | ||
* @param {null|boolean} byPassSetting if the setting check should be bypass | ||
*/ | ||
byPassSetting = null; | ||
|
||
/** | ||
* @param {string} settingName the setting to check before firing the feature | ||
*/ | ||
settingName = ""; | ||
|
||
/** | ||
* On hook firing | ||
*/ | ||
onHook() { | ||
// Hook definition must be provide by the class | ||
if (!this.hookName) { | ||
throw new Error("Missing hook definition"); | ||
} | ||
|
||
Hooks.once(this.hookName, this.handle.bind(this)); | ||
} | ||
|
||
/** | ||
* Handle the firing of the feature | ||
*/ | ||
handle() { | ||
// Check setting | ||
this.setting = | ||
this.byPassSetting ?? game.settings.get(CONSTANTS.MODULE_NAME, SETTINGS[this.settingName]); | ||
|
||
if (!this.setting) return; | ||
|
||
// Fire feature | ||
this.fireFeature(); | ||
} | ||
|
||
/** | ||
* Feature will be fired if setting is truthy or bypassed | ||
*/ | ||
fireFeature() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Applies blur effects | ||
*/ | ||
export class BlurInterface extends BaseFeature { | ||
/** @override */ | ||
settingName = "ENABLE_BLUR"; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
document.body.classList.add("shouldBlur"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { CONSTANTS } from "../shared/constants"; | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Create a warning message for blurred content | ||
*/ | ||
export class BlurWarningMessage extends BaseFeature { | ||
/** @override */ | ||
byPassSetting = true; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
// Listener | ||
document.body.addEventListener("click", async (event) => { | ||
if ( | ||
event.target.classList.contains("glass-theme-blur-message") || | ||
event.target.parentNode.classList.contains("glass-theme-blur-message") | ||
) { | ||
new SettingsConfig().render(true); | ||
await new Promise((r) => setTimeout(r, 100)).then(() => | ||
ui.activeWindow.activateTab(CONSTANTS.MODULE_NAME) | ||
); | ||
} | ||
}); | ||
|
||
// Chat message | ||
if (!game.user.getFlag(CONSTANTS.MODULE_NAME, "blurWarningMessageShown")) { | ||
const content = [ | ||
` | ||
<div> | ||
<h3>Theme: Glass</h3> | ||
<p>${game.i18n.localize(`${CONSTANTS.MODULE_NAME}.blurWarningMessage`)}</p> | ||
<p> | ||
<button type="button" class="glass-theme-blur-message" data-key="theme-glass.enable-blur"> | ||
<i class="fas fa-cogs"></i> ${game.i18n.localize("SETTINGS.Configure")} | ||
</button> | ||
</p> | ||
</div> | ||
` | ||
]; | ||
|
||
const chatData = content.map((c) => { | ||
return { | ||
whisper: [game.user.id], | ||
speaker: { alias: "Theme: Glass" }, | ||
flags: { core: { canPopout: true } }, | ||
content: c | ||
}; | ||
}); | ||
|
||
ChatMessage.implementation.createDocuments(chatData); | ||
|
||
game.user.setFlag(CONSTANTS.MODULE_NAME, "blurWarningMessageShown", true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { SETTINGS } from "../settings"; | ||
import { CONSTANTS } from "../shared/constants"; | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Applies a chat opacity | ||
*/ | ||
export class ChatOpacity extends BaseFeature { | ||
/** @override */ | ||
settingName = "CHAT_OPACITY"; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
document.body.classList.add("addChatOpacity"); | ||
document.documentElement.style.setProperty( | ||
"--chat-opactity-value", | ||
game.settings.get(CONSTANTS.MODULE_NAME, SETTINGS.CHAT_OPACITY_VALUE) | ||
); | ||
|
||
// Handle old chat cards | ||
document | ||
.querySelectorAll("#chat-log li.chat-message") | ||
.forEach((e) => e.classList.add("opacity-transition")); | ||
|
||
// Handle newly created chat cards | ||
this.handleNewChatCards(); | ||
} | ||
|
||
/** | ||
* Handle the opacity of a newly created chat cards | ||
*/ | ||
handleNewChatCards() { | ||
Hooks.on("renderChatMessage", async (message, html) => { | ||
html[0].classList.add("opacity-delay"); | ||
|
||
const timer = game.settings.get(CONSTANTS.MODULE_NAME, SETTINGS.CHAT_OPACITY_TIMER) * 1000; | ||
await new Promise((r) => setTimeout(r, timer)).then(() => { | ||
html[0].classList.add("opacity-transition"); | ||
html[0].classList.remove("opacity-delay"); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Collapses macro hotbar | ||
*/ | ||
export class CollapseHotbar extends BaseFeature { | ||
/** @override */ | ||
settingName = "COLLAPSE_HOTBAR"; | ||
|
||
/** @override */ | ||
hookName = "renderHotbar"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
ui.hotbar.collapse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Hides the fvtt logo | ||
*/ | ||
export class HideLogo extends BaseFeature { | ||
/** @override */ | ||
settingName = "HIDE_LOGO"; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
document.body.classList.add("hideLogo"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Reduces scenes height | ||
*/ | ||
export class ReduceScenesHeight extends BaseFeature { | ||
/** @override */ | ||
settingName = "REDUCE_SCENE_LIST"; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
document.body.classList.add("changeScenesHeight"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import BaseFeature from "./BaseFeature"; | ||
|
||
/** | ||
* Removes pause | ||
*/ | ||
export class RemovePause extends BaseFeature { | ||
/** @override */ | ||
settingName = "NO_PAUSE"; | ||
|
||
/** @override */ | ||
hookName = "ready"; | ||
|
||
/** @override */ | ||
fireFeature() { | ||
if (game.users.current.isGM && game.paused) { | ||
game.togglePause(false, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from "./BlurInterface.js"; | ||
export * from "./BlurWarningMessage.js"; | ||
export * from "./ChatOpacity.js"; | ||
export * from "./CollapseHotbar.js"; | ||
export * from "./HideLogo.js"; | ||
export * from "./ReduceScenesHeight.js"; | ||
export * from "./RemovePause.js"; |
Oops, something went wrong.