Initial import
This commit is contained in:
136
module/applications/sheets/character-sheet.mjs
Normal file
136
module/applications/sheets/character-sheet.mjs
Normal file
@@ -0,0 +1,136 @@
|
||||
import OathHammerActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["character"],
|
||||
position: {
|
||||
width: 972,
|
||||
height: 780,
|
||||
},
|
||||
window: {
|
||||
contentClasses: ["character-content"],
|
||||
},
|
||||
actions: {
|
||||
createWeapon: OathHammerCharacterSheet.#onCreateWeapon,
|
||||
createSpell: OathHammerCharacterSheet.#onCreateSpell,
|
||||
createMiracle: OathHammerCharacterSheet.#onCreateMiracle,
|
||||
createEquipment: OathHammerCharacterSheet.#onCreateEquipment,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-sheet.hbs",
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
identity: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-identity.hbs",
|
||||
},
|
||||
combat: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-combat.hbs",
|
||||
},
|
||||
magic: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-magic.hbs",
|
||||
},
|
||||
equipment: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-equipment.hbs",
|
||||
},
|
||||
notes: {
|
||||
template: "systems/fvtt-oath-hammer/templates/actor/character-notes.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = {
|
||||
sheet: "identity",
|
||||
}
|
||||
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
identity: { id: "identity", group: "sheet", icon: "fa-solid fa-person", label: "OATHHAMMER.Tab.Identity" },
|
||||
combat: { id: "combat", group: "sheet", icon: "fa-solid fa-swords", label: "OATHHAMMER.Tab.Combat" },
|
||||
magic: { id: "magic", group: "sheet", icon: "fa-solid fa-wand-magic-sparkles", label: "OATHHAMMER.Tab.Magic" },
|
||||
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-backpack", label: "OATHHAMMER.Tab.Equipment" },
|
||||
notes: { id: "notes", group: "sheet", icon: "fa-solid fa-book", label: "OATHHAMMER.Tab.Notes" },
|
||||
}
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
v.cssClass = v.active ? "active" : ""
|
||||
}
|
||||
return tabs
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
return context
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
break
|
||||
case "identity":
|
||||
context.tab = context.tabs.identity
|
||||
context.abilities = doc.itemTypes.ability
|
||||
context.oaths = doc.itemTypes.oath
|
||||
break
|
||||
case "combat":
|
||||
context.tab = context.tabs.combat
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
context.armors = doc.itemTypes.armor
|
||||
context.shields = doc.itemTypes.shield
|
||||
context.ammunition = doc.itemTypes.ammunition
|
||||
break
|
||||
case "magic":
|
||||
context.tab = context.tabs.magic
|
||||
context.spells = doc.itemTypes.spell
|
||||
context.miracles = doc.itemTypes.miracle
|
||||
break
|
||||
case "equipment":
|
||||
context.tab = context.tabs.equipment
|
||||
context.equipment = doc.itemTypes.equipment
|
||||
context.magicItems = doc.itemTypes["magic-item"]
|
||||
context.conditions = doc.itemTypes.condition
|
||||
break
|
||||
case "notes":
|
||||
context.tab = context.tabs.notes
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
if (data.type === "Item") {
|
||||
const item = await fromUuid(data.uuid)
|
||||
return this._onDropItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("OATHHAMMER.NewItem.Weapon"), type: "weapon" }])
|
||||
}
|
||||
|
||||
static #onCreateSpell(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("OATHHAMMER.NewItem.Spell"), type: "spell" }])
|
||||
}
|
||||
|
||||
static #onCreateMiracle(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("OATHHAMMER.NewItem.Miracle"), type: "miracle" }])
|
||||
}
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("OATHHAMMER.NewItem.Equipment"), type: "equipment" }])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user