From 65803c11c91fa254efe10d43f556e2024ce155f7 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 25 Aug 2025 11:01:07 +0100 Subject: [PATCH] Cleanup --- src/Dodge/Data/Item.hs | 29 +++++++---------------------- src/Dodge/DisplayInventory.hs | 1 + src/Dodge/Inventory.hs | 2 -- src/Dodge/Inventory/CheckSlots.hs | 1 - src/Dodge/Render/HUD.hs | 1 + src/Dodge/Update/Input/InGame.hs | 1 + src/Dodge/Update/Scroll.hs | 16 +++++++--------- 7 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/Dodge/Data/Item.hs b/src/Dodge/Data/Item.hs index 042ce526b..5bf63b809 100644 --- a/src/Dodge/Data/Item.hs +++ b/src/Dodge/Data/Item.hs @@ -3,7 +3,6 @@ module Dodge.Data.Item ( module Dodge.Data.Item, - --module Dodge.Data.Item.Effect, module Dodge.Data.Item.Misc, module Dodge.Data.Item.Params, module Dodge.Data.Item.Use, @@ -12,30 +11,18 @@ module Dodge.Data.Item ( module Dodge.Data.Item.Location, ) where -import Geometry.Data ---import qualified Data.IntMap.Strict as IM import Control.Lens import Data.Aeson import Data.Aeson.TH import Dodge.Data.Item.Combine ---import Dodge.Data.Item.Effect import Dodge.Data.Item.Location import Dodge.Data.Item.Misc import Dodge.Data.Item.Params import Dodge.Data.Item.Scope import Dodge.Data.Item.Use +import Geometry.Data import NewInt -data ItID = ItID - deriving (Eq, Ord, Show, Read) - ---data Consumables --- = NoConsumables --- | AmmoMag --- { _magLoadStatus :: ReloadStatus --- } --- deriving (Eq, Show, Read) - data Item = Item { _itUse :: ItemUse , _itConsumables :: Maybe Int @@ -53,19 +40,17 @@ data ItemScroll | ItemScrollInt {_itsInt :: Int} | ItemScrollIntRange {_itsMax :: Int, _itsRangeInt :: Int} -data ItemTargeting = NoItTargeting +data ItemTargeting + = NoItTargeting | ItTargeting - { _itTgPos :: Maybe Point2 - , _itTgID :: Maybe Int - , _itTgActive :: Bool - } + { _itTgPos :: Maybe Point2 + , _itTgID :: Maybe Int + , _itTgActive :: Bool + } makeLenses ''ItemTargeting ---makeLenses ''Consumables makeLenses ''Item makeLenses ''ItemScroll deriveJSON defaultOptions ''ItemScroll ---deriveJSON defaultOptions ''Consumables deriveJSON defaultOptions ''ItemTargeting -deriveJSON defaultOptions ''ItID deriveJSON defaultOptions ''Item diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 0a1872ccc..1ec0cb928 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -9,6 +9,7 @@ module Dodge.DisplayInventory ( toggleCombineInv, ) where +import Dodge.Inventory.CheckSlots import NewInt import Control.Applicative import Control.Lens diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index d0cbbb2a0..d4f6e11da 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -7,7 +7,6 @@ module Dodge.Inventory ( invSetSelection, invSetSelectionPos, scrollAugInvSel, - crNumFreeSlots, setInvPosFromSS, module Dodge.Inventory.RBList, swapInvItems, @@ -24,7 +23,6 @@ import Dodge.Base import Dodge.Data.SelectionList import Dodge.Data.World import Dodge.Equipment -import Dodge.Inventory.CheckSlots import Dodge.Inventory.Location import Dodge.Inventory.RBList import Dodge.Inventory.Swap diff --git a/src/Dodge/Inventory/CheckSlots.hs b/src/Dodge/Inventory/CheckSlots.hs index 54da60bf0..2c99be052 100644 --- a/src/Dodge/Inventory/CheckSlots.hs +++ b/src/Dodge/Inventory/CheckSlots.hs @@ -22,7 +22,6 @@ checkInvSlotsYou it w = do Just . NInt . IM.newKey . _unNIntMap $ _crInv ycr crNumFreeSlots :: IM.IntMap Item -> Creature -> Int ---crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr) crNumFreeSlots m cr = maxInvSlots - invSize (fmap f (_crInv cr)) where f i = m ^?! ix i diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index c2a2a02f9..55c084404 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -2,6 +2,7 @@ module Dodge.Render.HUD (drawHUD) where +import Dodge.Inventory.CheckSlots import Control.Applicative import Control.Lens import Control.Monad diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index d4a599f0a..834027793 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -5,6 +5,7 @@ module Dodge.Update.Input.InGame ( updateMouseInGame, ) where +import Dodge.Inventory.CheckSlots import Dodge.Base.Collide import Geometry.Vector import Dodge.Data.Terminal.Status diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index 3dffa9259..df9663967 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -52,14 +52,13 @@ selectedItemScroll :: Int -> World -> Maybe World selectedItemScroll yi w = do i <- you w ^? crManipulation . manObject . imSelectedItem itm <- you w ^? crInv . ix i >>= \k -> w ^? cWorld . lWorld . items . ix k - return $ itemScroll yi (_unNInt i) itm w + return $ itemScroll yi itm w -itemScroll :: Int -> Int -> Item -> World -> World -itemScroll yi invid itm w --- | isJust $ itm ^? itUse . uInt = w & itmlens . itUse . uInt +~ yi +itemScroll :: Int -> Item -> World -> World +itemScroll yi itm w | Just xs <- itm ^? itUse . uaParams . apProjectiles = w & itmlens . itUse . uaParams . apProjectiles .~ rotateList yi xs - | ATTACH ZOOMSCOPE <- itm ^. itType = updateScopeZoom invid w + | ATTACH ZOOMSCOPE <- itm ^. itType = updateScopeZoom (itm ^. itID) w | HELD ALTERIFLE <- itm ^. itType , yi /= 0 = w @@ -75,8 +74,8 @@ itemScroll yi invid itm w -- note that your _crInvLock does not apply to this TODO check that this is what -- is wanted -updateScopeZoom :: Int -> World -> World -updateScopeZoom i w +updateScopeZoom :: NewInt ItmInt -> World -> World +updateScopeZoom itid w | Just 0 <- w ^. input . mouseButtons . at SDL.ButtonRight = w & wppointer %~ resetscope @@ -84,8 +83,7 @@ updateScopeZoom i w w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos) | otherwise = w & wppointer %~ resetscope where - itid = w ^?! cWorld . lWorld . creatures . ix 0 . crInv . ix (NInt i) - wppointer = cWorld . lWorld . items . ix itid . itUse . uScope + wppointer = cWorld . lWorld . items . ix (_unNInt itid) . itUse . uScope resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz doScopeZoom :: Int -> Point2 -> Scope -> Scope