Skip to content

Commit

Permalink
remove one reference to default subworld name
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jul 17, 2023
1 parent 4785e4b commit b8505b3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/Swarm/Game/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Swarm/TUI/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Swarm/TUI/Editor/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm/TUI/Editor/Masking.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/Swarm/TUI/Editor/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8505b3

Please sign in to comment.