1 {-# LANGUAGE ScopedTypeVariables #-}
5 import Control.Concurrent
6 import Data.ReactiveValue
9 import Graphics.UI.Gtk.Reactive
11 import RMCA.Auxiliary.Concurrent
12 import RMCA.Auxiliary.RV
13 import RMCA.Global.Clock
14 import RMCA.Layer.Board
15 import RMCA.Layer.Layer
17 import RMCA.Translator.Jack
18 import RMCA.Translator.Message
19 import RMCA.Translator.Translator
24 boardRVIO = newCBMVarRW $
25 makeBoard [((0,0), mkCell (ChDir True na1 NE)),
26 ((1,1), mkCellRpt (ChDir False na1 NW) 3),
27 ((0,1), mkCell (ChDir False na1 S))]
28 {-makeBoard [((0,0), mkCell (ChDir True na1 N)),
29 ((0,2), mkCellRpt (ChDir False na2 SE) 3),
30 ((2,1), mkCell (ChDir False na1 SW)),
31 ((1,1), mkCellRpt (ChDir False na1 N) 0) {- Skipped! -},
32 ((0,4), mkCellRpt (ChDir True na1 N) (-1)) {- Rpt indef. -},
33 ((0, -6), mkCell (ChDir True na1 N)),
34 ((0, -2), mkCell (ChDir False na3 S) {- Silent -})]-}
39 naOrn = Ornaments Nothing [] NoSlide
45 naOrn = Ornaments Nothing [(10, MIDICVRnd)] SlideUp
51 naOrn = Ornaments Nothing [] NoSlide
58 newTempoRV :: IO (ReactiveFieldReadWrite IO Tempo)
59 newTempoRV = newCBMVarRW 200
66 set window [ windowTitle := "Reactogon"
68 globalSettingsBox <- vBoxNew False 10
69 containerAdd window globalSettingsBox
70 tempoAdj <- adjustmentNew 96 0 200 1 1 0
71 tempoLabel <- labelNew (Just "Tempo")
72 boxPackStart globalSettingsBox tempoLabel PackNatural 0
73 tempoScale <- hScaleNew tempoAdj
74 boxPackStart globalSettingsBox tempoScale PackGrow 0
75 let tempoRV = bijection (floor, fromIntegral) `liftRW` scaleValueReactive tempoScale
76 ------------------------------------------------------------------------------
77 layerRV <- getDefaultLayerRV
78 boardQueue <- newCBMVarRW []
80 layer <- reactiveValueRead layerRV
81 tempo <- reactiveValueRead tempoRV
83 board <- reactiveValueRead boardRV
84 (inBoard, outBoard) <- yampaReactiveDual (board, layer, tempo)
85 (boardSF $ startHeads board)
86 let inRV = liftRW2 (bijection (\(x,y,z) -> (x,(y,z)), \(x,(y,z)) -> (x,y,z)))
87 boardRV $ pairRW layerRV tempoRV
88 clock <- mkClockRV 100
91 --reactiveValueOnCanRead outBoard (reactiveValueRead outBoard >>= print . ("Board out " ++) . show)
92 reactiveValueOnCanRead outBoard $ do
93 bq <- reactiveValueRead boardQueue
94 ob <- reactiveValueRead $ liftR (event [] id) outBoard
95 reactiveValueWrite boardQueue (bq ++ ob)
97 --reactiveValueOnCanRead outBoard (reactiveValueRead outBoard >>= print)
98 putStrLn "Board started."
100 forkIO $ jackSetup tempoRV (constR 0) boardQueue
102 onDestroy window mainQuit