diff --git a/resources/fillable-char-sheetstyle-1-2-spells.pdf b/resources/fillable-char-sheetstyle-1-2-spells.pdf index 1850a8f18..58992cdc4 100644 Binary files a/resources/fillable-char-sheetstyle-1-2-spells.pdf and b/resources/fillable-char-sheetstyle-1-2-spells.pdf differ diff --git a/resources/public/image/orcpub-card-logo.png b/resources/public/image/card-logo.png similarity index 100% rename from resources/public/image/orcpub-card-logo.png rename to resources/public/image/card-logo.png diff --git a/src/clj/orcpub/pdf.clj b/src/clj/orcpub/pdf.clj index 22363019b..50788de24 100644 --- a/src/clj/orcpub/pdf.clj +++ b/src/clj/orcpub/pdf.clj @@ -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] @@ -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))] @@ -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) @@ -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))] @@ -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 diff --git a/src/clj/orcpub/routes.clj b/src/clj/orcpub/routes.clj index 6ad49d245..8196e92b9 100644 --- a/src/clj/orcpub/routes.clj +++ b/src/clj/orcpub/routes.clj @@ -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) @@ -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.)] @@ -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) @@ -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") @@ -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)) diff --git a/src/cljc/orcpub/pdf_spec.cljc b/src/cljc/orcpub/pdf_spec.cljc index 46ed91045..181282106 100644 --- a/src/cljc/orcpub/pdf_spec.cljc +++ b/src/cljc/orcpub/pdf_spec.cljc @@ -292,6 +292,7 @@ print-prepared-spells? prepares-spells prepared-spells-by-class] + (let [flat-spells (char5e/flat-spells spells-known) spells-map @(subscribe [::spells/spells-map]) plugin-spells-map @(subscribe [::spells/plugin-spells-map]) @@ -379,14 +380,17 @@ spell-pages))))) (defn spellcasting-fields [built-char print-prepared-spells?] - (let [spells-known (char5e/spells-known built-char) - spell-attack-modifier-fn (char5e/spell-attack-modifier-fn built-char) + (let [spell-attack-modifier-fn (char5e/spell-attack-modifier-fn built-char) spell-save-dc-fn (char5e/spell-save-dc-fn built-char) spell-slots (char5e/spell-slots built-char) prepares-spells (char5e/prepares-spells built-char) - prepared-spells-by-class (char5e/prepared-spells-by-class built-char)] + prepared-spells-by-class (char5e/prepared-spells-by-class built-char) + sorted-spells-known (into {} + (map (fn [[id datum]] + [id (into (sorted-map) datum)])) + (char5e/spells-known built-char))] - (spell-page-fields spells-known + (spell-page-fields sorted-spells-known spell-slots spell-save-dc-fn spell-attack-modifier-fn @@ -498,7 +502,8 @@ print-spell-cards? print-prepared-spells? print-large-abilities? - print-character-sheet-style?] :as options}] + print-character-sheet-style? + print-spell-card-dc-mod?] :as options}] (let [race (char5e/race built-char) subrace (char5e/subrace built-char) abilities (abilities-spec @@ -572,7 +577,9 @@ :faction-name (char5e/faction-name built-char) :print-character-sheet? print-character-sheet? :print-spell-cards? print-spell-cards? - :print-character-sheet-style? print-character-sheet-style?} + :print-character-sheet-style? print-character-sheet-style? + :print-spell-card-dc-mod? print-spell-card-dc-mod? + } (attacks-and-spellcasting-fields built-char) (skill-fields built-char) abilities diff --git a/src/cljs/orcpub/dnd/e5/events.cljs b/src/cljs/orcpub/dnd/e5/events.cljs index 2908cbcd7..58d48455a 100644 --- a/src/cljs/orcpub/dnd/e5/events.cljs +++ b/src/cljs/orcpub/dnd/e5/events.cljs @@ -3791,6 +3791,16 @@ (fn [db _] (update db ::char5e/exclude-spell-cards-print? not))) +(reg-event-db + ::char5e/toggle-spell-cards-by-level + (fn [db _] + (update db ::char5e/exclude-spell-cards-by-level? not))) + +(reg-event-db + ::char5e/toggle-spell-cards-by-dc-mod + (fn [db _] + (update db ::char5e/exclude-spell-cards-by-dc-mod? not))) + (reg-event-db ::char5e/toggle-large-abilities-print (fn [db _] diff --git a/src/cljs/orcpub/dnd/e5/subs.cljs b/src/cljs/orcpub/dnd/e5/subs.cljs index 0f7068658..daa40bf05 100644 --- a/src/cljs/orcpub/dnd/e5/subs.cljs +++ b/src/cljs/orcpub/dnd/e5/subs.cljs @@ -1196,6 +1196,12 @@ (fn [db _] (-> db ::char5e/exclude-spell-cards-print? not))) +(reg-sub + ::char5e/print-spell-card-dc-mod? + (fn [db _] + (-> db ::char5e/exclude-spell-cards-by-dc-mod? not))) + + (reg-sub ::char5e/print-character-sheet? (fn [db _] diff --git a/src/cljs/orcpub/dnd/e5/views.cljs b/src/cljs/orcpub/dnd/e5/views.cljs index 0dbd30d9d..4793c6d05 100644 --- a/src/cljs/orcpub/dnd/e5/views.cljs +++ b/src/cljs/orcpub/dnd/e5/views.cljs @@ -3476,14 +3476,16 @@ print-spell-cards? print-prepared-spells? print-large-abilities? - print-character-sheet-style?] + print-character-sheet-style? + print-spell-card-dc-mod?] #(let [export-fn (export-pdf built-char id {:print-character-sheet? print-character-sheet? :print-spell-cards? print-spell-cards? :print-prepared-spells? print-prepared-spells? :print-large-abilities? print-large-abilities? - :print-character-sheet-style? print-character-sheet-style?})] + :print-character-sheet-style? print-character-sheet-style? + :print-spell-card-dc-mod? print-spell-card-dc-mod?})] (export-fn) (dispatch [::char/hide-options]))) @@ -3508,6 +3510,7 @@ print-prepared-spells? @(subscribe [::char/print-prepared-spells?]) print-large-abilities? @(subscribe [::char/print-large-abilities?]) print-character-sheet-style? @(subscribe [::char/print-character-sheet-style?]) + print-spell-card-dc-mod? @(subscribe [::char/print-spell-card-dc-mod?]) has-spells? (seq (char/spells-known built-char)) print-button-enabled (if (or (= print-character-sheet-style? nil) (= (str print-character-sheet-style?) "NaN")) @@ -3539,6 +3542,14 @@ [labeled-checkbox "Print Spell Cards" print-spell-cards?]]]]) + (if print-spell-cards? + [:div.m-b-2 + [:div.flex + [:div + {:on-click (make-event-handler ::char/toggle-spell-cards-by-dc-mod)} + [labeled-checkbox + "Print Spell DC and MOD" + print-spell-card-dc-mod?]]]]) (if has-spells? [:div.m-b-10 [:div.m-b-10 @@ -3565,7 +3576,8 @@ print-spell-cards? print-prepared-spells? print-large-abilities? - print-character-sheet-style?)} + print-character-sheet-style? + print-spell-card-dc-mod?)} "Print"]]])) (defn make-print-handler [id built-char] @@ -7522,7 +7534,8 @@ {:print-character-sheet? true :print-spell-cards? true :print-prepared-spells? false - :print-character-sheet-style? 1})} + :print-character-sheet-style? 1 + :print-spell-card-dc-mod? true})} "print"] (if (= username owner) [:button.form-button.m-l-5