Skip to content

Commit 7645887

Browse files
committed
Allow disabling chat features
Fix #412
1 parent aa7379a commit 7645887

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

src/lang/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"CustomLanguages.title": "Custom Languages",
3737
"DefaultLanguage.hint": "Name of the default language to select. Keep empty to use system default.",
3838
"DefaultLanguage.title": "Default Language",
39+
"EnableChatFeatures": {
40+
"hint": "Enables all the chat features, such as the language selector in the chat and message scrambling.",
41+
"title": "Enable Chat Features"
42+
},
3943
"DisplayCheckbox": {
4044
"hint": "Removes the checkbox from the chat section.",
4145
"title": "Display Checkbox"

src/module/forms/GeneralSettings.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,20 @@ export class PolyglotGeneralSettings extends FormApplication {
108108
},
109109
chat: {
110110
// Chat
111-
displayCheckbox: this._prepSetting("displayCheckbox"),
112-
"display-translated": this._prepSetting("display-translated"),
113-
hideTranslation: this._prepSetting("hideTranslation"),
114-
allowOOC: this._prepSetting("allowOOC"),
115-
runifyGM: this._prepSetting("runifyGM"),
111+
enableChatFeatures: this._prepSetting("enableChatFeatures")
116112
},
117113
},
118114
};
115+
if (game.settings.get("polyglot", "enableChatFeatures")) {
116+
data.settings.chat = {
117+
...data.settings.chat,
118+
displayCheckbox: this._prepSetting("displayCheckbox"),
119+
"display-translated": this._prepSetting("display-translated"),
120+
hideTranslation: this._prepSetting("hideTranslation"),
121+
allowOOC: this._prepSetting("allowOOC"),
122+
runifyGM: this._prepSetting("runifyGM"),
123+
};
124+
}
119125
} else {
120126
data = {
121127
tabs: {
@@ -164,6 +170,8 @@ export class PolyglotGeneralSettings extends FormApplication {
164170
"omniglot",
165171
"comprehendLanguages",
166172
"truespeech",
173+
"enableChatFeatures",
174+
"displayCheckbox",
167175
"display-translated",
168176
"hideTranslation",
169177
"allowOOC",

src/module/logic.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,25 @@ export class Polyglot {
1414
}
1515

1616
init() {
17-
for (let hook of Object.getOwnPropertyNames(PolyglotHooks)) {
18-
if (!["length", "name", "prototype"].includes(hook)) {
19-
Hooks.on(hook, PolyglotHooks[hook]);
20-
}
17+
if (game.settings.get("polyglot", "enableChatFeatures")) {
18+
Hooks.on("renderChatLog", PolyglotHooks.renderChatLog);
19+
Hooks.on("updateActor", PolyglotHooks.updateActor);
20+
Hooks.on("controlToken", PolyglotHooks.controlToken);
21+
Hooks.on("updateUser", PolyglotHooks.updateUser);
22+
Hooks.on("updateActiveEffect", PolyglotHooks.updateActiveEffect);
23+
Hooks.on("preCreateChatMessage", PolyglotHooks.preCreateChatMessage);
24+
Hooks.on("renderChatMessage", PolyglotHooks.renderChatMessage);
25+
Hooks.on("createChatMessage", PolyglotHooks.createChatMessage);
26+
Hooks.on("renderActorDirectoryPF2e", PolyglotHooks.renderActorDirectoryPF2e);
27+
Hooks.on("vinoPrepareChatDisplayData", PolyglotHooks.vinoPrepareChatDisplayData);
2128
}
29+
Hooks.on("renderDocumentSheet", PolyglotHooks.renderDocumentSheet);
30+
Hooks.on("renderActorSheet", PolyglotHooks.renderActorSheet);
31+
Hooks.on("renderItemSheet", PolyglotHooks.renderItemSheet);
32+
Hooks.on("renderJournalTextPageSheet", PolyglotHooks.renderJournalTextPageSheet);
33+
Hooks.on("renderJournalSheet", PolyglotHooks.renderJournalSheet);
34+
Hooks.on("renderStorySheet", PolyglotHooks.renderStorySheet);
35+
Hooks.on("getProseMirrorMenuDropDowns", PolyglotHooks.getProseMirrorMenuDropDowns);
2236
Polyglot.handleTinyMCE();
2337

2438
libWrapper.register(

src/module/settings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ export function registerSettings() {
172172
});
173173

174174
// Chat Settings
175+
addMenuSetting("enableChatFeatures", {
176+
name: "POLYGLOT.EnableChatFeatures.title",
177+
hint: "POLYGLOT.EnableChatFeatures.hint",
178+
default: true,
179+
type: Boolean,
180+
requiresReload: true,
181+
});
175182
addMenuSetting("displayCheckbox", {
176183
name: "POLYGLOT.DisplayCheckbox.title",
177184
hint: "POLYGLOT.DisplayCheckbox.hint",

0 commit comments

Comments
 (0)