diff --git a/src/main.ts b/src/main.ts index 44beff9..0f1b8e9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,31 @@ -//ActorSheet +Hooks.on( + 'renderActorSheetWfrp4eCharacter', + (_app: ActorSheet, html: JQuery) => { + console.dir(_app); + addActorSheetActionButton(html, 'print', () => { + print(html); + }); + } +); -Hooks.on('renderActorSheet', (_app: ActorSheet, _html: JQuery) => { - console.dir(_app); -}); +function addActorSheetActionButton( + html: JQuery, + icon: string, + onClick: () => void +) { + const button = document.createElement('a'); + button.classList.add('print'); + button.innerHTML = ` `; + button.addEventListener('click', () => { + onClick(); + }); + const header = html.find('.window-header'); + const title = header.find('.window-title'); + title.after(button); +} + +function print(html: JQuery) { + $('.wfrp4e-print').removeClass('wfrp4e-print'); + html.addClass('wfrp4e-print'); + window.print(); +} diff --git a/styles/pj-print.css b/styles/pj-print.css index e69de29..e0e8bf6 100644 --- a/styles/pj-print.css +++ b/styles/pj-print.css @@ -0,0 +1,390 @@ +.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; +} + +@media print { + html { + background: unset !important; + } + + body { + width: auto !important; + height: auto !important; + overflow: auto; + box-shadow: none !important; + background-color: white !important; + background-image: none !important; + } + + body > *:not(.wfrp4e-print) { + display: none !important; + } + + button[type='submit'] { + display: none; + } + + input[name='name'] { + border: none; + background: none; + } + + .wfrp4e-print { + width: 100% !important; + height: auto !important; + position: unset !important; + box-shadow: none; + background-image: none; + } + + .wfrp4e-print .window-header, + .wfrp4e-print .window-content form > .header, + .wfrp4e-print .characteristics-table > div:not(.table-header):not(.bottom), + .wfrp4e-print .characteristics-table .advancement-indicator, + .wfrp4e-print .career-list, + .wfrp4e-print #extended-tests, + .wfrp4e-print .skill-section .advancement-indicator, + .wfrp4e-print .skill-type .inventory-list .item .row-value, + .wfrp4e-print .skill-type .inventory-list .item .skill-advances, + .wfrp4e-print .skill-type .inventory-header .adv, + .wfrp4e-print .talents .item-controls, + .wfrp4e-print .item-summary, + .wfrp4e-print .talents .trait-roll, + .wfrp4e-print .untrained, + .wfrp4e-print .combat .advantage, + .wfrp4e-print .combat .melee-weapon-header a, + .wfrp4e-print .combat .item-checkbox i, + .wfrp4e-print .combat .weapon-property .comma, + .wfrp4e-print .combat .ranged-weapon-list .content .image, + .wfrp4e-print .combat .ranged-weapon-list .weapon-property i, + .wfrp4e-print .armour-section .armour-total, + .wfrp4e-print .armour-section .shield-total, + .wfrp4e-print .armour-section .toughness-total, + .wfrp4e-print .armour-section .image, + .wfrp4e-print .effects .condition-list, + .wfrp4e-print .effects > *:nth-child(2), + .wfrp4e-print .effects > *:nth-child(3), + .wfrp4e-print .effects > *:nth-child(14), + .wfrp4e-print .effects > *:nth-child(15), + .wfrp4e-print .effects > *:nth-child(16), + .wfrp4e-print .effects > *:nth-child(17), + .wfrp4e-print .effects > *:nth-child(18), + .wfrp4e-print .effects > *:nth-child(19), + .wfrp4e-print .effects > *:nth-child(20), + .wfrp4e-print #tab-sections > .content > .inventory > .encumbrance, + .wfrp4e-print #tab-sections > .content > .inventory > .currency-header, + .wfrp4e-print + #tab-sections + > .content + > .inventory + > .container + .inventory-header + > *:not(.item-name), + .wfrp4e-print + #tab-sections + > .content + > .inventory + .content + > *:not(.item-name):not(.quantity), + .wfrp4e-print .magic .inventory-header::marker, + .wfrp4e-print .religion .inventory-header::marker, + .wfrp4e-print .inventory .dollar-icon, + .wfrp4e-print .inventory .item-toggle, + .wfrp4e-print .notes, + .wfrp4e-print .mount-drop, + .wfrp4e-print .wounds-section .rest-icon { + display: none !important; + } + + .wfrp4e-print + #tab-sections + > .content + > .inventory + > .inventory-header + > *:not(.name) { + color: white !important; + } + + .wfrp4e-print .magic .lore-header { + list-style: none; + } + + .wfrp4e-print #tab-sections > .content > .inventory, + .wfrp4e-print #tab-sections > .content > .inventory *, + .wfrp4e-print .combat .text.ranged-property-quality.ranged-property-flaw, + .wfrp4e-print .effects > *, + .wfrp4e-print .window-content, + .wfrp4e-print .mount-section, + .wfrp4e-print .mount-section .mount-header, + .wfrp4e-print .window-content form { + border: none !important; + } + + .wfrp4e-print .combat { + overflow: hidden !important; + } + + .wfrp4e-print .window-content form { + margin: 0 !important; + } + + .wfrp4e-print .characteristics, + .wfrp4e-print .characteristics-table { + height: 50px !important; + } + + .wfrp4e-print .fate-resilience-section .bottom { + height: 24px !important; + } + + .wfrp4e-print .move-value { + width: 100% !important; + } + + .wfrp4e-print select { + appearance: none !important; + border: none !important; + } + + .wfrp4e-print .skill-section { + width: 100% !important; + justify-content: space-between !important; + align-items: stretch !important; + display: flex !important; + flex-direction: row !important; + } + + .wfrp4e-print .skill-type .inventory-list, + .wfrp4e-print .talents .inventory-list, + .wfrp4e-print .magic .inventory-list, + .wfrp4e-print .religion .inventory-list, + .wfrp4e-print .inventory .inventory-list, + .wfrp4e-print .combat .inventory-list { + padding: 0 !important; + list-style-type: none !important; + } + + .wfrp4e-print .skill-type .inventory-list .item, + .wfrp4e-print .skill-type .inventory-header, + .wfrp4e-print .combat .melee-weapon-header, + .wfrp4e-print .combat .ranged-weapon-header, + .wfrp4e-print .combat .melee-weapon-list .content, + .wfrp4e-print .combat .ranged-weapon-list .content, + .wfrp4e-print .combat .melee-weapon-list .weapon-property, + .wfrp4e-print .combat .ranged-weapon-list .weapon-property, + .wfrp4e-print .talents .talent-header, + .wfrp4e-print .talents .talent-item .content, + .wfrp4e-print .talents .trait-list, + .wfrp4e-print .armour-section, + .wfrp4e-print .armour-section > *, + .wfrp4e-print .armour-section > *, + .wfrp4e-print #tab-sections > .content > .inventory > *, + .wfrp4e-print + #tab-sections + > .content + > .inventory + > .container + .inventory-list, + .wfrp4e-print .religion .religion-header, + .wfrp4e-print .religion .religion-header .religion-box-1, + .wfrp4e-print .religion .religion-header .religion-box-2, + .wfrp4e-print .religion .blessing-list, + .wfrp4e-print .religion .miracle-list, + .wfrp4e-print .magic .lore-header, + .wfrp4e-print .magic .lore-list .lore-item .content, + .wfrp4e-print .magic .petty-list { + justify-content: start !important; + align-items: stretch !important; + display: flex !important; + flex-direction: row !important; + } + + .wfrp4e-print #tab-sections > .content > .inventory > *, + .wfrp4e-print + #tab-sections + > .content + > .inventory + > .container + .inventory-list { + flex-wrap: wrap; + } + + .wfrp4e-print #tab-sections > .content > .inventory > *, + .wfrp4e-print .religion .religion-header, + .wfrp4e-print .religion .religion-header .religion-box-1, + .wfrp4e-print .religion .religion-header .religion-box-2, + .wfrp4e-print .religion .blessing-list, + .wfrp4e-print .religion .miracle-list, + .wfrp4e-print .combat .melee-weapon-list .weapon-property, + .wfrp4e-print .combat .ranged-weapon-list .weapon-property, + .wfrp4e-print .magic .petty-list, + .wfrp4e-print + #tab-sections + > .content + > .inventory + > .container + .inventory-list, + .wfrp4e-print .talents .trait-list { + gap: 10px !important; + } + + .wfrp4e-print + .combat + .melee-weapon-list + .weapon-property + .melee-property-quality, + .wfrp4e-print + .combat + .ranged-weapon-list + .weapon-property + .ranged-property-quality, + .wfrp4e-print + .combat + .melee-weapon-list + .weapon-property + .melee-property-flaw, + .wfrp4e-print + .combat + .ranged-weapon-list + .weapon-property + .ranged-property-flaw { + padding-right: 5px !important; + } + + .wfrp4e-print .combat .melee-weapon-header > *, + .wfrp4e-print .combat .melee-weapon-list .content > * { + flex: 25% !important; + } + + .wfrp4e-print .magic .lore-header > *, + .wfrp4e-print .magic .lore-list .lore-item .content > *, + .wfrp4e-print .combat .ranged-weapon-header > *, + .wfrp4e-print .combat .ranged-weapon-list .content > * { + flex: 20% !important; + } + + .wfrp4e-print .combat .ranged-weapon-list .content > *:not(.weapon-property) { + min-width: 0 !important; + max-width: 20% !important; + text-align: start !important; + } + + .wfrp4e-print .combat .ranged-weapon-list .weapon-property .label { + border: none !important; + } + + .wfrp4e-print .skill-type .inventory-list .item > *, + .wfrp4e-print .skill-type .inventory-header > *, + .wfrp4e-print .talents .talent-header > *, + .wfrp4e-print .talents .talent-item .content > *, + .wfrp4e-print .talents .talent-list .content > * { + flex: 33% !important; + } + + .wfrp4e-print .skill-type, + .wfrp4e-print .talents, + .wfrp4e-print .effects, + .wfrp4e-print .magic, + .wfrp4e-print .religion, + .wfrp4e-print #tab-sections > .content > .inventory, + .wfrp4e-print #tab-sections > .content > .inventory > .container, + .wfrp4e-print .combat { + justify-content: start !important; + align-items: stretch !important; + display: flex !important; + flex-direction: column !important; + } + + .wfrp4e-print .skill-type { + flex: 50% !important; + } + + .wfrp4e-print .armour-section * { + border: none !important; + } + + .wfrp4e-print .armour-section > * { + flex: 16% !important; + } + + .wfrp4e-print * { + background-color: transparent !important; + background-image: none !important; + border-image: none !important; + color: black !important; + border-color: black !important; + box-shadow: none !important; + text-shadow: none !important; + } + + .window-header { + display: none; + } + + .window-content { + background-image: none !important; + } + + .tab[data-tab] { + display: flex; + height: auto !important; + page-break-after: always; + page-break-inside: avoid; + break-inside: avoid; + } + + table, + li, + p { + page-break-inside: avoid; + break-inside: avoid; + } + + nav.tabs { + display: none !important; + } + + li.item { + page-break-inside: avoid; + break-inside: avoid; + } + + .window-resizable-handle, + .fa-edit, + .config-button, + .item-control, + .item-controls { + opacity: 0; + } + + .item-controls { + display: none; + } + + .editor-edit { + display: none !important; + } + + .journal-sheet select[name='folder'] { + background: none; + border: none; + -webkit-appearance: none; + -moz-appearance: none; + text-indent: 1px; + text-overflow: ''; + } + + .journal-sheet form .editor { + height: 100%; + } +}