advancements now with tabs

This commit is contained in:
Vlyan
2020-12-31 12:18:25 +01:00
parent c9b60c1333
commit 267c77c78b
10 changed files with 67 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ export class BaseSheetL5r5e extends ActorSheet {
// template: CONFIG.l5r5e.paths.templates + "actors/character-sheet.html",
width: 600,
height: 800,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }],
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
});
}
@@ -162,7 +162,7 @@ export class BaseSheetL5r5e extends ActorSheet {
tgt.hasClass("toggle-active") ? tgt.removeClass("toggle-active") : tgt.addClass("toggle-active");
});
// *** Items : add, edit, delete, curriculum ***
// *** Items : add, edit, delete ***
html.find(".item-add").on("click", (event) => {
this._addSubItem(event);
});
@@ -172,21 +172,6 @@ export class BaseSheetL5r5e extends ActorSheet {
html.find(`.item-delete`).on("click", (event) => {
this._deleteSubItem(event);
});
html.find(`.item-curriculum`).on("click", (event) => {
this._switchSubItemCurriculum(event);
});
html.find(`button[name=validate-curriculum]`).on("click", (event) => {
this.actor.data.data.identity.school_rank = this.actor.data.data.identity.school_rank + 1;
// Update actor
this.actor.update({
data: {
identity: {
school_rank: this.actor.data.data.identity.school_rank,
},
},
});
this.render(false);
});
}
/**

View File

@@ -9,6 +9,10 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
return mergeObject(super.defaultOptions, {
classes: ["l5r5e", "sheet", "actor"],
template: CONFIG.l5r5e.paths.templates + "actors/character-sheet.html",
tabs: [
{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" },
{ navSelector: ".advancements-tabs", contentSelector: ".advancements-body", initial: "last" },
],
});
}
@@ -57,6 +61,42 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
return sheetData;
}
/**
* Subscribe to events from the sheet.
* @param html HTML content of the sheet.
*/
activateListeners(html) {
super.activateListeners(html);
// *** Everything below here is only needed if the sheet is editable ***
if (!this.options.editable) {
return;
}
// *** Items : curriculum management ***
html.find(`.item-curriculum`).on("click", (event) => {
this._switchSubItemCurriculum(event);
});
html.find(`button[name=validate-curriculum]`).on("click", (event) => {
this.actor.data.data.identity.school_rank = this.actor.data.data.identity.school_rank + 1;
// Update actor
this.actor.update({
data: {
identity: {
school_rank: this.actor.data.data.identity.school_rank,
},
},
});
this.render(false);
});
// Advancements Tab to current rank onload
// TODO class "Active" Bug on load, dunno why :/
this._tabs
.find((e) => e._navSelector === ".advancements-tabs")
.activate("advancement_rank_" + (this.actor.data.data.identity.school_rank || 0));
}
/**
* Return the total xp spent and the current total xp spent for this rank
*/
@@ -77,10 +117,6 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e {
}
const rank = Math.max(0, item.data.bought_at_rank);
if (rank < 1) {
// Ignore starting comp/items
return;
}
if (!adv[rank]) {
adv[rank] = {
rank: rank,