-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GM welcome message when installing or updating module (#196)
* Show welcome and feedback message to GM users * Add localization for welcome message
- Loading branch information
Showing
9 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
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
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
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,64 @@ | ||
// Import Helpers | ||
import GMToolkit from "./gm-toolkit.mjs" | ||
import { refreshToolkitContent } from "./utility.mjs" | ||
|
||
export class GMToolkitWelcome { | ||
|
||
/** | ||
* Click on buttons to update Toolkit content | ||
* @param {html} html | ||
*/ | ||
static async chatListeners (html) { | ||
html.on("click", ".updateToolkitContent-button", event => { | ||
event.preventDefault() | ||
if (!game.user.isGM) return | ||
|
||
switch ($(event.currentTarget).attr("data-button")) { | ||
case "updateMacros": | ||
refreshToolkitContent("Macro") | ||
break | ||
case "updateTables": | ||
refreshToolkitContent("RollTable") | ||
break | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* Shows a welcome message to GM users. | ||
* Sets a message version flag on the user to prevent message repeats. | ||
*/ | ||
static _welcomeMessage () { | ||
if (!game.user.isGM) return | ||
|
||
const currentVersion = game.modules.get(GMToolkit.MODULE_ID).version | ||
const messageVersion = game.user.getFlag(GMToolkit.MODULE_ID, "welcomeMessageShown") | ||
|
||
if (messageVersion !== undefined | ||
&& !isNewerVersion(currentVersion, messageVersion)) return | ||
|
||
const templateData = { | ||
version: currentVersion, | ||
releases: game.modules.get(GMToolkit.MODULE_ID).changelog | ||
} | ||
|
||
renderTemplate("modules/wfrp4e-gm-toolkit/templates/welcomeMessage.hbs", templateData).then(html => { | ||
let options = { | ||
whisper: [game.user.id], | ||
speaker: { alias: GMToolkit.MODULE_NAME }, | ||
flags: { core: { canPopout: true } }, | ||
content: html | ||
} | ||
ChatMessage.create(options) | ||
}) | ||
|
||
game.user.setFlag(GMToolkit.MODULE_ID, "welcomeMessageShown", currentVersion) | ||
} | ||
} | ||
|
||
|
||
// ---- Set up Hooks ---- | ||
// Activate chat listeners | ||
Hooks.on("renderChatLog", (log, html, data) => { | ||
GMToolkitWelcome.chatListeners(html) | ||
}) |
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,15 @@ | ||
<h3 class="nue">{{ localize "GMTOOLKIT.Message.Welcome.VersionIsActive" version=this.version }}</h3> | ||
|
||
<span class="chat-card-button-area"> | ||
<a class="chat-card-button updateToolkitContent-button" data-button="updateMacros">{{ localize "GMTOOLKIT.Message.Welcome.UpdateMacros" }}</a> | ||
<a class="chat-card-button updateToolkitContent-button" data-button="updateTables">{{ localize "GMTOOLKIT.Message.Welcome.UpdateTables" }}</a> | ||
</span> | ||
|
||
<p>The next significant release of GM Toolkit will focus on light and vision.</p> | ||
|
||
<p>I'd particularly like to get feedback from module users to enhance the @UUID[Compendium.wfrp4e-gm-toolkit.gm-toolkit-macros.DGYdRmtbMZ81NmQ3]{Set Token Vision and Light} macro.</p> | ||
|
||
<p>Please <a href="https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/discussions/193">share ideas or opinions here</a> if you'd like to help.</p> | ||
|
||
<footer class="nue"> | ||
{{localize "GMTOOLKIT.Message.Welcome.ReleaseNotes"}}: <a href="{{{this.releases}}}/{{this.version}}">v{{this.version}}</a>. {{localize "GMTOOLKIT.Message.Welcome.ContentUpdateWarning"}}</footer> |
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