Add the locations selector (closes #153)
This commit is contained in:
parent
ad2da03f1e
commit
dd5a980f4e
5 changed files with 34 additions and 14 deletions
|
|
@ -68,13 +68,20 @@
|
|||
"rare": "Rare",
|
||||
"legendary": "Legendary"
|
||||
},
|
||||
"location": {
|
||||
"unknown": "@dotdungeon.common.empty",
|
||||
"inventory": "Inventory",
|
||||
"equipped": "Equipped",
|
||||
"storage": "Storage"
|
||||
},
|
||||
"default": {
|
||||
"name": "(Unnamed @TYPES.{document}.{type})"
|
||||
},
|
||||
"common": {
|
||||
"send-to-chat": "Send to Chat",
|
||||
"edit": "Edit",
|
||||
"delete": "Delete"
|
||||
"delete": "Delete",
|
||||
"empty": "---"
|
||||
},
|
||||
"sheet-names": {
|
||||
"UntypedDataSheet": "Data Sheet"
|
||||
|
|
|
|||
|
|
@ -12,4 +12,13 @@ export class DotDungeonItem extends Item {
|
|||
};
|
||||
return this.system.quantity;
|
||||
};
|
||||
|
||||
get availableLocations() {
|
||||
return [
|
||||
{ value: null, label: `dotdungeon.location.unknown` },
|
||||
{ value: `inventory`, label: `dotdungeon.location.inventory` },
|
||||
{ value: `equipped`, label: `dotdungeon.location.equipped` },
|
||||
{ value: `storage`, label: `dotdungeon.location.storage` },
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { schemaOptions } from "./schemaOptions.mjs";
|
|||
import { createArray } from "./createArray.mjs";
|
||||
import { detailsExpanded } from "./detailsExpanded.mjs";
|
||||
import { objectValue } from "./objectValue.mjs";
|
||||
import { handlebarsLocalizer } from "../utils/localizer.mjs";
|
||||
import { handlebarsLocalizer, localizer } from "../utils/localizer.mjs";
|
||||
import { options } from "./options.mjs";
|
||||
|
||||
export default {
|
||||
|
|
@ -19,7 +19,7 @@ export default {
|
|||
"dd-stringify": v => JSON.stringify(v, null, ` `),
|
||||
"dd-empty": v => v.length == 0,
|
||||
"dd-set-has": (s, k) => s.has(k),
|
||||
"dd-empty-state": (v) => v ?? `--`,
|
||||
"dd-empty-state": (v) => v ?? localizer(`dotdungeon.common.empty`),
|
||||
|
||||
// Logic helpers
|
||||
"eq": (a, b) => a == b,
|
||||
|
|
|
|||
|
|
@ -42,16 +42,8 @@ export class CommonItemData extends foundry.abstract.TypeDataModel {
|
|||
nullable: false,
|
||||
}),
|
||||
location: new fields.StringField({
|
||||
initial: null,
|
||||
nullable: true,
|
||||
/*
|
||||
"equipped" = on player, actively having an effect (e.g. armour
|
||||
is worn, weapon is held), not all items have an equipped state
|
||||
"inventory" = on player, equivalent to being put in a backpack
|
||||
"storage" = not on player at all, in a chest in their house or
|
||||
smth, these items should be displayed in the storage tab
|
||||
*/
|
||||
choices: ["equipped", "inventory", "storage"],
|
||||
initial: "",
|
||||
nullable: false,
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,8 +53,20 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
{{#if meta.isEmbedded}}
|
||||
<div class="location panel">
|
||||
<div class="location panel--row">
|
||||
Item Location
|
||||
<div class="grow"></div>
|
||||
{{#if meta.isEditable}}
|
||||
<select
|
||||
class="text-center"
|
||||
name="system.location"
|
||||
id="{{meta.idp}}-location"
|
||||
>
|
||||
{{{ dd-options system.location item.availableLocations localize=true }}}
|
||||
</select>
|
||||
{{else}}
|
||||
{{dd-i18n (concat "dotdungeon.location." system.location)}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="quantity panel">
|
||||
Quantity
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue