Refactor sounds

This commit is contained in:
2021-09-09 14:58:07 +01:00
parent be7b2d2cd7
commit 70c97f5367
26 changed files with 113 additions and 162 deletions
+4 -6
View File
@@ -18,11 +18,7 @@ makeButton c eff = Button
, _btPos = V2 0 0
, _btRot = 0
, _btEvent = \b w -> eff . over buttons (IM.adjust turnOn (_btID b))
-- . set (buttons . ix (_btID b) . btPict)
-- (onLayer WlLayer $ color c $ polygon $ rectNSEW (-3) (-5) 10 (-10))
-- . set (buttons . ix (_btID b) . btState) BtNoLabel
-- . set (buttons . ix (_btID b) . btEvent) (\b -> return)
. soundOnce 1 $ w
. soundFromGeneral (LeverSound 0) (btpos b) 1 Nothing $ w
, _btID = 0
, _btText = "Button"
--, _btText = "Button"
@@ -31,6 +27,7 @@ makeButton c eff = Button
where
turnOn bt = bt {_btState = BtNoLabel, _btPict = onPict, _btEvent = const id}
onPict = setLayer 0 $ onLayer WlLayer (color c $ polygon $ rectNSEW (-3) (-5) 10 (-10))
btpos b w' = _btPos $ _buttons w' IM.! _btID b
makeSwitch
:: Color
@@ -47,7 +44,8 @@ makeSwitch c effOn effOff = Button
, _btState = BtOff
}
where
flipSwitch b w = switchEffect b . soundOnce 1 $ w
flipSwitch b w = switchEffect b . soundFromGeneral (LeverSound 0) (bpos b) 1 Nothing $ w
bpos b w = _btPos $ _buttons w IM.! _btID b
switchEffect b = case _btState b of
BtOff -> effOn . over buttons (IM.adjust turnOn (_btID b))
BtOn -> effOff . over buttons (IM.adjust turnOff (_btID b))