Compare commits

..

5 commits
v3.0.1 ... main

12 changed files with 158 additions and 13 deletions

1
dev/dev.mjs Normal file
View file

@ -0,0 +1 @@
import "./hooks/renderSettings.mjs";

View file

@ -0,0 +1,5 @@
Hooks.on(`renderSettings`, (app, html, ctx, options) => {
/** @type {HTMLElement|undefined} */
const coreUpdateTooltip = html.querySelector(`.build .value a`);
coreUpdateTooltip?.remove();
});

View file

@ -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",

View file

@ -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 },
);

View file

@ -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;

View file

@ -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
};

View file

@ -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 <v13 menu option object
*/
export function createContextMenuOption(option) {
if (game.release.generation < 14) {
return {
name: option.label,
condition: option.visible,
callback: (target) => option.onClick(null, target),
};
};
return option;
};
/**
* @param {Event} _event The click event
* @param {HTMLElement} target The element to operate on

View file

@ -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__,

View file

@ -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;
}
}
}

View file

@ -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);

View file

@ -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.1",
"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"]

View file

@ -0,0 +1,48 @@
<section class="system flexcol">
<h4 class="divider">
{{ system.title }}
</h4>
<div class="version-info">
<span class="version">
{{localize "taf.misc.version" version=system.version}}
</span>
<a
href="{{ system.url }}/releases/tag/v{{ system.version }}"
class="whats-new"
target="_blank"
rel="noopener noreferrer"
style="font-size: smaller"
>
{{localize "taf.misc.whats-new"}}
</a>
</div>
<ul class="links">
<li>
<a
href="{{ system.url }}/releases"
target="_blank"
rel="noopener noreferrer"
>
{{localize "taf.misc.releases"}}
</a>
</li>
<li>
<a
href="{{ system.url }}/wiki"
target="_blank"
rel="noopener noreferrer"
>
{{localize "taf.misc.wiki"}}
</a>
</li>
<li>
<a
href="{{ system.url }}/issues"
target="_blank"
rel="noopener noreferrer"
>
{{localize "taf.misc.issues"}}
</a>
</li>
</ul>
</section>