Added a new button bar for system specific buttons
This commit is contained in:
@@ -17,15 +17,40 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the SendToChat button on top of sheet
|
||||
* @override
|
||||
* Add buttons to L5R specific bar
|
||||
* @return {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
_getL5rHeaderButtons() {
|
||||
/**
|
||||
* @var {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
const buttons = [];
|
||||
|
||||
if (this.isEditable && !this.actor.limited) {
|
||||
// Lock/Unlock
|
||||
buttons.unshift({
|
||||
label: `l5r5e.global.${this.actor.data.data.soft_locked ? "" : "un"}locked`,
|
||||
class: "l5r-softlock",
|
||||
icon: this.actor.data.data.soft_locked ? "fas fa-lock" : "fas fa-unlock",
|
||||
onclick: () =>
|
||||
game.l5r5e.HelpersL5r5e.debounce(
|
||||
"lock-" + this.object.id,
|
||||
() => {
|
||||
this.actor.update({
|
||||
data: {
|
||||
soft_locked: !this.actor.data.data.soft_locked,
|
||||
},
|
||||
});
|
||||
},
|
||||
500,
|
||||
true
|
||||
)(),
|
||||
});
|
||||
}
|
||||
|
||||
// Send To Chat
|
||||
buttons.unshift({
|
||||
label: game.i18n.localize("l5r5e.global.send_to_chat"),
|
||||
label: "l5r5e.global.send_to_chat",
|
||||
class: "send-to-chat",
|
||||
icon: "fas fa-comment-dots",
|
||||
onclick: () =>
|
||||
@@ -44,6 +69,9 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
|
||||
// System Header Buttons
|
||||
sheetData.l5rHeaderButtons = this._getL5rHeaderButtons();
|
||||
|
||||
sheetData.data.dtypes = ["String", "Number", "Boolean"];
|
||||
|
||||
// Sort Items by name
|
||||
@@ -109,6 +137,14 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
// Commons
|
||||
game.l5r5e.HelpersL5r5e.commonListeners(html, this.actor);
|
||||
|
||||
// System Header Buttons
|
||||
const l5rHeaderButtons = this._getL5rHeaderButtons();
|
||||
html.find(".l5r-header-button").click((event) => {
|
||||
event.preventDefault();
|
||||
const button = l5rHeaderButtons.find((b) => event.currentTarget.classList.contains(b.class));
|
||||
button.onclick(event);
|
||||
});
|
||||
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable) {
|
||||
return;
|
||||
|
||||
@@ -17,11 +17,12 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the TwentyQuestions button on top of sheet
|
||||
* Add the TwentyQuestions button in L5R specific bar
|
||||
* @override
|
||||
* @return {{label: string, class: string, icon: string, onclick: Function|null}[]}
|
||||
*/
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
_getL5rHeaderButtons() {
|
||||
const buttons = super._getL5rHeaderButtons();
|
||||
if (!this.isEditable || this.actor.limited) {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ export class TwentyQuestions {
|
||||
parseInt(formData.step18.heritage_add_honor);
|
||||
|
||||
// Update the actor
|
||||
actorDatas.soft_locked = true;
|
||||
actorDatas.template = formData.template;
|
||||
actorDatas.zeni = Math.floor(formData.step2.wealth * 50);
|
||||
actorDatas.identity = {
|
||||
|
||||
Reference in New Issue
Block a user