module Game.LambdaHack.Client.UI.PointUI
( PointUI(..), PointSquare(..), squareToUI, uiToSquare
, squareToMap, mapToSquare
#ifdef EXPOSE_INTERNAL
, mapStartY
#endif
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Game.LambdaHack.Common.Point
data PointUI = PointUI Int Int
deriving (Y -> PointUI -> ShowS
[PointUI] -> ShowS
PointUI -> String
(Y -> PointUI -> ShowS)
-> (PointUI -> String) -> ([PointUI] -> ShowS) -> Show PointUI
forall a.
(Y -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Y -> PointUI -> ShowS
showsPrec :: Y -> PointUI -> ShowS
$cshow :: PointUI -> String
show :: PointUI -> String
$cshowList :: [PointUI] -> ShowS
showList :: [PointUI] -> ShowS
Show, PointUI -> PointUI -> Bool
(PointUI -> PointUI -> Bool)
-> (PointUI -> PointUI -> Bool) -> Eq PointUI
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PointUI -> PointUI -> Bool
== :: PointUI -> PointUI -> Bool
$c/= :: PointUI -> PointUI -> Bool
/= :: PointUI -> PointUI -> Bool
Eq)
data PointSquare = PointSquare Int Int
deriving (Y -> PointSquare -> ShowS
[PointSquare] -> ShowS
PointSquare -> String
(Y -> PointSquare -> ShowS)
-> (PointSquare -> String)
-> ([PointSquare] -> ShowS)
-> Show PointSquare
forall a.
(Y -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Y -> PointSquare -> ShowS
showsPrec :: Y -> PointSquare -> ShowS
$cshow :: PointSquare -> String
show :: PointSquare -> String
$cshowList :: [PointSquare] -> ShowS
showList :: [PointSquare] -> ShowS
Show, PointSquare -> PointSquare -> Bool
(PointSquare -> PointSquare -> Bool)
-> (PointSquare -> PointSquare -> Bool) -> Eq PointSquare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PointSquare -> PointSquare -> Bool
== :: PointSquare -> PointSquare -> Bool
$c/= :: PointSquare -> PointSquare -> Bool
/= :: PointSquare -> PointSquare -> Bool
Eq)
squareToUI :: PointSquare -> PointUI
{-# INLINE squareToUI #-}
squareToUI :: PointSquare -> PointUI
squareToUI (PointSquare Y
x Y
y) = Y -> Y -> PointUI
PointUI (Y
x Y -> Y -> Y
forall a. Num a => a -> a -> a
* Y
2) Y
y
uiToSquare :: PointUI -> PointSquare
{-# INLINE uiToSquare #-}
uiToSquare :: PointUI -> PointSquare
uiToSquare (PointUI Y
x Y
y) = Y -> Y -> PointSquare
PointSquare (Y
x Y -> Y -> Y
forall a. Integral a => a -> a -> a
`div` Y
2) Y
y
mapStartY :: Int
mapStartY :: Y
mapStartY = Y
1
squareToMap :: PointSquare -> Point
{-# INLINE squareToMap #-}
squareToMap :: PointSquare -> Point
squareToMap (PointSquare Y
x Y
y) = Y -> Y -> Point
Point Y
x (Y
y Y -> Y -> Y
forall a. Num a => a -> a -> a
- Y
mapStartY)
mapToSquare :: Point -> PointSquare
{-# INLINE mapToSquare #-}
mapToSquare :: Point -> PointSquare
mapToSquare (Point Y
x Y
y) = Y -> Y -> PointSquare
PointSquare Y
x (Y
y Y -> Y -> Y
forall a. Num a => a -> a -> a
+ Y
mapStartY)