Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Feb 1, 2022
1 parent d703d5c commit 440bf93
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Item Piles Changelog

## Version 1.3.1
- Fixed `ItemPiles.API.turnTokensIntoItemPiles` failing to turn tokens into item piles
- Fixed module throwing errors in v8 regarding the actor sidebar
- Fixed some Item Pile interfaces lacking styling elements in v8

## Version 1.3.0
- Added item pile currency and/or item splitting capabilities
- Added chat message when currency and/or items are split between players
Expand Down
25 changes: 23 additions & 2 deletions scripts/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default class API {
static async _turnTokensIntoItemPiles(targetUuids, pileSettings = {}, tokenSettings = {}) {

const tokenUpdateGroups = {};
const actorUpdateGroups = {};
const defaults = foundry.utils.duplicate(CONSTANTS.PILE_DEFAULTS);

for(const targetUuid of targetUuids) {
Expand All @@ -196,8 +197,8 @@ export default class API {
pileSettings = foundry.utils.mergeObject(existingPileSettings, pileSettings);
pileSettings.enabled = true;

const targetItems = lib.getActorItems(target, pileSettings);
const targetCurrencies = lib.getActorCurrencies(target, pileSettings);
const targetItems = lib.getActorItems(target, pileSettings.overrideItemFilters);
const targetCurrencies = lib.getActorCurrencies(target, pileSettings.overrideCurrencies);

const data = { data: pileSettings, items: targetItems, currencies: targetCurrencies };

Expand All @@ -221,8 +222,17 @@ export default class API {
[`actorData.flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: pileSettings
});

if(target.isLinked){
if(actorUpdateGroups[target.actor.id]) continue;
actorUpdateGroups[target.actor.id] = {
"_id": target.actor.id,
[`flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: pileSettings
}
}
}

await Actor.updateDocuments(Object.values(actorUpdateGroups));

for(const [sceneId, updateData] of Object.entries(tokenUpdateGroups)){
const scene = game.scenes.get(sceneId);
await scene.updateEmbeddedDocuments("Token", updateData);
Expand Down Expand Up @@ -267,6 +277,7 @@ export default class API {
*/
static async _revertTokensFromItemPiles(targetUuids, tokenSettings) {

const actorUpdateGroups = {};
const tokenUpdateGroups = {};
const defaults = foundry.utils.duplicate(CONSTANTS.PILE_DEFAULTS);

Expand All @@ -291,8 +302,18 @@ export default class API {
[`actorData.flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: pileSettings
});

if(target.isLinked){
if(actorUpdateGroups[target.actor.id]) continue;
actorUpdateGroups[target.actor.id] = {
"_id": target.actor.id,
[`flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: pileSettings
}
}

}

await Actor.updateDocuments(Object.values(actorUpdateGroups));

for(const [sceneId, updateData] of Object.entries(tokenUpdateGroups)){
const scene = game.scenes.get(sceneId);
await scene.updateEmbeddedDocuments("Token", updateData);
Expand Down
4 changes: 1 addition & 3 deletions scripts/lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ export async function updateItemPileData(target, flagData, tokenData){

return documentActor.update({
[`flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: flagData,
"token": {
[`flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: flagData,
}
[`token.flags.${CONSTANTS.MODULE_NAME}.${CONSTANTS.PILE_DATA}`]: flagData
});

}
Expand Down
5 changes: 4 additions & 1 deletion scripts/libwrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import API from "./api.js";
import CONSTANTS from "./constants.js";
import { hotkeyActionState } from "./hotkeys.js";
import { ItemPileInventory } from "./formapplications/itemPileInventory.js";
import * as lib from "./lib/lib.js";

export function registerLibwrappers() {

Expand All @@ -12,7 +13,9 @@ export function registerLibwrappers() {
return wrapped(...args);
});

libWrapper.register(CONSTANTS.MODULE_NAME, 'SidebarDirectory.prototype._onClickDocumentName', function (wrapped, event) {
const actorSidebarMethodName = lib.isVersion9() ? "_onClickDocumentName" : "_onClickEntityName";

libWrapper.register(CONSTANTS.MODULE_NAME, `SidebarDirectory.prototype.${actorSidebarMethodName}`, function (wrapped, event) {

event.preventDefault();
const element = event.currentTarget;
Expand Down
20 changes: 10 additions & 10 deletions styles/module.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions styles/module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

&-highlight {
color: var(--color-text-hyperlink);
color: var(--color-text-hyperlink, #ff6400);
text-decoration: underline;
}

Expand Down Expand Up @@ -68,7 +68,7 @@
}

&-odd-color:nth-child(even) {
background-color: var(--color-text-light-highlight);
background-color: var(--color-text-light-highlight, #f0f0e0);
}

&-bottom-divider{
Expand All @@ -78,7 +78,7 @@
}

&-disabled {
background-color: var(--color-bg-btn-minor-inactive)
background-color: var(--color-bg-btn-minor-inactive, #c9c7b8)
}

}
Expand Down Expand Up @@ -127,11 +127,11 @@
border-radius: 4px;

&:nth-child(even):not(.item-piles-disabled) {
background-color: var(--color-text-light-highlight);
background-color: var(--color-text-light-highlight, #f0f0e0);
}

.item-piles-disabled {
background-color: var(--color-bg-btn-minor-inactive)
background-color: var(--color-bg-btn-minor-inactive, #c9c7b8)
}

div {
Expand Down Expand Up @@ -211,7 +211,7 @@
.sheet-navigation {
margin-bottom: 0.5rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--color-border-light-primary);
border-bottom: 1px solid var(--color-border-light-primary, #b5b3a4);
}

.item-piles-sections {
Expand All @@ -227,15 +227,15 @@
color: var(--color-text-dark-secondary);
padding-right: 1rem;
margin-top: 0;
overflow-y: scroll;
overflow-y: hidden;
}

.item-piles-collapsible {

&:not(:last-child) {
margin-bottom: 0.75rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--color-border-light-primary);
border-bottom: 1px solid var(--color-border-light-primary, #b5b3a4);
}

& > summary {
Expand Down Expand Up @@ -265,7 +265,7 @@
footer {
margin-top: 0.5rem;
padding-top: 0.5rem;
border-top: 1px solid var(--color-border-light-primary);
border-top: 1px solid var(--color-border-light-primary, #b5b3a4);
}

}
Expand Down Expand Up @@ -312,7 +312,7 @@
align-items: center;

&:nth-child(odd) {
background-color: var(--color-text-light-highlight);
background-color: var(--color-text-light-highlight, #f0f0e0);
}

img {
Expand Down

0 comments on commit 440bf93

Please sign in to comment.