Change the way feature flags are working because using settings was a bad idea (and bump version to 2.0.0 since it's an API change)

This commit is contained in:
Oliver-Akins 2024-09-29 00:09:30 -06:00
parent e0f6b2a8e1
commit 4584b1a7a5
7 changed files with 11 additions and 40 deletions

View file

@ -31,6 +31,7 @@ export default [
ActiveEffect: `readonly`, ActiveEffect: `readonly`,
Dialog: `readonly`, Dialog: `readonly`,
renderTemplate: `readonly`, renderTemplate: `readonly`,
TextEditor: `readonly`,
}, },
}, },
}, },
@ -42,6 +43,7 @@ export default [
languageOptions: { languageOptions: {
globals: { globals: {
Logger: `readonly`, Logger: `readonly`,
taf: `readonly`,
}, },
}, },
rules: { rules: {

View file

@ -1,3 +0,0 @@
export const FEATURE_FLAGS = Object.freeze({
ROLLMODECONTENT: `Roll Mode Message Content`,
});

View file

@ -1,5 +1,3 @@
import { FEATURE_FLAGS } from "../consts.mjs";
Hooks.on(`renderChatMessage`, (msg, html) => { Hooks.on(`renderChatMessage`, (msg, html) => {
// Short-Circuit when the flag isn't set for the message // Short-Circuit when the flag isn't set for the message
@ -7,13 +5,12 @@ Hooks.on(`renderChatMessage`, (msg, html) => {
return; return;
} }
const featureFlags = game.settings.get(game.system.id, `flags`); const featureFlagEnabled = taf.FEATURES.ROLL_MODE_CONTENT;
const featureFlagEnabled = featureFlags.includes(FEATURE_FLAGS.ROLLMODECONTENT);
const contentElement = html.find(`.message-content`)[0]; const contentElement = html.find(`.message-content`)[0];
let content = contentElement.innerHTML; let content = contentElement.innerHTML;
if (featureFlagEnabled && msg.blind && !game.user.isGM) { if (featureFlagEnabled && msg.blind && !game.user.isGM) {
content = content.replace(/-=.*?=-/gm, `???`); content = content.replace(/-=.*?=-/gm, `??`);
} else { } else {
content = content.replace(/-=|=-/gm, ``); content = content.replace(/-=|=-/gm, ``);
} }

View file

@ -1,24 +1,2 @@
import { FEATURE_FLAGS } from "../consts.mjs";
export function registerWorldSettings() { export function registerWorldSettings() {
game.settings.register(game.system.id, `flags`, {
name: `Feature Flags`,
hint: `World-based feature flags that are used to enable/disable specific behaviours`,
scope: `world`,
type: new foundry.data.fields.SetField(
new foundry.data.fields.StringField(
{
empty: false,
trim: true,
options: Object.values(FEATURE_FLAGS),
},
),
{
required: false,
initial: new Set(),
},
),
config: true,
requiresReload: true,
});
}; };

View file

@ -1,8 +1,5 @@
import { FEATURE_FLAGS } from "../../consts.mjs";
export function hideMessageText(content) { export function hideMessageText(content) {
const featureFlags = game.settings.get(game.system.id, `flags`); const hideContent = taf.FEATURES.ROLL_MODE_CONTENT;
const hideContent = featureFlags.includes(FEATURE_FLAGS.ROLLMODECONTENT);
if (hideContent) { if (hideContent) {
return `-=${content}=-`; return `-=${content}=-`;
} }

View file

@ -1,11 +1,11 @@
import { FEATURE_FLAGS } from "../consts.mjs";
import { hideMessageText } from "./feature_flags/rollModeMessageContent.mjs"; import { hideMessageText } from "./feature_flags/rollModeMessageContent.mjs";
globalThis.taf = Object.freeze({ globalThis.taf = Object.freeze({
utils: { utils: Object.freeze({
hideMessageText, hideMessageText,
}, }),
const: { FEATURES: {
FEATURE_FLAGS, ROLL_MODE_CONTENT: false,
STORABLE_SHEET_SIZE: false,
}, },
}); });

View file

@ -2,7 +2,7 @@
"id": "taf", "id": "taf",
"title": "Text-Based Actors", "title": "Text-Based Actors",
"description": "", "description": "",
"version": "1.2.0", "version": "2.0.0",
"download": "https://github.com/Oliver-Akins/Text-Actors-Foundry/releases/latest/download/dotdungeon.zip", "download": "https://github.com/Oliver-Akins/Text-Actors-Foundry/releases/latest/download/dotdungeon.zip",
"manifest": "https://github.com/Oliver-Akins/Text-Actors-Foundry/releases/latest/download/system.json", "manifest": "https://github.com/Oliver-Akins/Text-Actors-Foundry/releases/latest/download/system.json",
"url": "https://github.com/Oliver-Akins/Text-Actors-Foundry", "url": "https://github.com/Oliver-Akins/Text-Actors-Foundry",