Skip to content

Commit

Permalink
Merge remote-tracking branch 'DMV-orcpub/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
codeGlaze committed Apr 11, 2021
2 parents a1e80c9 + f71a828 commit e6f8543
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 75 deletions.
Binary file modified resources/fillable-char-sheetstyle-1-2-spells.pdf
Binary file not shown.
File renamed without changes
11 changes: 6 additions & 5 deletions src/clj/orcpub/pdf.clj
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@
(+ margin-x total-width)
y)))
(.setStrokingColor cs 0 0 0)))

(defn spell-school-level [{:keys [level school]} class-nm]
(if (zero? level)
(str class-nm " - "(s/capitalize school) " cantrip")
(str class-nm " Cantrip " (s/capitalize school))
(str class-nm " Level " level " " (str (s/capitalize school)))))

(defn draw-spell-field [cs document title value x y]
Expand Down Expand Up @@ -282,7 +283,7 @@
remaining-height (- 11.0 total-height)
margin-y (/ remaining-height 2)
fonts (load-fonts document)]
(with-open [img-stream (io/input-stream (io/resource "public/image/orcpub-card-logo.png"))
(with-open [img-stream (io/input-stream (io/resource "public/image/card-logo.png"))
over-img-stream (io/input-stream (io/resource "public/image/clockwise-rotation.png"))]
(let [img (LosslessFactory/createFromImage document (ImageIO/read img-stream))
over-img (LosslessFactory/createFromImage document (ImageIO/read over-img-stream))]
Expand Down Expand Up @@ -326,7 +327,7 @@
(- box-width 0.3)
(- box-height 0.2))))))))))

(defn print-spells [cs document box-width box-height spells page-number]
(defn print-spells [cs document box-width box-height spells page-number print-spell-card-dc-mod?]
(let [num-boxes-x (int (/ 8.5 box-width))
num-boxes-y (int (/ 11.0 box-height))
total-width (* num-boxes-x box-width)
Expand All @@ -336,7 +337,7 @@
remaining-height (- 11.0 total-height)
margin-y (/ remaining-height 2)
fonts (load-fonts document)]
(with-open [card-logo-img-stream (io/input-stream (io/resource "public/image/orcpub-card-logo.png"))
(with-open [card-logo-img-stream (io/input-stream (io/resource "public/image/card-logo.png"))
over-img-stream (io/input-stream (io/resource "public/image/clockwise-rotation.png"))]
(let [card-logo-img (LosslessFactory/createFromImage document (ImageIO/read card-logo-img-stream))
over-img (LosslessFactory/createFromImage document (ImageIO/read over-img-stream))]
Expand Down Expand Up @@ -417,7 +418,7 @@
0.2)
(draw-text-to-box cs
(if (not= class-nm "Homebrew")
(str (spell-school-level spell class-nm) " " dc-str (str " Spell Mod " (common/bonus-str attack-bonus)))
(str (spell-school-level spell class-nm) (when print-spell-card-dc-mod? (str " " dc-str (str " Spell Mod " (common/bonus-str attack-bonus)))))
(spell-school-level spell class-nm))
(:italic fonts)
8
Expand Down
11 changes: 6 additions & 5 deletions src/clj/orcpub/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
:weapon-name-2 8
:weapon-name-3 8}))

(defn add-spell-cards! [doc spells-known spell-save-dcs spell-attack-mods custom-spells] (try
(defn add-spell-cards! [doc spells-known spell-save-dcs spell-attack-mods custom-spells print-spell-card-dc-mod?] (try
(let [custom-spells-map (common/map-by-key custom-spells)
spells-map (merge spells/spell-map custom-spells-map)
flat-spells (-> spells-known vals flatten)
Expand All @@ -421,7 +421,7 @@
class)
key])
flat-spells)
parts (vec (partition-all 9 sorted-spells))]
parts (vec (partition-all 9 flat-spells))]
(doseq [i (range (count parts))
:let [part (parts i)]]
(let [page (PDPage.)]
Expand All @@ -444,7 +444,8 @@
2.5
3.5
spells
i))
i
print-spell-card-dc-mod?))
back-page (PDPage.)]
(with-open [back-page-cs (PDPageContentStream. doc back-page)]
(.addPage doc back-page)
Expand All @@ -453,7 +454,7 @@

(defn character-pdf-2 [req]
(let [fields (-> req :form-params :body edn/read-string)
{:keys [image-url image-url-failed faction-image-url faction-image-url-failed spells-known custom-spells spell-save-dcs spell-attack-mods print-spell-cards? print-character-sheet-style?]} fields
{:keys [image-url image-url-failed faction-image-url faction-image-url-failed spells-known custom-spells spell-save-dcs spell-attack-mods print-spell-cards? print-character-sheet-style? print-spell-card-dc-mod?]} fields

sheet6 (str "fillable-char-sheetstyle-" print-character-sheet-style? "-6-spells.pdf")
sheet5 (str "fillable-char-sheetstyle-" print-character-sheet-style? "-5-spells.pdf")
Expand All @@ -476,7 +477,7 @@
(with-open [doc (PDDocument/load input)]
(pdf/write-fields! doc fields (not chrome?) font-sizes)
(if (and print-spell-cards? (seq spells-known))
(add-spell-cards! doc spells-known spell-save-dcs spell-attack-mods custom-spells))
(add-spell-cards! doc spells-known spell-save-dcs spell-attack-mods custom-spells print-spell-card-dc-mod?))
(if (and image-url
(re-matches #"^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]" image-url)
(not image-url-failed))
Expand Down
Loading

0 comments on commit e6f8543

Please sign in to comment.