diff --git a/.forgejo/workflows/draft-release.yaml b/.forgejo/workflows/draft-release.yaml index cd816e7..2984948 100644 --- a/.forgejo/workflows/draft-release.yaml +++ b/.forgejo/workflows/draft-release.yaml @@ -43,7 +43,6 @@ jobs: run: node scripts/src/createForgejoRelease.mjs env: TAG: "v${{steps.version.outputs.version}}" - CDN_URL: "${{vars.CDN_URL}}" wiki-release-artifact: name: "Add Wiki to Release" @@ -65,10 +64,10 @@ jobs: token: ${{forgejo.token}} - name: "Install dependencies" - run: "pwd; npm i" + run: "npm i" - - name: "Remove development folders" - run: "rm -rf .git .vscode" + - name: "Remove development/web folders" + run: "rm -rf .git .vscode _*" working-directory: "wiki" - name: "Compress wiki folder" diff --git a/dev/dev.mjs b/dev/dev.mjs new file mode 100644 index 0000000..186743f --- /dev/null +++ b/dev/dev.mjs @@ -0,0 +1 @@ +import "./hooks/renderSettings.mjs"; diff --git a/dev/hooks/renderSettings.mjs b/dev/hooks/renderSettings.mjs new file mode 100644 index 0000000..ad11762 --- /dev/null +++ b/dev/hooks/renderSettings.mjs @@ -0,0 +1,5 @@ +Hooks.on(`renderSettings`, (app, html, ctx, options) => { + /** @type {HTMLElement|undefined} */ + const coreUpdateTooltip = html.querySelector(`.build .value a`); + coreUpdateTooltip?.remove(); +}); diff --git a/langs/en-ca.json b/langs/en-ca.json index 149bb72..43dcbb0 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -67,6 +67,11 @@ "macro-is-in-use": "The Macro is used by {count} items/attributes in the world or Actors, the items will lose their ability to use the macro.", "roll": "Roll", "use": "Use", + "version": "Version {version}", + "whats-new": "What's New", + "releases": "Releases", + "wiki": "Wiki", + "issues": "Issues", "item": { "weight": "Weight", "quantity": "Quantity", diff --git a/module/apps/PlayerSheet.mjs b/module/apps/PlayerSheet.mjs index 74830d6..5dfab59 100644 --- a/module/apps/PlayerSheet.mjs +++ b/module/apps/PlayerSheet.mjs @@ -1,8 +1,8 @@ import { __ID__, filePath } from "../consts.mjs"; -import { deleteItemFromElement, editItemFromElement } from "./utils.mjs"; +import { createContextMenuOption, deleteItemFromElement, editItemFromElement } from "./utils.mjs"; import { config } from "../config.mjs"; import { Logger } from "../utils/Logger.mjs"; -import { TAFDocumentSheetConfig } from "./TAFDocumentSheetConfig.mjs"; +import { TAFDocumentSheetConfig } from "./overrides/TAFDocumentSheetConfig.mjs"; import { TAFDocumentSheetMixin } from "./mixins/TAFDocumentSheetMixin.mjs"; import { TAFActor } from "../documents/Actor.mjs"; @@ -226,24 +226,24 @@ export class PlayerSheet extends this.element, `[data-item-uuid]`, [ - { + createContextMenuOption({ label: _loc(`taf.misc.edit`), - condition: (el) => { + visible: (el) => { const itemUuid = el.dataset.itemUuid; const itemExists = itemUuid != null && itemUuid !== ``; return this.isEditable && itemExists; }, onClick: editItemFromElement, - }, - { + }), + createContextMenuOption({ label: _loc(`taf.misc.delete`), - condition: (el) => { + visible: (el) => { const itemUuid = el.dataset.itemUuid; const itemExists = itemUuid != null && itemUuid !== ``; return this.isEditable && itemExists; }, onClick: deleteItemFromElement, - }, + }), ], { jQuery: false, fixed: true }, ); diff --git a/module/apps/TAFDocumentSheetConfig.mjs b/module/apps/overrides/TAFDocumentSheetConfig.mjs similarity index 96% rename from module/apps/TAFDocumentSheetConfig.mjs rename to module/apps/overrides/TAFDocumentSheetConfig.mjs index c35b8f6..f31f585 100644 --- a/module/apps/TAFDocumentSheetConfig.mjs +++ b/module/apps/overrides/TAFDocumentSheetConfig.mjs @@ -1,6 +1,6 @@ -import { __ID__, filePath } from "../consts.mjs"; -import { getDefaultSizing } from "../utils/getSizing.mjs"; -import { localizer } from "../utils/localizer.mjs"; +import { __ID__, filePath } from "../../consts.mjs"; +import { getDefaultSizing } from "../../utils/getSizing.mjs"; +import { localizer } from "../../utils/localizer.mjs"; const { diffObject, expandObject, flattenObject } = foundry.utils; const { DocumentSheetConfig } = foundry.applications.apps; diff --git a/module/apps/overrides/TAFSettingsSidebar.mjs b/module/apps/overrides/TAFSettingsSidebar.mjs new file mode 100644 index 0000000..b33bbb8 --- /dev/null +++ b/module/apps/overrides/TAFSettingsSidebar.mjs @@ -0,0 +1,30 @@ +import { filePath } from "../../consts.mjs"; + +const { renderTemplate } = foundry.applications.handlebars; +const { Settings } = foundry.applications.sidebar.tabs; + +export class TAFSettingsSidebar extends Settings { + // #region Lifecycle + async _onRender() { + // remove the row from the HTML + const systemRow = this.element.querySelector(`.info .system`); + systemRow?.remove(); + + // add the more customized system info into the sidebar + const systemBlock = this.element.querySelector(`section.system`); + if (!systemBlock) { + const htmlString = await renderTemplate( + filePath(`templates/settings-sidebar-addition.hbs`), + { system: game.system, }, + ); + + const temp = document.createElement(`div`); + temp.innerHTML = htmlString; + const rendered = temp.firstChild; + + const info = this.element.querySelector(`section.info`); + info.insertAdjacentElement(`afterend`, rendered); + }; + }; + // #endregion Lifecycle +}; diff --git a/module/apps/utils.mjs b/module/apps/utils.mjs index de8edcc..b883ddf 100644 --- a/module/apps/utils.mjs +++ b/module/apps/utils.mjs @@ -3,6 +3,25 @@ This file contains utility methods used by Applications in order to be DRYer */ +/** + * A helper function that takes a v14-compatible ContextMenuEntry option + * and adjusts it for v13 if required + * + * @param {ContextMenuEntry} option The v14+ compatible menu entry option + * @returns {ContextMenuEntry} The v14+ or option.onClick(null, target), + }; + }; + + return option; +}; + /** * @param {Event} _event The click event * @param {HTMLElement} target The element to operate on diff --git a/module/documents/Actor.mjs b/module/documents/Actor.mjs index 1bfa0ea..0c464b5 100644 --- a/module/documents/Actor.mjs +++ b/module/documents/Actor.mjs @@ -130,8 +130,11 @@ export class TAFActor extends Actor { * This checks and performs all data migrations that the system requires, some * of these are one-time only migrations, others of them will happen every time * an Actor is updated. + * + * The defaulting of options is provided to ensure that the migration doesn't + * cause errors in Foundry v13 */ - static migrateData(data, options) { + static migrateData(data, options = {}) { this.#migrateToAttributeItems(data, options); return super.migrateData(data, options); }; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index e898f46..b06467e 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -26,6 +26,7 @@ import helpers from "../handlebarsHelpers/_index.mjs"; import { Logger } from "../utils/Logger.mjs"; import { registerCustomComponents } from "../apps/elements/_index.mjs"; import { registerSockets } from "../sockets/_index.mjs"; +import { TAFSettingsSidebar } from "../apps/overrides/TAFSettingsSidebar.mjs"; Hooks.on(`init`, () => { Logger.debug(`Initializing`); @@ -44,6 +45,10 @@ Hooks.on(`init`, () => { CONFIG.Item.dataModels.attribute = AttributeItemData; // #endregion Data Models + // #region App Overrides + CONFIG.ui.settings = TAFSettingsSidebar; + // #endregion App Overrides + // #region Sheets foundry.documents.collections.Actors.registerSheet( __ID__, diff --git a/styles/Apps/TAFSettingsSidebar.css b/styles/Apps/TAFSettingsSidebar.css new file mode 100644 index 0000000..010d6b4 --- /dev/null +++ b/styles/Apps/TAFSettingsSidebar.css @@ -0,0 +1,29 @@ +#settings > .system { + .version-info { + display: flex; + justify-content: center; + align-items: center; + flex-direction: row; + gap: 8px; + + .whats-new { + font-size: smaller; + } + } + + .links { + display: flex; + justify-content: center; + align-items: center; + flex-direction: row; + flex-wrap: wrap; + gap: 8px; + list-style-type: none; + padding: 0; + margin: 0; + + li { + margin: 0; + } + } +} diff --git a/styles/main.css b/styles/main.css index 627b546..682b25d 100644 --- a/styles/main.css +++ b/styles/main.css @@ -31,3 +31,4 @@ @import url("./Apps/PlayerSheet.css") layer(apps); @import url("./Apps/QueryStatus.css") layer(apps); @import url("./Apps/TAFDocumentSheetConfig.css") layer(apps); +@import url("./Apps/TAFSettingsSidebar.css") layer(apps); diff --git a/system.json b/system.json index a301e22..22a301f 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "taf", "title": "Text-Based Actors", "description": "An intentionally minimalist system that enables you to play rules-light games without getting in your way!", - "version": "3.0.0", + "version": "3.0.2", "download": "", "manifest": "", "url": "https://git.varify.ca/Foundry/taf", @@ -15,7 +15,8 @@ { "name": "Oliver" } ], "esmodules": [ - "module/main.mjs" + "module/main.mjs", + "dev/dev.mjs" ], "styles": [ { @@ -54,6 +55,7 @@ }, "socket": true, "flags": { + "forgejo_api": "https://git.varify.ca/api/v1", "hotReload": { "extensions": ["css", "hbs", "json", "js", "mjs", "svg"], "paths": ["templates", "langs", "styles", "module", "assets"] diff --git a/templates/settings-sidebar-addition.hbs b/templates/settings-sidebar-addition.hbs new file mode 100644 index 0000000..71fed2b --- /dev/null +++ b/templates/settings-sidebar-addition.hbs @@ -0,0 +1,48 @@ +
+

+ {{ system.title }} +

+
+ + {{localize "taf.misc.version" version=system.version}} + + + {{localize "taf.misc.whats-new"}} + +
+ +