This commit is contained in:
2025-09-19 19:56:12 +01:00
parent 2d856ddf9e
commit d4f2cdd3fd
20 changed files with 282 additions and 351 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ import Dodge.Item.InventoryColor
import qualified IntMapHelp as IM
import SimpleTrie
combineList :: World -> [SelectionItem CombinableItem]
combineList :: World -> [SelectionItem CombItem]
combineList = map f . combineItemListYouX
where
f (is, itm) =
@@ -28,8 +28,8 @@ combineList = map f . combineItemListYouX
, _siWidth = 15
, _siIsSelectable = True
, _siColor = itemInvColor $ baseCI itm
, _siOffX = 0
, _siPayload = Just $ CombinableItem is itm
, _siOffX = 2
, _siPayload = Just $ CombItem is itm
}
combineItemListYouX :: World -> [([Int], Item)]
+1 -1
View File
@@ -59,7 +59,7 @@ loadingScreen str =
{ _scTitle = str
, _scOptions = mempty
, _scOffset = 0
, _scPositionedMenuOption = NoEscapeMenuOption
, _scPositionedMenuOption = NoExtraMenuOption
, _scOptionFlag = LoadingScreen
, _scSelectionList = mempty
, _scAvailableLines = 0
+6 -2
View File
@@ -1,9 +1,13 @@
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.Combine where
import Control.Lens
import Dodge.Data.Item
data CombinableItem = CombinableItem
data CombItem = CombItem
{ _ciInvIDs :: [Int]
, _ciItem :: Item
}
makeLenses ''CombinableItem
makeLenses ''CombItem
+1 -1
View File
@@ -22,7 +22,7 @@ data SubInventory
, _mapInvItmID :: NewInt ItmInt
}
| CombineInventory
{ _ciSections :: IMSS CombinableItem
{ _ciSections :: IMSS CombItem
, _ciSelection :: Maybe Selection
, _ciFilter :: Maybe String
}
+3 -3
View File
@@ -26,7 +26,7 @@ data SectionCursor = SectionCursor
, _scurColor :: Color
}
data SelectionSection a = SelectionSection
data SelSection a = SelSection
{ _ssItems :: IntMap (SelectionItem a)
, _ssOffset :: Int
, _ssShownItems :: [Picture]
@@ -34,7 +34,7 @@ data SelectionSection a = SelectionSection
, _ssIndent :: Int
}
type IMSS a = IntMap (SelectionSection a)
type IMSS a = IntMap (SelSection a)
data SelectionWidth = FixedSelectionWidth Int | UseItemWidth
@@ -51,6 +51,6 @@ data SelectionItem a
makeLenses ''ListDisplayParams
makeLenses ''SelectionItem
makeLenses ''SelectionSection
makeLenses ''SelSection
makeLenses ''SectionCursor
makeLenses ''CursorDisplay
+7 -10
View File
@@ -73,26 +73,23 @@ data OptionScreenFlag = NormalOptions | GameOverOptions | SplashOptions
| LoadingScreen
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data EscapeMenuOption
= BottomEscapeMenuOption { _emoMenuOption :: MenuOption }
| TopEscapeMenuOption { _emoMenuOption :: MenuOption }
| NoEscapeMenuOption
data ExtraMenuOption
= BottomMenuOption { _emoMenuOption :: MenuOption }
| TopMenuOption { _emoMenuOption :: MenuOption }
| NoExtraMenuOption
data ScreenLayer
= OptionScreen
{ _scTitle :: String
, _scOptions :: [MenuOption]
, _scOffset :: Int
, _scPositionedMenuOption :: EscapeMenuOption
, _scPositionedMenuOption :: ExtraMenuOption
, _scOptionFlag :: OptionScreenFlag
, _scSelectionList :: [SelectionItem (Universe -> Universe,Universe->Universe)]
, _scAvailableLines :: Int
, _scDisplayTime :: Int
}
| InputScreen
{ _scInput :: String
, _scFooter :: String
}
| InputScreen { _scInput :: String }
data MenuOptionDisplay
= MODString {_modString :: String}
@@ -117,6 +114,6 @@ makeLenses ''ScreenLayer
makeLenses ''SideEffect
makeLenses ''MenuOptionDisplay
makeLenses ''MenuOption
makeLenses ''EscapeMenuOption
makeLenses ''ExtraMenuOption
makeLenses ''DebugItem
makeLenses ''DebugInfo
+4 -4
View File
@@ -77,19 +77,19 @@ parseItem [] = Nothing
parseNum :: [String] -> Int
parseNum xs = fromMaybe 1 $ xs ^? ix 0 >>= readMaybe
showTerminalError :: String -> String -> Universe -> Universe
showTerminalError cmd s = uvScreenLayers .:~ InputScreen cmd s
showTerminalError :: String -> Universe -> Universe
showTerminalError cmd = uvScreenLayers .:~ InputScreen cmd
applySetTerminalString :: String -> Universe -> Universe
applySetTerminalString [] = id
applySetTerminalString var = case key' of
"" -> showTerminalError ("set " ++ var) ("Unable to read as argument as float: " ++ val)
"" -> showTerminalError ("set " ++ var)
"hp" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crHP .~ round (fromJust val')
-- "invcap" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
-- "mass" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMass .~ fromJust val'
-- "mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMvType . mvSpeed .~ fromJust val'
"mvspeed" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avMoveSpeed .~ fromJust val'
_ -> showTerminalError ("set " ++ var) ("Invalid set command: " ++ key) -- never reached?
_ -> showTerminalError ("set " ++ var)
where
(key, val) = getSplitString var
val' = readMaybe val :: Maybe Float
+31 -45
View File
@@ -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
+1 -1
View File
@@ -238,7 +238,7 @@ btText :: Button -> String
btText bt = case _btEvent bt of
ButtonPress {} -> "BUTTON"
ButtonSwitch {_btOn = t} -> if t then "SWITCH\\" else "SWITCH/"
ButtonAccessTerminal {} -> "TERMINAL"
ButtonAccessTerminal i -> "TERMINAL " ++ show i
closeItemToTextPictures :: Item -> ([String], Color)
closeItemToTextPictures it = (basicItemDisplay it, itemInvColor $ baseCI it)
+2 -2
View File
@@ -41,10 +41,10 @@ invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of
_ -> [North, South, West]
secondColumnLDP :: ListDisplayParams
secondColumnLDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 subInvX (-80)
secondColumnLDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 subInvX (-20)
subInvX :: Float
subInvX = 10 * fromIntegral topInvW + 70
subInvX = 10 * fromIntegral topInvW + 170
topInvW :: Int
topInvW = 15
+14 -16
View File
@@ -28,9 +28,9 @@ import System.Clipboard
import Text.Read
splashMenu :: Universe -> ScreenLayer
splashMenu u =
initializeOptionMenu "GAME TITLE" splashMenuOptions NoEscapeMenuOption u
& scOptionFlag .~ SplashOptions
splashMenu =
(scOptionFlag .~ SplashOptions)
. initializeOptionMenu NoExtraMenuOption "GAME TITLE" splashMenuOptions
splashMenuOptions :: [MenuOption]
splashMenuOptions =
@@ -55,8 +55,10 @@ splashMenuOptions =
pauseMenu :: Universe -> ScreenLayer
pauseMenu =
initializeOptionMenu "PAUSED" pauseMenuOptions $
TopEscapeMenuOption $ Toggle unpause (const (MODString "CONTINUE"))
initializeOptionMenu
(TopMenuOption $ Toggle unpause (const (MODString "CONTINUE")))
"PAUSED"
pauseMenuOptions
pauseMenuOptions :: [MenuOption]
pauseMenuOptions =
@@ -100,10 +102,10 @@ trySeedFromClipboard u = do
Just i -> return $ startSeedGame 0 i u
titleOptionsMenu :: String -> [MenuOption] -> Universe -> ScreenLayer
titleOptionsMenu title ops = initializeOptionMenuBO title ops "BACK" (popScreen . writeConfig)
titleOptionsMenu = initializeOptionMenuBO "BACK" (popScreen . writeConfig)
titleOptionsNoWrite :: String -> [MenuOption] -> Universe -> ScreenLayer
titleOptionsNoWrite title ops = initializeOptionMenuBO title ops "BACK" popScreen
titleOptionsNoWrite = initializeOptionMenuBO "BACK" popScreen
optionMenu :: Universe -> ScreenLayer
optionMenu = titleOptionsNoWrite "OPTIONS" optionsOptions
@@ -185,12 +187,9 @@ graphicsMenuOptions =
]
gameOverMenu :: Universe -> ScreenLayer
gameOverMenu u =
initializeOptionMenu "GAME OVER" pauseMenuOptions NoEscapeMenuOption u
& scOptionFlag .~ GameOverOptions
--charToScode :: Char -> Scancode
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
gameOverMenu =
set scOptionFlag GameOverOptions
. initializeOptionMenu NoExtraMenuOption "GAME OVER" pauseMenuOptions
unpause :: Universe -> Universe
unpause u' =
@@ -211,7 +210,8 @@ unpause u' =
-- note that this won't update after it is first loaded
displayConfig :: Universe -> ScreenLayer
displayConfig u = titleOptionsNoWrite "CONFIG" (map (Toggle id . const . MODString) $ listConfig u) u
displayConfig u = titleOptionsNoWrite "CONFIG" (map (Toggle id . const . MODString)
$ listConfig u) u
listConfig :: Universe -> [String]
listConfig =
@@ -239,8 +239,6 @@ listControls =
, ("q|e|0-9", "USE HOTKEY")
, ("<caps>&q|e|0-9", "JUMP TO HOTKEY")
, ("c", "COMBINE ITEMS")
-- , ("x", "EXAMINE ITEMS")
-- , ("m", "DISPLAY MAP")
, ("p|<esc>", "PAUSE")
, ("<lmb>", "SELECT/MOVE ITEMS")
, ("<F1>", "NORMAL CAMERA")
+11 -23
View File
@@ -14,9 +14,8 @@ import LensHelp
import Padding
import Picture.Base
initializeOptionMenu ::
String -> [MenuOption] -> EscapeMenuOption -> Universe -> ScreenLayer
initializeOptionMenu title ops pmo u =
initializeOptionMenu :: ExtraMenuOption -> String -> [MenuOption] -> Universe -> ScreenLayer
initializeOptionMenu pmo title ops u =
OptionScreen
{ _scTitle = title
, _scOptions = ops
@@ -28,12 +27,10 @@ initializeOptionMenu title ops pmo u =
, _scDisplayTime = 0
}
-- BO = Bottom Option
initializeOptionMenuBO ::
String -> [MenuOption] -> String -> (Universe -> Universe) -> Universe -> ScreenLayer
initializeOptionMenuBO title ops str eff = initializeOptionMenu title ops pmo
where
pmo = BottomEscapeMenuOption $ (Toggle eff . const . MODString) str
String -> (Universe -> Universe) -> String -> [MenuOption] -> Universe -> ScreenLayer
initializeOptionMenuBO str eff = initializeOptionMenu
$ BottomMenuOption $ (Toggle eff . const . MODString) str
refreshOptionsSelectionList :: Universe -> Universe
refreshOptionsSelectionList u = u & uvScreenLayers . ix 0 %~ f
@@ -51,17 +48,18 @@ optionsToSelections ::
Int ->
Universe ->
[MenuOption] ->
EscapeMenuOption ->
ExtraMenuOption ->
[SelectionItem (Universe -> Universe, Universe -> Universe)]
optionsToSelections maxlines u allops pmo = case pmo of
NoEscapeMenuOption -> map (menuOptionToSelectionItem u maxOptionLength) ops
TopEscapeMenuOption mo -> map (menuOptionToSelectionItem u maxOptionLength) (mo : ops)
BottomEscapeMenuOption mo -> map (menuOptionToSelectionItem u maxOptionLength) (ops ++ [mo])
NoExtraMenuOption -> map (menuOptionToSelectionItem u maxOptionLength) ops
TopMenuOption mo -> map (menuOptionToSelectionItem u maxOptionLength) (mo : ops)
BottomMenuOption mo -> map (menuOptionToSelectionItem u maxOptionLength) (ops ++ [mo])
where
offset = fromMaybe 0 $ u ^? uvScreenLayers . _head . scOffset
ops
| maxlines >= length allops = allops
| otherwise = take (maxlines - 2) (drop offset allops ++ repeat dummyMenuOption) ++ [cycleOptionsOption]
| otherwise = take (maxlines - 2) (drop offset allops ++ repeat dummyMenuOption)
++ [cycleOptionsOption]
maxOptionLength = 3 + maximum (0 : map (optionValueOffset u) ops)
cycleOptionsOption =
Toggle
@@ -117,13 +115,3 @@ menuOptionToSelectionItem w padAmount mo =
optionText = case _moString mo w of
MODStringOption s t -> rightPad padAmount '.' s ++ t
x -> _modString x
--menuOptionToString :: Universe -> Int -> MenuOption -> (Color, String)
--menuOptionToString w padAmount mo = (thecol, optionText)
-- where
-- thecol = case _moString mo w of
-- MODBlockedString{} -> greyN 0.5
-- _ -> white
-- optionText = case _moString mo w of
-- MODStringOption s t -> rightPad padAmount '.' s ++ t
-- x -> _modString x
+8 -14
View File
@@ -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)
+2 -3
View File
@@ -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
+15 -46
View File
@@ -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
+3 -3
View File
@@ -14,7 +14,7 @@ import Dodge.SelectionSections
import Picture.Base
drawSelectionSections ::
IM.IntMap (SelectionSection a) ->
IM.IntMap (SelSection a) ->
ListDisplayParams ->
Config ->
Picture
@@ -33,7 +33,7 @@ drawSelectionSections sss ldp cfig =
)
drawSSCursor ::
IM.IntMap (SelectionSection a) ->
IM.IntMap (SelSection a) ->
ListDisplayParams ->
CursorDisplay ->
Config ->
@@ -44,7 +44,7 @@ drawSSCursor sss ldp curs cfig =
selSecDrawCursor ldp curs sss
drawSSMultiCursor ::
IM.IntMap (SelectionSection a) ->
IM.IntMap (SelSection a) ->
Maybe (Int, Int) ->
Maybe Int ->
ListDisplayParams ->
-5
View File
@@ -73,8 +73,3 @@ showTimeFlow tfs = case tfs of
CameraScrollTimeFlow {_reverseAmount = ra } -> "CameraScrollTimeFlow" ++ show ra
RewindLeftClick {_reverseAmount = ra } -> "RewindLeftClick" ++ show ra
PausedTimeFlow {_timeFlowCharge = ra } -> "PausedTimeFlow" ++ show ra
-- [ show $ u ^? uvScreenLayers . _head . scOffset
-- ]
-- ++ [ shortShow $ u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crPos
-- ]
-- ++ map show (M.toList (u ^. uvWorld . input . pressedKeys))
+4 -3
View File
@@ -136,7 +136,7 @@ maybeOpenConsole u = case u ^. uvWorld . input . pressedKeys . at ScancodeSemico
openConsole :: [ScreenLayer] -> [ScreenLayer]
openConsole = \case
xs@(InputScreen{} : _) -> xs
xs -> InputScreen mempty "Enter command" : xs
xs -> InputScreen mempty : xs
updateUniverseLast :: Universe -> Universe
updateUniverseLast u =
@@ -348,7 +348,7 @@ updateMouseContextGame :: Config -> Universe -> MouseContext -> MouseContext
updateMouseContextGame cfig u = \case
OverInvDrag i _ -> OverInvDrag i (inverseSelNumPos cfig invDP mpos disss)
x@OverInvDragSelect{} -> x
_ -> fromMaybe aimcontext (isrotatedrag <|> overinv <|> overcomb <|> overterm)
_ -> fromMaybe aimcontext (isrotatedrag <|> overterm <|> overinv <|> overcomb)
where
w = u ^. uvWorld
isrotatedrag = do
@@ -406,7 +406,8 @@ isOverTerminalScreen cfig (V2 x y) =
&& y <= ymax + 5
&& y >= ymin
where
ldp = secondColumnLDP
--ldp = secondColumnLDP
ldp = invDP
V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
tsize = fromIntegral $ getMaxLinesTM + 1
s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
+1 -1
View File
@@ -545,7 +545,7 @@ getCloseObj w = getSelectedCloseObj w <|> topcitem <|> topcbut
tryCombine :: (Int, Int) -> World -> World
tryCombine (i, j) w = fromMaybe w $ do
CombinableItem is it <- w ^? hud . subInventory
CombItem is it <- w ^? hud . subInventory
. ciSections . ix i . ssItems . ix j . siPayload . _Just
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
return $