add basic actor sheet

This commit is contained in:
Sven Balzer 2024-09-26 10:56:53 +02:00
parent 74e884436a
commit 68522582fd
5 changed files with 218 additions and 42 deletions

67
src/ActorSheet.html Normal file
View File

@ -0,0 +1,67 @@
{{#*inline "editable-text"}}
<div class="editable-text col">
{{#if @root.editable}}
<input type="text" name="{{name}}" value="{{value}}" placeholder="{{placeholder}}">
{{else}}
<div>{{value}}</div>
{{/if}}
{{#if placeholder}}
<div class="placeholder">{{placeholder}}</div>
{{/if}}
</div>
{{/inline}}
{{#*inline "die-type"}}
<div class="center die die-{{type}}">{{type}}</div>
{{/inline}}
{{#*inline "die-value"}}
<div class="col">
<div class="center">{{type}}</div>
<div class="die die-{{type}}">{{lookup @root.actor.system.computed type}}</div>
</div>
{{/inline}}
<form class="actor-sheet {{ cssClass }}" autocomplete="off">
<div class="row">
{{>editable-text name="name" value=actor.name placeholder="Name"}}
{{>editable-text name="system.race" value=actor.system.race placeholder="Rasse"}}
{{>editable-text name="system.cultuee" value=actor.system.culture placeholder="Kultur"}}
{{>editable-text name="system.profession" value=actor.system.profession placeholder="Profession"}}
</div>
<div class="row">
<img class="character-image" src="{{ actor.img }}" title="{{ actor.name }}" {{#if editable}}data-edit="img"{{/if}}>
{{#each actor.system.attributes}}
{{>die-value type=@key}}
{{/each}}
</div>
<div class="row">
<table>
<tr>
<th></th>
{{#each actor.system.attributes}}
<th>{{@key}}</th>
{{/each}}
</tr>
<tr>
<td>Startwert</td>
{{#each actor.system.attributes}}
<td>{{>editable-text name=(concat "system.attributes." @key ".initial") value=(lookup this "initial")}}</td>
{{/each}}
</tr>
<tr>
<td>Steigerungen</td>
{{#each actor.system.attributes}}
<td>{{>editable-text name=(concat "system.attributes." @key ".advancement") value=(lookup this "advancement")}}</td>
{{/each}}
</tr>
<tr>
<td>Modifikatoren</td>
{{#each actor.system.attributes}}
<td>{{>editable-text name=(concat "system.attributes." @key ".modifier") value=(lookup this "modifier")}}</td>
{{/each}}
</tr>
</table>
</div>
</form>

15
src/Assets/d20.svg Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="64" height="64" version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
<g>
<path d="m11.906 20.4h40.188l-20.094 34.801z"/>
<path d="m52.635 21.059 6.5977 26.664-26.391 7.6172z"/>
<path d="m32 .55664 19.791 19.043h-39.582z"/>
<path d="m11.365 21.059 19.793 34.281-26.391-7.6172z"/>
<path d="m4.6875 16.691 6.0664 3.5039-6.0664 24.52z"/>
<path d="m29.359 1.9863-18.207 17.518-6.0664-3.5039z"/>
<path d="m34.641 1.9863 24.273 14.014-6.0664 3.5039z"/>
<path d="m59.312 16.691v28.023l-6.0664-24.52z"/>
<path d="m7.3281 49.295 24.271 7.0059v7.0078z"/>
<path d="m56.672 49.295-24.271 14.014v-7.0078z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 696 B

View File

@ -1,3 +1,65 @@
.row {
display: flex;
flex-direction: row;
}
.col {
display: flex;
flex-direction: column;
}
.wrap {
flex-wrap: wrap;
}
.center {
text-align: center;
}
.placeholder {
font-size: 0.8em;
border-top: 1px solid;
}
.editable-text {
flex: 1;
padding: 0px 3px;
}
.editable-text input {
border: none;
}
.character-image {
width: 115px;
height: 115px;
}
.die {
width: 48px;
height: 48px;
line-height: 48px;
background-color: #000;
mask-image: url("../src/Assets/d20.svg");
mask-size: contain;
text-align: center;
color: #fff;
}
.die-MU { background-color: #b22319; }
.die-KL { background-color: #8158a3; }
.die-IN { background-color: #388834; }
.die-CH { background-color: #0c0c0c; }
.die-FF { background-color: #d4b366; }
.die-GE { background-color: #678ec3; }
.die-KO { background-color: #a3a3a3; }
.die-KK { background-color: #d5a877; }
.item-sheet header {
display: flex;
flex-flow: row wrap;

View File

@ -1,43 +1,79 @@
function init() {
Hooks.once("init", function() {
console.log("INIT");
CONFIG.Actor.dataModels.Player = DSA41_CharacterData;
//DocumentSheetConfig.unregisterSheet(Actor, "core", ActorSheet);
DocumentSheetConfig.registerSheet(Actor, "dsa41", DSA41_ActorSheet, {
makeDefault: true,
types: [
"Player",
]
});
//DocumentSheetConfig.unregisterSheet(Item, "core", ItemSheet);
DocumentSheetConfig.registerSheet(Item, "dsa41", DSA41_ItemSheet, {
makeDefault: true,
types: [
"Generic Item",
"Melee Weapon",
"Ranged Weapon",
"Armor",
"Shield",
]
makeDefault: true,
types: [
"Generic Item",
"Melee Weapon",
"Ranged Weapon",
"Armor",
"Shield",
]
});
});
const { SchemaField, NumberField, StringField } = foundry.data.fields;
class AttributeField extends foundry.data.fields.SchemaField {
constructor() {
return super({
initial: new NumberField({ integer: true, initial: 8, min: 8, max: 14, }),
advancement: new NumberField({ integer: true, initial: 0, min: 0, max: 4, }),
modifier: new NumberField({ integer: true, initial: 0, min: 0, }),
});
}
}
class DSA41_CharacterData extends foundry.abstract.TypeDataModel {
static defineSchema() {
return {
race: new StringField(),
culture: new StringField(),
profession: new StringField(),
attributes: new SchemaField({
MU: new AttributeField(),
KL: new AttributeField(),
IN: new AttributeField(),
CH: new AttributeField(),
FF: new AttributeField(),
GE: new AttributeField(),
KO: new AttributeField(),
KK: new AttributeField(),
}),
}
);
}
prepareDerivedData() {
super.prepareDerivedData();
this.computed = {};
for (const [attribute, values] of Object.entries(this.attributes)) {
this.computed[attribute] = Object.values(values).reduce((a, b) => a + b, 0);
}
}
}
class DSA41_ActorSheet extends ActorSheet {
get template() {
return "systems/dsa-4th-edition/src/ActorSheet.html";
}
}
class DSA41_ItemSheet extends ItemSheet {
get template() {
return "systems/dsa-4th-edition/src/ItemSheets/" + this.item.type + ".html"
return "systems/dsa-4th-edition/src/ItemSheets/" + this.item.type + ".html";
}
getData() {
const data = super.getData();
console.log(data);
return data;
}
}
function ready() {
console.log("READY");
}
function setup() {
console.log("SETUP");
//Item.create({"name": "TestItem4", "type": "spell", "system": {"price": "15"}});
}
Hooks.once("init", init);
Hooks.once("ready", ready);
Hooks.once("setup", setup);

View File

@ -1,20 +1,16 @@
{
"Actor": {
"types": [
"Player"
]
},
"Item": {
"templates": {
},
"types": [
"Generic Item",
"Melee Weapon",
"Ranged Weapon",
"Armor",
"Shield"
],
"weapon": {
"templates": []
},
"spell": {
"templates": []
}
]
}
}