Allow use of items while examine subinventory shows

Still not sure what to do with right click scrolling, item swapping
This commit is contained in:
2025-01-01 21:58:07 +00:00
parent ff5c4db3ae
commit adc0878a28
15 changed files with 343 additions and 311 deletions
+3 -5
View File
@@ -44,7 +44,7 @@ useItemLoc cr loc pt w
| RemoteDetonatorSF <- sf | RemoteDetonatorSF <- sf
, pt == InitialPress = , pt == InitialPress =
return $ activateDetonator ldt w return $ activateDetonator ldt w
| ITEMSCANNER <- itm ^. itType | ITEMSCAN <- itm ^. itType
, pt == InitialPress = , pt == InitialPress =
return $ toggleExamineInv w return $ toggleExamineInv w
| Just b <- itm ^? itUse . useToggle | Just b <- itm ^? itUse . useToggle
@@ -126,7 +126,5 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation invid w of
toggleExamineInv :: World -> World toggleExamineInv :: World -> World
toggleExamineInv w = case w ^? hud . hudElement . subInventory of toggleExamineInv w = case w ^? hud . hudElement . subInventory of
Just ExamineInventory{} -> w & thepointer .~ NoSubInventory Just ExamineInventory{} -> w & hud . hudElement . subInventory .~ NoSubInventory
_ -> w & thepointer .~ ExamineInventory _ -> w & hud . hudElement . subInventory .~ ExamineInventory
where
thepointer = hud . hudElement . subInventory
+15 -6
View File
@@ -24,7 +24,8 @@ yourControl :: Creature -> World -> World
yourControl _ w yourControl _ w
| inTextInputFocus w = w | inTextInputFocus w = w
| Just x <- w ^? hud . hudElement . subInventory | Just x <- w ^? hud . hudElement . subInventory
, f x = w , f x =
w
& cWorld . lWorld . creatures . ix 0 & cWorld . lWorld . creatures . ix 0
%~ (wasdWithAiming w . setCrPosture pkeys) %~ (wasdWithAiming w . setCrPosture pkeys)
& tryClickUse pkeys & tryClickUse pkeys
@@ -69,6 +70,11 @@ hotkeyToScancode :: Hotkey -> SDL.Scancode
hotkeyToScancode x = case x of hotkeyToScancode x = case x of
HotkeyQ -> SDL.ScancodeQ HotkeyQ -> SDL.ScancodeQ
HotkeyE -> SDL.ScancodeE HotkeyE -> SDL.ScancodeE
HotkeyR -> SDL.ScancodeE
HotkeyZ -> SDL.ScancodeZ
HotkeyX -> SDL.ScancodeX
HotkeyC -> SDL.ScancodeC
HotkeyV -> SDL.ScancodeV
Hotkey1 -> SDL.Scancode1 Hotkey1 -> SDL.Scancode1
Hotkey2 -> SDL.Scancode2 Hotkey2 -> SDL.Scancode2
Hotkey3 -> SDL.Scancode3 Hotkey3 -> SDL.Scancode3
@@ -84,6 +90,11 @@ scancodeToHotkey :: SDL.Scancode -> Maybe Hotkey
scancodeToHotkey x = case x of scancodeToHotkey x = case x of
SDL.ScancodeQ -> Just HotkeyQ SDL.ScancodeQ -> Just HotkeyQ
SDL.ScancodeE -> Just HotkeyE SDL.ScancodeE -> Just HotkeyE
SDL.ScancodeR -> Just HotkeyR
SDL.ScancodeZ -> Just HotkeyZ
SDL.ScancodeX -> Just HotkeyX
SDL.ScancodeC -> Just HotkeyC
SDL.ScancodeV -> Just HotkeyV
SDL.Scancode1 -> Just Hotkey1 SDL.Scancode1 -> Just Hotkey1
SDL.Scancode2 -> Just Hotkey2 SDL.Scancode2 -> Just Hotkey2
SDL.Scancode3 -> Just Hotkey3 SDL.Scancode3 -> Just Hotkey3
@@ -166,8 +177,9 @@ tryClickUse :: M.Map SDL.MouseButton Int -> World -> World
tryClickUse pkeys w = fromMaybe w $ do tryClickUse pkeys w = fromMaybe w $ do
ltime <- pkeys ^? ix SDL.ButtonLeft ltime <- pkeys ^? ix SDL.ButtonLeft
rtime <- pkeys ^? ix SDL.ButtonRight rtime <- pkeys ^? ix SDL.ButtonRight
guard $ ltime <= rtime && inTopInv guard $ ltime <= rtime
invid <- w invid <-
w
^? cWorld . lWorld . creatures . ix 0 ^? cWorld . lWorld . creatures . ix 0
. crManipulation . crManipulation
. manObject . manObject
@@ -176,6 +188,3 @@ tryClickUse pkeys w = fromMaybe w $ do
where where
f 0 = InitialPress f 0 = InitialPress
f _ = ShortPress f _ = ShortPress
inTopInv = case w ^. hud . hudElement of
DisplayInventory{_subInventory = NoSubInventory{}} -> True
_ -> False
+5
View File
@@ -32,6 +32,11 @@ data EquipSite
data Hotkey data Hotkey
= HotkeyQ = HotkeyQ
| HotkeyE | HotkeyE
| HotkeyR
| HotkeyZ
| HotkeyX
| HotkeyC
| HotkeyV
| Hotkey1 | Hotkey1
| Hotkey2 | Hotkey2
| Hotkey3 | Hotkey3
+1 -1
View File
@@ -23,7 +23,7 @@ data HUDElement
, _diInvFilter :: Maybe String , _diInvFilter :: Maybe String
, _diCloseFilter :: Maybe String , _diCloseFilter :: Maybe String
} }
| DisplayCarte -- | DisplayCarte
data SubInventory data SubInventory
= NoSubInventory = NoSubInventory
+2 -1
View File
@@ -21,7 +21,8 @@ data ItemType
| TARGETING {_ibtTargeting :: TargetingType} | TARGETING {_ibtTargeting :: TargetingType}
| BULLETMOD {_ibtBulletMod :: BulletMod} | BULLETMOD {_ibtBulletMod :: BulletMod}
| STICKYMOD | STICKYMOD
| ITEMSCANNER | ITEMSCAN
| MAPPER
| INTROSCAN {_ibtIntroScanType :: IntroScanType} | INTROSCAN {_ibtIntroScanType :: IntroScanType}
deriving (Eq, Ord, Show, Read) deriving (Eq, Ord, Show, Read)
+5
View File
@@ -44,6 +44,11 @@ hotkeyToString :: Hotkey -> String
hotkeyToString x = case x of hotkeyToString x = case x of
HotkeyQ -> "[Q]" HotkeyQ -> "[Q]"
HotkeyE -> "[E]" HotkeyE -> "[E]"
HotkeyR -> "[R]"
HotkeyZ -> "[Z]"
HotkeyX -> "[X]"
HotkeyC -> "[C]"
HotkeyV -> "[V]"
Hotkey1 -> "[1]" Hotkey1 -> "[1]"
Hotkey2 -> "[2]" Hotkey2 -> "[2]"
Hotkey3 -> "[3]" Hotkey3 -> "[3]"
+2 -1
View File
@@ -25,8 +25,9 @@ itemFromBase = \case
TARGETING tt -> targetingScope tt TARGETING tt -> targetingScope tt
BULLETMOD bm -> bulletModule bm BULLETMOD bm -> bulletModule bm
STICKYMOD -> stickyMod STICKYMOD -> stickyMod
ITEMSCANNER -> itemScanner ITEMSCAN -> itemScan
INTROSCAN t -> introScan t INTROSCAN t -> introScan t
MAPPER -> mapper
itemFromAmmoMag :: AmmoMagType -> Item itemFromAmmoMag :: AmmoMagType -> Item
itemFromAmmoMag at = case at of itemFromAmmoMag at = case at of
+3 -2
View File
@@ -66,8 +66,9 @@ itemBaseName = \case
BULLETMOD (BulletModPayload btt) -> show btt BULLETMOD (BulletModPayload btt) -> show btt
BULLETMOD (BulletModEffect btt) -> show btt BULLETMOD (BulletModEffect btt) -> show btt
STICKYMOD -> "STICKYMOD" STICKYMOD -> "STICKYMOD"
ITEMSCANNER -> "ITEMSCANNER" ITEMSCAN -> "ITEMSCAN"
INTROSCAN t -> show t INTROSCAN t -> show t
MAPPER -> "MAPPER"
showAttachItem :: AttachType -> String showAttachItem :: AttachType -> String
showAttachItem t = case t of showAttachItem t = case t of
@@ -95,7 +96,7 @@ showEquipItem eit = case eit of
itemNumberDisplay :: World -> Creature -> ComposedItem -> [String] itemNumberDisplay :: World -> Creature -> ComposedItem -> [String]
itemNumberDisplay w cr ci itemNumberDisplay w cr ci
| Just x <- ci ^? _1 . itUse . useToggle = [show x] | Just x <- ci ^? _1 . itUse . useToggle = [show x]
| ITEMSCANNER <- ci ^. _1 . itType | ITEMSCAN <- ci ^. _1 . itType
, Just ExamineInventory <- w ^? hud . hudElement . subInventory , Just ExamineInventory <- w ^? hud . hudElement . subInventory
= ["ACTIVE"] = ["ACTIVE"]
| EQUIP WRIST_ECG <- ci ^. _1 . itType = | EQUIP WRIST_ECG <- ci ^. _1 . itType =
+2 -1
View File
@@ -41,7 +41,8 @@ itemSPic it = case it ^. itType of
TARGETING{} -> defSPic TARGETING{} -> defSPic
BULLETMOD{} -> defSPic BULLETMOD{} -> defSPic
STICKYMOD -> defSPic STICKYMOD -> defSPic
ITEMSCANNER -> defSPic ITEMSCAN -> defSPic
MAPPER -> defSPic
INTROSCAN {} -> defSPic INTROSCAN {} -> defSPic
craftItemSPic :: CraftType -> Shape craftItemSPic :: CraftType -> Shape
+1 -1
View File
@@ -131,7 +131,7 @@ getAmmoLinks itm =
itemToFunction :: Item -> ItemStructuralFunction itemToFunction :: Item -> ItemStructuralFunction
itemToFunction itm = case itm ^. itType of itemToFunction itm = case itm ^. itType of
ITEMSCANNER -> ToggleSF ITEMSCAN -> ToggleSF
INTROSCAN {} -> IntroScanSF INTROSCAN {} -> IntroScanSF
HELD LASER -> WeaponTargetingSF HELD LASER -> WeaponTargetingSF
HELD{} -> case itm ^? itUseCondition of HELD{} -> case itm ^? itUseCondition of
+11 -4
View File
@@ -15,8 +15,9 @@ module Dodge.Item.Scope (
bulletModule, bulletModule,
bulletPayloadModule, bulletPayloadModule,
smokeReducer, smokeReducer,
itemScanner, itemScan,
introScan, introScan,
mapper,
) where ) where
--import Dodge.Data.BlBl --import Dodge.Data.BlBl
@@ -55,13 +56,19 @@ introScan t =
& itType .~ INTROSCAN t & itType .~ INTROSCAN t
& itUse .~ UseNothing & itUse .~ UseNothing
itemScanner :: Item itemScan :: Item
itemScanner = itemScan =
defaultHeldItem defaultHeldItem
& itType .~ ITEMSCANNER & itType .~ ITEMSCAN
& itUse .~ UseNothing & itUse .~ UseNothing
& itEffect . ieOnDrop .~ ItemCancelExamineInventory & itEffect . ieOnDrop .~ ItemCancelExamineInventory
mapper :: Item
mapper =
defaultHeldItem
& itType .~ MAPPER
& itUse .~ UseNothing
bulletModule :: BulletMod -> Item bulletModule :: BulletMod -> Item
bulletModule bm = bulletModule bm =
defaultHeldItem defaultHeldItem
+2 -2
View File
@@ -31,7 +31,7 @@ import Dodge.Item.Info
import Dodge.Item.InvSize import Dodge.Item.InvSize
import Dodge.ListDisplayParams import Dodge.ListDisplayParams
import Dodge.Render.Connectors import Dodge.Render.Connectors
import Dodge.Render.HUD.Carte --import Dodge.Render.HUD.Carte
import Dodge.Render.List import Dodge.Render.List
import Dodge.ScreenPos import Dodge.ScreenPos
import Dodge.SelectionSections import Dodge.SelectionSections
@@ -46,7 +46,7 @@ import SDL (MouseButton (..))
drawHUD :: Configuration -> World -> Picture drawHUD :: Configuration -> World -> Picture
drawHUD cfig w = case w ^. hud . hudElement of drawHUD cfig w = case w ^. hud . hudElement of
DisplayCarte -> drawCarte cfig w -- DisplayCarte -> drawCarte cfig w
DisplayInventory{_diSections = sections, _subInventory = subinv} -> DisplayInventory{_diSections = sections, _subInventory = subinv} ->
drawInventory sections w cfig drawInventory sections w cfig
<> drawSubInventory subinv cfig w <> drawSubInventory subinv cfig w
+45 -45
View File
@@ -32,15 +32,15 @@ import Dodge.SoundLogic
import Dodge.Terminal import Dodge.Terminal
import Dodge.Update.Input.DebugTest import Dodge.Update.Input.DebugTest
import Dodge.Update.Input.Text import Dodge.Update.Input.Text
import Dodge.WorldPos --import Dodge.WorldPos
import Geometry --import Geometry
import LensHelp import LensHelp
import NewInt import NewInt
import SDL import SDL
updateUseInputInGame :: Universe -> Universe updateUseInputInGame :: Universe -> Universe
updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudElement of updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudElement of
DisplayCarte -> over uvWorld updatePressedButtonsCarte u -- DisplayCarte -> over uvWorld updatePressedButtonsCarte u
DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of DisplayInventory{_subInventory = si, _diSelection = disel} -> case si of
DisplayTerminal tmid -> updateKeysInTerminal tmid u DisplayTerminal tmid -> updateKeysInTerminal tmid u
CombineInventory{_ciSections = sss, _ciSelection = msel@(Just (-1, _, _))} -> CombineInventory{_ciSections = sss, _ciSelection = msel@(Just (-1, _, _))} ->
@@ -389,30 +389,30 @@ updateFunctionKey uv ScancodeF3 _ = doDebugTest uv
updateFunctionKey uv ScancodeF4 _ = doDebugTest2 uv updateFunctionKey uv ScancodeF4 _ = doDebugTest2 uv
updateFunctionKey uv _ _ = uv updateFunctionKey uv _ _ = uv
updatePressedButtonsCarte :: World -> World --updatePressedButtonsCarte :: World -> World
updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w --updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w
updatePressedButtonsCarte' :: M.Map MouseButton Int -> World -> World --updatePressedButtonsCarte' :: M.Map MouseButton Int -> World -> World
updatePressedButtonsCarte' pkeys w --updatePressedButtonsCarte' pkeys w
| isDown ButtonRight = -- | isDown ButtonRight =
w & hud . carteCenter %~ (-.- trans) -- w & hud . carteCenter %~ (-.- trans)
| isDown ButtonLeft = -- | isDown ButtonLeft =
w -- w
& hud . carteRot -~ rot -- & hud . carteRot -~ rot
& hud . carteZoom *~ czoom -- & hud . carteZoom *~ czoom
| otherwise = w -- | otherwise = w
where -- where
isDown but = but `M.member` pkeys -- isDown but = but `M.member` pkeys
mbutpos but = theinput ^. heldPos . at but -- mbutpos but = theinput ^. heldPos . at but
rot = maybe 0 (angleBetween (_mousePos (_input w))) $ mbutpos SDL.ButtonLeft -- rot = maybe 0 (angleBetween (_mousePos (_input w))) $ mbutpos SDL.ButtonLeft
czoom = fromMaybe 1 $ do -- czoom = fromMaybe 1 $ do
p <- mbutpos SDL.ButtonLeft -- p <- mbutpos SDL.ButtonLeft
return $ magV (_mousePos theinput) / magV p -- return $ magV (_mousePos theinput) / magV p
theinput = w ^. input -- theinput = w ^. input
trans = fromMaybe 0 $ do -- trans = fromMaybe 0 $ do
p <- mbutpos SDL.ButtonRight -- p <- mbutpos SDL.ButtonRight
return . rotateV (w ^. hud . carteRot) $ -- return . rotateV (w ^. hud . carteRot) $
1 / (w ^. hud . carteZoom) *.* (_mousePos (_input w) -.- p) -- 1 / (w ^. hud . carteZoom) *.* (_mousePos (_input w) -.- p)
updateKeysInTerminal :: Int -> Universe -> Universe updateKeysInTerminal :: Int -> Universe -> Universe
updateKeysInTerminal tmid u = updateKeysInTerminal tmid u =
@@ -437,7 +437,7 @@ updateInitialPressInGame uv sc = case sc of
ScancodeSpace -> over uvWorld spaceAction uv ScancodeSpace -> over uvWorld spaceAction uv
ScancodeP -> pauseGame uv ScancodeP -> pauseGame uv
ScancodeF -> over uvWorld youDropItem uv ScancodeF -> over uvWorld youDropItem uv
ScancodeM -> toggleMap uv -- ScancodeM -> toggleMap uv
ScancodeT -> over uvWorld testEvent uv ScancodeT -> over uvWorld testEvent uv
ScancodeC -> toggleCombineInv uv ScancodeC -> toggleCombineInv uv
-- the following should be put in a more sensible place -- the following should be put in a more sensible place
@@ -538,7 +538,7 @@ pauseGame u = u & uvScreenLayers .~ [pauseMenu u]
spaceAction :: World -> World spaceAction :: World -> World
spaceAction w = case w ^. hud . hudElement of spaceAction w = case w ^. hud . hudElement of
DisplayCarte -> w & hud . carteCenter .~ theLoc -- DisplayCarte -> w & hud . carteCenter .~ theLoc
DisplayInventory{_subInventory = NoSubInventory{}} -> fromMaybe w $ do DisplayInventory{_subInventory = NoSubInventory{}} -> fromMaybe w $ do
cobj <- selCloseObj w cobj <- selCloseObj w
return $ case cobj of return $ case cobj of
@@ -553,11 +553,11 @@ spaceAction w = case w ^. hud . hudElement of
& hud . hudElement . subInventory .~ NoSubInventory & hud . hudElement . subInventory .~ NoSubInventory
& worldEventFlags . at InventoryChange ?~ () & worldEventFlags . at InventoryChange ?~ ()
_ -> w & hud . hudElement . subInventory .~ NoSubInventory _ -> w & hud . hudElement . subInventory .~ NoSubInventory
where -- where
theLoc = -- theLoc =
doWorldPos -- doWorldPos
(w ^?! cWorld . lWorld . seenLocations . ix (w ^. cWorld . lWorld . selLocation) . _1) -- (w ^?! cWorld . lWorld . seenLocations . ix (w ^. cWorld . lWorld . selLocation) . _1)
w -- w
selCloseObj :: World -> Maybe (Either FloorItem Button) selCloseObj :: World -> Maybe (Either FloorItem Button)
selCloseObj w = selobj <|> firstcitem <|> firstcbut selCloseObj w = selobj <|> firstcitem <|> firstcbut
@@ -580,18 +580,18 @@ selCloseObj w = selobj <|> firstcitem <|> firstcbut
k <- w ^? hud . closeButtons . ix 0 k <- w ^? hud . closeButtons . ix 0
fmap Right $ w ^? cWorld . lWorld . buttons . ix k fmap Right $ w ^? cWorld . lWorld . buttons . ix k
toggleMap :: Universe -> Universe --toggleMap :: Universe -> Universe
toggleMap u = case u ^. uvWorld . hud . hudElement of --toggleMap u = case u ^. uvWorld . hud . hudElement of
DisplayCarte -> -- DisplayCarte ->
u & uvWorld . hud . hudElement -- u & uvWorld . hud . hudElement
.~ DisplayInventory -- .~ DisplayInventory
{ _subInventory = NoSubInventory -- { _subInventory = NoSubInventory
, _diSections = mempty -- , _diSections = mempty
, _diSelection = Nothing -- , _diSelection = Nothing
, _diInvFilter = mempty -- , _diInvFilter = mempty
, _diCloseFilter = mempty -- , _diCloseFilter = mempty
} -- }
_ -> u & uvWorld . hud . hudElement .~ DisplayCarte -- _ -> u & uvWorld . hud . hudElement .~ DisplayCarte
tryCombine :: (Int, Int) -> World -> World tryCombine :: (Int, Int) -> World -> World
tryCombine (i, j) w = fromMaybe w $ do tryCombine (i, j) w = fromMaybe w $ do
+5 -5
View File
@@ -14,15 +14,15 @@ import Dodge.SelectionSections
--import Dodge.SoundLogic --import Dodge.SoundLogic
import Dodge.Terminal import Dodge.Terminal
--import Dodge.Tweak --import Dodge.Tweak
import qualified IntMapHelp as IM --import qualified IntMapHelp as IM
import LensHelp import LensHelp
import SDL import SDL
updateWheelEvent :: Int -> World -> World updateWheelEvent :: Int -> World -> World
updateWheelEvent yi w = case w ^. hud . hudElement of updateWheelEvent yi w = case w ^. hud . hudElement of
DisplayCarte -- DisplayCarte
| bdown ButtonRight -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *) -- | bdown ButtonRight -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
| otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi) -- | otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
DisplayInventory{_subInventory = NoSubInventory{}} DisplayInventory{_subInventory = NoSubInventory{}}
-- functions that modify the inventory should be centralised so that -- functions that modify the inventory should be centralised so that
-- this lock can be sensibly applied, perhaps -- this lock can be sensibly applied, perhaps
@@ -46,7 +46,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeType esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeType
return $ length $ eqSiteToPositions esite return $ length $ eqSiteToPositions esite
y = fromIntegral yi y = fromIntegral yi
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1 -- numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
bdown b = b `M.member` _mouseButtons (_input w) bdown b = b `M.member` _mouseButtons (_input w)
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w) invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
+236 -232
View File
File diff suppressed because it is too large Load Diff