module DisplayState (newDState) where import Graphics.Rendering.OpenGL import Graphics.UI.GLUT import States import EventFlags import qualified Data.Map as Map newDState :: MState -> KState -> DState -> DState newDState mst kst dst = changeAllDisplayEvent dst mst -------ディスプレイイベントの実行 changeDisplayEvent :: MState -> DState -> EventKey -> DState changeDisplayEvent mst dst ekey = case ekey of EDivPlus -> eventDivPlusButton mst dst EDivMinus -> eventDivMinusButton mst dst _ -> dst changeAllDisplayEvent :: DState -> MState -> DState changeAllDisplayEvent dst mst = let ekeys = Map.keys (events mst) in foldl (changeDisplayEvent mst) dst ekeys ------分割増加ボタンイベント eventDivPlusButton :: MState -> DState -> DState eventDivPlusButton mst dst = if (\(Just x) -> x) (mStateGetEventFlag mst EDivPlus ) then let dCounterV = (dStateGetCounterV dst CDivTileNum) in if (dCounterV <= 7) then (dStateChangeCounterV dst (CDivTileNum , (dCounterV + 1) )) else dst else dst ------分割減小ボタンイベント eventDivMinusButton :: MState -> DState -> DState eventDivMinusButton mst dst = if (\(Just x) -> x) (mStateGetEventFlag mst EDivMinus ) then let dCounterV = (dStateGetCounterV dst CDivTileNum) in if (dCounterV >= 4) then (dStateChangeCounterV dst (CDivTileNum , (dCounterV - 1) )) else dst else dst