This commit is contained in:
2022-06-29 12:42:02 +01:00
parent e24f89217a
commit 1f4f1f6ab1
3 changed files with 10 additions and 13 deletions
+5 -7
View File
@@ -3,17 +3,17 @@ Module : Dodge.Event
Description : Direct event handling
Deals with direct events.
This includes individual key or mouse presses, but /not/ continuous held down input.
We cannot handle multiple keys held down at once here,
This could include individual key or mouse presses.
However, we cannot handle multiple keys held down at once here,
(eg left mouse button + right mouse button)
because these are separate events.
Instead we store the events in a set, and deal with the combinations in
"Dodge.Update"; in particular see 'updatePressedButtons'.
Nor could we handle continuous mouse button input.
Instead we store button presses (in a Map) and deal with the combinations in
the simulation step; in particular see 'updatePressedButtons'.
-}
module Dodge.Event
( handleEvent
) where
import Dodge.Terminal
import Dodge.InputFocus
import Dodge.Combine
import Dodge.Event.Keyboard
@@ -26,13 +26,11 @@ import Dodge.Data
import Dodge.PreloadData
--import Dodge.Creature.Action
import Dodge.Inventory
import Dodge.Inventory.Add
import Dodge.SoundLogic
--import Geometry
--import Preload.Update
--import Dodge.FloorItem
import qualified IntMapHelp as IM
import ListHelp
--import Data.Monoid
import Control.Lens
-1
View File
@@ -25,7 +25,6 @@ updateUsingInput w = case _hudElement $ _hud w of
DisplayCarte
-> updatePressedButtonsCarte (_mouseButtons w) w
-- ugly check for subinventory inventory hammer, this should change
updatePressedButtons :: SubInventory -> M.Map MouseButton Bool -> World -> World
updatePressedButtons subinv pkeys w = case subinv of
NoSubInventory
+5 -5
View File
@@ -16,7 +16,7 @@ import Geometry
import Data.Maybe
import Data.Bifunctor
import Streaming
import StreamingHelp
import qualified Streaming.Prelude as S
{- List those objects that appear on a line. -}
@@ -24,12 +24,12 @@ thingsHit
:: Point2 -- ^ Line start point
-> Point2 -- ^ Line end point
-> World
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
-> StreamOf (Point2, Either Creature Wall)
thingsHit sp ep w = void $ S.mergeOn (dist sp . fst)
(S.map (second Left) (crsHit sp ep w))
(S.map (second Right) (wlsHit sp ep w))
crsHit :: Point2 -> Point2 -> World -> Stream (Of (Point2, Creature)) Identity ()
crsHit :: Point2 -> Point2 -> World -> StreamOf (Point2, Creature)
crsHit sp ep
| sp == ep = const mempty
| otherwise = sortStreamOn (dist sp . fst)
@@ -48,14 +48,14 @@ thingsHitExceptCr
-> Point2 -- ^ Line start point
-> Point2 -- ^ Line end point
-> World
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
-> StreamOf (Point2, Either Creature Wall)
thingsHitExceptCr Nothing sp ep = thingsHit sp ep
thingsHitExceptCr (Just cid) sp ep = S.filter crNotCid . thingsHit sp ep
where
crNotCid (_,Left cr) = _crID cr /= cid
crNotCid _ = True
wlsHit :: Point2 -> Point2 -> World -> Stream (Of (Point2, Wall)) Identity ()
wlsHit :: Point2 -> Point2 -> World -> StreamOf (Point2, Wall)
wlsHit sp ep
| sp == ep = const mempty
| otherwise = sortStreamOn (dist sp . fst)