mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-23 16:03:39 +02:00
Potential Adversaries can be dragged out of the sheet onto canvas
This commit is contained in:
parent
4a53adf857
commit
1506f46efb
11 changed files with 54 additions and 66 deletions
|
|
@ -11,7 +11,6 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addAdversary: this.addAdversary,
|
addAdversary: this.addAdversary,
|
||||||
addFeature: this.addFeature,
|
|
||||||
deleteProperty: this.deleteProperty,
|
deleteProperty: this.deleteProperty,
|
||||||
viewAdversary: this.viewAdversary,
|
viewAdversary: this.viewAdversary,
|
||||||
openSettings: this.openSettings
|
openSettings: this.openSettings
|
||||||
|
|
@ -21,7 +20,7 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
||||||
submitOnChange: true,
|
submitOnChange: true,
|
||||||
closeOnSubmit: false
|
closeOnSubmit: false
|
||||||
},
|
},
|
||||||
dragDrop: [{ dragSelector: null, dropSelector: '.category-container' }]
|
dragDrop: [{ dragSelector: '.action-section .inventory-item', dropSelector: null }]
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
|
|
@ -91,32 +90,24 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async addFeature() {
|
|
||||||
ui.notifications.error('Not Implemented yet. Awaiting datamodel rework');
|
|
||||||
}
|
|
||||||
|
|
||||||
static async deleteProperty(_, target) {
|
static async deleteProperty(_, target) {
|
||||||
await this.document.update({ [`${target.dataset.path}.-=${target.id}`]: null });
|
await this.document.update({ [`${target.dataset.path}.-=${target.id}`]: null });
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async viewAdversary(_, button) {
|
static async viewAdversary(_, button) {
|
||||||
const adversary = foundry.utils.getProperty(
|
const adversary = await foundry.utils.fromUuid(button.dataset.adversary);
|
||||||
this.document.system.potentialAdversaries,
|
|
||||||
`${button.dataset.potentialAdversary}.adversaries.${button.dataset.adversary}`
|
|
||||||
);
|
|
||||||
adversary.sheet.render(true);
|
adversary.sheet.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDrop(event) {
|
async _onDragStart(event) {
|
||||||
const data = TextEditor.getDragEventData(event);
|
const item = event.currentTarget.closest('.inventory-item');
|
||||||
const item = await fromUuid(data.uuid);
|
|
||||||
if (item.type === 'adversary') {
|
if (item) {
|
||||||
const target = event.target.closest('.category-container');
|
const adversary = game.actors.find(x => x.type === 'adversary' && x.id === item.dataset.itemId);
|
||||||
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries.${item.id}`;
|
const adversaryData = { type: 'Actor', uuid: adversary.uuid };
|
||||||
await this.document.update({
|
event.dataTransfer.setData('text/plain', JSON.stringify(adversaryData));
|
||||||
[path]: item.uuid
|
event.dataTransfer.setDragImage(item, 60, 0);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,17 +180,15 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
||||||
}
|
}
|
||||||
|
|
||||||
static async #viewAdversary(_, button) {
|
static async #viewAdversary(_, button) {
|
||||||
const adversary = foundry.utils.getProperty(
|
const adversary = await foundry.utils.fromUuid(button.dataset.adversary);
|
||||||
this.actor.system.potentialAdversaries,
|
adversary.sheet.render(true);
|
||||||
`${button.dataset.potentialAdversary}.adversaries.${button.dataset.adversary}`
|
|
||||||
);
|
|
||||||
adversary.uuid.sheet.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async #deleteAdversary(event, target) {
|
static async #deleteAdversary(event, target) {
|
||||||
const adversaryKey = target.dataset.adversary;
|
const adversaryKey = target.dataset.adversary;
|
||||||
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries`;
|
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries`;
|
||||||
await this.actor.update({ [`${path}.-=${adversaryKey}`]: null });
|
const newAdversaries = foundry.utils.getProperty(this.actor, path).filter(x => x.uuid !== adversaryKey);
|
||||||
|
await this.actor.update({ [path]: newAdversaries });
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,11 +197,10 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
||||||
const item = await fromUuid(data.uuid);
|
const item = await fromUuid(data.uuid);
|
||||||
if (item.type === 'adversary') {
|
if (item.type === 'adversary') {
|
||||||
const target = event.target.closest('.category-container');
|
const target = event.target.closest('.category-container');
|
||||||
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries.${item.id}`;
|
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries`;
|
||||||
|
const current = foundry.utils.getProperty(this.actor, path).map(x => x.uuid);
|
||||||
await this.actor.update({
|
await this.actor.update({
|
||||||
[path]: {
|
[path]: [...current, item.uuid]
|
||||||
uuid: item.uuid
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export default function DhpApplicationMixin(Base) {
|
||||||
// drop: this._canDragDrop.bind(this)
|
// drop: this._canDragDrop.bind(this)
|
||||||
// };
|
// };
|
||||||
d.callbacks = {
|
d.callbacks = {
|
||||||
// dragstart: this._onDragStart.bind(this),
|
dragstart: this._onDragStart.bind(this),
|
||||||
// dragover: this._onDragOver.bind(this),
|
// dragover: this._onDragOver.bind(this),
|
||||||
drop: this._onDrop.bind(this)
|
drop: this._onDrop.bind(this)
|
||||||
};
|
};
|
||||||
|
|
@ -68,6 +68,7 @@ export default function DhpApplicationMixin(Base) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onDragStart(event) {}
|
||||||
_onDrop(event) {}
|
_onDrop(event) {}
|
||||||
|
|
||||||
_getTabs(tabs) {
|
_getTabs(tabs) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { environmentTypes } from '../../config/actorConfig.mjs';
|
||||||
import BaseDataActor from './base.mjs';
|
import BaseDataActor from './base.mjs';
|
||||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||||
import ActionField from '../fields/actionField.mjs';
|
import ActionField from '../fields/actionField.mjs';
|
||||||
|
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
||||||
|
|
||||||
export default class DhEnvironment extends BaseDataActor {
|
export default class DhEnvironment extends BaseDataActor {
|
||||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Sheets.Environment'];
|
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Sheets.Environment'];
|
||||||
|
|
@ -28,11 +29,7 @@ export default class DhEnvironment extends BaseDataActor {
|
||||||
potentialAdversaries: new fields.TypedObjectField(
|
potentialAdversaries: new fields.TypedObjectField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
label: new fields.StringField(),
|
label: new fields.StringField(),
|
||||||
adversaries: new fields.TypedObjectField(
|
adversaries: new ForeignDocumentUUIDArrayField({ type: 'Actor' })
|
||||||
new fields.SchemaField({
|
|
||||||
uuid: new ForeignDocumentUUIDField({ type: 'Actor' })
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
actions: new fields.ArrayField(new ActionField()),
|
actions: new fields.ArrayField(new ActionField()),
|
||||||
|
|
|
||||||
|
|
@ -4786,7 +4786,7 @@ div.daggerheart.views.multiclass {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
.theme-light .application.sheet.daggerheart.actor.dh-style.environment {
|
.theme-light .application.sheet.daggerheart.actor.dh-style.environment {
|
||||||
background: url('../assets/svg/trait-shield-light.svg') no-repeat;
|
background: url('../assets/parchments/dh-parchment-light.png');
|
||||||
}
|
}
|
||||||
.theme-dark .application.sheet.daggerheart.actor.dh-style.environment {
|
.theme-dark .application.sheet.daggerheart.actor.dh-style.environment {
|
||||||
background-image: url('../assets/parchments/dh-parchment-dark.png');
|
background-image: url('../assets/parchments/dh-parchment-dark.png');
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
@import '../../utils/colors.less';
|
@import '../../utils/colors.less';
|
||||||
@import '../../utils/fonts.less';
|
@import '../../utils/fonts.less';
|
||||||
|
|
||||||
.application.sheet.daggerheart.actor.dh-style.environment {
|
.application.sheet.daggerheart.actor.dh-style.environment {
|
||||||
.theme-light & {
|
.theme-light & {
|
||||||
background: url('../assets/svg/trait-shield-light.svg') no-repeat;
|
background: url('../assets/parchments/dh-parchment-light.png');
|
||||||
}
|
}
|
||||||
.theme-dark & {
|
.theme-dark & {
|
||||||
background-image: url('../assets/parchments/dh-parchment-dark.png');
|
background-image: url('../assets/parchments/dh-parchment-dark.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab {
|
.tab {
|
||||||
max-height: 300px;
|
max-height: 300px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
scrollbar-width: thin;
|
scrollbar-width: thin;
|
||||||
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@
|
||||||
{{localize (concat 'DAGGERHEART.Tiers.' source.system.tier)}}
|
{{localize (concat 'DAGGERHEART.Tiers.' source.system.tier)}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag">
|
{{#if source.system.type}}
|
||||||
<span>
|
<div class="tag">
|
||||||
{{localize (concat 'DAGGERHEART.Environment.Type.' source.system.type '.label')}}
|
<span>
|
||||||
</span>
|
{{localize (concat 'DAGGERHEART.Environment.Type.' source.system.type '.label')}}
|
||||||
</div>
|
</span>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-number">
|
<div class="status-number">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
>
|
>
|
||||||
<div class="action-section">
|
<div class="action-section">
|
||||||
{{#each document.system.potentialAdversaries}}
|
{{#each document.system.potentialAdversaries}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=this.label type='adversary' isGlassy=true}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items.hbs' title=this.label type='adversary' isGlassy=true adversaries=this.adversaries}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -14,9 +14,9 @@
|
||||||
<a><i class="fa-solid fa-trash" data-action="deleteProperty" data-path="system.potentialAdversaries" id={{@key}} data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'></i></a>
|
<a><i class="fa-solid fa-trash" data-action="deleteProperty" data-path="system.potentialAdversaries" id={{@key}} data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="adversaries-container">
|
<div class="adversaries-container">
|
||||||
{{#each this.adversaries as |adversary id|}}
|
{{#each this.adversaries as |adversary|}}
|
||||||
<div class="adversary-container">
|
<div class="adversary-container">
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary.uuid type='adversary' isActor=true categoryAdversary=@../key actorId=id}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary type='adversary' isActor=true categoryAdversary=@../key}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=feature companion=true}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=feature companion=true}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each this.adversaries as |adversary id|}}
|
{{#each adversaries as |adversary|}}
|
||||||
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary.uuid type='adversary' hideControls=true isActor=true categoryAdversary=@../key actorId=id}}
|
{{> 'systems/daggerheart/templates/sheets/global/partials/inventory-item.hbs' item=adversary type='adversary' hideControls=true isActor=true categoryAdversary=@../key}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@
|
||||||
{{#if isActor}}
|
{{#if isActor}}
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{#if (eq type 'adversary')}}
|
{{#if (eq type 'adversary')}}
|
||||||
<a data-action="viewAdversary" data-potential-adversary="{{categoryAdversary}}" data-adversary="{{actorId}}" data-tooltip='{{localize "DAGGERHEART.Tooltip.openActorWorld"}}'>
|
<a data-action="viewAdversary" data-potential-adversary="{{categoryAdversary}}" data-adversary="{{item.uuid}}" data-tooltip='{{localize "DAGGERHEART.Tooltip.openActorWorld"}}'>
|
||||||
<i class="fa-solid fa-globe"></i>
|
<i class="fa-solid fa-globe"></i>
|
||||||
</a>
|
</a>
|
||||||
<a data-action='deleteAdversary' data-potential-adversary="{{categoryAdversary}}" data-adversary="{{actorId}}" data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'>
|
<a data-action='deleteAdversary' data-potential-adversary="{{categoryAdversary}}" data-adversary="{{item.uuid}}" data-tooltip='{{localize "DAGGERHEART.Tooltip.delete"}}'>
|
||||||
<i class='fas fa-trash'></i>
|
<i class='fas fa-trash'></i>
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue