Compare commits

..

No commits in common. "e340a68cff25cdb4238258f271dcd197dd0b98f5" and "76674f410e262f68bc2951394a89ffd1ff67a6f2" have entirely different histories.

3 changed files with 31 additions and 57 deletions

View File

@ -159,8 +159,6 @@ html {
} }
&.chat-targets { &.chat-targets {
margin-top: 0.5em;
& img { & img {
width: 20px; width: 20px;
height: 20px; height: 20px;
@ -168,12 +166,11 @@ html {
& .target { & .target {
display: grid; display: grid;
grid-template-columns: max-content minmax(0, max-content) auto max-content; grid-template-columns: max-content minmax(0, max-content) auto minmax(min-content, max-content);
gap: 0.5em; gap: 0.5em;
align-items: center;
& button { & button {
grid-column: 4; grid-column: 3;
line-height: normal; line-height: normal;
} }
} }

View File

@ -1,29 +1,17 @@
const { TypeDataModel } = foundry.abstract; const { TypeDataModel } = foundry.abstract;
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
const { DocumentSheetConfig } = foundry.applications.apps;
const { loadTemplates, renderTemplate } = foundry.applications.handlebars;
const { ActorSheetV2, ItemSheetV2 } = foundry.applications.sheets;
const { Notifications } = foundry.applications.ui;
const { SchemaField, NumberField, StringField, BooleanField } = foundry.data.fields; const { SchemaField, NumberField, StringField, BooleanField } = foundry.data.fields;
const { Roll } = foundry.dice; const { ActorSheetV2, ItemSheetV2 } = foundry.applications.sheets;
const { OperatorTerm, NumericTerm } = foundry.dice.terms; const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
const { ChatMessage } = foundry.documents; const { OperatorTerm, NumericTerm } = foundry.dice.terms;
Hooks.once("i18nInit", async function() { Hooks.once("i18nInit", async function() {
const lang = game.i18n.lang; game.i18n._fallback = foundry.utils.mergeObject(await game.i18n._getTranslations("de"), game.i18n._fallback);
await game.i18n.setLanguage("de");
const fallback = game.i18n.translations;
await game.i18n.setLanguage(lang);
game.i18n._fallback = foundry.utils.mergeObject(fallback, game.i18n.fallback);
}); });
class DSA41_Notifications extends Notifications { class DSA41_Notifications extends Notifications {
notify(message, type="info", {localize=false, permanent=false, console=true}={}) { notify(message, type="info", {localize=false, permanent=false, console=true}={}) {
if (permanent && message === "ERROR.RESOLUTION.Window") if (permanent && message.startsWith("Foundry Virtual Tabletop requires a minimum screen resolution"))
return; return;
return super.notify(message, type, { localize, permanent, console }); return super.notify(message, type, { localize, permanent, console });
} }
} }
@ -58,6 +46,7 @@ Hooks.once("init", async function() {
CONFIG.statusEffects = []; CONFIG.statusEffects = [];
DocumentSheetConfig.unregisterSheet(Actor, "core", ActorSheet);
DocumentSheetConfig.registerSheet(Actor, "dsa41", DSA41_ActorSheet, { DocumentSheetConfig.registerSheet(Actor, "dsa41", DSA41_ActorSheet, {
makeDefault: true, makeDefault: true,
types: [ types: [
@ -65,6 +54,7 @@ Hooks.once("init", async function() {
] ]
}); });
DocumentSheetConfig.unregisterSheet(Item, "core", ItemSheet);
DocumentSheetConfig.registerSheet(Item, "dsa41", DSA41_ItemSheetV2, { DocumentSheetConfig.registerSheet(Item, "dsa41", DSA41_ItemSheetV2, {
makeDefault: true, makeDefault: true,
types: [ types: [
@ -142,8 +132,9 @@ class DSA41_ChatMessage extends ChatMessage {
return game.actors.get(this.speaker.actor); return game.actors.get(this.speaker.actor);
} }
async renderHTML({ canDelete, canClose=false, ...rest }={}) { async getHTML() {
const html = await super.renderHTML({ canDelete, canClose, ...rest }); const html = (await super.getHTML())[0];
if (!html) return;
const img = this.actor?.img ?? this.author.avatar; const img = this.actor?.img ?? this.author.avatar;
const name = this.alias; const name = this.alias;
@ -152,8 +143,8 @@ class DSA41_ChatMessage extends ChatMessage {
const sender = html.querySelector(".message-sender"); const sender = html.querySelector(".message-sender");
sender?.replaceChildren(header); sender?.replaceChildren(header);
if (this.flags.dsa41?.type === "trefferpunkte" && this.flags.dsa41?.targets?.length != 0) { if (this.flags.type === "trefferpunkte" && this.flags.targets.length != 0) {
const targets = this.flags.dsa41?.targets.map(x => fromUuidSync(x, { strict: false })).filter(x => x !== null); const targets = this.flags.targets.map(x => fromUuidSync(x, { strict: false })).filter(x => x !== null);
const targets_list = await instantiateTemplate("TrefferpunkteTargets", targets); const targets_list = await instantiateTemplate("TrefferpunkteTargets", targets);
html.querySelector(".message-content")?.appendChild(targets_list); html.querySelector(".message-content")?.appendChild(targets_list);
@ -892,10 +883,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: flavor, flavor: flavor,
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -971,10 +960,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: flavor, flavor: flavor,
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -1000,10 +987,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: flavor, flavor: flavor,
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -1024,10 +1009,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: flavor, flavor: flavor,
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -1048,10 +1031,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: game.i18n.localize("DSA41.roll_types." + roll_type), flavor: game.i18n.localize("DSA41.roll_types." + roll_type),
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -1072,10 +1053,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: game.i18n.localize("DSA41.roll_types." + roll_type), flavor: game.i18n.localize("DSA41.roll_types." + roll_type),
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
@ -1087,10 +1066,8 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
speaker: ChatMessage.getSpeaker({ actor: this.document }), speaker: ChatMessage.getSpeaker({ actor: this.document }),
flavor: flavor, flavor: flavor,
flags: { flags: {
dsa41: { type: roll_type,
type: roll_type, targets: get_targeted_actors(),
targets: get_targeted_actors(),
}
}, },
}); });
}, },

View File

@ -65,8 +65,8 @@
], ],
"compatibility": { "compatibility": {
"minimum": "13", "minimum": "12",
"verified": "13" "verified": "12"
}, },
"version": "0.1.5", "version": "0.1.5",