72 lines
1.9 KiB
Haskell
72 lines
1.9 KiB
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
{-# LANGUAGE DeriveAnyClass #-}
|
|
{-# LANGUAGE StrictData #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
module Dodge.Data.Button where
|
|
|
|
import Color
|
|
import Control.Lens
|
|
import Data.Aeson
|
|
import Data.Aeson.TH
|
|
import Dodge.Data.WorldEffect
|
|
import Geometry.Data
|
|
import Sound.Data
|
|
|
|
data ButtonDraw
|
|
= DefaultDrawButton Color
|
|
| DefaultDrawSwitch Color Color
|
|
| DrawNoButton
|
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
|
|
data ButtonEvent
|
|
= ButtonDoNothing
|
|
| ButtonPress
|
|
{ _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
|
|
}
|
|
| ButtonAccessTerminal
|
|
--deriving (Eq, Show, Read) --, Generic)
|
|
--h--deriving (Eq, Show, Read) --Generic, Flat)
|
|
|
|
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
|
|
}
|
|
--deriving (Eq, Show, Read) --, Generic)
|
|
--h--deriving (Eq, Show, Read) --Generic, Flat)
|
|
|
|
data ButtonState = BtOn | BtOff | BtNoLabel
|
|
deriving Eq -- (Eq, Ord, Show, Read) --Generic, Flat)
|
|
|
|
makeLenses ''Button
|
|
makeLenses ''ButtonEvent
|
|
deriveJSON defaultOptions ''ButtonDraw
|
|
deriveJSON defaultOptions ''ButtonState
|
|
deriveJSON defaultOptions ''ButtonEvent
|
|
deriveJSON defaultOptions ''Button
|