Commit before reorganising/removing SSSExtra
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (0 modules, at 21:05:25)
|
All good (595 modules, at 21:27:54)
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
--{-# LANGUAGE TupleSections #-}
|
|
||||||
|
|
||||||
--{-# OPTIONS_GHC -fno-full-laziness #-}
|
--{-# OPTIONS_GHC -fno-full-laziness #-}
|
||||||
|
|
||||||
module Dodge.DisplayInventory (
|
module Dodge.DisplayInventory (
|
||||||
toggleCombineInv,
|
toggleCombineInv,
|
||||||
updateInventoryPositioning,
|
updateInventoryPositioning,
|
||||||
updateCombinePositioning,
|
updateCombinePositioning,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Data.DoubleTree
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Inventory.SelectionList
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@@ -18,20 +13,22 @@ import Dodge.Base.You
|
|||||||
import Dodge.Combine
|
import Dodge.Combine
|
||||||
import Dodge.Data.Combine
|
import Dodge.Data.Combine
|
||||||
import Dodge.Data.Config
|
import Dodge.Data.Config
|
||||||
|
import Dodge.Data.DoubleTree
|
||||||
import Dodge.Data.SelectionList
|
import Dodge.Data.SelectionList
|
||||||
import Dodge.Data.Universe
|
import Dodge.Data.Universe
|
||||||
import Dodge.Inventory.CheckSlots
|
import Dodge.Inventory.CheckSlots
|
||||||
|
import Dodge.Inventory.SelectionList
|
||||||
|
import Dodge.Item.Grammar
|
||||||
import Dodge.ListDisplayParams
|
import Dodge.ListDisplayParams
|
||||||
import Dodge.SelectionList
|
import Dodge.SelectionList
|
||||||
import Dodge.Item.Grammar
|
|
||||||
import ListHelp
|
import ListHelp
|
||||||
import Picture.Base
|
import Picture.Base
|
||||||
import Regex
|
|
||||||
|
|
||||||
toggleCombineInv :: Universe -> Universe
|
toggleCombineInv :: Universe -> Universe
|
||||||
toggleCombineInv uv = case uv ^? uvWorld . hud . hudElement . subInventory of
|
toggleCombineInv uv = case uv ^? uvWorld . hud . hudElement . subInventory of
|
||||||
Just CombineInventory{} -> uv & uvWorld . hud . hudElement . subInventory
|
Just CombineInventory{} ->
|
||||||
.~ NoSubInventory MouseInvNothing Nothing
|
uv & uvWorld . hud . hudElement . subInventory
|
||||||
|
.~ NoSubInventory MouseInvNothing Nothing
|
||||||
_ -> uv & uvWorld %~ enterCombineInv (uv ^. uvConfig)
|
_ -> uv & uvWorld %~ enterCombineInv (uv ^. uvConfig)
|
||||||
|
|
||||||
updateCombinePositioning :: Universe -> Universe
|
updateCombinePositioning :: Universe -> Universe
|
||||||
@@ -40,8 +37,8 @@ updateCombinePositioning u =
|
|||||||
%~ updateCombineSections (_uvWorld u) (_uvConfig u)
|
%~ updateCombineSections (_uvWorld u) (_uvConfig u)
|
||||||
|
|
||||||
updateCombineSections :: World -> Configuration -> SelectionSections CombinableItem -> SelectionSections CombinableItem
|
updateCombineSections :: World -> Configuration -> SelectionSections CombinableItem -> SelectionSections CombinableItem
|
||||||
updateCombineSections w cfig sss =
|
updateCombineSections w cfig =
|
||||||
sss & sssSections
|
sssSections
|
||||||
%~ updateSectionsPositioning
|
%~ updateSectionsPositioning
|
||||||
mselpos
|
mselpos
|
||||||
availablelines
|
availablelines
|
||||||
@@ -55,7 +52,8 @@ updateCombineSections w cfig sss =
|
|||||||
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
|
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
|
||||||
return $ IM.filter (flip (andOrRegex $ regexCombs invitms) str) allcombs
|
return $ IM.filter (flip (andOrRegex $ regexCombs invitms) str) allcombs
|
||||||
showncombs
|
showncombs
|
||||||
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
|
| null filtcombs = IM.singleton 0
|
||||||
|
$ SelectionInfo ["No possible combinations"] 1 False white 0
|
||||||
| otherwise = filtcombs
|
| otherwise = filtcombs
|
||||||
filtinv = fromMaybe mempty $ do
|
filtinv = fromMaybe mempty $ do
|
||||||
str <- mstr
|
str <- mstr
|
||||||
@@ -77,7 +75,7 @@ regexCombs inv ci str = case str of
|
|||||||
return $ regexList str' $ _siPictures si'
|
return $ regexList str' $ _siPictures si'
|
||||||
|
|
||||||
andOrRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
andOrRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
||||||
andOrRegex f x str = all (orRegex f x) (wordsBy '&' str)
|
andOrRegex f x = all (orRegex f x) . wordsBy '&'
|
||||||
|
|
||||||
orRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
orRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
||||||
orRegex f x str = case words str of
|
orRegex f x str = case words str of
|
||||||
@@ -89,11 +87,11 @@ updateInventoryPositioning u =
|
|||||||
u & uvWorld . hud . hudElement . diSections
|
u & uvWorld . hud . hudElement . diSections
|
||||||
%~ updateDisplaySections (_uvWorld u) (_uvConfig u)
|
%~ updateDisplaySections (_uvWorld u) (_uvConfig u)
|
||||||
|
|
||||||
updateDisplaySections
|
updateDisplaySections ::
|
||||||
:: World
|
World ->
|
||||||
-> Configuration
|
Configuration ->
|
||||||
-> SelectionSections ()
|
SelectionSections () ->
|
||||||
-> SelectionSections ()
|
SelectionSections ()
|
||||||
updateDisplaySections w cfig sss =
|
updateDisplaySections w cfig sss =
|
||||||
sss & sssSections
|
sss & sssSections
|
||||||
%~ updateSectionsPositioning
|
%~ updateSectionsPositioning
|
||||||
@@ -117,8 +115,10 @@ updateDisplaySections w cfig sss =
|
|||||||
coitems' =
|
coitems' =
|
||||||
IM.fromDistinctAscList . zip [0 ..] $
|
IM.fromDistinctAscList . zip [0 ..] $
|
||||||
map closeObjectToSelectionItem (w ^. hud . closeObjects)
|
map closeObjectToSelectionItem (w ^. hud . closeObjects)
|
||||||
invitems' = IM.mapWithKey (\k (y,x) -> invSelectionItem cr k (x ^. locLDT . ldtValue) y)
|
invitems' =
|
||||||
invlocs
|
IM.mapWithKey
|
||||||
|
(\k (y, x) -> invSelectionItem cr k (x ^. locLDT . ldtValue) y)
|
||||||
|
invlocs
|
||||||
cr = you w
|
cr = you w
|
||||||
invlocs = allInvLocs $ _crInv (you w)
|
invlocs = allInvLocs $ _crInv (you w)
|
||||||
nfreeslots = crNumFreeSlots cr
|
nfreeslots = crNumFreeSlots cr
|
||||||
@@ -203,15 +203,20 @@ updateSection sis mcsel availablelines ss =
|
|||||||
si <- sis ^? ix csel
|
si <- sis ^? ix csel
|
||||||
let xselsize = length $ _siPictures si
|
let xselsize = length $ _siPictures si
|
||||||
return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of
|
return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of
|
||||||
pos | pos == 0 || length allstrings <= availablelines ->
|
pos
|
||||||
|
| pos == 0 || length allstrings <= availablelines ->
|
||||||
0
|
0
|
||||||
pos | pos - 1 < oldoffset ->
|
pos
|
||||||
|
| pos - 1 < oldoffset ->
|
||||||
pos - 1
|
pos - 1
|
||||||
pos | maxcsel == csel ->
|
pos
|
||||||
|
| maxcsel == csel ->
|
||||||
pos - availablelines + xselsize
|
pos - availablelines + xselsize
|
||||||
pos | pos + 1 + xselsize - availablelines > oldoffset ->
|
pos
|
||||||
|
| pos + 1 + xselsize - availablelines > oldoffset ->
|
||||||
pos - availablelines + 1 + xselsize
|
pos - availablelines + 1 + xselsize
|
||||||
_ | length allstrings - oldoffset < availablelines ->
|
_
|
||||||
|
| length allstrings - oldoffset < availablelines ->
|
||||||
length allstrings - availablelines
|
length allstrings - availablelines
|
||||||
_ -> oldoffset
|
_ -> oldoffset
|
||||||
tweakfirst (x : xs)
|
tweakfirst (x : xs)
|
||||||
@@ -232,13 +237,13 @@ updateSection sis mcsel availablelines ss =
|
|||||||
h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str
|
h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str
|
||||||
theindent = replicate (_ssIndent ss) ' '
|
theindent = replicate (_ssIndent ss) ' '
|
||||||
|
|
||||||
listSelectionColorPicture :: Foldable t => t (SelectionItem a) -> [(Color,Picture)]
|
listSelectionColorPicture :: Foldable t => t (SelectionItem a) -> [(Color, Picture)]
|
||||||
listSelectionColorPicture = foldMap f
|
listSelectionColorPicture = foldMap f
|
||||||
where
|
where
|
||||||
f si = map g (_siPictures si)
|
f si = map g (_siPictures si)
|
||||||
where
|
where
|
||||||
indent = 100 * fromIntegral (_siOffX si)
|
indent = 100 * fromIntegral (_siOffX si)
|
||||||
g str = (_siColor si,translate indent 0 . color (_siColor si) $ text str)
|
g str = (_siColor si, translate indent 0 . color (_siColor si) $ text str)
|
||||||
|
|
||||||
enterCombineInv :: Configuration -> World -> World
|
enterCombineInv :: Configuration -> World -> World
|
||||||
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory sss selpos
|
enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory sss selpos
|
||||||
@@ -269,17 +274,22 @@ enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory
|
|||||||
, _ssIndent = 0
|
, _ssIndent = 0
|
||||||
, _ssDescriptor = "COMB FILTER"
|
, _ssDescriptor = "COMB FILTER"
|
||||||
}
|
}
|
||||||
combsection = updateSection cm (Just 0) availablelines SelectionSection
|
combsection =
|
||||||
{ _ssItems = cm
|
updateSection
|
||||||
, _ssCursor = do
|
cm
|
||||||
(_, si) <- IM.lookupMin cm
|
(Just 0)
|
||||||
return $ SectionCursor 0 (_siHeight si) (_siColor si)
|
availablelines
|
||||||
, _ssMinSize = 5
|
SelectionSection
|
||||||
, _ssOffset = 0
|
{ _ssItems = cm
|
||||||
, _ssShownItems = mempty
|
, _ssCursor = do
|
||||||
, _ssIndent = 0
|
(_, si) <- IM.lookupMin cm
|
||||||
, _ssDescriptor = "COMBINATIONS"
|
return $ SectionCursor 0 (_siHeight si) (_siColor si)
|
||||||
}
|
, _ssMinSize = 5
|
||||||
|
, _ssOffset = 0
|
||||||
|
, _ssShownItems = mempty
|
||||||
|
, _ssIndent = 0
|
||||||
|
, _ssDescriptor = "COMBINATIONS"
|
||||||
|
}
|
||||||
|
|
||||||
regexList :: String -> [String] -> Bool
|
regexList :: String -> [String] -> Bool
|
||||||
regexList x = any (isInfixOf x)
|
regexList x = any (isInfixOf x)
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ module Dodge.InputFocus (
|
|||||||
inInputFocus,
|
inInputFocus,
|
||||||
regexScope,
|
regexScope,
|
||||||
regexFocus,
|
regexFocus,
|
||||||
-- , inputFocus'
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import Data.IntMap.Strict (IntMap)
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.SelectionList
|
import Dodge.Data.SelectionList
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
@@ -27,8 +25,7 @@ inTermFocus w = fromMaybe False $ do
|
|||||||
regexScope ::
|
regexScope ::
|
||||||
(Applicative f) =>
|
(Applicative f) =>
|
||||||
World ->
|
World ->
|
||||||
Maybe
|
Maybe ((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
|
||||||
((SSSExtra -> f SSSExtra) -> HUDElement -> f HUDElement, Int)
|
|
||||||
regexScope w = case w ^? hud . hudElement . subInventory of
|
regexScope w = case w ^? hud . hudElement . subInventory of
|
||||||
Just NoSubInventory{} -> case he ^? diSelection . _Just of
|
Just NoSubInventory{} -> case he ^? diSelection . _Just of
|
||||||
Just (-1, _) -> di (-1)
|
Just (-1, _) -> di (-1)
|
||||||
|
|||||||
Reference in New Issue
Block a user