Nouvelles corrections sur la fiche
This commit is contained in:
@@ -80,6 +80,9 @@
|
||||
"AWEMMY.Character.Notes": "Notes",
|
||||
"AWEMMY.Character.Pronouns": "Pronouns",
|
||||
"AWEMMY.Character.Specialization": "Specialization",
|
||||
"AWEMMY.Character.DropField": "Drag & drop a Field item here",
|
||||
"AWEMMY.Character.DropArchetype": "Drag & drop Archetype items here",
|
||||
"AWEMMY.Character.DropBackground": "Drag & drop a Background item here",
|
||||
"AWEMMY.Creature.EurekaRubric": "Eureka Rubric",
|
||||
"AWEMMY.Creature.Claims": "Claims",
|
||||
"AWEMMY.Creature.Evidence": "Evidence",
|
||||
|
||||
@@ -146,6 +146,15 @@ export default class AwEActorSheet extends HandlebarsApplicationMixin(foundry.ap
|
||||
*/
|
||||
_onDragStart(event) {
|
||||
if ("link" in event.target.dataset) return
|
||||
const el = event.currentTarget
|
||||
const itemId = el.dataset.itemId
|
||||
const itemUuid = el.dataset.itemUuid
|
||||
if (!itemUuid && !itemId) return
|
||||
const item = itemUuid
|
||||
? fromUuidSync(itemUuid)
|
||||
: this.document.items.get(itemId)
|
||||
if (!item) return
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify({ type: "Item", uuid: item.uuid }))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,6 +83,9 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.fields = doc.itemTypes.field
|
||||
context.archetypes = doc.itemTypes.archetype
|
||||
context.backgrounds = doc.itemTypes.background
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.description, { async: true }
|
||||
)
|
||||
@@ -102,7 +105,7 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
|
||||
/** @override */
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
if (!this.isEditable) return
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
if (data.type === "Item") {
|
||||
const item = await fromUuid(data.uuid)
|
||||
@@ -110,13 +113,29 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _onDropItem(item) {
|
||||
if (!item) return
|
||||
// field/background: max 1 (replace existing); archetype: multiple allowed
|
||||
if (item.type === "field" || item.type === "background") {
|
||||
const existing = this.document.itemTypes[item.type]
|
||||
if (existing.length > 0) await existing[0].delete()
|
||||
return this.document.createEmbeddedDocuments("Item", [item.toObject()])
|
||||
}
|
||||
if (item.type === "archetype") {
|
||||
return this.document.createEmbeddedDocuments("Item", [item.toObject()])
|
||||
}
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ability item.
|
||||
* @param {Event} event - The triggering event.
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateAbility(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Ability", type: "ability" }])
|
||||
const type = "ability"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +144,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Weapon", type: "weapon" }])
|
||||
const type = "weapon"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +154,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateKit(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Kit", type: "kit" }])
|
||||
const type = "kit"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +164,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Equipment", type: "equipment" }])
|
||||
const type = "equipment"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,4 +3,10 @@ export default class AwEItem extends Item {
|
||||
prepareData() {
|
||||
super.prepareData()
|
||||
}
|
||||
|
||||
/** Return "New Ability", "New Weapon", etc. based on item type. */
|
||||
static defaultName(context = {}) {
|
||||
const typeLabel = game.i18n.localize(CONFIG.Item.typeLabels[context.type] ?? "Item")
|
||||
return `New ${typeLabel}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ export default class AwECharacter extends foundry.abstract.TypeDataModel {
|
||||
|
||||
// Identity
|
||||
schema.pronouns = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
schema.fieldName = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
schema.specialization = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
schema.archetypeName = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
schema.backgroundName = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
|
||||
// Core stats
|
||||
schema.level = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1, max: 10,
|
||||
|
||||
@@ -6,22 +6,58 @@
|
||||
<label>{{localize "AWEMMY.Character.Pronouns"}}</label>
|
||||
{{formInput systemFields.pronouns value=system.pronouns disabled=isPlayMode}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{localize "AWEMMY.Character.Field"}}</label>
|
||||
{{formInput systemFields.fieldName value=system.fieldName disabled=isPlayMode}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{localize "AWEMMY.Character.Specialization"}}</label>
|
||||
{{formInput systemFields.specialization value=system.specialization disabled=isPlayMode}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{localize "AWEMMY.Item.Archetype"}}</label>
|
||||
{{formInput systemFields.archetypeName value=system.archetypeName disabled=isPlayMode}}
|
||||
</fieldset>
|
||||
|
||||
<!-- Field (max 1) -->
|
||||
<fieldset class="items-list-fieldset">
|
||||
<legend>{{localize "AWEMMY.Item.Field"}}</legend>
|
||||
{{#each fields}}
|
||||
<div class="item-row" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-drag="true">
|
||||
<img src="{{img}}" class="item-img" alt="{{name}}" />
|
||||
<span class="item-name">{{name}}</span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control" data-action="edit" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Edit"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control" data-action="delete" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Delete"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{localize "AWEMMY.Item.Background"}}</label>
|
||||
{{formInput systemFields.backgroundName value=system.backgroundName disabled=isPlayMode}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#unless fields.length}}<div class="item-row item-empty"><em>{{localize "AWEMMY.Character.DropField"}}</em></div>{{/unless}}
|
||||
</fieldset>
|
||||
|
||||
<!-- Archetypes (multiple) -->
|
||||
<fieldset class="items-list-fieldset">
|
||||
<legend>{{localize "AWEMMY.Item.Archetype"}}</legend>
|
||||
{{#each archetypes}}
|
||||
<div class="item-row" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-drag="true">
|
||||
<img src="{{img}}" class="item-img" alt="{{name}}" />
|
||||
<span class="item-name">{{name}}</span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control" data-action="edit" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Edit"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control" data-action="delete" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Delete"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#unless archetypes.length}}<div class="item-row item-empty"><em>{{localize "AWEMMY.Character.DropArchetype"}}</em></div>{{/unless}}
|
||||
</fieldset>
|
||||
|
||||
<!-- Background (max 1) -->
|
||||
<fieldset class="items-list-fieldset">
|
||||
<legend>{{localize "AWEMMY.Item.Background"}}</legend>
|
||||
{{#each backgrounds}}
|
||||
<div class="item-row" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-drag="true">
|
||||
<img src="{{img}}" class="item-img" alt="{{name}}" />
|
||||
<span class="item-name">{{name}}</span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control" data-action="edit" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Edit"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control" data-action="delete" data-item-id="{{id}}" data-item-uuid="{{uuid}}" data-tooltip="Delete"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#unless backgrounds.length}}<div class="item-row item-empty"><em>{{localize "AWEMMY.Character.DropBackground"}}</em></div>{{/unless}}
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@@ -47,3 +83,4 @@
|
||||
</fieldset>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<legend>{{localize "AWEMMY.Item.Kit"}}</legend>
|
||||
<div class="item-list">
|
||||
{{#each kits as |item|}}
|
||||
<div class="item-row" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<div class="item-row" data-drag="true" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
|
||||
<div class="item-name">{{item.name}}</div>
|
||||
<div class="item-charges">{{item.system.charges.value}}/{{item.system.charges.max}}</div>
|
||||
@@ -30,7 +30,7 @@
|
||||
<legend>{{localize "AWEMMY.Item.Weapon"}}</legend>
|
||||
<div class="item-list">
|
||||
{{#each weapons as |item|}}
|
||||
<div class="item-row" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<div class="item-row" data-drag="true" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
|
||||
<div class="item-name">{{item.name}}</div>
|
||||
<div class="item-damage">{{item.system.damageFormula}} ({{item.system.damageType}})</div>
|
||||
@@ -56,7 +56,7 @@
|
||||
<legend>{{localize "AWEMMY.Item.Equipment"}}</legend>
|
||||
<div class="item-list">
|
||||
{{#each equipments as |item|}}
|
||||
<div class="item-row" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<div class="item-row" data-drag="true" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
|
||||
<div class="item-name">{{item.name}}</div>
|
||||
<div class="item-qty">x{{item.system.quantity}}</div>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<legend>{{localize "AWEMMY.Item.Ability"}}</legend>
|
||||
<div class="item-list">
|
||||
{{#each abilities as |item|}}
|
||||
<div class="item-row" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<div class="item-row" data-drag="true" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
|
||||
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
|
||||
<div class="item-name">{{item.name}}</div>
|
||||
<div class="item-cost">{{item.costLabel}}</div>
|
||||
|
||||
Reference in New Issue
Block a user