Skip to content

Commit

Permalink
Add GM welcome message when installing or updating module (#196)
Browse files Browse the repository at this point in the history
* Show welcome and feedback message to GM users
* Add localization for welcome message
  • Loading branch information
Jagusti authored Oct 11, 2022
1 parent a1981c7 commit 0fb9012
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ See [Issue Backlog](../../issues) and [Roadmap](../../milestones).
* *Added* Polish localization. Thanks [@twisniowski](https://github.com/twisniowski) and [@silentmark](https://github.com/silentmark)! [#188](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/188)
* *Fixed* error when applying damage or making ranged attacks outside of combat when using group advantage. Thanks [@silentmark](https://github.com/silentmark)! [`a186651`](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/188/commits/a186651)
* *Added* version and download stat shields to README, to make it easy to see key install data for users and repo owners. [#190](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/190)
* *Fixed* module setting for Spectator notifications to *not* be suppressed by default. Unassigned characters are still being overlooked when experiencing issues with some macros that require an assigned actor. [#192](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/192)
* *Fixed* module setting for Spectator notifications to *not* be suppressed by default. Unassigned characters were still being overlooked when experiencing issues with some macros that require an assigned actor. [#192](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/192)
* *Fixed* issue where the Add Advantage macro be capped when using Group Advantage. [#194](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/issues/194)
* *Added* welcome message and invitation to feedback that is shown to GMs when updating or first installing the module. The message is saved in the chat log and confirms the installed version, links to release notes and provides quick access buttons to update macro and table content. [#196](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/pull/196)

## [Version 6.0.0](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/releases/tag/6.0.0) (2022-09-06)
- *Changed* Group Test setup form to clear or restore custom skill field if a skill is chosen from the skill list dropdown. [#160](https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/issues/160)
Expand Down
10 changes: 8 additions & 2 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@

"GMTOOLKIT.Damage.Dialog.Title" : "Damage Console",
"GMTOOLKIT.Damage.Message.Abort" : "Damage Console closed. No harm inflicted.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to ${character}.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to {character}.",
"GMTOOLKIT.Damage.Message.At0Wounds" : "At 0 Wounds",
"GMTOOLKIT.Damage.Dialog.SetDamageCriteria" : "Set Damage Criteria",
"GMTOOLKIT.Damage.Dialog.DamageFormula.Label" : "Damage",
Expand All @@ -306,6 +306,12 @@
"ROLL.AstoundingFailure" : "Erstaunliches Scheitern. 'Auf keinen Fall!'",
"ROLL.ImpressiveFailure" : "Beeindruckendes Scheitern. 'Nein, und ...'",
"ROLL.Failure" : "Failure. 'Nein'",
"ROLL.MarginalFailure" : "Knappes Scheitern. 'Nein, aber ...'"
"ROLL.MarginalFailure" : "Knappes Scheitern. 'Nein, aber ...'",

"GMTOOLKIT.Message.Welcome.VersionIsActive" : "GM Toolkit v{version} is active.",
"GMTOOLKIT.Message.Welcome.ReleaseNotes" : "Release Notes",
"GMTOOLKIT.Message.Welcome.ContentUpdateWarning" : "Updating macros or tables will delete existing GM Toolkit content. Any customizations will be lost if not saved under a different name.",
"GMTOOLKIT.Message.Welcome.UpdateMacros" : "Update Macros",
"GMTOOLKIT.Message.Welcome.UpdateTables" : "Update Tables"

}
10 changes: 8 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@

"GMTOOLKIT.Damage.Dialog.Title" : "Damage Console",
"GMTOOLKIT.Damage.Message.Abort" : "Damage Console closed. No harm inflicted.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to ${character}.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to {character}.",
"GMTOOLKIT.Damage.Message.At0Wounds" : "At 0 Wounds",
"GMTOOLKIT.Damage.Dialog.SetDamageCriteria" : "Set Damage Criteria",
"GMTOOLKIT.Damage.Dialog.DamageFormula.Label" : "Damage",
Expand All @@ -306,6 +306,12 @@
"ROLL.AstoundingFailure" : "Astounding Failure. 'Not in any way!'",
"ROLL.ImpressiveFailure" : "Impressive Failure. 'No, and ...'",
"ROLL.Failure" : "Failure. 'No'",
"ROLL.MarginalFailure" : "Marginal Failure. 'No, but ...'"
"ROLL.MarginalFailure" : "Marginal Failure. 'No, but ...'",

"GMTOOLKIT.Message.Welcome.VersionIsActive" : "GM Toolkit v{version} is active.",
"GMTOOLKIT.Message.Welcome.ReleaseNotes" : "Release Notes",
"GMTOOLKIT.Message.Welcome.ContentUpdateWarning" : "Updating macros or tables will delete existing GM Toolkit content. Any customizations will be lost if not saved under a different name.",
"GMTOOLKIT.Message.Welcome.UpdateMacros" : "Update Macros",
"GMTOOLKIT.Message.Welcome.UpdateTables" : "Update Tables"

}
10 changes: 8 additions & 2 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@

"GMTOOLKIT.Damage.Dialog.Title" : "Damage Console",
"GMTOOLKIT.Damage.Message.Abort" : "Damage Console closed. No harm inflicted.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to ${character}.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to {character}.",
"GMTOOLKIT.Damage.Message.At0Wounds" : "At 0 Wounds",
"GMTOOLKIT.Damage.Dialog.SetDamageCriteria" : "Set Damage Criteria",
"GMTOOLKIT.Damage.Dialog.DamageFormula.Label" : "Damage",
Expand All @@ -306,6 +306,12 @@
"ROLL.AstoundingFailure" : "Échec Stupéfiant. \"En aucun cas !\"",
"ROLL.ImpressiveFailure" : "Échec Impressionnant. \"Non, et...\"",
"ROLL.Failure" : "Échec. \"Non.\"",
"ROLL.MarginalFailure" : "Échec Négligeable. \"Non, mais...\""
"ROLL.MarginalFailure" : "Échec Négligeable. \"Non, mais...\"",

"GMTOOLKIT.Message.Welcome.VersionIsActive" : "GM Toolkit v{version} is active.",
"GMTOOLKIT.Message.Welcome.ReleaseNotes" : "Release Notes",
"GMTOOLKIT.Message.Welcome.ContentUpdateWarning" : "Updating macros or tables will delete existing GM Toolkit content. Any customizations will be lost if not saved under a different name.",
"GMTOOLKIT.Message.Welcome.UpdateMacros" : "Update Macros",
"GMTOOLKIT.Message.Welcome.UpdateTables" : "Update Tables"

}
10 changes: 8 additions & 2 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@

"GMTOOLKIT.Damage.Dialog.Title" : "Damage Console",
"GMTOOLKIT.Damage.Message.Abort" : "Damage Console closed. No harm inflicted.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to ${character}.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage" : "Cannot apply damage to {character}.",
"GMTOOLKIT.Damage.Message.At0Wounds" : "At 0 Wounds",
"GMTOOLKIT.Damage.Dialog.SetDamageCriteria" : "Set Damage Criteria",
"GMTOOLKIT.Damage.Dialog.DamageFormula.Label" : "Damage",
Expand All @@ -306,6 +306,12 @@
"ROLL.AstoundingFailure" : "小失敗。「ノー。いや……」",
"ROLL.ImpressiveFailure" : "失敗。「ノー」",
"ROLL.Failure" : "大失敗。「ノー。しくじったな……」",
"ROLL.MarginalFailure" : "超大失敗。「ノー。かすりもしねえ!」"
"ROLL.MarginalFailure" : "超大失敗。「ノー。かすりもしねえ!」",

"GMTOOLKIT.Message.Welcome.VersionIsActive" : "GM Toolkit v{version} is active.",
"GMTOOLKIT.Message.Welcome.ReleaseNotes" : "Release Notes",
"GMTOOLKIT.Message.Welcome.ContentUpdateWarning" : "Updating macros or tables will delete existing GM Toolkit content. Any customizations will be lost if not saved under a different name.",
"GMTOOLKIT.Message.Welcome.UpdateMacros" : "Update Macros",
"GMTOOLKIT.Message.Welcome.UpdateTables" : "Update Tables"

}
10 changes: 8 additions & 2 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@

"GMTOOLKIT.Damage.Dialog.Title": "Konsola Obrażeń",
"GMTOOLKIT.Damage.Message.Abort": "Zamknięto Konsole Obrażeń. Żadna krzywda nie została wyrządzona.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage": "Nie można przypisać obrażeń do ${character}.",
"GMTOOLKIT.Damage.Message.CannotApplyDamage": "Nie można przypisać obrażeń do {character}.",
"GMTOOLKIT.Damage.Message.At0Wounds": "Ma 0 Żywotności",
"GMTOOLKIT.Damage.Dialog.SetDamageCriteria": "Ustaw Kryteria Obrażeń",
"GMTOOLKIT.Damage.Dialog.DamageFormula.Label": "Obrażenia",
Expand All @@ -306,6 +306,12 @@
"ROLL.AstoundingFailure": "Zdumiewająca Porażka. 'Nie, nie ma mowy!'",
"ROLL.ImpressiveFailure": "Krytyczna Porażka. 'Nie, i...'",
"ROLL.Failure": "Porażka. 'Nie.'",
"ROLL.MarginalFailure": "Znikoma Porażka. 'Nie, ale...'"
"ROLL.MarginalFailure": "Znikoma Porażka. 'Nie, ale...'",

"GMTOOLKIT.Message.Welcome.VersionIsActive" : "GM Toolkit v{version} is active.",
"GMTOOLKIT.Message.Welcome.ReleaseNotes" : "Release Notes",
"GMTOOLKIT.Message.Welcome.ContentUpdateWarning" : "Updating macros or tables will delete existing GM Toolkit content. Any customizations will be lost if not saved under a different name.",
"GMTOOLKIT.Message.Welcome.UpdateMacros" : "Update Macros",
"GMTOOLKIT.Message.Welcome.UpdateTables" : "Update Tables"

}
64 changes: 64 additions & 0 deletions modules/welcome.mjs
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)
})
15 changes: 15 additions & 0 deletions templates/welcomeMessage.hbs
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>
5 changes: 4 additions & 1 deletion wfrp4e-gm-toolkit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { GroupTest } from "./apps/group-test.js"
import DarkWhispers from "./modules/dark-whispers.mjs"
import TokenHudExtension from "./modules/token-hud-extension.mjs"
import { DamageConsole } from "./apps/damage.js"
import { GMToolkitWelcome } from "./modules/welcome.mjs"


/* -------------------------------------------- */
Expand Down Expand Up @@ -82,6 +83,8 @@ Hooks.once("ready", async function () {
}
})

GMToolkitWelcome._welcomeMessage()

})

Hooks.on("ready", async () => {
Expand Down Expand Up @@ -124,7 +127,7 @@ Hooks.once("babele.ready", async function () {
})

/* -------------------------------------------- */
/* Socket Handlers */
/* Socket Handlers */
/* -------------------------------------------- */

export class SocketHandlers {
Expand Down

0 comments on commit 0fb9012

Please sign in to comment.