Simplify button drawing
This commit is contained in:
@@ -5,12 +5,14 @@ import Dodge.Data.Button
|
||||
import Geometry
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import Control.Lens
|
||||
|
||||
drawButton :: ButtonDraw -> Button -> SPic
|
||||
drawButton bd = case bd of
|
||||
DefaultDrawButton col -> defaultDrawButton col
|
||||
DefaultDrawSwitch col1 col2 -> drawSwitch col1 col2
|
||||
DrawNoButton -> const mempty
|
||||
drawButton :: Button -> SPic
|
||||
drawButton bt = case bt ^. btEvent of
|
||||
ButtonPress {_bpColor = col} -> defaultDrawButton col bt
|
||||
ButtonSimpleSwith {_bssColor1 = col1, _bssColor2 = col2} -> drawSwitch col1 col2 bt
|
||||
ButtonAccessTerminal -> mempty
|
||||
ButtonDoNothing -> mempty
|
||||
|
||||
drawSwitch :: Color -> Color -> Button -> SPic
|
||||
drawSwitch col1 col2 bt
|
||||
|
||||
@@ -9,13 +9,13 @@ import Dodge.WorldEffect
|
||||
doButtonEvent :: ButtonEvent -> Button -> World -> World
|
||||
doButtonEvent be = case be of
|
||||
ButtonDoNothing -> const id
|
||||
ButtonPress newstate newevent thesound f -> \b ->
|
||||
ButtonPress newstate newevent thesound f c -> \b ->
|
||||
doWdWd f
|
||||
. set (cWorld . lWorld . buttons . ix (_btID b) . btState) newstate
|
||||
. set (cWorld . lWorld . buttons . ix (_btID b) . btEvent) newevent
|
||||
. soundStart (LeverSound 0) (_btPos b) thesound Nothing
|
||||
--ButtonSwitch onstate onevent onsound oneff offstate offevent offsound offeff -> undefined
|
||||
ButtonSimpleSwith oneff offeff -> flipSwitch oneff offeff
|
||||
ButtonSimpleSwith oneff offeff _ _ -> flipSwitch oneff offeff
|
||||
ButtonAccessTerminal -> accessTerminal . _btTermMID
|
||||
|
||||
flipSwitch :: WdWd -> WdWd -> Button -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user