From 5a42e0b80165051c984fa1a2c3ff0f90a4dd7bfc Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 7 Jun 2022 20:39:52 +0100 Subject: [PATCH] Cleanup --- src/Dodge/Event.hs | 26 +++++++++++++------------- src/Dodge/Floor.hs | 2 +- src/Dodge/Item/Equipment.hs | 2 -- src/Dodge/Item/Weapon/ExtraEffect.hs | 8 ++++++-- src/Dodge/LockAndKey.hs | 8 ++++++++ src/Dodge/Room.hs | 2 ++ 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Dodge/Event.hs b/src/Dodge/Event.hs index 4f6de3268..9b3884ead 100644 --- a/src/Dodge/Event.hs +++ b/src/Dodge/Event.hs @@ -152,21 +152,18 @@ wheelEvent y w = case _hudElement $ _hud w of where updatetermsel tm = case tm ^? tmInput . tiSel of Nothing -> tm & tmInput . tiSel .~ (0,0) - & tmInput . tiText %~ replacewith tm 0 - Just (i,_) -> let newi = ((`mod` length (scrollCommands tm)) . subtract yi) i - in tm & tmInput . tiSel .~ (newi,0) - & tmInput . tiText %~ replacewith tm newi + Just (i,_) -> let newi = (i - yi) `mod` length (scrollCommands tm) + in tm & setInput newi 0 w updatetermsubsel tm = case tm ^? tmInput . tiSel of - Nothing -> tm - Just (i,j) -> let newj = (j - yi) `mod` (1 + length (getArguments (scrollCommands tm !! i) tm w)) - in tm & tmInput . tiSel .~ (i,newj) - & tmInput . tiText %~ replacewith' tm i newj w - replacewith tp newi _ = T.pack (_tcString (scrollCommands tp !! newi)) - replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j) + Nothing -> tm & tmInput . tiSel .~ (0,0) + Just (i,j) -> let newj = (j - yi) `mod` length (getArguments' (scrollCommands tm !! i) tm w) + in tm & setInput i newj w + setInput i j w' tm = tm + & tmInput . tiSel .~ (i,j) + & tmInput . tiText .~ T.pack (_tcString tc ++ " " ++ arg) where - arg :: String - arg = ("": getArguments tc tp w' )!! j - tc = scrollCommands tp !! i + tc = scrollCommands tm !! i + arg = getArguments' tc tm w' !! j numcombs = length $ combineItemListYou w yi = round $ signum y numLocs = (fst . IM.findMax $ _seenLocations w) + 1 @@ -174,6 +171,9 @@ wheelEvent y w = case _hudElement $ _hud w of lbDown = ButtonLeft `S.member` _mouseButtons w invKeyDown = ScancodeCapsLock `S.member` _keys w +getArguments' :: TerminalCommand -> Terminal -> World -> [String] +getArguments' tc tm = ("" :) . getArguments tc tm + getArguments :: TerminalCommand -> Terminal -> World -> [String] getArguments tc tm w = case _tcEffect tc tm w of NoArguments {} -> [] diff --git a/src/Dodge/Floor.hs b/src/Dodge/Floor.hs index 3e1cc750a..545caf258 100644 --- a/src/Dodge/Floor.hs +++ b/src/Dodge/Floor.hs @@ -55,7 +55,7 @@ initialAnoTree = padSucWithDoors $ treeFromPost [(sensorRoomRunPast ELECTRICAL, takeOne [STATICMODULE,SPARKGUN] )] itemRooms] , [SpecificRoom ((return . UseAll <$> tanksRoom [] []) <&> (, TreeSubLabelling "empty tanksRoom" Nothing))] - , [PassthroughLockKeyLists 2 lockRoomKeyItems itemRooms] + , [PassthroughLockKeyLists 222 lockRoomKeyItems itemRooms] , [SpecificRoom randomChallenges] , [AnoApplyInt 1 lasSensorTurretTest] -- ,[SpecificRoom $ fmap singleUseAll roomCCrits] diff --git a/src/Dodge/Item/Equipment.hs b/src/Dodge/Item/Equipment.hs index 74d0c1154..26224305b 100644 --- a/src/Dodge/Item/Equipment.hs +++ b/src/Dodge/Item/Equipment.hs @@ -95,8 +95,6 @@ onRemoveWristShield itm cr w = w setWristShieldPos :: Item -> Creature -> World -> World setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline --- & testString .~ (\w' -> [shortShow $ _wlLine (_walls w' IM.! i)]) --- & tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 (fst wlline `v2z` 40) where i = _eparamID $ _eqParams $ _eqEq $ _itUse itm wlline = (f (V3 (-10) 7 0), f (V3 10 7 0)) diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index abfaa8f21..9bf1e193f 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -98,8 +98,11 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do return $ winScale cfig $ setLayer FixedCoordLayer $ color thecol - $ line [p1, p2] - <> translate (20) (f p1 p2) (uncurryV translate (0.5 *.* (p1 +.+ p2)) . scale 0.1 0.1 $ text $ shortShow $ dist p mwp) + $ line [p1, p2] + <> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp) + +transMidLine :: Point2 -> Point2 -> Picture -> Picture +transMidLine p1 p2 = translate 20 (f p1 p2) . uncurryV translate (0.5 *.* (p1 +.+ p2)) where f (V2 x y) (V2 x' y') | y > y' && x > x' = max (-10) (x'-x) @@ -107,6 +110,7 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do | x > x' = min 10 (x-x') | otherwise = max (-10) (x-x') + targetRBCreatureUp :: Item -> Creature -> World -> Targeting -> (World, Targeting) targetRBCreatureUp it cr w t | not $ _itIsHeld it = (w, t diff --git a/src/Dodge/LockAndKey.hs b/src/Dodge/LockAndKey.hs index 852a6cfe4..b53642a5c 100644 --- a/src/Dodge/LockAndKey.hs +++ b/src/Dodge/LockAndKey.hs @@ -20,6 +20,14 @@ bossKeyItems = [(return . UseAll <$> bossRoom autoCrit, takeOne [PISTOL]) ] +lockRoomMultiItems :: RandomGen g => [ ( State g (LabSubCompTree Room) , State g [CombineType] ) ] +lockRoomMultiItems = + [ (blinkAcrossChallenge, takeOne [[BLINKERUNSAFE,AUTODETECTOR WALLDETECTOR] + ,[BLINKERUNSAFE,CLICKDETECTOR WALLDETECTOR] + ] + ) + ] + lockRoomKeyItems :: RandomGen g => [ (Int -> State g (LabSubCompTree Room) , State g CombineType ) ] lockRoomKeyItems = [(lasCenSensEdge, takeOne [LAUNCHER,LASGUN,SPARKGUN,FLATSHIELD,FORCEFIELDGUN] ) diff --git a/src/Dodge/Room.hs b/src/Dodge/Room.hs index 8075f03b7..52085796f 100644 --- a/src/Dodge/Room.hs +++ b/src/Dodge/Room.hs @@ -14,6 +14,7 @@ module Dodge.Room , module Dodge.Room.LongRoom , module Dodge.Room.Branch , module Dodge.Room.Teleport + , module Dodge.Room.BlinkAcross , module Dodge.Room.Start , module Dodge.Room.Boss , module Dodge.Room.Treasure @@ -33,6 +34,7 @@ import Dodge.Room.Start import Dodge.Room.Teleport import Dodge.Room.Branch import Dodge.Room.Foreground +import Dodge.Room.BlinkAcross import Dodge.LevelGen.Data import Dodge.Room.Procedural import Dodge.Room.Corridor