Skip to content

Commit

Permalink
Additions and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Dec 13, 2023
1 parent d966925 commit 66c172e
Show file tree
Hide file tree
Showing 13 changed files with 1,661 additions and 1,773 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Item Piles Changelog

## Version 2.8.7

- Added API endpoint on custom item pile types to support item & actor drag and drop fields
- Fixed flags sometimes not transferring correctly with items when added to item piles
- Minor changes to support Item Piles: Auctioneer's imminent release

## Version 2.8.6

- Fixed characters being able to buy things from merchants they could not afford
Expand Down
12 changes: 8 additions & 4 deletions src/API/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2076,8 +2076,8 @@ class API {
return PileUtilities.getActorItems(target);
}

static findSimilarItem(itemsToSearch, itemToFind) {
return Utilities.findSimilarItem(itemsToSearch, itemToFind);
static findSimilarItem(itemsToSearch, itemToFind, options = {}) {
return Utilities.findSimilarItem(itemsToSearch, itemToFind, options);
}

/**
Expand Down Expand Up @@ -2356,6 +2356,10 @@ class API {

}

static canItemFitInVault(item, vaultActor) {
return PileUtilities.canItemFitInVault(item, vaultActor);
}

static async registerItemPileType(type, label, flags = []) {
game.i18n.translations['ITEM-PILES'].Types[type] = "Custom: " + label;
CONSTANTS.CUSTOM_PILE_TYPES[type] = flags;
Expand All @@ -2365,8 +2369,8 @@ class API {
return PileUtilities.isItemInvalid(item.parent, item);
}

static canItemStack(item) {
return PileUtilities.canItemStack(item);
static canItemStack(item, actor = false) {
return PileUtilities.canItemStack(item, actor);
}

static getVaultGridData(vaultActor) {
Expand Down
8 changes: 6 additions & 2 deletions src/applications/item-pile-config/settings/custom.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@
<DropZone callback={(dropData) => handleDropData(dropData, key, data)}>
<div class="drop-item">
<img src={pileData[key]?.data?.img ?? "icons/svg/coins.svg"} class="drop-item-custom-image"/>
<span class:item-piles-clickable-link={!!pileData[key]?.data} on:click={() => { previewDocument(key); }}>
<span class:item-piles-clickable-link={!!pileData[key]?.data}
on:click={() => { previewDocument(key); }}>
{pileData[key]?.data?.name ?? "Drop item to add"}
</span>
<i
on:click|stopPropagation={() => { pileData[key] = {}; }}
on:click|stopPropagation={() => {
delete pileData[key];
pileData[key] = false;
}}
class="fas fa-times drop-item-remove item-piles-clickable-red item-piles-clickable-link"
></i>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/applications/vault-app/vault-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class VaultApp extends SvelteApplication {

}

onDropData(data) {
return this.store.onDropData(data);
}

/** @inheritdoc */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
Expand Down
23 changes: 10 additions & 13 deletions src/applications/vault-app/vault-shell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@
const hitApps = Object.values(ui.windows)
.sort((a, b) => b.position.zIndex - a.position.zIndex)
.filter(app => {
return (app instanceof ActorSheet || app instanceof ItemPileInventoryApp || app instanceof VaultApp)
&& isCoordinateWithinPosition(x, y, app.element[0].getBoundingClientRect());
});
.filter(app => isCoordinateWithinPosition(x, y, app.element[0].getBoundingClientRect()));
let dropData = {
type: "Item",
Expand All @@ -213,17 +210,18 @@
if (hitApps.length) {
if (hitApps[0] === application) return;
dropData.target = hitApps[0].actor;
if (hitApps[0] instanceof VaultApp) {
return hitApps[0].store.onDropData(dropData);
if(hitApps[0].actor) {
dropData.target = hitApps[0].actor;
}
if (hitApps[0].onDropData) {
return hitApps[0].onDropData(dropData);
}
} else {
const position = Helpers.getCanvasMouse().getLocalPosition(canvas.app.stage);
dropData.x = position.x;
dropData.y = position.y;
}
const position = Helpers.getCanvasMouse().getLocalPosition(canvas.app.stage);
dropData.x = position.x;
dropData.y = position.y;
Hooks.call("dropCanvasData", canvas, dropData);
}
Expand All @@ -238,7 +236,6 @@
const applicationHeight = application.position.stores.height;
const applicationWidth = application.position.stores.width;
const applicationLeft = application.position.stores.left;
const defaultWidth = get(application.position.stores.width);
$: {
Expand Down
41 changes: 28 additions & 13 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @module item_piles_constants */
const module_name = "item-piles";
const module_path = `modules/${module_name}/`;
const baseFlag = `flags.${module_name}.`
const baseFlag = `flags.${module_name}`

const CONSTANTS = {

Expand All @@ -11,18 +11,33 @@ const CONSTANTS = {
ACTOR_DELTA_PROPERTY: "actorData",

FLAGS: {
VERSION: baseFlag + "version",
PILE: baseFlag + "data",
ITEM: baseFlag + "item",
NO_VERSION: baseFlag + "-=version",
NO_PILE: baseFlag + "-=data",
NO_ITEM: baseFlag + "-=item",
LOG: baseFlag + "log",
SHARING: baseFlag + "sharing",
PUBLIC_TRADE_ID: baseFlag + "publicTradeId",
TRADE_USERS: baseFlag + "tradeUsers",
TEMPORARY_ITEM: baseFlag + "temporary_item",
CUSTOM_CATEGORY: baseFlag + "item.customCategory"
VERSION: `${baseFlag}.version`,
PILE: `${baseFlag}.data`,
ITEM: `${baseFlag}.item`,
NO_VERSION: `${baseFlag}.-=version`,
NO_PILE: `${baseFlag}.-=data`,
NO_ITEM: `${baseFlag}.-=item`,
LOG: `${baseFlag}.log`,
SHARING: `${baseFlag}.sharing`,
PUBLIC_TRADE_ID: `${baseFlag}.publicTradeId`,
TRADE_USERS: `${baseFlag}.tradeUsers`,
TEMPORARY_ITEM: `${baseFlag}.temporary_item`,
CUSTOM_CATEGORY: `${baseFlag}.item.customCategory`
},

SIMPLE_FLAGS: {
VERSION: `${module_name}.version`,
PILE: `${module_name}.data`,
ITEM: `${module_name}.item`,
NO_VERSION: `${module_name}.-=version`,
NO_PILE: `${module_name}.-=data`,
NO_ITEM: `${module_name}.-=item`,
LOG: `${module_name}.log`,
SHARING: `${module_name}.sharing`,
PUBLIC_TRADE_ID: `${module_name}.publicTradeId`,
TRADE_USERS: `${module_name}.tradeUsers`,
TEMPORARY_ITEM: `${module_name}.temporary_item`,
CUSTOM_CATEGORY: `${module_name}.item.customCategory`
},

ITEM_DEFAULTS: {
Expand Down
7 changes: 4 additions & 3 deletions src/helpers/compendium-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export async function initializeCompendiumCache() {
}
}

Hooks.on("updateCompendium", updateCache);

updateCache();
setTimeout(async () => {
await updateCache();
Hooks.on("updateCompendium", updateCache);
}, 250);

}

Expand Down
Loading

0 comments on commit 66c172e

Please sign in to comment.