feat: add mobile css

This commit is contained in:
Matthieu CAILLEAUX
2022-04-27 23:36:15 +02:00
parent b16967c351
commit 049c77a004
19 changed files with 639 additions and 319 deletions

View File

@@ -104,20 +104,31 @@ async function generate(actor: Actor & any, docBuilder: AbstractBuilder) {
value: item.data.data.total.value,
};
})
.sort((a, b) => a.label.localeCompare(b.label))
.sort((a, b) => a.label.localeCompare(b.label)),
undefined,
false,
{ name: 'skills' }
);
const talentsByName: { [name: string]: { count: number; test: string } } = {};
actor.itemCategories.talent.forEach((item) => {
const name = item.name;
if (talentsByName[name] == null) {
talentsByName[name] = { count: 1, test: item.data.data.tests.value };
} else {
talentsByName[name].count++;
}
});
const talents = new LabelledValues(
0,
0,
actor.itemCategories.talent
.map((item) => {
Object.entries(talentsByName)
.map(([name, value]) => {
return {
label:
item.data.data.tests.value.length > 0
? `${item.name} : ${item.data.data.tests.value}`
: item.name,
value: item.data.data.advances.value,
label: value.test.length > 0 ? `${name} : ${value.test}` : name,
value: value.count,
};
})
.sort((a, b) => a.label.localeCompare(b.label)),
@@ -376,250 +387,406 @@ async function generate(actor: Actor & any, docBuilder: AbstractBuilder) {
const labelledRowHeight = docBuilder.getLabelledRowHeight();
const imageWidth = 25;
const imageWidth = 25 * docBuilder.getImageScale();
const imageY = labelledRowHeight + MARGINS.top + 2;
const actorImageElement =
const actorImageElementPdf =
actorImageData != null
? new Image(0, imageY, imageWidth, imageWidth, actorImageData)
: new Box(0, imageY, imageWidth, imageWidth);
? new Image(0, imageY, imageWidth, imageWidth, actorImageData, {
isHtml: false,
})
: new Box(0, imageY, imageWidth, imageWidth, {
isHtml: false,
});
const actorImageElementHtml =
actorImageData != null
? new Image(0, imageY, imageWidth, imageWidth, actorImageData, {
isPdf: false,
})
: new Box(0, imageY, imageWidth, imageWidth, {
isPdf: false,
});
docBuilder.build([
actorImageElement,
new Column(0, 0, [
new Row(0, 0, [
new LabelledText(0, 0, 'Name', `${actor.name}`),
new LabelledText(0, 0, 'Species', `${actorDetails?.species?.value}`),
new LabelledText(0, 0, 'Gender', `${actorDetails?.gender?.value}`),
]),
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(0, 0, 'Class', `${careerDetail?.class?.value}`),
new LabelledText(
actorImageElementPdf,
new Column(
0,
0,
[
new Row(0, 0, [
new LabelledText(0, 0, 'Name', `${actor.name}`),
new LabelledText(0, 0, 'Species', `${actorDetails?.species?.value}`),
new LabelledText(0, 0, 'Gender', `${actorDetails?.gender?.value}`),
]),
new Row(
imageWidth + MARGINS.left + 1,
0,
0,
'Career Group',
`${careerDetail?.careergroup?.value}`
[
new LabelledText(0, 0, 'Class', `${careerDetail?.class?.value}`),
new LabelledText(
0,
0,
'Career Group',
`${careerDetail?.careergroup?.value}`
),
new LabelledText(0, 0, 'Career', `${currentCareer?.name}`),
],
undefined,
undefined,
undefined,
{ isHtml: false }
),
new LabelledText(0, 0, 'Career', `${currentCareer?.name}`),
]),
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(0, 0, 'Status', `${actorDetails?.status?.value}`),
new LabelledText(0, 0, 'Age', `${actorDetails?.age?.value}`),
new LabelledText(0, 0, 'Height', `${actorDetails?.height?.value}`),
new LabelledText(0, 0, 'Weight', `${actorDetails?.weight?.value}`),
new LabelledText(
new Row(
imageWidth + MARGINS.left + 1,
0,
0,
'Hair Colour',
`${actorDetails?.haircolour?.value}`
[
new LabelledText(0, 0, 'Status', `${actorDetails?.status?.value}`),
new LabelledText(0, 0, 'Age', `${actorDetails?.age?.value}`),
new LabelledText(0, 0, 'Height', `${actorDetails?.height?.value}`),
new LabelledText(0, 0, 'Weight', `${actorDetails?.weight?.value}`),
new LabelledText(
0,
0,
'Hair Colour',
`${actorDetails?.haircolour?.value}`
),
],
undefined,
undefined,
undefined,
{ isHtml: false }
),
]),
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(
new Row(
imageWidth + MARGINS.left + 1,
0,
0,
'Eye Colour',
`${actorDetails?.eyecolour?.value}`
[
new LabelledText(
0,
0,
'Eye Colour',
`${actorDetails?.eyecolour?.value}`
),
new LabelledText(
0,
0,
'Distinguishing Mark',
`${actorDetails?.distinguishingmark?.value}`
),
new LabelledText(
0,
0,
'Star Sign',
`${actorDetails?.starsign?.value}`
),
],
undefined,
undefined,
undefined,
{ isHtml: false }
),
new LabelledText(
new Row(
0,
0,
'Distinguishing Mark',
`${actorDetails?.distinguishingmark?.value}`
[
actorImageElementHtml,
new Column(0, 0, [
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(
0,
0,
'Class',
`${careerDetail?.class?.value}`
),
new LabelledText(
0,
0,
'Career Group',
`${careerDetail?.careergroup?.value}`
),
new LabelledText(0, 0, 'Career', `${currentCareer?.name}`),
]),
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(
0,
0,
'Status',
`${actorDetails?.status?.value}`
),
new LabelledText(0, 0, 'Age', `${actorDetails?.age?.value}`),
new LabelledText(
0,
0,
'Height',
`${actorDetails?.height?.value}`
),
new LabelledText(
0,
0,
'Weight',
`${actorDetails?.weight?.value}`
),
new LabelledText(
0,
0,
'Hair Colour',
`${actorDetails?.haircolour?.value}`
),
]),
new Row(imageWidth + MARGINS.left + 1, 0, [
new LabelledText(
0,
0,
'Eye Colour',
`${actorDetails?.eyecolour?.value}`
),
new LabelledText(
0,
0,
'Distinguishing Mark',
`${actorDetails?.distinguishingmark?.value}`
),
new LabelledText(
0,
0,
'Star Sign',
`${actorDetails?.starsign?.value}`
),
]),
]),
],
undefined,
undefined,
undefined,
{ isPdf: false }
),
new LabelledText(0, 0, 'Star Sign', `${actorDetails?.starsign?.value}`),
]),
Blank.heightBlank(2),
new Row(0, 0, [
new LabelledText(0, 0, 'CHARAbbrev.WS', `${actorCharacs?.ws?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.BS', `${actorCharacs?.bs?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.S', `${actorCharacs?.s?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.T', `${actorCharacs?.t?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.I', `${actorCharacs?.i?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.Ag', `${actorCharacs?.ag?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.Dex', `${actorCharacs?.dex?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.Int', `${actorCharacs?.int?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.WP', `${actorCharacs?.wp?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.Fel', `${actorCharacs?.fel?.value}`),
]),
new Row(0, 0, [
new LabelledText(0, 0, 'Move', `${actorDetails?.move?.value}`),
new LabelledText(0, 0, 'Walk', `${actorDetails?.move?.walk}`),
new LabelledText(0, 0, 'Run', `${actorDetails?.move?.run}`),
new LabelledText(0, 0, 'Fortune', `${actorStatus?.fortune?.value}`),
new LabelledText(0, 0, 'Fate', `${actorStatus?.fate?.value}`),
new LabelledText(0, 0, 'Resolve', `${actorStatus?.resolve?.value}`),
new LabelledText(
0,
0,
'Resilience',
`${actorStatus?.resilience?.value}`
),
new LabelledText(
0,
0,
'Wounds',
`${actorStatus?.wounds?.value}/${actorStatus?.wounds?.max}`
),
]),
new Separator(0, 0),
new Text(0, 0, 'Skills'),
skills,
new Separator(0, 0),
new Text(0, 0, `${i18nLocalize('Talents')} : ${i18nLocalize('Tests')}`),
talents,
traits.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
traits.elements.length > 0
? new Text(0, 0, 'Traits')
: Blank.heightBlank(0),
traits,
weaponsMelee.elements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
weaponsMelee.elements.length > 0
? new Text(
Blank.heightBlank(2),
new Row(0, 0, [
new LabelledText(0, 0, 'CHARAbbrev.WS', `${actorCharacs?.ws?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.BS', `${actorCharacs?.bs?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.S', `${actorCharacs?.s?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.T', `${actorCharacs?.t?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.I', `${actorCharacs?.i?.value}`),
new LabelledText(0, 0, 'CHARAbbrev.Ag', `${actorCharacs?.ag?.value}`),
new LabelledText(
0,
0,
`${i18nLocalize('SHEET.MeleeWeaponHeader')} : ${i18nLocalize(
'Weapon Group'
)}, ${i18nLocalize('Reach')}, ${i18nLocalize(
'Damage'
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
weaponsMelee,
weaponsRanged.elements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
weaponsRanged.elements.length > 0
? new Text(
'CHARAbbrev.Dex',
`${actorCharacs?.dex?.value}`
),
new LabelledText(
0,
0,
`${i18nLocalize('SHEET.RangedWeaponHeader')} : ${i18nLocalize(
'Weapon Group'
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
'Damage'
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
weaponsRanged,
ammunitions.elements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
ammunitions.elements.length > 0
? new Text(
'CHARAbbrev.Int',
`${actorCharacs?.int?.value}`
),
new LabelledText(0, 0, 'CHARAbbrev.WP', `${actorCharacs?.wp?.value}`),
new LabelledText(
0,
0,
`${i18nLocalize('Ammunition')} : ${i18nLocalize(
'Range'
)}, ${i18nLocalize('Damage')}, ${i18nLocalize(
'Qualities'
)}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
ammunitions,
armours.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
armours.elements.length > 0
? new Text(0, 0, 'Armour')
: Blank.heightBlank(0),
armours,
petty.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
petty.elements.length > 0
? new Text(
'CHARAbbrev.Fel',
`${actorCharacs?.fel?.value}`
),
]),
new Row(0, 0, [
new LabelledText(0, 0, 'Move', `${actorDetails?.move?.value}`),
new LabelledText(0, 0, 'Walk', `${actorDetails?.move?.walk}`),
new LabelledText(0, 0, 'Run', `${actorDetails?.move?.run}`),
new LabelledText(0, 0, 'Fortune', `${actorStatus?.fortune?.value}`),
new LabelledText(0, 0, 'Fate', `${actorStatus?.fate?.value}`),
new LabelledText(0, 0, 'Resolve', `${actorStatus?.resolve?.value}`),
new LabelledText(
0,
0,
`${i18nLocalize('SHEET.PettySpell')} : ${i18nLocalize(
'Casting Number'
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
'Target'
)}, ${i18nLocalize('Duration')}`
)
: Blank.heightBlank(0),
petty,
spell.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
spell.elements.length > 0
? new Text(
'Resilience',
`${actorStatus?.resilience?.value}`
),
new LabelledText(
0,
0,
`${i18nLocalize('SHEET.LoreSpell')} : ${i18nLocalize(
'Casting Number'
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
'Target'
)}, ${i18nLocalize('Duration')}, ${i18nLocalize(
'WFRP4E.TrappingType.Ingredients'
)}`
)
: Blank.heightBlank(0),
spell,
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,
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,
psychology.elements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
psychology.elements.length > 0
? new Text(0, 0, 'Psychology')
: Blank.heightBlank(0),
psychology,
critical.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
critical.elements.length > 0
? new Text(0, 0, 'Criticals')
: Blank.heightBlank(0),
critical,
disease.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
disease.elements.length > 0
? new Text(0, 0, 'Diseases')
: Blank.heightBlank(0),
disease,
injury.elements.length > 0 ? new Separator(0, 0) : Blank.heightBlank(0),
injury.elements.length > 0
? new Text(0, 0, 'Injuries')
: Blank.heightBlank(0),
injury,
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,
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,
]),
'Wounds',
`${actorStatus?.wounds?.value}/${actorStatus?.wounds?.max}`
),
]),
new Separator(0, 0),
new Text(0, 0, 'Skills'),
skills,
new Separator(0, 0),
new Text(0, 0, `${i18nLocalize('Talents')} : ${i18nLocalize('Tests')}`),
talents,
traits.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
traits.contextElements.length > 0
? new Text(0, 0, 'Traits')
: Blank.heightBlank(0),
traits,
weaponsMelee.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
weaponsMelee.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('SHEET.MeleeWeaponHeader')} : ${i18nLocalize(
'Weapon Group'
)}, ${i18nLocalize('Reach')}, ${i18nLocalize(
'Damage'
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
weaponsMelee,
weaponsRanged.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
weaponsRanged.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('SHEET.RangedWeaponHeader')} : ${i18nLocalize(
'Weapon Group'
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
'Damage'
)}, ${i18nLocalize('Qualities')}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
weaponsRanged,
ammunitions.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
ammunitions.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('Ammunition')} : ${i18nLocalize(
'Range'
)}, ${i18nLocalize('Damage')}, ${i18nLocalize(
'Qualities'
)}, ${i18nLocalize('Flaws')}`
)
: Blank.heightBlank(0),
ammunitions,
armours.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
armours.contextElements.length > 0
? new Text(0, 0, 'Armour')
: Blank.heightBlank(0),
armours,
petty.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
petty.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('SHEET.PettySpell')} : ${i18nLocalize(
'Casting Number'
)}, ${i18nLocalize('Range')}, ${i18nLocalize(
'Target'
)}, ${i18nLocalize('Duration')}`
)
: Blank.heightBlank(0),
petty,
spell.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
spell.contextElements.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,
blessing.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
blessing.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('Blessing')} : ${i18nLocalize(
'Range'
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
)
: Blank.heightBlank(0),
blessing,
miracle.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
miracle.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('Miracle')} : ${i18nLocalize(
'Range'
)}, ${i18nLocalize('Target')}, ${i18nLocalize('Duration')}`
)
: Blank.heightBlank(0),
miracle,
new Separator(0, 0),
trappingsHeader,
trappings,
psychology.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
psychology.contextElements.length > 0
? new Text(0, 0, 'Psychology')
: Blank.heightBlank(0),
psychology,
critical.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
critical.contextElements.length > 0
? new Text(0, 0, 'Criticals')
: Blank.heightBlank(0),
critical,
disease.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
disease.contextElements.length > 0
? new Text(0, 0, 'Diseases')
: Blank.heightBlank(0),
disease,
injury.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
injury.contextElements.length > 0
? new Text(0, 0, 'Injuries')
: Blank.heightBlank(0),
injury,
mutationP.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
mutationP.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('Mutations')} (${i18nLocalize('Physical')})`
)
: Blank.heightBlank(0),
mutationP,
mutationM.contextElements.length > 0
? new Separator(0, 0)
: Blank.heightBlank(0),
mutationM.contextElements.length > 0
? new Text(
0,
0,
`${i18nLocalize('Mutations')} (${i18nLocalize('Mental')})`
)
: Blank.heightBlank(0),
mutationM,
],
{
name: 'main-column',
}
),
]);
docBuilder.save(`${actor.name}`);
}