From b8505b32876792054c497f4a9800ed312f4cbf9b Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Sun, 16 Jul 2023 19:05:34 -0700 Subject: [PATCH] remove one reference to default subworld name --- src/Swarm/Game/State.hs | 5 +++-- src/Swarm/TUI/Controller.hs | 3 +-- src/Swarm/TUI/Editor/Controller.hs | 7 ++++--- src/Swarm/TUI/Editor/Masking.hs | 2 +- src/Swarm/TUI/Editor/Model.hs | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Swarm/Game/State.hs b/src/Swarm/Game/State.hs index 6ffed257d4..5562fab9fc 100644 --- a/src/Swarm/Game/State.hs +++ b/src/Swarm/Game/State.hs @@ -1215,8 +1215,9 @@ scenarioToGameState scenario (LaunchParams (Identity userSeed) (Identity toRun)) -- guaranteed to be first. genRobots = concat $ NE.toList $ NE.map (fst . snd) builtWorldTuples - builtWorldTuples = NE.map (worldName &&& buildWorld em) - $ scenario ^. scenarioWorlds + builtWorldTuples = + NE.map (worldName &&& buildWorld em) $ + scenario ^. scenarioWorlds allSubworldsMap s = M.map genWorld diff --git a/src/Swarm/TUI/Controller.hs b/src/Swarm/TUI/Controller.hs index 0b6f96934a..f3f67ff835 100644 --- a/src/Swarm/TUI/Controller.hs +++ b/src/Swarm/TUI/Controller.hs @@ -78,7 +78,6 @@ import Swarm.Game.Robot import Swarm.Game.ScenarioInfo import Swarm.Game.State import Swarm.Game.Step (finishGameTick, gameTick) -import Swarm.Game.Universe import Swarm.Language.Capability (Capability (CDebug, CMake)) import Swarm.Language.Context import Swarm.Language.Key (KeyCombo, mkKeyCombo) @@ -396,7 +395,7 @@ handleMainEvent ev = do case n of FocusablePanel WorldPanel -> do mouseCoordsM <- Brick.zoom gameState $ mouseLocToWorldCoords mouseLoc - shouldUpdateCursor <- EC.updateAreaBounds $ fmap (^. planar) mouseCoordsM + shouldUpdateCursor <- EC.updateAreaBounds mouseCoordsM when shouldUpdateCursor $ uiState . uiWorldCursor .= mouseCoordsM REPLInput -> handleREPLEvent ev diff --git a/src/Swarm/TUI/Editor/Controller.hs b/src/Swarm/TUI/Editor/Controller.hs index 4452551383..07bc536340 100644 --- a/src/Swarm/TUI/Editor/Controller.hs +++ b/src/Swarm/TUI/Editor/Controller.hs @@ -109,7 +109,7 @@ handleWorldEditorPanelEvent = \case _ -> return () -- | Return value: whether the cursor position should be updated -updateAreaBounds :: Maybe W.Coords -> EventM Name AppState Bool +updateAreaBounds :: Maybe (Cosmo W.Coords) -> EventM Name AppState Bool updateAreaBounds = \case Nothing -> return True Just mouseCoords -> do @@ -118,10 +118,11 @@ updateAreaBounds = \case UpperLeftPending -> do uiState . uiWorldEditor . editingBounds . boundsSelectionStep .= LowerRightPending mouseCoords return False - -- TODO (#1152): Validate that the lower-right click is below and to the right of the top-left coord + -- TODO (#1152): Validate that the lower-right click is below and to the right of + -- the top-left coord and that they are within the same subworld LowerRightPending upperLeftMouseCoords -> do uiState . uiWorldEditor . editingBounds . boundsRect - .= Just (Cosmo defaultRootSubworldName (upperLeftMouseCoords, mouseCoords)) + .= Just (fmap (,view planar mouseCoords) upperLeftMouseCoords) uiState . uiWorldEditor . lastWorldEditorMessage .= Nothing uiState . uiWorldEditor . editingBounds . boundsSelectionStep .= SelectionComplete t <- liftIO $ getTime Monotonic diff --git a/src/Swarm/TUI/Editor/Masking.hs b/src/Swarm/TUI/Editor/Masking.hs index f2988ed90b..034229b5b4 100644 --- a/src/Swarm/TUI/Editor/Masking.hs +++ b/src/Swarm/TUI/Editor/Masking.hs @@ -25,7 +25,7 @@ shouldHideWorldCell ui coords = ) isOutsideSingleSelectedCorner = fromMaybe False $ do - cornerCoords <- case we ^. editingBounds . boundsSelectionStep of + Cosmo _ cornerCoords <- case we ^. editingBounds . boundsSelectionStep of LowerRightPending cornerCoords -> Just cornerCoords _ -> Nothing pure $ EU.isOutsideTopLeftCorner cornerCoords coords diff --git a/src/Swarm/TUI/Editor/Model.hs b/src/Swarm/TUI/Editor/Model.hs index fd88defa9f..8f62befba9 100644 --- a/src/Swarm/TUI/Editor/Model.hs +++ b/src/Swarm/TUI/Editor/Model.hs @@ -22,7 +22,7 @@ import System.Clock data BoundsSelectionStep = UpperLeftPending | -- | Stores the *world coords* of the upper-left click - LowerRightPending W.Coords + LowerRightPending (Cosmo W.Coords) | SelectionComplete data EntityPaint