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
|
||||
|
||||
Reference in New Issue
Block a user