Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Sep 16, 2024
1 parent 23d4306 commit 16a2cb0
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 166 deletions.
86 changes: 61 additions & 25 deletions changelog.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@
"Title": "Editovat měny",
"Content": "Jako GM můžete aktualizovat měny v této kupě položek:",
"Secondary": "Sekundární měny:",
"NoCurrency": "{actor_name} nemá žádnou platnou měnu...",
"Submit": "Potvrdit"
},
"DropCurrencies": {
Expand Down Expand Up @@ -863,4 +864,4 @@
"Deposit": "{actor_name} ({user_name}) *uložil* {item_name} x {quantity} ({date})"
}
}
}
}
3 changes: 2 additions & 1 deletion languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@
"Title": "Währungen anpassen",
"Content": "Als SL kannst du die Währungen dieses Stapels anpassen:",
"Submit": "Speichern",
"NoCurrency": "{actor_name} besitzt keine validen Währungen...",
"Secondary": "Sekundärwährungen:"
},
"CustomItemCategoriesEditor": {
Expand Down Expand Up @@ -1090,4 +1091,4 @@
"Withdraw": "{actor_name} ({user_name}) **entnahm** {item_name} x {quantity} ({date})"
}
}
}
}
4 changes: 3 additions & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"Currency": "Currency",
"ContextMenu": {
"ShowToPlayers": "Show To Players",
"RequestTrade": "Request Trade"
"RequestTrade": "Request Trade",
"GiveToCharacter": "Give To Character"
},
"PlayerList": {
"TradeButton": "Trade"
Expand Down Expand Up @@ -359,6 +360,7 @@
"Title": "Editing Currencies",
"Content": "As a GM, you can update the currencies on this item pile:",
"Secondary": "Secondary Currencies:",
"NoCurrency": "{actor_name} has no valid currencies...",
"Submit": "Submit"
},
"DropCurrencies": {
Expand Down
3 changes: 2 additions & 1 deletion languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@
"Content": "En tant que MJ, vous pouvez mettre à jour les devises de cette pile d'objets :",
"Submit": "Soumettre",
"Title": "Modifier les devises",
"NoCurrency": "{actor_name} n'a pas de devises valables...",
"Secondary": "Devises secondaires :"
},
"CustomItemCategoriesEditor": {
Expand Down Expand Up @@ -1106,4 +1107,4 @@
"Deposit": "{actor_name} ({user_name}) *a déposé* {item_name} x {quantity} ({date})"
}
}
}
}
3 changes: 2 additions & 1 deletion languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@
"Submit": "送信",
"Title": "通貨を編集",
"Content": "GMとして、このアイテムの山の金額を更新できます:",
"NoCurrency": "{actor_name}には有効な硬貨がありません...",
"Secondary": "補助通貨:"
},
"WithdrawItem": {
Expand Down Expand Up @@ -1042,4 +1043,4 @@
"Deposit": "{actor_name}({user_name})が{item_name} x {quantity}を預けました({date})"
}
}
}
}
1 change: 1 addition & 0 deletions languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"Title": "Edycja walut",
"Content": "Jako GM możesz zaktualizować waluty na tym stosie przedmiotów:",
"Submit": "Wyślij",
"NoCurrency": "{aktor_name} nie ma ważnych walut...",
"Secondary": "Waluty dodatkowe:"
},
"TradeMerchantItem": {
Expand Down
1 change: 1 addition & 0 deletions languages/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
"Title": "Editando Moedas",
"Content": "Como MJ, você pode atualizar as moedas nesta pilha de itens:",
"Secondary": "Moedas Secundárias:",
"NoCurrency": "{actor_name} não tem moedas válidas.",
"Submit": "Enviar"
},
"DropCurrencies": {
Expand Down
3 changes: 2 additions & 1 deletion languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"Title": "Редактирование денег",
"Content": "Как ГМ, вы можете обновить валюты в этой добыче:",
"Secondary": "Вторичные монеты:",
"NoCurrency": "У {actor_name} нет денег...",
"Submit": "Принять"
},
"DropCurrencies": {
Expand Down Expand Up @@ -922,4 +923,4 @@
}
}
}
}
}
3 changes: 2 additions & 1 deletion languages/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@
"Title": "编辑货币",
"Content": "作为 GM,你可以在这个物品堆上更新货币:",
"Submit": "提交",
"NoCurrency": "{actor_name} 没有可用的货币…",
"Secondary": "次要货币:"
},
"UnstackableItemTypesEditor": {
Expand Down Expand Up @@ -910,4 +911,4 @@
"Withdraw": "{actor_name} ({user_name}) **取出了** {item_name} x {quantity} ({date})"
}
}
}
}
13 changes: 2 additions & 11 deletions src/API/private-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ReceiveItemsShell from "../applications/dialogs/receive-items-dialog/rece
import BankVaultApp from "../applications/vault-app/vault-app.js";
import { hotkeyActionState } from "../hotkeys.js";
import { ensureValidIds } from "../helpers/utilities.js";
import { getPileActorDefaults } from "../helpers/pile-utilities.js";

const preloadedFiles = new Set();

Expand Down Expand Up @@ -1211,17 +1212,7 @@ export default class PrivateAPI {

if (createActor) {

const defaultItemPileId = Helpers.getSetting(SETTINGS.DEFAULT_ITEM_PILE_ACTOR_ID);
const defaultItemPileActor = game.actors.get(defaultItemPileId);

let pileDataDefaults = foundry.utils.deepClone(CONSTANTS.PILE_DEFAULTS);
pileDataDefaults.enabled = true;
if (foundry.utils.isEmpty(itemPileFlags) && defaultItemPileActor) {
const defaultItemPileSettings = PileUtilities.getActorFlagData(defaultItemPileActor);
itemPileFlags = foundry.utils.mergeObject(pileDataDefaults, defaultItemPileSettings);
}

pileDataDefaults = foundry.utils.mergeObject(pileDataDefaults, itemPileFlags);
const pileDataDefaults = PileUtilities.getPileActorDefaults({ ...itemPileFlags, enabled: true });

const actorData = {
name: actor || "New Item Pile", type: Helpers.getSetting("actorClassType"), img: "icons/svg/item-bag.svg"
Expand Down
7 changes: 6 additions & 1 deletion src/applications/item-pile-config/item-pile-config.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
let form;
let pileData = PileUtilities.getActorFlagData(pileActor);
let pileData = PileUtilities.getActorFlagData(pileActor, { useDefaults: false });
if (foundry.utils.isEmpty(pileData)) {
pileData = PileUtilities.getPileActorDefaults();
} else {
pileData = PileUtilities.getActorFlagData(pileActor);
}
if (typeof pileData?.deleteWhenEmpty === "boolean") {
pileData.deleteWhenEmpty = !!pileData?.deleteWhenEmpty;
Expand Down
13 changes: 13 additions & 0 deletions src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ export function getPileDefaults() {
return foundry.utils.mergeObject({}, CONSTANTS.PILE_DEFAULTS, Helpers.getSetting(SETTINGS.PILE_DEFAULTS) ?? {});
}

export function getPileActorDefaults(itemPileFlags = {}) {
const defaultItemPileId = Helpers.getSetting(SETTINGS.DEFAULT_ITEM_PILE_ACTOR_ID);
const defaultItemPileActor = game.actors.get(defaultItemPileId);

let pileDataDefaults = foundry.utils.deepClone(CONSTANTS.PILE_DEFAULTS);
if (foundry.utils.isEmpty(itemPileFlags) && defaultItemPileActor) {
const defaultItemPileSettings = getActorFlagData(defaultItemPileActor);
itemPileFlags = foundry.utils.mergeObject(pileDataDefaults, defaultItemPileSettings);
}

return foundry.utils.mergeObject(pileDataDefaults, itemPileFlags);
}

function getFlagData(inDocument, flag, defaults, existing = false) {
const defaultFlags = foundry.utils.deepClone(defaults);
let flags = foundry.utils.deepClone(existing || (foundry.utils.getProperty(inDocument, flag) ?? {}));
Expand Down
1 change: 1 addition & 0 deletions src/helpers/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ export async function createFoldersFromNames(folders, type = "Actor") {
if (!actualFolder) {
const folderData = { name: folder, type, sorting: 'a' };
if (lastFolder) {
folderData.folder = lastFolder.id;
folderData.parent = lastFolder.id;
}
actualFolder = await Folder.create(folderData);
Expand Down
2 changes: 1 addition & 1 deletion src/systems/dnd5e-2.4.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default {

Hooks.on("dnd5e.getItemContextOptions", (item, options) => {
options.push({
name: "Give to character",
name: game.i18n.localize("ITEM-PILES.ContextMenu.GiveToCharacter"),
icon: "<i class='fa fa-user'></i>",
callback: async () => {
const result = await GiveItems.show(item);
Expand Down
2 changes: 1 addition & 1 deletion src/systems/dnd5e-3.1.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export default {

Hooks.on("dnd5e.getItemContextOptions", (item, options) => {
options.push({
name: "Give to character",
name: game.i18n.localize("ITEM-PILES.ContextMenu.GiveToCharacter"),
icon: "<i class='fa fa-user'></i>",
callback: async () => {
const result = await GiveItems.show(item);
Expand Down
2 changes: 1 addition & 1 deletion src/systems/dnd5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default {

Hooks.on("dnd5e.getItemContextOptions", (item, options) => {
options.push({
name: "Give to character",
name: game.i18n.localize("ITEM-PILES.ContextMenu.GiveToCharacter"),
icon: "<i class='fa fa-user'></i>",
callback: async () => {
const result = await GiveItems.show(item);
Expand Down
Loading

0 comments on commit 16a2cb0

Please sign in to comment.