Move combine list over to SelectionSections -- more todo

This commit is contained in:
2023-02-18 10:59:59 +00:00
parent 36b9b5445c
commit 6eca3bab38
10 changed files with 119 additions and 160 deletions
+21 -21
View File
@@ -52,14 +52,14 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
doSubInvRegexInput :: Universe -> Universe
doSubInvRegexInput u
| backspacetonothing =
u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex .~ Nothing
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
| endkeys || endmouse =
u & uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
u & uvWorld . hud . hudElement . subInventory . ciRegex .~ Nothing
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
| endkeys || endmouse = u
-- u & uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
| otherwise =
u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just)
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
u & doTextInputOver (uvWorld . hud . hudElement . subInventory . ciRegex . _Just)
-- & uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
where
endkeys =
any
@@ -67,7 +67,7 @@ doSubInvRegexInput u
[ScancodeReturn, ScancodeEscape, ScancodeSlash]
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
backspacetonothing =
u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just == Just ""
u ^? uvWorld . hud . hudElement . subInventory . ciRegex . _Just == Just ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
pkeys = u ^. uvWorld . input . pressedKeys
@@ -158,7 +158,7 @@ updateInitialPressInGame uv sc = case sc of
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv
ScancodeT -> over uvWorld testEvent uv
ScancodeX -> uv & uvWorld %~ toggleTweakInv
ScancodeC -> over uvWorld toggleCombineInv uv
ScancodeC -> toggleCombineInv uv
-- the following should be put in a more sensible place
ScancodeSlash -> uv & uvWorld %~ updateEnterRegex
ScancodeBackspace -> uv & uvWorld %~ updateBackspaceRegex
@@ -174,12 +174,12 @@ updateBackspaceRegex :: World -> World
updateBackspaceRegex w = case di ^? subInventory of
Just NoSubInventory | secfocus (-1) 0 -> w & cWorld . lWorld . creatures . ix 0 . crManipulation %~ trybackspace
Just NoSubInventory | secfocus 2 3 -> w & cWorld . lWorld . creatures . ix 0 . crManipulation %~ trybackspaceclose
Just CombineInventory{} ->
w & hud . hudElement . subInventory . subInvMap
%~ ( (smRegex %~ enternonzeroregex)
. (smSelPos ?~ 0)
. setShownIntMap
)
-- Just CombineInventory{} ->
-- w & hud . hudElement . subInventory . subInvMap
-- %~ ( (smRegex %~ enternonzeroregex)
-- . (smSelPos ?~ 0)
-- . setShownIntMap
-- )
_ -> w
where
secfocus a b = fromMaybe False $ do
@@ -215,12 +215,12 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
%~ ( (closeRegex %~ enterregex)
. (manObject .~ InNearby SortNearby)
)
Just CombineInventory{} ->
w & hud . hudElement . subInventory . subInvMap
%~ ( setShownIntMap
. (smSelPos ?~ 0)
. (smRegex %~ enterregex)
)
Just CombineInventory{} -> w
-- w & hud . hudElement . subInventory . subInvMap
-- %~ ( setShownIntMap
-- . (smSelPos ?~ 0)
-- . (smRegex %~ enterregex)
-- )
_ -> w
where
di = w ^. hud . hudElement
+3 -1
View File
@@ -2,6 +2,7 @@ module Dodge.Update.Scroll (
updateWheelEvent,
) where
import Dodge.SelectionSections
import SelectionIntMap
import qualified Data.Map.Strict as M
import Data.Maybe
@@ -49,7 +50,8 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
moveCombineSel :: Int -> World -> World
moveCombineSel yi = hud . hudElement . subInventory . subInvMap %~ moveSelectionMapSelection yi
moveCombineSel yi = hud . hudElement . subInventory . ciSections
%~ scrollSelectionSections yi
moveSubSel :: Int -> Int -> World -> World
moveSubSel yi maxyi =
+14 -10
View File
@@ -30,8 +30,8 @@ updateUsingInput w = case w ^. hud . hudElement of
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
pressedMBEffects subinv pkeys w = case subinv of
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
CombineInventory SelectionIntMap{_smSelPos = mi}
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
CombineInventory _ _ sss
| lbinitialpress -> tryCombine sss w -- maybeexitcombine (maybe id doCombine mi w)
DisplayTerminal tmid
| lbinitialpress && inTermFocus w ->
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
@@ -40,11 +40,14 @@ pressedMBEffects subinv pkeys w = case subinv of
_ -> w
where
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
maybeexitcombine w'
| ButtonRight `M.member` _mouseButtons (_input w) =
(hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
(hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
| otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
-- maybeexitcombine w'
-- | ButtonRight `M.member` _mouseButtons (_input w) =
-- (hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
-- (hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
-- | otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
tryCombine :: SelectionSections CombinableItem -> World -> World
tryCombine sss w = w
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
pressedMBEffectsNoInventory pkeys w
@@ -64,9 +67,10 @@ pressedMBEffectsNoInventory pkeys w
-- note "sort" on the inventory indices; otherwise
-- lower items may be shifted up and items below these removed instead
doCombine :: Int -> World -> World
doCombine i w = case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
Nothing -> w
Just (CombinableItem is it _) -> createAndSelectItem it $ foldr (rmInvItem 0) w (sort is)
doCombine i w = undefined
-- case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
-- Nothing -> w
-- Just (CombinableItem is it _) -> createAndSelectItem it $ foldr (rmInvItem 0) w (sort is)
updatePressedButtonsCarte :: M.Map MouseButton Bool -> World -> World
updatePressedButtonsCarte pkeys w