From 03b793802f92410c091a6c7c816eb1660a0e80af Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 19 May 2023 18:24:53 +0100 Subject: [PATCH] Cleanup, stop drawing space characters --- src/Dodge/DisplayInventory.hs | 11 +++-------- src/Dodge/Inventory/SelectionList.hs | 2 +- src/Dodge/Item/Display.hs | 4 ++-- src/Dodge/Render/List.hs | 2 -- src/Picture/Base.hs | 4 +++- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 3e7eed0a2..80809b22c 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TupleSections #-} +--{-# LANGUAGE TupleSections #-} --{-# OPTIONS_GHC -fno-full-laziness #-} @@ -195,11 +195,10 @@ updateSection sis mcsel availablelines ss = scurs = do csel <- mcsel (_, si) <- IM.lookupGE csel sis -- this is not right? - let cpos = sum (fmap ( _siHeight) . fst . IM.split csel $ sis) + let cpos = sum (fmap _siHeight . fst . IM.split csel $ sis) csize = length $ _siPictures si ccolor = _siColor si return $ SectionCursor (cpos - offset) csize ccolor - --return $ SectionCursor (cpos - offset) 1 ccolor nocursoroffset = if length allstrings - oldoffset <= availablelines then max 0 (length allstrings - availablelines) @@ -242,19 +241,15 @@ updateSection sis mcsel availablelines ss = | otherwise = tweakfirst shownstrings moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1 allstrings :: [(Color, Picture)] - --allstrings = foldMap g sis allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis shownstrings = drop offset allstrings - --h (col, str) = color col . text $ theindent ++ str - h (col, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str + h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str theindent = replicate (_ssIndent ss) ' ' --xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss - g si = map (_siColor si,) $ _siPictures si overlapSelectionItems :: [SelectionItem a] -> IM.IntMap (Color, Picture) overlapSelectionItems = go 0 where - --go :: Int -> [SelectionItem a] -> IM.IntMap (Picture,Color) go _ [] = mempty go i (si : xs) = doinsert $ go (i + _siHeight si) xs where diff --git a/src/Dodge/Inventory/SelectionList.hs b/src/Dodge/Inventory/SelectionList.hs index 6aacc85a8..3c1720a93 100644 --- a/src/Dodge/Inventory/SelectionList.hs +++ b/src/Dodge/Inventory/SelectionList.hs @@ -15,7 +15,7 @@ import Picture.Base invSelectionItem :: Creature -> Int -> Item -> SelectionItem () invSelectionItem cr i it = SelectionItem - { _siPictures = (pics & ix 0 %~ (++ anyequippos ++ anyhotkey)) + { _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey) , _siHeight = itSlotsTaken it , _siIsSelectable = True , _siColor = col diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index e597dab50..1267caa55 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -21,7 +21,7 @@ itemDisplay cr itm = --itemDisplayWithNumber (showConsumption cr it) it zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr itm) zipWithDefaults :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c] -zipWithDefaults f g h xs ys = go xs ys +zipWithDefaults f g h = go where go [] bs = map g bs go as [] = map f as @@ -113,7 +113,7 @@ showReloadProgress' cr itm = case ic ^? laSource of x <- ic ^? laSource . _InternalSource . iaLoaded return $ show x Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic) - Just AboveSource -> fromMaybe "XXXX" $ do + Just AboveSource -> fromMaybe "||||" $ do i <- fmap (subtract 1) $ itm ^? itLocation . ipInvID _ <- cr ^? crInv . ix i . itUse . equipEffect . eeUse . euseAmmoAmount --return $ showIntKMG' x diff --git a/src/Dodge/Render/List.hs b/src/Dodge/Render/List.hs index 61944f851..2d482a0b4 100644 --- a/src/Dodge/Render/List.hs +++ b/src/Dodge/Render/List.hs @@ -19,7 +19,6 @@ import Dodge.Data.Config import Dodge.Data.SelectionList import Dodge.ScreenPos import Dodge.SelectionList -import Dodge.SelectionSections import Geometry import LensHelp import ListHelp @@ -86,7 +85,6 @@ stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i -1 ..] selSecDrawCursor :: Int -> ListDisplayParams -> SelectionSections a -> Picture selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do (i, j) <- sss ^? sssExtra . sssSelPos . _Just - --yint <- selSecYint i j sss yint <- sss ^? sssSections . ix i . ssCursor . _Just . scurPos xint <- sss ^? sssSections . ix i . ssIndent si <- sss ^? sssSections . ix i . ssItems . ix j diff --git a/src/Picture/Base.hs b/src/Picture/Base.hs index 628004233..1147d1732 100644 --- a/src/Picture/Base.hs +++ b/src/Picture/Base.hs @@ -329,7 +329,9 @@ stringToList gap = concatMap (uncurry charToTuple) . zip [0, 100 + gap ..] charToTuple :: Float -> Char -> [(Point3, Point4, Point3)] {-# INLINE charToTuple #-} -charToTuple xoff c = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1] +charToTuple xoff c + | fromEnum c == 32 = [] -- don't draw space characters + | otherwise = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1] where f x y = (V3 (xoff + x * 100) (y * 200) 0, white, V3 x (1 - y) charnum) -- textures in opengl have origins at the lower left, my char array has its