From f12c39077842013e7b78a76a0279e32a570dd73d Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 26 Nov 2024 21:53:49 +0000 Subject: [PATCH] Add selection item width --- src/Dodge/Combine.hs | 1 + src/Dodge/Data/SelectionList.hs | 2 ++ src/Dodge/DisplayInventory.hs | 11 ++++++----- src/Dodge/Inventory/SelectionList.hs | 3 +++ src/Dodge/Menu/Option.hs | 1 + src/Dodge/Render/HUD.hs | 20 +++++++++++++------- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Dodge/Combine.hs b/src/Dodge/Combine.hs index dfa9cf5f7..0f076dccc 100644 --- a/src/Dodge/Combine.hs +++ b/src/Dodge/Combine.hs @@ -24,6 +24,7 @@ combineList = map f . combineItemListYouX SelectionItem { _siPictures = basicItemDisplay itm , _siHeight = _itInvSize itm + , _siWidth = 15 , _siIsSelectable = True , _siColor = itemInvColor . pciToCI $ basePCI itm , _siOffX = 0 diff --git a/src/Dodge/Data/SelectionList.hs b/src/Dodge/Data/SelectionList.hs index 07c4422db..456c34443 100644 --- a/src/Dodge/Data/SelectionList.hs +++ b/src/Dodge/Data/SelectionList.hs @@ -45,6 +45,7 @@ data SelectionItem a = SelectionItem { _siPictures :: [String] , _siHeight :: Int + , _siWidth :: Int , _siIsSelectable :: Bool , _siColor :: Color , _siOffX :: Int @@ -53,6 +54,7 @@ data SelectionItem a | SelectionInfo { _siPictures :: [String] , _siHeight :: Int + , _siWidth :: Int , _siIsSelectable :: Bool , _siColor :: Color , _siOffX :: Int diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 45c72b339..c603eb466 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -170,11 +170,11 @@ updateDisplaySections w cfig = btitems = IM.fromDistinctAscList . zip [0 ..] $ mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons) - 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) + makehead str i = (i, IM.singleton 0 $ SelectionInfo [str] 1 15 False white 0) + statushead = (-4, IM.singleton 0 $ SelectionInfo ["STATUS"] 1 15 False white 0) + statusdisplay = (-3, IM.singleton 0 $ SelectionInfo ["HEALTH: " ++ show (_crHP cr)] 1 15 False white 0) invhead = if null sfinv then makehead "INVENTORY" (-1) else filtinv - youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 () + youitems = IM.singleton 0 $ SelectionItem [thetext] 1 15 True invDimColor 2 () thetext = displayFreeSlots (crNumFreeSlots cr) closeitms = IM.fromDistinctAscList . zip [0 ..] $ @@ -207,6 +207,7 @@ filterSectionsPair infocus filtfn itms filtdescription mfilt = (filtsis, itms') $ SelectionInfo [filtdescription ++ " FILTER/" ++ str ++ [filtcurs], numfiltitems] 2 + 15 True white 0 @@ -370,7 +371,7 @@ enterCombineInv cfig w = cm | null cm' = IM.singleton 0 $ - SelectionInfo ["No possible combinations"] 1 False white 0 + SelectionInfo ["No possible combinations"] 1 25 False white 0 | otherwise = cm' selpos | null cm' = Nothing diff --git a/src/Dodge/Inventory/SelectionList.hs b/src/Dodge/Inventory/SelectionList.hs index f07440cdf..182d14eb6 100644 --- a/src/Dodge/Inventory/SelectionList.hs +++ b/src/Dodge/Inventory/SelectionList.hs @@ -23,6 +23,7 @@ invSelectionItem indent cr i ci = SelectionItem { _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey) , _siHeight = _itInvSize $ _cItem ci + , _siWidth = 15 , _siIsSelectable = True , _siColor = col , _siOffX = indent @@ -57,6 +58,7 @@ closeItemToSelectionItem w (NInt i) = do SelectionItem { _siPictures = pics , _siHeight = length pics + , _siWidth = 15 , _siIsSelectable = True , _siColor = col , _siOffX = 0 @@ -70,6 +72,7 @@ closeButtonToSelectionItem w i = do SelectionItem { _siPictures = [_btText bt] , _siHeight = 1 + , _siWidth = 15 , _siIsSelectable = True , _siColor = yellow , _siOffX = 0 diff --git a/src/Dodge/Menu/Option.hs b/src/Dodge/Menu/Option.hs index 217dabaff..6b54be401 100644 --- a/src/Dodge/Menu/Option.hs +++ b/src/Dodge/Menu/Option.hs @@ -100,6 +100,7 @@ menuOptionToSelectionItem w padAmount mo = SelectionItem { _siPictures = [optionText] , _siHeight = 1 + , _siWidth = 50 , _siIsSelectable = isselectable , _siColor = thecol , _siOffX = 0 diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index c98cbb384..ee8e83478 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -204,6 +204,7 @@ drawExamineInventory cfig w = f str = SelectionItem { _siPictures = [str] + , _siWidth = 55 , _siHeight = 1 , _siIsSelectable = True , _siColor = white @@ -366,7 +367,8 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do (drawSelectionListBackground secondColumnParams cfig tsize) <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig) where - toselitm (str, col) = SelectionItem [str] 1 True col 0 () + toselitm (str, col) = SelectionItem [str] 1 55 True col 0 () + -- not sure if the width (55) is correct here thesellist tm = thelist tm thelist tm = map toselitm . displayTermInput tm @@ -476,17 +478,21 @@ selNumPosCardinal :: Maybe Point2 selNumPosCardinal card cfig ldp sss i j = do ipos <- selSecYint i j sss - size <- selSecSelSize i j sss - itmindent <- sss ^? ix i . ssItems . ix j . siOffX - sindent <- sss ^? ix i . ssIndent +-- size <- selSecSelSize i j sss + ysize <- fromIntegral <$> sss ^? ix i . ssItems . ix j . siHeight + xsize <- fromIntegral <$> sss ^? ix i . ssItems . ix j . siWidth + itmindent <- fromIntegral <$> sss ^? ix i . ssItems . ix j . siOffX + sindent <- fromIntegral <$> sss ^? ix i . ssIndent let indent = itmindent + sindent - let offset = cardEightVec card * V2 0 (fromIntegral size * 0.5 * 20 * s) + let offset = cardEightVec card * V2 + (xsize * 0.5 * 10 * s) + (ysize * 0.5 * 20 * s) return $ screenPosAbs cfig (ldp ^. ldpPos) + offset + V2 - (10 * s * fromIntegral indent) - (negate (20 * s + ygap) * (fromIntegral ipos + fromIntegral size * 0.5)) + (10 * s * (indent + xsize * 0.5)) + (negate (20 * s + ygap) * (fromIntegral ipos + ysize * 0.5)) where s = _ldpScale ldp ygap = _ldpVerticalGap ldp