From 3ef511f4e4ddc64d998acd2b59f12aa11fb474f2 Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Mon, 5 Feb 2024 20:02:19 +1030 Subject: [PATCH 1/7] feat(titleCards): first pass working title cards --- ffg-star-wars-enhancements.js | 3 + release-notes.md | 1 + scripts/controls_layer.js | 10 + scripts/title_cards.js | 343 ++++++++++++++++++++++++++++++ templates/title_cards.html | 109 ++++++++++ templates/title_cards_dialog.html | 7 + 6 files changed, 473 insertions(+) create mode 100644 scripts/title_cards.js create mode 100644 templates/title_cards.html create mode 100644 templates/title_cards_dialog.html diff --git a/ffg-star-wars-enhancements.js b/ffg-star-wars-enhancements.js index 2ffe25e..f9c7b9f 100644 --- a/ffg-star-wars-enhancements.js +++ b/ffg-star-wars-enhancements.js @@ -2,6 +2,7 @@ import { init as settings_init } from "./scripts/settings.js"; import { FfgEnhancementsLayer, log_msg as log } from "./scripts/util.js"; import { init as attack_animation_init, attack_animation_check, attack_animation } from "./scripts/animation.js"; import { init as opening_crawl_init, ready as opening_crawl_ready } from "./scripts/opening_crawl.js"; +import { init as title_cards_init, ready as title_cards_ready } from "./scripts/title_cards.js"; import { init as hyperspace_init, ready as hyperspace_ready } from "./scripts/hyperspace.js"; import { init as rename_init, rename_combatant } from "./scripts/rename.js"; import { @@ -29,6 +30,7 @@ Hooks.once("init", async function () { strain_reminder_init(); talent_checker_init(); opening_crawl_init(); + title_cards_init(); shop_generator_init(); hyperspace_init(); quench_tests_init(); // Will have no effect unless Quench is active @@ -99,6 +101,7 @@ Hooks.once("ready", () => { /* register functionality here */ attack_animation_check(); opening_crawl_ready(); + title_cards_ready(); shop_sheet_ready(); dice_helper(); talent_checker(); diff --git a/release-notes.md b/release-notes.md index b133a5d..1af7e45 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,3 +1,4 @@ +- IMPROVEMENT: Opening crawl timing can be configured in the settings - FIX: Module settings popup windows titles corrected `2.0.5` - 2023-12-29 diff --git a/scripts/controls_layer.js b/scripts/controls_layer.js index 5547354..9ecb9dc 100644 --- a/scripts/controls_layer.js +++ b/scripts/controls_layer.js @@ -1,4 +1,5 @@ import { select_opening_crawl } from "./opening_crawl.js"; +import { title_cards_dialog } from "./title_cards.js"; import { select_hyperspace } from "./hyperspace.js"; import { create_datapad_journal } from "./datapads.js"; import { shop_creator } from "./shop.js"; @@ -25,6 +26,15 @@ export const register_controls = (controls) => { select_opening_crawl(); }, }, + { + name: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.name"), + title: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.title"), + icon: "fas fa-book", + button: true, + onClick: () => { + title_cards_dialog(); + }, + }, { name: game.i18n.localize("ffg-star-wars-enhancements.controls.new-journal-template.name"), title: game.i18n.localize("ffg-star-wars-enhancements.controls.new-journal-template.title"), diff --git a/scripts/title_cards.js b/scripts/title_cards.js new file mode 100644 index 0000000..ff33755 --- /dev/null +++ b/scripts/title_cards.js @@ -0,0 +1,343 @@ +import { log_msg as log } from "./util.js"; + + + +export function title_cards_dialog() { + new Dialog({ + title: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.title"), + content:` +
+
+

+ + +

+

+ + +

+
+
`, + buttons:{ + yes: { + icon: "", + label: `Launch Title Cards` + }}, + default:'yes', + close: html => { + let data = { + toptext: html.find('input[name=\'toptext\']').val(), + bottomtext: html.find('input[name=\'bottomtext\']').val() + } + launch_title_cards(data); + } + }).render(true); +} + + +/** + * Launch the title cards. + * @param {object} data + */ +export function launch_title_cards(data) { + log("title-cards", "launching"); + + data = mergeObject(data, { + type: "title-cards", + logo: game.settings.get("ffg-star-wars-enhancements", "opening-crawl-logo"), + music: game.settings.get("ffg-star-wars-enhancements", "title-cards-music"), + }); + game.socket.emit("module.ffg-star-wars-enhancements", data); + socket_listener(data); + log("title-cards", "event emmitted"); +} + + +/** + * Register settings used by title cards + */ +export function init() { + log("title-cards", "Initializing"); + game.settings.registerMenu("ffg-star-wars-enhancements", "title-cards_UISettings", { + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.ui.name"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.ui.hint"), + label: game.i18n.localize("ffg-star-wars-enhancements.title-cards.ui.label"), + icon: "fas fa-cut", + type: title_cards_UISettings, + restricted: true, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-music", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music"), + hint: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-hint"), + scope: "world", + config: false, + type: String, + filePicker: "audio", + default: "", + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-music-delay", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-delay"), + hint: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-delay-hint"), + scope: "world", + config: false, + type: Number, + default: 0.0, + }); + log("title-cards", "Initialized"); +} + +/** + * Ready handler that listens on the ffg-star-wars-enhancements socket. + */ +export function ready() { + log("title-cards", "ready"); + game.socket.on("module.ffg-star-wars-enhancements", socket_listener); +} + +/** + * Listener for the ffg-star-wars-enhancements socket that launches the + * TitleCardsApplication if the message type is "title-cards" + * + * @param {object} data object passed to TitleCardsApplication + */ +function socket_listener(data) { + log("socket", data); + if (data.type == "title-cards") { + new TitleCardsApplication(data).render(true); + } +} + +/** + * Helper function to delay code execution by an arbitrary amount + * @param ms - number of MS to delay by + * @returns {Promise} + */ +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +/** + * Application that displays the Opening Crawl. + */ +class TitleCardsApplication extends Application { + /** + * @param {object} data object to provide the opening crawl template + * @param {object} options additional options for the application + */ + constructor(data, options) { + super({}, options); + this.data = data; + } + + /** + * Configure a "full" screen with minimal controls that will display the + * Opening Crawl. + */ + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + template: "modules/ffg-star-wars-enhancements/templates/title_cards.html", + id: "ffg-star-wars-enhancements-title-cards", + title: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title"), + minimizable: false, + editable: false, + resizable: true, + popOut: true, + shareable: false, + top: 0, + left: 0, + width: 4096, + height: 2160, + }); + } + + /** + * Provide the data object for the template. + * @returns object provided to the constructor + */ + getData() { + let data = this.data; + data.img = {}; + data.img.bottom = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-image-bottom"); + data.img.right = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-image-right"); + data.size = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-font-size"); + return data; + } + + /** + * Play this.data.music using the Playlist volume. + * @param {function} callback callback to execute once playback has started + */ + async play_music(callback) { + let volume = game.settings.get("core", "globalPlaylistVolume"); + let audio_helper = game.audio; + const that = this; + + audio_helper.preload(this.data.music).then(async (sound) => { + callback(); + await sleep(game.settings.get("ffg-star-wars-enhancements", "title-cards-music-delay")); + sound.play({ + volume: volume, + }); + that.sound = sound; + }); + } + + /** + * Listener that times the audio playing the audio with the opening crawl. + * @param {jQuery} html + */ + activateListeners(html) { + log("opening-crawl", "active listeners"); + super.activateListeners(html); + + // When music is configured, hide the HTML until the audio loaded is + // loaded. Once it's loaded, redisplay the HTML to retrigger the + // animation. + if (this.data.music) { + function start_animation() { + html[0].style.display = "block"; + } + + html[0].style.display = "none"; + + this.play_music(start_animation); + } + } + + close() { + if (this.sound) { + this.sound.stop(); + this.sound = null; + } + return super.close(); + } +} + +// noinspection DuplicatedCode +class title_cards_UISettings extends FormApplication { + /** @override */ + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + id: "data-importer", + classes: ["starwarsffg", "data-import"], + title: `${game.i18n.localize("ffg-star-wars-enhancements.title-cards.ui.name")}`, + template: "modules/ffg-star-wars-enhancements/templates/settings.html", + }); + } + + // noinspection JSDeprecatedSymbols + getData(options) { + const gs = game.settings; + const canConfigure = game.user.can("SETTINGS_MODIFY"); + + const data = { + system: { title: game.system.title, menus: [], settings: [] }, + }; + + // Classify all settings + // noinspection JSUnusedLocalSymbols + for (let setting of gs.settings.values()) { + // Exclude settings the user cannot change + if (!setting.key.includes("title-cards-") || (!canConfigure && setting.scope !== "client")) continue; + + // Update setting data + const s = duplicate(setting); + s.name = game.i18n.localize(s.name); + s.hint = game.i18n.localize(s.hint); + s.value = game.settings.get(s.module, s.key); + s.type = setting.type instanceof Function ? setting.type.name : "String"; + s.isCheckbox = setting.type === Boolean; + s.isSelect = s.choices !== undefined; + s.isRange = setting.type === Number && s.range; + s.isFilePicker = setting.valueType === "FilePicker"; + + // Classify setting + const name = s.module; + if (s.key.includes("title-cards-")) data.system.settings.push(s); + } + + // Return data + return { + user: game.user, + canConfigure: canConfigure, + systemTitle: game.system.title, + data: data, + }; + } + + activateListeners(html) { + super.activateListeners(html); + html.find(".submenu button").click(this._onClickSubmenu.bind(this)); + html.find('button[name="reset"]').click(this._onResetDefaults.bind(this)); + html.find("button.filepicker").click(this._onFilePicker.bind(this)); + } + + /** + * Handle activating the button to configure User Role permissions + * @param event {Event} The initial button click event + * @private + */ + _onClickSubmenu(event) { + event.preventDefault(); + const menu = game.settings.menus.get(event.currentTarget.dataset.key); + if (!menu) return ui.notifications.error("No submenu found for the provided key"); + const app = new menu.type(); + return app.render(true); + } + + /* -------------------------------------------- */ + + /** + * Handle button click to reset default settings + * @param event {Event} The initial button click event + * @private + */ + _onResetDefaults(event) { + event.preventDefault(); + const button = event.currentTarget; + const form = button.form; + for (let [k, v] of game.settings.settings.entries()) { + if (!v.config) { + let input = form[k]; + if (input && input.type === "checkbox") { + input.checked = v.default; + } else if (input) { + input.value = v.default; + } + } + } + } + + /* -------------------------------------------- */ + + _onFilePicker(event) { + event.preventDefault(); + + const fp = new FilePicker({ + type: "image", + callback: (path) => { + $(event.currentTarget).prev().val(path); + //this._onSubmit(event); + }, + top: this.position.top + 40, + left: this.position.left + 10, + }); + return fp.browse(); + } + + /* -------------------------------------------- */ + + // noinspection JSUnusedGlobalSymbols + /** @override */ + async _updateObject(event, formData) { + for (let [k, v] of Object.entries(flattenObject(formData))) { + let s = game.settings.settings.get(k); + let current = game.settings.get(s.module, s.key); + if (v !== current) { + await game.settings.set(s.module, s.key, v); + } + } + } +} \ No newline at end of file diff --git a/templates/title_cards.html b/templates/title_cards.html new file mode 100644 index 0000000..c8dca84 --- /dev/null +++ b/templates/title_cards.html @@ -0,0 +1,109 @@ +
+ + +
+
{{toptext}}
+
{{bottomtext}}
+
+ +
+ + + + \ No newline at end of file diff --git a/templates/title_cards_dialog.html b/templates/title_cards_dialog.html new file mode 100644 index 0000000..a5c9f9d --- /dev/null +++ b/templates/title_cards_dialog.html @@ -0,0 +1,7 @@ +
+
+
+
+ + +
\ No newline at end of file From ecda493bc5c863823877e9cb12bf5874759beaa8 Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Mon, 5 Feb 2024 21:33:09 +1030 Subject: [PATCH 2/7] feat(titleCards): configurable title cards durations, auto-close, en loc --- lang/en.json | 27 ++++++++- scripts/title_cards.js | 112 +++++++++++++++++++++++++++++++++---- templates/title_cards.html | 8 +-- 3 files changed, 130 insertions(+), 17 deletions(-) diff --git a/lang/en.json b/lang/en.json index 67be758..64d5e89 100644 --- a/lang/en.json +++ b/lang/en.json @@ -195,5 +195,30 @@ "ffg-star-wars-enhancements.minionsize-sync-status-zero": "Minion Status at zero", "ffg-star-wars-enhancements.minionsize-sync-status-zero-hint": "Will be applied when zero minion member", "ffg-star-wars-enhancements.controls.holo.name": "Convert to Hologram2", - "ffg-star-wars-enhancements.controls.holo.title": "Toggle Hologram conversion" + "ffg-star-wars-enhancements.controls.holo.title": "Toggle Hologram conversion", + "ffg-star-wars-enhancements.controls.title-cards.title": "Title Cards", + "ffg-star-wars-enhancements.controls.title-cards.toptext-label": "Top Text", + "ffg-star-wars-enhancements.controls.title-cards.bottomtext-label": "Bottom Text", + "ffg-star-wars-enhancements.title-cards.ui.name": "Title Cards settings", + "ffg-star-wars-enhancements.title-cards.ui.hint": "Configure Title Cards", + "ffg-star-wars-enhancements.title-cards.ui.label": "Open Configuration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo": "Title Cards Logo", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-hint": "Logo to display first", + "ffg-star-wars-enhancements.title-cards.title-cards-music": "Title Cards music", + "ffg-star-wars-enhancements.title-cards.title-cards-music-hint": "Music to play. Default settings are synced to the Book of Boba Fett intro", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay": "Music start delay", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay-hint": "Delay in seconds until the music starts playing", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size": "Top Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size-hint": "Size of the top text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size": "Bottom Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size-hint": "Size of the bottom text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay": "Logo delay", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay-hint": "Time in seconds until the logo appears", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration": "Logo duration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration-hint": "Time in seconds the logo remains on screen", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay": "Text delay", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay-hint": "Time in seconds until the text appears", + "ffg-star-wars-enhancements.title-cards.title-cards-text-duration": "Text duration", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay": "Window close delay", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay-hint": "Time in seconds since the text disappeared to close the window. If 0, will not close the window" } diff --git a/scripts/title_cards.js b/scripts/title_cards.js index ff33755..02087b1 100644 --- a/scripts/title_cards.js +++ b/scripts/title_cards.js @@ -44,7 +44,7 @@ export function launch_title_cards(data) { data = mergeObject(data, { type: "title-cards", - logo: game.settings.get("ffg-star-wars-enhancements", "opening-crawl-logo"), + logo: game.settings.get("ffg-star-wars-enhancements", "title-cards-logo"), music: game.settings.get("ffg-star-wars-enhancements", "title-cards-music"), }); game.socket.emit("module.ffg-star-wars-enhancements", data); @@ -66,10 +66,20 @@ export function init() { type: title_cards_UISettings, restricted: true, }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-logo", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo-hint"), + scope: "world", + config: false, + type: String, + filePicker: "folder", + default: "", + }); game.settings.register("ffg-star-wars-enhancements", "title-cards-music", { module: "ffg-star-wars-enhancements", - name: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music"), - hint: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-hint"), + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-music"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-music-hint"), scope: "world", config: false, type: String, @@ -78,16 +88,87 @@ export function init() { }); game.settings.register("ffg-star-wars-enhancements", "title-cards-music-delay", { module: "ffg-star-wars-enhancements", - name: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-delay"), - hint: game.i18n.localize("ffg-star-wars-enhancements.opening-crawl.title-cards-music-delay-hint"), + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-music-delay"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-music-delay-hint"), scope: "world", config: false, type: Number, default: 0.0, }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-top-font-size", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-top-font-size"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-top-font-size-hint"), + scope: "world", + config: false, + type: Number, + default: 150, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-bottom-font-size", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size-hint"), + scope: "world", + config: false, + type: Number, + default: 50, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-logo-delay", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo-delay"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo-delay-hint"), + scope: "world", + config: false, + type: Number, + default: 5.7, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-logo-duration", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo-duration"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-logo-duration-hint"), + scope: "world", + config: false, + type: Number, + default: 4.5, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-text-delay", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-text-delay"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-text-delay-hint"), + scope: "world", + config: false, + type: Number, + default: 10.7, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-text-duration", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-text-duration"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-text-duration-hint"), + scope: "world", + config: false, + type: Number, + default: 5, + }); + game.settings.register("ffg-star-wars-enhancements", "title-cards-close-delay", { + module: "ffg-star-wars-enhancements", + name: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-close-delay"), + hint: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title-cards-close-delay-hint"), + scope: "world", + config: false, + type: Number, + default: 1, + }); log("title-cards", "Initialized"); } +function get_total_duration() { + return ( + game.settings.get("ffg-star-wars-enhancements", "title-cards-text-delay") + + game.settings.get("ffg-star-wars-enhancements", "title-cards-text-duration") + + game.settings.get("ffg-star-wars-enhancements", "title-cards-close-delay") + ); +} + /** * Ready handler that listens on the ffg-star-wars-enhancements socket. */ @@ -102,13 +183,18 @@ export function ready() { * * @param {object} data object passed to TitleCardsApplication */ -function socket_listener(data) { +async function socket_listener(data) { log("socket", data); if (data.type == "title-cards") { - new TitleCardsApplication(data).render(true); + let titles = new TitleCardsApplication(data).render(true); + if (game.settings.get("ffg-star-wars-enhancements", "title-cards-close-delay") != 0) { + await sleep(get_total_duration() * 1000); + titles.close(); + } } } + /** * Helper function to delay code execution by an arbitrary amount * @param ms - number of MS to delay by @@ -139,7 +225,7 @@ class TitleCardsApplication extends Application { return mergeObject(super.defaultOptions, { template: "modules/ffg-star-wars-enhancements/templates/title_cards.html", id: "ffg-star-wars-enhancements-title-cards", - title: game.i18n.localize("ffg-star-wars-enhancements.title-cards.title"), + title: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.title"), minimizable: false, editable: false, resizable: true, @@ -158,10 +244,12 @@ class TitleCardsApplication extends Application { */ getData() { let data = this.data; - data.img = {}; - data.img.bottom = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-image-bottom"); - data.img.right = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-image-right"); - data.size = game.settings.get("ffg-star-wars-enhancements", "opening-crawl-font-size"); + data.topSize = game.settings.get("ffg-star-wars-enhancements", "title-cards-top-font-size"); + data.bottomSize = game.settings.get("ffg-star-wars-enhancements", "title-cards-bottom-font-size"); + data.logoDelay = game.settings.get("ffg-star-wars-enhancements", "title-cards-logo-delay"); + data.logoDuration = game.settings.get("ffg-star-wars-enhancements", "title-cards-logo-duration"); + data.textDelay = game.settings.get("ffg-star-wars-enhancements", "title-cards-text-delay"); + data.textDuration = game.settings.get("ffg-star-wars-enhancements", "title-cards-text-duration"); return data; } diff --git a/templates/title_cards.html b/templates/title_cards.html index c8dca84..cb889ea 100644 --- a/templates/title_cards.html +++ b/templates/title_cards.html @@ -30,7 +30,7 @@ width: 50%; height: 50%; opacity: 0; - animation: logoAnimation 4.5s ease-out 5.7s; + animation: logoAnimation {{logoDuration}}s ease-out {{logoDelay}}s; display: flex; justify-content: center; } @@ -65,7 +65,7 @@ width: 100%; height: 50%; opacity: 0; - animation: textFadeAnimation 5s ease-out 10.7s; + animation: textFadeAnimation {{textDuration}}s ease-out {{textDelay}}s; font-family: "News Cycle"; font-weight: bolder; } @@ -79,12 +79,12 @@ } .top-text { - font-size: 150px; + font-size: {{topSize}}px; align-items: flex-end; } .bottom-text { - font-size: 50px; + font-size: {{bottomSize}}px; align-items: flex-start; } From 502ed20fde0500f691cbebc573e0ecde0fb865d7 Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Mon, 5 Feb 2024 21:40:03 +1030 Subject: [PATCH 3/7] fix(titleCards): fix closing title cards dialog launches title cards --- lang/en.json | 1 + scripts/title_cards.js | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lang/en.json b/lang/en.json index 64d5e89..de5f9a4 100644 --- a/lang/en.json +++ b/lang/en.json @@ -199,6 +199,7 @@ "ffg-star-wars-enhancements.controls.title-cards.title": "Title Cards", "ffg-star-wars-enhancements.controls.title-cards.toptext-label": "Top Text", "ffg-star-wars-enhancements.controls.title-cards.bottomtext-label": "Bottom Text", + "ffg-star-wars-enhancements.controls.title-cards.launch": "Launch Title Cards", "ffg-star-wars-enhancements.title-cards.ui.name": "Title Cards settings", "ffg-star-wars-enhancements.title-cards.ui.hint": "Configure Title Cards", "ffg-star-wars-enhancements.title-cards.ui.label": "Open Configuration", diff --git a/scripts/title_cards.js b/scripts/title_cards.js index 02087b1..cf28566 100644 --- a/scripts/title_cards.js +++ b/scripts/title_cards.js @@ -5,7 +5,7 @@ import { log_msg as log } from "./util.js"; export function title_cards_dialog() { new Dialog({ title: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.title"), - content:` + content: `

@@ -18,20 +18,21 @@ export function title_cards_dialog() {

`, - buttons:{ + buttons: { yes: { icon: "", - label: `Launch Title Cards` - }}, - default:'yes', - close: html => { - let data = { - toptext: html.find('input[name=\'toptext\']').val(), - bottomtext: html.find('input[name=\'bottomtext\']').val() + label: `${game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.launch")}`, + callback: html => { + let data = { + toptext: html.find('input[name=\'toptext\']').val(), + bottomtext: html.find('input[name=\'bottomtext\']').val() + } + launch_title_cards(data); + } } - launch_title_cards(data); - } - }).render(true); + }, + default: 'yes' + }).render(true); } From a25d6de11a67a912ff35c88b402e9454b0055efa Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Mon, 5 Feb 2024 21:41:30 +1030 Subject: [PATCH 4/7] feat(titleCards): add french and portuguese fallback text --- lang/fr.json | 28 +++++++++++++++++++++++++++- lang/pt-BR.json | 28 +++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/lang/fr.json b/lang/fr.json index e1ade61..b82589c 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -189,5 +189,31 @@ "ffg-star-wars-enhancements.minionsize-sync-status-zero": "Icône de status de sbires à zéro", "ffg-star-wars-enhancements.minionsize-sync-status-zero-hint": "Sera appliqué pour un groupe de sbire sans membres", "ffg-star-wars-enhancements.controls.holo.name": "Conversion vers Hologram2", - "ffg-star-wars-enhancements.controls.holo.title": "Active/Désactive la conversion en holograme" + "ffg-star-wars-enhancements.controls.holo.title": "Active/Désactive la conversion en holograme", + "ffg-star-wars-enhancements.controls.title-cards.title": "Title Cards", + "ffg-star-wars-enhancements.controls.title-cards.toptext-label": "Top Text", + "ffg-star-wars-enhancements.controls.title-cards.bottomtext-label": "Bottom Text", + "ffg-star-wars-enhancements.controls.title-cards.launch": "Launch Title Cards", + "ffg-star-wars-enhancements.title-cards.ui.name": "Title Cards settings", + "ffg-star-wars-enhancements.title-cards.ui.hint": "Configure Title Cards", + "ffg-star-wars-enhancements.title-cards.ui.label": "Open Configuration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo": "Title Cards Logo", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-hint": "Logo to display first", + "ffg-star-wars-enhancements.title-cards.title-cards-music": "Title Cards music", + "ffg-star-wars-enhancements.title-cards.title-cards-music-hint": "Music to play. Default settings are synced to the Book of Boba Fett intro", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay": "Music start delay", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay-hint": "Delay in seconds until the music starts playing", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size": "Top Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size-hint": "Size of the top text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size": "Bottom Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size-hint": "Size of the bottom text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay": "Logo delay", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay-hint": "Time in seconds until the logo appears", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration": "Logo duration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration-hint": "Time in seconds the logo remains on screen", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay": "Text delay", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay-hint": "Time in seconds until the text appears", + "ffg-star-wars-enhancements.title-cards.title-cards-text-duration": "Text duration", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay": "Window close delay", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay-hint": "Time in seconds since the text disappeared to close the window. If 0, will not close the window" } diff --git a/lang/pt-BR.json b/lang/pt-BR.json index cd0cc25..d94df50 100644 --- a/lang/pt-BR.json +++ b/lang/pt-BR.json @@ -189,5 +189,31 @@ "ffg-star-wars-enhancements.minionsize-sync-status-zero": "Status dos minions no zero", "ffg-star-wars-enhancements.minionsize-sync-status-zero-hint": "Will be applied when zero minion member", "ffg-star-wars-enhancements.controls.holo.name": "Converter para o Holograma", - "ffg-star-wars-enhancements.controls.holo.title": "Alterne a conversão do holograma" + "ffg-star-wars-enhancements.controls.holo.title": "Alterne a conversão do holograma", + "ffg-star-wars-enhancements.controls.title-cards.title": "Title Cards", + "ffg-star-wars-enhancements.controls.title-cards.toptext-label": "Top Text", + "ffg-star-wars-enhancements.controls.title-cards.bottomtext-label": "Bottom Text", + "ffg-star-wars-enhancements.controls.title-cards.launch": "Launch Title Cards", + "ffg-star-wars-enhancements.title-cards.ui.name": "Title Cards settings", + "ffg-star-wars-enhancements.title-cards.ui.hint": "Configure Title Cards", + "ffg-star-wars-enhancements.title-cards.ui.label": "Open Configuration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo": "Title Cards Logo", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-hint": "Logo to display first", + "ffg-star-wars-enhancements.title-cards.title-cards-music": "Title Cards music", + "ffg-star-wars-enhancements.title-cards.title-cards-music-hint": "Music to play. Default settings are synced to the Book of Boba Fett intro", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay": "Music start delay", + "ffg-star-wars-enhancements.title-cards.title-cards-music-delay-hint": "Delay in seconds until the music starts playing", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size": "Top Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-top-font-size-hint": "Size of the top text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size": "Bottom Text Size", + "ffg-star-wars-enhancements.title-cards.title-cards-bottom-font-size-hint": "Size of the bottom text in px", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay": "Logo delay", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-delay-hint": "Time in seconds until the logo appears", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration": "Logo duration", + "ffg-star-wars-enhancements.title-cards.title-cards-logo-duration-hint": "Time in seconds the logo remains on screen", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay": "Text delay", + "ffg-star-wars-enhancements.title-cards.title-cards-text-delay-hint": "Time in seconds until the text appears", + "ffg-star-wars-enhancements.title-cards.title-cards-text-duration": "Text duration", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay": "Window close delay", + "ffg-star-wars-enhancements.title-cards.title-cards-close-delay-hint": "Time in seconds since the text disappeared to close the window. If 0, will not close the window" } From 9e7680d4a2947cafe320aa40f52366390a13583b Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Mon, 5 Feb 2024 21:50:23 +1030 Subject: [PATCH 5/7] fix(titleCards): logo aspect ratio scaling --- templates/title_cards.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/title_cards.html b/templates/title_cards.html index cb889ea..101f8c8 100644 --- a/templates/title_cards.html +++ b/templates/title_cards.html @@ -28,7 +28,7 @@ left: 50%; transform: translate(-50%, -50%); width: 50%; - height: 50%; + height: auto; opacity: 0; animation: logoAnimation {{logoDuration}}s ease-out {{logoDelay}}s; display: flex; From 5aada3a28f20938ae775450f65f33d9de83784aa Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Tue, 6 Feb 2024 18:11:47 +1030 Subject: [PATCH 6/7] style(prettier): run prettier on title cards files --- release-notes.md | 6 +++--- scripts/title_cards.js | 21 ++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/release-notes.md b/release-notes.md index 5d12188..78ec248 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,6 +1,6 @@ -- NEW FEATURE: Configurable Book of Boba Fett-style title cards can be played like the opening crawl -- IMPROVEMENT: Opening crawl timing can be configured in the settings -- FIX: Module settings popup windows titles corrected +- NEW FEATURE: Configurable Book of Boba Fett-style title cards can be played like the opening crawl +- IMPROVEMENT: Opening crawl timing can be configured in the settings +- FIX: Module settings popup windows titles corrected `2.0.5` - 2023-12-29 diff --git a/scripts/title_cards.js b/scripts/title_cards.js index cf28566..1414516 100644 --- a/scripts/title_cards.js +++ b/scripts/title_cards.js @@ -1,7 +1,5 @@ import { log_msg as log } from "./util.js"; - - export function title_cards_dialog() { new Dialog({ title: game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.title"), @@ -22,20 +20,19 @@ export function title_cards_dialog() { yes: { icon: "", label: `${game.i18n.localize("ffg-star-wars-enhancements.controls.title-cards.launch")}`, - callback: html => { + callback: (html) => { let data = { - toptext: html.find('input[name=\'toptext\']').val(), - bottomtext: html.find('input[name=\'bottomtext\']').val() - } + toptext: html.find("input[name='toptext']").val(), + bottomtext: html.find("input[name='bottomtext']").val(), + }; launch_title_cards(data); - } - } + }, + }, }, - default: 'yes' + default: "yes", }).render(true); } - /** * Launch the title cards. * @param {object} data @@ -53,7 +50,6 @@ export function launch_title_cards(data) { log("title-cards", "event emmitted"); } - /** * Register settings used by title cards */ @@ -195,7 +191,6 @@ async function socket_listener(data) { } } - /** * Helper function to delay code execution by an arbitrary amount * @param ms - number of MS to delay by @@ -429,4 +424,4 @@ class title_cards_UISettings extends FormApplication { } } } -} \ No newline at end of file +} From 3a57fda61b184ba1cace7d4bb324919e9a33acfa Mon Sep 17 00:00:00 2001 From: Sean Mansell Date: Tue, 6 Feb 2024 21:47:46 +1030 Subject: [PATCH 7/7] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fd4601c..e9a73d1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This module is designed to supplement the ### Features - Launch a customizable Opening Crawl based upon the [Kassel Labs Star Wars Intro Creator](https://github.com/KasselLabs/StarWarsIntroCreator) +- Launch customisable Book of Boba Fett-style title cards - A shop generator - Easily create Bounties and Datapada entries for showing players - Provides support for automatic, configurable attack animations (with sounds!)