Cleanup
This commit is contained in:
+8
-14
@@ -55,8 +55,7 @@ drawHUD cfig w = case w ^. hud of
|
||||
drawInventory sections w cfig subinv
|
||||
<> drawSubInventory subinv cfig w
|
||||
|
||||
drawInventory
|
||||
:: IM.IntMap (SelectionSection ()) -> World -> Config -> SubInventory -> Picture
|
||||
drawInventory :: IM.IntMap (SelSection ()) -> World -> Config -> SubInventory -> Picture
|
||||
drawInventory sss w cfig = \case
|
||||
DisplayTerminal {} -> mempty
|
||||
_ -> drawSelectionSections sss invDP cfig
|
||||
@@ -76,7 +75,7 @@ drawInventory sss w cfig = \case
|
||||
|
||||
drawRootCursor ::
|
||||
World ->
|
||||
IM.IntMap (SelectionSection ()) ->
|
||||
IM.IntMap (SelSection ()) ->
|
||||
Maybe (Int, Int) ->
|
||||
ListDisplayParams ->
|
||||
Config ->
|
||||
@@ -182,7 +181,7 @@ drawMapperInventory itid w = fold $ do
|
||||
|
||||
drawCombineInventory ::
|
||||
Config ->
|
||||
IM.IntMap (SelectionSection CombinableItem) ->
|
||||
IM.IntMap (SelSection CombItem) ->
|
||||
World ->
|
||||
Picture
|
||||
drawCombineInventory cfig sss w =
|
||||
@@ -318,7 +317,7 @@ equipAllocString = \case
|
||||
RemoveEquipment{} -> "TAKE OFF"
|
||||
|
||||
drawItemConnections ::
|
||||
IM.IntMap (SelectionSection ()) ->
|
||||
IM.IntMap (SelSection ()) ->
|
||||
Config ->
|
||||
IM.IntMap (Maybe (Int, Int), [Int], [Int]) ->
|
||||
Picture
|
||||
@@ -327,12 +326,7 @@ drawItemConnections sss cfig =
|
||||
. IM.foldMapWithKey (drawItemChildrenConnect sss cfig)
|
||||
. fmap (\(_, a, b) -> a <> b)
|
||||
|
||||
drawItemChildrenConnect ::
|
||||
IM.IntMap (SelectionSection ()) ->
|
||||
Config ->
|
||||
Int ->
|
||||
[Int] ->
|
||||
Picture
|
||||
drawItemChildrenConnect :: IM.IntMap (SelSection ()) -> Config -> Int -> [Int] -> Picture
|
||||
drawItemChildrenConnect sss cfig i is = fromMaybe mempty $ do
|
||||
p <- snum i
|
||||
let ps = mapMaybe snum is
|
||||
@@ -341,7 +335,7 @@ drawItemChildrenConnect sss cfig i is = fromMaybe mempty $ do
|
||||
snum = selNumPos cfig invDP sss 0
|
||||
|
||||
combineInventoryExtra ::
|
||||
IM.IntMap (SelectionSection CombinableItem) ->
|
||||
IM.IntMap (SelSection CombItem) ->
|
||||
Maybe (Int, Int) ->
|
||||
Config ->
|
||||
World ->
|
||||
@@ -477,7 +471,7 @@ selNumPosCardinal ::
|
||||
CardinalEightPoint ->
|
||||
Config ->
|
||||
ListDisplayParams ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelSection a) ->
|
||||
Int ->
|
||||
Int ->
|
||||
Maybe Point2
|
||||
@@ -504,5 +498,5 @@ selNumPosCardinal card cfig ldp sss i j = do
|
||||
s = _ldpScale ldp
|
||||
ygap = _ldpVerticalGap ldp
|
||||
|
||||
selSecSelCol :: Int -> Int -> IM.IntMap (SelectionSection a) -> Maybe Color
|
||||
selSecSelCol :: Int -> Int -> IM.IntMap (SelSection a) -> Maybe Color
|
||||
selSecSelCol i j = (^? ix i . ssItems . ix j . siColor)
|
||||
|
||||
@@ -102,10 +102,9 @@ stackPicturesAtOff :: Int -> [Picture] -> Picture
|
||||
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..]
|
||||
|
||||
selSecDrawCursorAt ::
|
||||
-- Int ->
|
||||
ListDisplayParams ->
|
||||
CursorDisplay ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelSection a) ->
|
||||
(Int, Int) ->
|
||||
Picture
|
||||
selSecDrawCursorAt ldp curs sss (i, j) = fold $ do
|
||||
@@ -126,7 +125,7 @@ selSecDrawCursorAt ldp curs sss (i, j) = fold $ do
|
||||
selSecDrawCursor ::
|
||||
ListDisplayParams ->
|
||||
CursorDisplay ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelSection a) ->
|
||||
Maybe (Int, Int) ->
|
||||
Picture
|
||||
selSecDrawCursor ldp curs = maybe mempty . selSecDrawCursorAt ldp curs
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{- The menu picture. -}
|
||||
module Dodge.Render.MenuScreen (
|
||||
drawMenuScreen,
|
||||
) where
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Render.MenuScreen (drawMenuScreen) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Base.Window
|
||||
@@ -14,32 +12,20 @@ import Dodge.ScreenPos
|
||||
import Picture
|
||||
|
||||
drawMenuScreen :: Config -> Maybe Int -> ScreenLayer -> Picture
|
||||
drawMenuScreen cfig spos screen = case screen of
|
||||
OptionScreen{_scTitle = titf, _scSelectionList = slist} ->
|
||||
drawOptions cfig titf spos slist
|
||||
InputScreen inputstr help -> drawInputMenu cfig ('>' : inputstr) help
|
||||
drawMenuScreen cf mi = \case
|
||||
OptionScreen{_scTitle = s, _scSelectionList = l} -> drawOptions cf s mi l
|
||||
InputScreen inputstr -> drawInputMenu cf ('>' : inputstr)
|
||||
|
||||
drawInputMenu ::
|
||||
Config ->
|
||||
-- | Title
|
||||
String ->
|
||||
-- | Help Text
|
||||
String ->
|
||||
Picture
|
||||
drawInputMenu cfig title footer =
|
||||
fold
|
||||
[ darkenBackground cfig
|
||||
, drawTitle cfig title
|
||||
, drawFooterText cfig red footer
|
||||
]
|
||||
drawInputMenu :: Config -> String -> Picture
|
||||
drawInputMenu cf s = darkenBackground cf <> drawTitle cf s
|
||||
|
||||
drawOptions :: Config -> String -> Maybe Int -> [SelectionItem a] -> Picture
|
||||
drawOptions cfig title msel sl =
|
||||
darkenBackground cfig
|
||||
<> drawTitle cfig title
|
||||
<> drawSelectionList menuLDP cfig sl
|
||||
drawOptions cf title msel sl =
|
||||
darkenBackground cf
|
||||
<> drawTitle cf title
|
||||
<> drawSelectionList menuLDP cf sl
|
||||
<> translateScreenPos
|
||||
cfig
|
||||
cf
|
||||
(menuLDP ^. ldpPos)
|
||||
( drawCursorAt
|
||||
msel
|
||||
@@ -53,24 +39,7 @@ darkenBackground :: Config -> Picture
|
||||
darkenBackground = color (withAlpha 0.5 black) . polygon . reverse . screenBox
|
||||
|
||||
drawTitle :: Config -> String -> Picture
|
||||
drawTitle cfig = translate (- hw) (hh -80) . scale 0.4 0.4 . text
|
||||
drawTitle cf = translate (- hw) (hh -80) . scale 0.4 0.4 . text
|
||||
where
|
||||
hh = halfHeight cfig
|
||||
hw = halfWidth cfig
|
||||
|
||||
placeString ::
|
||||
-- | x distance from center
|
||||
Float ->
|
||||
-- | y distance from center
|
||||
Float ->
|
||||
-- | scale
|
||||
Float ->
|
||||
String ->
|
||||
Picture
|
||||
placeString x y sc = color white . translate x y . scale sc sc . text
|
||||
|
||||
drawFooterText :: Config -> Color -> String -> Picture
|
||||
drawFooterText cfig col = color col . placeString (- hw + 30) (- hh + 10) 0.1
|
||||
where
|
||||
hh = halfHeight cfig
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cf
|
||||
hw = halfWidth cf
|
||||
|
||||
Reference in New Issue
Block a user