Allow for scrolling in combine regex
This commit is contained in:
@@ -114,6 +114,6 @@ enterCombineInv w = w & hud . hudElement . subInventory .~ CombineInventory sm
|
|||||||
sm = initialSelPos $ SelectionIntMap
|
sm = initialSelPos $ SelectionIntMap
|
||||||
{ _smItems = combineList w
|
{ _smItems = combineList w
|
||||||
, _smSelPos = Nothing
|
, _smSelPos = Nothing
|
||||||
, _smRegex = NoSMRegex
|
, _smRegex = Nothing
|
||||||
, _smShownItems = IM.fromAscList $ zip [0..] (combineList w)
|
, _smShownItems = IM.fromAscList $ zip [0..] (combineList w)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ data SMRegex = NoSMRegex
|
|||||||
data SelectionIntMap a = SelectionIntMap
|
data SelectionIntMap a = SelectionIntMap
|
||||||
{ _smItems :: [SelectionItem a]
|
{ _smItems :: [SelectionItem a]
|
||||||
, _smSelPos :: Maybe Int
|
, _smSelPos :: Maybe Int
|
||||||
, _smRegex :: SMRegex
|
, _smRegex :: Maybe String
|
||||||
, _smShownItems :: IntMap (SelectionItem a)
|
, _smShownItems :: IntMap (SelectionItem a)
|
||||||
}
|
}
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
@@ -87,7 +87,6 @@ data SelectionItem a = SelectionItem
|
|||||||
{ _siPictures :: [String]
|
{ _siPictures :: [String]
|
||||||
, _siHeight :: Int
|
, _siHeight :: Int
|
||||||
, _siIsSelectable :: Bool
|
, _siIsSelectable :: Bool
|
||||||
--, _siWidth :: Int
|
|
||||||
, _siColor :: Color
|
, _siColor :: Color
|
||||||
, _siOffX :: Int
|
, _siOffX :: Int
|
||||||
, _siPayload :: a
|
, _siPayload :: a
|
||||||
@@ -96,7 +95,13 @@ data SelectionItem a = SelectionItem
|
|||||||
{ _siPictures :: [String]
|
{ _siPictures :: [String]
|
||||||
, _siHeight :: Int
|
, _siHeight :: Int
|
||||||
, _siIsSelectable :: Bool
|
, _siIsSelectable :: Bool
|
||||||
--, _siWidth :: Int
|
, _siColor :: Color
|
||||||
|
, _siOffX :: Int
|
||||||
|
}
|
||||||
|
| SelectionRegex
|
||||||
|
{ _siPictures :: [String]
|
||||||
|
, _siHeight :: Int
|
||||||
|
, _siIsSelectable :: Bool
|
||||||
, _siColor :: Color
|
, _siColor :: Color
|
||||||
, _siOffX :: Int
|
, _siOffX :: Int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,12 @@ inTermFocus w = fromMaybe False $ do
|
|||||||
return $ hasfocus && connectionstatus == TerminalReady
|
return $ hasfocus && connectionstatus == TerminalReady
|
||||||
|
|
||||||
inputFocus :: World -> Bool
|
inputFocus :: World -> Bool
|
||||||
inputFocus w = inTermFocus w
|
inputFocus w = inTermFocus w || inregexfocus
|
||||||
|| (w ^? hud . hudElement . subInventory . subInvMap . smRegex . smrInput) == Just True
|
where
|
||||||
|
inregexfocus = fromMaybe False $ do
|
||||||
|
sm <- w ^? hud . hudElement . subInventory . subInvMap
|
||||||
|
i <- sm ^? smSelPos . _Just
|
||||||
|
si <- sm ^? smShownItems . ix i
|
||||||
|
case si of
|
||||||
|
SelectionRegex {} -> return True
|
||||||
|
_ -> return False
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ import LensHelp
|
|||||||
-- & slSelPos .~ inventoryCursorPos w
|
-- & slSelPos .~ inventoryCursorPos w
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
--inventoryCursorPos :: World -> Maybe Int
|
|
||||||
--inventoryCursorPos w = case w ^? hud . hudElement . subInventory of
|
|
||||||
-- Just CombineInventory{} -> Nothing
|
|
||||||
-- _ -> Just $ yourInvSel w
|
|
||||||
--
|
|
||||||
invSelectionItem' :: Creature -> Int -> Item -> SelectionItem ()
|
invSelectionItem' :: Creature -> Int -> Item -> SelectionItem ()
|
||||||
invSelectionItem' cr i it = SelectionItem
|
invSelectionItem' cr i it = SelectionItem
|
||||||
{ _siPictures = pics
|
{ _siPictures = pics
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Dodge.Data.Universe
|
|||||||
--import qualified IntMapHelp as IM
|
--import qualified IntMapHelp as IM
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u =
|
testStringInit u =
|
||||||
[ show $ u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex
|
[ show $ u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just
|
||||||
]
|
]
|
||||||
|
|
||||||
showTimeFlow :: TimeFlowStatus -> String
|
showTimeFlow :: TimeFlowStatus -> String
|
||||||
|
|||||||
+8
-2
@@ -143,10 +143,16 @@ updateUseInput u = case u ^? uvScreenLayers . _head of
|
|||||||
optionScreenUpdate screen mop flag ldps sellist u
|
optionScreenUpdate screen mop flag ldps sellist u
|
||||||
_ -> case u ^? uvWorld . hud . hudElement . subInventory of
|
_ -> case u ^? uvWorld . hud . hudElement . subInventory of
|
||||||
Just (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
Just (DisplayTerminal tmid) | inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
|
||||||
Just (CombineInventory SelectionIntMap {_smRegex=smr})
|
Just (CombineInventory sm)
|
||||||
| smr ^? smrInput == Just True -> doSubInvRegexInput u
|
| inregex sm -> doSubInvRegexInput u
|
||||||
_ -> M.foldlWithKey' updateKeyInGame u pkeys
|
_ -> M.foldlWithKey' updateKeyInGame u pkeys
|
||||||
where
|
where
|
||||||
|
inregex sm = fromMaybe False $ do
|
||||||
|
i <- sm ^? smSelPos . _Just
|
||||||
|
si <- sm ^? smShownItems . ix i
|
||||||
|
case si of
|
||||||
|
SelectionRegex {} -> return True
|
||||||
|
_ -> return False
|
||||||
pkeys = u ^. uvWorld . input . pressedKeys
|
pkeys = u ^. uvWorld . input . pressedKeys
|
||||||
|
|
||||||
optionScreenUpdate ::
|
optionScreenUpdate ::
|
||||||
|
|||||||
@@ -47,20 +47,19 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
|
|||||||
doSubInvRegexInput :: Universe -> Universe
|
doSubInvRegexInput :: Universe -> Universe
|
||||||
doSubInvRegexInput u
|
doSubInvRegexInput u
|
||||||
| backspacetonothing
|
| backspacetonothing
|
||||||
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ const NoSMRegex
|
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex .~ Nothing
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
|
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||||
| endkeys || endmouse
|
| endkeys || endmouse
|
||||||
= u & uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . smrInput %~ const False
|
= u & uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap %~ initialSelPos
|
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just)
|
||||||
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvMap . smRegex. smrString)
|
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||||
where
|
where
|
||||||
endkeys = any
|
endkeys = any
|
||||||
( (== Just InitialPress) . (`M.lookup` pkeys))
|
( (== Just InitialPress) . (`M.lookup` pkeys))
|
||||||
[ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
[ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
||||||
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
|
endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft)
|
||||||
backspacetonothing = u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . smrString == Just ""
|
backspacetonothing = u ^? uvWorld . hud . hudElement . subInventory . subInvMap . smRegex . _Just == Just ""
|
||||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||||
pkeys = u ^. uvWorld . input . pressedKeys
|
pkeys = u ^. uvWorld . input . pressedKeys
|
||||||
|
|
||||||
@@ -106,16 +105,18 @@ updateKeyInGame uv sc InitialPress = case sc of
|
|||||||
ScancodeSlash -> uv
|
ScancodeSlash -> uv
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enterregex
|
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enterregex
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
|
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
|
||||||
|
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||||
ScancodeBackspace -> uv
|
ScancodeBackspace -> uv
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enternonzeroregex
|
& uvWorld . hud . hudElement . subInventory . subInvMap . smRegex %~ enternonzeroregex
|
||||||
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
|
& uvWorld . hud . hudElement . subInventory . subInvMap . smSelPos ?~ 0
|
||||||
|
& uvWorld . hud . hudElement . subInventory . subInvMap %~ setShownIntMap
|
||||||
|
|
||||||
-- in fact the whole logic should probably be rethought, oh well
|
-- in fact the whole logic should probably be rethought, oh well
|
||||||
_ -> uv
|
_ -> uv
|
||||||
where
|
where
|
||||||
enterregex NoSMRegex = SMRegex "" True
|
enterregex Nothing = Just ""
|
||||||
enterregex (SMRegex str _) = SMRegex str True
|
enterregex (Just str) = Just str
|
||||||
enternonzeroregex (SMRegex (x:xs) _) = SMRegex (init (x:xs)) True
|
enternonzeroregex (Just (x:xs)) = Just (init (x:xs))
|
||||||
enternonzeroregex smr = smr
|
enternonzeroregex smr = smr
|
||||||
updateKeyInGame uv sc LongPress = case sc of
|
updateKeyInGame uv sc LongPress = case sc of
|
||||||
ScancodeF -> over uvWorld youDropItem uv
|
ScancodeF -> over uvWorld youDropItem uv
|
||||||
|
|||||||
@@ -38,12 +38,10 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
|||||||
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
|
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeAugInvSel yi w
|
||||||
| rbDown -> w & changeTweakParam mi yi
|
| rbDown -> w & changeTweakParam mi yi
|
||||||
| otherwise -> w & moveTweakSel yi
|
| otherwise -> w & moveTweakSel yi
|
||||||
DisplayInventory {_subInventory = CombineInventory sm}
|
DisplayInventory {_subInventory = CombineInventory {}} -> w & moveCombineSel yi
|
||||||
| regexnotinput $ _smRegex sm -> w & moveCombineSel yi
|
|
||||||
DisplayInventory {_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
DisplayInventory {_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
regexnotinput smr = not $ smr ^? smrInput == Just True
|
|
||||||
y = fromIntegral yi
|
y = fromIntegral yi
|
||||||
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
||||||
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
|
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
|
||||||
|
|||||||
@@ -30,11 +30,8 @@ updateUsingInput w = case w ^. hud . hudElement of
|
|||||||
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
|
||||||
pressedMBEffects subinv pkeys w = case subinv of
|
pressedMBEffects subinv pkeys w = case subinv of
|
||||||
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
|
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
|
||||||
CombineInventory SelectionIntMap{_smSelPos = mi, _smRegex = smr}
|
CombineInventory SelectionIntMap{_smSelPos = mi}
|
||||||
| lbinitialpress && regexnotinput smr -> maybeexitcombine (maybe id doCombine mi w)
|
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
|
||||||
CombineInventory SelectionIntMap{}
|
|
||||||
| lbinitialpress -> w & hud . hudElement . subInventory . subInvMap . smRegex. smrInput
|
|
||||||
%~ const False
|
|
||||||
DisplayTerminal tmid
|
DisplayTerminal tmid
|
||||||
| lbinitialpress && inTermFocus w ->
|
| lbinitialpress && inTermFocus w ->
|
||||||
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
|
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
|
||||||
@@ -42,7 +39,6 @@ pressedMBEffects subinv pkeys w = case subinv of
|
|||||||
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
regexnotinput smr = not $ smr ^? smrInput == Just True
|
|
||||||
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
|
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
|
||||||
maybeexitcombine w'
|
maybeexitcombine w'
|
||||||
| ButtonRight `M.member` _mouseButtons (_input w) =
|
| ButtonRight `M.member` _mouseButtons (_input w) =
|
||||||
|
|||||||
@@ -10,16 +10,15 @@ import LensHelp
|
|||||||
|
|
||||||
setShownIntMap :: SelectionIntMap a -> SelectionIntMap a
|
setShownIntMap :: SelectionIntMap a -> SelectionIntMap a
|
||||||
setShownIntMap sm = case sm ^. smRegex of
|
setShownIntMap sm = case sm ^. smRegex of
|
||||||
NoSMRegex -> sm & smShownItems .~ IM.fromAscList (zip [0..] allitms)
|
Nothing -> sm & smShownItems .~ IM.fromAscList (zip [0..] allitms)
|
||||||
SMRegex str _ -> sm & smShownItems
|
Just str -> sm & smShownItems
|
||||||
.~ IM.fromAscList (zip [0..] (f str : filter (regexList str . _siPictures) allitms))
|
.~ IM.fromAscList (zip [0..] (f str : filter (regexList str . _siPictures) allitms))
|
||||||
where
|
where
|
||||||
allitms = sm ^. smItems
|
allitms = sm ^. smItems
|
||||||
f str = SelectionInfo
|
f str = SelectionRegex
|
||||||
{ _siPictures = ["FILTER: " ++ str]
|
{ _siPictures = ["FILTER: " ++ str]
|
||||||
, _siHeight = 1
|
, _siHeight = 1
|
||||||
, _siIsSelectable = False
|
, _siIsSelectable = True
|
||||||
--, _siWidth = length ("FILTER: " ++ str)
|
|
||||||
, _siColor = white
|
, _siColor = white
|
||||||
, _siOffX = 0
|
, _siOffX = 0
|
||||||
}
|
}
|
||||||
@@ -27,7 +26,9 @@ setShownIntMap sm = case sm ^. smRegex of
|
|||||||
initialSelPos :: SelectionIntMap a -> SelectionIntMap a
|
initialSelPos :: SelectionIntMap a -> SelectionIntMap a
|
||||||
initialSelPos sm = sm & smSelPos .~ mi
|
initialSelPos sm = sm & smSelPos .~ mi
|
||||||
where
|
where
|
||||||
mi = fst <$> ifind (const _siIsSelectable) (sm ^. smShownItems)
|
mi = fst <$> ifind t (sm ^. smShownItems)
|
||||||
|
t _ SelectionRegex{} = False
|
||||||
|
t _ si = _siIsSelectable si
|
||||||
|
|
||||||
-- assumes that at least one item is selectable!
|
-- assumes that at least one item is selectable!
|
||||||
-- also assumes that the integer is 1 or -1
|
-- also assumes that the integer is 1 or -1
|
||||||
|
|||||||
Reference in New Issue
Block a user