Replace length . _siPictures with _siHeight

This commit is contained in:
2025-01-05 17:31:37 +00:00
parent 27ffeb3a5a
commit 57d36855d8
4 changed files with 41 additions and 50 deletions
+11 -22
View File
@@ -1,7 +1,7 @@
-- {-# OPTIONS_GHC -fno-full-laziness #-}
--{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
--{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BangPatterns #-}
module Dodge.DisplayInventory (
updateInventoryPositioning,
@@ -9,7 +9,7 @@ module Dodge.DisplayInventory (
toggleCombineInv,
) where
--import StrictHelp
import StrictHelp
import Dodge.Item.Display
import qualified Data.Strict.Tuple as STup
import Control.Applicative
@@ -52,7 +52,6 @@ updateCombineSections ::
IM.IntMap (SelectionSection CombinableItem)
updateCombineSections w cfig =
updateSectionsPositioning
(const 5)
(const 0)
(w ^? hud . hudElement . subInventory . ciSelection . _Just)
(getAvailableListLines secondColumnParams cfig)
@@ -113,11 +112,6 @@ checkCombineSelectionExists si
%~ scrollSelectionSections (-1) sss
| otherwise = si
displaySectionsSizes :: Int -> Int
displaySectionsSizes 0 = 10
displaySectionsSizes 3 = 10
displaySectionsSizes _ = 3
displayIndents :: Int -> Int
displayIndents 0 = 2
displayIndents 3 = 2
@@ -131,7 +125,6 @@ updateDisplaySections ::
IM.IntMap (SelectionSection ())
updateDisplaySections w cfig =
updateSectionsPositioning
displaySectionsSizes
displayIndents
mselpos
(getAvailableListLines invDP cfig)
@@ -224,20 +217,17 @@ displayFreeSlots x = case x of
1 -> "1 FREE SLOT"
_ -> show x ++ " FREE SLOTS"
sectionsDesiredLines ::
IM.IntMap (IM.IntMap (SelectionItem a)) ->
IM.IntMap Int
sectionsDesiredLines :: IM.IntMap (IM.IntMap (SelectionItem a)) -> IM.IntMap Int
sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight
sectionsSizes ::
Int -> -- total available lines
(Int -> Int) -> -- minimum line bounds for each section
[Int] -> -- ordering in which to consider sections (others to be done lowest to highest)
IM.IntMap Int -> -- desired lines
IM.IntMap Int
sectionsSizes x f is sss = doSectionSize extraavailable mintaken is sss mempty
sectionsSizes x is sss = doSectionSize extraavailable mintaken is sss mempty
where
mintaken = IM.mapWithKey (min . f) sss
mintaken = IM.mapWithKey (min . const 10) sss
extraavailable = x - sum mintaken
doSectionSize ::
@@ -267,18 +257,16 @@ doSectionSize extraavailable mintaken is sss done = fromMaybe done $ do
return (v, s', k, [])
updateSectionsPositioning ::
(Int -> Int) -> -- for determining each sections minimum size
(Int -> Int) -> -- for determining each sections indent
Maybe (Int, Int, IntSet) ->
Int ->
[(Int, IM.IntMap (SelectionItem a))] ->
IM.IntMap (SelectionSection a) ->
IM.IntMap (SelectionSection a)
updateSectionsPositioning f h mselpos allavailablelines lsss sss =
updateSectionsPositioning h mselpos allavailablelines lsss sss =
IM.intersectionWithKey (\k -> updateSection (h k) (m k)) ls ssizes `g` offsets
where
offsets = fmap _ssOffset sss
--offsets = mempty
m k = do
(k', i, _) <- mselpos
guard $ k == k'
@@ -287,7 +275,7 @@ updateSectionsPositioning f h mselpos allavailablelines lsss sss =
-- defaults non-existing offsets to 0
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
lk = mselpos ^.. _Just . _1
ssizes = sectionsSizes allavailablelines f lk $ sectionsDesiredLines ls
ssizes = sectionsSizes allavailablelines lk $ sectionsDesiredLines ls
updateSection ::
Int ->
@@ -312,8 +300,9 @@ updateSection indent mcsel sis availablelines oldoffset =
offset = fromMaybe oldoffsetbounded $ do
csel <- mcsel
maxcsel <- fst <$> IM.lookupMax sis
xselsize <- fmap length $ sis ^? ix csel . siPictures
return $ case sum $ fmap (length . _siPictures) . fst . IM.split csel $ sis of
-- xselsize <- fmap length $ sis ^? ix csel . siPictures
xselsize <- sis ^? ix csel . siHeight
return $ case sum $ fmap _siHeight . fst . IM.split csel $ sis of
pos | pos == 0 || aslength <= availablelines -> 0
pos | pos - 1 < oldoffset -> pos - 1
pos | maxcsel == csel -> pos - availablelines + xselsize
@@ -338,7 +327,7 @@ updateSection indent mcsel sis availablelines oldoffset =
listSelectionColorPicture :: SelectionItem a -> ([STup.Pair Color Picture], Sum Int)
listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
where
g str =
g !str =
_siColor si STup.:!:
translate lindent 0 (color (_siColor si) $ text str)
lindent = 100 * fromIntegral (_siOffX si)
+1 -1
View File
@@ -178,7 +178,7 @@ ssLookupGE' i sss = do
Nothing -> ssLookupGT' i' sss
selSecSelSize :: Int -> Int -> IM.IntMap (SelectionSection a) -> Maybe Int
selSecSelSize i j = fmap length . (^? ix i . ssItems . ix j . siPictures)
selSecSelSize i j = (^? ix i . ssItems . ix j . siHeight)
-- need to check that the vertical gap is correctly put in here
posSelSecYint :: Configuration -> ListDisplayParams -> Float -> Int
+4 -2
View File
@@ -5,6 +5,7 @@ module Dodge.Update.Input.InGame (
updateMouseInGame,
) where
import Dodge.Item.Display
import Control.Applicative
import Control.Monad
import Data.Foldable
@@ -240,8 +241,9 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
guard $ i == 0
str <-
fmap (take 5) $
w
^? hud . hudElement . diSections . ix i . ssItems . ix j . siPictures . ix 0
w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix j
>>= (listToMaybe . basicItemDisplay)
-- ^? hud . hudElement . diSections . ix i . ssItems . ix j . siPictures . ix 0
return . (worldEventFlags . at CombineInventoryChange ?~ ()) $
case w ^? hud . hudElement . subInventory . ciFilter . _Just of
Just (_ : xs)
+25 -25
View File
@@ -3405,7 +3405,7 @@ ammoMagSPic src/Dodge/Item/Draw/SPic.hs 123;" f
amr src/Dodge/Item/Held/Rod.hs 44;" f
analyser src/Dodge/Placement/Instance/Analyser.hs 12;" f
analyserByDoor src/Dodge/Room/LasTurret.hs 76;" f
andOrRegex src/Dodge/DisplayInventory.hs 80;" f
andOrRegex src/Dodge/DisplayInventory.hs 84;" f
angleBetween src/Geometry.hs 159;" f
angleVV src/Geometry/Vector.hs 57;" f
angleVV3 src/Geometry/Vector3D.hs 122;" f
@@ -3617,7 +3617,7 @@ chaseCritAwarenessUpdate src/Dodge/Creature/Perception.hs 69;" f
chaseCritMv src/Dodge/Creature/ReaderUpdate.hs 112;" f
chaseCritPerceptionUpdate src/Dodge/Creature/Perception.hs 30;" f
chaseCritVocalization src/Dodge/Creature/ChaseCrit.hs 43;" f
checkCombineSelectionExists src/Dodge/DisplayInventory.hs 102;" f
checkCombineSelectionExists src/Dodge/DisplayInventory.hs 106;" f
checkConnection src/Dodge/Inventory/Swap.hs 64;" f
checkDeath src/Dodge/Creature/State.hs 78;" f
checkEndGame src/Dodge/Update.hs 703;" f
@@ -3625,7 +3625,7 @@ checkErrorGL src/Shader/Compile.hs 255;" f
checkFBO src/Framebuffer/Check.hs 6;" f
checkGLError src/GLHelp.hs 17;" f
checkInvSlotsYou src/Dodge/Inventory/CheckSlots.hs 16;" f
checkInventorySelectionExists src/Dodge/DisplayInventory.hs 95;" f
checkInventorySelectionExists src/Dodge/DisplayInventory.hs 99;" f
checkTermDist src/Dodge/Update.hs 311;" f
checkWallLeft src/Dodge/LevelGen/StaticWalls/Deprecated.hs 29;" f
checkWallRight src/Dodge/LevelGen/StaticWalls.hs 54;" f
@@ -4008,10 +4008,10 @@ disconnectTerminal src/Dodge/Terminal.hs 217;" f
displayConfig src/Dodge/Menu.hs 196;" f
displayControls src/Dodge/Menu.hs 206;" f
displayFrameTicks src/Dodge/Render/Picture.hs 39;" f
displayFreeSlots src/Dodge/DisplayInventory.hs 217;" f
displayIndents src/Dodge/DisplayInventory.hs 117;" f
displayFreeSlots src/Dodge/DisplayInventory.hs 221;" f
displayIndents src/Dodge/DisplayInventory.hs 121;" f
displayPulse src/Dodge/Item/Display.hs 136;" f
displaySectionsSizes src/Dodge/DisplayInventory.hs 112;" f
displaySectionsSizes src/Dodge/DisplayInventory.hs 116;" f
displayTerminalLineString src/Dodge/Update.hs 447;" f
dist src/Geometry/Vector.hs 179;" f
dist3 src/Geometry/Vector3D.hs 101;" f
@@ -4091,7 +4091,7 @@ doRoomOutPlacements src/Dodge/Layout.hs 107;" f
doRoomPlacements src/Dodge/Layout.hs 122;" f
doRoomShift src/Dodge/Room/Link.hs 33;" f
doScopeZoom src/Dodge/Update/Scroll.hs 82;" f
doSectionSize src/Dodge/DisplayInventory.hs 239;" f
doSectionSize src/Dodge/DisplayInventory.hs 243;" f
doSideEffects appDodge/Main.hs 120;" f
doStep src/Dodge/ArcStep.hs 9;" f
doStrategyActions src/Dodge/Creature/ReaderUpdate.hs 164;" f
@@ -4283,7 +4283,7 @@ encircleDistP src/Dodge/Creature/Boid.hs 21;" f
encircleP src/Dodge/Creature/Boid.hs 27;" f
endCombineRegex src/Dodge/Update/Input/InGame.hs 271;" f
endRegex src/Dodge/Update/Input/InGame.hs 258;" f
enterCombineInv src/Dodge/DisplayInventory.hs 356;" f
enterCombineInv src/Dodge/DisplayInventory.hs 355;" f
eqConstr src/SameConstr.hs 17;" f
eqPosText src/Dodge/Equipment/Text.hs 5;" f
eqSiteToPositions src/Dodge/Inventory/RBList.hs 75;" f
@@ -4332,7 +4332,7 @@ fdiv src/ShortShow.hs 26;" f
feet src/Dodge/Creature/Picture.hs 53;" f
ffoldM src/Framebuffer/Update.hs 79;" f
filter3 src/FoldableHelp.hs 76;" f
filterSectionsPair src/Dodge/DisplayInventory.hs 186;" f
filterSectionsPair src/Dodge/DisplayInventory.hs 190;" f
findBlips src/Dodge/RadarSweep.hs 62;" f
findBoundDists src/Dodge/Update/Camera.hs 205;" f
findClosePoint src/Dodge/LevelGen/StaticWalls.hs 155;" f
@@ -4648,7 +4648,7 @@ intsToPos src/Dodge/Room/Modify/Girder.hs 160;" f
invAdj src/Dodge/Item/Grammar.hs 289;" f
invCursorParams src/Dodge/ListDisplayParams.hs 36;" f
invDP src/Dodge/ListDisplayParams.hs 30;" f
invDimColor src/Dodge/DisplayInventory.hs 211;" f
invDimColor src/Dodge/DisplayInventory.hs 215;" f
invHead src/Dodge/Render/HUD.hs 404;" f
invItemLocUpdate src/Dodge/Creature/State.hs 178;" f
invLDT src/Dodge/Item/Grammar.hs 269;" f
@@ -4810,7 +4810,7 @@ listConfig src/Dodge/Menu.hs 199;" f
listControls src/Dodge/Menu.hs 212;" f
listCursorChooseBorderScale src/Dodge/Render/List.hs 135;" f
listGuard src/Dodge/Creature/ReaderUpdate.hs 188;" f
listSelectionColorPicture src/Dodge/DisplayInventory.hs 339;" f
listSelectionColorPicture src/Dodge/DisplayInventory.hs 338;" f
litCorridor90 src/Dodge/Room/RoadBlock.hs 26;" f
llleft src/Dodge/Item/Grammar.hs 195;" f
llright src/Dodge/Item/Grammar.hs 201;" f
@@ -5123,7 +5123,7 @@ optionScreenUpdate src/Dodge/Update/Input/ScreenLayer.hs 41;" f
optionValueOffset src/Dodge/Menu/Option.hs 89;" f
optionsOptions src/Dodge/Menu.hs 108;" f
optionsToSelections src/Dodge/Menu/Option.hs 51;" f
orRegex src/Dodge/DisplayInventory.hs 83;" f
orRegex src/Dodge/DisplayInventory.hs 87;" f
orange src/Color.hs 25;" f
orderAround3 src/Geometry/Vector3D.hs 105;" f
orderAroundFirst src/Geometry/Polygon.hs 82;" f
@@ -5224,7 +5224,7 @@ placeSpotRoomRand src/Dodge/Placement/PlaceSpot.hs 89;" f
placeSpotUsingLink src/Dodge/Placement/PlaceSpot.hs 70;" f
placeString src/Dodge/Render/MenuScreen.hs 64;" f
placeWallPoly src/Dodge/Placement/PlaceSpot.hs 162;" f
plainRegex src/Dodge/DisplayInventory.hs 214;" f
plainRegex src/Dodge/DisplayInventory.hs 218;" f
playIfFree src/Sound.hs 136;" f
playPositionalSoundQueue src/Sound.hs 144;" f
playSoundAndUpdate src/Sound.hs 54;" f
@@ -5459,8 +5459,8 @@ reflectInParam src/Geometry.hs 247;" f
reflectLaserAlong src/Dodge/Item/Weapon/LaserPath.hs 13;" f
refract src/Dodge/Item/Weapon/LaserPath.hs 40;" f
refreshOptionsSelectionList src/Dodge/Menu/Option.hs 39;" f
regexCombs src/Dodge/DisplayInventory.hs 70;" f
regexList src/Dodge/DisplayInventory.hs 347;" f
regexCombs src/Dodge/DisplayInventory.hs 73;" f
regexList src/Dodge/DisplayInventory.hs 346;" f
reload1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 448;" f
reloadLevelStart src/Dodge/Save.hs 71;" f
reloadS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 446;" f
@@ -5627,8 +5627,8 @@ seagullWhistle1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 378;" f
seagullWhistleS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 540;" f
searchIfDamaged src/Dodge/Creature/ReaderUpdate.hs 203;" f
secondColumnParams src/Dodge/ListDisplayParams.hs 43;" f
sectionsDesiredLines src/Dodge/DisplayInventory.hs 223;" f
sectionsSizes src/Dodge/DisplayInventory.hs 228;" f
sectionsDesiredLines src/Dodge/DisplayInventory.hs 227;" f
sectionsSizes src/Dodge/DisplayInventory.hs 232;" f
seedStartMenu src/Dodge/Menu.hs 79;" f
seedStartOptions src/Dodge/Menu.hs 82;" f
segOnCirc src/Geometry.hs 116;" f
@@ -5789,7 +5789,7 @@ singleLDT src/Dodge/DoubleTree.hs 12;" f
singleton src/DoubleStack.hs 11;" f
singletonTrie src/SimpleTrie.hs 19;" f
sizeFBOs src/Framebuffer/Update.hs 22;" f
sizeSelf src/Dodge/Creature/Action.hs 204;" f
sizeSelf src/Dodge/Creature/Action.hs 205;" f
skwareFadeTwoSecS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 384;" f
slap1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 506;" f
slapS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 450;" f
@@ -6026,7 +6026,7 @@ toTopLeft src/Dodge/Render/List.hs 219;" f
toV2 src/Geometry/Data.hs 36;" f
toV3 src/Geometry/Data.hs 38;" f
toV4 src/Geometry/Data.hs 40;" f
toggleCombineInv src/Dodge/DisplayInventory.hs 350;" f
toggleCombineInv src/Dodge/DisplayInventory.hs 349;" f
toggleCommand src/Dodge/Terminal.hs 196;" f
toggleEquipmentAt src/Dodge/Creature/Impulse/UseItem.hs 94;" f
toggleExamineInv src/Dodge/Creature/Impulse/UseItem.hs 132;" f
@@ -6168,14 +6168,14 @@ updateCamera src/Dodge/Update/Camera.hs 27;" f
updateCloseObjects src/Dodge/Inventory.hs 110;" f
updateCloud src/Dodge/Update.hs 731;" f
updateClouds src/Dodge/Update.hs 575;" f
updateCombinePositioning src/Dodge/DisplayInventory.hs 40;" f
updateCombineSections src/Dodge/DisplayInventory.hs 47;" f
updateCombinePositioning src/Dodge/DisplayInventory.hs 41;" f
updateCombineSections src/Dodge/DisplayInventory.hs 48;" f
updateCreature src/Dodge/Creature/Update.hs 13;" f
updateCreatureGroups src/Dodge/Update.hs 516;" f
updateCreatureSoundPositions src/Dodge/Update.hs 492;" f
updateDebugMessageOffset src/Dodge/Update.hs 91;" f
updateDelayedEvents src/Dodge/Update.hs 794;" f
updateDisplaySections src/Dodge/DisplayInventory.hs 123;" f
updateDisplaySections src/Dodge/DisplayInventory.hs 127;" f
updateDistortion src/Dodge/Distortion.hs 5;" f
updateDistortions src/Dodge/Update.hs 537;" f
updateEnergyBall src/Dodge/EnergyBall.hs 45;" f
@@ -6197,7 +6197,7 @@ updateIMl' src/Dodge/Update.hs 511;" f
updateInGameCamera src/Dodge/Update/Camera.hs 76;" f
updateInitialPressInGame src/Dodge/Update/Input/InGame.hs 435;" f
updateInv src/Dodge/Creature/State.hs 160;" f
updateInventoryPositioning src/Dodge/DisplayInventory.hs 88;" f
updateInventoryPositioning src/Dodge/DisplayInventory.hs 92;" f
updateItemTargeting src/Dodge/Creature/State.hs 377;" f
updateItemWithOrientation src/Dodge/Creature/State.hs 285;" f
updateKeyInGame src/Dodge/Update/Input/InGame.hs 429;" f
@@ -6235,8 +6235,8 @@ updateRenderSplit appDodge/Main.hs 108;" f
updateRootItemID src/Dodge/Inventory/Location.hs 35;" f
updateScopeZoom src/Dodge/Update/Scroll.hs 70;" f
updateScrollTestValue src/Dodge/ScrollValue.hs 6;" f
updateSection src/Dodge/DisplayInventory.hs 288;" f
updateSectionsPositioning src/Dodge/DisplayInventory.hs 265;" f
updateSection src/Dodge/DisplayInventory.hs 292;" f
updateSectionsPositioning src/Dodge/DisplayInventory.hs 269;" f
updateSeenWalls src/Dodge/Update.hs 683;" f
updateShockwave src/Dodge/Shockwave/Update.hs 12;" f
updateShockwaves src/Dodge/Update.hs 557;" f