Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d06e8c6850 | |||
| d04985b5b7 | |||
| 7603e79e42 | |||
| 3875cbba4f | |||
| e164e046a5 | |||
| 09ac9624ed | |||
| d3a60fbef5 |
13 changed files with 140 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
Hooks.on(`renderSettings`, (app, html, ctx, options) => {
|
Hooks.on(`renderSettings`, (app, html) => {
|
||||||
/** @type {HTMLElement|undefined} */
|
/** @type {HTMLElement|undefined} */
|
||||||
const coreUpdateTooltip = html.querySelector(`.build .value a`);
|
const coreUpdateTooltip = html.querySelector(`.build .value a`);
|
||||||
coreUpdateTooltip?.remove();
|
coreUpdateTooltip?.remove();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@
|
||||||
"hint": "This removes the default attributes that are applied when a new actor is created, making it so that no attributes get created alongside the actor.",
|
"hint": "This removes the default attributes that are applied when a new actor is created, making it so that no attributes get created alongside the actor.",
|
||||||
"label": "Remove Attributes"
|
"label": "Remove Attributes"
|
||||||
},
|
},
|
||||||
|
"betaChannel": {
|
||||||
|
"name": "Beta Release Notifications",
|
||||||
|
"hint": "Whether or not to receive notifications about new beta releases for the system. If left unchecked, you will still receive notifications about new versions, but only for stable versions."
|
||||||
|
},
|
||||||
"canPlayersManageAttributes": {
|
"canPlayersManageAttributes": {
|
||||||
"name": "Players Can Manage Attributes",
|
"name": "Players Can Manage Attributes",
|
||||||
"hint": "This allows players who have edit access to a document to be able to edit what attributes those characters have via the attribute editor"
|
"hint": "This allows players who have edit access to a document to be able to edit what attributes those characters have via the attribute editor"
|
||||||
|
|
@ -72,6 +76,7 @@
|
||||||
"releases": "Releases",
|
"releases": "Releases",
|
||||||
"wiki": "Wiki",
|
"wiki": "Wiki",
|
||||||
"issues": "Issues",
|
"issues": "Issues",
|
||||||
|
"new-version-available": "{version} available now!",
|
||||||
"item": {
|
"item": {
|
||||||
"weight": "Weight",
|
"weight": "Weight",
|
||||||
"quantity": "Quantity",
|
"quantity": "Quantity",
|
||||||
|
|
@ -155,7 +160,8 @@
|
||||||
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
"saved-default-attributes": "Successfully saved default Actor attributes",
|
"saved-default-attributes": "Successfully saved default Actor attributes.",
|
||||||
|
"removed-default-attributes": "The default attributes for Actors have been removed.",
|
||||||
"migration-successful": "Data migrations for version {version} were successful."
|
"migration-successful": "Data migrations for version {version} were successful."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { filePath } from "../../consts.mjs";
|
import { filePath } from "../../consts.mjs";
|
||||||
|
import { getLatestVersion } from "../../utils/ReleaseChannels.mjs";
|
||||||
|
|
||||||
|
const { isNewerVersion } = foundry.utils;
|
||||||
const { renderTemplate } = foundry.applications.handlebars;
|
const { renderTemplate } = foundry.applications.handlebars;
|
||||||
const { Settings } = foundry.applications.sidebar.tabs;
|
const { Settings } = foundry.applications.sidebar.tabs;
|
||||||
|
|
||||||
|
|
@ -13,9 +15,15 @@ export class TAFSettingsSidebar extends Settings {
|
||||||
// add the more customized system info into the sidebar
|
// add the more customized system info into the sidebar
|
||||||
const systemBlock = this.element.querySelector(`section.system`);
|
const systemBlock = this.element.querySelector(`section.system`);
|
||||||
if (!systemBlock) {
|
if (!systemBlock) {
|
||||||
|
const latest = await getLatestVersion();
|
||||||
|
const latestVersion = latest.tag_name.slice(1);
|
||||||
const htmlString = await renderTemplate(
|
const htmlString = await renderTemplate(
|
||||||
filePath(`templates/settings-sidebar-addition.hbs`),
|
filePath(`templates/settings-sidebar-addition.hbs`),
|
||||||
{ system: game.system, },
|
{
|
||||||
|
system: game.system,
|
||||||
|
hasNewVersion: isNewerVersion(latestVersion, game.system.version),
|
||||||
|
newVersion: latest.tag_name,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const temp = document.createElement(`div`);
|
const temp = document.createElement(`div`);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import { TAFMacro } from "../documents/Macro.mjs";
|
||||||
import { TAFTokenDocument } from "../documents/Token.mjs";
|
import { TAFTokenDocument } from "../documents/Token.mjs";
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
import { registerReleaseSettings } from "../utils/ReleaseChannels.mjs";
|
||||||
import { registerWorldSettings } from "../settings/world.mjs";
|
import { registerWorldSettings } from "../settings/world.mjs";
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
|
|
@ -89,6 +90,7 @@ Hooks.on(`init`, () => {
|
||||||
);
|
);
|
||||||
// #endregion Sheets
|
// #endregion Sheets
|
||||||
|
|
||||||
|
registerReleaseSettings();
|
||||||
registerWorldSettings();
|
registerWorldSettings();
|
||||||
|
|
||||||
registerSockets();
|
registerSockets();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { checkForNewReleases } from "../utils/ReleaseChannels.mjs";
|
||||||
import { checkMigrations } from "../migrations/checkMigrations.mjs";
|
import { checkMigrations } from "../migrations/checkMigrations.mjs";
|
||||||
|
|
||||||
Hooks.on(`ready`, () => {
|
Hooks.on(`ready`, () => {
|
||||||
|
|
@ -7,4 +8,5 @@ Hooks.on(`ready`, () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
checkMigrations();
|
checkMigrations();
|
||||||
|
checkForNewReleases();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ Hooks.on(`renderSettingsConfig`, (app, html) => {
|
||||||
button.innerHTML = _loc(`taf.settings.actorDefaultAttributes.label`);
|
button.innerHTML = _loc(`taf.settings.actorDefaultAttributes.label`);
|
||||||
button.addEventListener(`click`, () => {
|
button.addEventListener(`click`, () => {
|
||||||
game.settings.set(__ID__, `actorDefaultAttributes`, undefined);
|
game.settings.set(__ID__, `actorDefaultAttributes`, undefined);
|
||||||
|
formGroup.remove();
|
||||||
|
ui.notifications.success(_loc(`taf.notifs.success.removed-default-attributes`));
|
||||||
});
|
});
|
||||||
|
|
||||||
const hint = document.createElement(`p`);
|
const hint = document.createElement(`p`);
|
||||||
|
|
|
||||||
75
module/utils/ReleaseChannels.mjs
Normal file
75
module/utils/ReleaseChannels.mjs
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
import { __ID__, filePath } from "../consts.mjs";
|
||||||
|
import { Logger } from "./Logger.mjs";
|
||||||
|
|
||||||
|
const { ChatMessage } = foundry.documents;
|
||||||
|
const { renderTemplate } = foundry.applications.handlebars;
|
||||||
|
const { fetchJsonWithTimeout, isNewerVersion } = foundry.utils;
|
||||||
|
|
||||||
|
let newestVersion = null;
|
||||||
|
|
||||||
|
async function fetchLatestVersion() {
|
||||||
|
const includeBetas = game.settings.get(__ID__, `betaChannel`);
|
||||||
|
try {
|
||||||
|
const releases = await fetchJsonWithTimeout(`https://git.varify.ca/api/v1/repos/Foundry/taf/releases?pre-release=${includeBetas}&limit=1`);
|
||||||
|
return releases.at(0);
|
||||||
|
} catch {
|
||||||
|
Logger.error(`Failed to fetch latest version from Forgejo, halting version checks`);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function getLatestVersion() {
|
||||||
|
if (!newestVersion) {
|
||||||
|
newestVersion = await fetchLatestVersion();
|
||||||
|
};
|
||||||
|
return newestVersion;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function checkForNewReleases() {
|
||||||
|
// Only perform the update check if the game is ready and the user is the active GM
|
||||||
|
if (!game.user.isActiveGM || !game.ready) { return };
|
||||||
|
|
||||||
|
// Don't do any version notifications if this is a fresh world
|
||||||
|
const lastNotifiedVersion = game.settings.get(__ID__, `lastUpdateNotified`);
|
||||||
|
if (!lastNotifiedVersion) {
|
||||||
|
game.settings.set(__ID__, `lastUpdateNotified`, game.system.version);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let latest = newestVersion = await getLatestVersion();
|
||||||
|
|
||||||
|
// Is the latest release newer than the previously notified release
|
||||||
|
const latestVersion = latest.tag_name.replace(/^v/, ``);
|
||||||
|
if (!isNewerVersion(latestVersion, lastNotifiedVersion)) { return };
|
||||||
|
|
||||||
|
const content = await renderTemplate(
|
||||||
|
filePath(`templates/new-version-message.hbs`),
|
||||||
|
{
|
||||||
|
release: latest,
|
||||||
|
system: game.system,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
ChatMessage.implementation.create({
|
||||||
|
whisper: [ game.user.id ],
|
||||||
|
content,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark the new version as the
|
||||||
|
game.settings.set(__ID__, `lastUpdateNotified`, latestVersion);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function registerReleaseSettings() {
|
||||||
|
game.settings.register(__ID__, `betaChannel`, {
|
||||||
|
name: `${__ID__}.settings.betaChannel.name`,
|
||||||
|
hint: `${__ID__}.settings.betaChannel.hint`,
|
||||||
|
config: true,
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
scope: `world`,
|
||||||
|
});
|
||||||
|
|
||||||
|
game.settings.register(__ID__, `lastUpdateNotified`, {
|
||||||
|
config: false,
|
||||||
|
type: String,
|
||||||
|
scope: `world`,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -26,4 +26,10 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
font-size: small;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@
|
||||||
@import url("./elements/span.css") layer(elements);
|
@import url("./elements/span.css") layer(elements);
|
||||||
@import url("./elements/table.css") layer(elements);
|
@import url("./elements/table.css") layer(elements);
|
||||||
|
|
||||||
|
/* Partials */
|
||||||
|
@import url("./misc.css") layer(partials);
|
||||||
|
|
||||||
/* Apps */
|
/* Apps */
|
||||||
@import url("./Apps/common.css") layer(apps);
|
@import url("./Apps/common.css") layer(apps);
|
||||||
@import url("./Apps/Ask.css") layer(apps);
|
@import url("./Apps/Ask.css") layer(apps);
|
||||||
|
|
|
||||||
7
styles/misc.css
Normal file
7
styles/misc.css
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.taf-chat-version-notif {
|
||||||
|
h2 {
|
||||||
|
font-family: var(--font-body);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -55,7 +55,6 @@
|
||||||
},
|
},
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"flags": {
|
"flags": {
|
||||||
"forgejo_api": "https://git.varify.ca/api/v1",
|
|
||||||
"hotReload": {
|
"hotReload": {
|
||||||
"extensions": ["css", "hbs", "json", "js", "mjs", "svg"],
|
"extensions": ["css", "hbs", "json", "js", "mjs", "svg"],
|
||||||
"paths": ["templates", "langs", "styles", "module", "assets"]
|
"paths": ["templates", "langs", "styles", "module", "assets"]
|
||||||
|
|
|
||||||
17
templates/new-version-message.hbs
Normal file
17
templates/new-version-message.hbs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<div class="taf-chat-version-notif">
|
||||||
|
<h2>
|
||||||
|
{{ system.title }}
|
||||||
|
{{ release.tag_name }}
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
A new {{ifThen release.prerelease "beta" ""}} version of {{ system.title }} has been released.
|
||||||
|
</p>
|
||||||
|
<a
|
||||||
|
class="button"
|
||||||
|
href="{{ release.html_url }}"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
Release Notes
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
href="{{ system.url }}/releases/tag/v{{ system.version }}"
|
href="{{ system.url }}/releases/tag/v{{ system.version }}"
|
||||||
class="whats-new"
|
class="whats-new"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noreferrer"
|
||||||
style="font-size: smaller"
|
style="font-size: smaller"
|
||||||
>
|
>
|
||||||
{{localize "taf.misc.whats-new"}}
|
{{localize "taf.misc.whats-new"}}
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
<a
|
<a
|
||||||
href="{{ system.url }}/releases"
|
href="{{ system.url }}/releases"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
{{localize "taf.misc.releases"}}
|
{{localize "taf.misc.releases"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
<a
|
<a
|
||||||
href="{{ system.url }}/wiki"
|
href="{{ system.url }}/wiki"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
{{localize "taf.misc.wiki"}}
|
{{localize "taf.misc.wiki"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -39,10 +39,15 @@
|
||||||
<a
|
<a
|
||||||
href="{{ system.url }}/issues"
|
href="{{ system.url }}/issues"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
{{localize "taf.misc.issues"}}
|
{{localize "taf.misc.issues"}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{{#if hasNewVersion}}
|
||||||
|
<p>
|
||||||
|
{{localize "taf.misc.new-version-available" version=newVersion}}
|
||||||
|
</p>
|
||||||
|
{{/if}}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue