Пример #1
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Get the pointer table
            var pointerTable = PointerTables.GBA_PointerTable(s.Context, Offset.file);

            // Serialize the offset table
            s.DoAt(pointerTable[GBA_Pointer.UiOffsetTable], () => UiOffsetTable = s.SerializeObject <GBA_OffsetTable>(UiOffsetTable, name: nameof(UiOffsetTable)));

            var manager = (GBA_Manager)s.Context.Settings.GetGameManager;

            switch (manager.GetLevelType(s.Context))
            {
            case GBA_Manager.LevelType.Game:
                // Serialize the level block for the current level
                Scene = s.DoAt(UiOffsetTable.GetPointer(s.Context.Settings.Level), () => s.SerializeObject <GBA_Scene>(Scene, name: nameof(Scene)));
                break;

            case GBA_Manager.LevelType.Menu:
                // Serialize the playfield for the current menu
                MenuLevelPlayfield = s.DoAt(UiOffsetTable.GetPointer(s.Context.Settings.Level), () => s.SerializeObject <GBA_PlayField>(MenuLevelPlayfield, name: nameof(MenuLevelPlayfield)));
                break;

            case GBA_Manager.LevelType.MadTrax:
                MadTraxPlayfield1 = s.DoAt(UiOffsetTable.GetPointer(0), () => s.SerializeObject <GBA_MadTraxPlayField>(MadTraxPlayfield1, name: nameof(MadTraxPlayfield1)));
                MadTraxPlayfield2 = s.DoAt(UiOffsetTable.GetPointer(1), () => s.SerializeObject <GBA_MadTraxPlayField>(MadTraxPlayfield2, name: nameof(MadTraxPlayfield2)));
                MadTraxPalette    = s.DoAt(UiOffsetTable.GetPointer(2), () => s.SerializeObject <GBA_Palette>(MadTraxPalette, name: nameof(MadTraxPalette)));

                break;

            case GBA_Manager.LevelType.DLC:
                // Nothing more to do here if it's a DLC map...
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Get the pointer table
            var pointerTable = PointerTables.GBA_PointerTable(s.Context, Offset.file);

            // Serialize the offset table
            s.DoAt(pointerTable[GBA_Pointer.UiOffsetTable], () => UiOffsetTable = s.SerializeObject <GBA_OffsetTable>(UiOffsetTable, name: nameof(UiOffsetTable)));

            var manager = (GBA_Manager)s.Context.Settings.GetGameManager;

            switch (manager.GetLevelType(s.Context))
            {
            case GBA_Manager.LevelType.Game:
                // Serialize the level block for the current level

                // Common
                if (s.GameSettings.GBA_IsCommon)
                {
                    Scene = s.DoAt(UiOffsetTable.GetPointer(s.Context.Settings.Level), () => s.SerializeObject <GBA_Scene>(Scene, name: nameof(Scene)));
                }
                // Mad Trax
                else if (s.GameSettings.EngineVersion == EngineVersion.GBA_R3_MadTrax)
                {
                    MadTraxPlayField_BG = s.DoAt(UiOffsetTable.GetPointer(0), () => s.SerializeObject <GBA_PlayField>(MadTraxPlayField_BG, name: nameof(MadTraxPlayField_BG)));
                    MadTraxPlayField_FG = s.DoAt(UiOffsetTable.GetPointer(1), () => s.SerializeObject <GBA_PlayField>(MadTraxPlayField_FG, name: nameof(MadTraxPlayField_FG)));
                    MadTraxPalette      = s.DoAt(UiOffsetTable.GetPointer(2), () => s.SerializeObject <GBA_Palette>(MadTraxPalette, name: nameof(MadTraxPalette)));
                }
                // Milan
                else if (s.GameSettings.GBA_IsMilan)
                {
                    Milan_SceneList = s.DoAt(UiOffsetTable.GetPointer(0), () => s.SerializeObject <GBA_Milan_SceneList>(Milan_SceneList, name: nameof(Milan_SceneList)));
                    // TODO: Parse block 1 and 2 (menus?)
                }
                // Shanghai
                else
                {
                    Shanghai_Scene = s.DoAt(UiOffsetTable.GetPointer(s.Context.Settings.Level), () => s.SerializeObject <GBA_Shanghai_Scene>(Shanghai_Scene, name: nameof(Shanghai_Scene)));
                }

                break;

            case GBA_Manager.LevelType.Menu:
                // Serialize the playfield for the current menu
                MenuLevelPlayfield = s.DoAt(UiOffsetTable.GetPointer(s.Context.Settings.Level), () => s.SerializeObject <GBA_PlayField>(MenuLevelPlayfield, name: nameof(MenuLevelPlayfield)));
                break;

            case GBA_Manager.LevelType.DLC:
                // Nothing more to do here if it's a DLC map...
                break;
            }
        }