fix: optimize separator + missing css

This commit is contained in:
Matthieu CAILLEAUX
2021-10-19 01:43:48 +02:00
parent e28eb3cd12
commit b35284768e
10 changed files with 274 additions and 182 deletions

View File

@@ -14,10 +14,12 @@ build:
- npm ci
- npm run build
- mkdir -p dist/lang
- mkdir -p dist/styles
- cp lang/* dist/lang/
- cp styles/* dist/styles/
- cp module.json dist
- cd dist
- zip wfrp4e-actor-sheet-print.zip -r *.* elements lang -x ".*"
- zip wfrp4e-actor-sheet-print.zip -r *.* elements lang styles -x ".*"
artifacts:
name: wfrp4e-actor-sheet-print
when: on_success
@@ -33,10 +35,12 @@ build_beta:
- npm ci
- npm run build
- mkdir -p dist/lang
- mkdir -p dist/styles
- cp lang/* dist/lang/
- cp styles/* dist/styles/
- cp module-beta.json dist/module.json
- cd dist
- zip wfrp4e-actor-sheet-print.zip -r *.* elements lang -x ".*"
- zip wfrp4e-actor-sheet-print.zip -r *.* elements lang styles -x ".*"
artifacts:
name: wfrp4e-actor-sheet-print
when: on_success

View File

@@ -2,7 +2,7 @@
"name": "wfrp4e-actor-sheet-print-beta",
"title": "[WFRP4] Actor Sheet Print BETA version",
"description": "Functions to print actor sheet",
"version": "1.0.0",
"version": "1.0.1",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "0.8.9",
"author": "Skeroujvapluvit",
@@ -21,7 +21,7 @@
"path": "lang/fr.json"
}
],
"styles": [],
"styles": ["./styles/main.css"],
"url": "https://github.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print/tree/dist-beta",
"download": "https://github.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print/blob/dist-beta/dist/wfrp4e-actor-sheet-print.zip?raw=true",
"manifest": "https://raw.githubusercontent.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print/dist-beta/module-beta.json",

View File

@@ -2,7 +2,7 @@
"name": "wfrp4e-actor-sheet-print",
"title": "[WFRP4] Actor Sheet Print",
"description": "Functions to print actor sheet",
"version": "1.0.0",
"version": "1.0.1",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "0.8.9",
"author": "Skeroujvapluvit",
@@ -21,7 +21,7 @@
"path": "lang/fr.json"
}
],
"styles": [],
"styles": ["./styles/main.css"],
"url": "https://github.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print",
"download": "https://github.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print/blob/dist/dist/wfrp4e-actor-sheet-print.zip?raw=true",
"manifest": "https://raw.githubusercontent.com/mcailleaux/WFRP4-FoundryVTT-wfrp4e-actor-sheet-print/dist/module.json",

View File

@@ -1,4 +1,6 @@
npm run build
mkdir -p ./dist/lang
mkdir -p ./dist/styles
cp ./lang/* ./dist/lang/
cp ./styles/* ./dist/styles/
cp module.json ./dist/module.json

View File

@@ -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;
}
}

View File

@@ -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
)
)
)
);
}
}

View File

@@ -83,4 +83,8 @@ export class Row extends AbstractElement {
}
return elements;
}
public isEmpty(): boolean {
return this.elements.length === 0;
}
}

View File

@@ -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),
])
)
)
);
}
}

View File

@@ -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,
]),
]);

13
styles/main.css Normal file
View File

@@ -0,0 +1,13 @@
.app.window-app .window-header .print {
color: #e8d29c;
text-align: center;
height: 30px;
width: 30px;
margin: 0;
padding: 0;
background: url('/systems/wfrp4e/ui/buttons/button-blank.webp');
}
.app.window-app .window-header .print i {
font-size: 12px;
}