Skip to content

Commit

Permalink
Changelog, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Apr 11, 2024
1 parent 5b210d5 commit 231a0dd
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 124 deletions.
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Item Piles Changelog

## Version 2.9.1

- Added support for the Shadowdark system (thank you mrstarbuck007 on github!)
- Added additional settings for item types (thank you p4535992 on github!)
- Tweaked currency settings to update cached item if the currency names or images were updated
- Updated D&D4e system support (thank you EndlesNights on github!)
- Fixed Better Rolltables compatibility (thank you p4535992 on github!)
- Fixed trying to open merchant columns settings after they had broken would throw error and prevent fixing the error
- Fixed Simple Calendar integration not hiding tokens of closed merchants that were set to hide

## Version 2.9.0

- Added formal support for D&D5e 3.0.x - moving/buying/trading containers is still not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
form.requestSubmit();
}
function preventDefault(event) {
event.preventDefault();
}
</script>

<svelte:options accessors={true}/>
Expand Down
6 changes: 3 additions & 3 deletions src/applications/item-pile-config/settings/merchant.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
}
async function showMerchantColumns() {
const data = pileData.merchantColumns || [];
const data = Array.isArray(pileData.merchantColumns) ? pileData.merchantColumns : [];
return MerchantColumnsEditor.show(
data,
{ id: `merchant-columns-item-pile-config-${pileActor.id}` },
{ title: localize("ITEM-PILES.Applications.MerchantColumnsEditor.TitleActor", { actor_name: pileActor.name }), }
).then((result) => {
pileData.merchantColumns = result || [];
pileData.merchantColumns = Array.isArray(result.merchantColumns) ? result.merchantColumns : [];
});
}
Expand Down Expand Up @@ -292,7 +292,7 @@
<span>{localize("ITEM-PILES.Applications.ItemPileConfig.Merchant.HideTokenWhenClosed")}</span>
<p>{localize("ITEM-PILES.Applications.ItemPileConfig.Merchant.HideTokenWhenClosedExplanation")}</p>
</label>
<input bind:checked={pileData.openTimes.hideTokenWhenClosed} type="checkbox"/>
<input bind:checked={pileData.hideTokenWhenClosed} type="checkbox"/>
</div>
<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
.item-piles-items-list {
max-height: 500px;
overflow-y: scroll;
overflow-y: auto;
display: block;
padding-right: 5px;
Expand Down
18 changes: 14 additions & 4 deletions src/applications/settings-app/Setting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let key;
export let data;
export let disabled = false;
export let options = [];
</script>

Expand All @@ -26,7 +27,7 @@
{:else if data.choices}

<div class="choice-container">
<select name={data.key} bind:value={data.value} disabled={disabled}>
<select name={key} bind:value={data.value} disabled={disabled}>
{#each Object.entries(data.choices) as [key, choice], index (index)}
{#if data.type === Number}
<option value="{index}">{localize(choice)}</option>
Expand All @@ -52,9 +53,18 @@
{:else}

<div class="item-pile-setting-container">
<input type="text" bind:value={data.value} disabled={disabled}/>
{#if data.localize}
<input type="text" disabled value={localize(data.value)}/>

{#if options.length}
<select name="{key}" bind:value={data.value} disabled={disabled}>
{#each options as option}
<option value={option === "None" ? "" : option}>{option}</option>
{/each}
</select>
{:else}
<input type="text" bind:value={data.value} disabled={disabled}/>
{#if data.localize}
<input type="text" disabled value={localize(data.value)}/>
{/if}
{/if}
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/applications/settings-app/settings-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getActiveApps } from '../../helpers/helpers';
import SettingsShell from './settings-shell.svelte';
import SETTINGS from "../../constants/settings.js";

class SettingsApp extends SvelteApplication {
export class SettingsApp extends SvelteApplication {

static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
Expand Down Expand Up @@ -99,7 +99,7 @@ class SettingsApp extends SvelteApplication {
}
}

export default class SettingsShim extends FormApplication {
export class SettingsShim extends FormApplication {

/**
* @inheritDoc
Expand Down
19 changes: 14 additions & 5 deletions src/applications/settings-app/settings-shell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
for (let [key, setting] of settingsToUpdate) {
await helpers.setSetting(key, setting.value);
}
const currencies = settings[SETTINGS.CURRENCIES].value.concat(settings[SETTINGS.SECONDARY_CURRENCIES].value)
for (const currency of currencies) {
if (!currency.data?.uuid) continue;
const actualItem = await fromUuid(currency.data?.uuid);
await actualItem.update({
name: currency.name,
img: currency.img
});
}
application.close();
}
Expand Down Expand Up @@ -101,7 +110,7 @@
{ value: "system", label: localize("ITEM-PILES.Applications.Settings.System"), hidden: !userCanChangeSettings },
];
let activeTab = tabs[0].value;
let activeTab = application?.options?.tab ?? tabs[0].value;
</script>
Expand Down Expand Up @@ -183,13 +192,13 @@
getSettings();
}}/>
<Setting key={SETTINGS.ACTOR_CLASS_TYPE} bind:data="{settings[SETTINGS.ACTOR_CLASS_TYPE]}"
options={game.system.template.Actor.types}/>
options={["None", ...game.system.template.Actor.types]}/>
<Setting key={SETTINGS.ITEM_CLASS_LOOT_TYPE} bind:data="{settings[SETTINGS.ITEM_CLASS_LOOT_TYPE]}"
options={game.system.template.Item.types}/>
options={["None", ...game.system.template.Item.types]}/>
<Setting key={SETTINGS.ITEM_CLASS_WEAPON_TYPE} bind:data="{settings[SETTINGS.ITEM_CLASS_WEAPON_TYPE]}"
options={game.system.template.Item.types}/>
options={["None", ...game.system.template.Item.types]}/>
<Setting key={SETTINGS.ITEM_CLASS_EQUIPMENT_TYPE} bind:data="{settings[SETTINGS.ITEM_CLASS_EQUIPMENT_TYPE]}"
options={game.system.template.Item.types}/>
options={["None", ...game.system.template.Item.types]}/>
<Setting key={SETTINGS.ITEM_QUANTITY_ATTRIBUTE} bind:data="{settings[SETTINGS.ITEM_QUANTITY_ATTRIBUTE]}"/>
<Setting key={SETTINGS.ITEM_PRICE_ATTRIBUTE} bind:data="{settings[SETTINGS.ITEM_PRICE_ATTRIBUTE]}"/>
<SettingButton key={SETTINGS.CURRENCIES} bind:data="{settings[SETTINGS.CURRENCIES]}"/>
Expand Down
4 changes: 2 additions & 2 deletions src/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SETTINGS = {
ITEM_FILTERS: "itemFilters",
ACTOR_CLASS_TYPE: "actorClassType",
ITEM_CLASS_LOOT_TYPE: "itemClassLootType",
ITEM_CLASS_WEAPON_TYPE: "itemClassWeaponType",
ITEM_CLASS_WEAPON_TYPE: "itemClassWeaponType",
ITEM_CLASS_EQUIPMENT_TYPE: "itemClassEquipmentType",
ITEM_QUANTITY_ATTRIBUTE: "itemQuantityAttribute",
ITEM_PRICE_ATTRIBUTE: "itemPriceAttribute",
Expand Down Expand Up @@ -221,7 +221,7 @@ const SETTINGS = {
type: String
},

[SETTINGS.ITEM_CLASS_LOOT_TYPE]: {
[SETTINGS.ITEM_CLASS_WEAPON_TYPE]: {
name: "ITEM-PILES.Settings.ItemWeaponClass.Title",
hint: "ITEM-PILES.Settings.ItemWeaponClass.Hint",
scope: "world",
Expand Down
25 changes: 17 additions & 8 deletions src/plugins/simple-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,34 @@ export default class SimpleCalendarPlugin extends BasePlugin {

const actors = this.actors.filter((actor) => {
const pileData = PileUtilities.getActorFlagData(actor);
return pileData.hideTokenWhenClosed && PileUtilities.isMerchantClosed(actor, { pileData });
return pileData.hideTokenWhenClosed;
});

const actorTokens = actors.map(actor => actor.getActiveTokens())
const validTokensOnScenes = actors.map(actor => actor.getActiveTokens())
.deepFlatten()
.reduce((acc, token) => {
if (!acc[token.parent.id]) acc[token.parent.id] = [];
acc[token.parent.id].push(token);
const tokenDocument = token.document;
const sceneId = tokenDocument.parent.id;
if (!acc[sceneId]) acc[sceneId] = [];
acc[sceneId].push(tokenDocument);
return acc;
}, {});

const validTokensOnScenes = this.validTokensOnScenes.filter((token) => {
this.validTokensOnScenes.filter((token) => {
const pileData = PileUtilities.getActorFlagData(token);
return pileData.hideTokenWhenClosed && PileUtilities.isMerchantClosed(token, { pileData });
return pileData.hideTokenWhenClosed;
}).forEach(([sceneId, token]) => {
if (validTokensOnScenes[sceneId].length) {
if (!validTokensOnScenes[sceneId].find(t => t === token)) return;
validTokensOnScenes[sceneId].push(token)
} else {
validTokensOnScenes[sceneId] = [token]
}
});

for (const [sceneId, tokens] of validTokensOnScenes) {
for (const [sceneId, tokens] of Object.entries(validTokensOnScenes)) {
const scene = game.scenes.get(sceneId);
const updates = Object.values(tokens.concat(actorTokens).reduce((acc, token) => {
const updates = Object.values(tokens.reduce((acc, token) => {
if (!acc[token.id]) {
acc[token.id] = {
_id: token.id,
Expand Down
Loading

0 comments on commit 231a0dd

Please sign in to comment.