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",
|
"rare": "Rare",
|
||||||
"legendary": "Legendary"
|
"legendary": "Legendary"
|
||||||
},
|
},
|
||||||
|
"location": {
|
||||||
|
"unknown": "@dotdungeon.common.empty",
|
||||||
|
"inventory": "Inventory",
|
||||||
|
"equipped": "Equipped",
|
||||||
|
"storage": "Storage"
|
||||||
|
},
|
||||||
"default": {
|
"default": {
|
||||||
"name": "(Unnamed @TYPES.{document}.{type})"
|
"name": "(Unnamed @TYPES.{document}.{type})"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"send-to-chat": "Send to Chat",
|
"send-to-chat": "Send to Chat",
|
||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"delete": "Delete"
|
"delete": "Delete",
|
||||||
|
"empty": "---"
|
||||||
},
|
},
|
||||||
"sheet-names": {
|
"sheet-names": {
|
||||||
"UntypedDataSheet": "Data Sheet"
|
"UntypedDataSheet": "Data Sheet"
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,13 @@ export class DotDungeonItem extends Item {
|
||||||
};
|
};
|
||||||
return this.system.quantity;
|
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 { createArray } from "./createArray.mjs";
|
||||||
import { detailsExpanded } from "./detailsExpanded.mjs";
|
import { detailsExpanded } from "./detailsExpanded.mjs";
|
||||||
import { objectValue } from "./objectValue.mjs";
|
import { objectValue } from "./objectValue.mjs";
|
||||||
import { handlebarsLocalizer } from "../utils/localizer.mjs";
|
import { handlebarsLocalizer, localizer } from "../utils/localizer.mjs";
|
||||||
import { options } from "./options.mjs";
|
import { options } from "./options.mjs";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -19,7 +19,7 @@ export default {
|
||||||
"dd-stringify": v => JSON.stringify(v, null, ` `),
|
"dd-stringify": v => JSON.stringify(v, null, ` `),
|
||||||
"dd-empty": v => v.length == 0,
|
"dd-empty": v => v.length == 0,
|
||||||
"dd-set-has": (s, k) => s.has(k),
|
"dd-set-has": (s, k) => s.has(k),
|
||||||
"dd-empty-state": (v) => v ?? `--`,
|
"dd-empty-state": (v) => v ?? localizer(`dotdungeon.common.empty`),
|
||||||
|
|
||||||
// Logic helpers
|
// Logic helpers
|
||||||
"eq": (a, b) => a == b,
|
"eq": (a, b) => a == b,
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,8 @@ export class CommonItemData extends foundry.abstract.TypeDataModel {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
}),
|
}),
|
||||||
location: new fields.StringField({
|
location: new fields.StringField({
|
||||||
initial: null,
|
initial: "",
|
||||||
nullable: true,
|
nullable: false,
|
||||||
/*
|
|
||||||
"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"],
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,20 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{#if meta.isEmbedded}}
|
{{#if meta.isEmbedded}}
|
||||||
<div class="location panel">
|
<div class="location panel--row">
|
||||||
Item Location
|
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>
|
||||||
<div class="quantity panel">
|
<div class="quantity panel">
|
||||||
Quantity
|
Quantity
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue