Refactor, try to limit dependencies
This commit is contained in:
+51
-51
@@ -1,67 +1,67 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Dodge.Data.Button where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Data.WorldEffect
|
||||
|
||||
import Color
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Dodge.Data.WorldEffect
|
||||
import Geometry.Data
|
||||
import Sound.Data
|
||||
import Color
|
||||
data ButtonDraw = DefaultDrawButton Color
|
||||
|
||||
data ButtonDraw
|
||||
= DefaultDrawButton Color
|
||||
| DefaultDrawSwitch Color Color
|
||||
| DrawNoButton
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ButtonDraw where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ButtonDraw
|
||||
data ButtonEvent = ButtonDoNothing
|
||||
deriving (Eq, Ord, Show, Read)
|
||||
|
||||
data ButtonEvent
|
||||
= ButtonDoNothing
|
||||
| ButtonPress
|
||||
{_bpState :: ButtonState
|
||||
,_bpEvent :: ButtonEvent
|
||||
,_bpSound :: SoundID
|
||||
,_bpEff :: WdWd
|
||||
{ _bpState :: ButtonState
|
||||
, _bpEvent :: ButtonEvent
|
||||
, _bpSound :: SoundID
|
||||
, _bpEff :: WdWd
|
||||
}
|
||||
-- | ButtonSwitch
|
||||
-- {_bonState :: ButtonState
|
||||
-- ,_bonEvent :: ButtonEvent
|
||||
-- ,_bonSound :: SoundID
|
||||
-- ,_bonEff :: WorldEffect
|
||||
-- ,_boffState :: ButtonState
|
||||
-- ,_boffEvent :: ButtonEvent
|
||||
-- ,_boffSound :: SoundID
|
||||
-- ,_boffEff :: WorldEffect
|
||||
-- }
|
||||
| ButtonSimpleSwith
|
||||
{_bonEff :: WdWd
|
||||
,_boffEff :: WdWd
|
||||
| -- | ButtonSwitch
|
||||
-- {_bonState :: ButtonState
|
||||
-- ,_bonEvent :: ButtonEvent
|
||||
-- ,_bonSound :: SoundID
|
||||
-- ,_bonEff :: WorldEffect
|
||||
-- ,_boffState :: ButtonState
|
||||
-- ,_boffEvent :: ButtonEvent
|
||||
-- ,_boffSound :: SoundID
|
||||
-- ,_boffEff :: WorldEffect
|
||||
-- }
|
||||
ButtonSimpleSwith
|
||||
{ _bonEff :: WdWd
|
||||
, _boffEff :: WdWd
|
||||
}
|
||||
| ButtonAccessTerminal
|
||||
deriving (Eq,Show,Read,Generic)
|
||||
instance ToJSON ButtonEvent where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ButtonEvent
|
||||
data Button = Button
|
||||
{ _btPict :: ButtonDraw --Button -> SPic
|
||||
, _btPos :: Point2
|
||||
, _btRot :: Float
|
||||
, _btEvent :: ButtonEvent --Button -> World -> World
|
||||
, _btID :: Int
|
||||
, _btText :: String
|
||||
, _btState :: ButtonState
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
data Button = Button
|
||||
{ _btPict :: ButtonDraw --Button -> SPic
|
||||
, _btPos :: Point2
|
||||
, _btRot :: Float
|
||||
, _btEvent :: ButtonEvent --Button -> World -> World
|
||||
, _btID :: Int
|
||||
, _btText :: String
|
||||
, _btState :: ButtonState
|
||||
, _btTermMID :: Maybe Int
|
||||
, _btName :: String
|
||||
, _btColor :: Color
|
||||
, _btName :: String
|
||||
, _btColor :: Color
|
||||
}
|
||||
deriving (Eq,Show,Read,Generic)
|
||||
instance ToJSON Button where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Button
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
data ButtonState = BtOn | BtOff | BtNoLabel
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ButtonState where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ButtonState
|
||||
deriving (Eq, Ord, Show, Read)
|
||||
|
||||
makeLenses ''Button
|
||||
makeLenses ''ButtonEvent
|
||||
deriveJSON defaultOptions ''ButtonDraw
|
||||
deriveJSON defaultOptions ''ButtonEvent
|
||||
deriveJSON defaultOptions ''Button
|
||||
deriveJSON defaultOptions ''ButtonState
|
||||
|
||||
Reference in New Issue
Block a user