Add capability to examine you (empty slots) and close objects
This commit is contained in:
+45
-18
@@ -3,7 +3,7 @@ module Dodge.Render.HUD (
|
||||
drawHUD,
|
||||
) where
|
||||
|
||||
import Justify
|
||||
import Dodge.Creature.Info
|
||||
import Control.Lens
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
@@ -27,6 +27,7 @@ import Dodge.Tweak.Show
|
||||
import Dodge.WorldPos
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import Justify
|
||||
import ListHelp
|
||||
import Padding
|
||||
import Picture
|
||||
@@ -70,7 +71,7 @@ defaultSubInvSelectionList =
|
||||
invDisplayParams :: World -> ListDisplayParams
|
||||
invDisplayParams w =
|
||||
defaultListDisplayParams
|
||||
-- & ldpWidth .~ FixedSelectionWidth topInvW
|
||||
-- & ldpWidth .~ FixedSelectionWidth topInvW
|
||||
& ldpCursorType .~ BorderCursor selcursortype
|
||||
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
|
||||
where
|
||||
@@ -88,21 +89,29 @@ drawSubInventory :: SubInventory -> Configuration -> World -> Picture
|
||||
drawSubInventory subinv cfig w = case subinv of
|
||||
LockedInventory -> mempty -- topInvCursor col cursPos cfig w
|
||||
NoSubInventory -> drawNoSubInventory cfig w
|
||||
ExamineInventory mtweaki ->
|
||||
titledSub
|
||||
"EXAMINE"
|
||||
(defaultSubInvSelectionList & slItems .~ ammoTweakSelectionItems itm ++ map f (mitmInfo itm))
|
||||
<> examineInventoryExtra mtweaki itm cfig
|
||||
ExamineInventory mtweaki -> drawExamineInventory cfig mtweaki w
|
||||
DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld)
|
||||
CombineInventory mi ->
|
||||
titledSub
|
||||
cfig
|
||||
"COMBINE"
|
||||
(combineListSelection w mi)
|
||||
<> combineInventoryExtra mi cfig w
|
||||
|
||||
titledSub :: Configuration -> String -> SelectionList a -> Picture
|
||||
titledSub cfig subtitle subitems =
|
||||
invHead cfig subtitle
|
||||
<> drawSelectionList secondColumnParams cfig subitems
|
||||
|
||||
drawExamineInventory :: Configuration -> Maybe Int -> World -> Picture
|
||||
drawExamineInventory cfig mtweaki w =
|
||||
titledSub
|
||||
cfig
|
||||
"EXAMINE"
|
||||
(defaultSubInvSelectionList & slItems .~ ammoTweakSelectionItems itm
|
||||
++ map f (makeParagraph 60 $ yourAugmentedItem itemInfo (yourInfo (you w)) (closeObjectInfo (crNumFreeSlots (you w)) ) w))
|
||||
<> examineInventoryExtra mtweaki itm cfig
|
||||
where
|
||||
titledSub subtitle subitems =
|
||||
invHead cfig subtitle
|
||||
<> drawSelectionList secondColumnParams cfig subitems
|
||||
itm = yourItem w
|
||||
f str =
|
||||
SelectionItem
|
||||
@@ -115,6 +124,25 @@ drawSubInventory subinv cfig w = case subinv of
|
||||
, _siPayload = ()
|
||||
}
|
||||
|
||||
closeObjectInfo :: Int -> Either FloorItem Button -> String
|
||||
closeObjectInfo n x = case x of
|
||||
Left (FlIt {_flIt = itm}) -> "This item is on the floor " ++ floorItemPickupInfo n itm ++ itemInfo itm
|
||||
Right _ -> "This is some sort of switch or button."
|
||||
|
||||
floorItemPickupInfo :: Int -> Item -> String
|
||||
floorItemPickupInfo n itm
|
||||
| n >= ceiling (_itInvSize itm) = ", but you have space to pick it up. "
|
||||
| otherwise = " and you don't have space to pick it up. "
|
||||
|
||||
yourAugmentedItem :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> a
|
||||
yourAugmentedItem f x g w
|
||||
| i < n = f $ yourInv w ^?! ix i
|
||||
| i == n = x
|
||||
| otherwise = g $ w ^?! hud . closeObjects . ix (i - n - 1)
|
||||
where
|
||||
i = crSel (you w)
|
||||
n = length $ yourInv w
|
||||
|
||||
drawNoSubInventory :: Configuration -> World -> Picture
|
||||
drawNoSubInventory cfig w =
|
||||
pictures
|
||||
@@ -132,7 +160,7 @@ drawNoSubInventory cfig w =
|
||||
cfig
|
||||
(Just i)
|
||||
(inventorySelectionList w)
|
||||
equipcursor = case cr ^. crLeftInvSel . lisMPos of
|
||||
equipcursor = case cr ^. crLeftInvSel . lisMPos of
|
||||
Just invid -> f cyan invid (_crInvEquipped cr IM.! invid)
|
||||
_ -> mempty
|
||||
equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr)
|
||||
@@ -150,7 +178,7 @@ examineInventoryExtra mtweaki mitm cfig =
|
||||
-- consider moving this functionality out into a tweaks module
|
||||
tparam <- mitm ^? _Just . itTweaks . tweakParams . ix tweaki
|
||||
return $ listCursorNSW subInvX 60 cfig tweaki white (length $ showTweak tparam) 15
|
||||
-- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm))
|
||||
-- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm))
|
||||
]
|
||||
|
||||
combineInventoryExtra :: Maybe Int -> Configuration -> World -> Picture
|
||||
@@ -201,9 +229,6 @@ secondColumnParams =
|
||||
-- , _siPayload = ()
|
||||
-- }
|
||||
|
||||
mitmInfo :: Maybe Item -> [String]
|
||||
mitmInfo = maybe [] $ makeParagraph 60 . itmInfo
|
||||
|
||||
displayTerminal :: Int -> Configuration -> LWorld -> Picture
|
||||
displayTerminal tid cfig w = fromMaybe mempty $ do
|
||||
tm <- w ^? terminals . ix tid
|
||||
@@ -301,8 +326,9 @@ determineInvSelCursorWidth :: World -> Int
|
||||
determineInvSelCursorWidth w = case _rbOptions w of
|
||||
NoRightButtonOptions -> topInvW
|
||||
EquipOptions{}
|
||||
| ButtonRight `M.member` _mouseButtons (_input w)
|
||||
&& w ^? hud . hudElement . subInventory == Just NoSubInventory -> 47
|
||||
| ButtonRight `M.member` _mouseButtons (_input w)
|
||||
&& w ^? hud . hudElement . subInventory == Just NoSubInventory ->
|
||||
47
|
||||
| otherwise -> topInvW
|
||||
|
||||
combineListSelection :: World -> Maybe Int -> SelectionList ()
|
||||
@@ -365,8 +391,9 @@ mapOverlay :: Configuration -> World -> [Picture]
|
||||
mapOverlay cfig w =
|
||||
(color (withAlpha 0.5 black) . polygon $ reverse $ rectNSWE 1 (-1) 1 (-1)) :
|
||||
[foldMap (drawMapWall cfig (w ^. hud)) $ IM.restrictKeys (lw ^. walls) (w ^. cWorld . seenWalls)]
|
||||
--(mapMaybe (mapWall cfig (w ^. hud)) . IM.elems $ w ^. cWorld . lWorld . walls)
|
||||
where
|
||||
--(mapMaybe (mapWall cfig (w ^. hud)) . IM.elems $ w ^. cWorld . lWorld . walls)
|
||||
|
||||
lw = w ^. cWorld . lWorld
|
||||
|
||||
drawMapWall :: Configuration -> HUD -> Wall -> Picture
|
||||
|
||||
Reference in New Issue
Block a user