From 076003528c83cac79c10f122530ac997a0df7cad Mon Sep 17 00:00:00 2001 From: Jeremy Regnerus Date: Sun, 20 Mar 2022 08:43:59 -0400 Subject: [PATCH 1/4] added quick toggle to sheet image --- scripts/dnd5e/MonsterBlock5e.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/dnd5e/MonsterBlock5e.js b/scripts/dnd5e/MonsterBlock5e.js index 174283d..cb8ddbc 100644 --- a/scripts/dnd5e/MonsterBlock5e.js +++ b/scripts/dnd5e/MonsterBlock5e.js @@ -696,11 +696,15 @@ export default class MonsterBlock5e extends ActorSheet5eNPC { html.find(".profile-image").click((event) => { event.preventDefault(); - new ImagePopout(event.target.currentSrc, { - title: this.actor.name, - shareable: true, - uuid: this.actor.uuid - }).render(true); + if (event.altKey || event.ctrlKey || event.shiftKey) { + this.flagManager.flags["use-token-image"] = !this.flagManager.flags["use-token-image"]; + } else { + new ImagePopout(event.target.currentSrc, { + title: this.actor.name, + shareable: true, + uuid: this.actor.uuid + }).render(true); + } }); html.find("[data-roll-formula]").click(async (event) => { // Universal way to add an element that provides a roll, just add the data attribute "data-roll-formula" with a formula in it, and this applies. From 813dc102a5d4d6e5c13f5ceacd2abd2232630bfd Mon Sep 17 00:00:00 2001 From: Jeremy Regnerus Date: Tue, 22 Mar 2022 23:09:39 -0400 Subject: [PATCH 2/4] added quick show for profile image --- lang/en.json | 1 + scripts/Flags.js | 4 +++ scripts/dnd5e/MonsterBlock5e.js | 40 +++++++++++++---------- templates/dnd5e/parts/header/identity.hbs | 2 +- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/lang/en.json b/lang/en.json index 85fc0ce..8888fb2 100644 --- a/lang/en.json +++ b/lang/en.json @@ -185,6 +185,7 @@ "DescriptionS": "Descriptions", "ProfileImage": "Profile image", + "ProfileImageHint": "\n- Alt Key to switch image\n- Shift Key to show current image to players\n- Ctrl Key to show alternate image to players", "OpenTokenizer": "Open VTTA Tokenizer", "QuickInsert": "Quick Insert", diff --git a/scripts/Flags.js b/scripts/Flags.js index ebac227..65eaf91 100644 --- a/scripts/Flags.js +++ b/scripts/Flags.js @@ -101,4 +101,8 @@ export default class Flags { yield { name, ...details, value: this.flags[name] } } } + + toggle(name) { + this.flags[name] = !this.flags[name]; + } } \ No newline at end of file diff --git a/scripts/dnd5e/MonsterBlock5e.js b/scripts/dnd5e/MonsterBlock5e.js index cb8ddbc..a6eaf31 100644 --- a/scripts/dnd5e/MonsterBlock5e.js +++ b/scripts/dnd5e/MonsterBlock5e.js @@ -671,20 +671,15 @@ export default class MonsterBlock5e extends ActorSheet5eNPC { }); html.find(".switch").click((event) => { // Switches are the primary way that settings are applied per-actor. event.preventDefault(); - let control = event.currentTarget.dataset.control; // A data attribute is used on an element with the class .switch, and it contains the name of the switch to toggle. - - let state = !this.flagManager.flags[control]; // Get the current setting of this flag, and reverse it. - if (debug.enabled) console.debug(`Monster Block | %cSwitching: ${control} to: ${state}`, "color: orange") - - this.flagManager.flags[control] = state; // Set the flag to the new state. + this.flagManager.toggle(event.currentTarget.dataset.control); }); - html.find(".trigger").click((event) => { + html.find(".trigger").click((event) => { event.preventDefault(); let control = event.currentTarget.dataset.control; - + this[control](event); }); - html.find(".switch-input").keydown((event) => { + html.find(".switch-input").keydown((event) => { if (event.key !== "Enter") return; event.preventDefault(); let target = event.currentTarget; @@ -696,15 +691,26 @@ export default class MonsterBlock5e extends ActorSheet5eNPC { html.find(".profile-image").click((event) => { event.preventDefault(); - if (event.altKey || event.ctrlKey || event.shiftKey) { - this.flagManager.flags["use-token-image"] = !this.flagManager.flags["use-token-image"]; - } else { - new ImagePopout(event.target.currentSrc, { - title: this.actor.name, - shareable: true, - uuid: this.actor.uuid - }).render(true); + // toggle the profile image - alt for alternate + if (event.altKey) { + this.flagManager.toggle("use-token-image"); + return; } + + let image = event.target.currentSrc; + + if (event.ctrlKey) image = event.target.dataset.edit.startsWith("token.") ? this.actor.data.img : this.actor.data.token.img; + + console.log(image); + + // open the profile image + const popout = new ImagePopout(image, { + title: this.actor.name, + shareable: true, + uuid: this.actor.uuid + }).render(true); + + if (event.ctrlKey || event.shiftKey) popout.shareImage(); }); html.find("[data-roll-formula]").click(async (event) => { // Universal way to add an element that provides a roll, just add the data attribute "data-roll-formula" with a formula in it, and this applies. diff --git a/templates/dnd5e/parts/header/identity.hbs b/templates/dnd5e/parts/header/identity.hbs index 903bbd4..83714ca 100644 --- a/templates/dnd5e/parts/header/identity.hbs +++ b/templates/dnd5e/parts/header/identity.hbs @@ -30,6 +30,6 @@ {{else}} src="{{actor.img}}" data-edit="img" {{/if}} - title="{{actor.name}}{{#if flags.editing}} - {{localize "MOBLOKS5E.EditHint"}}{{/if}}"> + title="{{actor.name}}{{#if flags.editing}} - {{localize "MOBLOKS5E.EditHint"}}{{/if}}{{localize "MOBLOKS5E.ProfileImageHint"}}"> {{/unless}} \ No newline at end of file From 42eba0ed564d0e11fb2f449a5fa7a7b062b18196 Mon Sep 17 00:00:00 2001 From: Jeremy Regnerus Date: Sat, 26 Mar 2022 09:05:57 -0400 Subject: [PATCH 3/4] updated help tooltip --- lang/en.json | 4 +++- templates/dnd5e/parts/header/identity.hbs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lang/en.json b/lang/en.json index 8888fb2..e662e9d 100644 --- a/lang/en.json +++ b/lang/en.json @@ -185,7 +185,6 @@ "DescriptionS": "Descriptions", "ProfileImage": "Profile image", - "ProfileImageHint": "\n- Alt Key to switch image\n- Shift Key to show current image to players\n- Ctrl Key to show alternate image to players", "OpenTokenizer": "Open VTTA Tokenizer", "QuickInsert": "Quick Insert", @@ -225,6 +224,9 @@ "ProfBonus": "Proficiency Bonus", "EditHint": "Right-click to edit", + "ProfileImageHintAlt": "Alt key to switch image", + "ProfileImageHintShift": "Shift key to show current image to players", + "ProfileImageHintCtrl": "Control key to show alternate image to players", "EditButtonHint": "Click the + button above to add features", "AddFeat": "Feature", diff --git a/templates/dnd5e/parts/header/identity.hbs b/templates/dnd5e/parts/header/identity.hbs index 83714ca..ae5cb20 100644 --- a/templates/dnd5e/parts/header/identity.hbs +++ b/templates/dnd5e/parts/header/identity.hbs @@ -30,6 +30,10 @@ {{else}} src="{{actor.img}}" data-edit="img" {{/if}} - title="{{actor.name}}{{#if flags.editing}} - {{localize "MOBLOKS5E.EditHint"}}{{/if}}{{localize "MOBLOKS5E.ProfileImageHint"}}"> + title="{{actor.name~}} + {{#if flags.editing}} - {{localize "MOBLOKS5E.EditHint"}}{{/if~}} + - {{localize "MOBLOKS5E.ProfileImageHintAlt"~}} + - {{localize "MOBLOKS5E.ProfileImageHintShift"~}} + - {{localize "MOBLOKS5E.ProfileImageHintCtrl"}}"> {{/unless}} \ No newline at end of file From 4c835a50e14e17d52f91be41775bddf3e4ef31cf Mon Sep 17 00:00:00 2001 From: Jeremy Regnerus Date: Sat, 26 Mar 2022 10:51:36 -0400 Subject: [PATCH 4/4] updated localization for image toggle --- lang/fr.json | 3 +++ lang/ja.json | 3 +++ lang/pt-BR.json | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lang/fr.json b/lang/fr.json index ef6e2db..5bb34fa 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -224,6 +224,9 @@ "ProfBonus": "Bonus de compétence", "EditHint": "Clic-droit pour éditer", + "ProfileImageHintAlt": "Touche Alt pour changer d'image", + "ProfileImageHintShift": "Touche Maj pour afficher l'image actuelle aux joueurs", + "ProfileImageHintCtrl": "Touche de contrôle pour montrer une autre image aux joueurs", "EditButtonHint": "Cliquez sur le bouton + ci-dessus pour ajouter des fonctionnalités", "AddFeat": "Capacité", diff --git a/lang/ja.json b/lang/ja.json index 12f384d..7fe293e 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -224,6 +224,9 @@ "ProfBonus": "習熟度ボーナス", "EditHint": "右クリックして編集", + "ProfileImageHintAlt": "画像を切り替えるAltキー", + "ProfileImageHintShift": "Shiftキーを押して、現在の画像をプレーヤーに表示します", + "ProfileImageHintCtrl": "プレーヤーに代替画像を表示するためのコントロールキー", "EditButtonHint": "機能を追加するには、上の[+]ボタンをクリックしてください", "AddFeat": "特徴", diff --git a/lang/pt-BR.json b/lang/pt-BR.json index 5c9a27f..a47a214 100644 --- a/lang/pt-BR.json +++ b/lang/pt-BR.json @@ -224,6 +224,9 @@ "ProfBonus": "Bônus de proficiência", "EditHint": "Clique com o botão direito para editar", + "ProfileImageHintAlt": "Tecla Alt para alternar a imagem", + "ProfileImageHintShift": "Tecla Shift para mostrar a imagem atual aos jogadores", + "ProfileImageHintCtrl": "Tecla de controle para mostrar imagem alternativa aos jogadores", "EditButtonHint": "Clique no botão + acima para adicionar recursos", "AddFeat": "Característica",