Add the ability to create custom items
This commit is contained in:
parent
23dd021df6
commit
83039c6144
9 changed files with 118 additions and 4 deletions
|
|
@ -84,7 +84,8 @@
|
|||
},
|
||||
"AspectSheet": "Aspect Sheet",
|
||||
"SpellSheet": "Spell Sheet",
|
||||
"PetSheet": "Pet Sheet"
|
||||
"PetSheet": "Pet Sheet",
|
||||
"CustomItemSheet": "Custom Item"
|
||||
},
|
||||
"actor": {
|
||||
"pc": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Data Models
|
||||
import { DescribedItemData } from "./models/Item/DescribedItemData.mjs";
|
||||
import { AspectItemData } from "./models/Item/Aspect.mjs";
|
||||
import { SpellItemData } from "./models/Item/Spell.mjs";
|
||||
import { PlayerData } from "./models/Actor/Player.mjs";
|
||||
|
|
@ -11,13 +12,14 @@ import { ActorHandler } from "./documents/Actor/Handler.mjs";
|
|||
import { ItemHandler } from "./documents/Item/Handler.mjs";
|
||||
|
||||
// Item Sheets
|
||||
import { SpellSheet } from "./sheets/Items/SpellSheet.mjs";
|
||||
import { CustomItemSheet } from "./sheets/Items/CustomItemSheet.mjs";
|
||||
import { AspectSheet } from "./sheets/Items/AspectSheet.mjs";
|
||||
import { SpellSheet } from "./sheets/Items/SpellSheet.mjs";
|
||||
import { PetSheet } from "./sheets/Items/PetSheet.mjs";
|
||||
|
||||
// Actor Sheets
|
||||
import { PlayerSheet } from "./sheets/PlayerSheet.mjs";
|
||||
import { BasicSyncSheet } from "./sheets/SyncVariations/BasicSyncSheet.mjs";
|
||||
import { PlayerSheet } from "./sheets/PlayerSheet.mjs";
|
||||
import { MobSheet } from "./sheets/MobSheet.mjs";
|
||||
|
||||
// Utility imports
|
||||
|
|
@ -39,6 +41,7 @@ Hooks.once(`init`, async () => {
|
|||
CONFIG.Actor.dataModels.player = PlayerData;
|
||||
CONFIG.Actor.dataModels.sync = SyncData;
|
||||
CONFIG.Actor.dataModels.mob = MobData;
|
||||
CONFIG.Item.dataModels.custom = DescribedItemData;
|
||||
CONFIG.Item.dataModels.aspect = AspectItemData;
|
||||
CONFIG.Item.dataModels.spell = SpellItemData;
|
||||
CONFIG.Item.dataModels.pet = PetItemData;
|
||||
|
|
@ -77,8 +80,12 @@ Hooks.once(`init`, async () => {
|
|||
Items.registerSheet("dotdungeon", PetSheet, {
|
||||
makeDefault: true,
|
||||
types: ["pet"],
|
||||
lable: "dotdungeon.sheet-names.PetSheet"
|
||||
label: "dotdungeon.sheet-names.PetSheet"
|
||||
});
|
||||
Items.registerSheet("dotdungeon", CustomItemSheet, {
|
||||
makeDefault: true,
|
||||
label: "dotdungeon.sheet-names.CustomItemSheet"
|
||||
})
|
||||
|
||||
|
||||
hbs.registerHandlebarsHelpers();
|
||||
|
|
|
|||
|
|
@ -4,13 +4,21 @@ export class CommonItemData extends foundry.abstract.TypeDataModel {
|
|||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
quantity: new fields.NumberField({
|
||||
initial: 1,
|
||||
min: 0,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
}),
|
||||
buy: new fields.NumberField({
|
||||
initial: null,
|
||||
nullable: true,
|
||||
integer: true,
|
||||
}),
|
||||
usage_cost: new fields.NumberField({
|
||||
initial: null,
|
||||
nullable: true,
|
||||
integer: true,
|
||||
}),
|
||||
tier: new fields.StringField({
|
||||
initial: `simple`,
|
||||
|
|
|
|||
21
module/sheets/Items/CustomItemSheet.mjs
Normal file
21
module/sheets/Items/CustomItemSheet.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { GenericItemSheet } from "./GenericItemSheet.mjs";
|
||||
|
||||
export class CustomItemSheet extends GenericItemSheet {
|
||||
static get defaultOptions() {
|
||||
let opts = mergeObject(
|
||||
super.defaultOptions,
|
||||
{
|
||||
template: `systems/dotdungeon/templates/items/custom.hbs`,
|
||||
width: 280,
|
||||
height: 340,
|
||||
}
|
||||
);
|
||||
opts.classes.push(`dotdungeon`);
|
||||
return opts;
|
||||
};
|
||||
|
||||
async getData() {
|
||||
const ctx = await super.getData();
|
||||
return ctx;
|
||||
};
|
||||
};
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
border: 2px solid black;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
height: unset;
|
||||
|
||||
&.left { text-align: left; }
|
||||
&.center { text-align: center; }
|
||||
|
|
@ -19,6 +20,10 @@
|
|||
flex-direction: row;
|
||||
align-items: center;
|
||||
transition: all ease-in-out 50ms;
|
||||
border: 2px solid black;
|
||||
border-radius: 4px;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
|
||||
&:focus-within {
|
||||
transform: scale(102%);
|
||||
|
|
@ -39,6 +44,10 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: all ease-in-out 50ms;
|
||||
border: 2px solid black;
|
||||
border-radius: 4px;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
|
||||
&:focus-within {
|
||||
transform: scale(102%);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
@use "./sheets/actor/mvp.scss";
|
||||
@use "./sheets/actor/mob/mob.scss";
|
||||
@use "./sheets/actor/sync/basic.scss";
|
||||
@use "./sheets/items/custom.scss";
|
||||
@use "./sheets/items/aspect.scss";
|
||||
@use "./sheets/items/spell.scss";
|
||||
@use "./sheets/items/pet.scss";
|
||||
16
styles/sheets/items/custom.scss
Normal file
16
styles/sheets/items/custom.scss
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
.item--custom {
|
||||
padding: 8px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: repeat(3, min-content) 1fr;
|
||||
grid-template-areas:
|
||||
"name name"
|
||||
". ."
|
||||
"usage usage"
|
||||
"description description";
|
||||
gap: 8px;
|
||||
|
||||
.name { grid-area: name; }
|
||||
.usage { grid-area: usage; }
|
||||
.description { grid-area: description; }
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
},
|
||||
"Item": {
|
||||
"types": [
|
||||
"custom",
|
||||
"aspect",
|
||||
"weapon",
|
||||
"armour",
|
||||
|
|
|
|||
50
templates/items/custom.hbs
Normal file
50
templates/items/custom.hbs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<form class="item--custom">
|
||||
<input
|
||||
type="text"
|
||||
class="masked name"
|
||||
name="name"
|
||||
value="{{item.name}}"
|
||||
>
|
||||
<label class="masked-input quantity">
|
||||
Quantity:
|
||||
<input
|
||||
type="number"
|
||||
class="right"
|
||||
name="system.quantity"
|
||||
value="{{system.quantity}}"
|
||||
>
|
||||
</label>
|
||||
<label class="masked-input cost">
|
||||
Cost:
|
||||
<input
|
||||
type="number"
|
||||
class="right"
|
||||
name="system.buy"
|
||||
value="{{system.buy}}"
|
||||
>
|
||||
</label>
|
||||
<label class="masked-input usage">
|
||||
Usage Cost:
|
||||
<input
|
||||
type="number"
|
||||
class="right"
|
||||
name="system.usage_cost"
|
||||
value="{{system.usage_cost}}"
|
||||
>
|
||||
</label>
|
||||
{{!-- <label class="masked-select tier">
|
||||
Tier:
|
||||
<select name="system.tier">
|
||||
<option value="a">Potatpo</option>
|
||||
<option value="b">Potatpo</option>
|
||||
<option value="c">Potatpo</option>
|
||||
<option value="d">Potatpo</option>
|
||||
</select>
|
||||
</label> --}}
|
||||
<label class="masked-textarea description">
|
||||
Description:
|
||||
<textarea
|
||||
name="system.description"
|
||||
>{{system.description}}</textarea>
|
||||
</label>
|
||||
</form>
|
||||
Loading…
Add table
Add a link
Reference in a new issue