void QuitEditor() { _lastSelectionGrid = editor.SelectionGrid; _lastWorld = Levels.GetWorldOfLevel(map); _lastMapType = MapType(); editor = null; mode = Mode.Menu; _paraPhysicalMapLogic = null; _inventories.Save(); }
void SaveGrid() { string[] lines = Levels.GetLinesFromGrid(editor.MapGrid, mode != Mode.Minimap ? 4 : 1, mode != Mode.Minimap, Levels.TilesOffset(Levels.GetWorldOfLevel(map), MapType())); File.WriteAllLines(Levels.GetLevelPath(map, MapType()), lines); if (Settings.Paradise && mode == Mode.Physical) { string objectsPath = Levels.GetObjectsPath(map); string[] objects = _paraPhysicalMapLogic.GetLines(); File.WriteAllLines(objectsPath, objects); } }
bool LoadGrid() { int[,] grid; List <GridEditor.OverlayGrid> underlays = new List <GridEditor.OverlayGrid>(); List <GridEditor.OverlayGrid> overlays = new List <GridEditor.OverlayGrid>(); string world = Levels.GetWorldOfLevel(map); Levels.MapType mapType = MapType(); string levelPath = Levels.GetLevelPath(map, mapType); if (!File.Exists(levelPath)) // Should only happen in Paradise { return(false); } if (mode == Mode.Minimap) { grid = Levels.GetGridFromLines(File.ReadAllLines(levelPath), 64, 64, Levels.TilesOffset(world, Levels.MapType.Minimap)); sset = new TilesSet(Load.MinimapColors, false, _ssetBounds, 64); } else { Load.LoadWorldTiles(GraphicsDevice, world); grid = Levels.GetGridFromLines(File.ReadAllLines(levelPath), Levels.TilesOffset(world, mapType)); sset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, mapType)], true, _ssetBounds, 64); if (Settings.Paradise && mode == Mode.Physical) { string objectsPath = Levels.GetObjectsPath(map); string[] objects = File.Exists(objectsPath) ? File.ReadAllLines(objectsPath) : new string[0]; _paraPhysicalMapLogic = new ParadisePhysicalMapLogic(objects); } int[,] ogrid; TilesSet osset; if (mode != Mode.Background) { try { ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Background)), Levels.TilesOffset(world, Levels.MapType.Background)); osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Background)], true, Rectangle.Empty, 0); underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false)); } catch { } } if (mode != Mode.Graphical2) { try { ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Graphical2)), Levels.TilesOffset(world, Levels.MapType.Graphical2)); osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Graphical2)], true, Rectangle.Empty, 0); if (mode == Mode.Background) { overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false)); } else { underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false)); } } catch { } } if (mode != Mode.Graphical) { try { ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Graphical)), Levels.TilesOffset(world, Levels.MapType.Graphical)); osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Graphical)], true, Rectangle.Empty, 0); if (mode == Mode.Physical) { underlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false)); } else { overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, false)); } } catch { } } if (mode != Mode.Physical) { try { ogrid = Levels.GetGridFromLines(File.ReadAllLines(Levels.GetLevelPath(map, Levels.MapType.Physical)), Levels.TilesOffset(world, Levels.MapType.Physical)); osset = new TilesSet(Load.Tiles[new Load.WorldAndType(world, Levels.MapType.Physical)], true, Rectangle.Empty, 0); overlays.Add(new GridEditor.OverlayGrid(osset, ogrid, true)); } catch { } } } int[,] selectionGrid = null; if (_lastMapType == mapType /*&& (_lastWorld == world || mapType == Levels.MapType.Physical || mapType == Levels.MapType.Minimap)*/) { // Sometimes, inter-world copy paste can be relevant even for grounds and backgrounds selectionGrid = _lastSelectionGrid; } editor = new GridEditor(this, MapType(), _gridEditorBounds, sset, grid, new Point(-8, -8), overlays.ToArray(), underlays.ToArray(), selectionGrid, _inventories.GetInventory(MapType())); return(true); }