From 2837f0d0af34c33e28aa3404334e9102009e1111 Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 5 Jan 2025 22:33:05 +0000 Subject: [PATCH] Stop displaying hotkeys and equip positions, fixes space leak --- src/Dodge/DisplayInventory.hs | 26 ++++++++++---------------- src/Dodge/Equipment/Text.hs | 2 +- src/Dodge/Inventory/SelectionList.hs | 10 ++++++---- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index d3addbeac..49a7acca5 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -16,7 +16,6 @@ module Dodge.DisplayInventory ( import Control.Applicative import Control.Lens import Control.Monad -import Data.Bifunctor import Data.IntMap.Merge.Strict import qualified Data.IntMap.Strict as IM import Data.IntSet (IntSet) @@ -66,7 +65,6 @@ updateCombineSections w cfig = (IM.fromDistinctAscList . zip [0 ..] $ combineList w) "COMBINATIONS" $ w ^? hud . hudElement . subInventory . ciFilter . _Just - --invitms = fold $ w ^? hud . hudElement . diSections . ix 0 . ssItems invitms = fold $ w ^? cWorld . lWorld . creatures . ix 0 . crInv --regexCombs :: IM.IntMap (SelectionItem ()) -> SelectionItem CombinableItem -> String -> Bool @@ -135,7 +133,7 @@ updateDisplaySections w cfig = [-1 .. 5] [ invhead , sinv - , youx + , IM.singleton 0 $ SelectionItem [displayFreeSlots (crNumFreeSlots cr)] 1 15 True invDimColor 2 () , nearbyhead , sclose , interfaceshead @@ -152,11 +150,7 @@ updateDisplaySections w cfig = (sfclose, sclose) = filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $ w ^? hud . hudElement . diCloseFilter . _Just - nearbyhead = - if null sfclose - then if null sclose then mempty else makehead "NEARBY ITEMS" - else sfclose - youx = youitems + nearbyhead = if null sfclose then makehead "NEARBY ITEMS" else sfclose interfaceshead = if null btitems then mempty else makehead "NEARBY INTERFACES" interfaces = btitems btitems = @@ -164,20 +158,20 @@ updateDisplaySections w cfig = mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons) makehead str = IM.singleton 0 $ SelectionInfo [str] 1 15 False white 0 invhead = if null sfinv then makehead "INVENTORY" else sfinv - youitems = IM.singleton 0 $ SelectionItem [thetext] 1 15 True invDimColor 2 () - thetext = displayFreeSlots (crNumFreeSlots cr) + cr = you w closeitms = IM.fromDistinctAscList . zip [0 ..] $ mapMaybe (closeItemToSelectionItem w) (w ^. hud . closeItems) invitems = IM.map (uncurry (invSelectionItem w)) - (fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr) - removeindentiffiltering = - if maybe False (not . null) (w ^? hud . hudElement . diInvFilter . _Just) - then const 0 - else id - cr = you w + (allInvLocs $ _crInv cr) + +-- (fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr) +-- removeindentiffiltering = +-- if maybe False (not . null) (w ^? hud . hudElement . diInvFilter . _Just) +-- then const 0 +-- else id filterSectionsPair :: Bool -> -- check for whether filter is in focus, changes string at the end diff --git a/src/Dodge/Equipment/Text.hs b/src/Dodge/Equipment/Text.hs index 3514b3e8d..240002544 100644 --- a/src/Dodge/Equipment/Text.hs +++ b/src/Dodge/Equipment/Text.hs @@ -5,7 +5,7 @@ import Dodge.Data.Equipment.Misc eqPosText :: EquipSite -> String eqPosText ep = case ep of OnHead -> "HEAD" - OnChest -> "CHESt" + OnChest -> "CHEST" OnBack -> "BACK" OnLeftWrist -> "L.WRIST" OnRightWrist -> "R.WRIST" diff --git a/src/Dodge/Inventory/SelectionList.hs b/src/Dodge/Inventory/SelectionList.hs index 84f22f7fe..9714e89ca 100644 --- a/src/Dodge/Inventory/SelectionList.hs +++ b/src/Dodge/Inventory/SelectionList.hs @@ -24,7 +24,8 @@ import Picture.Base invSelectionItem :: World -> Int -> LocationLDT ItemLink ComposedItem -> SelectionItem () invSelectionItem w indent loc = SelectionItem - { _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey) +-- { _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey) + { _siPictures = pics -- & ix 0 %~ (++ anyequippos ++ anyhotkey) , _siHeight = itInvHeight $ ci ^. _1 , _siWidth = 15 , _siIsSelectable = True @@ -38,7 +39,9 @@ invSelectionItem w indent loc = cr = lw ^?! creatures . ix 0 itid = ci ^. _1 . itID . unNInt anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . unNIntMap . ix itid) - anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText) + anyequippos = maybe + [] + (rightPad 8 ' ' . (' ' :) . eqPosText) (ci ^? _1 . itLocation . ilEquipSite . _Just) col = itemInvColor ci pics = itemDisplay w cr ci @@ -93,7 +96,6 @@ closeButtonToSelectionItem w i = do } closeItemToTextPictures :: FloorItem -> ([String], Color) -closeItemToTextPictures flit = - (basicItemDisplay it, itemInvColor $ baseCI it) +closeItemToTextPictures flit = (basicItemDisplay it, itemInvColor $ baseCI it) where it = _flIt flit