Esempio n. 1
0
        // Add room state to active room.
        private bool ForceAddRoomState(StateType type)
        {
            if (ActiveRoom == null)
            {
                return(false);
            }
            RoomStateHeader newHeader = new RoomStateHeader();

            newHeader.SetDefault();
            newHeader.HeaderType = type;

            var newState     = new RoomState();
            var newLevelData = new LevelData(RoomWidthInScreens, RoomHeightInScreens);
            var newPlmSet    = new PlmSet();
            var newEnemySet  = new EnemySet();
            var newEnemyGfx  = new EnemyGfx();
            var newFx        = new Fx();

            newState.SetDefault();
            newLevelData.SetDefault();
            newPlmSet.SetDefault();
            newEnemySet.SetDefault();
            newEnemyGfx.SetDefault();
            newFx.SetDefault();

            newState.SetLevelData(newLevelData, out var ignore1);
            newState.SetScrollSet(null, out var ignore2);
            newState.SetPlmSet(newPlmSet, out var ignore3);
            newState.SetEnemySet(newEnemySet, out var ignore4);
            newState.SetEnemyGfx(newEnemyGfx, out var ignore5);
            newState.SetFx(newFx, out var ignore6);
            newState.SetBackground(null, out var ignore7);
            newState.SetSetupAsm(null, out var ignore8);
            newState.SetMainAsm(null, out var ignore9);

            ActiveRoom.RoomStateHeaders.Insert(0, newHeader);
            ActiveRoom.RoomStates.Insert(0, newState);
            LevelDatas.Add(newState.MyLevelData);
            PlmSets.Add(newState.MyPlmSet);
            EnemySets.Add(newState.MyEnemySet);
            EnemyGfxs.Add(newState.MyEnemyGfx);
            Fxs.Add(newState.MyFx);
            ChangesMade = true;
            return(true);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        // Read all PLM sets from ROM.
        private void ReadPlmSets(Rom rom, List <RoomState> roomStates)
        {
            List <int> addressesPC = new List <int> ();

            foreach (RoomState r in roomStates)
            {
                int address = Tools.LRtoPC(r.PlmSetPtr);
                if (address != 0)
                {
                    addressesPC.Add(address);
                }
            }
            Tools.RemoveDuplicates(addressesPC);
            PlmSets.Clear();
            for (int n = 0; n < addressesPC.Count; n++)
            {
                PlmSets.Add(new PlmSet());
                PlmSets [n].ReadFromROM(rom, addressesPC [n]);
            }
        }
Esempio n. 4
0
//========================================================================================
// 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;
        }