Move toward adding infoboxes/better creature information display
This commit is contained in:
+8
-35
@@ -6,12 +6,18 @@ Consider splitting. -}
|
|||||||
module Dodge.Base
|
module Dodge.Base
|
||||||
( module Dodge.Base
|
( module Dodge.Base
|
||||||
, module Dodge.Base.You
|
, module Dodge.Base.You
|
||||||
|
, module Dodge.Base.WinScale
|
||||||
|
, module Dodge.Base.Window
|
||||||
|
, module Dodge.Base.Coordinate
|
||||||
|
, module Dodge.Base.Collide
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.WinScale
|
import Dodge.Base.WinScale
|
||||||
|
import Dodge.Base.Coordinate
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
--import Dodge.Zone.Data
|
--import Dodge.Zone.Data
|
||||||
--import Dodge.Base.Window
|
import Dodge.Base.Window
|
||||||
|
import Dodge.Base.Collide
|
||||||
import Geometry
|
import Geometry
|
||||||
--import Picture
|
--import Picture
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
@@ -407,39 +413,6 @@ nearestCrInFront p dir x
|
|||||||
crInPolygon :: Creature -> [Point2] -> Bool
|
crInPolygon :: Creature -> [Point2] -> Bool
|
||||||
crInPolygon = pointInPolygon . _crPos
|
crInPolygon = pointInPolygon . _crPos
|
||||||
|
|
||||||
{- | Transform coordinates from world position to screen coordinates. -}
|
|
||||||
worldPosToScreenNorm :: Configuration -> World -> Point2 -> Point2
|
|
||||||
worldPosToScreenNorm cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
|
||||||
where
|
|
||||||
doTranslate p = p -.- _cameraCenter w
|
|
||||||
doZoom p = _cameraZoom w *.* p
|
|
||||||
doRotate p = rotateV (negate $ _cameraRot w) p
|
|
||||||
{- | Transform world coordinates to scaled screen coordinates.
|
|
||||||
- These have to be according to the size of the window to get actual screen positions.
|
|
||||||
- This allows for line thicknesses etc to correspond to pixel sizes.-}
|
|
||||||
worldPosToScreen :: World -> Point2 -> Point2
|
|
||||||
worldPosToScreen w = doRotate . doZoom . doTranslate
|
|
||||||
where
|
|
||||||
doTranslate p = p -.- _cameraCenter w
|
|
||||||
doZoom p = _cameraZoom w *.* p
|
|
||||||
doRotate p = rotateV (negate $ _cameraRot w) p
|
|
||||||
{- | Transform coordinates from the map position to screen
|
|
||||||
coordinates. -}
|
|
||||||
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
|
|
||||||
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
|
||||||
where
|
|
||||||
doTranslate p = p -.- _carteCenter (_hud w)
|
|
||||||
doZoom p = _carteZoom (_hud w) *.* p
|
|
||||||
doRotate p = rotateV (negate $ _carteRot (_hud w)) p
|
|
||||||
crToMousePosOffset :: Creature -> World -> (Point2,Float)
|
|
||||||
crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr,0)
|
|
||||||
{- | The mouse position in world coordinates. -}
|
|
||||||
mouseWorldPos :: World -> Point2
|
|
||||||
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
|
|
||||||
{- | The mouse position in map coordinates -}
|
|
||||||
mouseCartePos :: World -> Point2
|
|
||||||
mouseCartePos w = _carteCenter (_hud w) +.+ (1/_carteZoom (_hud w))
|
|
||||||
*.* rotateV (_carteRot (_hud w)) (_mousePos w)
|
|
||||||
{- | Create a logistic function given three parameters. -}
|
{- | Create a logistic function given three parameters. -}
|
||||||
logistic :: Float -> Float -> Float -> (Float -> Float)
|
logistic :: Float -> Float -> Float -> (Float -> Float)
|
||||||
logistic x0 l k x = l / (1 + exp (k*(x0 - x)))
|
logistic x0 l k x = l / (1 + exp (k*(x0 - x)))
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import Dodge.WorldEvent.Shockwave
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
import Dodge.Base.Collide
|
|
||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
--import Dodge.WorldEvent
|
--import Dodge.WorldEvent
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ module Dodge.Creature.ChooseTarget
|
|||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Base.Collide
|
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
--import qualified Data.IntMap.Strict as IM
|
--import qualified Data.IntMap.Strict as IM
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ module Dodge.Creature.Picture
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
--import Dodge.Base
|
--import Dodge.Base
|
||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
|
import Dodge.Render.InfoBox
|
||||||
|
import Dodge.Render.List
|
||||||
--import Dodge.Creature.AlertLevel.Data
|
--import Dodge.Creature.AlertLevel.Data
|
||||||
--import Dodge.Picture.Layer
|
--import Dodge.Picture.Layer
|
||||||
import Dodge.Clock
|
import Dodge.Clock
|
||||||
|
import Dodge.Debug.Picture
|
||||||
import Picture
|
import Picture
|
||||||
import Geometry
|
import Geometry
|
||||||
import Shape
|
import Shape
|
||||||
@@ -71,8 +74,26 @@ basicCrShape col cr = tr . scaleSH (V3 crsize crsize crsize) $ mconcat
|
|||||||
rotmdir = rotateSH (_crMvDir cr)
|
rotmdir = rotateSH (_crMvDir cr)
|
||||||
. colorSH (greyN 0.3)
|
. colorSH (greyN 0.3)
|
||||||
|
|
||||||
|
crDisplayInfo :: Configuration -> World -> Creature -> (Point2,[String])
|
||||||
|
crDisplayInfo cfig w cr = (_crPos cr,
|
||||||
|
[show $_crGoal ap
|
||||||
|
,show $ _crStrategy ap
|
||||||
|
,show $ _crAction ap
|
||||||
|
,show $ _crImpulse ap
|
||||||
|
]
|
||||||
|
)
|
||||||
|
where
|
||||||
|
ap = _crActionPlan cr
|
||||||
|
crOnScreen = pointOnScreen cfig w $ _crPos cr
|
||||||
|
|
||||||
creatureDisplayText :: Configuration -> World -> Creature -> Picture
|
creatureDisplayText :: Configuration -> World -> Creature -> Picture
|
||||||
creatureDisplayText cfig w cr
|
creatureDisplayText cfig w cr = setLayer 4 . setDepth 50
|
||||||
|
$ color white $ renderListAt 0 0 cfig $ zip ["TEST","ME"] $ repeat white
|
||||||
|
-- $ renderInfoListAt 0 0 cfig w
|
||||||
|
-- $ crDisplayInfo cfig w cr
|
||||||
|
|
||||||
|
creatureDisplayText' :: Configuration -> World -> Creature -> Picture
|
||||||
|
creatureDisplayText' cfig w cr
|
||||||
| not (_debug_cr_status cfig) = []
|
| not (_debug_cr_status cfig) = []
|
||||||
| otherwise
|
| otherwise
|
||||||
= setLayer 4
|
= setLayer 4
|
||||||
@@ -82,10 +103,10 @@ creatureDisplayText cfig w cr
|
|||||||
. rotate (0.5 * pi)
|
. rotate (0.5 * pi)
|
||||||
-- . rotate (argV v - 0.5 * pi)
|
-- . rotate (argV v - 0.5 * pi)
|
||||||
. scale theScale theScale
|
. scale theScale theScale
|
||||||
. centerText
|
. stackText
|
||||||
$ clockCycle 25 (V.fromList
|
$ clockCycle 25 (V.fromList
|
||||||
[ crDisplayAwake
|
[ \cr' -> [crDisplayAwake cr']
|
||||||
, crDisplayAlert
|
, \cr' -> [crDisplayAlert cr']
|
||||||
]
|
]
|
||||||
) w cr
|
) w cr
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import Dodge.Data
|
|||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Creature.Volition
|
import Dodge.Creature.Volition
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Base.Collide
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import FoldableHelp
|
import FoldableHelp
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ lineOnScreenCone cfig w p1 p2 = pointInPolygon p1 sp
|
|||||||
| otherwise = orderPolygon (_cameraViewFrom w : sp')
|
| otherwise = orderPolygon (_cameraViewFrom w : sp')
|
||||||
sps = zip sp (tail sp ++ [head sp])
|
sps = zip sp (tail sp ++ [head sp])
|
||||||
|
|
||||||
|
pointOnScreen :: Configuration -> World -> Point2 -> Bool
|
||||||
|
pointOnScreen cfig w p = pointInPolygon p $ screenPolygon cfig w
|
||||||
|
|
||||||
drawWallFace :: Configuration -> World -> Wall -> Picture
|
drawWallFace :: Configuration -> World -> Wall -> Picture
|
||||||
drawWallFace cfig w wall
|
drawWallFace cfig w wall
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ import Dodge.Inventory.CloseObject
|
|||||||
import Dodge.Inventory.CheckSlots
|
import Dodge.Inventory.CheckSlots
|
||||||
import Dodge.Inventory.ItemSpace
|
import Dodge.Inventory.ItemSpace
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Base.Window
|
|
||||||
import Dodge.Base.Collide
|
|
||||||
import Geometry
|
import Geometry
|
||||||
--import FoldableHelp
|
--import FoldableHelp
|
||||||
import Padding
|
import Padding
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ module Dodge.Item.Weapon.Booster
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
import Dodge.Base.Collide
|
|
||||||
import Dodge.Default.Weapon
|
import Dodge.Default.Weapon
|
||||||
import Geometry
|
import Geometry
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import Geometry
|
|||||||
import ShapePicture
|
import ShapePicture
|
||||||
import Shape
|
import Shape
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Base.Collide
|
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ updateTurret rotSpeed mc w
|
|||||||
doTurn
|
doTurn
|
||||||
| seesYou = machines . ix mcid . mcDir %~ turnTo rotSpeed mcpos ypos
|
| seesYou = machines . ix mcid . mcDir %~ turnTo rotSpeed mcpos ypos
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
closeFireAngle = seesYou && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
|
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
|
||||||
updateFiringStatus
|
updateFiringStatus
|
||||||
| closeFireAngle = machines . ix mcid . mcType . tuFireTime .~ 20
|
| closeFireAngle = machines . ix mcid . mcType . tuFireTime .~ 20
|
||||||
| otherwise = machines . ix mcid . mcType . tuFireTime %~ (max 0 . subtract 1)
|
| otherwise = machines . ix mcid . mcType . tuFireTime %~ (max 0 . subtract 1)
|
||||||
|
|||||||
+1
-1
@@ -116,7 +116,7 @@ doDrawing pdata u = do
|
|||||||
else renderBlankWalls pdata nWalls
|
else renderBlankWalls pdata nWalls
|
||||||
--draw object pictures onto base buffer
|
--draw object pictures onto base buffer
|
||||||
renderLayer 0 shadV layerCounts
|
renderLayer 0 shadV layerCounts
|
||||||
--draw object shpaes onto base buffer
|
--draw object shapes onto base buffer
|
||||||
let fs = _shapeShader pdata
|
let fs = _shapeShader pdata
|
||||||
currentProgram $= Just (_shadProg fs)
|
currentProgram $= Just (_shadProg fs)
|
||||||
bindVertexArrayObject $= Just (_vao $ _shadVAO fs)
|
bindVertexArrayObject $= Just (_vao $ _shadVAO fs)
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ module Dodge.Render.HUD
|
|||||||
( hudDrawings
|
( hudDrawings
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.WinScale
|
|
||||||
import Dodge.Combine
|
import Dodge.Combine
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Base.Window
|
|
||||||
--import Dodge.Combine.Combinations
|
--import Dodge.Combine.Combinations
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Inventory.ItemSpace
|
import Dodge.Inventory.ItemSpace
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module Dodge.Render.List where
|
module Dodge.Render.List where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base.Window
|
import Dodge.Base.Window
|
||||||
import Dodge.WinScale
|
import Dodge.Base.WinScale
|
||||||
import Picture
|
import Picture
|
||||||
import Geometry
|
import Geometry
|
||||||
--import Control.Monad
|
--import Control.Monad
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Dodge.Render.Picture
|
|||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
--import Dodge.Base.Window
|
--import Dodge.Base.Window
|
||||||
import Dodge.WinScale
|
import Dodge.Base.WinScale
|
||||||
import Dodge.Picture.Layer
|
import Dodge.Picture.Layer
|
||||||
import Dodge.Render.HUD
|
import Dodge.Render.HUD
|
||||||
import Dodge.Render.MenuScreen
|
import Dodge.Render.MenuScreen
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ module Dodge.Update.Camera
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
import Dodge.Base.Window
|
|
||||||
import Dodge.Base.Collide
|
|
||||||
--import Dodge.Config.KeyConfig
|
|
||||||
import Geometry
|
import Geometry
|
||||||
--import Geometry.ConvexPoly
|
--import Geometry.ConvexPoly
|
||||||
import Dodge.GameRoom
|
import Dodge.GameRoom
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
module Dodge.WinScale where
|
|
||||||
import Dodge.Config.Data
|
|
||||||
import Geometry
|
|
||||||
import Picture
|
|
||||||
|
|
||||||
winScale :: Configuration -> Picture -> Picture
|
|
||||||
{-# INLINE winScale #-}
|
|
||||||
winScale cfig = scale (2 / _windowX cfig) (2 / _windowY cfig)
|
|
||||||
|
|
||||||
doWindowScale :: Configuration -> Point2 -> Point2
|
|
||||||
doWindowScale cfig (V2 x y) = V2 ( x * 2 / _windowX cfig) ( y * 2 / _windowY cfig)
|
|
||||||
@@ -25,6 +25,7 @@ module Picture
|
|||||||
, lineCol
|
, lineCol
|
||||||
, text
|
, text
|
||||||
, centerText
|
, centerText
|
||||||
|
, stackText
|
||||||
, pictures
|
, pictures
|
||||||
, concatMapPic
|
, concatMapPic
|
||||||
, appendPic
|
, appendPic
|
||||||
@@ -224,6 +225,10 @@ centerText :: String -> Picture
|
|||||||
{-# INLINE centerText #-}
|
{-# INLINE centerText #-}
|
||||||
centerText s = translate (50 * (negate . fromIntegral $ length s - 1)) 0 $ text s
|
centerText s = translate (50 * (negate . fromIntegral $ length s - 1)) 0 $ text s
|
||||||
|
|
||||||
|
stackText :: [String] -> Picture
|
||||||
|
{-# INLINE stackText #-}
|
||||||
|
stackText = mconcat . zipWith (\y s -> translate 0 y $ centerText s) [0,100..]
|
||||||
|
|
||||||
text :: String -> Picture
|
text :: String -> Picture
|
||||||
{-# INLINE text #-}
|
{-# INLINE text #-}
|
||||||
text = map f . stringToList
|
text = map f . stringToList
|
||||||
|
|||||||
Reference in New Issue
Block a user