module Rattletrap.Type.RemoteId.Splitscreen where

import qualified Data.Word as Word
import qualified Rattletrap.BitGet as BitGet
import qualified Rattletrap.BitPut as BitPut
import qualified Rattletrap.Schema as Schema
import qualified Rattletrap.Utility.Json as Json

newtype Splitscreen
  = Splitscreen Word.Word32
  deriving (Splitscreen -> Splitscreen -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Splitscreen -> Splitscreen -> Bool
$c/= :: Splitscreen -> Splitscreen -> Bool
== :: Splitscreen -> Splitscreen -> Bool
$c== :: Splitscreen -> Splitscreen -> Bool
Eq, Int -> Splitscreen -> ShowS
[Splitscreen] -> ShowS
Splitscreen -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Splitscreen] -> ShowS
$cshowList :: [Splitscreen] -> ShowS
show :: Splitscreen -> String
$cshow :: Splitscreen -> String
showsPrec :: Int -> Splitscreen -> ShowS
$cshowsPrec :: Int -> Splitscreen -> ShowS
Show)

instance Json.FromJSON Splitscreen where
  parseJSON :: Value -> Parser Splitscreen
parseJSON = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> Splitscreen
fromWord32 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. FromJSON a => Value -> Parser a
Json.parseJSON

instance Json.ToJSON Splitscreen where
  toJSON :: Splitscreen -> Value
toJSON = forall a. ToJSON a => a -> Value
Json.toJSON forall b c a. (b -> c) -> (a -> b) -> a -> c
. Splitscreen -> Word32
toWord32

fromWord32 :: Word.Word32 -> Splitscreen
fromWord32 :: Word32 -> Splitscreen
fromWord32 = Word32 -> Splitscreen
Splitscreen

toWord32 :: Splitscreen -> Word.Word32
toWord32 :: Splitscreen -> Word32
toWord32 (Splitscreen Word32
x) = Word32
x

schema :: Schema.Schema
schema :: Schema
schema = Schema
Schema.integer

bitPut :: Splitscreen -> BitPut.BitPut
bitPut :: Splitscreen -> BitPut
bitPut = forall a. Bits a => Int -> a -> BitPut
BitPut.bits Int
24 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Splitscreen -> Word32
toWord32

bitGet :: BitGet.BitGet Splitscreen
bitGet :: BitGet Splitscreen
bitGet = forall a. String -> BitGet a -> BitGet a
BitGet.label String
"Splitscreen" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Word32 -> Splitscreen
fromWord32 forall a b. (a -> b) -> a -> b
$ forall a. Bits a => Int -> BitGet a
BitGet.bits Int
24