Unify terminal size determination

This commit is contained in:
2024-11-25 22:59:54 +00:00
parent 21aae232fc
commit 6aea049b80
3 changed files with 41 additions and 38 deletions
+17 -15
View File
@@ -4,7 +4,6 @@ module Dodge.Render.HUD (
drawHUD, drawHUD,
) where ) where
import NewInt
import Control.Applicative import Control.Applicative
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
@@ -41,6 +40,7 @@ import Dodge.Terminal.Type
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Justify import Justify
import NewInt
import Picture import Picture
import SDL (MouseButton (..)) import SDL (MouseButton (..))
@@ -59,7 +59,7 @@ drawInventory sss w cfig =
<> iextra <> iextra
<> drawMouseOver cfig w <> drawMouseOver cfig w
where where
f = fmap (\(x,y,_) -> (x,y)) f = fmap (\(x, y, _) -> (x, y))
ldp = invDisplayParams w ldp = invDisplayParams w
curs = invCursorParams w curs = invCursorParams w
iextra = fromMaybe mempty $ do iextra = fromMaybe mempty $ do
@@ -116,9 +116,9 @@ drawMouseOver cfig w =
let idp = invDisplayParams w let idp = invDisplayParams w
return . translateScreenPos cfig (invDisplayParams w ^. ldpPos) return . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
. color (withAlpha 0.1 white) . color (withAlpha 0.1 white)
-- . color white -- . color white
$ selSecDrawCursorAt 15 idp curs sss (j, i) $ selSecDrawCursorAt 15 idp curs sss (j, i)
-- curs = BoundaryCursor [West] -- curs = BoundaryCursor [West]
curs = BackdropCursor curs = BackdropCursor
combinvsel = do combinvsel = do
(j, i) <- (j, i) <-
@@ -133,11 +133,12 @@ drawMouseOver cfig w =
drawDragSelected :: Configuration -> World -> Maybe Picture drawDragSelected :: Configuration -> World -> Maybe Picture
drawDragSelected cfig w = do drawDragSelected cfig w = do
ys <- w ^? hud . hudElement . diSelection . _Just . _3 ys <- w ^? hud . hudElement . diSelection . _Just . _3
guard $ not (IS.null ys) && guard $
( case w ^? hud . hudElement . subInventory of not (IS.null ys)
Just NoSubInventory -> True && ( case w ^? hud . hudElement . subInventory of
_ -> False Just NoSubInventory -> True
) _ -> False
)
(i, _, _) <- w ^? hud . hudElement . diSelection . _Just (i, _, _) <- w ^? hud . hudElement . diSelection . _Just
sss <- w ^? hud . hudElement . diSections sss <- w ^? hud . hudElement . diSections
let idp = invDisplayParams w let idp = invDisplayParams w
@@ -179,8 +180,9 @@ drawCombineInventory cfig sss w =
<> combineInventoryExtra sss msel cfig w <> combineInventoryExtra sss msel cfig w
where where
curs = BoundaryCursor [North, South, West] curs = BoundaryCursor [North, South, West]
msel = fmap (\(x,y,_) -> (x,y)) msel =
$ w ^? hud . hudElement . subInventory . ciSelection . _Just fmap (\(x, y, _) -> (x, y)) $
w ^? hud . hudElement . subInventory . ciSelection . _Just
drawExamineInventory :: Configuration -> World -> Picture drawExamineInventory :: Configuration -> World -> Picture
drawExamineInventory cfig w = drawExamineInventory cfig w =
@@ -228,7 +230,7 @@ yourAugmentedItem f x g w = case you w ^? crManipulation . manObject of
j <- w ^? hud . closeItems . ix i . unNInt j <- w ^? hud . closeItems . ix i . unNInt
flit <- w ^? cWorld . lWorld . floorItems . unNIntMap . ix j flit <- w ^? cWorld . lWorld . floorItems . unNIntMap . ix j
return . g $ Left flit return . g $ Left flit
-- g . Left $ w ^?! hud . closeItems . ix i -- g . Left $ w ^?! hud . closeItems . ix i
Just (SelCloseButton i) -> fromMaybe x $ do Just (SelCloseButton i) -> fromMaybe x $ do
j <- w ^? hud . closeButtons . ix i j <- w ^? hud . closeButtons . ix i
flit <- w ^? cWorld . lWorld . buttons . ix j flit <- w ^? cWorld . lWorld . buttons . ix j
@@ -245,7 +247,7 @@ drawRBOptions cfig w = fromMaybe mempty $ do
i <- w ^? rbOptions . opSel i <- w ^? rbOptions . opSel
let ae = getEquipmentAllocation w let ae = getEquipmentAllocation w
sss <- w ^? hud . hudElement . diSections sss <- w ^? hud . hudElement . diSections
(i', j,_) <- w ^? hud . hudElement . diSelection . _Just (i', j, _) <- w ^? hud . hudElement . diSelection . _Just
curpos <- selSecYint i' j sss curpos <- selSecYint i' j sss
let ytext = drawListElement 0 1 0 curpos . text let ytext = drawListElement 0 1 0 curpos . text
midstr = equipAllocString ae midstr = equipAllocString ae
@@ -356,11 +358,11 @@ combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
drawTerminalDisplay :: Int -> Configuration -> LWorld -> Picture drawTerminalDisplay :: Int -> Configuration -> LWorld -> Picture
drawTerminalDisplay tid cfig w = fromMaybe mempty $ do drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
tm <- w ^? terminals . ix tid tm <- w ^? terminals . ix tid
let tsize = getMaxLinesTM (tm ^. tmType) + 1
return $ return $
invHead cfig (_tmTitle tm ++ ":T" ++ show tid) invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
<> drawSelectionList secondColumnParams cfig (thesellist tm) <> drawSelectionList secondColumnParams cfig (thesellist tm)
<> color (withAlpha 0.5 green) (drawSelectionListBackground secondColumnParams cfig 15) <> color (withAlpha 0.5 green) (drawSelectionListBackground secondColumnParams cfig tsize)
-- when changing the 15, change isOverTerminalScreen
<> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig) <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig)
where where
toselitm (str, col) = SelectionItem [str] 1 True col 0 () toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
+7 -6
View File
@@ -47,6 +47,7 @@ import Dodge.Shockwave.Update
import Dodge.SmoothScroll import Dodge.SmoothScroll
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.Spark import Dodge.Spark
import Dodge.Terminal.Type
import Dodge.Tesla.Arc import Dodge.Tesla.Arc
import Dodge.TmTm import Dodge.TmTm
import Dodge.TractorBeam.Update import Dodge.TractorBeam.Update
@@ -315,7 +316,8 @@ updateMouseContextGame :: Configuration -> Universe -> Universe
updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
OverInvDrag i _ _ _ -> u & uvWorld . input . mouseContext .~ invdrag i OverInvDrag i _ _ _ -> u & uvWorld . input . mouseContext .~ invdrag i
OverInvDragSelect{} -> u OverInvDragSelect{} -> u
_ -> u & uvWorld . input . mouseContext _ ->
u & uvWorld . input . mouseContext
.~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm) .~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm)
where where
w = u ^. uvWorld w = u ^. uvWorld
@@ -332,7 +334,7 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
return $ OverInvDrag i' (Just (i, j)) above bneath return $ OverInvDrag i' (Just (i, j)) above bneath
overinv = do overinv = do
sss <- w ^? hud . hudElement . diSections sss <- w ^? hud . hudElement . diSections
selpos@(i,j) <- inverseSelNumPos cfig (invDisplayParams w) sss mpos selpos@(i, j) <- inverseSelNumPos cfig (invDisplayParams w) sss mpos
case w ^? hud . hudElement . subInventory . ciSelection of case w ^? hud . hudElement . subInventory . ciSelection of
Just _ -> do Just _ -> do
guard (i == 0) guard (i == 0)
@@ -384,7 +386,7 @@ getMenuMouseContext screen u = case screen ^. scOptions of
u ^? uvScreenLayers . _head . scSelectionList . ix yi . siIsSelectable u ^? uvScreenLayers . _head . scSelectionList . ix yi . siIsSelectable
isOverTerminalScreen :: Configuration -> Terminal -> Point2 -> Bool isOverTerminalScreen :: Configuration -> Terminal -> Point2 -> Bool
isOverTerminalScreen cfig _ (V2 x y) = isOverTerminalScreen cfig tm (V2 x y) =
x <= xmax x <= xmax
&& x >= xmin - 5 && x >= xmin - 5
&& y <= ymax + 5 && y <= ymax + 5
@@ -392,9 +394,8 @@ isOverTerminalScreen cfig _ (V2 x y) =
where where
ldp = secondColumnParams ldp = secondColumnParams
V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos) V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
s = 5 + 15 * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap) tsize = fromIntegral $ getMaxLinesTM (tm ^. tmType) + 1
-- the 15 is the length of list in the terminal display, don't change s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
-- without changing drawTerminalDisplay
ymin = ymax - s ymin = ymax - s
xmax = xmin + 555 -- HACK drawSelectionListBackground xmax = xmin + 555 -- HACK drawSelectionListBackground
+17 -17
View File
@@ -3350,7 +3350,7 @@ adjustIMZone src/Dodge/Base.hs 77;" f
advanceScrollAmount src/Dodge/Update.hs 408;" f advanceScrollAmount src/Dodge/Update.hs 408;" f
advanceSmoothScroll src/Dodge/SmoothScroll.hs 29;" f advanceSmoothScroll src/Dodge/SmoothScroll.hs 29;" f
advanceStepCounter src/Dodge/Creature/Impulse/Movement.hs 45;" f advanceStepCounter src/Dodge/Creature/Impulse/Movement.hs 45;" f
aimDelaySweep src/Dodge/Render/Picture.hs 233;" f aimDelaySweep src/Dodge/Render/Picture.hs 235;" f
aimStanceInfo src/Dodge/Item/Info.hs 210;" f aimStanceInfo src/Dodge/Item/Info.hs 210;" f
aimTurn src/Dodge/Creature/YourControl.hs 143;" f aimTurn src/Dodge/Creature/YourControl.hs 143;" f
aimingMuzzleLength src/Dodge/Creature/HandPos.hs 46;" f aimingMuzzleLength src/Dodge/Creature/HandPos.hs 46;" f
@@ -4097,8 +4097,8 @@ drawCPUShadows src/Dodge/Render/Shadow.hs 19;" f
drawCarte src/Dodge/Render/HUD/Carte.hs 14;" f drawCarte src/Dodge/Render/HUD/Carte.hs 14;" f
drawCircFlare src/Dodge/Flare.hs 25;" f drawCircFlare src/Dodge/Flare.hs 25;" f
drawCollisionTest src/Dodge/Debug/Picture.hs 103;" f drawCollisionTest src/Dodge/Debug/Picture.hs 103;" f
drawCombFilter src/Dodge/Render/Picture.hs 214;" f drawCombFilter src/Dodge/Render/Picture.hs 216;" f
drawCombFilterJump src/Dodge/Render/Picture.hs 157;" f drawCombFilterJump src/Dodge/Render/Picture.hs 159;" f
drawCombineInventory src/Dodge/Render/HUD.hs 170;" f drawCombineInventory src/Dodge/Render/HUD.hs 170;" f
drawConcurrentMessage src/Dodge/Render/Picture.hs 62;" f drawConcurrentMessage src/Dodge/Render/Picture.hs 62;" f
drawCorpse src/Dodge/Corpse/Draw.hs 6;" f drawCorpse src/Dodge/Corpse/Draw.hs 6;" f
@@ -4111,13 +4111,13 @@ drawCursorAt src/Dodge/Render/List.hs 71;" f
drawDDATest src/Dodge/Debug/Picture.hs 256;" f drawDDATest src/Dodge/Debug/Picture.hs 256;" f
drawDoorPaths src/Dodge/Debug/Picture.hs 217;" f drawDoorPaths src/Dodge/Debug/Picture.hs 217;" f
drawDoubleLampCover src/Dodge/Prop/Draw.hs 81;" f drawDoubleLampCover src/Dodge/Prop/Draw.hs 81;" f
drawDrag src/Dodge/Render/Picture.hs 164;" f drawDrag src/Dodge/Render/Picture.hs 166;" f
drawDragDrop src/Dodge/Render/Picture.hs 175;" f drawDragDrop src/Dodge/Render/Picture.hs 177;" f
drawDragPickup src/Dodge/Render/Picture.hs 184;" f drawDragPickup src/Dodge/Render/Picture.hs 186;" f
drawDragSelect src/Dodge/Render/Picture.hs 161;" f drawDragSelect src/Dodge/Render/Picture.hs 163;" f
drawDragSelected src/Dodge/Render/HUD.hs 133;" f drawDragSelected src/Dodge/Render/HUD.hs 133;" f
drawDragSelecting src/Dodge/Render/HUD.hs 150;" f drawDragSelecting src/Dodge/Render/HUD.hs 150;" f
drawEmptySet src/Dodge/Render/Picture.hs 112;" f drawEmptySet src/Dodge/Render/Picture.hs 114;" f
drawEnergyBall src/Dodge/EnergyBall/Draw.hs 8;" f drawEnergyBall src/Dodge/EnergyBall/Draw.hs 8;" f
drawEquipment src/Dodge/Creature/Picture.hs 140;" f drawEquipment src/Dodge/Creature/Picture.hs 140;" f
drawExamineInventory src/Dodge/Render/HUD.hs 185;" f drawExamineInventory src/Dodge/Render/HUD.hs 185;" f
@@ -4127,7 +4127,7 @@ drawFlamelet src/Dodge/EnergyBall/Draw.hs 23;" f
drawFlare src/Dodge/Flare.hs 12;" f drawFlare src/Dodge/Flare.hs 12;" f
drawFooterText src/Dodge/Render/MenuScreen.hs 74;" f drawFooterText src/Dodge/Render/MenuScreen.hs 74;" f
drawForceField src/Dodge/Wall/Draw.hs 11;" f drawForceField src/Dodge/Wall/Draw.hs 11;" f
drawGapPlus src/Dodge/Render/Picture.hs 224;" f drawGapPlus src/Dodge/Render/Picture.hs 226;" f
drawGib src/Dodge/Prop/Draw.hs 28;" f drawGib src/Dodge/Prop/Draw.hs 28;" f
drawHUD src/Dodge/Render/HUD.hs 47;" f drawHUD src/Dodge/Render/HUD.hs 47;" f
drawInputMenu src/Dodge/Render/MenuScreen.hs 21;" f drawInputMenu src/Dodge/Render/MenuScreen.hs 21;" f
@@ -4145,8 +4145,8 @@ drawListYgapScaleYoff src/Dodge/Render/List.hs 99;" f
drawListYoff src/Dodge/Render/List.hs 96;" f drawListYoff src/Dodge/Render/List.hs 96;" f
drawMachine src/Dodge/Machine/Draw.hs 17;" f drawMachine src/Dodge/Machine/Draw.hs 17;" f
drawMapWall src/Dodge/Render/HUD/Carte.hs 33;" f drawMapWall src/Dodge/Render/HUD/Carte.hs 33;" f
drawMenuClick src/Dodge/Render/Picture.hs 132;" f drawMenuClick src/Dodge/Render/Picture.hs 134;" f
drawMenuCursor src/Dodge/Render/Picture.hs 145;" f drawMenuCursor src/Dodge/Render/Picture.hs 147;" f
drawMenuOrHUD src/Dodge/Render/Picture.hs 57;" f drawMenuOrHUD src/Dodge/Render/Picture.hs 57;" f
drawMenuScreen src/Dodge/Render/MenuScreen.hs 15;" f drawMenuScreen src/Dodge/Render/MenuScreen.hs 15;" f
drawMouseCursor src/Dodge/Render/Picture.hs 73;" f drawMouseCursor src/Dodge/Render/Picture.hs 73;" f
@@ -4159,7 +4159,7 @@ drawOptions src/Dodge/Render/MenuScreen.hs 35;" f
drawPathBetween src/Dodge/Debug/Picture.hs 168;" f drawPathBetween src/Dodge/Debug/Picture.hs 168;" f
drawPathEdge src/Dodge/Debug/Picture.hs 222;" f drawPathEdge src/Dodge/Debug/Picture.hs 222;" f
drawPathing src/Dodge/Debug/Picture.hs 384;" f drawPathing src/Dodge/Debug/Picture.hs 384;" f
drawPlus src/Dodge/Render/Picture.hs 129;" f drawPlus src/Dodge/Render/Picture.hs 131;" f
drawPointLabel src/Dodge/Render/Label.hs 13;" f drawPointLabel src/Dodge/Render/Label.hs 13;" f
drawProjectile src/Dodge/Projectile/Draw.hs 13;" f drawProjectile src/Dodge/Projectile/Draw.hs 13;" f
drawProp src/Dodge/Prop/Draw.hs 15;" f drawProp src/Dodge/Prop/Draw.hs 15;" f
@@ -4167,11 +4167,11 @@ drawProp' src/Dodge/Prop/Draw.hs 12;" f
drawRBOptions src/Dodge/Render/HUD.hs 238;" f drawRBOptions src/Dodge/Render/HUD.hs 238;" f
drawRadarSweep src/Dodge/RadarSweep/Draw.hs 7;" f drawRadarSweep src/Dodge/RadarSweep/Draw.hs 7;" f
drawRemoteShell src/Dodge/Projectile/Draw.hs 30;" f drawRemoteShell src/Dodge/Projectile/Draw.hs 30;" f
drawReturn src/Dodge/Render/Picture.hs 118;" f drawReturn src/Dodge/Render/Picture.hs 120;" f
drawRootCursor src/Dodge/Render/HUD.hs 71;" f drawRootCursor src/Dodge/Render/HUD.hs 71;" f
drawSSCursor src/Dodge/SelectionSections/Draw.hs 31;" f drawSSCursor src/Dodge/SelectionSections/Draw.hs 31;" f
drawSSMultiCursor src/Dodge/SelectionSections/Draw.hs 42;" f drawSSMultiCursor src/Dodge/SelectionSections/Draw.hs 42;" f
drawSelect src/Dodge/Render/Picture.hs 203;" f drawSelect src/Dodge/Render/Picture.hs 205;" f
drawSelectionList src/Dodge/Render/List.hs 35;" f drawSelectionList src/Dodge/Render/List.hs 35;" f
drawSelectionListBackground src/Dodge/Render/List.hs 51;" f drawSelectionListBackground src/Dodge/Render/List.hs 51;" f
drawSelectionSections src/Dodge/SelectionSections/Draw.hs 17;" f drawSelectionSections src/Dodge/SelectionSections/Draw.hs 17;" f
@@ -4184,7 +4184,7 @@ drawShockwave src/Dodge/Shockwave/Draw.hs 7;" f
drawSpark src/Dodge/Spark/Draw.hs 6;" f drawSpark src/Dodge/Spark/Draw.hs 6;" f
drawStaticBall src/Dodge/EnergyBall/Draw.hs 14;" f drawStaticBall src/Dodge/EnergyBall/Draw.hs 14;" f
drawSubInventory src/Dodge/Render/HUD.hs 162;" f drawSubInventory src/Dodge/Render/HUD.hs 162;" f
drawSweep src/Dodge/Render/Picture.hs 240;" f drawSweep src/Dodge/Render/Picture.hs 242;" f
drawSwitch src/Dodge/Button/Draw.hs 15;" f drawSwitch src/Dodge/Button/Draw.hs 15;" f
drawSwitchWire src/Dodge/LevelGen/Switch.hs 28;" f drawSwitchWire src/Dodge/LevelGen/Switch.hs 28;" f
drawTargetLaser src/Dodge/Particle/Draw.hs 6;" f drawTargetLaser src/Dodge/Particle/Draw.hs 6;" f
@@ -4726,7 +4726,7 @@ launcherCrit src/Dodge/Creature/LauncherCrit.hs 12;" f
launcherPic src/Dodge/Item/Draw/SPic.hs 331;" f launcherPic src/Dodge/Item/Draw/SPic.hs 331;" f
launcherX src/Dodge/Item/Held/Launcher.hs 32;" f launcherX src/Dodge/Item/Held/Launcher.hs 32;" f
layoutLevelFromSeed src/Dodge/LevelGen.hs 47;" f layoutLevelFromSeed src/Dodge/LevelGen.hs 47;" f
ldpVerticalSelection src/Dodge/Update/Input/ScreenLayer.hs 73;" f ldpVerticalSelection src/Dodge/Update/Input/ScreenLayer.hs 72;" f
ldtIL src/Dodge/DoubleTree.hs 149;" f ldtIL src/Dodge/DoubleTree.hs 149;" f
ldtPropagate src/Dodge/DoubleTree.hs 20;" f ldtPropagate src/Dodge/DoubleTree.hs 20;" f
ldtPropagateFold src/Dodge/DoubleTree.hs 29;" f ldtPropagateFold src/Dodge/DoubleTree.hs 29;" f
@@ -5640,7 +5640,7 @@ setOutLinksByType src/Dodge/RoomLink.hs 57;" f
setOutLinksPD src/Dodge/RoomLink.hs 77;" f setOutLinksPD src/Dodge/RoomLink.hs 77;" f
setRBCreatureTargeting src/Dodge/Creature/State.hs 292;" f setRBCreatureTargeting src/Dodge/Creature/State.hs 292;" f
setSelWhileDragging src/Dodge/Update/Input/InGame.hs 280;" f setSelWhileDragging src/Dodge/Update/Input/InGame.hs 280;" f
setSelectionListRestriction src/Dodge/Update/Input/ScreenLayer.hs 104;" f setSelectionListRestriction src/Dodge/Update/Input/ScreenLayer.hs 85;" f
setShaderSource src/Shader/Compile.hs 290;" f setShaderSource src/Shader/Compile.hs 290;" f
setShadowLimits src/Dodge/Shadows.hs 11;" f setShadowLimits src/Dodge/Shadows.hs 11;" f
setSoundVolume src/Sound.hs 156;" f setSoundVolume src/Sound.hs 156;" f