Compare commits

...

10 Commits

Author SHA1 Message Date
Sven Balzer
e340a68cff change minimum and verified foundry versions to 13 2025-05-01 10:14:18 +02:00
Sven Balzer
b82f6ab305 guard against not having flags on the chat message 2025-05-01 10:12:59 +02:00
Sven Balzer
d233593a9b fix css for chat targets 2025-05-01 10:06:56 +02:00
Sven Balzer
c7e748e382 replace getHTML with renderHTML for ChatMessage 2025-05-01 09:55:19 +02:00
Sven Balzer
21ac6bf9fa put all flags inside dsa41 scope 2025-05-01 09:03:38 +02:00
Sven Balzer
6497042f97 get rid of old {Actor,Item}Sheet unregisters 2025-05-01 07:25:36 +02:00
Sven Balzer
735650358a reference loadTemplates and renderTemplate from their new namespace 2025-05-01 07:19:22 +02:00
Sven Balzer
d653d58741 reference DocumentSheetConfig from the new namespace 2025-05-01 07:16:16 +02:00
Sven Balzer
51235ebaf2 reference Notifications from the new namespace 2025-05-01 07:06:50 +02:00
Sven Balzer
61bc68dd3c fix i18n fallback for v13 2025-05-01 07:01:39 +02:00
3 changed files with 57 additions and 31 deletions

View File

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

View File

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

View File

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