mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Initial
This commit is contained in:
parent
883aaeec02
commit
23a497bab8
7 changed files with 157 additions and 70 deletions
|
|
@ -2135,6 +2135,10 @@
|
||||||
"plural": "Experiences"
|
"plural": "Experiences"
|
||||||
},
|
},
|
||||||
"failure": "Failure",
|
"failure": "Failure",
|
||||||
|
"favorite": {
|
||||||
|
"single": "Favorite",
|
||||||
|
"plural": "Favorites"
|
||||||
|
},
|
||||||
"fear": "Fear",
|
"fear": "Fear",
|
||||||
"features": "Features",
|
"features": "Features",
|
||||||
"formula": "Formula",
|
"formula": "Formula",
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
||||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||||
useDowntime: this.useDowntime,
|
useDowntime: this.useDowntime,
|
||||||
viewParty: CharacterSheet.#viewParty,
|
viewParty: CharacterSheet.#viewParty
|
||||||
},
|
},
|
||||||
window: {
|
window: {
|
||||||
resizable: true,
|
resizable: true,
|
||||||
|
|
@ -49,6 +49,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
{
|
{
|
||||||
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]',
|
||||||
dropSelector: null
|
dropSelector: null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dragSelector: null,
|
||||||
|
dropSelector: '.character-sidebar-sheet'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
contextMenus: [
|
contextMenus: [
|
||||||
|
|
@ -261,6 +265,24 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
*/
|
*/
|
||||||
async _prepareSidebarContext(context, _options) {
|
async _prepareSidebarContext(context, _options) {
|
||||||
context.isDeath = this.document.system.deathMoveViable;
|
context.isDeath = this.document.system.deathMoveViable;
|
||||||
|
context.sidebarFavoritesEmpty = this.document.system.sidebarFavorites.length === 0;
|
||||||
|
|
||||||
|
const initialFavorites = this.document.system.usedUnarmed
|
||||||
|
? {
|
||||||
|
equipment: {
|
||||||
|
label: 'DAGGERHEART.GENERAL.equipment',
|
||||||
|
items: [{ type: 'attack', value: this.document.system.usedUnarmed }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: {};
|
||||||
|
context.sidebarFavorites = this.document.system.sidebarFavorites.reduce((acc, item) => {
|
||||||
|
const type = item.type === 'domainCard' ? item.type : 'equipment';
|
||||||
|
const label = type === 'domainCard' ? 'DAGGERHEART.GENERAL.loadout' : 'DAGGERHEART.GENERAL.equipment';
|
||||||
|
if (!acc[type]) acc[type] = { label, items: [] };
|
||||||
|
acc[type].items.push({ type: item.type, value: item });
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, initialFavorites);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -310,7 +332,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-arrow-up',
|
icon: 'fa-solid fa-arrow-up',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async target => {
|
callback: async target => {
|
||||||
const doc = await getDocFromElement(target);
|
const doc = await getDocFromElement(target);
|
||||||
|
|
@ -324,7 +348,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-bolt-lightning',
|
icon: 'fa-solid fa-bolt-lightning',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async (target, event) => {
|
callback: async (target, event) => {
|
||||||
const doc = await getDocFromElement(target);
|
const doc = await getDocFromElement(target);
|
||||||
|
|
@ -338,15 +364,20 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
}
|
}
|
||||||
const type = 'effect';
|
const type = 'effect';
|
||||||
const cls = game.system.api.models.actions.actionsTypes[type];
|
const cls = game.system.api.models.actions.actionsTypes[type];
|
||||||
const action = new cls({
|
const action = new cls(
|
||||||
...cls.getSourceConfig(doc.system),
|
{
|
||||||
type: type,
|
...cls.getSourceConfig(doc.system),
|
||||||
chatDisplay: false,
|
type: type,
|
||||||
cost: [{
|
chatDisplay: false,
|
||||||
key: 'stress',
|
cost: [
|
||||||
value: doc.system.recallCost
|
{
|
||||||
}]
|
key: 'stress',
|
||||||
}, { parent: doc.system });
|
value: doc.system.recallCost
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{ parent: doc.system }
|
||||||
|
);
|
||||||
const config = await action.use(event);
|
const config = await action.use(event);
|
||||||
if (config) {
|
if (config) {
|
||||||
return doc.update({ 'system.inVault': false });
|
return doc.update({ 'system.inVault': false });
|
||||||
|
|
@ -358,7 +389,9 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
icon: 'fa-solid fa-arrow-down',
|
icon: 'fa-solid fa-arrow-down',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc && !doc.system.inVault;
|
const inCharacterSidebar =
|
||||||
|
this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
return doc && !doc.system.inVault && !inCharacterSidebar;
|
||||||
},
|
},
|
||||||
callback: async target => (await getDocFromElement(target)).update({ 'system.inVault': true })
|
callback: async target => (await getDocFromElement(target)).update({ 'system.inVault': true })
|
||||||
}
|
}
|
||||||
|
|
@ -900,32 +933,32 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttons = parties.map((p) => {
|
const buttons = parties.map(p => {
|
||||||
const button = document.createElement("button");
|
const button = document.createElement('button');
|
||||||
button.type = "button";
|
button.type = 'button';
|
||||||
button.classList.add("plain");
|
button.classList.add('plain');
|
||||||
const img = document.createElement("img");
|
const img = document.createElement('img');
|
||||||
img.src = p.img;
|
img.src = p.img;
|
||||||
button.append(img);
|
button.append(img);
|
||||||
const name = document.createElement("span");
|
const name = document.createElement('span');
|
||||||
name.textContent = p.name;
|
name.textContent = p.name;
|
||||||
button.append(name);
|
button.append(name);
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener('click', () => {
|
||||||
p.sheet?.render({ force: true });
|
p.sheet?.render({ force: true });
|
||||||
game.tooltip.dismissLockedTooltips();
|
game.tooltip.dismissLockedTooltips();
|
||||||
});
|
});
|
||||||
return button;
|
return button;
|
||||||
});
|
});
|
||||||
|
|
||||||
const html = document.createElement("div");
|
const html = document.createElement('div');
|
||||||
html.classList.add("party-list");
|
html.classList.add('party-list');
|
||||||
html.append(...buttons);
|
html.append(...buttons);
|
||||||
|
|
||||||
game.tooltip.dismissLockedTooltips();
|
game.tooltip.dismissLockedTooltips();
|
||||||
game.tooltip.activate(target, {
|
game.tooltip.activate(target, {
|
||||||
html,
|
html,
|
||||||
locked: true,
|
locked: true
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -948,6 +981,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onDropItem(event, item) {
|
async _onDropItem(event, item) {
|
||||||
|
const sidebarDrop = event.target.closest('.character-sidebar-sheet');
|
||||||
|
if (sidebarDrop) {
|
||||||
|
return this._onSidebarDrop(event, item);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.document.uuid === item.parent?.uuid) {
|
if (this.document.uuid === item.parent?.uuid) {
|
||||||
return super._onDropItem(event, item);
|
return super._onDropItem(event, item);
|
||||||
}
|
}
|
||||||
|
|
@ -986,4 +1024,18 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
itemData = itemData instanceof Array ? itemData : [itemData];
|
itemData = itemData instanceof Array ? itemData : [itemData];
|
||||||
return this.document.createEmbeddedDocuments('Item', itemData);
|
return this.document.createEmbeddedDocuments('Item', itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onSidebarDrop(event, item) {
|
||||||
|
if (!item.testUserPermission(game.user, 'OWNER')) return;
|
||||||
|
|
||||||
|
if (!(item instanceof game.system.api.documents.DHItem)) return;
|
||||||
|
if (!this.document.items.get(item.id)) return;
|
||||||
|
|
||||||
|
const allowedItemTypes = ['domainCard', 'feature', 'weapon', 'armor', 'loot', 'consumable'];
|
||||||
|
if (!allowedItemTypes.includes(item.type)) return;
|
||||||
|
|
||||||
|
if (this.document.system.sidebarFavorites.some(x => x.id === item.id)) return;
|
||||||
|
|
||||||
|
this.document.update({ 'system.sidebarFavorites': [...this.document.system.sidebarFavorites, item] });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -539,6 +539,39 @@ export default function DHApplicationMixin(Base) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
options.push({
|
||||||
|
name: 'Unfavorite',
|
||||||
|
icon: 'fa-regular fa-star',
|
||||||
|
condition: target => {
|
||||||
|
return this.document.type === 'character' && target.closest('.items-sidebar-list');
|
||||||
|
},
|
||||||
|
callback: async (target, _event) => {
|
||||||
|
const doc = await getDocFromElement(target);
|
||||||
|
this.document.update({
|
||||||
|
'system.sidebarFavorites': this.document.system.sidebarFavorites.filter(x => x.id !== doc.id)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
options.push({
|
||||||
|
name: 'Favorite',
|
||||||
|
icon: 'fa-solid fa-star',
|
||||||
|
condition: target => {
|
||||||
|
const doc = getDocFromElementSync(target);
|
||||||
|
return (
|
||||||
|
!(doc instanceof game.system.api.documents.DhActiveEffect) &&
|
||||||
|
this.document.type === 'character' &&
|
||||||
|
!target.closest('.items-sidebar-list')
|
||||||
|
);
|
||||||
|
},
|
||||||
|
callback: async (target, _event) => {
|
||||||
|
const doc = await getDocFromElement(target);
|
||||||
|
this.document.update({
|
||||||
|
'system.sidebarFavorites': [...this.document.system.sidebarFavorites, doc]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return options.map(option => ({
|
return options.map(option => ({
|
||||||
...option,
|
...option,
|
||||||
icon: `<i class="${option.icon}"></i>`
|
icon: `<i class="${option.icon}"></i>`
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import BaseDataActor, { commonActorRules } from './base.mjs';
|
||||||
import { attributeField, resourceField, stressDamageReductionRule, bonusField } from '../fields/actorField.mjs';
|
import { attributeField, resourceField, stressDamageReductionRule, bonusField } from '../fields/actorField.mjs';
|
||||||
import { ActionField } from '../fields/actionField.mjs';
|
import { ActionField } from '../fields/actionField.mjs';
|
||||||
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
|
import DHCharacterSettings from '../../applications/sheets-configs/character-settings.mjs';
|
||||||
|
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
||||||
|
|
||||||
export default class DhCharacter extends BaseDataActor {
|
export default class DhCharacter extends BaseDataActor {
|
||||||
/**@override */
|
/**@override */
|
||||||
|
|
@ -284,7 +285,8 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
burden: new fields.SchemaField({
|
burden: new fields.SchemaField({
|
||||||
ignore: new fields.BooleanField()
|
ignore: new fields.BooleanField()
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
|
sidebarFavorites: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,25 @@
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
scrollbar-color: light-dark(@dark-blue, @golden) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-favorites {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 40px;
|
||||||
|
border: 1px dashed light-dark(@dark-blue-50, @beige-50);
|
||||||
|
border-radius: 3px;
|
||||||
|
color: light-dark(@dark-blue-50, @beige-50);
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-left: 4px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.equipment-section,
|
.equipment-section,
|
||||||
|
|
|
||||||
|
|
@ -96,45 +96,27 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="shortcut-items-section">
|
<div class="shortcut-items-section">
|
||||||
<div class="equipment-section">
|
{{#if sidebarFavoritesEmpty}}
|
||||||
<div class="title">
|
<div class="empty-favorites"><span>{{localize "DAGGERHEART.GENERAL.favorite.plural"}}</span></div>
|
||||||
<side-line-div class="invert"></side-line-div>
|
{{else}}
|
||||||
<h3>{{localize "DAGGERHEART.GENERAL.equipment"}}</h3>
|
{{#each sidebarFavorites as |category|}}
|
||||||
<side-line-div></side-line-div>
|
<div class="equipment-section">
|
||||||
</div>
|
<div class="title">
|
||||||
<ul class="items-sidebar-list">
|
<side-line-div class="invert"></side-line-div>
|
||||||
{{#if document.system.usedUnarmed}}
|
<h3>{{localize category.label}}</h3>
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
<side-line-div></side-line-div>
|
||||||
item=document.system.usedUnarmed
|
</div>
|
||||||
type='attack'
|
<ul class="items-sidebar-list">
|
||||||
}}
|
{{#each category.items as |item|}}
|
||||||
{{/if}}
|
{{> 'daggerheart.inventory-item-compact'
|
||||||
{{#each document.items as |item|}}
|
item=item.value
|
||||||
{{#if item.system.equipped}}
|
type=item.type
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
}}
|
||||||
item=item
|
{{/each}}
|
||||||
type=item.type
|
</ul>
|
||||||
}}
|
</div>
|
||||||
{{/if}}
|
{{/each}}
|
||||||
{{/each}}
|
{{/if}}
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="loadout-section">
|
|
||||||
<div class="title">
|
|
||||||
<side-line-div class="invert"></side-line-div>
|
|
||||||
<h3>{{localize "DAGGERHEART.GENERAL.loadout"}}</h3>
|
|
||||||
<side-line-div></side-line-div>
|
|
||||||
</div>
|
|
||||||
<ul class="items-sidebar-list">
|
|
||||||
{{#each document.system.domainCards.loadout as |card|}}
|
|
||||||
{{> 'daggerheart.inventory-item-compact'
|
|
||||||
item=card
|
|
||||||
type='domainCard'
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="experience-section">
|
<div class="experience-section">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<side-line-div class="invert"></side-line-div>
|
<side-line-div class="invert"></side-line-div>
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,6 @@
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
|
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
|
||||||
<i class="fa-solid fa-fw fa-shield"></i>
|
<i class="fa-solid fa-fw fa-shield"></i>
|
||||||
</a>
|
</a>
|
||||||
{{else if (eq type 'domainCard')}}
|
|
||||||
<a data-action="toggleVault"
|
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.inVault 'sendToLoadout' 'sendToVault' }}">
|
|
||||||
<i class="fa-solid fa-fw {{ifThen item.system.inVault 'fa-arrow-up' 'fa-arrow-down'}}"></i>
|
|
||||||
</a>
|
|
||||||
{{else if (eq type 'effect')}}
|
{{else if (eq type 'effect')}}
|
||||||
<a data-action="toggleEffect"
|
<a data-action="toggleEffect"
|
||||||
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.disabled 'enableEffect' 'disableEffect' }}">
|
data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.disabled 'enableEffect' 'disableEffect' }}">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue