From b2de834bb7fd69aa8cce231d83adf06672d1decd Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 24 Nov 2024 12:51:20 +0000 Subject: [PATCH] Move status to list on left of screen --- ghcidOutput | 2 +- src/Dodge/Default/World.hs | 64 ++++++-------------------------- src/Dodge/DisplayInventory.hs | 9 +++-- src/Dodge/Update/Input/InGame.hs | 5 +-- 4 files changed, 20 insertions(+), 60 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index a483ac2dc..003a9f961 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (594 modules, at 12:24:25) +All good (594 modules, at 12:48:20) diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index e632b8bda..587539660 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -1,15 +1,14 @@ -module Dodge.Default.World where +module Dodge.Default.World ( + defaultWorld, +) where -import Color -import NewInt -import Control.Lens import Data.Graph.Inductive.Graph hiding ((&)) import qualified Data.Map as M -import Dodge.Data.SelectionList import Dodge.Data.World import Geometry.Data import Geometry.Polygon import qualified IntMapHelp as IM +import NewInt import System.Random defaultInput :: Input @@ -61,8 +60,8 @@ defaultCWGen = { _cwgParams = GenParams M.empty , _cwgSeed = 0 , _cwgWorldBounds = defaultBounds - , _cwgGameRooms = [] - , _cwgRoomClipping = [] + , _cwgGameRooms = mempty + , _cwgRoomClipping = mempty } defaultCWCam :: Camera @@ -77,7 +76,7 @@ defaultCWCam = , _camItemZoom = 1 , _camBoundBox = square 100 , _camBoundDist = (100, -100, 100, -100) - , _camControl = CamInGame {_cigType = CamOnPlayer} + , _camControl = CamInGame{_cigType = CamOnPlayer} } defaultCWorld :: CWorld @@ -113,9 +112,9 @@ defaultLWorld = , _energyBalls = [] , _radarBlips = [] , _flares = [] --- , _newBeams = WorldBeams [] [] [] [] --- , _beams = WorldBeams [] [] [] [] - , _teslaArcs = [] + , -- , _newBeams = WorldBeams [] [] [] [] + -- , _beams = WorldBeams [] [] [] [] + _teslaArcs = [] , _shockwaves = [] , _lasers = [] , _lasersToDraw = [] @@ -163,49 +162,10 @@ defaultHUD = defaultDisplayInventory :: HUDElement defaultDisplayInventory = DisplayInventory - { _subInventory = NoSubInventory - --, _diSections = defaultInvSections + { _subInventory = NoSubInventory , _diSections = mempty - , _diSelection = Just (1,0) + , _diSelection = Just (1, 0) , _diSelectionExtra = mempty , _diInvFilter = mempty , _diCloseFilter = mempty } - -defaultInvSections :: IM.IntMap (SelectionSection ()) -defaultInvSections = IM.fromDistinctAscList $ - zip - [-2 ..] - [ defaultSS - & ssItems .~ IM.fromAscList [(0,SelectionItem ["STATUS"] 1 False white 0 ())] - , defaultFiltSection - , defaultInvSection - , defaultYouSection - , defaultFiltSection - , defaultCOSection - ] - -defaultSS :: SelectionSection a -defaultSS = - SelectionSection - { _ssItems = mempty - , _ssOffset = 0 - , _ssShownItems = [] - , _ssIndent = 0 - } - -defaultCOSection :: SelectionSection () -defaultCOSection = - defaultSS - -defaultFiltSection :: SelectionSection a -defaultFiltSection = - defaultSS - -defaultInvSection :: SelectionSection () -defaultInvSection = - defaultSS - -defaultYouSection :: SelectionSection () -defaultYouSection = - defaultSS diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 603e35ca1..3060090e9 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -127,8 +127,8 @@ updateDisplaySections w cfig = displaySectionsSizes mselpos (getAvailableListLines (invDisplayParams w) cfig) - [filtinv, filtclose, invx, youx, closex] - (IM.fromAscList [(-1,0),(0,2),(1,0),(2,0),(3,2)]) + [statushead,statusdisplay,filtinv, filtclose, invx, youx, closex] + (IM.fromAscList [(-3,0),(-2,2),(-1,0),(0,2),(1,0),(2,0),(3,2)]) where mselpos = w ^? hud . hudElement . diSelection . _Just invfiltcurs = mselpos ^? _Just . _1 == Just (-1) @@ -142,6 +142,8 @@ updateDisplaySections w cfig = w ^? hud . hudElement . diCloseFilter . _Just (filtclose, closex) = ((2, sfclose), (3, sclose)) youx = (1, youitems) + statushead = (-3,IM.singleton 0 $ SelectionInfo ["STATUS"] 1 False white 0) + statusdisplay = (-2,IM.singleton 0 $ SelectionInfo ["HEALTH "++show (_crHP cr)] 1 False white 0) youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 0 () thetext = displayFreeSlots (crNumFreeSlots cr) closeitms = @@ -199,11 +201,9 @@ displayFreeSlots x = case x of _ -> show x ++ " FREE SLOTS" sectionsDesiredLines :: --- IM.IntMap (SelectionSection a) -> IM.IntMap (IM.IntMap (SelectionItem a)) -> IM.IntMap Int sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight ---sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight . _ssItems sectionsSizes :: Int -> -- total available lines @@ -261,6 +261,7 @@ updateSectionsPositioning f mselpos allavailablelines lsss indents sss = return i ls = IM.fromList lsss h = IM.intersectionWith ($) + -- defaults non-existing offsets to 0 g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($))) lk = fromMaybe [] $ fmap ((: []) . fst) mselpos ssizes = diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 8ed2fe6c1..f95e93a17 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -17,7 +17,6 @@ import Dodge.Camera import Dodge.Creature.Action import Dodge.Data.Combine import Dodge.Data.Universe -import Dodge.Default.World import Dodge.DisplayInventory import Dodge.Event.Test import Dodge.InputFocus @@ -480,8 +479,8 @@ toggleMap u = case u ^. uvWorld . hud . hudElement of DisplayCarte -> u & uvWorld . hud . hudElement .~ DisplayInventory - { _subInventory = NoSubInventory --MouseInvNothing - , _diSections = defaultInvSections + { _subInventory = NoSubInventory + , _diSections = mempty , _diSelection = Nothing , _diSelectionExtra = mempty , _diInvFilter = mempty