packages feed

minesweeper-0.8.8: Event.hs

module Event where

import Core.Square
import Configuration (Configuration)
import State (ScoreAttr, ScoreEntry)

-------------------------------------- input -------------

type MousePos = Maybe Square

data Event
    = RevealEvent MousePos  -- Nothing: by keyboard
    | MarkEvent   MousePos  -- Nothing: by keyboard
    | MouseMotion MousePos  -- Nothing: mouse is outside
    | NewEvent
    | LeftEvent
    | RightEvent
    | UpEvent
    | DownEvent
    | UndoEvent
    | RedoEvent
    | HintEvent 
    | FullHintEvent 
    | ShowScores
    | OpenPreferences
    | PreferencesClosed (Maybe Configuration)
    | NewScoreClosed (Maybe String) [ScoreAttr]
    | FocusOut
    | FocusIn   MousePos    -- Nothing: mouse is outside

    | UpdateTable

    -- jóváhagyások (legyen mindenről?)
    | DrawingDone 
    | InfoDrawingDone 

    | Init                  -- triggered?

    | Triggered Triggered       -- nem kéne beágyazni ide
        deriving (Eq, Ord, Show)

data Triggered
    = RevealDone
    | SquareHintDone
    | Tick
    | FadeTick
    | BusyTick
    | InterruptVisible      -- better name: LongInterrupt
        deriving (Eq, Ord, Show)


---------------------------- output --------------------

type Responses = [Response]

data Response
    = DrawSquares Board [(Square, (Bool, BackGround, Sign))]
    | ShowTime String       -- gyorsulna szerkezetváltással
    | ShowInfo String       -- gyorsulna szerkezetváltással
    | PopUpPreferences Configuration
    | PopUpNewScore Configuration (Maybe Int) [ScoreEntry] [ScoreAttr]
        deriving (Eq, Ord, Show)

data BackGround 
    = Blue
    | BlueGreen
    | Green
    | Reddish Int   -- ^ 0-100
        deriving (Eq, Ord, Show)

data Sign
    = NoSign
    | Bomb
    | Death
    | Clear Int -- ^ 0-8
    | Hint Int  -- ^ 0-100
    | HintedBomb Int  -- ^ 0-100
    | BusySign Int  -- ^ phase 0-100
        deriving (Eq, Ord, Show)


isBomb Bomb           = True
isBomb (HintedBomb _) = True
isBomb _              = False