Commit before using central mouse context type
This commit is contained in:
@@ -16,8 +16,15 @@ data PressType
|
||||
| LongPress
|
||||
deriving (Eq, Show)
|
||||
|
||||
data MouseContext
|
||||
= NoMouseContext
|
||||
| OverInv (Int,Int)
|
||||
| OverCombInv (Int,Int)
|
||||
| OverTerminalScreen
|
||||
|
||||
data Input = Input
|
||||
{ _mousePos :: Point2 -- in pixels, from the center of the screen
|
||||
, _mouseContext :: MouseContext
|
||||
, _mouseMoving :: Bool
|
||||
, _pressedKeys :: M.Map Scancode PressType
|
||||
, _mouseButtons :: M.Map MouseButton Int -- counts number of frames held down
|
||||
|
||||
@@ -15,6 +15,7 @@ defaultInput :: Input
|
||||
defaultInput =
|
||||
Input
|
||||
{ _clickPos = mempty
|
||||
, _mouseContext = NoMouseContext
|
||||
, _clickWorldPos = mempty
|
||||
, _heldPos = mempty
|
||||
, _heldWorldPos = mempty
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Render.Picture (
|
||||
fixedCoordPictures,
|
||||
) where
|
||||
|
||||
import Dodge.CharacterEnums
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
@@ -79,6 +80,7 @@ drawMouseCursor u =
|
||||
mouseCursorType :: Universe -> Picture
|
||||
mouseCursorType u
|
||||
| isselect = drawPlus 5
|
||||
| Just tmid <- u ^? uvWorld . hud . hudElement . subInventory . termID = determineTermCursor tmid u
|
||||
| Just csel <- u ^? uvWorld . hud . hudElement . subInventory . ciSelection =
|
||||
if ( csel == u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just
|
||||
|| null (u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just)
|
||||
@@ -100,6 +102,17 @@ mouseCursorType u
|
||||
argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- cpos)
|
||||
- w ^. wCam . camRot
|
||||
|
||||
determineTermCursor :: Int -> Universe -> Picture
|
||||
determineTermCursor tmid u = fromMaybe (drawPlus 5) $ do
|
||||
return drawReturn
|
||||
|
||||
drawReturn :: Picture
|
||||
drawReturn = scale 0.1 0.1 . translate (-50) (-100) $ text [toEnum 153]
|
||||
|
||||
drawWireRectCursor :: Picture
|
||||
drawWireRectCursor = scale 0.1 0.1 $ text [cWireRect]
|
||||
--drawReturn = text "ASDF"
|
||||
|
||||
drawPlus :: Float -> Picture
|
||||
drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
|
||||
|
||||
|
||||
+12
-12
@@ -1,24 +1,24 @@
|
||||
module Dodge.SelectUse
|
||||
where
|
||||
module Dodge.SelectUse (selectUse) where
|
||||
|
||||
import Dodge.Payload
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
import Dodge.Payload
|
||||
|
||||
selectUse :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
selectUse ittree _ w = fromMaybe w $ do
|
||||
itid <- ittree ^? ldtValue . itID
|
||||
pjid <- ittree ^? ldtValue . itUse . uaParams . apLinkedProjectile . _Just
|
||||
thepj <- w ^? cWorld . lWorld . projectiles . ix pjid
|
||||
return $ w
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU (Just itid) 30] -- 69 is placeholder, should be removed
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & itPoint . itUse . heldUse .~ HeldDoNothing
|
||||
-- & itPoint . itUse . heldMods .~ DoNothingMod
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU (Just itid) 30] -- 69 is placeholder, should be removed
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & itPoint . itUse . heldUse .~ HeldDoNothing
|
||||
-- & itPoint . itUse . heldMods .~ DoNothingMod
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
|
||||
-- where
|
||||
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
|
||||
|
||||
|
||||
@@ -301,6 +301,10 @@ checkTermDist w = fromMaybe w $ do
|
||||
w & hud . hudElement . subInventory
|
||||
.~ NoSubInventory MouseInvNothing
|
||||
|
||||
-- for other mouse effects, see yourControl
|
||||
updateMouseInventoryEffects :: Configuration -> World -> World
|
||||
updateMouseInventoryEffects cfig w = w
|
||||
|
||||
updateMouseInventorySelection :: Configuration -> World -> World
|
||||
updateMouseInventorySelection cfig w = fromMaybe w $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
|
||||
Reference in New Issue
Block a user