Implements rudimentary item management
parent
edf6dcab1a
commit
39917a0f89
|
|
@ -20,6 +20,7 @@ async function preloadHandlebarsTemplates() {
|
||||||
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs',
|
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs',
|
||||||
|
'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-array-editor.hbs'
|
'systems/DSA_4-1/templates/ui/partial-array-editor.hbs'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ export class CharacterSheet extends ActorSheet {
|
||||||
#addEquipmentsToContext(context) {
|
#addEquipmentsToContext(context) {
|
||||||
context.equipments = [];
|
context.equipments = [];
|
||||||
const actorData = context.data;
|
const actorData = context.data;
|
||||||
|
context.carryingweight = 0;
|
||||||
Object.values(actorData.items).forEach( (item, index) => {
|
Object.values(actorData.items).forEach( (item, index) => {
|
||||||
if (item.type === "Equipment") {
|
if (item.type === "Equipment") {
|
||||||
context.equipments.push({
|
context.equipments.push({
|
||||||
|
|
@ -164,8 +165,11 @@ export class CharacterSheet extends ActorSheet {
|
||||||
quantity: item.system.quantity,
|
quantity: item.system.quantity,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
})
|
})
|
||||||
|
context.carryingweight += item.system.quantity * item.system.weight;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
context.maxcarryingcapacity = actorData.system.attribute.kk.aktuell
|
||||||
|
context.carryingpercentage = (context.carryingweight / context.maxcarryingcapacity)*100;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareEigenschaftRoll(actorData, name) {
|
prepareEigenschaftRoll(actorData, name) {
|
||||||
|
|
@ -323,7 +327,7 @@ export class CharacterSheet extends ActorSheet {
|
||||||
})
|
})
|
||||||
|
|
||||||
html.on('click', '.equipment .name', (evt) => {
|
html.on('click', '.equipment .name', (evt) => {
|
||||||
this.openEmbeddedDocument(evt.target.dataset.id);
|
this.openEmbeddedDocument(evt.target.parentElement.dataset.id);
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -358,6 +362,17 @@ export class CharacterSheet extends ActorSheet {
|
||||||
li.addEventListener("dragstart", handler, false);
|
li.addEventListener("dragstart", handler, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new ContextMenu(html, '.equipment', [
|
||||||
|
{
|
||||||
|
name: "Aus dem Inventar entfernen",
|
||||||
|
icon: '<i class="fa-solid fa-trash"></i>',
|
||||||
|
callback: (event) => {
|
||||||
|
this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id])
|
||||||
|
},
|
||||||
|
condition: () => true
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#handleDroppedSkill(actor, skill) {
|
#handleDroppedSkill(actor, skill) {
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,22 @@ export class GroupSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
console.log(groupData, context.characters)
|
|
||||||
return await context;
|
|
||||||
|
|
||||||
|
|
||||||
|
context.equipments = [];
|
||||||
|
const actorData = context.data;
|
||||||
|
Object.values(actorData.items).forEach( (item, index) => {
|
||||||
|
if (item.type === "Equipment") {
|
||||||
|
context.equipments.push({
|
||||||
|
index: index,
|
||||||
|
id: item._id,
|
||||||
|
quantity: item.system.quantity,
|
||||||
|
name: item.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return await context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
|
@ -97,6 +110,16 @@ export class GroupSheet extends ActorSheet {
|
||||||
})
|
})
|
||||||
ui.notifications.info(`${character.name} ist der Heldengruppe ${group.name} beigetreten`)
|
ui.notifications.info(`${character.name} ist der Heldengruppe ${group.name} beigetreten`)
|
||||||
}
|
}
|
||||||
|
if (data.type === "Equipment") {
|
||||||
|
const uuid = await foundry.utils.parseUuid(data.uuid);
|
||||||
|
const equipment = await (game.actors.get(uuid.id))
|
||||||
|
ui.notifications.info(`${equipment.name} befindet sich nun im Inventar der Heldengruppe ${group.name}`)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openEmbeddedDocument(documentId) {
|
||||||
|
this.object.items.get(documentId).sheet.render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
|
|
@ -122,5 +145,22 @@ export class GroupSheet extends ActorSheet {
|
||||||
(await game.actors.get(id)).sheet.render(true);
|
(await game.actors.get(id)).sheet.render(true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
html.on('click', '.equipment .name', (evt) => {
|
||||||
|
this.openEmbeddedDocument(evt.target.dataset.id);
|
||||||
|
evt.stopPropagation();
|
||||||
|
})
|
||||||
|
|
||||||
|
new ContextMenu(html, '.equipment', [
|
||||||
|
{
|
||||||
|
name: "Aus dem Gruppeninventar entfernen",
|
||||||
|
icon: '<i class="fa-solid fa-trash"></i>',
|
||||||
|
callback: (event) => {
|
||||||
|
this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id])
|
||||||
|
},
|
||||||
|
condition: () => true
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,39 @@
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.backpack {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 8px;
|
||||||
|
|
||||||
|
.resource {
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
border: 1px inset #ccc;
|
||||||
|
background-color: rgba(0,0,0,0.2);
|
||||||
|
height: 8px;
|
||||||
|
|
||||||
|
span.fill {
|
||||||
|
position:absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: linear-gradient(to bottom, #0bad29 0%,#11f128 50%,#0cde24 51%,#6ff77b 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.equipment:hover {
|
||||||
|
.item-name {
|
||||||
|
text-shadow: 0 0 10px rgb(255 0 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,14 +5,17 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
|
|
||||||
.tab.meta.active {
|
.tab.active {
|
||||||
|
padding: 4px;
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
padding: 4px;
|
}
|
||||||
|
|
||||||
|
.tab.meta.active {
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-auto-columns: 1fr 1fr;
|
grid-auto-columns: 1fr 1fr;
|
||||||
grid-template-columns: 80px auto;
|
grid-template-columns: 80px auto;
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,19 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 27px;
|
top: 76px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sheet-body {
|
.sheet-body {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 112px;
|
top: 98px;
|
||||||
left: 2px;
|
left: 0;
|
||||||
bottom: 2px;
|
bottom: 0;
|
||||||
right: 2px;
|
right: 0;
|
||||||
|
padding: 8px;
|
||||||
|
margin: 8px;
|
||||||
|
|
||||||
div.tab {
|
div.tab {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
@ -41,6 +44,7 @@
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
&.minimal {
|
&.minimal {
|
||||||
display: unset!important;
|
display: unset!important;
|
||||||
|
|
@ -167,4 +171,10 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.equipment:hover {
|
||||||
|
.item-name {
|
||||||
|
text-shadow: 0 0 10px rgb(255 0 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,14 +146,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tab backpack" data-group="primary" data-tab="backpack">
|
<div class="tab backpack" data-group="primary" data-tab="backpack">
|
||||||
|
|
||||||
<ul>
|
<div class="capacity">
|
||||||
|
<label>Tragkraft: {{this.carryingweight}} von maximal {{this.maxcarryingcapacity}} Stein</label>
|
||||||
|
<div class="resource">
|
||||||
|
<span class="fill" style="width: {{this.carryingpercentage}}%"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#each equipments}}
|
{{#each equipments}}
|
||||||
<li class="equipment">
|
{{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" this}}
|
||||||
<span class="quantity">{{this.quantity}}</span>
|
|
||||||
<span class="name" data-id="{{this.id}}">{{this.name}}</span>
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="tab spells" data-group="primary" data-tab="spells">
|
<div class="tab spells" data-group="primary" data-tab="spells">
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,11 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="tab inventory" data-group="primary" data-tab="inventory">
|
<div class="tab inventory" data-group="primary" data-tab="inventory">
|
||||||
|
<ul>
|
||||||
|
{{#each equipments}}
|
||||||
|
{{> 'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs' this}}
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="equipment" data-id="{{this.id}}">
|
||||||
|
<span class="quantity">{{this.quantity}}</span>
|
||||||
|
<span class="item-name">{{this.name}}</span>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue