Cleanup. Probable leak when inventory is large enough for scrolling
This commit is contained in:
@@ -33,7 +33,7 @@ data SubInventory
|
||||
, _ciSelection :: Maybe (Int, Int, IS.IntSet)
|
||||
, _ciFilter :: Maybe String
|
||||
}
|
||||
| LockedInventory
|
||||
-- | LockedInventory
|
||||
| DisplayTerminal {_termID :: Int}
|
||||
|
||||
data HUD = HUD
|
||||
|
||||
@@ -12,10 +12,8 @@ import Dodge.Data.ArcStep
|
||||
|
||||
data ItemParams
|
||||
= NoParams
|
||||
| MagShieldParams
|
||||
{_magShieldMgMIX :: Maybe Int}
|
||||
| ShrinkGunParams
|
||||
{_shrinkGunStatus :: ShrinkGunStatus}
|
||||
-- | MagShieldParams
|
||||
-- {_magShieldMgMIX :: Maybe Int}
|
||||
| FlatShieldParams
|
||||
{_flatShieldWlMIX :: Maybe Int}
|
||||
| Arcing
|
||||
@@ -25,8 +23,8 @@ data ItemParams
|
||||
, _newArcStep :: NextArcStep --ItemParams -> World -> ArcStep -> State StdGen (Maybe ArcStep)
|
||||
, _previousArcEffect :: PreviousArcEffect
|
||||
}
|
||||
| ParamMID {_paramMID :: Maybe Int}
|
||||
| BoostPropIX {_boostPropIX :: Maybe Int}
|
||||
-- | ParamMID {_paramMID :: Maybe Int}
|
||||
-- | BoostPropIX {_boostPropIX :: Maybe Int}
|
||||
|
||||
data ShrinkGunStatus = FullSize | Shrunk
|
||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
module Dodge.HeldScroll (
|
||||
-- doHeldScroll,
|
||||
-- canHeldScrollAttach,
|
||||
) where
|
||||
|
||||
--import LensHelp hiding ((<|), (|>))
|
||||
--import Data.Maybe
|
||||
--import Control.Monad
|
||||
--import Geometry
|
||||
--import Control.Lens hiding ((<|), (|>))
|
||||
--import Data.Sequence
|
||||
--import Dodge.Data.World
|
||||
--import SDL (MouseButton (..))
|
||||
--import qualified Data.Map.Strict as M
|
||||
|
||||
-- note that scope zooming is controlled by updateScopeZoom
|
||||
--doHeldScroll :: Int -> ScrollAttachParams -> Float -> World -> World
|
||||
--doHeldScroll _ _ _ = id
|
||||
--doHeldScroll invid hs x w = case hs of
|
||||
-- ZoomScrollParams{}
|
||||
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w) -> w &
|
||||
-- cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
-- . itUse . attachParams . scrollAttachParams %~ doScopeZoom (w ^. input . smoothScrollAmount) mp
|
||||
-- ZoomScrollParams{} -> w &
|
||||
-- cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
-- . itUse . attachParams . scrollAttachParams %~ resetscope
|
||||
--
|
||||
-- CharScrollParams{} -> w & cWorld . lWorld . creatures . ix 0 . crInv . ix invid . itUse . attachParams . scrollAttachParams . scrollChar %~ cycleSignum x
|
||||
-- where
|
||||
-- mp = rotateV (w ^. wCam . camRot) $ _mousePos (_input w)
|
||||
-- resetscope (ZoomScrollParams _ _ defz) = ZoomScrollParams (V2 0 0) defz defz
|
||||
-- resetscope otherAtt = otherAtt
|
||||
|
||||
--doScopeZoom :: Int -> Point2 -> ScrollAttachParams -> ScrollAttachParams
|
||||
--doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
-- x
|
||||
-- | x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
-- | x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
-- | x > 0 -> zoomInLongGun mp sc
|
||||
-- | x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) sc
|
||||
-- | x < -5 -> (zoomOutLongGun . zoomOutLongGun) sc
|
||||
-- | x < 0 -> zoomOutLongGun sc
|
||||
-- | otherwise -> sc
|
||||
--
|
||||
--zoomSpeed :: Float
|
||||
--zoomSpeed = 39 / 40
|
||||
|
||||
--zoomInLongGun :: Point2 -> ScrollAttachParams -> ScrollAttachParams
|
||||
--zoomInLongGun mousep sc = fromMaybe sc $ do
|
||||
-- curzoom <- sc ^? opticZoom
|
||||
-- guard $ curzoom < 8
|
||||
-- return $
|
||||
-- sc & opticPos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
|
||||
-- & opticZoom %~ (/ zoomSpeed)
|
||||
--
|
||||
--zoomOutLongGun :: ScrollAttachParams -> ScrollAttachParams
|
||||
--zoomOutLongGun sc = fromMaybe sc $ do
|
||||
-- curzoom <- sc ^? opticZoom
|
||||
-- guard $ curzoom > 0.5
|
||||
-- return $
|
||||
-- sc & opticPos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||
-- & opticZoom *~ zoomSpeed
|
||||
--
|
||||
--cycleSignum :: Float -> Seq a -> Seq a
|
||||
--cycleSignum x
|
||||
-- | x > 0 = cycleL
|
||||
-- | otherwise = cycleR
|
||||
--
|
||||
--cycleL, cycleR :: Seq a -> Seq a
|
||||
--cycleL (x :<| xs) = xs |> x
|
||||
--cycleL xs = xs
|
||||
--cycleR (xs :|> x) = x <| xs
|
||||
--cycleR xs = xs
|
||||
--
|
||||
--canHeldScrollAttach :: Item -> ScrollAttachParams -> Bool
|
||||
--canHeldScrollAttach _ _ = True
|
||||
@@ -27,7 +27,6 @@ import LensHelp
|
||||
magShield :: Item
|
||||
magShield =
|
||||
defaultEquipment
|
||||
& itParams .~ MagShieldParams Nothing
|
||||
& itUse . uequipEffect . eeUse .~ EMagShield MagnetRepulse
|
||||
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||
& itType .~ EQUIP MAGSHIELD
|
||||
|
||||
@@ -75,11 +75,6 @@ tractorGun =
|
||||
& itUse . heldTriggerType .~ AutoTrigger
|
||||
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
|
||||
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
|
||||
& itTargeting .~ ItTargeting
|
||||
{ _itTgPos = Nothing
|
||||
, _itTgID = Nothing
|
||||
, _itTgActive = False
|
||||
}
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimRange .~ 1
|
||||
& itUse . heldAim . aimStance .~ TwoHandUnder
|
||||
|
||||
@@ -158,7 +158,7 @@ drawDragSelecting cfig w = do
|
||||
|
||||
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
|
||||
drawSubInventory subinv cfig w = case subinv of
|
||||
LockedInventory -> mempty -- topInvCursor col cursPos cfig w
|
||||
-- LockedInventory -> mempty -- topInvCursor col cursPos cfig w
|
||||
NoSubInventory{} -> drawRBOptions cfig w
|
||||
ExamineInventory -> drawExamineInventory cfig w
|
||||
DisplayTerminal tid -> drawTerminalDisplay tid cfig (w ^. cWorld . lWorld)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Dodge.Render.HUD.Carte
|
||||
( drawCarte
|
||||
) where
|
||||
module Dodge.Render.HUD.Carte (
|
||||
drawCarte,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Base
|
||||
|
||||
+30
-35
@@ -3,52 +3,41 @@ module Dodge.Update.Scroll (
|
||||
) where
|
||||
|
||||
import Control.Monad
|
||||
import Geometry
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
import Dodge.Data.Universe
|
||||
--import Dodge.HeldScroll
|
||||
import Dodge.Inventory
|
||||
import Dodge.SelectionSections
|
||||
--import Dodge.SoundLogic
|
||||
import Dodge.Terminal
|
||||
--import Dodge.Tweak
|
||||
--import qualified IntMapHelp as IM
|
||||
import Geometry
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
updateWheelEvent :: Int -> World -> World
|
||||
updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
-- DisplayCarte
|
||||
-- | bdown ButtonRight -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
|
||||
-- | otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
|
||||
DisplayInventory{_subInventory = NoSubInventory{}}
|
||||
-- functions that modify the inventory should be centralised so that
|
||||
-- this lock can be sensibly applied, perhaps
|
||||
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
|
||||
| bdown ButtonRight -> case _rbOptions w of
|
||||
EquipOptions{} -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||
NoRightButtonOptions -> selectedItemScroll yi w
|
||||
| bdown ButtonLeft -> w & wCam . camZoom +~ y
|
||||
| invKeyDown -> changeSwapSel yi w
|
||||
| otherwise -> scrollAugInvSel yi w
|
||||
DisplayInventory{_subInventory = ExamineInventory}
|
||||
-- | invKeyDown
|
||||
-> scrollAugInvSel yi w
|
||||
-- | otherwise -> w
|
||||
DisplayInventory{_subInventory = CombineInventory{}} -> w & moveCombineSel yi
|
||||
DisplayInventory{_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
||||
_ -> w
|
||||
updateWheelEvent yi w = case w ^. hud . hudElement . subInventory of
|
||||
NoSubInventory -> updateBaseWheelEvent yi w
|
||||
ExamineInventory -> updateBaseWheelEvent yi w
|
||||
CombineInventory{} -> w & moveCombineSel yi
|
||||
DisplayTerminal tmid -> terminalWheelEvent yi tmid w
|
||||
|
||||
updateBaseWheelEvent :: Int -> World -> World
|
||||
updateBaseWheelEvent yi w
|
||||
| Just True <- w ^? cWorld . lWorld . creatures . ix 0 . crInvLock = w
|
||||
| bdown ButtonRight = case _rbOptions w of
|
||||
EquipOptions{} -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
|
||||
NoRightButtonOptions -> selectedItemScroll yi w
|
||||
| bdown ButtonLeft = w & wCam . camZoom +~ y
|
||||
| invKeyDown = changeSwapSel yi w
|
||||
| otherwise = scrollAugInvSel yi w
|
||||
where
|
||||
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
|
||||
y = fromIntegral yi
|
||||
bdown b = b `M.member` _mouseButtons (_input w)
|
||||
rbscrollmax = fromMaybe 1 $ do
|
||||
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
||||
esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeType
|
||||
return $ length $ eqSiteToPositions esite
|
||||
y = fromIntegral yi
|
||||
-- numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
||||
bdown b = b `M.member` _mouseButtons (_input w)
|
||||
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
|
||||
|
||||
selectedItemScroll :: Int -> World -> World
|
||||
selectedItemScroll scrollamount w = fromMaybe w $ do
|
||||
@@ -58,10 +47,17 @@ selectedItemScroll scrollamount w = fromMaybe w $ do
|
||||
|
||||
itemScroll :: Int -> Int -> Item -> World -> World
|
||||
itemScroll yi invid itm w = case itm ^. itType of
|
||||
ATTACH ZOOMSCOPE -> updateScopeZoom w
|
||||
HELD ALTERIFLE | yi /= 0 -> w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
. itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot %~ ((`mod` 2) . (+1))
|
||||
ATTACH ZOOMSCOPE -> updateScopeZoom w
|
||||
HELD ALTERIFLE
|
||||
| yi /= 0 ->
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInv . ix invid
|
||||
. itUse
|
||||
. heldAim
|
||||
. aimMuzzles
|
||||
. ix 0
|
||||
. mzAmmoSlot
|
||||
%~ ((`mod` 2) . (+ 1))
|
||||
_ -> w
|
||||
|
||||
-- note that your _crInvLock does not apply to this TODO check that this is what
|
||||
@@ -110,7 +106,6 @@ zoomOutLongGun sc = fromMaybe sc $ do
|
||||
sc & opticPos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||
& opticZoom *~ zoomSpeed
|
||||
|
||||
|
||||
moveCombineSel :: Int -> World -> World
|
||||
moveCombineSel yi =
|
||||
( hud . hudElement . subInventory %~ doscroll
|
||||
|
||||
@@ -3367,7 +3367,7 @@ advanceSmoothScroll src/Dodge/SmoothScroll.hs 29;" f
|
||||
advanceStepCounter src/Dodge/Creature/Impulse/Movement.hs 45;" f
|
||||
aimDelaySweep src/Dodge/Render/Picture.hs 239;" f
|
||||
aimStanceInfo src/Dodge/Item/Info.hs 199;" f
|
||||
aimTurn src/Dodge/Creature/YourControl.hs 160;" f
|
||||
aimTurn src/Dodge/Creature/YourControl.hs 161;" f
|
||||
aimingWeaponHandlePos src/Dodge/Item/HeldOffset.hs 69;" f
|
||||
aimingWeaponZeroPos src/Dodge/Item/HeldOffset.hs 63;" f
|
||||
airlock src/Dodge/Room/Airlock.hs 19;" f
|
||||
@@ -4493,7 +4493,7 @@ halfWidth src/Dodge/Base/Window.hs 48;" f
|
||||
haltSound src/Dodge/SoundLogic.hs 37;" f
|
||||
hammerCheck src/Dodge/HeldUse.hs 57;" f
|
||||
handleEvent src/Dodge/Event.hs 27;" f
|
||||
handleHotkeys src/Dodge/Creature/YourControl.hs 40;" f
|
||||
handleHotkeys src/Dodge/Creature/YourControl.hs 41;" f
|
||||
handleKeyboardEvent src/Dodge/Event/Input.hs 22;" f
|
||||
handleMouseButtonEvent src/Dodge/Event/Input.hs 63;" f
|
||||
handleMouseMotionEvent src/Dodge/Event/Input.hs 47;" f
|
||||
@@ -4541,7 +4541,7 @@ holdForm src/Dodge/Creature/Boid.hs 136;" f
|
||||
holsterWeapon src/Dodge/Creature/Volition.hs 14;" f
|
||||
homingModule src/Dodge/Item/Scope.hs 44;" f
|
||||
horPipe src/Dodge/Placement/Instance/Pipe.hs 9;" f
|
||||
hotkeyToScancode src/Dodge/Creature/YourControl.hs 68;" f
|
||||
hotkeyToScancode src/Dodge/Creature/YourControl.hs 69;" f
|
||||
hotkeyToString src/Dodge/Inventory/SelectionList.hs 43;" f
|
||||
humanoidAIList src/Dodge/Humanoid.hs 181;" f
|
||||
iShape src/Dodge/Placement/Instance/LightSource.hs 73;" f
|
||||
@@ -5569,7 +5569,7 @@ scaleMat src/MatrixHelper.hs 59;" f
|
||||
scaleMatrix src/MatrixHelper.hs 56;" f
|
||||
scaleSH src/Shape.hs 268;" f
|
||||
scalp src/Dodge/Creature/Picture.hs 96;" f
|
||||
scancodeToHotkey src/Dodge/Creature/YourControl.hs 88;" f
|
||||
scancodeToHotkey src/Dodge/Creature/YourControl.hs 89;" f
|
||||
scodeToChar src/Dodge/ScodeToChar.hs 6;" f
|
||||
scorchSPic src/Dodge/Creature/State.hs 116;" f
|
||||
screenBox src/Dodge/Base/Window.hs 53;" f
|
||||
@@ -5627,7 +5627,7 @@ sentinelFireType src/Dodge/Creature/SentinelAI.hs 50;" f
|
||||
setChannelPos src/Sound.hs 149;" f
|
||||
setClickWorldPos src/Dodge/Update.hs 97;" f
|
||||
setClusterID src/Dodge/Combine/Graph.hs 115;" f
|
||||
setCrPosture src/Dodge/Creature/YourControl.hs 170;" f
|
||||
setCrPosture src/Dodge/Creature/YourControl.hs 171;" f
|
||||
setDepth src/Picture/Base.hs 128;" f
|
||||
setDirPS src/Dodge/PlacementSpot.hs 49;" f
|
||||
setFallback src/Dodge/PlacementSpot.hs 127;" f
|
||||
@@ -6070,7 +6070,7 @@ truncFaces src/Polyhedra/Geodesic.hs 53;" f
|
||||
truncate src/Polyhedra/Geodesic.hs 38;" f
|
||||
trunkDepth src/TreeHelp.hs 161;" f
|
||||
tryAttachItems src/Dodge/Item/Grammar.hs 22;" f
|
||||
tryClickUse src/Dodge/Creature/YourControl.hs 175;" f
|
||||
tryClickUse src/Dodge/Creature/YourControl.hs 176;" f
|
||||
tryCombine src/Dodge/Update/Input/InGame.hs 596;" f
|
||||
tryDropSelected src/Dodge/Update/Input/InGame.hs 123;" f
|
||||
tryGetChannel src/Sound.hs 96;" f
|
||||
@@ -6257,7 +6257,7 @@ useC src/Dodge/Cuse.hs 8;" f
|
||||
useC' src/Dodge/Cuse.hs 13;" f
|
||||
useE src/Dodge/Euse.hs 34;" f
|
||||
useGasParams src/Dodge/HeldUse.hs 532;" f
|
||||
useHotkey src/Dodge/Creature/YourControl.hs 63;" f
|
||||
useHotkey src/Dodge/Creature/YourControl.hs 64;" f
|
||||
useItem src/Dodge/Creature/Impulse/UseItem.hs 20;" f
|
||||
useItemLoc src/Dodge/Creature/Impulse/UseItem.hs 27;" f
|
||||
useLnkRoomPos src/Dodge/PlacementSpot.hs 244;" f
|
||||
@@ -6319,12 +6319,12 @@ wallLine src/Dodge/Placement/Instance/Wall.hs 71;" f
|
||||
wallsFromRooms src/Dodge/Layout.hs 146;" f
|
||||
wallsToDraw src/Dodge/Render/Walls.hs 17;" f
|
||||
warningRooms src/Dodge/Room/Warning.hs 27;" f
|
||||
wasdAim src/Dodge/Creature/YourControl.hs 122;" f
|
||||
wasdAim src/Dodge/Creature/YourControl.hs 123;" f
|
||||
wasdDir src/Dodge/WASD.hs 17;" f
|
||||
wasdM src/Dodge/WASD.hs 9;" f
|
||||
wasdMovement src/Dodge/Creature/YourControl.hs 148;" f
|
||||
wasdTwist src/Dodge/Creature/YourControl.hs 130;" f
|
||||
wasdWithAiming src/Dodge/Creature/YourControl.hs 112;" f
|
||||
wasdMovement src/Dodge/Creature/YourControl.hs 149;" f
|
||||
wasdTwist src/Dodge/Creature/YourControl.hs 131;" f
|
||||
wasdWithAiming src/Dodge/Creature/YourControl.hs 113;" f
|
||||
watchCombinations src/Dodge/Combine/Combinations.hs 15;" f
|
||||
watchUpdateStrat src/Dodge/Creature/ReaderUpdate.hs 177;" f
|
||||
weakenMatS src/Dodge/Material/Sound.hs 18;" f
|
||||
|
||||
Reference in New Issue
Block a user