diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 6440094eb..1fc9fd435 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -152,7 +152,10 @@ changeSwapSelSet yi w swapSelSet :: (Int -> IS.IntSet -> World -> World) -> World -> World swapSelSet f w = fromMaybe w $ do - Sel j _ is <- w ^. hud . diSelection + Sel j i is' <- w ^. hud . diSelection + let is = if IS.null is' + then IS.singleton i + else is' return $ if concurrentIS is then f j is w @@ -224,7 +227,10 @@ multiSelScroll' f w = fromMaybe w $ do Sel j i is <- w ^. hud . diSelection ss <- w ^? hud . diSections . ix j . ssItems k <- f i ss - let insertordelete = if k `IS.member` is then IS.delete i else IS.insert i . IS.insert k + let insertordelete + | not (i `IS.member` is) && k `IS.member` is = IS.delete k + | k `IS.member` is = IS.delete i + | otherwise = IS.insert i . IS.insert k return $ w & hud . diSelection . _Just . slSet %~ insertordelete diff --git a/src/Dodge/SelectionSections.hs b/src/Dodge/SelectionSections.hs index e240d399f..e32d4a467 100644 --- a/src/Dodge/SelectionSections.hs +++ b/src/Dodge/SelectionSections.hs @@ -41,21 +41,35 @@ ssScrollUsing :: Maybe Selection ssScrollUsing g = ssScrollMinOnFail g . fmap (ssItems %~ IM.filter _siIsSelectable) +-- ssScrollMinOnFail :: (Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)) -> IMSS a -> Maybe Selection -> Maybe Selection -ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> Sel i j (q i j)) $ l <|> ssLookupMin sss +ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> Sel i j q) $ l <|> ssLookupMin sss where - q i j = fromMaybe mempty $ do - Sel k _ xs <- msel ^? _Just - guard $ j `IS.member` xs && i == k - return xs + q = fold (msel ^? _Just . slSet) l = do Sel i j _ <- msel f i j sss +---- this version removes the selected set when scrolling outside it +--ssScrollMinOnFail' :: +-- (Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)) -> +-- IMSS a -> +-- Maybe Selection -> +-- Maybe Selection +--ssScrollMinOnFail' f sss msel = fmap (\(i, j, _) -> Sel i j (q i j)) $ l <|> ssLookupMin sss +-- where +-- q i j = fromMaybe mempty $ do +-- Sel k _ xs <- msel ^? _Just +-- guard $ j `IS.member` xs && i == k +-- return xs +-- l = do +-- Sel i j _ <- msel +-- f i j sss + ssSetCursor :: (IMSS a -> Maybe (Int, Int, SelectionItem a)) -> IMSS a -> diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index 7ffbfb7dc..195c3be71 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -29,15 +29,14 @@ updateWheelEvent yi w = case w ^. hud . subInventory of -- yi should be nonzero updateBaseWheelEvent :: Int -> World -> World updateBaseWheelEvent yi w - -- | Just True <- w ^? cWorld . lWorld . creatures . ix 0 . crInvLock = w | Just True <- w ^? cWorld . lWorld . lInvLock = w | bdown ButtonRight = case _rbState w of EquipOptions{} -> w & rbState . opSel %~ scrollRBOption yi rbscrollmax NoRightButtonState -> fromMaybe w (selectedItemScroll yi w) | bdown ButtonLeft = w & wCam . camZoom +~ fromIntegral yi | ScancodeCapsLock `M.member` _pressedKeys (_input w) - , ScancodeLShift `M.member` (w ^. input . pressedKeys) = changeSwapSelSet yi w - | ScancodeCapsLock `M.member` _pressedKeys (_input w) = changeSwapSel yi w + , ScancodeLShift `M.member` (w ^. input . pressedKeys) = changeSwapSel yi w + | ScancodeCapsLock `M.member` _pressedKeys (_input w) = changeSwapSelSet yi w | ScancodeLShift `M.member` (w ^. input . pressedKeys) = multiSelScroll yi w | otherwise = scrollAugInvSel yi w where diff --git a/tags b/tags index c385b8425..7c523895f 100644 --- a/tags +++ b/tags @@ -2790,10 +2790,10 @@ centerVaultRoom src/Dodge/Room/Procedural.hs 270;" f centroid src/Geometry/Polygon.hs 192;" f centroidNum src/Geometry/Polygon.hs 195;" f chainPairs src/Geometry.hs 360;" f -changeSwapOther src/Dodge/Inventory.hs 233;" f -changeSwapSel src/Dodge/Inventory.hs 208;" f -changeSwapSelSet src/Dodge/Inventory.hs 147;" f -changeSwapWith src/Dodge/Inventory.hs 273;" f +changeSwapOther src/Dodge/Inventory.hs 236;" f +changeSwapSel src/Dodge/Inventory.hs 211;" f +changeSwapSelSet src/Dodge/Inventory.hs 148;" f +changeSwapWith src/Dodge/Inventory.hs 276;" f charToTuple src/Picture/Base.hs 312;" f charToTupleGrad src/Picture/Text.hs 18;" f chartreuse src/Color.hs 51;" f @@ -2875,7 +2875,7 @@ cogRaised src/Dodge/Creature/Perception.hs 101;" f colCrWall src/Dodge/WallCreatureCollisions.hs 27;" f colCrsWalls src/Dodge/WallCreatureCollisions.hs 19;" f collectDamageTypes src/Dodge/Damage.hs 53;" f -collectInvItems src/Dodge/Inventory.hs 198;" f +collectInvItems src/Dodge/Inventory.hs 201;" f collide3 src/Dodge/Base/Collide.hs 127;" f collide3Chasm src/Dodge/Base/Collide.hs 111;" f collide3Chasms src/Dodge/Base/Collide.hs 103;" f @@ -2915,7 +2915,7 @@ composeTree src/Dodge/Tree/Compose.hs 48;" f compressor src/Dodge/Item/Ammo.hs 74;" f computerBeepingS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 665;" f conEffects src/Dodge/Concurrent.hs 12;" f -concurrentIS src/Dodge/Inventory.hs 190;" f +concurrentIS src/Dodge/Inventory.hs 193;" f connectItemS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 745;" f constructEdges src/Polyhedra.hs 31;" f constructEdgesList src/Polyhedra.hs 40;" f @@ -3165,11 +3165,11 @@ deleteWallFromZones src/Dodge/Wall/Zone.hs 23;" f deleteWallID src/Dodge/Wall/Delete.hs 13;" f deleteWallIDs src/Dodge/Wall/Delete.hs 27;" f denormalEdges src/Polyhedra.hs 128;" f -destroyAllInvItems src/Dodge/Inventory.hs 60;" f +destroyAllInvItems src/Dodge/Inventory.hs 61;" f destroyBlock src/Dodge/Block.hs 17;" f destroyDoor src/Dodge/Wall/Damage.hs 146;" f -destroyInvItem src/Dodge/Inventory.hs 47;" f -destroyItem src/Dodge/Inventory.hs 69;" f +destroyInvItem src/Dodge/Inventory.hs 48;" f +destroyItem src/Dodge/Inventory.hs 70;" f destroyLSFlashAt src/Dodge/LightSource.hs 44;" f destroyMachine src/Dodge/Machine/Destroy.hs 13;" f destroyMachine' src/Dodge/Wall/Damage.hs 112;" f @@ -3262,7 +3262,7 @@ doRandImpulse src/Dodge/RandImpulse.hs 8;" f doRegexInput src/Dodge/Update/Input/InGame.hs 423;" f doRoomPlacements src/Dodge/Layout.hs 104;" f doRoomShift src/Dodge/Room/Link.hs 33;" f -doScopeZoom src/Dodge/Update/Scroll.hs 90;" f +doScopeZoom src/Dodge/Update/Scroll.hs 89;" f doSectionSize src/Dodge/DisplayInventory.hs 215;" f doSideEffects appDodge/Main.hs 117;" f doStrategyActions src/Dodge/Creature/ReaderUpdate.hs 172;" f @@ -3836,14 +3836,14 @@ invItemEffs src/Dodge/Creature/State.hs 63;" f invItemLocUpdate src/Dodge/Creature/State.hs 71;" f invRootMap src/Dodge/Item/Grammar.hs 231;" f invSelectionItem src/Dodge/Inventory/SelectionList.hs 32;" f -invSetSelection src/Dodge/Inventory.hs 278;" f -invSetSelectionPos src/Dodge/Inventory.hs 286;" f +invSetSelection src/Dodge/Inventory.hs 281;" f +invSetSelectionPos src/Dodge/Inventory.hs 289;" f invShiftPointBy src/Dodge/ShiftPoint.hs 17;" f invSize src/Dodge/Inventory/CheckSlots.hs 33;" f inventoryX src/Dodge/Creature.hs 111;" f -inverseSelNumPos src/Dodge/SelectionSections.hs 189;" f -inverseSelSecYint src/Dodge/SelectionSections.hs 165;" f -inverseSelSecYintXPosCheck src/Dodge/SelectionSections.hs 178;" f +inverseSelNumPos src/Dodge/SelectionSections.hs 203;" f +inverseSelSecYint src/Dodge/SelectionSections.hs 179;" f +inverseSelSecYintXPosCheck src/Dodge/SelectionSections.hs 192;" f inverseShockwaveAt src/Dodge/WorldEvent/Shockwave.hs 42;" f invertEncircleDistP src/Dodge/Creature/Boid.hs 16;" f invertIntMap src/IntMapHelp.hs 100;" f @@ -3914,7 +3914,7 @@ itemRooms src/Dodge/LockAndKey.hs 40;" f itemRotTreeSPic src/Dodge/Item/Draw/SPicTree.hs 16;" f itemSPic src/Dodge/Item/Draw/SPic.hs 17;" f itemScan src/Dodge/Item/Scope.hs 68;" f -itemScroll src/Dodge/Update/Scroll.hs 56;" f +itemScroll src/Dodge/Update/Scroll.hs 55;" f itemScrollDisplay src/Dodge/Inventory/SelectionList.hs 121;" f itemScrollValue src/Dodge/Inventory/SelectionList.hs 148;" f itemShapeMax src/Dodge/Item/Orientation.hs 68;" f @@ -4231,7 +4231,7 @@ mouseCursorType src/Dodge/Render/Picture.hs 90;" f mouseWorldPos src/Dodge/Base/Coordinate.hs 39;" f mouseWorldPosW src/Dodge/Base/Coordinate.hs 42;" f moveBullet src/Dodge/Bullet.hs 197;" f -moveCombineSel src/Dodge/Update/Scroll.hs 120;" f +moveCombineSel src/Dodge/Update/Scroll.hs 119;" f moveInverseShockwave src/Dodge/Shockwave/Update.hs 31;" f movePenBullet src/Dodge/Bullet.hs 203;" f moveProjectile src/Dodge/Projectile/Update.hs 249;" f @@ -4251,8 +4251,8 @@ multGunCrit src/Dodge/Creature.hs 75;" f multiArrow src/Picture/Composite.hs 11;" f multiLookupTrie src/SimpleTrie.hs 57;" f multiLookupTrieI src/SimpleTrie.hs 66;" f -multiSelScroll src/Dodge/Inventory.hs 215;" f -multiSelScroll' src/Dodge/Inventory.hs 222;" f +multiSelScroll src/Dodge/Inventory.hs 218;" f +multiSelScroll' src/Dodge/Inventory.hs 225;" f muout src/Dodge/RoomLink.hs 144;" f muzFlareAt src/Dodge/HeldUse.hs 692;" f muzzlePos src/Dodge/HeldUse.hs 779;" f @@ -4493,7 +4493,7 @@ polygonWire src/Picture/Base.hs 59;" f polysToPic src/Polyhedra.hs 122;" f popScreen src/Dodge/Menu/PushPop.hs 6;" f posRms src/Dodge/Tree/Shift.hs 45;" f -posSelSecYint src/Dodge/SelectionSections.hs 147;" f +posSelSecYint src/Dodge/SelectionSections.hs 161;" f positionRoomsFromTree src/Dodge/Tree/Shift.hs 36;" f postGenerationProcessing src/Dodge/LevelGen.hs 31;" f postUniverseLoadSideEffect src/Dodge/WorldLoad.hs 14;" f @@ -4718,7 +4718,7 @@ rightWristPQ src/Dodge/Creature/HandPos.hs 58;" f rlPosDir src/Dodge/RoomLink.hs 112;" f rlauncherPic src/Dodge/Item/Draw/SPic.hs 398;" f rmInLinks src/Dodge/RoomLink.hs 153;" f -rmInvItem src/Dodge/Inventory.hs 82;" f +rmInvItem src/Dodge/Inventory.hs 83;" f rmLinksOfType src/Dodge/RoomLink.hs 150;" f rmOutLinks src/Dodge/RoomLink.hs 153;" f roomC src/Dodge/Room/Room.hs 51;" f @@ -4809,9 +4809,9 @@ screenPolygon src/Dodge/Base/Window.hs 18;" f screenPolygonBord src/Dodge/Base/Window.hs 28;" f screenPosAbs src/Dodge/ScreenPos.hs 15;" f screenToWorldPos src/Dodge/Base/Coordinate.hs 45;" f -scrollAugInvSel src/Dodge/Inventory.hs 289;" f -scrollAugNextInSection src/Dodge/Inventory.hs 303;" f -scrollRBOption src/Dodge/Update/Scroll.hs 140;" f +scrollAugInvSel src/Dodge/Inventory.hs 292;" f +scrollAugNextInSection src/Dodge/Inventory.hs 306;" f +scrollRBOption src/Dodge/Update/Scroll.hs 139;" f scrollSelectionSections src/Dodge/SelectionSections.hs 28;" f scrollTimeBack src/Dodge/Update.hs 243;" f scrollTimeForward src/Dodge/Update.hs 260;" f @@ -4835,9 +4835,9 @@ selNumPos src/Dodge/Render/HUD.hs 470;" f selNumPosCardinal src/Dodge/Render/HUD.hs 487;" f selSecDrawCursor src/Dodge/Render/List.hs 101;" f selSecSelCol src/Dodge/Render/HUD.hs 507;" f -selSecSelSize src/Dodge/SelectionSections.hs 143;" f -selSecYint src/Dodge/SelectionSections.hs 152;" f -selectedItemScroll src/Dodge/Update/Scroll.hs 50;" f +selSecSelSize src/Dodge/SelectionSections.hs 157;" f +selSecYint src/Dodge/SelectionSections.hs 166;" f +selectedItemScroll src/Dodge/Update/Scroll.hs 49;" f semitoneLoop1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 785;" f sensAboveDoor src/Dodge/Room/SensorDoor.hs 70;" f sensInsideDoor src/Dodge/Room/SensorDoor.hs 79;" f @@ -4918,8 +4918,8 @@ shiftChildren src/Dodge/Tree/Compose.hs 45;" f shiftDraw src/Dodge/Render/ShapePicture.hs 130;" f shiftInBy src/Dodge/PlacementSpot.hs 254;" f shiftInvItems src/Dodge/Update/Input/InGame.hs 294;" f -shiftInvItemsDown src/Dodge/Inventory.hs 174;" f -shiftInvItemsUp src/Dodge/Inventory.hs 184;" f +shiftInvItemsDown src/Dodge/Inventory.hs 177;" f +shiftInvItemsUp src/Dodge/Inventory.hs 187;" f shiftLinkBy src/Dodge/Room/Link.hs 87;" f shiftPSBy src/Dodge/Placement/Shift.hs 12;" f shiftPathBy src/Dodge/Room/Link.hs 92;" f @@ -4931,8 +4931,8 @@ shiftRelativeToPS src/Dodge/Placement/Shift.hs 18;" f shiftRoomBy src/Dodge/Room/Link.hs 37;" f shiftRoomShiftBy src/Dodge/Room/Link.hs 81;" f shiftRoomShiftToLink src/Dodge/Room/Link.hs 70;" f -shiftSetDown src/Dodge/Inventory.hs 167;" f -shiftSetUp src/Dodge/Inventory.hs 161;" f +shiftSetDown src/Dodge/Inventory.hs 170;" f +shiftSetUp src/Dodge/Inventory.hs 164;" f shineTargetLaser src/Dodge/Creature/State.hs 201;" f shineTorch src/Dodge/Creature/State.hs 238;" f shootBullet src/Dodge/HeldUse.hs 991;" f @@ -5070,21 +5070,21 @@ square src/Geometry/Polygon.hs 56;" f squareDecoration src/Dodge/Placement/TopDecoration.hs 48;" f squashIntersectCirclePoint src/Dodge/WallCreatureCollisions.hs 115;" f squashNormalizeV src/Geometry/Vector.hs 158;" f -ssLookupDown src/Dodge/SelectionSections.hs 82;" f -ssLookupGE' src/Dodge/SelectionSections.hs 136;" f -ssLookupGT src/Dodge/SelectionSections.hs 123;" f -ssLookupGT' src/Dodge/SelectionSections.hs 129;" f -ssLookupLE' src/Dodge/SelectionSections.hs 111;" f -ssLookupLT src/Dodge/SelectionSections.hs 98;" f -ssLookupLT' src/Dodge/SelectionSections.hs 104;" f -ssLookupMax src/Dodge/SelectionSections.hs 72;" f -ssLookupMaxInSection src/Dodge/SelectionSections.hs 92;" f -ssLookupMin src/Dodge/SelectionSections.hs 118;" f -ssLookupNextMax src/Dodge/SelectionSections.hs 87;" f -ssLookupUp src/Dodge/SelectionSections.hs 77;" f -ssScrollMinOnFail src/Dodge/SelectionSections.hs 44;" f +ssLookupDown src/Dodge/SelectionSections.hs 96;" f +ssLookupGE' src/Dodge/SelectionSections.hs 150;" f +ssLookupGT src/Dodge/SelectionSections.hs 137;" f +ssLookupGT' src/Dodge/SelectionSections.hs 143;" f +ssLookupLE' src/Dodge/SelectionSections.hs 125;" f +ssLookupLT src/Dodge/SelectionSections.hs 112;" f +ssLookupLT' src/Dodge/SelectionSections.hs 118;" f +ssLookupMax src/Dodge/SelectionSections.hs 86;" f +ssLookupMaxInSection src/Dodge/SelectionSections.hs 106;" f +ssLookupMin src/Dodge/SelectionSections.hs 132;" f +ssLookupNextMax src/Dodge/SelectionSections.hs 101;" f +ssLookupUp src/Dodge/SelectionSections.hs 91;" f +ssScrollMinOnFail src/Dodge/SelectionSections.hs 45;" f ssScrollUsing src/Dodge/SelectionSections.hs 37;" f -ssSetCursor src/Dodge/SelectionSections.hs 59;" f +ssSetCursor src/Dodge/SelectionSections.hs 73;" f ssfold src/FoldableHelp.hs 105;" f stackPicturesAt src/Dodge/Render/List.hs 95;" f stackPicturesAtOff src/Dodge/Render/List.hs 98;" f @@ -5130,8 +5130,8 @@ swapAnyExtraSelection src/Dodge/Inventory/Swap.hs 57;" f swapInOutLinks src/Dodge/RoomLink.hs 99;" f swapIndices src/ListHelp.hs 50;" f swapInvItems src/Dodge/Inventory/Swap.hs 22;" f -swapItemWith src/Dodge/Inventory.hs 262;" f -swapSelSet src/Dodge/Inventory.hs 154;" f +swapItemWith src/Dodge/Inventory.hs 265;" f +swapSelSet src/Dodge/Inventory.hs 153;" f swarmCrit src/Dodge/Creature/SwarmCrit.hs 10;" f swarmUsingCenter src/Dodge/Creature/Boid.hs 174;" f t src/ShortShow.hs 48;" f @@ -5175,7 +5175,7 @@ terminalReturnLocal src/Dodge/Terminal.hs 283;" f terminalSPic src/Dodge/Machine/Draw.hs 47;" f terminalScreenGlow src/Dodge/Machine/Update.hs 43;" f terminalShape src/Dodge/Machine/Draw.hs 50;" f -terminalWheelEvent src/Dodge/Update/Scroll.hs 130;" f +terminalWheelEvent src/Dodge/Update/Scroll.hs 129;" f teslaCoil src/Dodge/Item/Held/BatteryGuns.hs 12;" f teslaGunPic src/Dodge/Item/Draw/SPic.hs 410;" f teslaParams src/Dodge/Item/Held/BatteryGuns.hs 18;" f @@ -5381,7 +5381,7 @@ updateBulVel src/Dodge/Bullet.hs 57;" f updateBullet src/Dodge/Bullet.hs 22;" f updateBullets src/Dodge/Update.hs 642;" f updateCamera src/Dodge/Update/Camera.hs 32;" f -updateCloseObjects src/Dodge/Inventory.hs 124;" f +updateCloseObjects src/Dodge/Inventory.hs 125;" f updateCloud src/Dodge/Update.hs 884;" f updateClouds src/Dodge/Update.hs 753;" f updateCombinePositioning src/Dodge/DisplayInventory.hs 40;" f @@ -5465,7 +5465,7 @@ updateRandNode src/TreeHelp.hs 109;" f updateRenderSplit appDodge/Main.hs 104;" f updateRightParentSF src/Dodge/Item/Grammar.hs 185;" f updateRootItemID src/Dodge/Inventory/Location.hs 41;" f -updateScopeZoom src/Dodge/Update/Scroll.hs 78;" f +updateScopeZoom src/Dodge/Update/Scroll.hs 77;" f updateScrollTestValue src/Dodge/ScrollValue.hs 6;" f updateSection src/Dodge/DisplayInventory.hs 262;" f updateSectionsPositioning src/Dodge/DisplayInventory.hs 241;" f @@ -5694,7 +5694,7 @@ zoneWall src/Dodge/Zoning/Wall.hs 65;" f zonesAroundPoint src/Dodge/Zoning/Base.hs 98;" f zonesExtract src/Dodge/Zoning/Base.hs 62;" f zoomFloatingCamera src/Dodge/Update/Camera.hs 77;" f -zoomInLongGun src/Dodge/Update/Scroll.hs 104;" f -zoomOutLongGun src/Dodge/Update/Scroll.hs 112;" f +zoomInLongGun src/Dodge/Update/Scroll.hs 103;" f +zoomOutLongGun src/Dodge/Update/Scroll.hs 111;" f zoomScope src/Dodge/Item/Scope.hs 32;" f -zoomSpeed src/Dodge/Update/Scroll.hs 101;" f +zoomSpeed src/Dodge/Update/Scroll.hs 100;" f