add more context to chat messages
This commit is contained in:
parent
d7779f3c48
commit
ef00bd029e
7
src/Chat/Header.hbs
Normal file
7
src/Chat/Header.hbs
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="DSA41 row chat-header">
|
||||
<img src="{{img}}" alt="{{name}}">
|
||||
<div class="col">
|
||||
<span class="title">{{name}}</span>
|
||||
<span class="subtitle">{{author}}</span>
|
||||
</div>
|
||||
</div>
|
||||
15
src/main.css
15
src/main.css
@ -49,7 +49,7 @@ html {
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
& .row {
|
||||
& .row, &.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
@ -145,6 +145,19 @@ html {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
&.chat-header {
|
||||
& img {
|
||||
margin-right: .75em;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
& .subtitle {
|
||||
color: #666;
|
||||
font-size: .6875rem;
|
||||
}
|
||||
}
|
||||
|
||||
& .die {
|
||||
display: inline-grid;
|
||||
|
||||
|
||||
33
src/main.mjs
33
src/main.mjs
@ -14,6 +14,7 @@ Hooks.once("init", async function() {
|
||||
CONFIG.Actor.dataModels.Player = DSA41_CharacterData;
|
||||
CONFIG.Actor.documentClass = DSA41_CharacterDocument;
|
||||
|
||||
CONFIG.ChatMessage.documentClass = DSA41_ChatMessage;
|
||||
CONFIG.Item.dataModels.Gegenstand = DSA41_GegenstandData;
|
||||
CONFIG.Item.dataModels.Ruestung = DSA41_RuestungData;
|
||||
CONFIG.Item.dataModels.Bewaffnung = DSA41_BewaffnungData;
|
||||
@ -22,6 +23,8 @@ Hooks.once("init", async function() {
|
||||
CONFIG.Item.dataModels.Sonderfertigkeit = DSA41_SonderfertigkeitData;
|
||||
CONFIG.Item.dataModels.VorNachteil = DSA41_VorNachteilData;
|
||||
|
||||
CONFIG.statusEffects = [];
|
||||
|
||||
DocumentSheetConfig.unregisterSheet(Actor, "core", ActorSheet);
|
||||
DocumentSheetConfig.registerSheet(Actor, "dsa41", DSA41_ActorSheet, {
|
||||
makeDefault: true,
|
||||
@ -70,10 +73,40 @@ Hooks.once("init", async function() {
|
||||
"fernkampf_attacke_tooltip": "systems/dsa-4th-edition/src/Tooltips/FernkampfAttacke.hbs",
|
||||
"fernkampf_trefferpunkte_tooltip": "systems/dsa-4th-edition/src/Tooltips/FernkampfTrefferpunkte.hbs",
|
||||
|
||||
"CHAT_HEADER": "systems/dsa-4th-edition/src/Chat/Header.hbs",
|
||||
"talent_chat": "systems/dsa-4th-edition/src/Chat/Talent.hbs",
|
||||
});
|
||||
});
|
||||
|
||||
class DSA41_ChatMessage extends ChatMessage {
|
||||
get actor() {
|
||||
if (this.speaker.scene && this.speaker.token) {
|
||||
const scene = game.scenes.get(this.speaker.scene);
|
||||
const token = scene?.tokens.get(this.speaker.token);
|
||||
if (token) return token.actor;
|
||||
}
|
||||
|
||||
return game.actors.get(this.speaker.actor);
|
||||
}
|
||||
|
||||
async getHTML() {
|
||||
const html = (await super.getHTML())[0];
|
||||
|
||||
const img = this.actor?.img ?? this.author.avatar;
|
||||
const name = this.alias;
|
||||
|
||||
const header_html = await renderTemplate("CHAT_HEADER", { img: img, name: name, author: this.author?.name ?? "" });
|
||||
const header_template = document.createElement("template");
|
||||
header_template.innerHTML = header_html;
|
||||
const header = header_template.content.children;
|
||||
|
||||
const sender = html?.querySelector(".message-sender");
|
||||
sender?.replaceChildren(...header);
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
function get_minified_formula(formula, data) {
|
||||
const terms = Roll.simplifyTerms(Roll.parse(formula, data));
|
||||
let output = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user