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