mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
Level Up
This commit is contained in:
parent
c1a1e74bc4
commit
0e74ce0476
7 changed files with 99 additions and 69 deletions
|
|
@ -43,6 +43,8 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
};
|
||||
|
||||
this._dragDrop = this._createDragDropHandlers();
|
||||
|
||||
this.itemBrowser = null;
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
|
@ -503,7 +505,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null },
|
||||
};
|
||||
|
||||
return new ItemBrowser({ presets }).render({ force: true });
|
||||
return this.itemBrowser = await new ItemBrowser({ presets }).render({ force: true });
|
||||
}
|
||||
|
||||
static async viewItem(_, target) {
|
||||
|
|
@ -617,6 +619,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
}
|
||||
});
|
||||
|
||||
if(this.itemBrowser) this.itemBrowser.close();
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
|
||||
this._dragDrop = this._createDragDropHandlers();
|
||||
this.tabGroups.primary = 'advancements';
|
||||
|
||||
this.itemBrowser = null;
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
|
@ -537,13 +539,20 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
}
|
||||
};
|
||||
|
||||
// if(type == "domains")
|
||||
// presets.filter = {
|
||||
// 'level.max': { key: 'level.max', value: 1 },
|
||||
// 'system.domain': { key: 'system.domain', value: this.setup.class?.system.domains ?? null },
|
||||
// };
|
||||
if(type == "domains") {
|
||||
const domains = this.actor.system.domains,
|
||||
multiclassDomain = this.levelup.classUpgradeChoices?.multiclass?.domain;
|
||||
if (multiclassDomain) {
|
||||
if (!domains.includes(x => x === multiclassDomain))
|
||||
domains.push(multiclassDomain);
|
||||
}
|
||||
presets.filter = {
|
||||
'level.max': { key: 'level.max', value: this.levelup.currentLevel },
|
||||
'system.domain': { key: 'system.domain', value: domains },
|
||||
};
|
||||
}
|
||||
|
||||
return new ItemBrowser({ presets }).render({ force: true });
|
||||
return this.itemBrowser = await new ItemBrowser({ presets }).render({ force: true });
|
||||
}
|
||||
|
||||
static async selectPreview(_, button) {
|
||||
|
|
@ -644,6 +653,7 @@ export default class DhlevelUp extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
}, {});
|
||||
|
||||
await this.actor.levelUp(levelupData);
|
||||
if(this.itemBrowser) this.itemBrowser.close();
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
this.config = CONFIG.DH.ITEMBROWSER.compendiumConfig;
|
||||
this.presets = options.presets;
|
||||
|
||||
if(this.presets?.folder)
|
||||
if(this.presets?.compendium && this.presets?.folder)
|
||||
ItemBrowser.selectFolder.call(this, null, null, this.presets.compendium, this.presets.folder);
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
sortList: this.sortList
|
||||
},
|
||||
position: {
|
||||
top: 70,
|
||||
top: 330,
|
||||
left: 120,
|
||||
width: 800,
|
||||
height: 600
|
||||
|
|
@ -86,6 +86,23 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
}
|
||||
};
|
||||
|
||||
/** @inheritDoc */
|
||||
async _preFirstRender(context, options) {
|
||||
if(context.presets?.render?.noFolder || context.presets?.render?.lite)
|
||||
options.position.width = 600;
|
||||
|
||||
await super._preFirstRender(context, options);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _preRender(context, options) {
|
||||
|
||||
if(context.presets?.render?.noFolder || context.presets?.render?.lite)
|
||||
options.parts.splice(options.parts.indexOf('sidebar'), 1);
|
||||
|
||||
await super._preRender(context, options);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
|
@ -93,6 +110,15 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
this._createSearchFilter();
|
||||
this._createFilterInputs();
|
||||
this._createDragProcess();
|
||||
|
||||
if(context.presets?.render?.lite)
|
||||
this.element.classList.add('lite');
|
||||
|
||||
if(context.presets?.render?.noFolder)
|
||||
this.element.classList.add('no-folder');
|
||||
|
||||
if(context.presets?.render?.noFilter)
|
||||
this.element.classList.add('no-filter');
|
||||
|
||||
if(this.presets?.filter) {
|
||||
Object.entries(this.presets.filter).forEach(([k,v]) => this.fieldFilter.find(c => c.name === k).value = v.value);
|
||||
|
|
@ -129,11 +155,9 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
folder.folders = c.folders
|
||||
? ItemBrowser.sortBy(this.getCompendiumFolders(c.folders, folder, depth + 2), 'label')
|
||||
: [];
|
||||
// sortBy(Object.values(c.folders), 'label')
|
||||
folders.push(folder);
|
||||
});
|
||||
|
||||
// console.log(folders)
|
||||
return folders;
|
||||
}
|
||||
|
||||
|
|
@ -197,8 +221,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
f.choices = f.choices();
|
||||
}
|
||||
f.name ??= f.key;
|
||||
f.value = this.presets.filter?.[f.name]?.value ?? null;
|
||||
// filters.push(f);
|
||||
f.value = this.presets?.filter?.[f.name]?.value ?? null;
|
||||
});
|
||||
return filters;
|
||||
}
|
||||
|
|
@ -248,8 +271,6 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
container: '[data-application-part="list"] .filter-content .wrapper',
|
||||
content: '[data-application-part="list"] .item-list',
|
||||
callback: this._onInputFilterBrowser.bind(this)
|
||||
// target: '.filter-button',
|
||||
// filters: FilterMenu.invetoryFilters
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -283,7 +304,6 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
if (matchesSearch) this.#filteredItems.browser.search.add(item.id);
|
||||
const { input } = this.#filteredItems.browser;
|
||||
li.hidden = !(input.has(item.id) && matchesSearch);
|
||||
// li.hidden = !(matchesSearch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,10 +333,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
const { search } = this.#filteredItems.browser;
|
||||
li.hidden = !(search.has(item.id) && matchesMenu);
|
||||
// li.hidden = !(matchesMenu);
|
||||
}
|
||||
|
||||
console.log(this.fieldFilter)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -383,45 +400,22 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
itemListContainer.replaceChildren(...newOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize salient information about this Document when dragging it.
|
||||
* @returns {object} An object of drag data.
|
||||
*/
|
||||
// toDragData() {
|
||||
// const dragData = {type: this.documentName};
|
||||
// if ( this.id ) dragData.uuid = this.uuid;
|
||||
// else dragData.data = this.toObject();
|
||||
// return dragData;
|
||||
// }
|
||||
|
||||
_createDragProcess() {
|
||||
new foundry.applications.ux.DragDrop.implementation({
|
||||
dragSelector: '.item-container',
|
||||
// dropSelector: ".directory-list",
|
||||
permissions: {
|
||||
dragstart: this._canDragStart.bind(this)
|
||||
// drop: this._canDragDrop.bind(this)
|
||||
},
|
||||
callbacks: {
|
||||
// dragover: this._onDragOver.bind(this),
|
||||
dragstart: this._onDragStart.bind(this)
|
||||
// drop: this._onDrop.bind(this)
|
||||
}
|
||||
}).bind(this.element);
|
||||
// this.element.querySelectorAll(".directory-item.folder").forEach(folder => {
|
||||
// folder.addEventListener("dragenter", this._onDragHighlight.bind(this));
|
||||
// folder.addEventListener("dragleave", this._onDragHighlight.bind(this));
|
||||
// });
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
// console.log(event)
|
||||
// ui.context?.close({ animate: false });
|
||||
const { itemUuid } = event.target.closest('[data-item-uuid]').dataset,
|
||||
item = await foundry.utils.fromUuid(itemUuid),
|
||||
dragData = item.toDragData();
|
||||
// console.log(dragData)
|
||||
// const dragData = { UUID: itemUuid };
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,6 +242,10 @@
|
|||
border-radius: 6px;
|
||||
min-height: 30px;
|
||||
|
||||
> * {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
div[data-sort-key] {
|
||||
&:after {
|
||||
font-family: "Font Awesome 6 Pro";
|
||||
|
|
@ -272,6 +276,8 @@
|
|||
.item-desc .wrapper {
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
img {
|
||||
|
|
@ -328,6 +334,7 @@
|
|||
.title {
|
||||
font-family: @font-subtitle;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.hint {
|
||||
font-family: @font-body;
|
||||
|
|
@ -339,4 +346,24 @@
|
|||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.lite, &.no-folder {
|
||||
.menu-path {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.lite {
|
||||
.filter-header {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.no-filter {
|
||||
.filter-header {
|
||||
a[data-action="expandContent"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Parameters:
|
|||
<legend>
|
||||
{{localize title}}
|
||||
{{#if canCreate}}
|
||||
<a data-action="addNewItem" data-document-class="{{ifThen (eq type 'effect') 'ActiveEffect' 'Item' }}"
|
||||
<a data-action="{{ifThen (or (eq type 'effect') (eq type 'feature')) 'createDoc' 'addNewItem' }}" data-document-class="{{ifThen (eq type 'effect') 'ActiveEffect' 'Item' }}"
|
||||
data-type="{{ifThen (eq type 'effect') 'base' type}}"
|
||||
{{#if inVault}}data-in-vault="{{inVault}}"{{/if}}
|
||||
{{#if disabled}} data-disabled="{{disabled}}"{{/if}}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,29 @@
|
|||
<div class="compendium-results">
|
||||
{{#if menu.data }}
|
||||
{{#unless (or presets.render.lite presets.render.noFolder)}}
|
||||
<div class="menu-path">
|
||||
{{#each menu.path}}
|
||||
{{#if (eq this "folders")}}
|
||||
<span class="path-link">
|
||||
/
|
||||
</span>
|
||||
{{else}}
|
||||
<span class="item-path">{{this}}</span>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/unless}}
|
||||
<div class="menu-path">
|
||||
{{#each menu.path}}
|
||||
{{#if (eq this "folders")}}
|
||||
<span class="path-link">
|
||||
/
|
||||
</span>
|
||||
{{else}}
|
||||
<span class="item-path">{{this}}</span>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="item-filter">
|
||||
{{#unless presets.render.lite}}
|
||||
<div class="filter-header">
|
||||
<div class="search-bar">
|
||||
<div class="icon">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</div>
|
||||
<input type="search" name="search" class="search-input" placeholder="Search...">
|
||||
<div class="filter-header">
|
||||
<div class="search-bar">
|
||||
<div class="icon">
|
||||
<i class="fa-solid fa-magnifying-glass"></i>
|
||||
</div>
|
||||
{{#if (and fieldFilter (not presets.render.noFilter))}}
|
||||
<a data-tooltip="Filters" data-action="expandContent"><i class="fa-solid fa-filter"></i></a>
|
||||
{{/if}}
|
||||
<a data-tooltip="Erase" data-action="resetFilters"><i class="fa-solid fa-eraser"></i></a>
|
||||
<input type="search" name="search" class="search-input" placeholder="Search...">
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{#if fieldFilter.length}}
|
||||
<a data-tooltip="Filters" data-action="expandContent"><i class="fa-solid fa-filter"></i></a>
|
||||
{{/if}}
|
||||
<a data-tooltip="Erase" data-action="resetFilters"><i class="fa-solid fa-eraser"></i></a>
|
||||
</div>
|
||||
<div class="filter-content extensible">
|
||||
<div class="wrapper">
|
||||
{{#each fieldFilter}}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="compendium-sidebar" {{#if (or presets.render.lite presets.render.noFolder)}}style="display: none;"{{/if}}>
|
||||
<div class="compendium-sidebar">
|
||||
{{#each compendiums}}
|
||||
<details class="compendium-container" data-compendium-id="{{id}}" open>
|
||||
<summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue