mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-25 00:43:38 +02:00
Compare commits
No commits in common. "209963405f0ce9842a31cafe7bbd7c941990be41" and "8f9f0617cd1ae50d52e5cc853dae1d105ad2fe18" have entirely different histories.
209963405f
...
8f9f0617cd
4 changed files with 14 additions and 156 deletions
|
|
@ -1,101 +1,24 @@
|
||||||
|
//Setting RollTable
|
||||||
export default class DhRollTableSheet extends foundry.applications.sheets.RollTableSheet {
|
export default class DhRollTableSheet extends foundry.applications.sheets.RollTableSheet {
|
||||||
static DEFAULT_OPTIONS = {
|
|
||||||
...super.DEFAULT_OPTIONS,
|
|
||||||
classes:['daggerheart', 'sheet', 'dh-style'],
|
|
||||||
actions: {
|
|
||||||
addAltFormula: DhRollTableSheet.#onAddAltFormula,
|
|
||||||
removeAltFormula: DhRollTableSheet.#onRemoveAltFormula
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static buildParts() {
|
static buildParts() {
|
||||||
const { footer, ...parts } = super.PARTS;
|
const { footer, ...parts } = super.PARTS;
|
||||||
const test = {
|
return {
|
||||||
...parts,
|
...parts,
|
||||||
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
|
summary: { template: 'systems/daggerheart/templates/sheets/rollTable/summary.hbs' },
|
||||||
footer
|
footer
|
||||||
};
|
}
|
||||||
return test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PARTS = DhRollTableSheet.buildParts();
|
static PARTS = DhRollTableSheet.buildParts();
|
||||||
|
|
||||||
|
static actions = {
|
||||||
|
addAltFormula: DhRollTableSheet.#onAddAltFormula,
|
||||||
|
removeAltForuma: DhRollTableSheet.#onRemoveAltFormula
|
||||||
|
};
|
||||||
|
|
||||||
async _preparePartContext(partId, context, options) {
|
//Add formulafield
|
||||||
context = await super._preparePartContext(partId, context, options);
|
static async #onAddAltFormula(event, target) {}
|
||||||
|
|
||||||
switch (partId) {
|
//Remove formulafield
|
||||||
case 'summary':
|
static async #onRemoveAltFormula(event, target) {}
|
||||||
context.flagFields = this.daggerheartFlag.schema.fields;
|
|
||||||
context.flagData = this.daggerheartFlag;
|
|
||||||
const formulas =[];
|
|
||||||
formulas.push({
|
|
||||||
index: 0,
|
|
||||||
key: this.daggerheartFlag.formulaName, //Stored in flags as discussed
|
|
||||||
formula: context.source.formula, //Settinng default formula as part of first element
|
|
||||||
formulaInputName: "formula",
|
|
||||||
keyInputName: "flags.daggerheart.formulaName"
|
|
||||||
});
|
|
||||||
this.daggerheartFlag.altFormula.forEach((alt,i) =>{
|
|
||||||
formulas.push({
|
|
||||||
index: i+1,
|
|
||||||
key: alt.key,
|
|
||||||
formula: alt.formula,
|
|
||||||
formulaInputName:`flags.daggerheart.altFormula.${i}.formula`,
|
|
||||||
keyInputName: `flags.daggerheart.altFormula.${i}.key`
|
|
||||||
});
|
|
||||||
});
|
|
||||||
context.formulaList=formulas;
|
|
||||||
context.isListView=formulas.length>1; //Condition to show list view only if more than one entry
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _preRender(context, options) {
|
|
||||||
await super._preRender(context, options);
|
|
||||||
|
|
||||||
if (!options.internalReferesh)
|
|
||||||
this.daggerheartFlag = new game.system.api.data.DhRollTable(this.document.flags.daggerheart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @override */
|
|
||||||
async _processSubmitData(event, form, submitData, options) {
|
|
||||||
//submitData.flags.daggerheart = this.daggerheartFlag.toObject(); caused render headaches
|
|
||||||
|
|
||||||
super._processSubmitData(event, form, submitData, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #onAddAltFormula(_event, target) {
|
|
||||||
const currentAltFormula=this.daggerheartFlag.altFormula;
|
|
||||||
await this.daggerheartFlag.updateSource({
|
|
||||||
altFormula:[...currentAltFormula,{key:"",formula:""}]
|
|
||||||
});
|
|
||||||
this.render({ internalRefresh: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #onRemoveAltFormula(_event, target) {
|
|
||||||
const visualIndex = parseInt(target.dataset.index);
|
|
||||||
const currentAltFormula=this.daggerheartFlag.altFormula;
|
|
||||||
if(visualIndex===0) {//If deleting formula at [0] index
|
|
||||||
if(currentAltFormula.length>0) {
|
|
||||||
const newCore = currentAltFormula[0];
|
|
||||||
const newAlt = currentAltFormula.slice(1);
|
|
||||||
await this.document.update({formula: newCore.formula});
|
|
||||||
await this.daggerheartFlag.updateSource({
|
|
||||||
formulaName:newCore.key,
|
|
||||||
altFormula:newAlt
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await this.document.update({ formula: "" });
|
|
||||||
await this.daggerheartFlag.updateSource({ formulaName: "" });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const arrayIndex = visualIndex - 1;
|
|
||||||
await this.daggerheartFlag.updateSource({
|
|
||||||
altFormula: currentAltFormula.filter((_, i) => i !== arrayIndex)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.render({ internalRefresh: true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
export { default as DhCombat } from './combat.mjs';
|
export { default as DhCombat } from './combat.mjs';
|
||||||
export { default as DhCombatant } from './combatant.mjs';
|
export { default as DhCombatant } from './combatant.mjs';
|
||||||
export { default as DhTagTeamRoll } from './tagTeamRoll.mjs';
|
export { default as DhTagTeamRoll } from './tagTeamRoll.mjs';
|
||||||
export { default as DhRollTable } from './rollTable.mjs';
|
|
||||||
|
|
||||||
export * as countdowns from './countdowns.mjs';
|
export * as countdowns from './countdowns.mjs';
|
||||||
export * as actions from './action/_module.mjs';
|
export * as actions from './action/_module.mjs';
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import FormulaField from './fields/formulaField.mjs';
|
|
||||||
|
|
||||||
//Extra definitions for RollTable
|
|
||||||
export default class DhRollTable extends foundry.abstract.TypeDataModel {
|
|
||||||
static defineSchema() {
|
|
||||||
const fields = foundry.data.fields;
|
|
||||||
|
|
||||||
return {
|
|
||||||
formulaName: new fields.StringField({
|
|
||||||
// This is to give a name to go together with the core.formula
|
|
||||||
required: true,
|
|
||||||
nullable: false,
|
|
||||||
initial: 'Formula' // Should be a translation
|
|
||||||
}),
|
|
||||||
altFormula: new fields.ArrayField(
|
|
||||||
new fields.SchemaField({
|
|
||||||
key: new fields.StringField({
|
|
||||||
required: false,
|
|
||||||
nullable: false,
|
|
||||||
blank: true
|
|
||||||
}),
|
|
||||||
formula: new FormulaField()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +1,6 @@
|
||||||
<section class="tab{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
<section class="tab{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||||
{{formGroup fields.description value=source.description rootId=rootId}}
|
{{formGroup fields.description value=source.description rootId=rootId}}
|
||||||
<fieldset class="one-column" data-key="formula">
|
{{formGroup fields.formula value=source.formula placeholder=formulaPlaceholder rootId=rootId}}
|
||||||
<legend>
|
|
||||||
Formula
|
|
||||||
<a><i class="fa-solid fa-plus icon-button" data-action="addAltFormula"></i></a>
|
|
||||||
</legend>
|
|
||||||
|
|
||||||
{{#if isListView}}
|
|
||||||
{{#each formulaList as |row|}}
|
|
||||||
<div class="nest-inputs">
|
|
||||||
{{formGroup ../flagFields.formulaName
|
|
||||||
value=row.key
|
|
||||||
name=row.keyInputName
|
|
||||||
placeholder="Name"
|
|
||||||
}}
|
|
||||||
{{formGroup ../fields.formula
|
|
||||||
value=row.formula
|
|
||||||
name=row.formulaInputName
|
|
||||||
placeholder="Formula"
|
|
||||||
}}
|
|
||||||
<a class="btn"
|
|
||||||
data-tooltip="{{localize "CONTROLS.CommonDelete"}}"
|
|
||||||
data-action="removeAltFormula"
|
|
||||||
data-index="{{row.index}}">
|
|
||||||
<i class="fas fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
{{else}}
|
|
||||||
<div class="nest-inputs">
|
|
||||||
<input type="hidden" name="flags.daggerheart.formulaName" value="{{flagData.formulaName}}">
|
|
||||||
{{formGroup fields.formula
|
|
||||||
value=source.formula
|
|
||||||
placeholder=formulaPlaceholder
|
|
||||||
rootId=rootId
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
</fieldset>
|
|
||||||
{{formGroup fields.replacement value=source.replacement rootId=rootId}}
|
{{formGroup fields.replacement value=source.replacement rootId=rootId}}
|
||||||
{{formGroup fields.displayRoll value=source.displayRoll rootId=rootId}}
|
{{formGroup fields.displayRoll value=source.displayRoll rootId=rootId}}
|
||||||
</section>
|
</section>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue