Skip to content

Commit 8e9b335

Browse files
committed
Remove Checkbox
1 parent 00c294b commit 8e9b335

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

src/lang/en.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
"hint": "Enables all the chat features, such as the language selector in the chat and message scrambling.",
4141
"title": "Enable Chat Features"
4242
},
43-
"DisplayCheckbox": {
44-
"hint": "Displays a checkbox next to the language selector in the chat.",
45-
"title": "Display Checkbox"
46-
},
4743
"DisplayTranslated.hint": "For languages that are translated in the chat window, display the original text and a translation below.",
4844
"DisplayTranslated.title": "Display Translations",
4945
"enableAllFonts": {

src/module/forms/GeneralSettings.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export class PolyglotGeneralSettings extends FormApplication {
115115
if (game.settings.get("polyglot", "enableChatFeatures")) {
116116
data.settings.chat = {
117117
...data.settings.chat,
118-
displayCheckbox: this._prepSetting("displayCheckbox"),
119118
"display-translated": this._prepSetting("display-translated"),
120119
hideTranslation: this._prepSetting("hideTranslation"),
121120
allowOOC: this._prepSetting("allowOOC"),
@@ -171,7 +170,6 @@ export class PolyglotGeneralSettings extends FormApplication {
171170
"comprehendLanguages",
172171
"truespeech",
173172
"enableChatFeatures",
174-
"displayCheckbox",
175173
"display-translated",
176174
"hideTranslation",
177175
"allowOOC",

src/module/hooks.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ export default class PolyglotHooks {
55
*/
66
static renderChatLog(chatlog, html, data) {
77
game.polyglot.renderChatLog = true;
8-
const input = game.settings.get("polyglot", "displayCheckbox")
9-
? `<input id="polyglot-checkbox" type="checkbox" ${game.settings.get("polyglot", "checkbox") ? "checked" : ""}>`
10-
: "";
118
const polyglotDiv = document.createElement("div");
129
polyglotDiv.setAttribute("id", "polyglot");
1310
polyglotDiv.classList.add("polyglot", "polyglot-lang-select", "flexrow");
14-
polyglotDiv.innerHTML = `${input}<select id='polyglot-language' name='polyglot-language'></select>`;
11+
polyglotDiv.innerHTML = "<select id='polyglot-language' name='polyglot-language'></select>";
12+
polyglotDiv.addEventListener("contextmenu", (event) => {
13+
const setting = !game.settings.get("polyglot", "checkbox");
14+
game.settings.set("polyglot", "checkbox", setting);
15+
if (setting) game.polyglot.tomSelect.enable();
16+
else game.polyglot.tomSelect.disable();
17+
});
1518
html.querySelector(".chat-controls").insertAdjacentElement("afterend", polyglotDiv);
1619
html.querySelector(".polyglot-lang-select select").addEventListener("change", (ev) => {
1720
const lang = ev.target.value;
1821
game.polyglot.lastSelection = lang;
1922
});
20-
html.querySelector("input[id='polyglot-checkbox']").addEventListener("change", (ev) => {
23+
html.querySelector("input[id='polyglot-checkbox']")?.addEventListener("change", (ev) => {
2124
game.settings.set("polyglot", "checkbox", ev.target.checked);
2225
});
2326
game.polyglot.updateUserLanguages(html);
@@ -60,8 +63,7 @@ export default class PolyglotHooks {
6063
* @returns {Boolean}
6164
*/
6265
static preCreateChatMessage(message, data, options, userId) {
63-
const isCheckboxEnabled = !game.settings.get("polyglot", "displayCheckbox")
64-
|| game.polyglot.chatElement.querySelector("input#polyglot-checkbox").checked;
66+
const isCheckboxEnabled = !game.settings.get("polyglot", "checkbox");
6567
const isMessageLink = game.polyglot._isMessageLink(data.content);
6668
const isMessageInlineRoll = /\[\[(.*?)\]\]/g.test(data.content);
6769
// Message preprended by /desc from either Cautious GM Tools or Narrator Tools modules

src/module/logic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export class Polyglot {
319319
console.log(dropdown);
320320
}
321321
});
322+
if (!game.settings.get("polyglot", "checkbox")) this.tomSelect.disable();
322323
} else {
323324
this.tomSelect.close();
324325
this.tomSelect.clearOptions();

src/module/settings.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ export function registerSettings() {
179179
type: Boolean,
180180
requiresReload: true,
181181
});
182-
addMenuSetting("displayCheckbox", {
183-
name: "POLYGLOT.DisplayCheckbox.title",
184-
hint: "POLYGLOT.DisplayCheckbox.hint",
185-
default: true,
186-
type: Boolean,
187-
requiresReload: true,
188-
});
189182
addMenuSetting("display-translated", {
190183
name: "POLYGLOT.DisplayTranslated.title",
191184
hint: "POLYGLOT.DisplayTranslated.hint",

src/styles/_language-selector.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
}
5555
}
5656
.ts-wrapper {
57+
&.disabled {
58+
text-decoration: line-through;
59+
}
5760
.ts-control {
5861
background: rgba(0, 0, 0, 0.1);
5962
border: none;

0 commit comments

Comments
 (0)