Get rid of world hammers
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ bulletSpawn bu = case _buSpawn bu of
|
|||||||
BulSpark -> Nothing
|
BulSpark -> Nothing
|
||||||
BulFlak -> Just (makeFlak bu)
|
BulFlak -> Just (makeFlak bu)
|
||||||
BulFrag -> Just makeFragBullets
|
BulFrag -> Just makeFragBullets
|
||||||
BulGas -> Just (flip makeGasCloud (V2 0 0))
|
BulGas -> Just (`makeGasCloud` V2 0 0)
|
||||||
BulBall IncBall -> Just incBallAt
|
BulBall IncBall -> Just incBallAt
|
||||||
BulBall ConcBall -> Just $ \p -> cWorld . lWorld . shockwaves .:~ concBall p
|
BulBall ConcBall -> Just $ \p -> cWorld . lWorld . shockwaves .:~ concBall p
|
||||||
BulBall TeslaBall -> Just makeStaticBall
|
BulBall TeslaBall -> Just makeStaticBall
|
||||||
|
|||||||
+7
-24
@@ -2,10 +2,10 @@
|
|||||||
module Dodge.Combine (
|
module Dodge.Combine (
|
||||||
toggleCombineInv,
|
toggleCombineInv,
|
||||||
enterCombineInv,
|
enterCombineInv,
|
||||||
combineListSelection,
|
combineList,
|
||||||
picsToSelectable,
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import SelectionIntMap
|
||||||
import Dodge.Data.Combine
|
import Dodge.Data.Combine
|
||||||
import Dodge.Item.Display
|
import Dodge.Item.Display
|
||||||
import Color
|
import Color
|
||||||
@@ -108,29 +108,12 @@ toggleCombineInv w = case w ^. hud . hudElement of
|
|||||||
_ -> w & enterCombineInv
|
_ -> w & enterCombineInv
|
||||||
|
|
||||||
enterCombineInv :: World -> World
|
enterCombineInv :: World -> World
|
||||||
enterCombineInv w = w & hud . hudElement . subInventory .~ CombineInventory
|
enterCombineInv w = w & hud . hudElement . subInventory .~ CombineInventory sm
|
||||||
(combineListSelection w mi "" False)
|
|
||||||
where
|
where
|
||||||
mi = 0 <$ listToMaybe (combineList w)
|
sm = initialSelPos $ SelectionIntMap
|
||||||
|
|
||||||
combineListSelection :: World -> Maybe Int -> String -> Bool -> SelectionIntMap CombinableItem
|
|
||||||
combineListSelection w mi regex x = SelectionIntMap
|
|
||||||
{ _smItems = combineList w
|
{ _smItems = combineList w
|
||||||
, _smSelPos = mi
|
, _smSelPos = Nothing
|
||||||
, _smLength = length (combineList w)
|
, _smRegex = ""
|
||||||
, _smRegex = regex
|
, _smRegexInput = False
|
||||||
, _smRegexInput = x
|
|
||||||
, _smShownItems = IM.fromAscList $ zip [0..] (combineList w)
|
, _smShownItems = IM.fromAscList $ zip [0..] (combineList w)
|
||||||
}
|
}
|
||||||
|
|
||||||
picsToSelectable :: Int -> [String] -> SelectionItem ()
|
|
||||||
picsToSelectable wdth pics =
|
|
||||||
SelectionItem
|
|
||||||
{ _siPictures = pics
|
|
||||||
, _siHeight = length pics
|
|
||||||
, _siIsSelectable = True
|
|
||||||
, _siWidth = wdth
|
|
||||||
, _siColor = white
|
|
||||||
, _siOffX = 0
|
|
||||||
, _siPayload = ()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
module Dodge.Data.Input where
|
module Dodge.Data.Input where
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Dodge.Data.CWorld
|
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import SDL (MouseButton, Scancode)
|
import SDL (MouseButton, Scancode)
|
||||||
|
|
||||||
@@ -14,13 +13,6 @@ data PressType = InitialPress
|
|||||||
| LongPress
|
| LongPress
|
||||||
deriving (Eq,Show)
|
deriving (Eq,Show)
|
||||||
|
|
||||||
data MouseButtonInfo = MouseButtonInfo
|
|
||||||
{ _mbHeldDown :: Bool
|
|
||||||
, _mbFlags :: [MouseButtonFlag]
|
|
||||||
}
|
|
||||||
data MouseButtonFlag
|
|
||||||
= PressedStartRewind
|
|
||||||
|
|
||||||
data Input = Input
|
data Input = Input
|
||||||
{ _mousePos :: Point2
|
{ _mousePos :: Point2
|
||||||
, _mouseMoving :: Bool
|
, _mouseMoving :: Bool
|
||||||
@@ -28,7 +20,6 @@ data Input = Input
|
|||||||
, _mouseButtons :: M.Map MouseButton Bool -- shortpress False, repeatpress True
|
, _mouseButtons :: M.Map MouseButton Bool -- shortpress False, repeatpress True
|
||||||
, _scrollAmount :: Int
|
, _scrollAmount :: Int
|
||||||
, _previousScrollAmount :: Int
|
, _previousScrollAmount :: Int
|
||||||
, _hammers :: M.Map WorldHammer HammerPosition
|
|
||||||
, _lLine :: (Point2, Point2)
|
, _lLine :: (Point2, Point2)
|
||||||
, _rLine :: (Point2, Point2)
|
, _rLine :: (Point2, Point2)
|
||||||
, _lrLine :: (Point2, Point2)
|
, _lrLine :: (Point2, Point2)
|
||||||
@@ -39,9 +30,4 @@ data Input = Input
|
|||||||
, _scrollTestValue :: Float
|
, _scrollTestValue :: Float
|
||||||
}
|
}
|
||||||
|
|
||||||
data WorldHammer
|
|
||||||
= SubInvHam
|
|
||||||
| DoubleMouseHam
|
|
||||||
deriving (Eq, Ord, Show, Read, Enum, Bounded)
|
|
||||||
|
|
||||||
makeLenses ''Input
|
makeLenses ''Input
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ data SelectionList a = SelectionList
|
|||||||
data SelectionIntMap a = SelectionIntMap
|
data SelectionIntMap a = SelectionIntMap
|
||||||
{ _smItems :: [SelectionItem a]
|
{ _smItems :: [SelectionItem a]
|
||||||
, _smSelPos :: Maybe Int
|
, _smSelPos :: Maybe Int
|
||||||
, _smLength :: Int
|
|
||||||
, _smRegex :: String
|
, _smRegex :: String
|
||||||
, _smRegexInput :: Bool
|
, _smRegexInput :: Bool
|
||||||
, _smShownItems :: IntMap (SelectionItem a)
|
, _smShownItems :: IntMap (SelectionItem a)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ module Dodge.Default.World where
|
|||||||
--import Dodge.Data.SelectionList
|
--import Dodge.Data.SelectionList
|
||||||
import Data.Graph.Inductive.Graph hiding ((&))
|
import Data.Graph.Inductive.Graph hiding ((&))
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Set as S
|
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Geometry.Polygon
|
import Geometry.Polygon
|
||||||
@@ -21,7 +20,6 @@ defaultInput =
|
|||||||
, _mouseMoving = False
|
, _mouseMoving = False
|
||||||
, _scrollAmount = 0
|
, _scrollAmount = 0
|
||||||
, _previousScrollAmount = 0
|
, _previousScrollAmount = 0
|
||||||
, _hammers = defaultWorldHammers
|
|
||||||
, _lrLine = (0, 0)
|
, _lrLine = (0, 0)
|
||||||
, _lLine = (0, 0)
|
, _lLine = (0, 0)
|
||||||
, _rLine = (0, 0)
|
, _rLine = (0, 0)
|
||||||
@@ -154,9 +152,6 @@ defaultHUD =
|
|||||||
, _closeObjects = []
|
, _closeObjects = []
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultWorldHammers :: M.Map WorldHammer HammerPosition
|
|
||||||
defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound .. maxBound]
|
|
||||||
|
|
||||||
--youLight :: TempLightSource
|
--youLight :: TempLightSource
|
||||||
--youLight = TLS
|
--youLight = TLS
|
||||||
-- { _tlsParam = LSParam
|
-- { _tlsParam = LSParam
|
||||||
|
|||||||
+13
-2
@@ -6,7 +6,6 @@ module Dodge.Render.HUD (
|
|||||||
import SelectionIntMap
|
import SelectionIntMap
|
||||||
import Dodge.Data.Combine
|
import Dodge.Data.Combine
|
||||||
import Dodge.Default.SelectionList
|
import Dodge.Default.SelectionList
|
||||||
import Dodge.Combine
|
|
||||||
import Dodge.Creature.Info
|
import Dodge.Creature.Info
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -90,7 +89,7 @@ drawSubInventory subinv cfig w = case subinv of
|
|||||||
let mi = _smSelPos sl
|
let mi = _smSelPos sl
|
||||||
in titledSub'
|
in titledSub'
|
||||||
cfig
|
cfig
|
||||||
("COMBINE")
|
"COMBINE"
|
||||||
sl
|
sl
|
||||||
<> combineInventoryExtra sl mi cfig w
|
<> combineInventoryExtra sl mi cfig w
|
||||||
|
|
||||||
@@ -445,6 +444,18 @@ mainListCursor c = openCursorAt 120 c 5 0
|
|||||||
textSelItems :: [String] -> [SelectionItem ()]
|
textSelItems :: [String] -> [SelectionItem ()]
|
||||||
textSelItems = map (picsToSelectable 15 . (: []))
|
textSelItems = map (picsToSelectable 15 . (: []))
|
||||||
|
|
||||||
|
picsToSelectable :: Int -> [String] -> SelectionItem ()
|
||||||
|
picsToSelectable wdth pics =
|
||||||
|
SelectionItem
|
||||||
|
{ _siPictures = pics
|
||||||
|
, _siHeight = length pics
|
||||||
|
, _siIsSelectable = True
|
||||||
|
, _siWidth = wdth
|
||||||
|
, _siColor = white
|
||||||
|
, _siOffX = 0
|
||||||
|
, _siPayload = ()
|
||||||
|
}
|
||||||
|
|
||||||
openCursorAt ::
|
openCursorAt ::
|
||||||
-- | Width
|
-- | Width
|
||||||
Float ->
|
Float ->
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
module Dodge.SelectionList where
|
module Dodge.SelectionList where
|
||||||
|
|
||||||
--import Color
|
|
||||||
--import Dodge.WindowLayout
|
|
||||||
import Color
|
import Color
|
||||||
import Regex
|
import Regex
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
import LensHelp
|
import LensHelp
|
||||||
--import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
getAvailableListLines :: ListDisplayParams -> Configuration -> Int
|
getAvailableListLines :: ListDisplayParams -> Configuration -> Int
|
||||||
getAvailableListLines ldps cfig = floor ((dToBot - vgap) / itmHeight)
|
getAvailableListLines ldps cfig = floor ((dToBot - vgap) / itmHeight)
|
||||||
@@ -42,7 +40,7 @@ moveSelectionListSelection :: Int -> SelectionList a -> SelectionList a
|
|||||||
moveSelectionListSelection yi sl = sl & slSelPos %~ f
|
moveSelectionListSelection yi sl = sl & slSelPos %~ f
|
||||||
where
|
where
|
||||||
f x | maxsel == 0 = Nothing
|
f x | maxsel == 0 = Nothing
|
||||||
| x == Nothing = Just 0
|
| isNothing x = Just 0
|
||||||
| otherwise = fmap ((`mod` maxsel) . subtract yi) x
|
| otherwise = fmap ((`mod` maxsel) . subtract yi) x
|
||||||
maxsel = case _slRegex sl of
|
maxsel = case _slRegex sl of
|
||||||
"" -> length (_slItems sl)
|
"" -> length (_slItems sl)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import Dodge.DrWdWd
|
|||||||
import Dodge.EnergyBall
|
import Dodge.EnergyBall
|
||||||
import Dodge.Flame
|
import Dodge.Flame
|
||||||
import Dodge.Flare
|
import Dodge.Flare
|
||||||
import Dodge.Hammer
|
|
||||||
import Dodge.InputFocus
|
import Dodge.InputFocus
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Item.Location
|
import Dodge.Item.Location
|
||||||
@@ -261,7 +260,6 @@ functionalUpdate w =
|
|||||||
checkEndGame
|
checkEndGame
|
||||||
. over uvWorld (cWorld . lWorld . lClock +~ 1)
|
. over uvWorld (cWorld . lWorld . lClock +~ 1)
|
||||||
. over uvWorld updateWorldSelect'
|
. over uvWorld updateWorldSelect'
|
||||||
. moveHammersUp
|
|
||||||
. over uvWorld updateDistortions
|
. over uvWorld updateDistortions
|
||||||
. over uvWorld updateCreatureSoundPositions
|
. over uvWorld updateCreatureSoundPositions
|
||||||
. over uvWorld ppEvents
|
. over uvWorld ppEvents
|
||||||
@@ -355,9 +353,6 @@ updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. lWorld
|
|||||||
|
|
||||||
--updatePastWorlds w = w & pastWorlds .~ []
|
--updatePastWorlds w = w & pastWorlds .~ []
|
||||||
|
|
||||||
moveHammersUp :: Universe -> Universe
|
|
||||||
moveHammersUp = uvWorld . input . hammers %~ M.map moveHammerUp
|
|
||||||
|
|
||||||
doWorldEvents :: World -> World
|
doWorldEvents :: World -> World
|
||||||
doWorldEvents w = foldl'
|
doWorldEvents w = foldl'
|
||||||
(flip doWdWd)
|
(flip doWdWd)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ module Dodge.Update.UsingInput (
|
|||||||
updateUsingInput,
|
updateUsingInput,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.Combine
|
||||||
|
import SelectionIntMap
|
||||||
import Dodge.Data.Combine
|
import Dodge.Data.Combine
|
||||||
import Dodge.Data.SelectionList
|
import Dodge.Data.SelectionList
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
@@ -27,46 +29,32 @@ updateUsingInput w = case w ^. hud . hudElement of
|
|||||||
|
|
||||||
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
||||||
pressedMBEffects subinv pkeys w = case subinv of
|
pressedMBEffects subinv pkeys w = case subinv of
|
||||||
NoSubInventory
|
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
|
||||||
| ButtonLeft `M.member` pkeys && w ^?! input . hammers . ix SubInvHam /= HammerUp ->
|
|
||||||
w & input . hammers . ix SubInvHam .~ HammerDown
|
|
||||||
| otherwise -> pressedMBEffectsNoInventory pkeys w
|
|
||||||
CombineInventory SelectionIntMap {_smSelPos = mi, _smRegexInput = False}
|
CombineInventory SelectionIntMap {_smSelPos = mi, _smRegexInput = False}
|
||||||
| pkeys ^? ix ButtonLeft == Just False ->
|
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
|
||||||
maybeexitcombine (maybe id doCombine mi w) & input . hammers . ix SubInvHam .~ HammerDown
|
|
||||||
CombineInventory SelectionIntMap {_smRegexInput = True}
|
CombineInventory SelectionIntMap {_smRegexInput = True}
|
||||||
| pkeys ^? ix ButtonLeft == Just False
|
| lbinitialpress -> w & hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
|
||||||
-> w & hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
|
|
||||||
DisplayTerminal tmid
|
DisplayTerminal tmid
|
||||||
| pkeys ^? ix ButtonLeft == Just False && inTermFocus w ->
|
| lbinitialpress && inTermFocus w ->
|
||||||
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
|
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
|
||||||
& input . hammers . ix SubInvHam .~ HammerDown
|
| lbinitialpress ->
|
||||||
| pkeys ^? ix ButtonLeft == Just False ->
|
|
||||||
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||||
& input . hammers . ix SubInvHam .~ HammerDown
|
|
||||||
_
|
|
||||||
| ButtonLeft `M.member` pkeys ->
|
|
||||||
w & input . hammers . ix SubInvHam .~ HammerDown
|
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
maybeexitcombine
|
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
|
||||||
| ButtonRight `M.member` _mouseButtons (_input w) = id
|
maybeexitcombine w'
|
||||||
| otherwise = hud . hudElement . subInventory .~ NoSubInventory
|
| ButtonRight `M.member` _mouseButtons (_input w)
|
||||||
|
= (hud . hudElement . subInventory . subInvMap %~ setShownIntMap)
|
||||||
|
$ (hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
|
||||||
|
| otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
|
||||||
|
|
||||||
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
|
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
|
||||||
pressedMBEffectsNoInventory pkeys w
|
pressedMBEffectsNoInventory pkeys w
|
||||||
| isDown ButtonLeft && isDown ButtonRight && inTopInv =
|
| isDown ButtonLeft && isDown ButtonRight && inTopInv = useItem (you w) w
|
||||||
useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown
|
| isDown ButtonLeft && inTopInv = useLeftItem 0 w
|
||||||
| isDown ButtonLeft && inTopInv
|
|
||||||
&& w ^?! input . hammers . ix DoubleMouseHam == HammerUp =
|
|
||||||
useLeftItem 0 w
|
|
||||||
| isDown ButtonLeft && inTopInv =
|
|
||||||
w & input . hammers . ix DoubleMouseHam .~ HammerDown
|
|
||||||
| isDown ButtonRight && inTopInv = w
|
|
||||||
| isDown ButtonMiddle =
|
| isDown ButtonMiddle =
|
||||||
w & cWorld . camPos . camRot -~ rotation
|
w & cWorld . camPos . camRot -~ rotation
|
||||||
& input . clickMousePos .~ _mousePos (_input w)
|
& input . clickMousePos .~ _mousePos (_input w)
|
||||||
| isDown ButtonLeft = w & input . hammers . ix DoubleMouseHam .~ HammerDown
|
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
where
|
where
|
||||||
inTopInv = case w ^. hud . hudElement of
|
inTopInv = case w ^. hud . hudElement of
|
||||||
@@ -81,7 +69,6 @@ doCombine :: Int -> World -> World
|
|||||||
doCombine i w = case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
|
doCombine i w = case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
Just (CombinableItem is it _) ->
|
Just (CombinableItem is it _) ->
|
||||||
-- set (hud . hudElement) (DisplayInventory NoSubInventory)
|
|
||||||
selectinv --enterCombineInv
|
selectinv --enterCombineInv
|
||||||
. createPutItem it
|
. createPutItem it
|
||||||
$ foldr (rmInvItem 0) w (sort is)
|
$ foldr (rmInvItem 0) w (sort is)
|
||||||
|
|||||||
Reference in New Issue
Block a user