Refactor close objects hud display
This commit is contained in:
@@ -50,11 +50,10 @@ data HUD = HUD
|
||||
, _carteCenter :: Point2
|
||||
, _carteZoom :: Float
|
||||
, _carteRot :: Float
|
||||
, _closeObjects :: [Either FloorItem Button]
|
||||
, _closeItems :: [FloorItem]
|
||||
, _closeInterfaces :: [Button]
|
||||
}
|
||||
|
||||
makeLenses ''HUD
|
||||
makeLenses ''HUDElement
|
||||
makeLenses ''SubInventory
|
||||
|
||||
--makeLenses ''MouseInventorySelection
|
||||
|
||||
@@ -156,7 +156,8 @@ defaultHUD =
|
||||
, _carteCenter = V2 0 0
|
||||
, _carteZoom = 0.5
|
||||
, _carteRot = 0
|
||||
, _closeObjects = []
|
||||
, _closeItems = mempty
|
||||
, _closeInterfaces = mempty
|
||||
}
|
||||
|
||||
defaultDisplayInventory :: HUDElement
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- {-# OPTIONS_GHC -fno-full-laziness #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.DisplayInventory (
|
||||
toggleCombineInv,
|
||||
@@ -52,10 +52,10 @@ updateCombineSections ::
|
||||
updateCombineSections w cfig =
|
||||
updateSectionsPositioning
|
||||
(const 5)
|
||||
(const 0)
|
||||
(w ^? hud . hudElement . subInventory . ciSelection . _Just)
|
||||
(getAvailableListLines secondColumnParams cfig)
|
||||
[(0, sclose), (-1, sfclose)]
|
||||
(IM.fromAscList [(-1,0),(0,0)])
|
||||
where
|
||||
filtcurs = w ^? hud . hudElement . subInventory . ciSelection . _Just . _1 == Just (-1)
|
||||
(sfclose, sclose) =
|
||||
@@ -117,6 +117,13 @@ displaySectionsSizes 0 = 10
|
||||
displaySectionsSizes 3 = 10
|
||||
displaySectionsSizes _ = 3
|
||||
|
||||
displayIndents :: Int -> Int
|
||||
displayIndents (-3) = 2
|
||||
displayIndents 0 = 2
|
||||
displayIndents 3 = 2
|
||||
displayIndents 5 = 2
|
||||
displayIndents _ = 0
|
||||
|
||||
updateDisplaySections ::
|
||||
World ->
|
||||
Configuration ->
|
||||
@@ -125,10 +132,10 @@ updateDisplaySections ::
|
||||
updateDisplaySections w cfig =
|
||||
updateSectionsPositioning
|
||||
displaySectionsSizes
|
||||
displayIndents
|
||||
mselpos
|
||||
(getAvailableListLines (invDisplayParams w) cfig)
|
||||
[statushead,statusdisplay,invhead,invx,youx, nearbyhead, closex]
|
||||
(IM.fromAscList [(-4,0),(-3,2),(-2,0),(-1,0),(0,2),(1,0),(2,0),(3,2)])
|
||||
where
|
||||
mselpos = w ^? hud . hudElement . diSelection . _Just
|
||||
invfiltcurs = mselpos ^? _Just . _1 == Just (-1)
|
||||
@@ -147,21 +154,19 @@ updateDisplaySections w cfig =
|
||||
youx = (1, youitems)
|
||||
makehead str i = (i,IM.singleton 0 $ SelectionInfo [str] 1 False white 0)
|
||||
statushead = (-4,IM.singleton 0 $ SelectionInfo ["STATUS"] 1 False white 0)
|
||||
statusdisplay = (-3,IM.singleton 0 $ SelectionInfo ["HEALTH "++show (_crHP cr)] 1 False white 0)
|
||||
statusdisplay = (-3,IM.singleton 0 $ SelectionInfo ["HEALTH: "++show (_crHP cr)] 1 False white 0)
|
||||
invhead = if null sfinv then makehead "INVENTORY" (-2) else filtinv
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
|
||||
thetext = displayFreeSlots (crNumFreeSlots cr)
|
||||
closeitms =
|
||||
IM.fromDistinctAscList . zip [0 ..] $
|
||||
map closeObjectToSelectionItem (w ^. hud . closeObjects)
|
||||
map closeItemToSelectionItem (w ^. hud . closeItems)
|
||||
invitems =
|
||||
IM.mapWithKey
|
||||
(\k (indent, x) -> invSelectionItem indent cr k (x ^. locLDT . ldtValue))
|
||||
(fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr)
|
||||
-- this clearly deserves refactoring, also check if drawInventory/iextra
|
||||
-- needs it at the same time
|
||||
removeindentiffiltering =
|
||||
if maybe False isFilteringInv (w ^? hud . hudElement . diSections)
|
||||
if maybe False (not . null) (w ^? hud . hudElement . diInvFilter . _Just)
|
||||
then const 0
|
||||
else id
|
||||
cr = you w
|
||||
@@ -218,7 +223,7 @@ sectionsSizes ::
|
||||
IM.IntMap Int
|
||||
sectionsSizes x f is sss = doSectionSize extraavailable mintaken is sss mempty
|
||||
where
|
||||
mintaken = IM.mapWithKey (\k y -> min (f k) y) sss
|
||||
mintaken = IM.mapWithKey (min . f) sss
|
||||
extraavailable = x - sum mintaken
|
||||
|
||||
doSectionSize ::
|
||||
@@ -249,26 +254,25 @@ doSectionSize extraavailable mintaken is sss done = fromMaybe done $ do
|
||||
|
||||
updateSectionsPositioning ::
|
||||
(Int -> Int) -> -- for determining each sections minimum size
|
||||
(Int -> Int) -> -- for determining each sections indent
|
||||
Maybe (Int, Int) ->
|
||||
Int ->
|
||||
[(Int, IM.IntMap (SelectionItem a))] ->
|
||||
IM.IntMap Int ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelectionSection a)
|
||||
updateSectionsPositioning f mselpos allavailablelines lsss indents sss =
|
||||
IM.intersectionWith updateSection ls mss `h` ssizes `g` offsets `h` indents
|
||||
updateSectionsPositioning f h mselpos allavailablelines lsss sss =
|
||||
IM.intersectionWithKey (\k -> updateSection (h k) (m k)) ls ssizes `g` offsets
|
||||
where
|
||||
offsets = fmap _ssOffset sss
|
||||
mss = IM.mapWithKey m ssizes
|
||||
m k _ = do
|
||||
m k = do
|
||||
(k', i) <- mselpos
|
||||
guard $ k == k'
|
||||
return i
|
||||
ls = IM.fromList lsss
|
||||
h = IM.intersectionWith ($)
|
||||
-- h = IM.intersectionWith ($)
|
||||
-- defaults non-existing offsets to 0
|
||||
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
|
||||
lk = fromMaybe [] $ fmap ((: []) . fst) mselpos
|
||||
lk = maybe [] ((: []) . fst) mselpos
|
||||
ssizes =
|
||||
sectionsSizes
|
||||
allavailablelines
|
||||
@@ -277,13 +281,13 @@ updateSectionsPositioning f mselpos allavailablelines lsss indents sss =
|
||||
$ sectionsDesiredLines ls
|
||||
|
||||
updateSection ::
|
||||
IM.IntMap (SelectionItem a) ->
|
||||
Maybe Int ->
|
||||
Int ->
|
||||
Maybe Int ->
|
||||
IM.IntMap (SelectionItem a) ->
|
||||
Int ->
|
||||
Int ->
|
||||
SelectionSection a
|
||||
updateSection sis mcsel availablelines oldoffset indent =
|
||||
updateSection indent mcsel sis availablelines oldoffset =
|
||||
SelectionSection
|
||||
{ _ssItems = sis
|
||||
, _ssOffset = offset
|
||||
@@ -363,10 +367,10 @@ enterCombineInv cfig w =
|
||||
}
|
||||
combsection =
|
||||
updateSection
|
||||
cm
|
||||
(Just 0)
|
||||
availablelines
|
||||
0
|
||||
(Just 0)
|
||||
cm
|
||||
availablelines
|
||||
0
|
||||
|
||||
regexList :: String -> [String] -> Bool
|
||||
|
||||
+62
-65
@@ -9,39 +9,38 @@ module Dodge.Inventory (
|
||||
scrollAugInvSel,
|
||||
crNumFreeSlots,
|
||||
crInvSize,
|
||||
selectedCloseObject,
|
||||
selectedCloseItem,
|
||||
setInvPosFromSS,
|
||||
module Dodge.Inventory.RBList,
|
||||
swapInvItems,
|
||||
scrollAugNextInSection,
|
||||
isFilteringInv,
|
||||
-- isFilteringInv,
|
||||
swapItemWith,
|
||||
) where
|
||||
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Monad
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Data.DoubleTree
|
||||
import Sound.Data
|
||||
import Dodge.SoundLogic
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Function
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.World
|
||||
--import Dodge.DisplayInventory
|
||||
import Dodge.Euse
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Inventory.CloseObject
|
||||
import Dodge.Inventory.Location
|
||||
import Dodge.Inventory.RBList
|
||||
import Dodge.ItEffect
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.SelectionSections
|
||||
import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import ListHelp
|
||||
import NewInt
|
||||
import Sound.Data
|
||||
|
||||
--import Padding
|
||||
|
||||
@@ -90,12 +89,13 @@ rmInvItem cid invid w =
|
||||
-- & updateCreatureItemLocations cid
|
||||
|
||||
pointcid = cWorld . lWorld . creatures . ix cid
|
||||
updateselectionextra | cid == 0 = hud . hudElement . diSelectionExtra .~ mempty
|
||||
updateselectionextra
|
||||
| cid == 0 = hud . hudElement . diSelectionExtra .~ mempty
|
||||
| otherwise = id
|
||||
updateselection
|
||||
| cid == 0 && cr ^? crManipulation . manObject . imSelectedItem == Just invid =
|
||||
scrollAugInvSel (-1) . scrollAugInvSel 1 -- . updateInventorySectionItems
|
||||
-- id -- . updateInventorySectionItems
|
||||
-- id -- . updateInventorySectionItems
|
||||
| otherwise =
|
||||
pointcid . crManipulation . manObject . imSelectedItem %~ g
|
||||
|
||||
@@ -126,36 +126,34 @@ rmInvItem cid invid w =
|
||||
updateCloseObjects :: World -> World
|
||||
updateCloseObjects w =
|
||||
w
|
||||
& hud . closeObjects .~ newcloseobjects
|
||||
& updatecursorposifnecessary
|
||||
& hud . closeItems %~ f
|
||||
& hud . closeInterfaces %~ g
|
||||
where
|
||||
newcloseobjects = unionBy closeObjEq oldCloseFiltered currentClose
|
||||
updatecursorposifnecessary =
|
||||
case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject of
|
||||
Just i
|
||||
| i >= length newcloseobjects -> scrollAugInvSel 1
|
||||
| isNothing (w ^? hud . hudElement . diSections . ix 3 . ssItems . ix i) ->
|
||||
scrollAugInvSel (-1)
|
||||
_ -> id
|
||||
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
|
||||
-- the following should update any changed properties of flits/bts
|
||||
g oldbts = intersectBy bteq cbts oldbts `btunion` cbts
|
||||
f olditems = intersectBy feq citems olditems `itunion` citems
|
||||
itunion = unionBy feq
|
||||
btunion = unionBy bteq
|
||||
feq = (==) `on` _flItID
|
||||
bteq = (==) `on` _btID
|
||||
cbts = filter (isclose . _btPos) activeButtons
|
||||
citems =
|
||||
filter (isclose . _flItPos)
|
||||
. IM.elems
|
||||
$ w ^. cWorld . lWorld . floorItems . unNIntMap
|
||||
isclose pos = dist ypos pos < 40 && hasButtonLOS ypos pos w
|
||||
ypos = _crPos $ you w
|
||||
activeButtons =
|
||||
map Right
|
||||
. filter ((/=) BtNoLabel . _btState)
|
||||
filter ((/=) BtNoLabel . _btState)
|
||||
. IM.elems
|
||||
$ w ^. cWorld . lWorld . buttons
|
||||
currentClose =
|
||||
filt $
|
||||
map Left (IM.elems $ w ^. cWorld . lWorld . floorItems . unNIntMap)
|
||||
++ activeButtons
|
||||
oldClose = filt $ mapMaybe updatebyid $ w ^. hud . closeObjects
|
||||
oldCloseFiltered = intersectBy closeObjEq oldClose currentClose
|
||||
updatebyid (Left flid) =
|
||||
fmap Left $
|
||||
w
|
||||
^? cWorld . lWorld . floorItems . unNIntMap
|
||||
. ix (_unNInt $ _flItID flid)
|
||||
updatebyid (Right btid) = fmap Right $ w ^? cWorld . lWorld . buttons . ix (_btID btid)
|
||||
-- updatecursorposifnecessary =
|
||||
-- case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject of
|
||||
-- Just i
|
||||
-- | i >= length newcloseobjects -> scrollAugInvSel 1
|
||||
-- | isNothing (w ^? hud . hudElement . diSections . ix 3 . ssItems . ix i) ->
|
||||
-- scrollAugInvSel (-1)
|
||||
-- _ -> id
|
||||
|
||||
changeSwapSel :: Int -> World -> World
|
||||
changeSwapSel yi w
|
||||
@@ -178,7 +176,7 @@ changeSwapClose f i w = fromMaybe w $ do
|
||||
& swapAnyExtraSelection i k
|
||||
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject
|
||||
.~ k
|
||||
& hud . closeObjects %~ swapIndices i k
|
||||
& hud . closeItems %~ swapIndices i k
|
||||
& hud . hudElement . diSelection . _Just . _2 .~ k
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
@@ -196,7 +194,7 @@ swapInvItems f i w = fromMaybe w $ do
|
||||
Just (0, j) | j == i -> hud . hudElement . diSelection . _Just . _2 .~ k
|
||||
_ -> id
|
||||
return $
|
||||
w
|
||||
w
|
||||
& swapAnyExtraSelection i k
|
||||
& checkConnection InventorySound disconnectItemS i k
|
||||
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
|
||||
@@ -207,15 +205,16 @@ swapInvItems f i w = fromMaybe w $ do
|
||||
& cWorld . lWorld %~ crUpdateItemLocations 0 -- the double application is inefficient, but necessary without further changes
|
||||
-- a rethink is maybe in order
|
||||
& checkConnection InventoryConnectSound connectItemS i k
|
||||
-- & checkconnect k InventoryConnectSound connectItemS
|
||||
where
|
||||
-- cpos = fromMaybe 0 $ w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
-- checkconnect k stype s w'
|
||||
-- | p (i+1) || p (i-1)
|
||||
-- || p (k+1) || p (k-1) = soundStart stype cpos s Nothing w'
|
||||
-- | otherwise = w'
|
||||
-- where
|
||||
-- p j = maybe False not $ w' ^? cWorld . lWorld . creatures . ix 0 . crInv . ix j . itLocation . ilIsRoot
|
||||
-- & checkconnect k InventoryConnectSound connectItemS
|
||||
|
||||
-- cpos = fromMaybe 0 $ w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
-- checkconnect k stype s w'
|
||||
-- | p (i+1) || p (i-1)
|
||||
-- || p (k+1) || p (k-1) = soundStart stype cpos s Nothing w'
|
||||
-- | otherwise = w'
|
||||
-- where
|
||||
-- p j = maybe False not $ w' ^? cWorld . lWorld . creatures . ix 0 . crInv . ix j . itLocation . ilIsRoot
|
||||
updatecreature k =
|
||||
(crInv %~ IM.safeSwapKeys i k)
|
||||
. (crManipulation . manObject . imSelectedItem .~ k)
|
||||
@@ -238,8 +237,9 @@ swapAnyExtraSelection i k w = fromMaybe w $ do
|
||||
is <- w ^? hud . hudElement . diSelectionExtra
|
||||
let f = if i `IS.member` is then IS.insert k else id
|
||||
g = if k `IS.member` is then IS.insert i else id
|
||||
return $ w & hud . hudElement . diSelectionExtra
|
||||
%~ (f . g . IS.delete i . IS.delete k)
|
||||
return $
|
||||
w & hud . hudElement . diSelectionExtra
|
||||
%~ (f . g . IS.delete i . IS.delete k)
|
||||
|
||||
checkConnection :: SoundOrigin -> SoundID -> Int -> Int -> World -> World
|
||||
checkConnection so s i j w = fromMaybe w $ do
|
||||
@@ -253,16 +253,17 @@ checkConnection so s i j w = fromMaybe w $ do
|
||||
|
||||
isConnected :: LocationLDT b a -> Bool
|
||||
isConnected x = case x ^. locLdtContext of
|
||||
TopLDT -> not (null $ x ^. locLDT . ldtRight)
|
||||
|| not (null $ x ^. locLDT . ldtLeft)
|
||||
TopLDT ->
|
||||
not (null $ x ^. locLDT . ldtRight)
|
||||
|| not (null $ x ^. locLDT . ldtLeft)
|
||||
_ -> True
|
||||
|
||||
swapItemWith ::
|
||||
swapItemWith ::
|
||||
(Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) ->
|
||||
(Int,Int) ->
|
||||
(Int, Int) ->
|
||||
World ->
|
||||
World
|
||||
swapItemWith f (j,i) w = case j of
|
||||
swapItemWith f (j, i) w = case j of
|
||||
0 -> w & swapInvItems f i
|
||||
3 -> w & changeSwapClose f i
|
||||
_ -> w
|
||||
@@ -296,22 +297,18 @@ scrollAugInvSel yi w
|
||||
|
||||
scrollAugNextInSection :: World -> World
|
||||
scrollAugNextInSection w =
|
||||
w & hud . hudElement %~ doscroll
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& setInvPosFromSS
|
||||
& cWorld . lWorld %~ crUpdateItemLocations 0
|
||||
w & hud . hudElement %~ doscroll
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& setInvPosFromSS
|
||||
& cWorld . lWorld %~ crUpdateItemLocations 0
|
||||
where
|
||||
doscroll he = fromMaybe he $ do
|
||||
sss <- he ^? diSections
|
||||
return $ he & diSelection %~ nextInSectionSS sss
|
||||
|
||||
selectedCloseObject :: World -> Maybe (Either FloorItem Button)
|
||||
selectedCloseObject w = do
|
||||
selectedCloseItem :: World -> Maybe FloorItem
|
||||
selectedCloseItem w = do
|
||||
i <-
|
||||
you w ^? crManipulation . manObject . ispCloseObject
|
||||
<|> fmap fst (IM.lookupMin =<< w ^? hud . hudElement . diSections . ix 3 . ssItems)
|
||||
w ^? hud . closeObjects . ix i
|
||||
|
||||
isFilteringInv :: IM.IntMap (SelectionSection a) -> Bool
|
||||
isFilteringInv = not . null . (^. ix (-1) . ssItems)
|
||||
|
||||
w ^? hud . closeItems . ix i
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
module Dodge.Inventory.CloseObject (
|
||||
closeObjPos,
|
||||
closeObjEq,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Button
|
||||
import Dodge.Data.FloorItem
|
||||
import Geometry
|
||||
|
||||
closeObjPos :: Either FloorItem Button -> Point2
|
||||
closeObjPos e = case e of
|
||||
Right x -> _btPos x
|
||||
Left x -> _flItPos x
|
||||
|
||||
closeObjEq :: Either FloorItem Button -> Either FloorItem Button -> Bool
|
||||
closeObjEq (Right x) (Right y) = _btID x == _btID y
|
||||
closeObjEq (Left x) (Left y) = _flItID x == _flItID y
|
||||
closeObjEq _ _ = False
|
||||
@@ -1,9 +1,9 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
--{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Inventory.SelectionList (
|
||||
invSelectionItem,
|
||||
invSelectionItem',
|
||||
closeObjectToSelectionItem,
|
||||
closeItemToSelectionItem,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
@@ -51,8 +51,8 @@ hotkeyToString x = case x of
|
||||
Hotkey9 -> "[9]"
|
||||
Hotkey0 -> "[0]"
|
||||
|
||||
closeObjectToSelectionItem :: Either FloorItem Button -> SelectionItem ()
|
||||
closeObjectToSelectionItem e =
|
||||
closeItemToSelectionItem :: FloorItem -> SelectionItem ()
|
||||
closeItemToSelectionItem e =
|
||||
SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
@@ -63,11 +63,11 @@ closeObjectToSelectionItem e =
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
(pics, col) = closeObjectToTextPictures e
|
||||
(pics, col) = closeItemToTextPictures e
|
||||
|
||||
closeObjectToTextPictures :: Either FloorItem Button -> ([String], Color)
|
||||
closeObjectToTextPictures = \case
|
||||
Left flit ->
|
||||
closeItemToTextPictures :: FloorItem -> ([String], Color)
|
||||
closeItemToTextPictures flit =
|
||||
let it = _flIt flit
|
||||
in (basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
|
||||
Right bt -> ([_btText bt], yellow)
|
||||
|
||||
-- Right bt -> ([_btText bt], yellow)
|
||||
|
||||
+40
-38
@@ -4,10 +4,10 @@ module Dodge.Render.HUD (
|
||||
drawHUD,
|
||||
) where
|
||||
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
--import qualified Data.Vector as V
|
||||
@@ -47,19 +47,9 @@ drawHUD :: Configuration -> World -> Picture
|
||||
drawHUD cfig w = case w ^. hud . hudElement of
|
||||
DisplayCarte -> drawCarte cfig w
|
||||
DisplayInventory{_diSections = sections, _subInventory = subinv} ->
|
||||
drawHP cfig w
|
||||
<> drawInventory sections w cfig
|
||||
drawInventory sections w cfig
|
||||
<> drawSubInventory subinv cfig w
|
||||
|
||||
drawHP :: Configuration -> World -> Picture
|
||||
drawHP cfig =
|
||||
dShadCol white
|
||||
. translate (halfWidth cfig) (halfHeight cfig - 40)
|
||||
. scale 0.2 0.2
|
||||
. textRight
|
||||
. show
|
||||
. (^?! cWorld . lWorld . creatures . ix 0 . crHP)
|
||||
|
||||
drawInventory :: IM.IntMap (SelectionSection ()) -> World -> Configuration -> Picture
|
||||
drawInventory sss w cfig =
|
||||
drawSelectionSections sss ldp cfig
|
||||
@@ -72,8 +62,9 @@ drawInventory sss w cfig =
|
||||
curs = invCursorParams w
|
||||
iextra = fromMaybe mempty $ do
|
||||
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
|
||||
guard . not . isFilteringInv =<< (w ^? hud . hudElement . diSections)
|
||||
return . inventoryExtra sss cfig w $ invAdj inv
|
||||
case w ^? hud . hudElement . diInvFilter . _Just of
|
||||
Just (_ : _) -> Nothing
|
||||
_ -> return . inventoryExtra sss cfig w $ invAdj inv
|
||||
|
||||
drawRootCursor ::
|
||||
World ->
|
||||
@@ -109,13 +100,17 @@ getRootItemBounds i inv = do
|
||||
|
||||
-- this should display while dragging a single inv item
|
||||
drawMouseOver :: Configuration -> World -> Picture
|
||||
drawMouseOver cfig w = concat (invsel <|> combinvsel
|
||||
<|> drawDragSelect cfig w)
|
||||
<> concat (drawDragSelected cfig w)
|
||||
drawMouseOver cfig w =
|
||||
concat
|
||||
( invsel <|> combinvsel
|
||||
<|> drawDragSelect cfig w
|
||||
)
|
||||
<> concat (drawDragSelected cfig w)
|
||||
where
|
||||
invsel = do
|
||||
(j, i) <- w ^? input . mouseContext . mcoInvSelect <|>
|
||||
w ^? input . mouseContext . mcoInvFilt
|
||||
(j, i) <-
|
||||
w ^? input . mouseContext . mcoInvSelect
|
||||
<|> w ^? input . mouseContext . mcoInvFilt
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
return . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
||||
@@ -123,8 +118,9 @@ drawMouseOver cfig w = concat (invsel <|> combinvsel
|
||||
$ selSecDrawCursorAt 15 idp curs sss (j, i)
|
||||
curs = BackdropCursor
|
||||
combinvsel = do
|
||||
(j, i) <- (w ^? input . mouseContext . mcoCombSelect)
|
||||
<|> (w ^? input . mouseContext . mcoCombCombine)
|
||||
(j, i) <-
|
||||
(w ^? input . mouseContext . mcoCombSelect)
|
||||
<|> (w ^? input . mouseContext . mcoCombCombine)
|
||||
sss <- w ^? hud . hudElement . subInventory . ciSections
|
||||
let idp = secondColumnParams
|
||||
return . translateScreenPos cfig (idp ^. ldpPos)
|
||||
@@ -135,23 +131,27 @@ drawDragSelected :: Configuration -> World -> Maybe Picture
|
||||
drawDragSelected cfig w = do
|
||||
ys <- w ^? hud . hudElement . diSelectionExtra
|
||||
guard $ not (IS.null ys)
|
||||
(i,_) <- w ^? hud . hudElement . diSelection . _Just
|
||||
(i, _) <- w ^? hud . hudElement . diSelection . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
let f x = (selSecDrawCursorAt 15 idp BackdropCursor sss (i, x) <>)
|
||||
return . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
||||
. color (withAlpha 0.2 white) . IS.foldr f mempty $ ys
|
||||
. color (withAlpha 0.2 white)
|
||||
. IS.foldr f mempty
|
||||
$ ys
|
||||
|
||||
drawDragSelect :: Configuration -> World -> Maybe Picture
|
||||
drawDragSelect cfig w = do
|
||||
OverInvDragSelect (i,j) mselend <- w ^? input . mouseContext
|
||||
(a,b) <- mselend
|
||||
OverInvDragSelect (i, j) mselend <- w ^? input . mouseContext
|
||||
(a, b) <- mselend
|
||||
guard $ i == a
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
let f x = selSecDrawCursorAt 15 idp BackdropCursor sss (i, x)
|
||||
return . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
||||
. color (withAlpha 0.2 white) . foldMap f $ [min j b .. max j b]
|
||||
. color (withAlpha 0.2 white)
|
||||
. foldMap f
|
||||
$ [min j b .. max j b]
|
||||
|
||||
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
|
||||
drawSubInventory subinv cfig w = case subinv of
|
||||
@@ -181,14 +181,15 @@ drawExamineInventory cfig w =
|
||||
<> drawSelectionList
|
||||
secondColumnParams
|
||||
cfig
|
||||
( map f
|
||||
( makeParagraph 55 $
|
||||
yourAugmentedItem
|
||||
itemInfo
|
||||
(yourInfo (you w))
|
||||
(closeObjectInfo (crNumFreeSlots (you w)))
|
||||
w
|
||||
)
|
||||
( map
|
||||
f
|
||||
( makeParagraph 55 $
|
||||
yourAugmentedItem
|
||||
itemInfo
|
||||
(yourInfo (you w))
|
||||
(closeObjectInfo (crNumFreeSlots (you w)))
|
||||
w
|
||||
)
|
||||
)
|
||||
where
|
||||
f str =
|
||||
@@ -216,7 +217,7 @@ floorItemPickupInfo n itm
|
||||
yourAugmentedItem :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> a
|
||||
yourAugmentedItem f x g w = case you w ^? crManipulation . manObject of
|
||||
Just (SelectedItem i _ _) -> f $ yourInv w ^?! ix i
|
||||
Just (SelCloseObject i) -> g $ w ^?! hud . closeObjects . ix i
|
||||
Just (SelCloseObject i) -> g . Left $ w ^?! hud . closeItems . ix i
|
||||
_ -> x
|
||||
|
||||
drawRBOptions :: Configuration -> World -> Picture
|
||||
@@ -323,7 +324,7 @@ combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
|
||||
let col = _siColor si
|
||||
lnks <- si ^? siPayload . ciInvIDs
|
||||
return (lnkMidPosInvSelsCol cfig w j col lnks)
|
||||
<> foldMap invcursor lnks
|
||||
<> foldMap invcursor lnks
|
||||
where
|
||||
invcursor i = do
|
||||
sss' <- w ^? hud . hudElement . diSections
|
||||
@@ -344,7 +345,7 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
|
||||
invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
||||
<> drawSelectionList secondColumnParams cfig (thesellist tm)
|
||||
<> color (withAlpha 0.5 green) (drawSelectionListBackground secondColumnParams cfig 15)
|
||||
-- when changing the 15, change isOverTerminalScreen
|
||||
-- when changing the 15, change isOverTerminalScreen
|
||||
<> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig)
|
||||
where
|
||||
toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
|
||||
@@ -361,7 +362,8 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
|
||||
displayInputText tm s
|
||||
| _tmStatus tm == TerminalReady = partcommand tm ++ getPromptTM (tm ^. tmType) ++ s
|
||||
| otherwise = ""
|
||||
-- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w
|
||||
|
||||
-- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w
|
||||
|
||||
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
|
||||
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f
|
||||
|
||||
@@ -26,7 +26,7 @@ drawSelectionSections sss ldp cfig =
|
||||
(_ldpScale ldp)
|
||||
0
|
||||
(foldMap
|
||||
(\ss -> fmap (translate (100*fromIntegral (_ssIndent ss)) 0) $ _ssShownItems ss) sss)
|
||||
(\ss -> translate (100*fromIntegral (_ssIndent ss)) 0 <$> _ssShownItems ss) sss)
|
||||
|
||||
drawSSCursor ::
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
|
||||
@@ -453,7 +453,7 @@ pauseGame u = u & uvScreenLayers .~ [pauseMenu u]
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case w ^. hud . hudElement of
|
||||
DisplayCarte -> w & hud . carteCenter .~ theLoc
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> case selectedCloseObject w of
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> case Left <$> selectedCloseItem w of
|
||||
Just (Left flit) ->
|
||||
pickUpItem 0 flit w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
Reference in New Issue
Block a user