Decouple selection section inventory position

This commit is contained in:
2024-10-24 14:55:51 +01:00
parent 81f4f38166
commit 388064895f
17 changed files with 304 additions and 261 deletions
+4 -1
View File
@@ -16,6 +16,7 @@ data HUDElement
= DisplayInventory
{ _subInventory :: SubInventory
, _diSections :: SelectionSections ()
, _diSelection :: Maybe (Int,Int)
}
| DisplayCarte
@@ -33,7 +34,9 @@ data SubInventory
, _nsMouseOver :: Maybe (Int, Int)
}
| ExamineInventory
| CombineInventory {_ciSections :: SelectionSections CombinableItem}
| CombineInventory {_ciSections :: SelectionSections CombinableItem
, _ciSelection :: Maybe (Int,Int)
}
| LockedInventory
| DisplayTerminal {_termID :: Int}
+1 -2
View File
@@ -42,8 +42,7 @@ data SelectionSections a = SelectionSections
-- a pair of ints (i,i+1) such that the lower is the regex section, the higher
-- is the items section.
data SSSExtra = SSSExtra
{ _sssSelPos :: Maybe (Int, Int)
, _sssFilters :: IntMap (Maybe String)
{ _sssFilters :: IntMap (Maybe String)
}
data SectionCursor = SectionCursor
+1 -1
View File
@@ -166,13 +166,13 @@ defaultDisplayInventory =
, _nsMouseOver = Just (0,3)
}
, _diSections = defaultInvSections
, _diSelection = Just (1,0)
}
defaultSSSExtra :: SSSExtra
defaultSSSExtra =
SSSExtra
{ _sssFilters = IM.fromList [(-1, mempty), (2, mempty)]
, _sssSelPos = Nothing
}
defaultInvSections :: SelectionSections ()
+9 -6
View File
@@ -47,7 +47,7 @@ updateCombineSections w cfig sss =
availablelines
[(0, showncombs), (-1, filtinv)]
where
mselpos = sss ^. sssExtra . sssSelPos
mselpos = w ^? hud . hudElement . subInventory . ciSelection . _Just
availablelines = getAvailableListLines secondColumnParams cfig
allcombs = IM.fromDistinctAscList $ zip [0 ..] $ combineList w
filtcombs = fromMaybe allcombs $ do
@@ -89,7 +89,11 @@ updateInventoryPositioning u =
u & uvWorld . hud . hudElement . diSections
%~ updateDisplaySections (_uvWorld u) (_uvConfig u)
updateDisplaySections :: World -> Configuration -> SelectionSections () -> SelectionSections ()
updateDisplaySections
:: World
-> Configuration
-> SelectionSections ()
-> SelectionSections ()
updateDisplaySections w cfig sss =
sss & sssSections
%~ updateSectionsPositioning
@@ -97,7 +101,7 @@ updateDisplaySections w cfig sss =
availablelines
addorder
where
mselpos = sss ^. sssExtra . sssSelPos
mselpos = w ^? hud . hudElement . diSelection . _Just
addorder = case mselpos of
Just (-1, _) -> reverse [filtinv, filtclose, invx, youx, closex]
Just (0, _) -> reverse [filtinv, filtclose, invx, youx, closex]
@@ -237,7 +241,7 @@ listSelectionColorPicture = foldMap f
g str = (_siColor si,translate indent 0 . color (_siColor si) $ text str)
enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory sss
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory sss selpos
where
cm' = IM.fromDistinctAscList . zip [0 ..] $ combineList w
cm
@@ -248,8 +252,7 @@ enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory
{ _sssSections = IM.fromDistinctAscList [(-1, filtsection), (0, combsection)]
, _sssExtra =
SSSExtra
{ _sssSelPos = selpos
, _sssFilters = IM.singleton (-1) Nothing
{ _sssFilters = IM.singleton (-1) Nothing
}
}
selpos
+6 -6
View File
@@ -30,7 +30,7 @@ regexScope ::
Maybe
((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
regexScope w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{} -> case he ^? diSections . sssExtra . sssSelPos . _Just of
Just NoSubInventory{} -> case he ^? diSelection . _Just of
Just (-1, _) -> di (-1)
Just (0, _) -> di (-1)
Just (2, _) -> di 2
@@ -49,7 +49,7 @@ regexFocus ::
Maybe
((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
regexFocus w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{} -> case he ^? diSections . sssExtra . sssSelPos . _Just of
Just NoSubInventory{} -> case he ^? diSelection . _Just of
Just (-1, _) -> di (-1)
Just (2, _) -> di 2
_ -> Nothing
@@ -71,11 +71,11 @@ inputFocus ::
World ->
Maybe ((String -> f String) -> World -> f World)
inputFocus w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{} -> case he ^? diSections . sssExtra . sssSelPos . _Just of
Just NoSubInventory{} -> case he ^? diSelection . _Just of
Just (-1, _) -> di (-1)
Just (2, _) -> di 2
_ -> Nothing
Just CombineInventory{} -> case he ^? subInventory . ciSections . sssExtra . sssSelPos . _Just of
Just CombineInventory{} -> case he ^? subInventory . ciSelection . _Just of
Just (-1, _) -> Just $ hud . hudElement . subInventory . ciSections . sssExtra . sssFilters . ix (-1) . _Just
_ -> Nothing
Just DisplayTerminal{_termID = tmid} -> do
@@ -90,7 +90,7 @@ inputFocus w = case w ^? hud . hudElement . subInventory of
inTopRegex :: Int -> World -> Bool
inTopRegex x w = fromMaybe False $ do
i <- w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _1
i <- w ^? hud . hudElement . diSelection . _Just . _1
return $ i == x
inInvRegex :: World -> Bool
@@ -101,7 +101,7 @@ inCloseRegex = inTopRegex 2
inSubInvRegex :: World -> Bool
inSubInvRegex w = fromMaybe False $ do
i <- w ^? hud . hudElement . subInventory . ciSections . sssExtra . sssSelPos . _Just . _1
i <- w ^? hud . hudElement . subInventory . ciSelection . _Just . _1
return $ i == (-1)
--inputFocus :: World -> Bool
+10 -8
View File
@@ -166,7 +166,7 @@ changeSwapClose f i w = fromMaybe w $ do
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject
.~ k
& hud . closeObjects %~ swapIndices i k
& hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _2 .~ k
& hud . hudElement . diSelection . _Just . _2 .~ k
& worldEventFlags . at InventoryChange ?~ ()
-- can be specialised for when we know that item i is selected
@@ -178,9 +178,9 @@ swapInvItems ::
swapInvItems f i w = fromMaybe w $ do
ss <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
k <- f i ss
let updateselection = case w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just of
Just (0, j) | j == k -> hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _2 .~ i
Just (0, j) | j == i -> hud . hudElement . diSections . sssExtra . sssSelPos . _Just . _2 .~ k
let updateselection = case w ^? hud . hudElement . diSelection . _Just of
Just (0, j) | j == k -> hud . hudElement . diSelection . _Just . _2 .~ i
Just (0, j) | j == i -> hud . hudElement . diSelection . _Just . _2 .~ k
_ -> id
return $
w & cWorld . lWorld . creatures . ix 0 %~ updatecreature k
@@ -209,7 +209,7 @@ swapInvItems f i w = fromMaybe w $ do
Nothing -> id
changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World
changeSwapWith f w = case w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just of
changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of
Just (0, i) -> w & swapInvItems f i
Just (3, i) -> w & changeSwapClose f i
_ -> w
@@ -217,7 +217,7 @@ changeSwapWith f w = case w ^? hud . hudElement . diSections . sssExtra . sssSel
augInvDirectSelect :: (Int, Int) -> World -> World
augInvDirectSelect (i, j) w =
w
& hud . hudElement . diSections . sssExtra . sssSelPos .~ Just (i, j)
& hud . hudElement . diSelection .~ Just (i, j)
& worldEventFlags . at InventoryChange ?~ ()
& setInvPosFromSS
& cWorld . lWorld %~ crUpdateItemLocations 0
@@ -226,12 +226,14 @@ scrollAugInvSel :: Int -> World -> World
scrollAugInvSel yi w
| yi == 0 = w
| otherwise =
w & hud . hudElement . diSections %~ doscroll
w & hud . hudElement %~ doscroll
& worldEventFlags . at InventoryChange ?~ ()
& setInvPosFromSS
& cWorld . lWorld %~ crUpdateItemLocations 0
where
doscroll sss = sss & sssExtra . sssSelPos %~ scrollSelectionSections yi sss
doscroll he = fromMaybe he $ do
sss <- he ^? diSections
return $ he & diSelection %~ scrollSelectionSections yi sss
selectedCloseObject :: World -> Maybe (Either FloorItem Button)
selectedCloseObject w = do
+1 -1
View File
@@ -73,7 +73,7 @@ setInvPosFromSS w =
where
thesel = fromMaybe SelNothing $ do
sss <- w ^? hud . hudElement . diSections
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
(i, j) <- w ^? hud . hudElement . diSelection . _Just
case i of
(-1) -> Just SortInventory
0 -> do
+13 -9
View File
@@ -58,7 +58,7 @@ drawHP cfig =
drawInventory :: SelectionSections () -> World -> Configuration -> Picture
drawInventory sss w cfig =
drawSelectionSections sss ldp cfig
drawSelectionSections sss (w ^? hud . hudElement . diSelection . _Just) ldp cfig
<> iextra
<> translateScreenPos cfig (ldp ^. ldpPos)
(drawDIMouseOver w)
@@ -88,7 +88,7 @@ getMouseInvSel w = case w ^? hud . hudElement . subInventory . nsSelected of
getMouseInvSel' :: World -> Maybe ((Int,Int),(Int,Int))
getMouseInvSel' w = case w ^? hud . hudElement . subInventory . nsSelected of
Just (MouseInvChosen x) -> do
(i,j) <- w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just
(i,j) <- w ^? hud . hudElement . diSelection . _Just
return ((i,j),(i,j+x))
_ -> Nothing
@@ -122,8 +122,10 @@ drawSubInventory subinv cfig w = case subinv of
drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture
drawCombineInventory cfig sss w =
invHead cfig "COMBINE"
<> drawSelectionSections sss secondColumnParams cfig
<> combineInventoryExtra sss cfig w
<> drawSelectionSections sss msel secondColumnParams cfig
<> combineInventoryExtra sss msel cfig w
where
msel = w ^? hud . hudElement . subInventory . ciSelection . _Just
drawExamineInventory :: Configuration -> World -> Picture
drawExamineInventory cfig w =
@@ -181,7 +183,7 @@ drawRBOptions cfig w = fromMaybe mempty $ do
i <- w ^? rbOptions . opSel
let ae = getEquipmentAllocation w
sss <- w ^? hud . hudElement . diSections
(i', j) <- sss ^? sssExtra . sssSelPos . _Just
(i', j) <- w ^? hud . hudElement . diSelection . _Just
curpos <- selSecYint i' j sss
let ytext = drawListElement 0 1 0 curpos . text
midstr = equipAllocString ae
@@ -244,9 +246,11 @@ inventoryExtraH sss cfig w i is = fromMaybe mempty $ do
where
snum = selNumPos cfig (invDisplayParams w) sss 0
combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture
combineInventoryExtra sss cfig w = fromMaybe mempty $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
combineInventoryExtra :: SelectionSections CombinableItem
-> Maybe (Int,Int)
-> Configuration -> World -> Picture
combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
(i, j) <- msel
cpos <- selSecYint i j sss
si <- sss ^? sssSections . ix i . ssItems . ix j
let col = _siColor si
@@ -269,7 +273,7 @@ combineInventoryExtra sss cfig w = fromMaybe mempty $ do
let idp = invDisplayParams w & ldpCursorSides .~ [North, South, East, West]
return $
translateScreenPos cfig (idp ^. ldpPos) $
selSecDrawCursor 17 idp (sss' & sssExtra . sssSelPos ?~ (0, i))
selSecDrawCursor 17 idp sss' (Just (0, i))
displayTerminal :: Int -> Configuration -> LWorld -> Picture
displayTerminal tid cfig w = fromMaybe mempty $ do
+4 -3
View File
@@ -101,10 +101,11 @@ selSecDrawCursorAt (i,j) xsize ldp sss = fromMaybe mempty $ do
xsize
(_siHeight si)
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture
selSecDrawCursor xsize ldp sss = maybe mempty
selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a ->
Maybe (Int,Int) -> Picture
selSecDrawCursor xsize ldp sss msel = maybe mempty
(\x -> selSecDrawCursorAt x xsize ldp sss)
(sss ^? sssExtra . sssSelPos . _Just)
msel
-- displays a cursor that should match up to list text pictures
listCursorChooseBorderScale ::
+9 -12
View File
@@ -3,7 +3,7 @@ module Dodge.SelectionSections (
ssLookupDown,
ssLookupGT,
ssSetCursor,
setFirstPosSelectionSections,
-- setFirstPosSelectionSections,
selSecYint,
selSecSelSize,
inverseSelSecYint,
@@ -31,10 +31,10 @@ scrollSelectionSections yi sss msel
| yi > 0 = foldr ($) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
| otherwise = foldr ($) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a
setFirstPosSelectionSections sss = fromMaybe sss $ do
(i, j, _) <- ssLookupMin sss
return $ sss & sssExtra . sssSelPos ?~ (i, j)
--setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a
--setFirstPosSelectionSections sss = fromMaybe sss $ do
-- (i, j, _) <- ssLookupMin sss
-- return $ sss & sssExtra . sssSelPos ?~ (i, j)
ssScrollUsing ::
(Int -> Int -> SelectionSections a -> Maybe (Int, Int, SelectionItem a)) ->
@@ -66,14 +66,11 @@ ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> (i, j)) $ l <|> ssLookupMin s
ssSetCursor ::
(SelectionSections a -> Maybe (Int, Int, SelectionItem a)) ->
SelectionSections a ->
SelectionSections a
ssSetCursor f sss = fromMaybe sss $ do
Maybe (Int,Int) ->
Maybe (Int,Int)
ssSetCursor f sss msel = fromMaybe msel $ do
(i, j, _) <- f sss
return $
sss
& sssExtra . sssSelPos ?~ (i, j)
-- & sssSections . ix i . ssCursor ?~ SectionCursor j j (_siHeight si) (_siColor si)
return $ Just (i, j)
ssLookupMax :: SelectionSections a -> Maybe (Int, Int, SelectionItem a)
ssLookupMax sss = do
+3 -3
View File
@@ -7,14 +7,14 @@ import Dodge.Render.List
import Dodge.ScreenPos
import Picture.Base
drawSelectionSections :: SelectionSections a -> ListDisplayParams -> Configuration -> Picture
drawSelectionSections sss ldp cfig =
drawSelectionSections :: SelectionSections a -> Maybe (Int,Int) -> ListDisplayParams -> Configuration -> Picture
drawSelectionSections sss msel ldp cfig =
translateScreenPos cfig (ldp ^. ldpPos) $
drawListYgapScaleYoff
(_ldpVerticalGap ldp)
(_ldpScale ldp)
0
pics
<> selSecDrawCursor 15 ldp sss
<> selSecDrawCursor 15 ldp sss msel
where
pics = foldMap _ssShownItems (_sssSections sss)
+1 -2
View File
@@ -37,8 +37,7 @@ testStringInit u = [show $ u ^? uvWorld . hud . hudElement . subInventory . nsMo
-- showh _ = ""
topTestPart :: Universe -> [String]
topTestPart u = [show $ u ^? uvWorld . hud . hudElement . diSections . sssExtra . sssSelPos
, maybe "" showManObj $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . manObject
topTestPart u = [maybe "" showManObj $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . manObject
]
showManObj :: ManipulatedObject -> String
+1 -1
View File
@@ -344,7 +344,7 @@ updateMouseInventorySelection' sss cfig w
startDrag :: (Int,Int) -> World -> World
startDrag (a,b) w = fromMaybe (augInvDirectSelect (a,b) $ setmichosen 0 w) $ do
(i,j) <- w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just
(i,j) <- w ^? hud . hudElement . diSelection . _Just
x <- w ^? hud . hudElement . subInventory . nsSelected . misExtra
guard $ i == a && b >= j && b <= j + x
return w
+52 -30
View File
@@ -38,24 +38,26 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
| inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
| lbinitialpress ->
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
CombineInventory{_ciSections = sss}
CombineInventory{_ciSections = sss, _ciSelection = msel}
| inSubInvRegex (u ^. uvWorld) ->
u
& uvWorld . hud . hudElement . subInventory . ciSections
%~ doRegexInput (u ^. uvWorld . input) (-1)
& uvWorld . hud . hudElement . subInventory
%~ docombineregexinput
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
| lbinitialpress ->
(uvWorld . worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
over uvWorld (tryCombine sss) u
over uvWorld (tryCombine sss msel) u
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
_
| inInvRegex (u ^. uvWorld) ->
u & uvWorld . hud . hudElement . diSections %~ doRegexInput (u ^. uvWorld . input) (-1)
u & uvWorld . hud . hudElement %~ dodisplayregexinput (-1)
-- . diSections %~ doRegexInput (u ^. uvWorld . input) (-1)
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
& uvWorld %~ setInvPosFromSS
_
| inCloseRegex (u ^. uvWorld) ->
u & uvWorld . hud . hudElement . diSections %~ doRegexInput (u ^. uvWorld . input) 2
--u & uvWorld . hud . hudElement . diSections %~ doRegexInput (u ^. uvWorld . input) 2
u & uvWorld . hud . hudElement %~ dodisplayregexinput 2
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
& uvWorld %~ setInvPosFromSS
_ -> M.foldlWithKey' updateKeyInGame u pkeys
@@ -63,6 +65,18 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
w = u ^. uvWorld
pkeys = u ^. uvWorld . input . pressedKeys
lbinitialpress = u ^? uvWorld . input . mouseButtons . ix ButtonLeft == Just 0
docombineregexinput ci = fromMaybe ci $ do
sss <- ci ^? ciSections
msel <- ci ^? ciSelection
let (sss',msel') = doRegexInput (u ^. uvWorld . input) (-1) sss msel
return $ ci & ciSections .~ sss'
& ciSelection .~ msel'
dodisplayregexinput x di = fromMaybe di $ do
sss <- di ^? diSections
msel <- di ^? diSelection
let (sss',msel') = doRegexInput (u ^. uvWorld . input) x sss msel
return $ di & diSections .~ sss'
& diSelection .~ msel'
updatePressedButtonsCarte :: World -> World
updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w
@@ -132,17 +146,18 @@ updateLongPressInGame uv sc = case sc of
ScancodeSpace -> over uvWorld spaceAction uv
_ -> uv
doRegexInput :: Input -> Int -> SelectionSections a -> SelectionSections a
doRegexInput inp i sss
doRegexInput :: Input -> Int -> SelectionSections a -> Maybe (Int,Int)
-> (SelectionSections a, Maybe (Int,Int))
doRegexInput inp i sss msel
| backspacetonothing || escapekey = endregex i 0
| endkeys || endmouse = endregex (i + 1) (j -1)
| otherwise = sss & doTextInputOver inp (sssExtra . sssFilters . ix i . _Just)
| otherwise = (sss & doTextInputOver inp (sssExtra . sssFilters . ix i . _Just)
, msel)
where
endregex a b =
sss
& sssExtra . sssFilters . ix i .~ Nothing
(sss & sssExtra . sssFilters . ix i .~ Nothing
& sssSections . ix i . ssItems .~ mempty
& ssSetCursor (ssLookupDown a b)
, msel & ssSetCursor (ssLookupDown a b) sss)
j = fromMaybe 0 $ do
itms <- sss ^? sssSections . ix (i + 1) . ssItems
fst <$> IM.lookupMin itms
@@ -161,53 +176,59 @@ updateBackspaceRegex :: World -> World
updateBackspaceRegex w = case di ^? subInventory of
Just NoSubInventory{}
| secfocus (-1) 0 ->
w & hud . hudElement . diSections %~ trybackspace (-1)
w & hud . hudElement %~ trybackspace (-1)
& worldEventFlags . at InventoryChange ?~ ()
Just NoSubInventory{}
| secfocus 2 3 ->
w & hud . hudElement . diSections %~ trybackspace 2
w & hud . hudElement %~ trybackspace 2
& worldEventFlags . at InventoryChange ?~ ()
Just CombineInventory{} ->
w & hud . hudElement . subInventory . ciSections %~ trybackspace (-1)
w & hud . hudElement . subInventory %~ trybackspace' (-1)
& worldEventFlags . at InventoryChange ?~ ()
_ -> w
where
secfocus a b = fromMaybe False $ do
i <- di ^? diSections . sssExtra . sssSelPos . _Just . _1
i <- di ^? diSelection . _Just . _1
return $ i == a || i == b
trybackspace x sss = fromMaybe sss $ do
-- i <- fss ^? fssSections . sssSelPos . _Just . _1
-- guard (i == x || i == x+1)
trybackspace x he = fromMaybe he $ do
sss <- he ^? diSections
str <- sss ^? sssExtra . sssFilters . ix x . _Just
return $ case str of
(_ : _) ->
sss & sssExtra . sssFilters . ix x . _Just %~ init
& sssExtra . sssSelPos ?~ (x, 0)
[] -> sss & sssExtra . sssFilters . ix x .~ Nothing
he & diSections . sssExtra . sssFilters . ix x . _Just %~ init
& diSelection ?~ (x, 0)
[] -> he & diSections . sssExtra . sssFilters . ix x .~ Nothing
trybackspace' x ci = fromMaybe ci $ do
sss <- ci ^? ciSections
str <- sss ^? sssExtra . sssFilters . ix x . _Just
return $ case str of
(_ : _) ->
ci & ciSections . sssExtra . sssFilters . ix x . _Just %~ init
& ciSelection ?~ (x, 0)
[] -> ci & ciSections . sssExtra . sssFilters . ix x .~ Nothing
di = w ^. hud . hudElement
updateEnterRegex :: World -> World
updateEnterRegex w = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{}
| secfocus (-1) 0 ->
w & hud . hudElement . diSections . sssExtra . sssSelPos ?~ (-1, 0)
w & hud . hudElement . diSelection ?~ (-1, 0)
& hud . hudElement . diSections %~ enterregex (-1)
Just NoSubInventory{}
| secfocus 2 3 ->
w & hud . hudElement . diSections . sssExtra . sssSelPos ?~ (2, 0)
w & hud . hudElement . diSelection ?~ (2, 0)
& hud . hudElement . diSections %~ enterregex 2
Just CombineInventory{} ->
w & hud . hudElement . subInventory . ciSections %~ enterregex (-1)
& hud . hudElement . subInventory . ciSections . sssExtra . sssSelPos ?~ (-1, 0)
& hud . hudElement . subInventory . ciSelection ?~ (-1, 0)
_ -> w
where
di = w ^. hud . hudElement
secfocus a b = fromMaybe False $ do
i <- di ^? diSections . sssExtra . sssSelPos . _Just . _1
i <- di ^? diSelection . _Just . _1
return $ i == a || i == b
enterregex x sss =
sss & sssExtra . sssFilters . ix x %~ f
& sssExtra . sssSelPos ?~ (x, 0)
f Nothing = Just ""
f x = x
@@ -242,6 +263,7 @@ toggleMap u = case u ^. uvWorld . hud . hudElement of
.~ DisplayInventory
{ _subInventory = NoSubInventory NoMouseSel Nothing
, _diSections = defaultInvSections
, _diSelection = Nothing
}
_ -> u & uvWorld . hud . hudElement .~ DisplayCarte
@@ -254,9 +276,9 @@ toggleTweakInv w = case w ^? hud . hudElement . subInventory of
-- mi = 0 <$ (yourSelectedItem w >>= (^? itTweaks . tweakParams . ix 0))
tryCombine :: SelectionSections CombinableItem -> World -> World
tryCombine sss w = fromMaybe w $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
tryCombine :: SelectionSections CombinableItem -> Maybe (Int,Int) -> World -> World
tryCombine sss msel w = fromMaybe w $ do
(i, j) <- msel
CombinableItem is it _ <- sss ^? sssSections . ix i . ssItems . ix j . siPayload
return $
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
+4 -3
View File
@@ -58,12 +58,13 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
moveCombineSel :: Int -> World -> World
moveCombineSel yi =
( hud . hudElement . subInventory . ciSections
%~ doscroll
( hud . hudElement . subInventory %~ doscroll
)
. (worldEventFlags . at CombineInventoryChange ?~ ())
where
doscroll sss = sss & sssExtra . sssSelPos %~ scrollSelectionSections yi sss
doscroll ci = fromMaybe ci $ do
sss <- ci ^? ciSections
return $ ci & ciSelection %~ scrollSelectionSections yi sss
--moveSubSel :: Int -> Int -> World -> World
--moveSubSel yi maxyi =