Files
loop/src/Dodge/Data/Button.hs
T
justin dae0e0591c Fix bugs in equipment allocation using hotkeys
The behaviour is still not perfect, should be able to cycle through all
options by pressing one key. There is unnecessary memory of past state
going on here
2025-01-01 14:48:17 +00:00

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 | BtInactive
deriving Eq -- (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''Button
makeLenses ''ButtonEvent
deriveJSON defaultOptions ''ButtonDraw
deriveJSON defaultOptions ''ButtonState
deriveJSON defaultOptions ''ButtonEvent
deriveJSON defaultOptions ''Button