This commit is contained in:
2025-08-25 11:01:07 +01:00
parent ee884899ef
commit 65803c11c9
7 changed files with 17 additions and 34 deletions
+7 -22
View File
@@ -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
+1
View File
@@ -9,6 +9,7 @@ module Dodge.DisplayInventory (
toggleCombineInv,
) where
import Dodge.Inventory.CheckSlots
import NewInt
import Control.Applicative
import Control.Lens
-2
View File
@@ -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
-1
View File
@@ -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
+1
View File
@@ -2,6 +2,7 @@
module Dodge.Render.HUD (drawHUD) where
import Dodge.Inventory.CheckSlots
import Control.Applicative
import Control.Lens
import Control.Monad
+1
View File
@@ -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
+7 -9
View File
@@ -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