diff --git a/.gitignore b/.gitignore index 4a9ea7dfa..8c0394ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ loop.cabal *.lock keys.json +log/* diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 0d16adabd..6b400b1cf 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -64,7 +64,7 @@ activateDetonator det = fromMaybe id $ do return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0 toggleEquipmentAt :: NewInt InvInt -> Creature -> World -> World -toggleEquipmentAt invid cr w = case getEquipmentAllocation invid w of +toggleEquipmentAt invid cr w = case equipmentDesignation invid w of DoNotMoveEquipment -> w PutOnEquipment{_allocNewPos = newp} -> w diff --git a/src/Dodge/Inventory/RBList.hs b/src/Dodge/Inventory/RBList.hs index 19c13945b..5f81f5297 100644 --- a/src/Dodge/Inventory/RBList.hs +++ b/src/Dodge/Inventory/RBList.hs @@ -1,14 +1,15 @@ +{-# LANGUAGE TupleSections #-} module Dodge.Inventory.RBList ( updateRBList, - getEquipmentAllocation, - eqSiteToPositions, + equipmentDesignation, + eqTypeToSites, ) where import NewInt import qualified Data.IntMap.Strict as IM import Dodge.Data.Equipment.Misc import Dodge.Data.EquipType -import Control.Applicative +--import Control.Applicative import Control.Lens import Data.List (elemIndex, findIndex) import qualified Data.Map.Strict as M @@ -23,14 +24,14 @@ updateRBList w = case w ^. rbOptions of EquipOptions{} -> w _ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do i <- cr ^? crManipulation . manObject . imSelectedItem - esite <- cr ^? crInv . ix i >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType -- . itUse . uequipEffect . eeType - return $ - w & rbOptions - .~ EquipOptions - { _opSel = chooseEquipPosition (w ^. cWorld . lWorld . items) cr (eqSiteToPositions esite) - } + itid <- cr ^? crInv . ix i + etype <- w ^? cWorld . lWorld . items . ix itid >>= equipType + return $ w & rbOptions + .~ EquipOptions + (chooseEquipPosition (w ^. cWorld . lWorld . items) cr (eqTypeToSites etype)) where - norightclick = not $ SDL.ButtonRight `M.member` (w ^. input . mouseButtons) + --norightclick = not $ SDL.ButtonRight `M.member` (w ^. input . mouseButtons) + norightclick = null $ w ^. input . mouseButtons . at SDL.ButtonRight cr = you w -- want to choose the current position if the item is equipped, otherwise try to @@ -47,14 +48,17 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment where hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep -getEquipmentAllocation :: NewInt InvInt -> World -> EquipmentAllocation -getEquipmentAllocation invid w = fromMaybe DoNotMoveEquipment $ do +equipmentDesignation :: NewInt InvInt -> World -> EquipmentAllocation +equipmentDesignation invid w = fromMaybe DoNotMoveEquipment $ do itid <- you w ^? crInv . ix invid - esite <- w ^? cWorld . lWorld . items . ix itid >>= equipType + etype <- w ^? cWorld . lWorld . items . ix itid >>= equipType + let mesite = w ^? cWorld . lWorld . items . ix itid . itLocation . ilEquipSite . _Just i <- w ^? rbOptions . opSel - <|> Just (chooseEquipPosition (w ^. cWorld . lWorld . items) (you w) (eqSiteToPositions esite)) - es <- eqSiteToPositions esite ^? ix i - return $ case you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k . itLocation . ilEquipSite . _Just of +-- <|> (uncurry elemIndex =<< (mesite <&> (,eqSiteToPositions etype))) +-- <|> Just (chooseFreeSite (you w) (eqSiteToPositions etype)) +---- <|> Just (chooseEquipPosition (w ^. cWorld . lWorld . items) (you w) (eqSiteToPositions etype)) + es <- eqTypeToSites etype ^? ix i + return $ case mesite of Just epos | es == epos -> RemoveEquipment{_allocOldPos = epos} Just epos @@ -76,10 +80,9 @@ getEquipmentAllocation invid w = fromMaybe DoNotMoveEquipment $ do , _allocRemoveID = _crEquipment (you w) M.! es } Nothing -> PutOnEquipment{_allocNewPos = es} - where -eqSiteToPositions :: EquipType -> [EquipSite] -eqSiteToPositions es = case es of +eqTypeToSites :: EquipType -> [EquipSite] +eqTypeToSites es = case es of GoesOnHead -> [OnHead] GoesOnChest -> [OnChest] GoesOnBack -> [OnBack] diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 33b5bde9c..d41324d61 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -248,11 +248,12 @@ drawRBOptions :: Config -> World -> Picture drawRBOptions cfig w = fold $ do guard $ ButtonRight `M.member` _mouseButtons (_input w) invid <- you w ^? crManipulation . manObject . imSelectedItem + itid <- you w ^? crInv . ix invid eslist <- - fmap eqSiteToPositions $ - you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType -- . itUse . uequipEffect . eeType + fmap eqTypeToSites $ + w ^? cWorld . lWorld . items . ix itid >>= equipType i <- w ^? rbOptions . opSel - let ae = getEquipmentAllocation invid w + let ae = equipmentDesignation invid w sss <- w ^? hud . diSections Sel i' j _ <- w ^? hud . diSelection . _Just curpos <- selSecYint i' j sss diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index ba5d3b61d..3e4e734bf 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -45,8 +45,8 @@ updateBaseWheelEvent yi w bdown b = w & has (input . mouseButtons . ix b) rbscrollmax = fromMaybe 1 $ do invid <- you w ^? crManipulation . manObject . imSelectedItem - esite <- you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType -- . itUse . uequipEffect . eeType - return . length $ eqSiteToPositions esite + etype <- you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType + return . length $ eqTypeToSites etype selectedItemScroll :: Int -> World -> Maybe World selectedItemScroll yi w = do diff --git a/tags b/tags index 61e03583b..702b4fd24 100644 --- a/tags +++ b/tags @@ -2841,9 +2841,9 @@ centroid src/Geometry/Polygon.hs 136;" f centroidNum src/Geometry/Polygon.hs 139;" f chainCreatureUpdates src/Dodge/Creature/ChainUpdates.hs 6;" f chainPairs src/Geometry.hs 363;" f -changeSwapOther src/Dodge/Inventory.hs 139;" f -changeSwapSel src/Dodge/Inventory.hs 132;" f -changeSwapWith src/Dodge/Inventory.hs 173;" f +changeSwapOther src/Dodge/Inventory.hs 140;" f +changeSwapSel src/Dodge/Inventory.hs 133;" f +changeSwapWith src/Dodge/Inventory.hs 174;" f charToTuple src/Picture/Base.hs 317;" f charToTupleGrad src/Picture/Text.hs 18;" f chartreuse src/Color.hs 24;" f @@ -2871,9 +2871,9 @@ checkWallRight src/Dodge/LevelGen/StaticWalls/Deprecated.hs 59;" f chemFuelPouch src/Dodge/Item/Ammo.hs 75;" f chestPQ src/Dodge/Creature/HandPos.hs 128;" f chooseCursorBorders src/Dodge/Render/List.hs 156;" f -chooseEquipPosition src/Dodge/Inventory/RBList.hs 38;" f +chooseEquipPosition src/Dodge/Inventory/RBList.hs 39;" f chooseFootSound src/Dodge/Creature/State/WalkCycle.hs 34;" f -chooseFreeSite src/Dodge/Inventory/RBList.hs 45;" f +chooseFreeSite src/Dodge/Inventory/RBList.hs 46;" f chooseMovementLtAuto src/Dodge/CreatureEffect.hs 105;" f chooseMovementPistol src/Dodge/Humanoid.hs 203;" f chooseMovementPistol' src/Dodge/Humanoid.hs 208;" f @@ -3536,7 +3536,7 @@ enterCombineInv src/Dodge/DisplayInventory.hs 322;" f epText src/Dodge/Inventory/SelectionList.hs 76;" f eqConstr src/SameConstr.hs 17;" f eqPosText src/Dodge/Equipment/Text.hs 5;" f -eqSiteToPositions src/Dodge/Inventory/RBList.hs 81;" f +eqSiteToPositions src/Dodge/Inventory/RBList.hs 84;" f equipAllocString src/Dodge/Render/HUD.hs 305;" f equipAttachPos src/Dodge/Item/Draw.hs 33;" f equipBackgroundEffect src/Dodge/Euse.hs 15;" f @@ -3545,6 +3545,7 @@ equipItemSPic src/Dodge/Item/Draw/SPic.hs 171;" f equipPosition src/Dodge/Item/Draw.hs 41;" f equipSiteInfo src/Dodge/Item/Info.hs 254;" f equipType src/Dodge/Data/EquipType.hs 10;" f +equipmentDesignation src/Dodge/Inventory/RBList.hs 51;" f equipmentStrValue src/Dodge/Creature/Statistics.hs 52;" f errorAngleVV src/Geometry.hs 60;" f errorClosestPointOnLine src/Geometry.hs 72;" f @@ -3696,7 +3697,6 @@ getCommand src/Dodge/Terminal.hs 58;" f getCommands src/Dodge/Terminal.hs 55;" f getCrMoveSpeed src/Dodge/Creature/Statistics.hs 46;" f getDistortions src/Dodge/Render.hs 435;" f -getEquipmentAllocation src/Dodge/Inventory/RBList.hs 50;" f getGrenadeHitEffect src/Dodge/HeldUse.hs 1301;" f getInventoryPath src/Dodge/Inventory/Path.hs 9;" f getItemValue src/Dodge/Inventory/SelectionList.hs 147;" f @@ -3905,8 +3905,8 @@ invItemEffs src/Dodge/Creature/State.hs 62;" f invItemLocUpdate src/Dodge/Creature/State.hs 70;" f invRootMap src/Dodge/Item/Grammar.hs 226;" f invSelectionItem src/Dodge/Inventory/SelectionList.hs 32;" f -invSetSelection src/Dodge/Inventory.hs 178;" f -invSetSelectionPos src/Dodge/Inventory.hs 186;" f +invSetSelection src/Dodge/Inventory.hs 179;" f +invSetSelectionPos src/Dodge/Inventory.hs 187;" f invShiftPointBy src/Dodge/ShiftPoint.hs 8;" f invSize src/Dodge/Inventory/CheckSlots.hs 33;" f inventoryX src/Dodge/Creature.hs 113;" f @@ -4896,8 +4896,8 @@ screenPolygon src/Dodge/Base/Window.hs 17;" f screenPolygonBord src/Dodge/Base/Window.hs 27;" f screenPosAbs src/Dodge/ScreenPos.hs 15;" f screenToWorldPos src/Dodge/Base/Coordinate.hs 51;" f -scrollAugInvSel src/Dodge/Inventory.hs 189;" f -scrollAugNextInSection src/Dodge/Inventory.hs 202;" f +scrollAugInvSel src/Dodge/Inventory.hs 190;" f +scrollAugNextInSection src/Dodge/Inventory.hs 203;" f scrollDebugInfoInt src/Dodge/Debug.hs 71;" f scrollRBOption src/Dodge/Update/Scroll.hs 217;" f scrollSelectionSections src/Dodge/SelectionSections.hs 28;" f @@ -5206,7 +5206,7 @@ swapAnyExtraSelection src/Dodge/Inventory/Swap.hs 56;" f swapInOutLinks src/Dodge/RoomLink.hs 80;" f swapIndices src/ListHelp.hs 50;" f swapInvItems src/Dodge/Inventory/Swap.hs 21;" f -swapItemWith src/Dodge/Inventory.hs 162;" f +swapItemWith src/Dodge/Inventory.hs 163;" f swarmCrit src/Dodge/Creature/SwarmCrit.hs 10;" f swarmUsingCenter src/Dodge/Creature/Boid.hs 172;" f switchDoor src/Dodge/Placement/Instance/Door.hs 96;" f @@ -5284,7 +5284,7 @@ thingHitFilt src/Dodge/WorldEvent/ThingsHit.hs 71;" f thingsHit src/Dodge/WorldEvent/ThingsHit.hs 34;" f thingsHitExceptCr src/Dodge/WorldEvent/ThingsHit.hs 92;" f threeLineDecoration src/Dodge/Placement/TopDecoration.hs 61;" f -throwItem src/Dodge/Creature/Action.hs 210;" f +throwItem src/Dodge/Creature/Action.hs 211;" f tileTexCoords src/Tile.hs 11;" f tilesFromRooms src/Dodge/Layout.hs 205;" f tilesToLine src/Shader/AuxAddition.hs 66;" f @@ -5455,7 +5455,7 @@ updateBulVel src/Dodge/Bullet.hs 56;" f updateBullet src/Dodge/Bullet.hs 21;" f updateBullets src/Dodge/Update.hs 576;" f updateCamera src/Dodge/Update/Camera.hs 30;" f -updateCloseObjects src/Dodge/Inventory.hs 113;" f +updateCloseObjects src/Dodge/Inventory.hs 114;" f updateCloud src/Dodge/Update.hs 814;" f updateClouds src/Dodge/Update.hs 682;" f updateCombinePositioning src/Dodge/DisplayInventory.hs 39;" f @@ -5522,7 +5522,7 @@ updatePulse src/Dodge/Creature/Update.hs 136;" f updatePulseBall src/Dodge/Update.hs 458;" f updatePulseLaser src/Dodge/Update.hs 623;" f updatePulseLasers src/Dodge/Update.hs 453;" f -updateRBList src/Dodge/Inventory/RBList.hs 20;" f +updateRBList src/Dodge/Inventory/RBList.hs 21;" f updateRadarBlip src/Dodge/RadarBlip.hs 11;" f updateRadarBlips src/Dodge/Update.hs 572;" f updateRadarSweep src/Dodge/RadarSweep.hs 39;" f @@ -5713,7 +5713,7 @@ yIntercepts' src/Dodge/Zoning/Base.hs 76;" f yV2 src/Geometry/Vector.hs 210;" f yellow src/Color.hs 17;" f you src/Dodge/Base/You.hs 13;" f -youDropItem src/Dodge/Creature/Action.hs 195;" f +youDropItem src/Dodge/Creature/Action.hs 196;" f yourAugmentedItem src/Dodge/Render/HUD.hs 234;" f yourControl src/Dodge/Creature/YourControl.hs 29;" f yourDefaultStrideLength src/Dodge/Default/Creature.hs 110;" f