From a1c51a79da8169c9ce2ecd3b46f29fd7782bb50d Mon Sep 17 00:00:00 2001 From: = Date: Mon, 15 Sep 2014 21:04:09 -0700 Subject: [PATCH] one cursor to rule them all. --- desktop/resources/cursor.png | Bin 2254 -> 2131 bytes desktop/src-common/advent/screens/scene.clj | 99 ++++++-------------- 2 files changed, 30 insertions(+), 69 deletions(-) diff --git a/desktop/resources/cursor.png b/desktop/resources/cursor.png index 10516fd9274eaf390c2c0dae0e2d9a264b568a72..ad16cbc89319e7fba6d9d751af6c1a5fbf323763 100644 GIT binary patch delta 1040 zcmV+r1n>LK5z`Q`Qv`nl>PbXFRA>e5SHDYKK@c9rG-;AxD(@_8f?yLYY>tTeaR_OH zT$9Smzd+0%5D=@BRze`nA^rg(Cc$8Hh1dvUV?yq%5@MAmMDxCl-(}vq``+$*XN<%J z-MQWQW@hJ`o!b*pqf)7ys*l&=e~^JbeMS~Qr_)KTYaN%|*;s!xg;S|7MB!Yv%B(T| zEE_RrgS{C2EWbtf%ESFH?+0TTDG%!qk!Z!b5Tv9YlzQj6pQ7+)YU z1(jvTXP@i9p7EJ^-hKi&ha{1@oPWICqIfB@ov3!ZEv`QXXX|s_H6w{J`m_O@{l~qK znFNOD+BzDW7k_`Z185^Cg4mm)@nz(1`yafw=g#N@?^g_B2I(BlW|N{c8Vw_3|Lknt zJqkXO4-XFwkx6IFyh*gf890oQkrAQHy}X$O66cD|*GV*%zEK3e_)P&2qyxK*A^`c{ zKX2w5*TIcPlLo3~A8}9w?&fe!Zgqaj?Z@+7xAmFdH~Q<^d)Ya8E=QY7-Mu`) zCO%I;Z$B%EdDzf>AAuqGJghJNa|M7KQms~v&mvubANlIdpIfM z{cmLO*_3~5tX8EyGbQtlsw_3zNwJ8t3*dlgd3vx5=(Q}_#=CTV?GyyK^zAjRr`tFQ zgnmdI+AeM40gsW_HK0%519Xf8wpy)j>x7}?9f0Y=e-(iIp|hJ0@_F<3x9=z3znCHz z?_ZSqNn2jKyPt_u|MQWLbNWU|*H~Fu5hhRD!5V*ZIXgQm6B849t1E*T4SgUe4$M#|KFVxK}e~dFy5El?)HvmC@R+JegTA z9pGrw?^$;NoQY@gBhouQ;-KXtPFp~}l02GD;IfrxgZQi>fPYt^WxUOds z>^ie+jqNmqIPC|v5=^R{$Jns(uGqA{GID>4eEl7UWQ98Z_~NN)d%j1X>(-VD+J_}! z`VmCZfeAei?bBW?PU8_vOfHGVT*N;y+74ycInEUTl`*>jdSA;d0=tmg zjvX?RSq9$=8@-6ZK9~NSDgeE46=hxhWr@3r=f95mIs?%e_yus5n>Qv`nmWl2OqRA>e5S4&7$K^Xq8=%!7HwJ0kRA_562!3ZgOiP)xv ziJNF~iLiZ1(K?D2)h<^;(Z2#}3Lkrp<1B;M2CjlHdRjVJFua81wJ zoPAJ*LP1;~6S9BpIq&Lmh*|6z1Ag{LU7DT%rm?kcv~MW?qyii`Gm$HHieWAQt=qBH zjyo&kFRvbYZ%_T&E#C5t+Yiv$1_uWzN>5LZk)elOTm=#x1s}-c;*5BVxv810a2}**b9B2UH;>xMFx7QiX_N7s|{1XBke!Va< z;L|Jam+V;`eY*C>d+U^`5dn~{9$NMR2S@lVSkWd6i$7%1&b}mUd-v3ho*23>&wlQc zk9STdx{!Zh10S*v>B}8r$TzLt2VffikgqR)LjZz5`Ls^zS|&@@%Sr(pwZ%mzk0krUgonQ!N!_X(*Cm`7u?nFuXKFigDAe1rfLif z3ON{Jz{flO=(-93Odkn+5q!YG-UpnH zg#(VkHJ8X0D-?tN#%8=bGlF70GMnZyC5^ur)hxG@dzTx16`IFw!bSkyzu=hRsT(^G~ z_A}iGn0^EibgY&2AQ>;KANK`+8PpO*6kxkHf6QAMq=VQK^4ukBL6tRqrhKnD^-t=Q$$au=vf9l;%$w^9ktr ebEscreen screen {:x (:input-x screen) :y (:input-y screen)}) interaction (first (filter #(mouse-in? % [x y]) (get-in entities [:background :interactions]))) - current-cursor (get-in entities [:cursor :current]) cursor-override (get-in entities [:cursor :override]) ;; TODO - hacky way of resetting queue entities (if-let [current-action (get-in entities [:actions :current])] @@ -79,10 +60,10 @@ :actions {:channel (chan) :current nil :started? false}) entities) script (or (when cursor-override - (interact cursor-override screen entities current-cursor [x y])) + (interact cursor-override screen entities [x y])) (when interaction - (interact interaction screen entities current-cursor [x y])) - (interact default-interaction screen entities current-cursor [x y]))] + (interact interaction screen entities [x y])) + (interact default-interaction screen entities [x y]))] (script (get-in entities [:actions :channel])) entities)) @@ -130,7 +111,7 @@ :on-show (fn [screen entities] (update! screen :renderer (stage) :camera (orthographic)) - (let [_ (input! :set-cursor-image (cursor "cursor.png" :walk) 0 0) + (let [_ (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) sheep-sheet (texture! (texture "outsidehouse/sheep-anim.png") :split 33 21) sheep (animation 0.15 (for [i (flatten [(repeat 10 0) 1 2 3 4 5 6 7 4 5 6 7 8 9 10 (repeat 25 11) (repeat 15 12)])] (aget sheep-sheet 0 i))) @@ -146,7 +127,7 @@ :channel (chan) :current nil :started? false} - :cursor {:id "cursor" :current :walk } + :cursor {:id "cursor" :current :main } :sheep (assoc (animation->texture screen sheep) :x 38 :y 160 :baseline 160 :anim sheep) :background (assoc {} :collision (advent.pathfind/map-from-resource "pathfind-test-big.png") @@ -156,7 +137,7 @@ (mouse-in? [_ location] (apply (zone/box 300 131 320 224) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [319 160]))) ICursorOverridable @@ -166,7 +147,7 @@ (mouse-in? [_ location] (apply (zone/box 60 180 224 240) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [137 204]))) ICursorOverridable @@ -176,7 +157,7 @@ (mouse-in? [_ location] (apply (zone/box 0 40 20 140) location)) IInteractable - (interact [_ _ entities _ _] + (interact [_ _ entities _] (actions/get-script (actions/walk-to entities :ego [0 80]))) ICursorOverridable @@ -186,49 +167,31 @@ (mouse-in? [_ location] (apply (zone/box 258 100 281 160) location)) IInteractable - (interact [_ _ entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "The last time I went through that door, Fangald turned me into a frog."))) - - :touch - (actions/get-script - (actions/walk-to entities :ego [262 88]) - (actions/talk entities :ego (str "Anyone home?"))) - nil))) + (interact [_ _ entities _] + (actions/get-script + (actions/walk-to entities :ego [262 88]) + (actions/talk entities :ego (str "Anyone home?"))))) (reify IMouseIn (mouse-in? [_ location] (apply (zone/box 274 55 305 88) location)) IInteractable - (interact [_ screen entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "It's the coolest sword I've ever seen!"))) - :touch - (actions/get-script - (actions/walk-to entities :ego [290 66]) - (actions/talk entities :ego "Maybe I can pull it out.")) - nil))) + (interact [_ screen entities _] + (actions/get-script + (actions/talk entities :ego (str "It's the coolest sword I've ever seen!")) + (actions/walk-to entities :ego [290 66]) + (actions/talk entities :ego "Maybe I can pull it out.")))) (reify IMouseIn (mouse-in? [_ location] (apply (zone/box 38 160 71 181) location)) IInteractable - (interact [_ screen entities cursor _] - (case cursor - :look - (actions/get-script - (actions/talk entities :ego (str "Aww, it's a cute little sheep."))) - :touch - (actions/get-script - (if ((get-in entities [:ego :inventory]) :wool) - (actions/talk entities :ego "The sheep has given me enough wool.") - (do (actions/give entities :ego :wool) - (actions/talk entities :ego "I guess his wool is shedding.")))) - nil)))] + (interact [_ screen entities _] + (actions/get-script + (if ((get-in entities [:ego :inventory]) :wool) + (actions/talk entities :ego "The sheep has given me enough wool.") + (do (actions/give entities :ego :wool) + (actions/talk entities :ego "I guess his wool is shedding."))))))] :scale-fn (scaler-fn-with-baseline 110 0.10 1.00) :layers [(assoc background :x 0 :y 0 :baseline 0) (assoc house :x 0 :y 0 :baseline 122) @@ -266,10 +229,8 @@ (assoc-in entities [:cursor :override] mouse-override))) (when (get-in entities [:cursor :override]) - (do (input! :set-cursor-image (cursor "cursor.png" (get-in entities [:cursor :current])) 0 0) + (do (input! :set-cursor-image (cursor "cursor.png" :main) 0 0) (assoc-in entities [:cursor :override] nil)))))) :on-touch-down (fn [screen [entities]] - (if (= (button-code :right) (:button screen)) - (right-click screen entities) - (left-click screen entities)))) + (left-click screen entities)))