Skip to content

Commit

Permalink
Add Display Checkbox setting
Browse files Browse the repository at this point in the history
Fix #344
  • Loading branch information
mclemente committed Apr 11, 2024
1 parent c19bda3 commit 1d4a3ac
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
12 changes: 8 additions & 4 deletions src/lang/en.json
Expand Up @@ -36,6 +36,10 @@
"CustomLanguages.title": "Custom Languages",
"DefaultLanguage.hint": "Name of the default language to select. Keep empty to use system default.",
"DefaultLanguage.title": "Default Language",
"DisplayCheckbox": {
"hint": "Removes the checkbox from the chat section.",
"title": "Display Checkbox"
},
"DisplayTranslated.hint": "For languages that are translated in the chat window, display the original text and a translation below.",
"DisplayTranslated.title": "Display Translations",
"enableAllFonts": {
Expand All @@ -44,7 +48,7 @@
},
"ExportFonts.hint": "Add Polyglot's fonts to Foundry's features, such as Drawings.",
"ExportFonts.title": "Add Polyglot's fonts to Foundry",
"HideTranslation.hint": "Hides the Globe and the \"Translated from\" text from chat messages to players. Useful for when you don't want to show players which language you are speaking. Requires reload.",
"HideTranslation.hint": "Hides the Globe and the \"Translated from\" text from chat messages to players. Useful for when you don't want to show players which language you are speaking.",
"HideTranslation.title": "Hide Indicators from Players",
"IgnoreJournalFontSize": {
"hint": "Ignores the size of Polyglot's fonts on journals, making them have the same size as normal text would have. Useful for when the formatting of the journal matters.",
Expand All @@ -69,11 +73,11 @@
},
"languageDataPath": {
"title": "Language Data Path",
"hint": "If your system has languages set in actors' data and aren't being loaded properly, it might be using another data path. Input the data path to the correct attribute (e.g. actor.system.languages or actor.system.speak). This settings takes precedence over the {setting} setting. Requires reload."
"hint": "If your system has languages set in actors' data and aren't being loaded properly, it might be using another data path. Input the data path to the correct attribute (e.g. actor.system.languages or actor.system.speak). This settings takes precedence over the {setting} setting."
},
"literacyDataPath": {
"title": "Literacy Data Path",
"hint": "Same as the {setting} setting, but for reading journals. This settings requires the {setting} setting. Requires reload."
"hint": "Same as the {setting} setting, but for reading journals. This settings requires the {setting} setting."
},
"LanguageRegex": {
"hint": "You can use this to change the term searched on items from \"Language\" to something else, like \"Tongue\". This setting is more useful for non-English speakers.",
Expand All @@ -94,7 +98,7 @@
"hint": "Makes the randomization ignore non-alphanumerical characters (e.g. !,.;:?#$\"'). This might have the undesired effect of showing some of those characters as a square (□) on some fonts.",
"title": "Randomize Only Alphanumericals"
},
"ScrambleGM.hint": "Don't translate the text for the GM (refer to the globe's color for the token's understanding). Requires reload.",
"ScrambleGM.hint": "Don't translate the text for the GM (refer to the globe's color for the token's understanding).",
"ScrambleGM.title": "Scramble Messages for GM",
"Truespeech.hint": "Set a language whose speaker understands all spoken languages (can't read Journals) and which is understood by all creatures. An actor will be able to read all chat messages and to write messages in a language that is understood by all.",
"Truespeech.title": "Omnispeech Language",
Expand Down
1 change: 1 addition & 0 deletions src/module/forms/GeneralSettings.js
Expand Up @@ -108,6 +108,7 @@ export class PolyglotGeneralSettings extends FormApplication {
},
chat: {
// Chat
displayCheckbox: this._prepSetting("displayCheckbox"),
"display-translated": this._prepSetting("display-translated"),
hideTranslation: this._prepSetting("hideTranslation"),
allowOOC: this._prepSetting("allowOOC"),
Expand Down
15 changes: 8 additions & 7 deletions src/module/hooks.js
Expand Up @@ -5,21 +5,21 @@ export default class PolyglotHooks {
*/
static renderChatLog(chatlog, html, data) {
game.polyglot.renderChatLog = true;
const input = game.settings.get("polyglot", "displayCheckbox")
? `<input name="polyglot-checkbox" type="checkbox" ${game.settings.get("polyglot", "checkbox") ? "checked" : ""}>`
: "";
html.find("#chat-controls").after(
`<div id='polyglot' class='polyglot polyglot-lang-select flexrow'>
<input name="polyglot-checkbox" type="checkbox" ${game.settings.get("polyglot", "checkbox") ? "checked" : ""}></input>
${input}
<label>${game.i18n.localize("POLYGLOT.LanguageLabel")}</label>
<select name='polyglot-language'></select>
</div>`,
);
const select = html.find(".polyglot-lang-select select");

select.change((ev) => {
html.find(".polyglot-lang-select select").change((ev) => {
const lang = ev.target.value;
game.polyglot.lastSelection = lang;
});
const input = html.find("input[name='polyglot-checkbox']");
input.change((ev) => {
html.find("input[name='polyglot-checkbox']").change((ev) => {
game.settings.set("polyglot", "checkbox", ev.target.checked);
});
game.polyglot.updateUserLanguages(html);
Expand Down Expand Up @@ -62,7 +62,8 @@ export default class PolyglotHooks {
* @returns {Boolean}
*/
static preCreateChatMessage(message, data, options, userId) {
const isCheckboxEnabled = game.polyglot.chatElement.find("input[name=polyglot-checkbox]").prop("checked");
const isCheckboxEnabled = !game.settings.get("polyglot", "displayCheckbox")
|| game.polyglot.chatElement.find("input[name=polyglot-checkbox]").prop("checked");
const isMessageLink = game.polyglot._isMessageLink(data.content);
const isMessageInlineRoll = /\[\[(.*?)\]\]/g.test(data.content);
// Message preprended by /desc from either Cautious GM Tools or Narrator Tools modules
Expand Down
7 changes: 7 additions & 0 deletions src/module/settings.js
Expand Up @@ -174,6 +174,13 @@ export function registerSettings() {
});

// Chat Settings
addMenuSetting("displayCheckbox", {
name: "POLYGLOT.DisplayCheckbox.title",
hint: "POLYGLOT.DisplayCheckbox.hint",
default: true,
type: Boolean,
requiresReload: true,
});
addMenuSetting("display-translated", {
name: "POLYGLOT.DisplayTranslated.title",
hint: "POLYGLOT.DisplayTranslated.hint",
Expand Down

1 comment on commit 1d4a3ac

@Rapids00122
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you kind sir!

Please sign in to comment.