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