Rethink item ammo to item consumables, start item type datatype
This commit is contained in:
@@ -11,7 +11,7 @@ data Configuration = Configuration
|
|||||||
, _volume_music :: Float
|
, _volume_music :: Float
|
||||||
, _wall_textured :: Bool
|
, _wall_textured :: Bool
|
||||||
, _cloud_shadows :: Bool
|
, _cloud_shadows :: Bool
|
||||||
, _resolution_factor :: Int -- ^ Higher values divide screen size, i.e. make the resolution worse
|
, _resolution_factor :: ResFactor
|
||||||
, _windowX :: Float
|
, _windowX :: Float
|
||||||
, _windowY :: Float
|
, _windowY :: Float
|
||||||
, _windowPosX :: Int
|
, _windowPosX :: Int
|
||||||
@@ -25,6 +25,17 @@ data Configuration = Configuration
|
|||||||
, _debug_pathing :: Bool
|
, _debug_pathing :: Bool
|
||||||
}
|
}
|
||||||
deriving (Generic, Show)
|
deriving (Generic, Show)
|
||||||
|
data ResFactor = FullRes | HalfRes | QuarterRes
|
||||||
|
deriving (Generic, Show, Eq, Ord, Enum, Bounded)
|
||||||
|
instance ToJSON ResFactor where
|
||||||
|
toEncoding = genericToEncoding defaultOptions
|
||||||
|
instance FromJSON ResFactor
|
||||||
|
resFactorNum :: ResFactor -> Int
|
||||||
|
resFactorNum rf = case rf of
|
||||||
|
FullRes -> 1
|
||||||
|
HalfRes -> 2
|
||||||
|
QuarterRes -> 4
|
||||||
|
|
||||||
makeLenses ''Configuration
|
makeLenses ''Configuration
|
||||||
|
|
||||||
instance ToJSON Configuration where
|
instance ToJSON Configuration where
|
||||||
@@ -39,7 +50,7 @@ defaultConfig = Configuration
|
|||||||
, _volume_music = 1
|
, _volume_music = 1
|
||||||
, _wall_textured = True
|
, _wall_textured = True
|
||||||
, _cloud_shadows = True
|
, _cloud_shadows = True
|
||||||
, _resolution_factor = 1
|
, _resolution_factor = FullRes
|
||||||
, _windowX = 800
|
, _windowX = 800
|
||||||
, _windowY = 600
|
, _windowY = 600
|
||||||
, _windowPosX = 0
|
, _windowPosX = 0
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ setVol :: Configuration -> IO ()
|
|||||||
setVol cfig = do
|
setVol cfig = do
|
||||||
setSoundVolume ( _volume_master cfig * _volume_sound cfig)
|
setSoundVolume ( _volume_master cfig * _volume_sound cfig)
|
||||||
setMusicVolume ( _volume_master cfig * _volume_music cfig)
|
setMusicVolume ( _volume_master cfig * _volume_music cfig)
|
||||||
|
-- what?
|
||||||
setVolThen :: Configuration -> (a -> IO a) -> a -> IO a
|
setVolThen :: Configuration -> (a -> IO a) -> a -> IO a
|
||||||
setVolThen cfig f a = do
|
setVolThen cfig f a = do
|
||||||
setVol cfig
|
setVol cfig
|
||||||
@@ -47,4 +47,4 @@ applyWorldConfig cfig pdata = do
|
|||||||
where
|
where
|
||||||
x = round $ _windowX cfig
|
x = round $ _windowX cfig
|
||||||
y = round $ _windowY cfig
|
y = round $ _windowY cfig
|
||||||
divRes = _resolution_factor cfig
|
divRes = resFactorNum $ _resolution_factor cfig
|
||||||
|
|||||||
@@ -144,29 +144,28 @@ performAction cr w ac = case ac of
|
|||||||
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
|
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
|
||||||
NoAction -> ([],Nothing)
|
NoAction -> ([],Nothing)
|
||||||
|
|
||||||
startReloadingWeapon
|
startReloadingWeapon :: Creature -> World -> Maybe World
|
||||||
:: Creature
|
|
||||||
-> World
|
|
||||||
-> Maybe World
|
|
||||||
startReloadingWeapon cr w =
|
startReloadingWeapon cr w =
|
||||||
let cid = _crID cr
|
let cid = _crID cr
|
||||||
it = _crInv cr IM.! _crInvSel cr
|
it = _crInv cr IM.! _crInvSel cr
|
||||||
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
|
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
|
||||||
in case it of
|
in case it of
|
||||||
Weapon {_wpAmmo = LoadableAmmo {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA ,_wpReloadState=rS,_wpReloadTime=rT}}
|
Weapon {_itConsumption = LoadableAmmo {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA ,_wpReloadState=rS,_wpReloadTime=rT}}
|
||||||
| lA < maxA && rS == 0 -> Just $ set ( itRef . wpAmmo . wpLoadedAmmo) maxA
|
| lA < maxA && rS == 0 -> Just $ set ( itRef . itConsumption . wpLoadedAmmo) maxA
|
||||||
$ set ( itRef . wpAmmo . wpReloadState) rT w
|
$ set ( itRef . itConsumption . wpReloadState) rT w
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
{- | Start reloading if clip is empty. -}
|
{- | Start reloading if clip is empty. -}
|
||||||
crAutoReload :: Creature -> Creature
|
crAutoReload :: Creature -> Creature
|
||||||
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo of
|
crAutoReload cr = case cr ^? ptrItConsumption' . wpLoadedAmmo of
|
||||||
Just 0 | _posture (_crStance cr) /= Aiming
|
Just 0 | _posture (_crStance cr) /= Aiming
|
||||||
-> cr & crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState %~ (`fromMaybe` reloadT)
|
-> cr & ptrItConsumption . wpReloadState %~ (`fromMaybe` reloadT)
|
||||||
& crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo %~ (`fromMaybe` maxA)
|
& ptrItConsumption . wpLoadedAmmo %~ (`fromMaybe` maxA)
|
||||||
_ -> cr
|
_ -> cr
|
||||||
where
|
where
|
||||||
reloadT = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadTime
|
ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption
|
||||||
maxA = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpMaxAmmo
|
ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption
|
||||||
|
reloadT = cr ^? ptrItConsumption' . wpReloadTime
|
||||||
|
maxA = cr ^? ptrItConsumption' . wpMaxAmmo
|
||||||
{- | Teleport a creature to the mouse position -}
|
{- | Teleport a creature to the mouse position -}
|
||||||
blinkAction
|
blinkAction
|
||||||
:: Creature
|
:: Creature
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ reloadOverrideR
|
|||||||
:: Creature
|
:: Creature
|
||||||
-> Reader World Creature
|
-> Reader World Creature
|
||||||
reloadOverrideR cr
|
reloadOverrideR cr
|
||||||
| cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo == Just 0
|
| cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpLoadedAmmo == Just 0
|
||||||
&& cr ^. crStance . posture == Aiming
|
&& cr ^. crStance . posture == Aiming
|
||||||
= return $ cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
= return $ cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
||||||
| otherwise = return cr
|
| otherwise = return cr
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
|||||||
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
||||||
|
|
||||||
weaponReloadSounds :: Creature -> World -> World
|
weaponReloadSounds :: Creature -> World -> World
|
||||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of
|
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
|
||||||
Just am@LoadableAmmo{} -> case _wpReloadType am of
|
Just am@LoadableAmmo{} -> case _wpReloadType am of
|
||||||
PassiveReload stype |_wpReloadTime am ==_wpReloadState am
|
PassiveReload stype |_wpReloadTime am ==_wpReloadState am
|
||||||
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||||
@@ -153,6 +153,7 @@ weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of
|
|||||||
ActiveReload | _wpReloadState am == 0 -> w
|
ActiveReload | _wpReloadState am == 0 -> w
|
||||||
ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||||
Just ChargeableAmmo {} -> w
|
Just ChargeableAmmo {} -> w
|
||||||
|
Just ItemItselfConsumable {} -> w
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
@@ -185,7 +186,7 @@ isFrictionless cr = case cr ^? crStance . carriage of
|
|||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
stepReloading :: Creature -> Creature
|
stepReloading :: Creature -> Creature
|
||||||
stepReloading cr = over (crInv . ix iSel . wpAmmo . wpReloadState) decreaseToZero cr
|
stepReloading cr = over (crInv . ix iSel . itConsumption . wpReloadState) decreaseToZero cr
|
||||||
where
|
where
|
||||||
iSel = _crInvSel cr
|
iSel = _crInvSel cr
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c
|
|||||||
onBoth f g h x = f (g x) (h x)
|
onBoth f g h x = f (g x) (h x)
|
||||||
|
|
||||||
crIsReloading :: (World, Creature) -> Bool
|
crIsReloading :: (World, Creature) -> Bool
|
||||||
crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState of
|
crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpReloadState of
|
||||||
Just t -> t > 0
|
Just t -> t > 0
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
crIsReloadingR :: Creature -> Reader World Bool
|
crIsReloadingR :: Creature -> Reader World Bool
|
||||||
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState of
|
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpReloadState of
|
||||||
Just t -> t > 0
|
Just t -> t > 0
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ crAwayFromPostR cr = return $ case find sentinelGoal $ _crGoal $ _crActionPlan c
|
|||||||
sentinelGoal _ = False
|
sentinelGoal _ = False
|
||||||
|
|
||||||
crHasAmmo :: (World,Creature) -> Bool
|
crHasAmmo :: (World,Creature) -> Bool
|
||||||
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo
|
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpLoadedAmmo
|
||||||
|
|
||||||
crCanShoot :: (World,Creature) -> Bool
|
crCanShoot :: (World,Creature) -> Bool
|
||||||
crCanShoot p = crIsAiming p && crHasAmmo p
|
crCanShoot p = crIsAiming p && crHasAmmo p
|
||||||
|
|||||||
+22
-11
@@ -133,7 +133,7 @@ data ScreenLayer
|
|||||||
= OptionScreen
|
= OptionScreen
|
||||||
{ _scTitle :: Universe -> String
|
{ _scTitle :: Universe -> String
|
||||||
, _scOptions :: [MenuOption]
|
, _scOptions :: [MenuOption]
|
||||||
, _scDefaultEff :: Universe -> IO (Maybe Universe) -- IO (Maybe Universe)?
|
, _scDefaultEff :: Universe -> IO (Maybe Universe)
|
||||||
, _scOptionFlag :: OptionScreenFlag
|
, _scOptionFlag :: OptionScreenFlag
|
||||||
}
|
}
|
||||||
| ColumnsScreen String [(String,String)]
|
| ColumnsScreen String [(String,String)]
|
||||||
@@ -148,19 +148,19 @@ data ScreenLayer
|
|||||||
data MenuOption
|
data MenuOption
|
||||||
= Toggle
|
= Toggle
|
||||||
{ _moKey :: Scancode
|
{ _moKey :: Scancode
|
||||||
, _moEff :: Universe -> Maybe Universe
|
, _moEff :: Universe -> IO (Maybe Universe)
|
||||||
, _moString :: Universe -> String
|
, _moString :: Universe -> String
|
||||||
}
|
}
|
||||||
| Toggle2
|
| Toggle2
|
||||||
{ _moKey1 :: Scancode
|
{ _moKey1 :: Scancode
|
||||||
, _moEff1 :: Universe -> Maybe Universe
|
, _moEff1 :: Universe -> IO (Maybe Universe)
|
||||||
, _moKey2 :: Scancode
|
, _moKey2 :: Scancode
|
||||||
, _moEff2 :: Universe -> Maybe Universe
|
, _moEff2 :: Universe -> IO (Maybe Universe)
|
||||||
, _moString :: Universe -> String
|
, _moString :: Universe -> String
|
||||||
}
|
}
|
||||||
| InvisibleToggle
|
| InvisibleToggle
|
||||||
{ _moKey :: Scancode
|
{ _moKey :: Scancode
|
||||||
, _moEff :: Universe -> Maybe Universe
|
, _moEff :: Universe -> IO (Maybe Universe)
|
||||||
}
|
}
|
||||||
data InventoryMode
|
data InventoryMode
|
||||||
= TopInventory
|
= TopInventory
|
||||||
@@ -332,7 +332,7 @@ data AimParams = AimParams
|
|||||||
}
|
}
|
||||||
_itUseAimStance :: Item -> AimStance
|
_itUseAimStance :: Item -> AimStance
|
||||||
_itUseAimStance = _aimStance . _useAim . _itUse
|
_itUseAimStance = _aimStance . _useAim . _itUse
|
||||||
data ItemAmmo
|
data ItemConsumption
|
||||||
= LoadableAmmo
|
= LoadableAmmo
|
||||||
{ _aoType :: AmmoType
|
{ _aoType :: AmmoType
|
||||||
, _wpMaxAmmo :: Int
|
, _wpMaxAmmo :: Int
|
||||||
@@ -345,13 +345,23 @@ data ItemAmmo
|
|||||||
{ _wpMaxCharge :: Int
|
{ _wpMaxCharge :: Int
|
||||||
, _wpCharge :: Int
|
, _wpCharge :: Int
|
||||||
}
|
}
|
||||||
|
| ItemItselfConsumable
|
||||||
|
{ _itMaxStack' :: Int
|
||||||
|
, _itAmount' :: Int
|
||||||
|
}
|
||||||
|
data ItemType
|
||||||
|
= Weapon'
|
||||||
|
{ _wpSpread :: Float
|
||||||
|
, _wpRange :: Float
|
||||||
|
, _wpNumBarrels :: Int
|
||||||
|
}
|
||||||
|
| UtilityItem
|
||||||
|
| ConsumableItem
|
||||||
data Item
|
data Item
|
||||||
= Weapon
|
= Weapon
|
||||||
{ _itName :: String
|
{ _itName :: String
|
||||||
, _wpAmmo :: ItemAmmo
|
, _itConsumption :: ItemConsumption
|
||||||
, _itUse :: ItemUse
|
, _itUse :: ItemUse
|
||||||
, _wpSpread :: Float
|
|
||||||
, _wpRange :: Float
|
|
||||||
, _itFloorPict :: Item -> SPic
|
, _itFloorPict :: Item -> SPic
|
||||||
, _itZoom :: ItZoom
|
, _itZoom :: ItZoom
|
||||||
, _itEquipPict :: Creature -> Int -> SPic
|
, _itEquipPict :: Creature -> Int -> SPic
|
||||||
@@ -364,9 +374,9 @@ data Item
|
|||||||
, _itInvColor :: Color
|
, _itInvColor :: Color
|
||||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
||||||
, _itWorldTrigger :: Maybe (Int -> World -> Bool)
|
, _itWorldTrigger :: Maybe (Int -> World -> Bool)
|
||||||
, _wpNumBarrels :: Int
|
|
||||||
, _itDimension :: ItemDimension
|
, _itDimension :: ItemDimension
|
||||||
, _itCurseStatus :: CurseStatus
|
, _itCurseStatus :: CurseStatus
|
||||||
|
, _itType :: ItemType
|
||||||
}
|
}
|
||||||
| Consumable
|
| Consumable
|
||||||
{ _itName :: String
|
{ _itName :: String
|
||||||
@@ -880,7 +890,7 @@ makeLenses ''ItemPos
|
|||||||
makeLenses ''ItEffect
|
makeLenses ''ItEffect
|
||||||
makeLenses ''ItZoom
|
makeLenses ''ItZoom
|
||||||
makeLenses ''FloorItem
|
makeLenses ''FloorItem
|
||||||
makeLenses ''ItemAmmo
|
makeLenses ''ItemConsumption
|
||||||
makeLenses ''AmmoType
|
makeLenses ''AmmoType
|
||||||
makeLenses ''PjParam
|
makeLenses ''PjParam
|
||||||
makeLenses ''Prop
|
makeLenses ''Prop
|
||||||
@@ -907,3 +917,4 @@ makeLenses ''UseDelay
|
|||||||
makeLenses ''AimParams
|
makeLenses ''AimParams
|
||||||
makeLenses ''Universe
|
makeLenses ''Universe
|
||||||
makeLenses ''LSParam
|
makeLenses ''LSParam
|
||||||
|
makeLenses ''ItemType
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Geometry
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
defaultAmmo :: ItemAmmo
|
defaultAmmo :: ItemConsumption
|
||||||
defaultAmmo = LoadableAmmo
|
defaultAmmo = LoadableAmmo
|
||||||
{ _aoType = GenericAmmo
|
{ _aoType = GenericAmmo
|
||||||
, _wpMaxAmmo = 15
|
, _wpMaxAmmo = 15
|
||||||
@@ -84,7 +84,7 @@ defaultGun = Weapon
|
|||||||
{ _itName = "default"
|
{ _itName = "default"
|
||||||
, _itCurseStatus = Uncursed
|
, _itCurseStatus = Uncursed
|
||||||
, _itIdentity = Pistol
|
, _itIdentity = Pistol
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
, _itUse = defaultrUse
|
, _itUse = defaultrUse
|
||||||
, _wpSpread = 0.02
|
, _wpSpread = 0.02
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
|
|||||||
+11
-9
@@ -45,7 +45,7 @@ handleEvent e = case eventPayload e of
|
|||||||
MouseMotionEvent mmev -> return . handleMouseMotionEvent mmev
|
MouseMotionEvent mmev -> return . handleMouseMotionEvent mmev
|
||||||
MouseButtonEvent mbev -> return . handleMouseButtonEvent mbev
|
MouseButtonEvent mbev -> return . handleMouseButtonEvent mbev
|
||||||
MouseWheelEvent mwev -> return . handleMouseWheelEvent mwev
|
MouseWheelEvent mwev -> return . handleMouseWheelEvent mwev
|
||||||
WindowSizeChangedEvent sev -> return . handleResizeEvent sev
|
WindowSizeChangedEvent sev -> handleResizeEvent sev
|
||||||
WindowMovedEvent mev -> return . handleWindowMoveEvent mev
|
WindowMovedEvent mev -> return . handleWindowMoveEvent mev
|
||||||
_ -> return . Just
|
_ -> return . Just
|
||||||
|
|
||||||
@@ -74,8 +74,10 @@ handleWindowMoveEvent mev u = Just $ u
|
|||||||
P (V2 x y) = windowMovedEventPosition mev
|
P (V2 x y) = windowMovedEventPosition mev
|
||||||
|
|
||||||
{- | Resets the world window size, and resizes the fbo that gets the light map drawn into it. -}
|
{- | Resets the world window size, and resizes the fbo that gets the light map drawn into it. -}
|
||||||
handleResizeEvent :: WindowSizeChangedEventData -> Universe -> Maybe Universe
|
-- using a sideeffect here for the io change seems to work better, more testing
|
||||||
handleResizeEvent sev u = Just $ u
|
-- later may be a good idea
|
||||||
|
handleResizeEvent :: WindowSizeChangedEventData -> Universe -> IO (Maybe Universe)
|
||||||
|
handleResizeEvent sev u = return . Just $ u
|
||||||
& config . windowX .~ fromIntegral x
|
& config . windowX .~ fromIntegral x
|
||||||
& config . windowY .~ fromIntegral y
|
& config . windowY .~ fromIntegral y
|
||||||
& uvWorld . sideEffects %~ sideEffectUpdatePreload divRes x y
|
& uvWorld . sideEffects %~ sideEffectUpdatePreload divRes x y
|
||||||
@@ -83,7 +85,7 @@ handleResizeEvent sev u = Just $ u
|
|||||||
x = fromIntegral x'
|
x = fromIntegral x'
|
||||||
y = fromIntegral y'
|
y = fromIntegral y'
|
||||||
V2 x' y' = windowSizeChangedEventSize sev
|
V2 x' y' = windowSizeChangedEventSize sev
|
||||||
divRes = u ^. config . resolution_factor
|
divRes = resFactorNum $ u ^. config . resolution_factor
|
||||||
|
|
||||||
handlePressedMouseButton :: MouseButton -> Universe -> Maybe Universe
|
handlePressedMouseButton :: MouseButton -> Universe -> Maybe Universe
|
||||||
handlePressedMouseButton but w
|
handlePressedMouseButton but w
|
||||||
@@ -123,14 +125,14 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
|
|||||||
invKeyDown = ScancodeCapsLock `S.member` _keys w
|
invKeyDown = ScancodeCapsLock `S.member` _keys w
|
||||||
|
|
||||||
moveYourAmmoSel :: Int -> World -> World
|
moveYourAmmoSel :: Int -> World -> World
|
||||||
moveYourAmmoSel i w = case yourItem w ^? wpAmmo . aoType. amPjParams of
|
moveYourAmmoSel i w = case yourItem w ^? itConsumption . aoType. amPjParams of
|
||||||
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
||||||
. wpAmmo . aoType. amParamSel %~ (`mod` length l) . subtract i
|
. itConsumption . aoType. amParamSel %~ (`mod` length l) . subtract i
|
||||||
_ -> w
|
_ -> w
|
||||||
moveYourAmmoParam :: Int -> World -> World
|
moveYourAmmoParam :: Int -> World -> World
|
||||||
moveYourAmmoParam i w = case yourItem w ^? wpAmmo . aoType. amPjParams . ix paramid . pjMaxParam of
|
moveYourAmmoParam i w = case yourItem w ^? itConsumption . aoType. amPjParams . ix paramid . pjMaxParam of
|
||||||
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
||||||
. wpAmmo . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
|
. itConsumption . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
paramid = _amParamSel $ _aoType $ _wpAmmo $ yourItem w
|
paramid = _amParamSel $ _aoType $ _itConsumption $ yourItem w
|
||||||
|
|||||||
+11
-12
@@ -5,7 +5,9 @@ module Dodge.Event.Menu
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Debug.Terminal
|
import Dodge.Debug.Terminal
|
||||||
import Dodge.Menu
|
import Dodge.Menu
|
||||||
|
import Dodge.Menu.PushPop
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
import SDL
|
import SDL
|
||||||
@@ -14,28 +16,25 @@ handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Unive
|
|||||||
handlePressedKeyInMenu mState scode = case mState of
|
handlePressedKeyInMenu mState scode = case mState of
|
||||||
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
|
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
|
||||||
-> optionListToEffects mos defeff scode
|
-> optionListToEffects mos defeff scode
|
||||||
DisplayScreen {} -> return . popScreen
|
DisplayScreen {} -> popScreen
|
||||||
ColumnsScreen {} -> return . popScreen
|
ColumnsScreen {} -> popScreen
|
||||||
WaitScreen {} -> return . Just
|
WaitScreen {} -> return . Just
|
||||||
InputScreen s -> case scode of
|
InputScreen s -> case scode of
|
||||||
ScancodeEscape -> return . popScreen
|
ScancodeEscape -> popScreen
|
||||||
ScancodeReturn -> return . popScreen . applyTerminalString s
|
ScancodeReturn -> popScreen . applyTerminalString s
|
||||||
ScancodeBackspace
|
ScancodeBackspace
|
||||||
-> return . (popScreen >=> pushScreen (InputScreen $ dropLast s))
|
-> return . (popScreen' >=> pushScreen' (InputScreen $ dropLast s))
|
||||||
_ -> return . (popScreen >=> pushScreen (InputScreen $ s ++ [scodeToChar scode]))
|
_ -> return . (popScreen' >=> pushScreen' (InputScreen $ s ++ [scodeToChar scode]))
|
||||||
where
|
where
|
||||||
dropLast (x:xs) = init (x:xs)
|
dropLast (x:xs) = init (x:xs)
|
||||||
dropLast _ = []
|
dropLast _ = []
|
||||||
|
|
||||||
optionListToEffects :: [MenuOption] -> (Universe -> IO (Maybe Universe)) -> Scancode
|
optionListToEffects :: [MenuOption] -> (Universe -> IO (Maybe Universe)) -> Scancode
|
||||||
-> Universe -> IO (Maybe Universe)
|
-> Universe -> IO (Maybe Universe)
|
||||||
optionListToEffects mos defaulteff sc w = case lookup sc listEffects of
|
optionListToEffects mos defaulteff sc = fromMaybe defaulteff .
|
||||||
Nothing -> defaulteff w
|
lookup sc $ concatMap menuOptionToEffects mos
|
||||||
Just eff -> return $ eff w
|
|
||||||
where
|
|
||||||
listEffects = concatMap menuOptionToEffects mos
|
|
||||||
|
|
||||||
menuOptionToEffects :: MenuOption -> [(Scancode,Universe -> Maybe Universe)]
|
menuOptionToEffects :: MenuOption -> [(Scancode,Universe -> IO (Maybe Universe))]
|
||||||
menuOptionToEffects Toggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
menuOptionToEffects Toggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
||||||
menuOptionToEffects InvisibleToggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
menuOptionToEffects InvisibleToggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
||||||
menuOptionToEffects Toggle2
|
menuOptionToEffects Toggle2
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ defaultAimParams = AimParams
|
|||||||
useAmmoParams :: Item -> Creature -> World -> World
|
useAmmoParams :: Item -> Creature -> World -> World
|
||||||
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||||
where
|
where
|
||||||
b = _aoType $ _wpAmmo it
|
b = _aoType $ _itConsumption it
|
||||||
|
|
||||||
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
|
||||||
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||||
where
|
where
|
||||||
b = _aoType $ _wpAmmo it
|
b = _aoType $ _itConsumption it
|
||||||
|
|
||||||
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
|
||||||
withVelWthHiteff
|
withVelWthHiteff
|
||||||
@@ -74,11 +74,11 @@ withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : )
|
|||||||
|
|
||||||
loadedAmmo :: Item -> Int
|
loadedAmmo :: Item -> Int
|
||||||
loadedAmmo it
|
loadedAmmo it
|
||||||
| _wpReloadState (_wpAmmo it) == 0 = _wpLoadedAmmo (_wpAmmo it)
|
| _wpReloadState (_itConsumption it) == 0 = _wpLoadedAmmo (_itConsumption it)
|
||||||
| otherwise = 0
|
| otherwise = 0
|
||||||
|
|
||||||
fractionLoadedAmmo :: Item -> Float
|
fractionLoadedAmmo :: Item -> Float
|
||||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_wpAmmo it))
|
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_itConsumption it))
|
||||||
|
|
||||||
fractionLoadedAmmo2 :: Item -> Float
|
fractionLoadedAmmo2 :: Item -> Float
|
||||||
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_wpAmmo it)))**2
|
fractionLoadedAmmo2 it = 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral (_wpMaxAmmo (_itConsumption it)))**2
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ teslaGun :: Item
|
|||||||
teslaGun = defaultGun
|
teslaGun = defaultGun
|
||||||
{ _itName = "TESLA"
|
{ _itName = "TESLA"
|
||||||
, _itIdentity = TeslaGun
|
, _itIdentity = TeslaGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 200
|
{ _wpMaxAmmo = 200
|
||||||
, _wpLoadedAmmo = 200
|
, _wpLoadedAmmo = 200
|
||||||
, _wpReloadTime = 80
|
, _wpReloadTime = 80
|
||||||
@@ -67,7 +67,7 @@ lasGun :: Item
|
|||||||
lasGun = defaultAutoGun
|
lasGun = defaultAutoGun
|
||||||
{ _itName = "LASGUN ////"
|
{ _itName = "LASGUN ////"
|
||||||
, _itIdentity = LasGun
|
, _itIdentity = LasGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 200
|
{ _wpMaxAmmo = 200
|
||||||
, _wpLoadedAmmo = 200
|
, _wpLoadedAmmo = 200
|
||||||
, _wpReloadTime = 80
|
, _wpReloadTime = 80
|
||||||
@@ -105,7 +105,7 @@ tractorGun :: Item
|
|||||||
tractorGun = defaultAutoGun
|
tractorGun = defaultAutoGun
|
||||||
{ _itName = "TRACTORGUN"
|
{ _itName = "TRACTORGUN"
|
||||||
, _itIdentity = TractorGun
|
, _itIdentity = TractorGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 10000
|
{ _wpMaxAmmo = 10000
|
||||||
, _wpLoadedAmmo = 10000
|
, _wpLoadedAmmo = 10000
|
||||||
, _wpReloadTime = 40
|
, _wpReloadTime = 40
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ bezierGun = defaultGun
|
|||||||
, _itScroll = \_ _ -> removeItTarget
|
, _itScroll = \_ _ -> removeItTarget
|
||||||
, _itEffect = rbSetTarget
|
, _itEffect = rbSetTarget
|
||||||
, _itZoom = defaultItZoom
|
, _itZoom = defaultItZoom
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 50
|
{ _wpMaxAmmo = 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ boostSelfL
|
|||||||
-> World
|
-> World
|
||||||
-> World
|
-> World
|
||||||
boostSelfL x cr invid w = case boostPoint x cr w of
|
boostSelfL x cr invid w = case boostPoint x cr w of
|
||||||
Left p -> crEff p (wpAmmo . wpLoadedAmmo .~ 0)
|
Left p -> crEff p (itConsumption . wpLoadedAmmo .~ 0)
|
||||||
Right p -> crEff p (wpAmmo . wpLoadedAmmo -~ 1)
|
Right p -> crEff p (itConsumption . wpLoadedAmmo -~ 1)
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
@@ -113,7 +113,7 @@ boosterGun :: Item
|
|||||||
boosterGun = defaultGun
|
boosterGun = defaultGun
|
||||||
{ _itName = "BOOSTER"
|
{ _itName = "BOOSTER"
|
||||||
, _itIdentity = Blinker
|
, _itIdentity = Blinker
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 20
|
, _wpReloadTime = 20
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ autoGun :: Item
|
|||||||
autoGun = defaultAutoGun
|
autoGun = defaultAutoGun
|
||||||
{ _itName = "AUTOGUN"
|
{ _itName = "AUTOGUN"
|
||||||
, _itIdentity = AutoGun
|
, _itIdentity = AutoGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = basicBullet
|
{ _aoType = basicBullet
|
||||||
, _wpMaxAmmo = 30
|
, _wpMaxAmmo = 30
|
||||||
, _wpLoadedAmmo = 30
|
, _wpLoadedAmmo = 30
|
||||||
@@ -84,7 +84,7 @@ pistol :: Item
|
|||||||
pistol = defaultGun
|
pistol = defaultGun
|
||||||
{ _itName = "PISTOL"
|
{ _itName = "PISTOL"
|
||||||
, _itIdentity = Pistol
|
, _itIdentity = Pistol
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = basicBullet
|
{ _aoType = basicBullet
|
||||||
, _wpMaxAmmo = 15
|
, _wpMaxAmmo = 15
|
||||||
, _wpLoadedAmmo = 15
|
, _wpLoadedAmmo = 15
|
||||||
@@ -128,7 +128,7 @@ hvAutoGun :: Item
|
|||||||
hvAutoGun = defaultAutoGun
|
hvAutoGun = defaultAutoGun
|
||||||
{ _itName = "AUTO-HV"
|
{ _itName = "AUTO-HV"
|
||||||
, _itIdentity = HvAutoGun
|
, _itIdentity = HvAutoGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = hvBullet
|
{ _aoType = hvBullet
|
||||||
, _wpMaxAmmo = 100
|
, _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
@@ -164,7 +164,7 @@ ltAutoGun :: Item
|
|||||||
ltAutoGun = defaultAutoGun
|
ltAutoGun = defaultAutoGun
|
||||||
{ _itName = "AUTO-LT"
|
{ _itName = "AUTO-LT"
|
||||||
, _itIdentity = LtAutoGun
|
, _itIdentity = LtAutoGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = ltBullet
|
{ _aoType = ltBullet
|
||||||
, _wpMaxAmmo = 25
|
, _wpMaxAmmo = 25
|
||||||
, _wpLoadedAmmo = 25
|
, _wpLoadedAmmo = 25
|
||||||
@@ -200,7 +200,7 @@ miniGun :: Item
|
|||||||
miniGun = defaultAutoGun
|
miniGun = defaultAutoGun
|
||||||
{ _itName = "MINI-G"
|
{ _itName = "MINI-G"
|
||||||
, _itIdentity = MiniGun
|
, _itIdentity = MiniGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = basicBullet
|
{ _aoType = basicBullet
|
||||||
, _wpMaxAmmo = 1500
|
, _wpMaxAmmo = 1500
|
||||||
, _wpLoadedAmmo = 1500
|
, _wpLoadedAmmo = 1500
|
||||||
@@ -262,7 +262,7 @@ miniGun = defaultAutoGun
|
|||||||
miniGunPictItem :: Item -> SPic
|
miniGunPictItem :: Item -> SPic
|
||||||
miniGunPictItem it = miniGunPict spin (loadedAmmo it)
|
miniGunPictItem it = miniGunPict spin (loadedAmmo it)
|
||||||
where
|
where
|
||||||
spin = (-10) * _wpLoadedAmmo (_wpAmmo it) + _warmTime (_useDelay $ _itUse it)
|
spin = (-10) * _wpLoadedAmmo (_itConsumption it) + _warmTime (_useDelay $ _itUse it)
|
||||||
|
|
||||||
miniGunPict :: Int -> Int -> SPic
|
miniGunPict :: Int -> Int -> SPic
|
||||||
miniGunPict spin am =
|
miniGunPict spin am =
|
||||||
@@ -290,7 +290,7 @@ spreadGun :: Item
|
|||||||
spreadGun = defaultGun
|
spreadGun = defaultGun
|
||||||
{ _itName = "SPREAD"
|
{ _itName = "SPREAD"
|
||||||
, _itIdentity = SpreadGun
|
, _itIdentity = SpreadGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = basicBullet
|
{ _aoType = basicBullet
|
||||||
, _wpMaxAmmo = 5
|
, _wpMaxAmmo = 5
|
||||||
, _wpLoadedAmmo = 5
|
, _wpLoadedAmmo = 5
|
||||||
@@ -323,7 +323,7 @@ multGun :: Item
|
|||||||
multGun = defaultGun
|
multGun = defaultGun
|
||||||
{ _itName = "MULTGUN"
|
{ _itName = "MULTGUN"
|
||||||
, _itIdentity = MultGun
|
, _itIdentity = MultGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = basicBullet
|
{ _aoType = basicBullet
|
||||||
, _wpMaxAmmo = 2
|
, _wpMaxAmmo = 2
|
||||||
, _wpLoadedAmmo = 2
|
, _wpLoadedAmmo = 2
|
||||||
@@ -368,7 +368,7 @@ longGun :: Item
|
|||||||
longGun = defaultGun
|
longGun = defaultGun
|
||||||
{ _itName = "LONGGUN"
|
{ _itName = "LONGGUN"
|
||||||
, _itIdentity = LongGun
|
, _itIdentity = LongGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = hvBullet
|
{ _aoType = hvBullet
|
||||||
, _wpMaxAmmo = 1
|
, _wpMaxAmmo = 1
|
||||||
, _wpLoadedAmmo = 1
|
, _wpLoadedAmmo = 1
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ lasDrones :: Item
|
|||||||
lasDrones = defaultGun
|
lasDrones = defaultGun
|
||||||
{ _itName = "DRONES"
|
{ _itName = "DRONES"
|
||||||
, _itIdentity = Generic
|
, _itIdentity = Generic
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
|
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
|
||||||
, _wpMaxAmmo = 2
|
, _wpMaxAmmo = 2
|
||||||
, _wpLoadedAmmo = 2
|
, _wpLoadedAmmo = 2
|
||||||
@@ -58,7 +58,7 @@ aDroneWithItemParams
|
|||||||
-> World
|
-> World
|
||||||
aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
|
aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
|
||||||
where
|
where
|
||||||
am = _wpAmmo it
|
am = _itConsumption it
|
||||||
i = IM.newKey $ _props w
|
i = IM.newKey $ _props w
|
||||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ itemLaserScopeEffect
|
|||||||
--glowPoint = case listToMaybe $ thingsHitLongLine sp xp w of
|
--glowPoint = case listToMaybe $ thingsHitLongLine sp xp w of
|
||||||
-- Just (pos,E3x2 wl) -> pos +.+ 2 *.* wallNormal wl
|
-- Just (pos,E3x2 wl) -> pos +.+ 2 *.* wallNormal wl
|
||||||
-- _ -> ep -.- 2 *.* unitVectorAtAngle d
|
-- _ -> ep -.- 2 *.* unitVectorAtAngle d
|
||||||
it = (cr ^. crInv) IM.! invid
|
wpammo = _itConsumption $ (cr ^. crInv) IM.! invid
|
||||||
reloadFrac
|
reloadFrac
|
||||||
| _wpLoadedAmmo (_wpAmmo it) == 0 = 1
|
| _wpLoadedAmmo wpammo == 0 = 1
|
||||||
| otherwise = fromIntegral (_wpReloadState (_wpAmmo it)) / fromIntegral (_wpReloadTime (_wpAmmo it))
|
| otherwise = fromIntegral (_wpReloadState wpammo) / fromIntegral (_wpReloadTime wpammo)
|
||||||
--col = mixColors reloadFrac (1-reloadFrac) red green
|
--col = mixColors reloadFrac (1-reloadFrac) red green
|
||||||
{- | Automatically send out radar pulses that detect walls. -}
|
{- | Automatically send out radar pulses that detect walls. -}
|
||||||
autoRadarEffect :: ItEffect
|
autoRadarEffect :: ItEffect
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ basicWeaponDisplay :: Item -> String
|
|||||||
basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam
|
basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam
|
||||||
where
|
where
|
||||||
thename = _itName it
|
thename = _itName it
|
||||||
thenumber = case it ^? wpAmmo of
|
thenumber = case it ^? itConsumption of
|
||||||
Just am@LoadableAmmo{} -> case _wpReloadState am of
|
Just am@LoadableAmmo{} -> case _wpReloadState am of
|
||||||
0 -> show $ _wpLoadedAmmo am
|
0 -> show $ _wpLoadedAmmo am
|
||||||
x -> "R" ++ show x
|
x -> "R" ++ show x
|
||||||
Just am@ChargeableAmmo{} -> show $ _wpCharge am
|
Just am@ChargeableAmmo{} -> show $ _wpCharge am
|
||||||
|
Just x@ItemItselfConsumable{} -> show $ _itMaxStack' x
|
||||||
Nothing -> ""
|
Nothing -> ""
|
||||||
theparam = fromMaybe []
|
theparam = fromMaybe []
|
||||||
. listToMaybe
|
. listToMaybe
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ launcher :: Item
|
|||||||
launcher = defaultGun
|
launcher = defaultGun
|
||||||
{ _itName = "ROCKO"
|
{ _itName = "ROCKO"
|
||||||
, _itIdentity = Launcher
|
, _itIdentity = Launcher
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = defaultShellAmmo
|
{ _aoType = defaultShellAmmo
|
||||||
{ _amPayload = makeExplosionAt
|
{ _amPayload = makeExplosionAt
|
||||||
, _amString = ""
|
, _amString = ""
|
||||||
@@ -140,7 +140,7 @@ aRocketWithItemParams
|
|||||||
-> World
|
-> World
|
||||||
aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
|
aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
|
||||||
where
|
where
|
||||||
am = _wpAmmo it
|
am = _itConsumption it
|
||||||
i = IM.newKey $ _props w
|
i = IM.newKey $ _props w
|
||||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
@@ -240,7 +240,7 @@ remoteLauncher :: Item
|
|||||||
remoteLauncher = defaultGun
|
remoteLauncher = defaultGun
|
||||||
{ _itName = "ROCKO-REM"
|
{ _itName = "ROCKO-REM"
|
||||||
, _itIdentity = RemoteLauncher
|
, _itIdentity = RemoteLauncher
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = defaultShellAmmo
|
{ _aoType = defaultShellAmmo
|
||||||
{ _amPayload = makeExplosionAt
|
{ _amPayload = makeExplosionAt
|
||||||
, _amString = ""
|
, _amString = ""
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ radar :: Item
|
|||||||
radar = defaultGun
|
radar = defaultGun
|
||||||
{ _itName = "RADAR"
|
{ _itName = "RADAR"
|
||||||
, _itIdentity = Generic
|
, _itIdentity = Generic
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 200
|
, _wpReloadTime = 200
|
||||||
@@ -44,7 +44,7 @@ sonar :: Item
|
|||||||
sonar = defaultGun
|
sonar = defaultGun
|
||||||
{ _itName = "SONAR"
|
{ _itName = "SONAR"
|
||||||
, _itIdentity = Generic
|
, _itIdentity = Generic
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 200
|
, _wpReloadTime = 200
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Creates a creature next to the creature using the item. -}
|
|||||||
spawnGun :: Creature -> Item
|
spawnGun :: Creature -> Item
|
||||||
spawnGun cr = defaultGun
|
spawnGun cr = defaultGun
|
||||||
{ _itName = "SPAWNER"
|
{ _itName = "SPAWNER"
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 1
|
{ _wpMaxAmmo = 1
|
||||||
, _wpLoadedAmmo = 1
|
, _wpLoadedAmmo = 1
|
||||||
, _wpReloadTime = 80
|
, _wpReloadTime = 80
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ poisonSprayer :: Item
|
|||||||
poisonSprayer = defaultAutoGun
|
poisonSprayer = defaultAutoGun
|
||||||
{ _itName = "POISON"
|
{ _itName = "POISON"
|
||||||
, _itIdentity = PoisonSprayer
|
, _itIdentity = PoisonSprayer
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 500
|
{ _wpMaxAmmo = 500
|
||||||
, _wpLoadedAmmo = 500
|
, _wpLoadedAmmo = 500
|
||||||
, _wpReloadTime = 100
|
, _wpReloadTime = 100
|
||||||
@@ -58,7 +58,7 @@ flamer :: Item
|
|||||||
flamer = defaultAutoGun
|
flamer = defaultAutoGun
|
||||||
{ _itName = "FLAMER"
|
{ _itName = "FLAMER"
|
||||||
, _itIdentity = Flamethrower
|
, _itIdentity = Flamethrower
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 250
|
{ _wpMaxAmmo = 250
|
||||||
, _wpLoadedAmmo = 250
|
, _wpLoadedAmmo = 250
|
||||||
, _wpReloadTime = 100
|
, _wpReloadTime = 100
|
||||||
|
|||||||
@@ -95,10 +95,13 @@ withThickSmokeI eff item cr w = eff item cr
|
|||||||
-- fire.
|
-- fire.
|
||||||
ammoCheckI :: ChainEffect
|
ammoCheckI :: ChainEffect
|
||||||
ammoCheckI eff item cr w
|
ammoCheckI eff item cr w
|
||||||
| _wpLoadedAmmo (_wpAmmo item) <= 0
|
| _wpLoadedAmmo (_itConsumption item) <= 0 = fromMaybe w (startReloadingWeapon cr w)
|
||||||
= fromMaybe w (startReloadingWeapon cr w)
|
| _wpReloadState (_itConsumption item) > 0 = w
|
||||||
| _wpReloadState (_wpAmmo item) > 0 = w
|
|
||||||
| otherwise = eff item cr w
|
| otherwise = eff item cr w
|
||||||
|
|
||||||
|
itUseAmmo :: Int -> Item -> Item
|
||||||
|
itUseAmmo x = itConsumption . wpLoadedAmmo %~ (max 0 . subtract x)
|
||||||
|
|
||||||
{- | Fires at an increasing rate.
|
{- | Fires at an increasing rate.
|
||||||
Has different effect after first fire.
|
Has different effect after first fire.
|
||||||
Applies ammo check and use cooldown check. -}
|
Applies ammo check and use cooldown check. -}
|
||||||
@@ -109,12 +112,12 @@ rateIncAB
|
|||||||
rateIncAB exeffFirst exeffCont eff item cr w
|
rateIncAB exeffFirst exeffCont eff item cr w
|
||||||
| repeatFire = w
|
| repeatFire = w
|
||||||
& pointItem %~ ( (itUse . useDelay . rateMax .~ max fastRate (currentRate - 1))
|
& pointItem %~ ( (itUse . useDelay . rateMax .~ max fastRate (currentRate - 1))
|
||||||
. (wpAmmo . wpLoadedAmmo -~ 1)
|
. itUseAmmo 1
|
||||||
. (itUse . useDelay . rateTime .~ currentRate) )
|
. (itUse . useDelay . rateTime .~ currentRate) )
|
||||||
& exeffCont eff item cr
|
& exeffCont eff item cr
|
||||||
| firstFire = w
|
| firstFire = w
|
||||||
& pointItem %~ ( (itUse . useDelay . rateMax .~ startRate - 1)
|
& pointItem %~ ( (itUse . useDelay . rateMax .~ startRate - 1)
|
||||||
. (wpAmmo . wpLoadedAmmo -~ 1)
|
. itUseAmmo 1
|
||||||
. (itUse . useDelay . rateTime .~ startRate) )
|
. (itUse . useDelay . rateTime .~ startRate) )
|
||||||
& exeffFirst eff item cr
|
& exeffFirst eff item cr
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
@@ -125,15 +128,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
|||||||
itRef = _crInvSel cr
|
itRef = _crInvSel cr
|
||||||
pointItem = creatures . ix cid . crInv . ix itRef
|
pointItem = creatures . ix cid . crInv . ix itRef
|
||||||
currentRate = _rateMax (_useDelay (_itUse item))
|
currentRate = _rateMax (_useDelay (_itUse item))
|
||||||
repeatFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 1
|
repeatFire = _wpReloadState (_itConsumption item) == 0 && _rateTime (_useDelay (_itUse item)) == 1
|
||||||
firstFire = _wpReloadState (_wpAmmo item) == 0 && _rateTime (_useDelay (_itUse item)) == 0
|
firstFire = _wpReloadState (_itConsumption item) == 0 && _rateTime (_useDelay (_itUse item)) == 0
|
||||||
{- | Apply effect after a warm up. -}
|
{- | Apply effect after a warm up. -}
|
||||||
-- note this is quite unsafe, requires the item to have the correct delay type
|
-- note this is quite unsafe, requires the item to have the correct delay type
|
||||||
withWarmUp
|
withWarmUp
|
||||||
:: SoundID -- ^ warm up sound id
|
:: SoundID -- ^ warm up sound id
|
||||||
-> ChainEffect
|
-> ChainEffect
|
||||||
withWarmUp soundID f item cr w
|
withWarmUp soundID f item cr w
|
||||||
| _wpReloadState (_wpAmmo item) /= 0 = w
|
| _wpReloadState (_itConsumption item) /= 0 = w
|
||||||
| curWarmUp < maxWarmUp = w
|
| curWarmUp < maxWarmUp = w
|
||||||
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
& pointerToItem . itUse . useDelay . warmTime +~ 2
|
||||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
|
||||||
@@ -218,7 +221,7 @@ useAmmo
|
|||||||
:: Int -- ^ amount of ammo to use
|
:: Int -- ^ amount of ammo to use
|
||||||
-> ChainEffect
|
-> ChainEffect
|
||||||
useAmmo amAmount eff item cr = eff item cr
|
useAmmo amAmount eff item cr = eff item cr
|
||||||
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo -~ amAmount)
|
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . wpLoadedAmmo -~ amAmount)
|
||||||
{- |
|
{- |
|
||||||
Applies a world effect after an item use cooldown check. -}
|
Applies a world effect after an item use cooldown check. -}
|
||||||
useTimeCheck :: ChainEffect
|
useTimeCheck :: ChainEffect
|
||||||
@@ -243,7 +246,7 @@ hammerCheckI f it cr w = case it ^? itUse . useHammer . hammerPosition of
|
|||||||
ammoUseCheck :: ChainEffect
|
ammoUseCheck :: ChainEffect
|
||||||
ammoUseCheck f item cr w
|
ammoUseCheck f item cr w
|
||||||
| fireCondition = f item cr w & pointerToItem %~
|
| fireCondition = f item cr w & pointerToItem %~
|
||||||
( (wpAmmo . wpLoadedAmmo -~ 1)
|
( itUseAmmo 1
|
||||||
. (itUse . useDelay . rateTime .~ _rateMax ( _useDelay (_itUse item)) ))
|
. (itUse . useDelay . rateTime .~ _rateMax ( _useDelay (_itUse item)) ))
|
||||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
@@ -251,10 +254,10 @@ ammoUseCheck f item cr w
|
|||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
itRef = _crInvSel cr
|
itRef = _crInvSel cr
|
||||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||||
fireCondition = _wpReloadState (_wpAmmo item) == 0
|
fireCondition = _wpReloadState (_itConsumption item) == 0
|
||||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||||
&& _wpLoadedAmmo (_wpAmmo item) > 0
|
&& _wpLoadedAmmo (_itConsumption item) > 0
|
||||||
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
|
reloadCondition = _wpLoadedAmmo (_itConsumption item) == 0
|
||||||
{- | Applies a world effect after a hammer position check.
|
{- | Applies a world effect after a hammer position check.
|
||||||
Arbitrary inventory position. -}
|
Arbitrary inventory position. -}
|
||||||
hammerCheckL
|
hammerCheckL
|
||||||
@@ -278,7 +281,7 @@ shootL
|
|||||||
-> World
|
-> World
|
||||||
shootL f cr invid w
|
shootL f cr invid w
|
||||||
| fireCondition = f cr invid w & pointerToItem %~
|
| fireCondition = f cr invid w & pointerToItem %~
|
||||||
( (wpAmmo . wpLoadedAmmo -~ 1)
|
( itUseAmmo 1
|
||||||
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
|
. (itUse . useDelay . rateTime .~ _rateMax (_useDelay (_itUse item))) )
|
||||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
@@ -286,10 +289,10 @@ shootL f cr invid w
|
|||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
item = _crInv cr IM.! invid
|
item = _crInv cr IM.! invid
|
||||||
pointerToItem = creatures . ix cid . crInv . ix invid
|
pointerToItem = creatures . ix cid . crInv . ix invid
|
||||||
fireCondition = _wpReloadState (_wpAmmo item) == 0
|
fireCondition = _wpReloadState (_itConsumption item) == 0
|
||||||
&& _rateTime (_useDelay (_itUse item)) == 0
|
&& _rateTime (_useDelay (_itUse item)) == 0
|
||||||
&& _wpLoadedAmmo (_wpAmmo item) > 0
|
&& _wpLoadedAmmo (_itConsumption item) > 0
|
||||||
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
|
reloadCondition = _wpLoadedAmmo (_itConsumption item) == 0
|
||||||
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
||||||
withTempLight time rad col eff item cr = eff item cr
|
withTempLight time rad col eff item cr = eff item cr
|
||||||
. over tempLightSources (theTLS :)
|
. over tempLightSources (theTLS :)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ rewindGun :: Item
|
|||||||
rewindGun = defaultGun
|
rewindGun = defaultGun
|
||||||
{ _itName = "REWINDER"
|
{ _itName = "REWINDER"
|
||||||
, _itIdentity = Rewinder
|
, _itIdentity = Rewinder
|
||||||
, _wpAmmo = ChargeableAmmo
|
, _itConsumption = ChargeableAmmo
|
||||||
{ _wpMaxCharge = 250
|
{ _wpMaxCharge = 250
|
||||||
, _wpCharge = 0
|
, _wpCharge = 0
|
||||||
}
|
}
|
||||||
@@ -30,11 +30,12 @@ rewindGun = defaultGun
|
|||||||
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
|
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||||
rewindEffect _ cr invid w
|
rewindEffect _ cr invid w
|
||||||
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
||||||
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ length (_rewindWorlds w)
|
& ptrWpCharge .~ length (_rewindWorlds w)
|
||||||
| otherwise = w & rewindWorlds .~ []
|
| otherwise = w & rewindWorlds .~ []
|
||||||
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ 0
|
& ptrWpCharge .~ 0
|
||||||
where
|
where
|
||||||
maxcharge = _wpMaxCharge . _wpAmmo $ _crInv cr IM.! invid
|
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
||||||
|
maxcharge = _wpMaxCharge . _itConsumption $ _crInv cr IM.! invid
|
||||||
w' = w & rewindWorlds .~ []
|
w' = w & rewindWorlds .~ []
|
||||||
& rewinding .~ True
|
& rewinding .~ True
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ shrinkGun :: Item
|
|||||||
shrinkGun = defaultGun
|
shrinkGun = defaultGun
|
||||||
{ _itName = "SHRINKER"
|
{ _itName = "SHRINKER"
|
||||||
, _itIdentity = Generic
|
, _itIdentity = Generic
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 20
|
, _wpReloadTime = 20
|
||||||
@@ -87,7 +88,7 @@ blinkGun :: Item
|
|||||||
blinkGun = defaultGun
|
blinkGun = defaultGun
|
||||||
{ _itName = "BLINKER"
|
{ _itName = "BLINKER"
|
||||||
, _itIdentity = Blinker
|
, _itIdentity = Blinker
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 20
|
, _wpReloadTime = 20
|
||||||
@@ -121,7 +122,7 @@ forceFieldGun :: Item
|
|||||||
forceFieldGun = defaultGun
|
forceFieldGun = defaultGun
|
||||||
{ _itName = "FORCEFIELD"
|
{ _itName = "FORCEFIELD"
|
||||||
, _itIdentity = ForceFieldGun
|
, _itIdentity = ForceFieldGun
|
||||||
, _wpAmmo = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _wpMaxAmmo = 100
|
{ _wpMaxAmmo = 100
|
||||||
, _wpLoadedAmmo = 100
|
, _wpLoadedAmmo = 100
|
||||||
, _wpReloadTime = 40
|
, _wpReloadTime = 40
|
||||||
|
|||||||
+38
-69
@@ -6,6 +6,9 @@ module Dodge.Menu
|
|||||||
, gameOverMenu
|
, gameOverMenu
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
import LensHelp
|
||||||
|
import Dodge.Menu.OptionType
|
||||||
|
import Dodge.Menu.PushPop
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.PreloadData
|
import Dodge.PreloadData
|
||||||
import Dodge.Save
|
import Dodge.Save
|
||||||
@@ -16,12 +19,14 @@ import SDL.Internal.Numbered
|
|||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
import Dodge.LevelGen
|
import Dodge.LevelGen
|
||||||
|
|
||||||
import Control.Lens
|
--import Control.Lens
|
||||||
import System.Random
|
import System.Random
|
||||||
|
|
||||||
titleOptions title ops = titleOptionsEff title ops (return . popScreen . writeConfig)
|
slTitleOptions :: String -> [MenuOption] -> ScreenLayer
|
||||||
|
slTitleOptions title ops = slTitleOptionsEff title ops (popScreen . writeConfig)
|
||||||
|
|
||||||
titleOptionsEff title ops eff = OptionScreen
|
slTitleOptionsEff :: String -> [MenuOption] -> (Universe -> IO (Maybe Universe)) -> ScreenLayer
|
||||||
|
slTitleOptionsEff title ops eff = OptionScreen
|
||||||
{ _scTitle = const title
|
{ _scTitle = const title
|
||||||
, _scOptions = ops
|
, _scOptions = ops
|
||||||
, _scDefaultEff = eff
|
, _scDefaultEff = eff
|
||||||
@@ -29,19 +34,17 @@ titleOptionsEff title ops eff = OptionScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
optionMenu :: ScreenLayer
|
optionMenu :: ScreenLayer
|
||||||
optionMenu = titleOptionsEff "OPTIONS" optionsOptions (return . popScreen)
|
optionMenu = slTitleOptionsEff "OPTIONS" optionsOptions popScreen
|
||||||
|
|
||||||
optionsOptions :: [MenuOption]
|
optionsOptions :: [MenuOption]
|
||||||
optionsOptions =
|
optionsOptions =
|
||||||
[ anOption ScancodeV soundMenu "VOLUME"
|
[ makeSubmenuOption ScancodeV soundMenu "VOLUME"
|
||||||
, anOption ScancodeG graphicsMenu "GRAPHICS"
|
, makeSubmenuOption ScancodeG graphicsMenu "GRAPHICS"
|
||||||
, anOption ScancodeP gameplayMenu "GAMEPLAY"
|
, makeSubmenuOption ScancodeP gameplayMenu "GAMEPLAY"
|
||||||
, anOption ScancodeD debugMenu "DEBUG OPTIONS"
|
, makeSubmenuOption ScancodeD debugMenu "DEBUG OPTIONS"
|
||||||
]
|
]
|
||||||
where
|
|
||||||
anOption scode submenu t = Toggle scode (pushScreen submenu) (const t)
|
|
||||||
debugMenu :: ScreenLayer
|
debugMenu :: ScreenLayer
|
||||||
debugMenu = titleOptions
|
debugMenu = slTitleOptions
|
||||||
"OPTIONS:GAMEPLAY"
|
"OPTIONS:GAMEPLAY"
|
||||||
debugMenuOptions
|
debugMenuOptions
|
||||||
debugMenuOptions :: [MenuOption]
|
debugMenuOptions :: [MenuOption]
|
||||||
@@ -54,77 +57,54 @@ debugMenuOptions =
|
|||||||
]
|
]
|
||||||
where
|
where
|
||||||
doption scode l t rec
|
doption scode l t rec
|
||||||
= Toggle scode (Just . (config . l %~ not)) (\w -> t ++ ":" ++ show (rec $ _config w))
|
= Toggle scode (return . Just . (config . l %~ not)) (\w -> t ++ ":" ++ show (rec $ _config w))
|
||||||
gameplayMenu :: ScreenLayer
|
gameplayMenu :: ScreenLayer
|
||||||
gameplayMenu = titleOptions
|
gameplayMenu = slTitleOptions
|
||||||
"OPTIONS:GAMEPLAY"
|
"OPTIONS:GAMEPLAY"
|
||||||
gameplayMenuOptions
|
gameplayMenuOptions
|
||||||
|
|
||||||
gameplayMenuOptions :: [MenuOption]
|
gameplayMenuOptions :: [MenuOption]
|
||||||
gameplayMenuOptions =
|
gameplayMenuOptions =
|
||||||
[ option ScancodeR rotate_to_wall "ROTATE TO WALL" _rotate_to_wall
|
[ makeBoolOption ScancodeR rotate_to_wall "ROTATE TO WALL"
|
||||||
, option ScancodeS show_sound "SHOW VISUAL SOUNDS" _show_sound
|
, makeBoolOption ScancodeS show_sound "SHOW VISUAL SOUNDS"
|
||||||
]
|
]
|
||||||
where
|
|
||||||
option scode l t rec = Toggle scode (Just . (config . l %~ not))
|
|
||||||
(\w -> t ++ ":" ++ show (rec $ _config w))
|
|
||||||
|
|
||||||
soundMenu :: ScreenLayer
|
soundMenu :: ScreenLayer
|
||||||
soundMenu = titleOptions
|
soundMenu = slTitleOptions
|
||||||
"OPTIONS:VOLUME"
|
"OPTIONS:VOLUME"
|
||||||
soundMenuOptions
|
soundMenuOptions
|
||||||
|
|
||||||
soundMenuOptions :: [MenuOption]
|
soundMenuOptions :: [MenuOption]
|
||||||
soundMenuOptions =
|
soundMenuOptions =
|
||||||
[ Toggle2 ScancodeY (master dec . sw)
|
[ theoption ScancodeY volume_master ScancodeU "MASTER VOLUME:" _volume_master
|
||||||
ScancodeU (master inc . sw) (\w -> "MASTER VOLUME:" ++ mavol w)
|
, theoption ScancodeH volume_sound ScancodeJ "EFFECTS VOLUME:" _volume_sound
|
||||||
, Toggle2 ScancodeH (soundEffs dec . sw)
|
, theoption ScancodeN volume_music ScancodeM "MUSIC VOLUME:" _volume_music
|
||||||
ScancodeJ (soundEffs inc . sw) (\w -> "EFFECTS VOLUME:" ++ snvol w)
|
|
||||||
, Toggle2 ScancodeN (music dec . sw)
|
|
||||||
ScancodeM (music inc . sw) (\w -> "MUSIC VOLUME:" ++ muvol w)
|
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
theoption scod1 stype scod2 str voltype = Toggle2
|
||||||
|
scod1
|
||||||
|
(change dec stype)
|
||||||
|
scod2
|
||||||
|
(change inc stype)
|
||||||
|
(\w -> str ++ show (round $ 10 * voltype (_config w)::Int))
|
||||||
|
change g vt = return . Just . (config . vt %~ g) . sw
|
||||||
dec x = max 0 (x - 0.1)
|
dec x = max 0 (x - 0.1)
|
||||||
inc x = min 1 (x + 0.1)
|
inc x = min 1 (x + 0.1)
|
||||||
sw w = w & uvWorld . sideEffects %~ setVolThen (_config w)
|
sw w = w & uvWorld . sideEffects %~ setVolThen (_config w)
|
||||||
master g = Just . (config . volume_master %~ g)
|
|
||||||
soundEffs g = Just . (config . volume_sound %~ g)
|
|
||||||
music g = Just . (config . volume_music %~ g)
|
|
||||||
cfig w = _config w
|
|
||||||
mavol w = f $ _volume_master $ cfig w
|
|
||||||
snvol w = f $ _volume_sound $ cfig w
|
|
||||||
muvol w = f $ _volume_music $ cfig w
|
|
||||||
f x = show (round $ 10 * x :: Int)
|
|
||||||
|
|
||||||
pushScreen :: ScreenLayer -> Universe -> Maybe Universe
|
|
||||||
pushScreen ml w = Just $ w & menuLayers %~ (ml :)
|
|
||||||
|
|
||||||
popScreen :: Universe -> Maybe Universe
|
|
||||||
popScreen = Just . (menuLayers %~ tail)
|
|
||||||
|
|
||||||
writeConfig :: Universe -> Universe
|
writeConfig :: Universe -> Universe
|
||||||
writeConfig w = w & uvWorld . sideEffects %~ saveConfig (_config w)
|
writeConfig w = w & uvWorld . sideEffects %~ saveConfig (_config w)
|
||||||
|
|
||||||
graphicsMenu :: ScreenLayer
|
graphicsMenu :: ScreenLayer
|
||||||
graphicsMenu = titleOptions "OPTIONS:GRAPHICS" graphicsMenuOptions
|
graphicsMenu = slTitleOptions "OPTIONS:GRAPHICS" graphicsMenuOptions
|
||||||
|
|
||||||
graphicsMenuOptions :: [MenuOption]
|
graphicsMenuOptions :: [MenuOption]
|
||||||
graphicsMenuOptions =
|
graphicsMenuOptions =
|
||||||
[ Toggle ScancodeW (Just . (config . wall_textured %~ not)) wtextstring
|
[ makeEnumOption ScancodeS resolution_factor "RESOLUTION" updateFramebufferSize
|
||||||
, Toggle ScancodeS upf resostring
|
, makeBoolOption ScancodeW wall_textured "WALL TEXTURES"
|
||||||
, Toggle ScancodeD (Just . (config . cloud_shadows %~ not)) cshadstring
|
, makeBoolOption ScancodeD cloud_shadows "CLOUD SHADOWS"
|
||||||
]
|
]
|
||||||
where
|
|
||||||
wtextstring w = "WALL TEXTURES:" ++ show (_wall_textured $ _config w)
|
|
||||||
resostring w = "RESOLUTION: 1/" ++ show (_resolution_factor $ _config w)
|
|
||||||
upf w = Just $ updateFramebufferSize $ w & config . resolution_factor %~ cycleResolution
|
|
||||||
cshadstring w = "CLOUD SHADOWS:" ++ show (_cloud_shadows $ _config w)
|
|
||||||
|
|
||||||
cycleResolution :: (Eq a, Num a, Num p) => a -> p
|
|
||||||
cycleResolution 1 = 2
|
|
||||||
cycleResolution 2 = 4
|
|
||||||
cycleResolution 4 = 1
|
|
||||||
cycleResolution _ = 1
|
|
||||||
|
|
||||||
gameOverMenu :: ScreenLayer
|
gameOverMenu :: ScreenLayer
|
||||||
gameOverMenu = OptionScreen
|
gameOverMenu = OptionScreen
|
||||||
@@ -135,15 +115,15 @@ gameOverMenu = OptionScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
pauseMenu :: ScreenLayer
|
pauseMenu :: ScreenLayer
|
||||||
pauseMenu = titleOptionsEff "PAUSED" pauseMenuOptions (return . unpause)
|
pauseMenu = slTitleOptionsEff "PAUSED" pauseMenuOptions (return . unpause)
|
||||||
|
|
||||||
pauseMenuOptions :: [MenuOption]
|
pauseMenuOptions :: [MenuOption]
|
||||||
pauseMenuOptions =
|
pauseMenuOptions =
|
||||||
[ Toggle ScancodeN startNewGame (const "NEW LEVEL")
|
[ Toggle ScancodeN (return . startNewGame) (const "NEW LEVEL")
|
||||||
, Toggle ScancodeR (Just . loadSaveSlot LevelStartSlot) (const "RESTART")
|
, Toggle ScancodeR (return . Just . loadSaveSlot LevelStartSlot) (const "RESTART")
|
||||||
, Toggle ScancodeO (pushScreen optionMenu ) (const "OPTIONS")
|
, Toggle ScancodeO (pushScreen optionMenu ) (const "OPTIONS")
|
||||||
, Toggle ScancodeC (pushScreen displayControls) (const "CONTROLS")
|
, Toggle ScancodeC (pushScreen displayControls) (const "CONTROLS")
|
||||||
, InvisibleToggle ScancodeEscape (const Nothing)
|
, InvisibleToggle ScancodeEscape (return . const Nothing)
|
||||||
]
|
]
|
||||||
startNewGame :: Universe -> Maybe Universe
|
startNewGame :: Universe -> Maybe Universe
|
||||||
startNewGame w = Just $ w
|
startNewGame w = Just $ w
|
||||||
@@ -154,10 +134,6 @@ startNewGame w = Just $ w
|
|||||||
where
|
where
|
||||||
i = fst $ random (_randGen (_uvWorld w))
|
i = fst $ random (_randGen (_uvWorld w))
|
||||||
|
|
||||||
--uvWorldSideEffects :: Int -> Universe -> b -> IO Universe
|
|
||||||
--uvWorldSideEffects i w = const (generateWorldFromSeed i <&> config .~ _config w)
|
|
||||||
|
|
||||||
|
|
||||||
-- | hacky
|
-- | hacky
|
||||||
scodeToChar :: Scancode -> Char
|
scodeToChar :: Scancode -> Char
|
||||||
scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
|
scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
|
||||||
@@ -165,13 +141,6 @@ scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
|
|||||||
--charToScode :: Char -> Scancode
|
--charToScode :: Char -> Scancode
|
||||||
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
||||||
|
|
||||||
updateFramebufferSize :: Universe -> Universe
|
|
||||||
updateFramebufferSize u = u & uvWorld . sideEffects %~ sideEffectUpdatePreload divRes x y
|
|
||||||
where
|
|
||||||
(x,y) = (round $ _windowX cfig, round $ _windowY cfig)
|
|
||||||
cfig = _config u
|
|
||||||
divRes = u ^. config . resolution_factor
|
|
||||||
|
|
||||||
--levelMenu :: Int -> ScreenLayer
|
--levelMenu :: Int -> ScreenLayer
|
||||||
--levelMenu x = OptionScreen
|
--levelMenu x = OptionScreen
|
||||||
-- { _scTitle = const $ "LEVEL "++ show x
|
-- { _scTitle = const $ "LEVEL "++ show x
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{-# OPTIONS -fno-warn-missing-signatures #-}
|
||||||
|
module Dodge.Menu.OptionType where
|
||||||
|
import Dodge.Data
|
||||||
|
import Dodge.Menu.PushPop
|
||||||
|
import Control.Lens
|
||||||
|
|
||||||
|
makeBoolOption scode lns t = Toggle
|
||||||
|
scode
|
||||||
|
(return . Just . (config . lns #%~ not))
|
||||||
|
(\u -> t ++ ":" ++ show (u ^# config . lns))
|
||||||
|
|
||||||
|
makeEnumOption scode lns str sideeff = Toggle
|
||||||
|
scode
|
||||||
|
(\u -> Just <$> sideeff (u & config . lns #%~ cycleEnum) )
|
||||||
|
(\u -> str ++ ":" ++ show (u ^# config . lns))
|
||||||
|
|
||||||
|
makeSubmenuOption scode submenu t = Toggle scode (pushScreen submenu) (const t)
|
||||||
|
|
||||||
|
cycleEnum :: (Eq a, Enum a,Bounded a) => a -> a
|
||||||
|
cycleEnum x
|
||||||
|
| x == maxBound = minBound
|
||||||
|
| otherwise = succ x
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
module Dodge.Menu.PushPop where
|
||||||
|
import Dodge.Data
|
||||||
|
import LensHelp
|
||||||
|
|
||||||
|
popScreen' :: Universe -> Maybe Universe
|
||||||
|
popScreen' = Just . (menuLayers %~ tail)
|
||||||
|
popScreen :: Universe -> IO (Maybe Universe)
|
||||||
|
popScreen = return . popScreen'
|
||||||
|
|
||||||
|
|
||||||
|
pushScreen' :: ScreenLayer -> Universe -> Maybe Universe
|
||||||
|
pushScreen' ml = Just . (menuLayers .:~ ml)
|
||||||
|
pushScreen :: ScreenLayer -> Universe -> IO (Maybe Universe)
|
||||||
|
pushScreen ml = return . pushScreen' ml
|
||||||
@@ -25,7 +25,7 @@ damageSensor damF wdth upf ps = pContID ps ( PutLS theLS)
|
|||||||
, _mcLSs = [lsid]
|
, _mcLSs = [lsid]
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
theLS = lsPosCol (V3 0 0 30) (0.1)
|
theLS = lsPosCol (V3 0 0 30) 0.1
|
||||||
|
|
||||||
lightSensor :: Float -> (Machine -> World -> World) -> PlacementSpot -> Placement
|
lightSensor :: Float -> (Machine -> World -> World) -> PlacementSpot -> Placement
|
||||||
lightSensor = damageSensor senseLasering
|
lightSensor = damageSensor senseLasering
|
||||||
|
|||||||
@@ -15,3 +15,15 @@ sideEffectUpdatePreload :: Int -> Int -> Int -> (Universe -> IO Universe) -> Uni
|
|||||||
sideEffectUpdatePreload divRes x y f u = do
|
sideEffectUpdatePreload divRes x y f u = do
|
||||||
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData u)
|
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData u)
|
||||||
f $ u & preloadData .~ pdata
|
f $ u & preloadData .~ pdata
|
||||||
|
|
||||||
|
updatePreload :: Int -> Int -> Int -> Universe -> IO Universe
|
||||||
|
updatePreload divRes x y u = do
|
||||||
|
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData u)
|
||||||
|
return $ u & preloadData .~ pdata
|
||||||
|
|
||||||
|
updateFramebufferSize :: Universe -> IO Universe
|
||||||
|
updateFramebufferSize u = updatePreload divRes x y u
|
||||||
|
where
|
||||||
|
(x,y) = (round $ _windowX cfig, round $ _windowY cfig)
|
||||||
|
cfig = _config u
|
||||||
|
divRes = resFactorNum $ u ^. config . resolution_factor
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ doDrawing pdata u = do
|
|||||||
camzoom = _cameraZoom w
|
camzoom = _cameraZoom w
|
||||||
trans = _cameraCenter w
|
trans = _cameraCenter w
|
||||||
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
||||||
resFact = cfig ^. resolution_factor
|
resFact = resFactorNum $ cfig ^. resolution_factor
|
||||||
(wallPointsCol,windowPoints) = wallsAndWindows cfig w
|
(wallPointsCol,windowPoints) = wallsAndWindows cfig w
|
||||||
lightPoints = lightsForGloom w
|
lightPoints = lightsForGloom w
|
||||||
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ subInventoryDisplay cfig w = case _inventoryMode w of
|
|||||||
col = itCol it
|
col = itCol it
|
||||||
|
|
||||||
cursorsZ :: Configuration -> Int -> Item -> Picture
|
cursorsZ :: Configuration -> Int -> Item -> Picture
|
||||||
cursorsZ cfig ipos it = case it ^? wpAmmo . aoType . amParamSel of
|
cursorsZ cfig ipos it = case it ^? itConsumption . aoType . amParamSel of
|
||||||
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
|
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
|
||||||
Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5)))
|
Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5)))
|
||||||
where
|
where
|
||||||
@@ -75,12 +75,12 @@ topInvCursor col iPos cfig w
|
|||||||
| otherwise = mainListCursor col iPos cfig
|
| otherwise = mainListCursor col iPos cfig
|
||||||
|
|
||||||
ammoTweakStrings :: Item -> [String]
|
ammoTweakStrings :: Item -> [String]
|
||||||
ammoTweakStrings it = case it ^? wpAmmo . aoType . amPjParams of
|
ammoTweakStrings it = case it ^? itConsumption . aoType . amPjParams of
|
||||||
Just l -> map pjTweakString l
|
Just l -> map pjTweakString l
|
||||||
_ -> ["NOT TWEAKABLE"]
|
_ -> ["NOT TWEAKABLE"]
|
||||||
|
|
||||||
mCurs :: Item -> Configuration -> World -> Picture
|
mCurs :: Item -> Configuration -> World -> Picture
|
||||||
mCurs it cfig w = case it ^? wpAmmo . aoType . amParamSel of
|
mCurs it cfig w = case it ^? itConsumption . aoType . amParamSel of
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just i
|
Just i
|
||||||
| ButtonRight `S.member` _mouseButtons w ->
|
| ButtonRight `S.member` _mouseButtons w ->
|
||||||
|
|||||||
Reference in New Issue
Block a user