Move held item scrolling into dedicated datatype
This commit is contained in:
+5
-25
@@ -10,6 +10,8 @@ circular imports are probably not a good idea.
|
|||||||
{-# LANGUAGE DerivingStrategies #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
module Dodge.Data
|
module Dodge.Data
|
||||||
( module Dodge.Data
|
( module Dodge.Data
|
||||||
|
, module Dodge.Data.Item.HeldScroll
|
||||||
|
, module Dodge.Data.Item.Consumption
|
||||||
, module Dodge.Data.Gas
|
, module Dodge.Data.Gas
|
||||||
, module Dodge.Data.Ammo
|
, module Dodge.Data.Ammo
|
||||||
, module Dodge.Data.Payload
|
, module Dodge.Data.Payload
|
||||||
@@ -56,6 +58,8 @@ module Dodge.Data
|
|||||||
, module Dodge.Data.RadarBlip
|
, module Dodge.Data.RadarBlip
|
||||||
, module Dodge.Data.PathGraph
|
, module Dodge.Data.PathGraph
|
||||||
) where
|
) where
|
||||||
|
import Dodge.Data.Item.HeldScroll
|
||||||
|
import Dodge.Data.Item.Consumption
|
||||||
import Dodge.Data.Gas
|
import Dodge.Data.Gas
|
||||||
import Dodge.Data.Ammo
|
import Dodge.Data.Ammo
|
||||||
import Dodge.Data.Payload
|
import Dodge.Data.Payload
|
||||||
@@ -401,7 +405,7 @@ data ItemUse
|
|||||||
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
||||||
, _useHammer :: HammerPosition
|
, _useHammer :: HammerPosition
|
||||||
, _useAim :: AimParams
|
, _useAim :: AimParams
|
||||||
, _heldScroll :: Float -> Creature -> Item -> Item
|
, _heldScroll :: HeldScroll --Float -> Creature -> Item -> Item
|
||||||
}
|
}
|
||||||
| LeftUse
|
| LeftUse
|
||||||
{ _lUse :: Item -> Creature -> World -> World
|
{ _lUse :: Item -> Creature -> World -> World
|
||||||
@@ -428,29 +432,6 @@ data Equipment = Equipment
|
|||||||
_itUseAimStance :: Item -> AimStance
|
_itUseAimStance :: Item -> AimStance
|
||||||
_itUseAimStance = _aimStance . _useAim . _itUse
|
_itUseAimStance = _aimStance . _useAim . _itUse
|
||||||
|
|
||||||
data ItemConsumption
|
|
||||||
= LoadableAmmo
|
|
||||||
{ _laAmmoType :: AmmoType
|
|
||||||
, _laMax :: Int
|
|
||||||
, _laLoaded :: Int
|
|
||||||
, _laPrimed :: Bool
|
|
||||||
, _laCycle :: [LoadAction]
|
|
||||||
, _laProgress :: Maybe [LoadAction]
|
|
||||||
}
|
|
||||||
| AutoRecharging
|
|
||||||
{ _arLoaded :: Int
|
|
||||||
, _arMax :: Int
|
|
||||||
, _arTime :: Int
|
|
||||||
, _arProgress :: Int
|
|
||||||
}
|
|
||||||
| ChargeableAmmo
|
|
||||||
{ _wpMaxCharge :: Int
|
|
||||||
, _wpCharge :: Int
|
|
||||||
}
|
|
||||||
| ItemItselfConsumable
|
|
||||||
{ _icAmount :: IcAmount
|
|
||||||
}
|
|
||||||
| NoConsumption
|
|
||||||
data Item = Item
|
data Item = Item
|
||||||
{ _itConsumption :: ItemConsumption
|
{ _itConsumption :: ItemConsumption
|
||||||
, _itUse :: ItemUse
|
, _itUse :: ItemUse
|
||||||
@@ -1279,7 +1260,6 @@ makeLenses ''Item
|
|||||||
makeLenses ''ItemUse
|
makeLenses ''ItemUse
|
||||||
makeLenses ''ItEffect
|
makeLenses ''ItEffect
|
||||||
makeLenses ''FloorItem
|
makeLenses ''FloorItem
|
||||||
makeLenses ''ItemConsumption
|
|
||||||
makeLenses ''TweakParam
|
makeLenses ''TweakParam
|
||||||
makeLenses ''Prop
|
makeLenses ''Prop
|
||||||
makeLenses ''Proj
|
makeLenses ''Proj
|
||||||
|
|||||||
@@ -2,3 +2,30 @@
|
|||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Data.Item.Consumption where
|
module Dodge.Data.Item.Consumption where
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
import Dodge.Data.Ammo
|
||||||
|
import Dodge.Data.LoadAction
|
||||||
|
import Dodge.Data.ItemAmount
|
||||||
|
data ItemConsumption
|
||||||
|
= LoadableAmmo
|
||||||
|
{ _laAmmoType :: AmmoType
|
||||||
|
, _laMax :: Int
|
||||||
|
, _laLoaded :: Int
|
||||||
|
, _laPrimed :: Bool
|
||||||
|
, _laCycle :: [LoadAction]
|
||||||
|
, _laProgress :: Maybe [LoadAction]
|
||||||
|
}
|
||||||
|
| AutoRecharging
|
||||||
|
{ _arLoaded :: Int
|
||||||
|
, _arMax :: Int
|
||||||
|
, _arTime :: Int
|
||||||
|
, _arProgress :: Int
|
||||||
|
}
|
||||||
|
| ChargeableAmmo
|
||||||
|
{ _wpMaxCharge :: Int
|
||||||
|
, _wpCharge :: Int
|
||||||
|
}
|
||||||
|
| ItemItselfConsumable
|
||||||
|
{ _icAmount :: IcAmount
|
||||||
|
}
|
||||||
|
| NoConsumption
|
||||||
|
makeLenses ''ItemConsumption
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
--{-# LANGUAGE StrictData #-}
|
||||||
|
module Dodge.Data.Item.HeldScroll where
|
||||||
|
|
||||||
|
data HeldScroll = HeldScrollDoNothing | HeldScrollZoom | HeldScrollCharMode
|
||||||
@@ -65,7 +65,7 @@ defaultrUse = RightUse
|
|||||||
, _useMods = []
|
, _useMods = []
|
||||||
, _useHammer = HammerUp
|
, _useHammer = HammerUp
|
||||||
, _useAim = defaultAimParams
|
, _useAim = defaultAimParams
|
||||||
, _heldScroll = \_ _ -> id
|
, _heldScroll = HeldScrollDoNothing
|
||||||
}
|
}
|
||||||
defaultlUse :: ItemUse
|
defaultlUse :: ItemUse
|
||||||
defaultlUse = LeftUse
|
defaultlUse = LeftUse
|
||||||
|
|||||||
+2
-1
@@ -14,6 +14,7 @@ the simulation step; in particular see 'updatePressedButtons'.
|
|||||||
module Dodge.Event
|
module Dodge.Event
|
||||||
( handleEvent
|
( handleEvent
|
||||||
) where
|
) where
|
||||||
|
import Dodge.HeldScroll
|
||||||
import Dodge.InputFocus
|
import Dodge.InputFocus
|
||||||
import Dodge.Combine
|
import Dodge.Combine
|
||||||
import Dodge.Event.Keyboard
|
import Dodge.Event.Keyboard
|
||||||
@@ -110,7 +111,7 @@ wheelEvent y w = case _hudElement $ _hud w of
|
|||||||
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll,_rbOptions w) of
|
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll,_rbOptions w) of
|
||||||
(_,EquipOptions{}) -> scrollRBOption y w
|
(_,EquipOptions{}) -> scrollRBOption y w
|
||||||
(Nothing,_) -> closeObjScrollDir y w
|
(Nothing,_) -> closeObjScrollDir y w
|
||||||
(Just f,_) -> w & creatures . ix 0 . crInv . ix (crSel $ you w) %~ f y (you w)
|
(Just f,_) -> w & creatures . ix 0 . crInv . ix (crSel $ you w) %~ doHeldScroll f y (you w)
|
||||||
| lbDown -> w & cameraZoom +~ y
|
| lbDown -> w & cameraZoom +~ y
|
||||||
| invKeyDown -> changeSwapInvSel yi w
|
| invKeyDown -> changeSwapInvSel yi w
|
||||||
| otherwise -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
|
| otherwise -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
module Dodge.HeldScroll
|
||||||
|
( doHeldScroll
|
||||||
|
) where
|
||||||
|
import Dodge.Data
|
||||||
|
import Dodge.Item.Weapon.ZoomScope
|
||||||
|
import Control.Lens hiding ((|>),(<|))
|
||||||
|
import Data.Sequence
|
||||||
|
|
||||||
|
doHeldScroll :: HeldScroll -> Float -> Creature -> Item -> Item
|
||||||
|
doHeldScroll hs = case hs of
|
||||||
|
HeldScrollDoNothing -> const . const id
|
||||||
|
HeldScrollZoom -> zoomLongGun
|
||||||
|
HeldScrollCharMode -> scrollCharMode
|
||||||
|
scrollCharMode
|
||||||
|
:: Float -- ^ Amount scrolled
|
||||||
|
-> Creature
|
||||||
|
-> Item
|
||||||
|
-> Item
|
||||||
|
scrollCharMode x _
|
||||||
|
| x > 0 = incCharMode
|
||||||
|
| x < 0 = decCharMode
|
||||||
|
| otherwise = id
|
||||||
|
|
||||||
|
incCharMode
|
||||||
|
:: Item
|
||||||
|
-> Item
|
||||||
|
incCharMode = itAttachment . atCharMode %~ cycleL
|
||||||
|
where
|
||||||
|
cycleL (x :<| xs) = xs |> x
|
||||||
|
cycleL xs = xs
|
||||||
|
decCharMode
|
||||||
|
:: Item
|
||||||
|
-> Item
|
||||||
|
decCharMode = itAttachment . atCharMode %~ cycleR
|
||||||
|
where
|
||||||
|
cycleR (xs :|> x) = x <| xs
|
||||||
|
cycleR xs = xs
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
module Dodge.Item.Attachment
|
module Dodge.Item.Attachment
|
||||||
( charFiringStratI
|
( charFiringStratI
|
||||||
, scrollCharMode
|
|
||||||
, changeFuse
|
, changeFuse
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
@@ -13,32 +12,6 @@ import Data.Maybe
|
|||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
|
|
||||||
|
|
||||||
scrollCharMode
|
|
||||||
:: Float -- ^ Amount scrolled
|
|
||||||
-> Creature
|
|
||||||
-> Item
|
|
||||||
-> Item
|
|
||||||
scrollCharMode x _
|
|
||||||
| x > 0 = incCharMode
|
|
||||||
| x < 0 = decCharMode
|
|
||||||
| otherwise = id
|
|
||||||
|
|
||||||
incCharMode
|
|
||||||
:: Item
|
|
||||||
-> Item
|
|
||||||
incCharMode = itAttachment . atCharMode %~ cycleL
|
|
||||||
where
|
|
||||||
cycleL (x :<| xs) = xs |> x
|
|
||||||
cycleL xs = xs
|
|
||||||
|
|
||||||
decCharMode
|
|
||||||
:: Item
|
|
||||||
-> Item
|
|
||||||
decCharMode = itAttachment . atCharMode %~ cycleR
|
|
||||||
where
|
|
||||||
cycleR (xs :|> x) = x <| xs
|
|
||||||
cycleR xs = xs
|
|
||||||
|
|
||||||
charFiringStratI
|
charFiringStratI
|
||||||
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
|
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
|
||||||
-> ChainEffect
|
-> ChainEffect
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ flatShield = defaultWeapon
|
|||||||
, _aimHandlePos = 0
|
, _aimHandlePos = 0
|
||||||
, _aimMuzPos = 0
|
, _aimMuzPos = 0
|
||||||
}
|
}
|
||||||
, _heldScroll = \_ _ -> id
|
|
||||||
}
|
}
|
||||||
& itInvSize .~ 3
|
& itInvSize .~ 3
|
||||||
& itType . iyBase .~ HELD FLATSHIELD
|
& itType . iyBase .~ HELD FLATSHIELD
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Dodge.Reloading.Action
|
|||||||
import Dodge.Default.Weapon
|
import Dodge.Default.Weapon
|
||||||
import Dodge.Item.Weapon.Bullet
|
import Dodge.Item.Weapon.Bullet
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Item.Weapon.ZoomScope
|
--import Dodge.Item.Weapon.ZoomScope
|
||||||
import Dodge.Item.Weapon.ExtraEffect
|
import Dodge.Item.Weapon.ExtraEffect
|
||||||
import Dodge.Item.Weapon.TriggerType
|
import Dodge.Item.Weapon.TriggerType
|
||||||
import Dodge.SoundLogic.LoadSound
|
import Dodge.SoundLogic.LoadSound
|
||||||
@@ -91,7 +91,7 @@ sniperRifle = elephantGun
|
|||||||
& itType . iyBase .~ HELD SNIPERRIFLE
|
& itType . iyBase .~ HELD SNIPERRIFLE
|
||||||
& itParams . gunBarrels .~ SingleBarrel 0
|
& itParams . gunBarrels .~ SingleBarrel 0
|
||||||
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5}
|
||||||
& itUse . heldScroll .~ zoomLongGun
|
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
|
||||||
& itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False
|
& itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False
|
||||||
& itTargeting .~ targetLaser
|
& itTargeting .~ targetLaser
|
||||||
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
|
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ autoGun = defaultAutoGun
|
|||||||
& itUse . useAim . aimRange .~ 1
|
& itUse . useAim . aimRange .~ 1
|
||||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||||
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||||
& itUse . heldScroll .~ scrollCharMode
|
& itUse . heldScroll .~ HeldScrollCharMode
|
||||||
& itType . iyBase .~ HELD AUTOGUN
|
& itType . iyBase .~ HELD AUTOGUN
|
||||||
autoGunPic :: Item -> SPic
|
autoGunPic :: Item -> SPic
|
||||||
autoGunPic it = noPic $
|
autoGunPic it = noPic $
|
||||||
|
|||||||
Reference in New Issue
Block a user