fix: optimize separator + missing css
This commit is contained in:
@@ -18,7 +18,9 @@ export class Column extends AbstractElement {
|
||||
element.x = Math.max(element.x, this.x);
|
||||
element.y = currentY;
|
||||
element.prepareRender(doc);
|
||||
currentY += element.getHeight(doc) + 2;
|
||||
const elementHeight = element.getHeight(doc);
|
||||
currentY +=
|
||||
elementHeight > 0 ? element.getHeight(doc) + 2 : elementHeight;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
@@ -53,4 +55,8 @@ export class Column extends AbstractElement {
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return this.elements.length === 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,50 +25,52 @@ export class LabelledValues extends Row {
|
||||
const labelPercent = 100 - valuePercent;
|
||||
const widthPercent = [labelPercent, valuePercent];
|
||||
let currentIndex = 0;
|
||||
if (this.nbrOfCol > 1) {
|
||||
const nbrPerCol = Math.floor(labelledValues.length / this.nbrOfCol);
|
||||
const rest = labelledValues.length - nbrPerCol * this.nbrOfCol;
|
||||
const nbrPerCols = [
|
||||
rest > 0 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 1 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 2 ? nbrPerCol + 1 : nbrPerCol,
|
||||
];
|
||||
for (let i = 0; i < this.nbrOfCol; i++) {
|
||||
this.elements[i] = new Column(0, 0, []);
|
||||
}
|
||||
for (let i = 0; i < labelledValues.length; i++) {
|
||||
if (i < nbrPerCols[0]) {
|
||||
currentIndex = 0;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1]) {
|
||||
currentIndex = 1;
|
||||
} else {
|
||||
currentIndex = 2;
|
||||
if (labelledValues.length > 0) {
|
||||
if (this.nbrOfCol > 1) {
|
||||
const nbrPerCol = Math.floor(labelledValues.length / this.nbrOfCol);
|
||||
const rest = labelledValues.length - nbrPerCol * this.nbrOfCol;
|
||||
const nbrPerCols = [
|
||||
rest > 0 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 1 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 2 ? nbrPerCol + 1 : nbrPerCol,
|
||||
];
|
||||
for (let i = 0; i < this.nbrOfCol; i++) {
|
||||
this.elements[i] = new Column(0, 0, []);
|
||||
}
|
||||
(<Column>this.elements[currentIndex]).elements.push(
|
||||
new LabelledValue(
|
||||
labelledValues[i].label,
|
||||
labelledValues[i].value,
|
||||
widthPercent,
|
||||
multiline
|
||||
for (let i = 0; i < labelledValues.length; i++) {
|
||||
if (i < nbrPerCols[0]) {
|
||||
currentIndex = 0;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1]) {
|
||||
currentIndex = 1;
|
||||
} else {
|
||||
currentIndex = 2;
|
||||
}
|
||||
(<Column>this.elements[currentIndex]).elements.push(
|
||||
new LabelledValue(
|
||||
labelledValues[i].label,
|
||||
labelledValues[i].value,
|
||||
widthPercent,
|
||||
multiline
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.elements.push(
|
||||
new Column(
|
||||
0,
|
||||
0,
|
||||
labelledValues.map(
|
||||
(libelledValue) =>
|
||||
new LabelledValue(
|
||||
libelledValue.label,
|
||||
libelledValue.value,
|
||||
widthPercent,
|
||||
multiline
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.elements.push(
|
||||
new Column(
|
||||
0,
|
||||
0,
|
||||
labelledValues.map(
|
||||
(libelledValue) =>
|
||||
new LabelledValue(
|
||||
libelledValue.label,
|
||||
libelledValue.value,
|
||||
widthPercent,
|
||||
multiline
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,4 +83,8 @@ export class Row extends AbstractElement {
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return this.elements.length === 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,51 +23,53 @@ export class Texts extends Row {
|
||||
this.nbrOfCol = 4;
|
||||
}
|
||||
let currentIndex = 0;
|
||||
if (this.nbrOfCol > 1) {
|
||||
const nbrPerCol = Math.floor(texts.length / this.nbrOfCol);
|
||||
const rest = texts.length - nbrPerCol * this.nbrOfCol;
|
||||
const nbrPerCols = [
|
||||
rest > 0 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 1 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 2 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 3 ? nbrPerCol + 1 : nbrPerCol,
|
||||
];
|
||||
for (let i = 0; i < this.nbrOfCol; i++) {
|
||||
this.elements[i] = new Column(0, 0, []);
|
||||
}
|
||||
for (let i = 0; i < texts.length; i++) {
|
||||
if (i < nbrPerCols[0]) {
|
||||
currentIndex = 0;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1]) {
|
||||
currentIndex = 1;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1] + nbrPerCols[2]) {
|
||||
currentIndex = 2;
|
||||
} else {
|
||||
currentIndex = 3;
|
||||
if (texts.length > 0) {
|
||||
if (this.nbrOfCol > 1) {
|
||||
const nbrPerCol = Math.floor(texts.length / this.nbrOfCol);
|
||||
const rest = texts.length - nbrPerCol * this.nbrOfCol;
|
||||
const nbrPerCols = [
|
||||
rest > 0 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 1 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 2 ? nbrPerCol + 1 : nbrPerCol,
|
||||
rest > 3 ? nbrPerCol + 1 : nbrPerCol,
|
||||
];
|
||||
for (let i = 0; i < this.nbrOfCol; i++) {
|
||||
this.elements[i] = new Column(0, 0, []);
|
||||
}
|
||||
(<Column>this.elements[currentIndex]).elements.push(
|
||||
new Row(0, 0, [
|
||||
multiline
|
||||
? new MultilineText(0, 0, texts[i])
|
||||
: new Text(0, 0, texts[i]),
|
||||
])
|
||||
for (let i = 0; i < texts.length; i++) {
|
||||
if (i < nbrPerCols[0]) {
|
||||
currentIndex = 0;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1]) {
|
||||
currentIndex = 1;
|
||||
} else if (i < nbrPerCols[0] + nbrPerCols[1] + nbrPerCols[2]) {
|
||||
currentIndex = 2;
|
||||
} else {
|
||||
currentIndex = 3;
|
||||
}
|
||||
(<Column>this.elements[currentIndex]).elements.push(
|
||||
new Row(0, 0, [
|
||||
multiline
|
||||
? new MultilineText(0, 0, texts[i])
|
||||
: new Text(0, 0, texts[i]),
|
||||
])
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.elements.push(
|
||||
new Column(
|
||||
0,
|
||||
0,
|
||||
texts.map(
|
||||
(text) =>
|
||||
new Row(0, 0, [
|
||||
multiline
|
||||
? new MultilineText(0, 0, text)
|
||||
: new Text(0, 0, text),
|
||||
])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.elements.push(
|
||||
new Column(
|
||||
0,
|
||||
0,
|
||||
texts.map(
|
||||
(text) =>
|
||||
new Row(0, 0, [
|
||||
multiline
|
||||
? new MultilineText(0, 0, text)
|
||||
: new Text(0, 0, text),
|
||||
])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
245
src/main.ts
245
src/main.ts
@@ -16,7 +16,6 @@ import { Blank } from './elements/blank';
|
||||
Hooks.on(
|
||||
'renderActorSheetWfrp4eCharacter',
|
||||
async (app: ActorSheet, html: JQuery) => {
|
||||
console.dir(app);
|
||||
const actor: Actor & any = app.actor;
|
||||
const actorData = actor.data;
|
||||
// @ts-ignore
|
||||
@@ -468,115 +467,175 @@ Hooks.on(
|
||||
`${i18nLocalize('Talents')} : ${i18nLocalize('Tests')}`
|
||||
),
|
||||
talents,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Traits'),
|
||||
traits.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
traits.elements.length > 0
|
||||
? new Text(0, 0, 'Traits')
|
||||
: Blank.heightBlank(0),
|
||||
traits,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.MeleeWeaponHeader')} : ${i18nLocalize(
|
||||
'Weapon Group'
|
||||
)}, ${i18nLocalize('Reach')}, ${i18nLocalize(
|
||||
'Damage'
|
||||
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
|
||||
),
|
||||
weaponsMelee.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
weaponsMelee.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.MeleeWeaponHeader')} : ${i18nLocalize(
|
||||
'Weapon Group'
|
||||
)}, ${i18nLocalize('Reach')}, ${i18nLocalize(
|
||||
'Damage'
|
||||
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
weaponsMelee,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.RangedWeaponHeader')} : ${i18nLocalize(
|
||||
'Weapon Group'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Damage'
|
||||
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
|
||||
),
|
||||
weaponsRanged.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
weaponsRanged.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.RangedWeaponHeader')} : ${i18nLocalize(
|
||||
'Weapon Group'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Damage'
|
||||
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
weaponsRanged,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Ammunition')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Damage')}, ${i18nLocalize(
|
||||
'Qualities'
|
||||
)}, ${i18nLocalize('Flaws')}`
|
||||
),
|
||||
ammunitions.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
ammunitions.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Ammunition')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Damage')}, ${i18nLocalize(
|
||||
'Qualities'
|
||||
)}, ${i18nLocalize('Flaws')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
ammunitions,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Armour'),
|
||||
armours.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
armours.elements.length > 0
|
||||
? new Text(0, 0, 'Armour')
|
||||
: Blank.heightBlank(0),
|
||||
armours,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.PettySpell')} : ${i18nLocalize(
|
||||
'Casting Number'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Target'
|
||||
)}, ${i18nLocalize('Duration')}`
|
||||
),
|
||||
petty.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
petty.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.PettySpell')} : ${i18nLocalize(
|
||||
'Casting Number'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Target'
|
||||
)}, ${i18nLocalize('Duration')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
petty,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.LoreSpell')} : ${i18nLocalize(
|
||||
'Casting Number'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Target'
|
||||
)}, ${i18nLocalize('Duration')}, ${i18nLocalize(
|
||||
'WFRP4E.TrappingType.Ingredients'
|
||||
)}`
|
||||
),
|
||||
spell.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
spell.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('SHEET.LoreSpell')} : ${i18nLocalize(
|
||||
'Casting Number'
|
||||
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
|
||||
'Target'
|
||||
)}, ${i18nLocalize('Duration')}, ${i18nLocalize(
|
||||
'WFRP4E.TrappingType.Ingredients'
|
||||
)}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
spell,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Blessing')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
|
||||
),
|
||||
blessing.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
blessing.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Blessing')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
blessing,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Miracle')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
|
||||
),
|
||||
miracle.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
miracle.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Miracle')} : ${i18nLocalize(
|
||||
'Range'
|
||||
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
miracle,
|
||||
new Separator(0, 0),
|
||||
trappingsHeader,
|
||||
trappings,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Psychology'),
|
||||
psychology.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
psychology.elements.length > 0
|
||||
? new Text(0, 0, 'Psychology')
|
||||
: Blank.heightBlank(0),
|
||||
psychology,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Criticals'),
|
||||
critical.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
critical.elements.length > 0
|
||||
? new Text(0, 0, 'Criticals')
|
||||
: Blank.heightBlank(0),
|
||||
critical,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Diseases'),
|
||||
disease.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
disease.elements.length > 0
|
||||
? new Text(0, 0, 'Diseases')
|
||||
: Blank.heightBlank(0),
|
||||
disease,
|
||||
new Separator(0, 0),
|
||||
new Text(0, 0, 'Injuries'),
|
||||
injury.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
injury.elements.length > 0
|
||||
? new Text(0, 0, 'Injuries')
|
||||
: Blank.heightBlank(0),
|
||||
injury,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Mutations')} (${i18nLocalize('Physical')})`
|
||||
),
|
||||
mutationP.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
mutationP.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Mutations')} (${i18nLocalize('Physical')})`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
mutationP,
|
||||
new Separator(0, 0),
|
||||
new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Mutations')} (${i18nLocalize('Mental')})`
|
||||
),
|
||||
mutationM.elements.length > 0
|
||||
? new Separator(0, 0)
|
||||
: Blank.heightBlank(0),
|
||||
mutationM.elements.length > 0
|
||||
? new Text(
|
||||
0,
|
||||
0,
|
||||
`${i18nLocalize('Mutations')} (${i18nLocalize('Mental')})`
|
||||
)
|
||||
: Blank.heightBlank(0),
|
||||
mutationM,
|
||||
]),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user