diff --git a/src/cljs/wish/sheets/dnd5e/overlays/hp.cljs b/src/cljs/wish/sheets/dnd5e/overlays/hp.cljs index dbc1a0be..0cc17846 100644 --- a/src/cljs/wish/sheets/dnd5e/overlays/hp.cljs +++ b/src/cljs/wish/sheets/dnd5e/overlays/hp.cljs @@ -16,6 +16,10 @@ [wish.views.widgets.spinning-modifier :refer [spinning-modifier]])) +(defn- apply-hp-delta! [delta max-hp] + (>evt [::events/update-hp delta max-hp]) + (>evt [:toggle-overlay nil])) + (defn- condition-widget [[id level] _on-delete] (let [c (get data/conditions id)] @@ -120,8 +124,7 @@ {:on-submit (fn-click (let [{:keys [heal damage]} @state] (log "Update HP: heal +" heal " -" damage) - (>evt [::events/update-hp (- heal damage) max-hp]) - (>evt [:toggle-overlay nil])))} + (apply-hp-delta! (- heal damage) max-hp)))} [:div.sections [:div.quick-adjust @@ -224,7 +227,17 @@ :per-rotation (condp > max-hp 100 20 40) - :path [:heal]]] + :path [:heal]] + + (when (let [delta (:heal @state)] + (and delta (not= 0 delta))) + [:div.sections + [:input.apply {:type 'button + :value "Apply!" + :on-click (fn-click + (apply-hp-delta! (:heal @state) max-hp)) + }] ]) + ] ]) ; ======= public interface ================================ diff --git a/src/cljs/wish/sheets/dnd5e/overlays/style.cljs b/src/cljs/wish/sheets/dnd5e/overlays/style.cljs index 0bebce7d..80787049 100644 --- a/src/cljs/wish/sheets/dnd5e/overlays/style.cljs +++ b/src/cljs/wish/sheets/dnd5e/overlays/style.cljs @@ -86,7 +86,10 @@ [:.section-header {:margin-bottom "0px"}] [:.touchable (merge flex/vertical - flex/align-center)] + flex/align-center) + [:input.apply (merge + styles/button + {:margin-top "1em"})]] [:.new-hp (merge styles/text-center {:padding "12px" diff --git a/src/cljs/wish/views/widgets/spinning_modifier.cljs b/src/cljs/wish/views/widgets/spinning_modifier.cljs index 54e6c3de..451a4ece 100644 --- a/src/cljs/wish/views/widgets/spinning_modifier.cljs +++ b/src/cljs/wish/views/widgets/spinning_modifier.cljs @@ -85,14 +85,18 @@ :or {delta->color (constantly nil)}}] (letfn [(v [v] - (assoc-in @ratom path v))] + (v< [v] + (swap! ratom assoc-in path v))] (r/with-let [state (atom nil) rotation (r/atom 0)] (let [delta (int (* per-rotation (/ @rotation 360))) current (min (+ initial delta) maximum) color (delta->color delta)] + + (when-not (= (