From d7bc926607c644ac242e6d4631dd13ed5194fce3 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Mon, 5 Dec 2016 09:37:14 -0800 Subject: [PATCH] panning cancels click --- desktop/src-common/advent/screens/dialogue.clj | 11 +++++++---- desktop/src-common/advent/screens/scene.clj | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/desktop/src-common/advent/screens/dialogue.clj b/desktop/src-common/advent/screens/dialogue.clj index c7eae4f3..bf9b163d 100644 --- a/desktop/src-common/advent/screens/dialogue.clj +++ b/desktop/src-common/advent/screens/dialogue.clj @@ -286,20 +286,23 @@ :on-hover-start (fn [screen {:keys [all-icons] :as entities} {:keys [hover-text x y scene-viewport cursor ]}] + (println cursor hover-text) (let [x (if utils/mobile? x (+ 8 x)) [scene-x scene-y] (scene-world->talk-world scene-viewport [x y]) - depressed? (< 0.5 (- (or (:total-time screen) 0) (int (or (:total-time screen) 0))))] + depressed? (< 0.5 (- (or (:total-time screen) 0) (int (or (:total-time screen) 0)))) + item-cursor (:cursor (first (:last cursor))) + action-cursor (utils/translate-depressed (first (:last cursor)) depressed?)] (label! (get-in entities [:label]) :set-text hover-text) (cond-> entities true (assoc-in [:label :text] hover-text) utils/mobile? (update-in [:label] assoc :x (* 20 4) :y 12) - (and utils/mobile? (or (:cursor (first (:last cursor))) (first (:last cursor)))) + (and utils/mobile? (or item-cursor action-cursor) + #_(not= :main action-cursor)) (assoc-in [:action-icon] (assoc - (texture (aget all-icons 0 (.indexOf utils/+all-cursors+ (or (:cursor (first (:last cursor))) (utils/translate-depressed (first (:last cursor)) - depressed?))))) + (texture (aget all-icons 0 (.indexOf utils/+all-cursors+ (or item-cursor action-cursor)))) :x 4 :y 4 :width (* 18 4) :height (* 16 4))) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 08f8dd49..15ed57e1 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -1122,7 +1122,13 @@ void main () e))) (defn mouse-moved [screen entities {:keys [input-x input-y] :as options}] - (utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options)) + (if utils/mobile? + (-> entities + (assoc-in [:cursor :last] [:main nil]) + (assoc-in [:cursor :override] nil) + (assoc-in [:cursor :down-target] nil) + (assoc-in [:label :text] "")) + (utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options))) (defn grab-layers [entities] (update-in entities [:room] @@ -1343,7 +1349,7 @@ void main () entities )) - :on-scrolled + #_#_:on-scrolled (fn [{:keys [^OrthographicCamera camera ^FitViewport viewport ^Stage renderer] :as screen} entities options] (update-in entities [:cam :zoom] #(* % (+ 1 (/ (double (:amount options)) 100.0 ))))) @@ -1447,7 +1453,9 @@ void main () (set! (. camera zoom) (:zoom (:cam entities))) (set! (.. camera position x) (:x (:cam entities) 160.0)) (set! (.. camera position y) (:y (:cam entities) 120.0))) - (let [entities (utils/update-override screen entities options) + (let [entities (if utils/mobile? + entities + (utils/update-override screen entities options)) entities (play-key-sounds screen entities) entities (update-current-sound-vols! entities) entities (remove-ended-sounds screen entities)] @@ -1470,7 +1478,7 @@ void main () (filter identity))] (utils/stop-music snd))) - :on-mouse-moved + #_#_:on-mouse-moved mouse-moved :on-touch-dragged @@ -1478,6 +1486,7 @@ void main () :on-touch-down (fn [{:keys [^FitViewport viewport] :as screen} entities {:keys [input-x input-y] :as options}] + (when (utils/contains-point? (.getScreenX viewport) (.getScreenY viewport) (.getScreenWidth viewport) (.getScreenHeight viewport) input-x input-y) @@ -1488,6 +1497,7 @@ void main () (not (get-in entities [:state :hud-active?])) (= 0.0 (get-in entities [:fade :opacity]))) (let [[x y] (utils/unproject screen options) + entities (utils/update-override screen (assoc-in entities [:cursor :last-pos] [input-x input-y]) options) interaction (get-interaction entities x y) interacting-entity (get-interacting-entity entities x y)] (-> entities