Cleanup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
-- {-# OPTIONS_GHC -fno-full-laziness #-}
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
--{-# LANGUAGE BangPatterns #-}
|
||||
|
||||
module Dodge.DisplayInventory (
|
||||
@@ -9,9 +10,6 @@ module Dodge.DisplayInventory (
|
||||
toggleCombineInv,
|
||||
) where
|
||||
|
||||
import Dodge.Data.HUD
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import NewInt
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -24,9 +22,11 @@ import Dodge.CharacterEnums
|
||||
import Dodge.Combine
|
||||
import Dodge.Data.Combine
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.HUD
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Inventory
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Inventory.SelectionList
|
||||
import Dodge.Item.Display
|
||||
import Dodge.Item.Grammar
|
||||
@@ -34,6 +34,7 @@ import Dodge.ListDisplayParams
|
||||
import Dodge.SelectionList
|
||||
import Dodge.SelectionSections
|
||||
import qualified ListHelp as List
|
||||
import NewInt
|
||||
import Picture.Base
|
||||
|
||||
updateCombinePositioning :: Universe -> Universe
|
||||
@@ -43,17 +44,14 @@ updateCombinePositioning u =
|
||||
%~ updateCombineSections (_uvWorld u) (_uvConfig u)
|
||||
& uvWorld . hud . subInventory %~ checkCombineSelectionExists
|
||||
|
||||
updateCombineSections ::
|
||||
World ->
|
||||
Config ->
|
||||
IM.IntMap (SelectionSection CombinableItem) ->
|
||||
IM.IntMap (SelectionSection CombinableItem)
|
||||
updateCombineSections
|
||||
:: World -> Config -> IM.IntMap (SelSection CombItem) -> IM.IntMap (SelSection CombItem)
|
||||
updateCombineSections w cfig =
|
||||
updateSectionsPositioning
|
||||
(const 0)
|
||||
(w ^? hud . subInventory . ciSelection . _Just)
|
||||
(getAvailableListLines secondColumnLDP cfig)
|
||||
(IM.fromDistinctAscList [(-1, sfclose),(0, sclose')])
|
||||
(IM.fromDistinctAscList [(-1, sfclose), (0, sclose')])
|
||||
where
|
||||
filtcurs = w ^? hud . subInventory . ciSelection . _Just . slSec == Just (-1)
|
||||
(sfclose, sclose) =
|
||||
@@ -67,10 +65,10 @@ updateCombineSections w cfig =
|
||||
sclose'
|
||||
| null sclose =
|
||||
IM.singleton 0 $
|
||||
SelItem ["NONE"] 1 25 False white 0 Nothing
|
||||
SelItem ["NONE"] 1 25 False white 2 Nothing
|
||||
| otherwise = sclose
|
||||
|
||||
regexCombs :: IM.IntMap Item -> SelectionItem CombinableItem -> String -> Bool
|
||||
regexCombs :: IM.IntMap Item -> SelectionItem CombItem -> String -> Bool
|
||||
regexCombs inv ci = \case
|
||||
'#' : str -> any (g str) (_ciInvIDs $ fromJust $ _siPayload ci)
|
||||
str -> (regexList str . _siPictures) ci
|
||||
@@ -121,19 +119,17 @@ updateDisplaySections w cfig =
|
||||
displayIndents
|
||||
mselpos
|
||||
(getAvailableListLines invDP cfig)
|
||||
( IM.fromDistinctAscList $
|
||||
zip
|
||||
[-1 .. 5]
|
||||
[ invhead
|
||||
$ IM.fromDistinctAscList $
|
||||
zip [-1 .. 5]
|
||||
[ sfinv
|
||||
, sinv
|
||||
, IM.singleton 0
|
||||
$ SelItem [displayFreeSlots (crNumFreeSlots (w ^. cWorld . lWorld . items) cr)] 1 15 True invDimColor 2 Nothing
|
||||
, nearbyhead
|
||||
, IM.singleton 0 $
|
||||
SelItem [displayFreeSlots (crNumFreeSlots (w ^. cWorld . lWorld . items) cr)] 1 15 True invDimColor 2 Nothing
|
||||
, sfclose
|
||||
, sclose
|
||||
, interfaceshead
|
||||
, btitems
|
||||
]
|
||||
)
|
||||
where
|
||||
mselpos = w ^? hud . diSelection . _Just
|
||||
invfiltcurs = mselpos ^? _Just . slSec == Just (-1)
|
||||
@@ -144,15 +140,11 @@ updateDisplaySections w cfig =
|
||||
(sfclose, sclose) =
|
||||
filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $
|
||||
w ^? hud . diCloseFilter . _Just
|
||||
nearbyhead
|
||||
| null sfclose && not (null sclose) = makehead "NEARBY ITEMS"
|
||||
| otherwise = sfclose
|
||||
interfaceshead = if null btitems then mempty else makehead "NEARBY INTERFACES"
|
||||
btitems =
|
||||
IM.fromDistinctAscList . zip [0 ..] $
|
||||
mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons)
|
||||
makehead str = IM.singleton 0 $ SelItem [str] 1 15 False white 0 Nothing
|
||||
invhead = if null sfinv then makehead "INVENTORY" else sfinv
|
||||
cr = you w
|
||||
closeitms =
|
||||
IM.fromDistinctAscList . zip [0 ..] $
|
||||
@@ -172,9 +164,11 @@ filterSectionsPair ::
|
||||
filterSectionsPair infocus filtfn itms s mfilt = (x, itms')
|
||||
where
|
||||
filtcurs = if infocus then cFilledRect else cWireRect
|
||||
x = IM.singleton 0 $ fromMaybe (SelItem [s] 1 (length s) False white 0 Nothing) $ do
|
||||
str <- mfilt
|
||||
return $ SelItem
|
||||
x = IM.singleton 0 $
|
||||
fromMaybe (SelItem [s] 1 (length s) False white 0 Nothing) $ do
|
||||
str <- mfilt
|
||||
return $
|
||||
SelItem
|
||||
[s ++ " FILTER/" ++ str ++ [filtcurs], numfiltitems]
|
||||
2
|
||||
(length (s ++ " FILTER/" ++ str ++ [filtcurs]))
|
||||
@@ -182,20 +176,11 @@ filterSectionsPair infocus filtfn itms s mfilt = (x, itms')
|
||||
white
|
||||
0
|
||||
Nothing
|
||||
-- filtsis = fold $ do
|
||||
-- str <- mfilt
|
||||
-- return $
|
||||
-- IM.singleton
|
||||
-- 0
|
||||
-- $ SelItem
|
||||
-- [filtdescription ++ " FILTER/" ++ str ++ [filtcurs], numfiltitems]
|
||||
-- 2
|
||||
-- (length (filtdescription ++ " FILTER/" ++ str ++ [filtcurs]))
|
||||
-- True
|
||||
-- white
|
||||
-- 0
|
||||
-- Nothing
|
||||
itms' = maybe id (IM.filter . filtfn) mfilt itms
|
||||
f y
|
||||
| null y =
|
||||
IM.singleton 0 $ SelItem ["(NONE)"] 1 (length s) True (greyN 0.5) 0 Nothing
|
||||
| otherwise = y
|
||||
itms' = f $ maybe id (IM.filter . filtfn) mfilt itms
|
||||
numfiltitems = show (length itms - length itms') ++ " FILTERED"
|
||||
|
||||
invDimColor :: Color
|
||||
@@ -254,8 +239,8 @@ updateSectionsPositioning ::
|
||||
Maybe Selection ->
|
||||
Int ->
|
||||
IM.IntMap (IM.IntMap (SelectionItem a)) ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelectionSection a)
|
||||
IM.IntMap (SelSection a) ->
|
||||
IM.IntMap (SelSection a)
|
||||
updateSectionsPositioning h mselpos allavailablelines lsss sss =
|
||||
IM.intersectionWithKey (\k -> updateSection (h k) (m k)) ls ssizes `g` offsets
|
||||
where
|
||||
@@ -276,9 +261,9 @@ updateSection ::
|
||||
IM.IntMap (SelectionItem a) ->
|
||||
Int ->
|
||||
Int ->
|
||||
SelectionSection a
|
||||
SelSection a
|
||||
updateSection indent mcsel sis availablelines oldoffset =
|
||||
SelectionSection
|
||||
SelSection
|
||||
{ _ssItems = sis
|
||||
, _ssOffset = offset
|
||||
, _ssShownItems = shownitems
|
||||
@@ -337,4 +322,5 @@ enterCombineInv cfig w =
|
||||
, _ciSelection = Just (Sel 0 0 mempty)
|
||||
, _ciFilter = Nothing
|
||||
}
|
||||
& hud . diInvFilter .~ Nothing
|
||||
& hud . diInvFilter
|
||||
.~ Nothing
|
||||
|
||||
Reference in New Issue
Block a user