This commit is contained in:
François-Xavier Guillois
2023-09-05 12:06:22 +02:00
parent e1238a1ad1
commit 983f856187
15 changed files with 153 additions and 145 deletions
+3 -1
View File
@@ -315,7 +315,9 @@ export class VermineActorSheet extends ActorSheet {
// Grab any data associated with this control.
const data = duplicate(header.dataset);
// Initialize a default name.
const name = `New ${type.capitalize()}`;
// const name = `New ${type.capitalize()}`;
const name = game.i18n.localize('ITEMS.new_' + type);
// Prepare the item object.
const itemData = {
name: name,
+3 -40
View File
@@ -143,20 +143,9 @@ export class VermineCharacterSheet extends VermineActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
// Add Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this));
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.items.get(li.data("itemId"));
item.delete();
li.slideUp(200, () => this.render(false));
});
// Active Effect management
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
// Add and delete Inventory Item
// already configured in parents listeners
// Rollable abilities.
html.find('.rollable').click(this._onRoll.bind(this));
@@ -189,32 +178,6 @@ export class VermineCharacterSheet extends VermineActorSheet {
}
}
/**
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
* @param {Event} event The originating click event
* @private
*/
async _onItemCreate(event) {
event.preventDefault();
const header = event.currentTarget;
// Get the type of item to create.
const type = header.dataset.type;
// Grab any data associated with this control.
const data = duplicate(header.dataset);
// Initialize a default name.
const name = `New ${type.capitalize()}`;
// Prepare the item object.
const itemData = {
name: name,
type: type,
system: data
};
// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.system["type"];
// Finally, create the item!
return await Item.create(itemData, {parent: this.actor});
}
/**
* Handle clickable rolls.
+1 -14
View File
@@ -140,20 +140,7 @@ export class VermineCreatureSheet extends ActorSheet {
// -------------------------------------------------------------
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
// Add Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this));
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.items.get(li.data("itemId"));
item.delete();
li.slideUp(200, () => this.render(false));
});
// Active Effect management
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
// Rollable abilities.
html.find('.rollable').click(this._onRoll.bind(this));
-14
View File
@@ -141,20 +141,6 @@ export class VermineNpcSheet extends VermineActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
// Add Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this));
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.items.get(li.data("itemId"));
item.delete();
li.slideUp(200, () => this.render(false));
});
// Active Effect management
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor));
// Rollable abilities.
html.find('.rollable').click(this._onRoll.bind(this));
+2 -4
View File
@@ -8,9 +8,7 @@
// Actor partials.
"systems/vermine2047/templates/actor/parts/actor-spells.html",
"systems/vermine2047/templates/actor/parts/actor-features.html",
"systems/vermine2047/templates/actor/parts/actor-spells.html",
// "systems/vermine2047/templates/actor/parts/actor-features.html",
"systems/vermine2047/templates/actor/parts/actor-id.hbs",
"systems/vermine2047/templates/actor/parts/actor-totem.hbs",
"systems/vermine2047/templates/actor/parts/character-features.hbs",
@@ -19,7 +17,7 @@
"systems/vermine2047/templates/actor/parts/actor-weapons.hbs",
"systems/vermine2047/templates/actor/parts/actor-defenses.hbs",
"systems/vermine2047/templates/actor/parts/actor-stories.hbs",
"systems/vermine2047/templates/actor/parts/actor-effects.html",
"systems/vermine2047/templates/actor/parts/actor-combat.html",
// Group partials
"systems/vermine2047/templates/actor/parts/group-header.hbs",