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, module Dodge.Data.Item,
--module Dodge.Data.Item.Effect,
module Dodge.Data.Item.Misc, module Dodge.Data.Item.Misc,
module Dodge.Data.Item.Params, module Dodge.Data.Item.Params,
module Dodge.Data.Item.Use, module Dodge.Data.Item.Use,
@@ -12,30 +11,18 @@ module Dodge.Data.Item (
module Dodge.Data.Item.Location, module Dodge.Data.Item.Location,
) where ) where
import Geometry.Data
--import qualified Data.IntMap.Strict as IM
import Control.Lens import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Aeson.TH import Data.Aeson.TH
import Dodge.Data.Item.Combine import Dodge.Data.Item.Combine
--import Dodge.Data.Item.Effect
import Dodge.Data.Item.Location import Dodge.Data.Item.Location
import Dodge.Data.Item.Misc import Dodge.Data.Item.Misc
import Dodge.Data.Item.Params import Dodge.Data.Item.Params
import Dodge.Data.Item.Scope import Dodge.Data.Item.Scope
import Dodge.Data.Item.Use import Dodge.Data.Item.Use
import Geometry.Data
import NewInt import NewInt
data ItID = ItID
deriving (Eq, Ord, Show, Read)
--data Consumables
-- = NoConsumables
-- | AmmoMag
-- { _magLoadStatus :: ReloadStatus
-- }
-- deriving (Eq, Show, Read)
data Item = Item data Item = Item
{ _itUse :: ItemUse { _itUse :: ItemUse
, _itConsumables :: Maybe Int , _itConsumables :: Maybe Int
@@ -53,19 +40,17 @@ data ItemScroll
| ItemScrollInt {_itsInt :: Int} | ItemScrollInt {_itsInt :: Int}
| ItemScrollIntRange {_itsMax :: Int, _itsRangeInt :: Int} | ItemScrollIntRange {_itsMax :: Int, _itsRangeInt :: Int}
data ItemTargeting = NoItTargeting data ItemTargeting
= NoItTargeting
| ItTargeting | ItTargeting
{ _itTgPos :: Maybe Point2 { _itTgPos :: Maybe Point2
, _itTgID :: Maybe Int , _itTgID :: Maybe Int
, _itTgActive :: Bool , _itTgActive :: Bool
} }
makeLenses ''ItemTargeting makeLenses ''ItemTargeting
--makeLenses ''Consumables
makeLenses ''Item makeLenses ''Item
makeLenses ''ItemScroll makeLenses ''ItemScroll
deriveJSON defaultOptions ''ItemScroll deriveJSON defaultOptions ''ItemScroll
--deriveJSON defaultOptions ''Consumables
deriveJSON defaultOptions ''ItemTargeting deriveJSON defaultOptions ''ItemTargeting
deriveJSON defaultOptions ''ItID
deriveJSON defaultOptions ''Item deriveJSON defaultOptions ''Item
+1
View File
@@ -9,6 +9,7 @@ module Dodge.DisplayInventory (
toggleCombineInv, toggleCombineInv,
) where ) where
import Dodge.Inventory.CheckSlots
import NewInt import NewInt
import Control.Applicative import Control.Applicative
import Control.Lens import Control.Lens
-2
View File
@@ -7,7 +7,6 @@ module Dodge.Inventory (
invSetSelection, invSetSelection,
invSetSelectionPos, invSetSelectionPos,
scrollAugInvSel, scrollAugInvSel,
crNumFreeSlots,
setInvPosFromSS, setInvPosFromSS,
module Dodge.Inventory.RBList, module Dodge.Inventory.RBList,
swapInvItems, swapInvItems,
@@ -24,7 +23,6 @@ import Dodge.Base
import Dodge.Data.SelectionList import Dodge.Data.SelectionList
import Dodge.Data.World import Dodge.Data.World
import Dodge.Equipment import Dodge.Equipment
import Dodge.Inventory.CheckSlots
import Dodge.Inventory.Location import Dodge.Inventory.Location
import Dodge.Inventory.RBList import Dodge.Inventory.RBList
import Dodge.Inventory.Swap import Dodge.Inventory.Swap
-1
View File
@@ -22,7 +22,6 @@ checkInvSlotsYou it w = do
Just . NInt . IM.newKey . _unNIntMap $ _crInv ycr Just . NInt . IM.newKey . _unNIntMap $ _crInv ycr
crNumFreeSlots :: IM.IntMap Item -> Creature -> Int crNumFreeSlots :: IM.IntMap Item -> Creature -> Int
--crNumFreeSlots cr = _crInvCapacity cr - invSize (_crInv cr)
crNumFreeSlots m cr = maxInvSlots - invSize (fmap f (_crInv cr)) crNumFreeSlots m cr = maxInvSlots - invSize (fmap f (_crInv cr))
where where
f i = m ^?! ix i f i = m ^?! ix i
+1
View File
@@ -2,6 +2,7 @@
module Dodge.Render.HUD (drawHUD) where module Dodge.Render.HUD (drawHUD) where
import Dodge.Inventory.CheckSlots
import Control.Applicative import Control.Applicative
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
+1
View File
@@ -5,6 +5,7 @@ module Dodge.Update.Input.InGame (
updateMouseInGame, updateMouseInGame,
) where ) where
import Dodge.Inventory.CheckSlots
import Dodge.Base.Collide import Dodge.Base.Collide
import Geometry.Vector import Geometry.Vector
import Dodge.Data.Terminal.Status import Dodge.Data.Terminal.Status
+7 -9
View File
@@ -52,14 +52,13 @@ selectedItemScroll :: Int -> World -> Maybe World
selectedItemScroll yi w = do selectedItemScroll yi w = do
i <- you w ^? crManipulation . manObject . imSelectedItem i <- you w ^? crManipulation . manObject . imSelectedItem
itm <- you w ^? crInv . ix i >>= \k -> w ^? cWorld . lWorld . items . ix k 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 :: Int -> Item -> World -> World
itemScroll yi invid itm w itemScroll yi itm w
-- | isJust $ itm ^? itUse . uInt = w & itmlens . itUse . uInt +~ yi
| Just xs <- itm ^? itUse . uaParams . apProjectiles = w | Just xs <- itm ^? itUse . uaParams . apProjectiles = w
& itmlens . itUse . uaParams . apProjectiles .~ rotateList yi xs & 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 | HELD ALTERIFLE <- itm ^. itType
, yi /= 0 = , yi /= 0 =
w 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 -- note that your _crInvLock does not apply to this TODO check that this is what
-- is wanted -- is wanted
updateScopeZoom :: Int -> World -> World updateScopeZoom :: NewInt ItmInt -> World -> World
updateScopeZoom i w updateScopeZoom itid w
| Just 0 <- w ^. input . mouseButtons . at SDL.ButtonRight = | Just 0 <- w ^. input . mouseButtons . at SDL.ButtonRight =
w w
& wppointer %~ resetscope & wppointer %~ resetscope
@@ -84,8 +83,7 @@ updateScopeZoom i w
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos) w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos)
| otherwise = w & wppointer %~ resetscope | otherwise = w & wppointer %~ resetscope
where where
itid = w ^?! cWorld . lWorld . creatures . ix 0 . crInv . ix (NInt i) wppointer = cWorld . lWorld . items . ix (_unNInt itid) . itUse . uScope
wppointer = cWorld . lWorld . items . ix itid . itUse . uScope
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
doScopeZoom :: Int -> Point2 -> Scope -> Scope doScopeZoom :: Int -> Point2 -> Scope -> Scope