//======================================================================================== // Object management - internal methods. // Add room to active area. private bool ForceAddRoom(int mapX, int mapY, int width, int height, string name) { if (AreaIndex == IndexNone) { return(false); } int newRoomIndex = NewRoomIndex(AreaIndex); if (newRoomIndex == -1) { return(false); } DoorSet newDoorSet = new DoorSet(); newDoorSet.SetDefault(); Room newRoom = new Room(); newRoom.SetDefault(); newRoom.MapX = (byte)mapX; newRoom.MapY = (byte)mapY; newRoom.Width = (byte)width; newRoom.Height = (byte)height; newRoom.Name = name; newRoom.MyDoorSet = newDoorSet; Rooms [AreaIndex].Add(newRoom); DoorSets.Add(newDoorSet); ForceSelectRoom(Rooms [AreaIndex].Count - 1); ForceAddRoomState(StateType.Standard); ChangesMade = true; return(true); }
public void Close() { if (!ProjectLoaded) { return; } Rooms.Clear(); DoorSets.Clear(); Doors.Clear(); ScrollSets.Clear(); PlmSets.Clear(); ScrollPlmDatas.Clear(); Backgrounds.Clear(); Fxs.Clear(); SaveStations.Clear(); LevelDatas.Clear(); EnemySets.Clear(); EnemyGfxs.Clear(); ScrollAsms.Clear(); DoorAsms.Clear(); SetupAsms.Clear(); MainAsms.Clear(); TileSets.Clear(); TileTables.Clear(); TileSheets.Clear(); Palettes.Clear(); AreaMaps.Clear(); PlmTypes.Clear(); EnemyTypes.Clear(); CurrentRom = null; ProjectPath = String.Empty; RomFileName = String.Empty; ProjectFileName = String.Empty; RoomTiles.Clear(); MapTiles.Clear(); BackgroundImage = null; ChangesMade = false; ProjectLoaded = false; ProjectClosed?.Invoke(this, null); }
//---------------------------------------------------------------------------------------- // Read all rooms from ROM. private void ReadRooms(Rom rom, List <Tuple <int, int, string> > rooms, out List <RoomState> roomStates) { roomStates = new List <RoomState> (); Rooms.Clear(); for (int n = 0; n < rooms.Count; n++) { Room newRoom = new Room(); newRoom.ReadFromROM(rom, rooms [n].Item1); newRoom.Name = rooms [n].Item3; Rooms [newRoom.Area].Add(newRoom); var newDoorSet = new DoorSet() { DoorCount = rooms [n].Item2 }; newDoorSet.ReadFromROM(rom, newRoom.DoorsPtrPC); DoorSets.Add(newDoorSet); for (int i = 0; i < newRoom.RoomStates.Count; i++) { roomStates.Add(newRoom.RoomStates [i]); } } }
//======================================================================================== // Object management - tools. private void DeleteData(Data data) { if (data is IReferenceable refdata) { refdata.DetachAllReferences(); } switch (data) { case Room d: Rooms.Remove(d); break; case DoorSet d: DoorSets.Remove(d); break; case Door d: Doors.Remove(d); break; case ScrollSet d: ScrollSets.Remove(d); break; case PlmSet d: PlmSets.Remove(d); break; case ScrollPlmData d: ScrollPlmDatas.Remove(d); break; case Background d: Backgrounds.Remove(d); break; case Fx d: Fxs.Remove(d); break; case SaveStation d: SaveStations.Remove(d); break; case LevelData d: LevelDatas.Remove(d); break; case EnemySet d: EnemySets.Remove(d); break; case EnemyGfx d: EnemyGfxs.Remove(d); break; case ScrollAsm d: ScrollAsms.Remove(d); break; case Asm d: DoorAsms.Remove(d); SetupAsms.Remove(d); MainAsms.Remove(d); break; case TileSet d: TileSets.Remove(d); break; case TileTable d: TileTables.Remove(d); break; case TileSheet d: TileSheets.Remove(d); break; case Palette d: Palettes.Remove(d); break; case AreaMap d: AreaMaps.Remove(d); break; default: break; } ChangesMade = true; }