Cleanup
This commit is contained in:
@@ -47,7 +47,8 @@ combineItemListYouX = map (first $ concatMap g) . lookupItems . yourInv
|
||||
|
||||
combineList :: World -> [SelectionItem CombinableItem]
|
||||
combineList w = case combineList' w of
|
||||
[] -> [SelectionInfo ["No possible combinations"] 1 False 0 white 0]
|
||||
-- [] -> [SelectionInfo ["No possible combinations"] 1 False 0 white 0]
|
||||
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0]
|
||||
xs -> xs
|
||||
|
||||
combineList' :: World -> [SelectionItem CombinableItem]
|
||||
@@ -57,7 +58,7 @@ combineList' = map f . combineListInfo
|
||||
{ _siPictures = itemDisplay itm
|
||||
, _siHeight = length (itemDisplay itm)
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = maximum (map length (itemDisplay itm))
|
||||
--, _siWidth = maximum (map length (itemDisplay itm))
|
||||
, _siColor = _itInvColor itm
|
||||
, _siOffX = 0
|
||||
, _siPayload = CombinableItem is itm strs
|
||||
|
||||
@@ -33,15 +33,8 @@ data SelectionList a = SelectionList
|
||||
data SelectionSections a = SelectionSections
|
||||
{ _sssSections :: IntMap (SelectionSection a)
|
||||
, _sssSelPos :: Maybe Int
|
||||
, _sssMaxSize :: Int
|
||||
}
|
||||
|
||||
data SSRestriction = NoSSRestriction
|
||||
| SSRestriction
|
||||
{ _ssrSize :: Int
|
||||
, _ssrOffset :: Int
|
||||
}
|
||||
|
||||
data SectionCursor = SectionCursor
|
||||
{ _scurPos :: Int
|
||||
, _scurSize :: Int
|
||||
@@ -55,9 +48,8 @@ data SelectionSection a = SelectionSection
|
||||
-- , _ssSelSize :: Maybe Int
|
||||
-- , _ssSelColor :: Maybe Color
|
||||
, _ssMinSize :: Int
|
||||
, _ssPriority :: Int
|
||||
--, _ssPriority :: Int
|
||||
, _ssOffset :: Int
|
||||
, _ssRestriction :: SSRestriction
|
||||
, _ssShownItems :: [Picture]
|
||||
, _ssIndent :: Int
|
||||
, _ssDescriptor :: String
|
||||
@@ -84,7 +76,7 @@ data SelectionItem a = SelectionItem
|
||||
{ _siPictures :: [String]
|
||||
, _siHeight :: Int
|
||||
, _siIsSelectable :: Bool
|
||||
, _siWidth :: Int
|
||||
--, _siWidth :: Int
|
||||
, _siColor :: Color
|
||||
, _siOffX :: Int
|
||||
, _siPayload :: a
|
||||
@@ -93,7 +85,7 @@ data SelectionItem a = SelectionItem
|
||||
{ _siPictures :: [String]
|
||||
, _siHeight :: Int
|
||||
, _siIsSelectable :: Bool
|
||||
, _siWidth :: Int
|
||||
--, _siWidth :: Int
|
||||
, _siColor :: Color
|
||||
, _siOffX :: Int
|
||||
}
|
||||
@@ -106,6 +98,5 @@ makeLenses ''SelectionIntMap
|
||||
makeLenses ''SelectionSection
|
||||
makeLenses ''SelectionSections
|
||||
makeLenses ''SectionCursor
|
||||
makeLenses ''SSRestriction
|
||||
--deriveJSON defaultOptions ''SelectionItem
|
||||
--deriveJSON defaultOptions ''SelectionList
|
||||
|
||||
@@ -146,7 +146,6 @@ defaultDisplaySections :: SelectionSections a
|
||||
defaultDisplaySections = SelectionSections
|
||||
{ _sssSections = mempty
|
||||
, _sssSelPos = Just 0
|
||||
, _sssMaxSize = 20
|
||||
}
|
||||
|
||||
defaultHUD :: HUD
|
||||
|
||||
@@ -5,8 +5,6 @@ module Dodge.DisplayInventory
|
||||
) where
|
||||
|
||||
import Data.Maybe
|
||||
--import Picture.Text
|
||||
--import Dodge.Inventory.ItemSpace
|
||||
import Picture.Base
|
||||
import Dodge.Render.HUD
|
||||
import Dodge.SelectionList
|
||||
@@ -22,41 +20,27 @@ import Dodge.Data.SelectionList
|
||||
import Dodge.Data.World
|
||||
|
||||
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
||||
updateDisplayInventory w cfig sss = sss
|
||||
--{ _sssSections = restrictsections
|
||||
{ _sssSections = sections
|
||||
, _sssSelPos = mspos
|
||||
, _sssMaxSize = availablelines
|
||||
}
|
||||
updateDisplayInventory w cfig sss = case cr ^? crInvSel . isel of
|
||||
Just (SelItem i _) -> sss
|
||||
{ _sssSections = updateSections availablelines (0,i) [invx ,youx, closex]
|
||||
, _sssSelPos = Just 0
|
||||
}
|
||||
Just SelNothing -> sss
|
||||
{ _sssSections = updateSections availablelines (1,0) [invx ,youx, closex]
|
||||
, _sssSelPos = Just 1
|
||||
}
|
||||
Just (SelCloseObject i) -> sss
|
||||
{ _sssSections = updateSections availablelines (2,i) [closex, invx ,youx]
|
||||
, _sssSelPos = Just 2
|
||||
}
|
||||
_ -> error "error when getting cr inv sel"
|
||||
where
|
||||
sections = case cr ^? crInvSel . isel of
|
||||
Just (SelItem i _) -> updateSections availablelines (0,i) [invx ,youx, closex]
|
||||
Just SelNothing -> updateSections availablelines (1,0) [invx ,youx, closex]
|
||||
Just (SelCloseObject i) -> updateSections availablelines (2,i) [closex, invx ,youx]
|
||||
_ -> error "wat"
|
||||
invx = (0,(invsec, invitems))
|
||||
youx = (1,(makeYouSection w, youitems))
|
||||
youx = (1,(yousec, youitems))
|
||||
closex = (2,(cosec, coitems))
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True (length thetext) invDimColor 2 ()
|
||||
thetext = case nfreeslots of
|
||||
0 -> " INVENTORY FULL"
|
||||
1 -> " +1 FREE SLOT"
|
||||
x -> " +" ++ show x ++ " FREE SLOTS"
|
||||
mspos = do
|
||||
mo <- cr ^? crInvSel . isel
|
||||
case mo of
|
||||
SelItem {} -> Just 0
|
||||
SelNothing -> Just 1
|
||||
SelCloseObject {} -> Just 2
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
|
||||
thetext = displayFreeSlots nfreeslots
|
||||
availablelines = getAvailableListLines (invDisplayParams w) cfig
|
||||
iavailablelines = availablelines - 6
|
||||
invsection = updateSection invpos invitems iavailablelines invsec
|
||||
invsectionlines = length $ _ssShownItems invsection
|
||||
restrictsections = IM.fromList
|
||||
[ (0, invsection )
|
||||
, (1, makeYouSection w)
|
||||
, (2, updateSection copos coitems (availablelines - invsectionlines - 1) cosec)
|
||||
]
|
||||
cosec = fromMaybe defaultCOSection $ sss ^? sssSections . ix 2
|
||||
invsec = fromMaybe defaultInvSection $ sss ^? sssSections . ix 0
|
||||
coitems = IM.fromDistinctAscList . zip [0..]
|
||||
@@ -65,18 +49,12 @@ updateDisplayInventory w cfig sss = sss
|
||||
cr = you w
|
||||
inv = _crInv (you w)
|
||||
nfreeslots = crNumFreeSlots cr
|
||||
invpos = do
|
||||
mo <- cr ^? crInvSel . isel
|
||||
case mo of
|
||||
SelItem i _ -> Just i
|
||||
SelNothing -> Nothing
|
||||
SelCloseObject {} -> Nothing
|
||||
copos = do
|
||||
mo <- cr ^? crInvSel . isel
|
||||
case mo of
|
||||
SelItem {} -> Nothing
|
||||
SelNothing -> Nothing
|
||||
SelCloseObject i -> Just i
|
||||
|
||||
displayFreeSlots :: Int -> String
|
||||
displayFreeSlots x = case x of
|
||||
0 -> " INVENTORY FULL"
|
||||
1 -> " +1 FREE SLOT"
|
||||
_ -> " +" ++ show x ++ " FREE SLOTS"
|
||||
|
||||
updateSections :: Int -> (Int, Int) -> [(Int,(SelectionSection a,IM.IntMap (SelectionItem a)))]
|
||||
-> IM.IntMap (SelectionSection a)
|
||||
@@ -89,23 +67,20 @@ updateSections allavailablelines (i,j) ((k,(x,y)):xs) = IM.insert k ss
|
||||
availablelines = allavailablelines - sum (map (_ssMinSize . fst . snd) xs)
|
||||
|
||||
defaultCOSection :: SelectionSection ()
|
||||
defaultCOSection = SelectionSection mempty Nothing 5 1 0 NoSSRestriction [] 2 "CLOSE OBJECTS"
|
||||
defaultCOSection = SelectionSection mempty Nothing 5 0 [] 2 "CLOSE OBJECTS"
|
||||
|
||||
defaultInvSection :: SelectionSection ()
|
||||
defaultInvSection = SelectionSection mempty Nothing 5 0 0 NoSSRestriction [] 0 "INVENTORY ITEMS"
|
||||
defaultInvSection = SelectionSection mempty Nothing 5 0 [] 0 "INVENTORY ITEMS"
|
||||
|
||||
updateSection
|
||||
:: Maybe Int
|
||||
-> IM.IntMap (SelectionItem a)
|
||||
-> Int
|
||||
-- -> World
|
||||
-> SelectionSection a
|
||||
-> SelectionSection a
|
||||
updateSection mspos sis availablelines ss = ss
|
||||
{ _ssItems = sis
|
||||
, _ssCursor = scurs
|
||||
, _ssRestriction = NoSSRestriction
|
||||
, _ssPriority = 0
|
||||
, _ssOffset = offset
|
||||
-- , _ssRegex = ""
|
||||
-- , _ssRegexInput = False
|
||||
@@ -160,26 +135,16 @@ updateSection mspos sis availablelines ss = ss
|
||||
si <- sis ^? ix i
|
||||
return . length $ _siPictures si
|
||||
|
||||
makeYouSection :: World -> SelectionSection ()
|
||||
makeYouSection w = SelectionSection
|
||||
{ _ssItems = IM.singleton 0 $ SelectionItem [thetext] 1 True (length thetext) invDimColor 2 ()
|
||||
yousec :: SelectionSection ()
|
||||
yousec = SelectionSection
|
||||
{ _ssItems = mempty
|
||||
, _ssCursor = Just $ SectionCursor 0 1 invDimColor
|
||||
, _ssOffset = 0
|
||||
, _ssPriority = 1
|
||||
, _ssRestriction = NoSSRestriction
|
||||
, _ssIndent = 2
|
||||
-- , _ssRegex = ""
|
||||
-- , _ssRegexInput = False
|
||||
, _ssMinSize = 1
|
||||
-- , _ssOffset = 0
|
||||
, _ssShownItems = [color invDimColor $ text thetext]
|
||||
, _ssShownItems = mempty
|
||||
, _ssDescriptor = "YOUR STATUS"
|
||||
}
|
||||
where
|
||||
cr = you w
|
||||
nfreeslots = crNumFreeSlots cr
|
||||
thetext = case nfreeslots of
|
||||
0 -> " INVENTORY FULL"
|
||||
1 -> " +1 FREE SLOT"
|
||||
x -> " +" ++ show x ++ " FREE SLOTS"
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ invSelectionItem' cr i it = SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = 15
|
||||
--, _siWidth = 15
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
@@ -46,7 +46,7 @@ invSelectionItem cr (i,it) = SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = 15
|
||||
--, _siWidth = 15
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
@@ -63,7 +63,7 @@ closeObjectToSelectionItem n e = SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = 15
|
||||
--, _siWidth = 15
|
||||
, _siColor = col
|
||||
, _siOffX = 2
|
||||
, _siPayload = ()
|
||||
|
||||
@@ -104,7 +104,7 @@ colStrToSelItem (col, str) =
|
||||
{ _siPictures = [str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = length str
|
||||
--, _siWidth = length str
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siPayload = id
|
||||
@@ -121,7 +121,7 @@ menuOptionToSelectionItem w padAmount mo =
|
||||
{ _siPictures = [optionText]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = isselectable
|
||||
, _siWidth = length optionText
|
||||
--, _siWidth = length optionText
|
||||
, _siColor = thecol
|
||||
, _siOffX = 0
|
||||
, _siPayload = f
|
||||
|
||||
@@ -139,7 +139,7 @@ drawExamineInventory cfig mtweaki w =
|
||||
{ _siPictures = [str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = length str
|
||||
--, _siWidth = length str
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
@@ -260,7 +260,8 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
|
||||
, drawSelectionList secondColumnParams cfig (thesellist tm)
|
||||
]
|
||||
where
|
||||
toselitm (str, col) = SelectionItem [str] 1 True (length str) col 0 ()
|
||||
--toselitm (str, col) = SelectionItem [str] 1 True (length str) col 0 ()
|
||||
toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
|
||||
thesellist tm = defaultSelectionList
|
||||
{ _slItems = thelist tm
|
||||
-- , _slLength = length (thelist tm)
|
||||
@@ -465,15 +466,15 @@ mainListCursor :: Color -> Int -> Configuration -> Picture
|
||||
mainListCursor c = openCursorAt 120 c 5 0
|
||||
|
||||
textSelItems :: [String] -> [SelectionItem ()]
|
||||
textSelItems = map (picsToSelectable 15 . (: []))
|
||||
textSelItems = map (picsToSelectable . (: []))
|
||||
|
||||
picsToSelectable :: Int -> [String] -> SelectionItem ()
|
||||
picsToSelectable wdth pics =
|
||||
picsToSelectable :: [String] -> SelectionItem ()
|
||||
picsToSelectable pics =
|
||||
SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
, _siWidth = wdth
|
||||
--, _siWidth = wdth
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
|
||||
@@ -27,7 +27,7 @@ makeRegexList sl = case sl ^. slRegex of
|
||||
{ _siPictures = ["FILTER: "++str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = False
|
||||
, _siWidth = length $ "FILTER: "++str
|
||||
--, _siWidth = length $ "FILTER: "++str
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
}, Nothing) : filter (doregex str) (zip (_slItems sl) $ fmap Just [0..])
|
||||
|
||||
@@ -19,7 +19,7 @@ setShownIntMap sm = case sm ^. smRegex of
|
||||
{ _siPictures = ["FILTER: " ++ str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = False
|
||||
, _siWidth = length ("FILTER: " ++ str)
|
||||
--, _siWidth = length ("FILTER: " ++ str)
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user