Skip to content

Commit

Permalink
WIP toplevel record reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jan 9, 2025
1 parent 1dbf414 commit b0d98d5
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/swarm-tui/Swarm/TUI/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ data SwarmKeyDispatchers = SwarmKeyDispatchers
, robotDispatcher :: SwarmKeyDispatcher
}


-- | This encapsulates both game and UI state for an actively-playing scenario.
data PlayState = PlayState {
_gameState :: GameState
, _somethingState :: ()
}

--------------------------------------------------
-- Lenses for PlayState

makeLensesNoSigs ''PlayState

-- | The 'GameState' record.
gameState :: Lens' PlayState GameState

-- | The 'UIGameplay' record.
somethingState :: Lens' PlayState ()


-- ----------------------------------------------------------------------------
-- APPSTATE --
-- ----------------------------------------------------------------------------
Expand All @@ -174,7 +193,7 @@ data SwarmKeyDispatchers = SwarmKeyDispatchers
-- or updating the UI. Also consider that GameState can change when loading
-- a new scenario - if the state should persist games, use RuntimeState.
data AppState = AppState
{ _gameState :: GameState
{ _playState :: PlayState
, _uiState :: UIState
, _keyEventHandling :: KeyEventHandlingState
, _runtimeState :: RuntimeState
Expand Down Expand Up @@ -315,11 +334,9 @@ keyDispatchers :: Lens' KeyEventHandlingState SwarmKeyDispatchers
--------------------------------------------------
-- Lenses for AppState

playState :: Functor f => (PlayState -> f PlayState) -> AppState -> f AppState
makeLensesNoSigs ''AppState

-- | The 'GameState' record.
gameState :: Lens' AppState GameState

-- | The 'UIState' record.
uiState :: Lens' AppState UIState

Expand Down

0 comments on commit b0d98d5

Please sign in to comment.