Work on inventory management

This commit is contained in:
2023-02-16 16:12:03 +00:00
parent ff5fa6321a
commit 934dd64704
30 changed files with 129 additions and 111 deletions
+17 -8
View File
@@ -79,7 +79,9 @@ doInvRegexInput :: Universe -> Universe
doInvRegexInput u
| backspacetonothing
= u & uvWorld . hud . hudElement . diSections %~ overSection
( ssRegex .~ EmptyRegex )
( ( ssRegex .~ EmptyRegex )
. ( ssItems . at (-1) .~ Nothing)
)
-- . initialSelPos )
-- & uvWorld . hud . hudElement . diSections %~ setShownIntMap
| endkeys || endmouse = u
@@ -122,7 +124,13 @@ updateKeysInTerminal tmid u =
| otherwise = id
updateKeyInGame :: Universe -> Scancode -> PressType -> Universe
updateKeyInGame uv sc InitialPress = case sc of
updateKeyInGame uv sc pt = case pt of
InitialPress -> updateInitialPressInGame uv sc
LongPress -> updateLongPressInGame uv sc
_ -> uv
updateInitialPressInGame :: Universe -> Scancode -> Universe
updateInitialPressInGame uv sc = case sc of
ScancodeF5 -> doQuicksave uv
ScancodeF9 -> loadSaveSlot QuicksaveSlot uv
ScancodeEscape -> pauseGame uv
@@ -137,20 +145,19 @@ updateKeyInGame uv sc InitialPress = case sc of
-- the following should be put in a more sensible place
ScancodeSlash -> uv & uvWorld . hud . hudElement %~ updateEnterRegex
ScancodeBackspace -> uv & uvWorld . hud . hudElement %~ updateBackspaceRegex
-- in fact the whole logic should probably be rethought, oh well
_ -> uv
updateKeyInGame uv sc LongPress = case sc of
updateLongPressInGame :: Universe -> Scancode -> Universe
updateLongPressInGame uv sc = case sc of
ScancodeF -> over uvWorld youDropItem uv
ScancodeSpace -> over uvWorld spaceAction uv
_ -> uv
updateKeyInGame uv _ _ = uv
updateBackspaceRegex :: HUDElement -> HUDElement
updateBackspaceRegex di = case di ^? subInventory of
Just NoSubInventory -> di & diSections %~ overSection
( (ssRegex %~ backssregex)
. (ssCursor .~ Just (SectionCursor (-1) 0 1 white))
. (ssCursor ?~ SectionCursor (-1) 0 1 white)
)
Just CombineInventory {} -> di
& subInventory . subInvMap . smRegex %~ enternonzeroregex
@@ -165,7 +172,9 @@ updateBackspaceRegex di = case di ^? subInventory of
updateEnterRegex :: HUDElement -> HUDElement
updateEnterRegex di = case di ^? subInventory of
Just NoSubInventory -> di & diSections %~ overSection (ssRegex %~ enterssregex)
Just NoSubInventory -> di & diSections %~ overSection
( (ssRegex %~ enterssregex)
)
Just CombineInventory {} -> di
& subInventory . subInvMap . smRegex %~ enterregex
& subInventory . subInvMap . smSelPos ?~ 0