This commit is contained in:
2023-05-01 22:35:33 +01:00
parent 7b8b8750a9
commit 61f88aeb4a
9 changed files with 120 additions and 121 deletions
+34 -34
View File
@@ -3,7 +3,7 @@ module Dodge.Render.HUD (
drawHUD,
) where
import Dodge.SelectionSections.Draw
import Data.Foldable
import Control.Lens
import qualified Data.Map.Strict as M
import Data.Maybe
@@ -22,8 +22,8 @@ import Dodge.Item.Info
import Dodge.ListDisplayParams
import Dodge.Render.Connectors
import Dodge.Render.List
import Dodge.SelectionSections.Draw
import Dodge.Tweak.Show
--import Dodge.WorldPos
import Geometry
import qualified IntMapHelp as IM
import Justify
@@ -41,11 +41,10 @@ drawHUD cfig w = case w ^. hud . hudElement of
<> drawSubInventory subinv cfig w
drawHP :: Configuration -> World -> Picture
drawHP cfig w = dShadCol white $ displayHP 0 cfig w
drawHP cfig = dShadCol white . displayHP 0 cfig
drawInventory :: SelectionSections () -> World -> Configuration -> Picture
drawInventory sss w = drawSelectionSections sss (invDisplayParams w)
drawInventory sss = drawSelectionSections sss . invDisplayParams
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
drawSubInventory subinv cfig w = case subinv of
@@ -55,7 +54,6 @@ drawSubInventory subinv cfig w = case subinv of
DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld)
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture
drawCombineInventory cfig sss w =
invHead cfig "COMBINE"
@@ -66,11 +64,20 @@ drawExamineInventory :: Configuration -> Maybe Int -> World -> Picture
drawExamineInventory cfig mtweaki w =
invHead cfig "EXAMINE"
<> examineInventoryExtra mtweaki itm cfig
<> drawSelectionList secondColumnParams
cfig
( defaultSelectionList & slItems .~ ammoTweakSelectionItems itm
++ map f (makeParagraph 60 $ yourAugmentedItem itemInfo (yourInfo (you w)) (closeObjectInfo (crNumFreeSlots (you w))) w)
)
<> drawSelectionList
secondColumnParams
cfig
( defaultSelectionList & slItems .~ ammoTweakSelectionItems itm
++ map
f
( makeParagraph 60 $
yourAugmentedItem
itemInfo
(yourInfo (you w))
(closeObjectInfo (crNumFreeSlots (you w)))
w
)
)
where
itm = yourItem w
f str =
@@ -78,8 +85,7 @@ drawExamineInventory cfig mtweaki w =
{ _siPictures = [str]
, _siHeight = 1
, _siIsSelectable = True
, --, _siWidth = length str
_siColor = white
, _siColor = white
, _siOffX = 0
, _siPayload = ()
}
@@ -104,7 +110,7 @@ yourAugmentedItem f x g w = case you w ^? crManipulation . manObject of
drawNoSubInventory :: Configuration -> World -> Picture
drawNoSubInventory cfig w =
pictures
fold
[ equipcursors
, equipcursor -- the order is important, this should go on top of the other equipcursors
, rboptions
@@ -134,8 +140,6 @@ examineInventoryExtra mtweaki mitm cfig = fromMaybe mempty $ do
tparam <- mitm ^? _Just . itTweaks . tweakParams . ix tweaki
return $ listCursorNSW subInvX 60 cfig tweaki 0 white (length $ showTweak tparam) 15
-- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm))
combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture
combineInventoryExtra sss cfig w = fromMaybe mempty $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
@@ -204,13 +208,9 @@ 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 col 0 ()
thesellist tm =
defaultSelectionList
{ _slItems = thelist tm
-- , _slLength = length (thelist tm)
}
defaultSelectionList & slItems .~ thelist tm
thelist tm =
map toselitm . displayTermInput tm
. reverse
@@ -218,11 +218,12 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
$ _tmDisplayedLines tm
displayTermInput tm = case _tmInput tm of
TerminalInput s hasfoc _ -> (++ [(displayInputText tm s ++ displayBlinkCursor hasfoc, white)])
partcommand tm = fromMaybe "" $ tm ^? tmPartialCommand . _Just
displayInputText tm s
| _tmStatus tm == TerminalReady = '>' : s
| _tmStatus tm == TerminalReady = partcommand tm ++ "> " ++ s
| otherwise = ""
displayBlinkCursor hasfoc
| hasfoc = clockCycle 10 (V.fromList ["_", ""]) w
| hasfoc = clockCycle 10 (V.fromList ["_", "."]) w
| otherwise = []
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
@@ -276,8 +277,7 @@ combineCounts cfig w = foldMap f . group
f _ = mempty
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
lnkMidPosInvSelsCol cfig w i col =
foldMap f
lnkMidPosInvSelsCol cfig w i col = foldMap f
where
f j = fromMaybe mempty $ do
sss <- w ^? hud . hudElement . diSections
@@ -301,7 +301,7 @@ tweakString tp = rightPad 12 ' ' (show $ _tweakType tp) ++ " " ++ showTweak tp
invHead :: Configuration -> String -> Picture
invHead cfig =
translate (- halfWidth cfig + subInvX + 20) (halfHeight cfig - 40)
translate (- halfWidth cfig + subInvX + 20) (halfHeight cfig - 40)
. dShadCol white
. scale 0.4 0.4
. text
@@ -310,15 +310,16 @@ drawCarte :: Configuration -> World -> Picture
drawCarte cfig w =
pictures $
renderListAt 0 0 cfig locs :
-- zipWith bConnect (displayListEndCoords cfig locTexts) locPoss
-- ++
-- zipWith bConnect (displayListEndCoords cfig locTexts) locPoss
-- ++
mapOverlay w
++ [mainListCursor white iPos cfig]
where
iPos = w ^. cWorld . lWorld . selLocation
locs = map (\(_, s) -> (s, white)) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locPoss = map (cartePosToScreen cfig (w ^. hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locTexts = map fst locs
--locPoss = map (cartePosToScreen cfig (w ^. hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locTexts = map fst locs
--displayListEndCoords :: Configuration -> [String] -> [Point2]
--displayListEndCoords cfig ss = map (doWindowScale cfig) $ zipWith h ss $ map f [1 ..]
@@ -399,8 +400,7 @@ picsToSelectable pics =
{ _siPictures = pics
, _siHeight = length pics
, _siIsSelectable = True
, --, _siWidth = wdth
_siColor = white
, _siColor = white
, _siOffX = 0
, _siPayload = ()
}
@@ -418,8 +418,8 @@ openCursorAt ::
Configuration ->
Picture
openCursorAt wth col xoff yoff yint w =
translate (xoff - halfWidth w) (halfHeight w - (20 * fromIntegral yint + yoff) - 20)
$ lineCol
translate (xoff - halfWidth w) (halfHeight w - (20 * fromIntegral yint + yoff) - 20) $
lineCol
[ (V2 wth 12.5, withAlpha 0 col)
, (V2 0 12.5, col)
, (V2 0 (-7.5), col)