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:
parent
e0f6b2a8e1
commit
4584b1a7a5
7 changed files with 11 additions and 40 deletions
|
|
@ -1,3 +0,0 @@
|
|||
export const FEATURE_FLAGS = Object.freeze({
|
||||
ROLLMODECONTENT: `Roll Mode Message Content`,
|
||||
});
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import { FEATURE_FLAGS } from "../consts.mjs";
|
||||
|
||||
Hooks.on(`renderChatMessage`, (msg, html) => {
|
||||
|
||||
// Short-Circuit when the flag isn't set for the message
|
||||
|
|
@ -7,13 +5,12 @@ Hooks.on(`renderChatMessage`, (msg, html) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const featureFlags = game.settings.get(game.system.id, `flags`);
|
||||
const featureFlagEnabled = featureFlags.includes(FEATURE_FLAGS.ROLLMODECONTENT);
|
||||
const featureFlagEnabled = taf.FEATURES.ROLL_MODE_CONTENT;
|
||||
|
||||
const contentElement = html.find(`.message-content`)[0];
|
||||
let content = contentElement.innerHTML;
|
||||
if (featureFlagEnabled && msg.blind && !game.user.isGM) {
|
||||
content = content.replace(/-=.*?=-/gm, `???`);
|
||||
content = content.replace(/-=.*?=-/gm, `??`);
|
||||
} else {
|
||||
content = content.replace(/-=|=-/gm, ``);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,2 @@
|
|||
import { FEATURE_FLAGS } from "../consts.mjs";
|
||||
|
||||
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,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
import { FEATURE_FLAGS } from "../../consts.mjs";
|
||||
|
||||
export function hideMessageText(content) {
|
||||
const featureFlags = game.settings.get(game.system.id, `flags`);
|
||||
const hideContent = featureFlags.includes(FEATURE_FLAGS.ROLLMODECONTENT);
|
||||
const hideContent = taf.FEATURES.ROLL_MODE_CONTENT;
|
||||
if (hideContent) {
|
||||
return `-=${content}=-`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { FEATURE_FLAGS } from "../consts.mjs";
|
||||
import { hideMessageText } from "./feature_flags/rollModeMessageContent.mjs";
|
||||
|
||||
globalThis.taf = Object.freeze({
|
||||
utils: {
|
||||
utils: Object.freeze({
|
||||
hideMessageText,
|
||||
},
|
||||
const: {
|
||||
FEATURE_FLAGS,
|
||||
}),
|
||||
FEATURES: {
|
||||
ROLL_MODE_CONTENT: false,
|
||||
STORABLE_SHEET_SIZE: false,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue