示例#1
0
        public void NumberTest()
        {
            var btw = new BinaryTextWriter();

            btw.AddNumber(7, 4);
            btw.AddNumber(1, 10);
            var btr = new BinaryTextReader(btw.GetOutputString());

            Assert.AreEqual(7, btr.ReadNumber(4));
            Assert.AreEqual(1, btr.ReadNumber(10));
        }
示例#2
0
        // constructor
        public Settings(string config = null)
        {
            SetDefaults();

            if (string.IsNullOrEmpty(config))
            {
                return;
            }

            BinaryTextReader btr;

            try
            {
                btr = new BinaryTextReader(config);
            }
            catch (FormatException)
            {
                throw new FormatException("Config string is not valid.");
            }

            // check version
            int    major     = btr.ReadNumber(4);
            int    minor     = btr.ReadNumber(4);
            int    patch     = btr.ReadNumber(4);
            string configVer = $"{major}.{minor}.{patch}";

            // convert settings
            switch (configVer)
            {
            case "1.4.0":
                LoadSettings(btr);
                break;

            case "1.3.0":
            case "1.3.1":
            case "1.3.2":
                LoadSettings_1_3_2(btr);
                break;

            default:
                throw new FormatException("Config string is not valid.");
            }
        }
示例#3
0
        private void LoadSettings(BinaryTextReader btr)
        {
            // items
            randomAbilities = btr.ReadBool();
            randomTanks     = btr.ReadBool();

            // excluded items
            excludedItems = new List <int>();
            for (int i = 0; i < 100; i++)
            {
                bool excluded = btr.ReadBool();
                if (excluded)
                {
                    excludedItems.Add(i);
                }
            }

            gameCompletion      = (GameCompletion)btr.ReadNumber(2);
            iceNotRequired      = btr.ReadBool();
            plasmaNotRequired   = btr.ReadBool();
            noPBsBeforeChozodia = btr.ReadBool();
            chozoStatueHints    = btr.ReadBool();
            infiniteBombJump    = btr.ReadBool();
            wallJumping         = btr.ReadBool();

            // palettes
            tilesetPalettes = btr.ReadBool();
            enemyPalettes   = btr.ReadBool();
            beamPalettes    = btr.ReadBool();
            hueMinimum      = btr.ReadNumber(8);
            hueMaximum      = btr.ReadNumber(8);

            // misc
            enableItemToggle     = btr.ReadBool();
            obtainUnkItems       = btr.ReadBool();
            hardModeAvailable    = btr.ReadBool();
            pauseScreenInfo      = btr.ReadBool();
            removeCutscenes      = btr.ReadBool();
            removeNorfairVine    = btr.ReadBool();
            removeVariaAnimation = btr.ReadBool();
            skipSuitless         = btr.ReadBool();
        }
示例#4
0
        // constructor
        public Settings_Old(string str = null)
        {
            if (string.IsNullOrEmpty(str))
            {
                SetDefaults();
                return;
            }

            BinaryTextReader btr;

            try
            {
                btr = new BinaryTextReader(str);
            }
            catch (FormatException)
            {
                throw new FormatException("Config string is not valid.");
            }

            // check version
            int configVer = btr.ReadNumber(10);

            if (configVer != version)
            {
                // convert settings
                SetDefaults();
                switch (configVer)
                {
                case 100:
                    LoadSettings100(btr);
                    break;

                case 110:
                    LoadSettings110(btr);
                    break;

                default:
                    throw new FormatException("Config string is not valid.");
                }
            }
            else
            {
                LoadSettings(btr);
            }
        }
示例#5
0
        private void LoadSettings_1_3_2(BinaryTextReader btr)
        {
            // items
            bool randAbilities = btr.ReadBool();
            bool randTanks     = btr.ReadBool();

            if (randAbilities && randTanks)
            {
                AbilitySwap = Swap.GlobalPool;
                TankSwap    = Swap.GlobalPool;
            }
            else if (randAbilities)
            {
                AbilitySwap = Swap.LocalPool;
            }
            else if (randTanks)
            {
                TankSwap = Swap.LocalPool;
            }

            if (btr.ReadBool())
            {
                NumItemsRemoved = btr.ReadNumber(7);
            }
            if (SwapOrRemoveItems)
            {
                Completion          = (GameCompletion)btr.ReadNumber(2);
                IceNotRequired      = btr.ReadBool();
                PlasmaNotRequired   = btr.ReadBool();
                NoPBsBeforeChozodia = btr.ReadBool();
                ChozoStatueHints    = btr.ReadBool();
                InfiniteBombJump    = btr.ReadBool();
                WallJumping         = btr.ReadBool();
            }

            // locations
            if (btr.ReadBool())
            {
                int count = btr.ReadNumber(7);
                for (int i = 0; i < count; i++)
                {
                    int      locNum = btr.ReadNumber(7);
                    ItemType item   = (ItemType)btr.ReadNumber(5);
                    CustomAssignments[locNum] = item;
                }
            }

            // enemies
            RandoEnemies = btr.ReadBool();

            // palettes
            TilesetPalettes = btr.ReadBool();
            EnemyPalettes   = btr.ReadBool();
            BeamPalettes    = btr.ReadBool();
            if (RandomPalettes)
            {
                if (btr.ReadBool())
                {
                    HueMinimum = btr.ReadNumber(8);
                }
                if (btr.ReadBool())
                {
                    HueMaximum = btr.ReadNumber(8);
                }
            }

            // misc
            EnableItemToggle    = btr.ReadBool();
            ObtainUnkItems      = btr.ReadBool();
            HardModeAvailable   = btr.ReadBool();
            PauseScreenInfo     = btr.ReadBool();
            RemoveCutscenes     = btr.ReadBool();
            SkipSuitless        = btr.ReadBool();
            SkipDoorTransitions = btr.ReadBool();
        }
示例#6
0
        private void LoadSettings(BinaryTextReader btr)
        {
            // items
            AbilitySwap = (Swap)btr.ReadNumber(2);
            TankSwap    = (Swap)btr.ReadNumber(2);
            if (btr.ReadBool())
            {
                NumItemsRemoved = btr.ReadNumber(7);
                if (btr.ReadBool())
                {
                    NumAbilitiesRemoved = btr.ReadNumber(4);
                }
            }
            if (SwapOrRemoveItems)
            {
                Completion          = (GameCompletion)btr.ReadNumber(2);
                IceNotRequired      = btr.ReadBool();
                PlasmaNotRequired   = btr.ReadBool();
                NoPBsBeforeChozodia = btr.ReadBool();
                ChozoStatueHints    = btr.ReadBool();
                InfiniteBombJump    = btr.ReadBool();
                WallJumping         = btr.ReadBool();
            }

            // locations
            if (btr.ReadBool())
            {
                int count = btr.ReadNumber(7);
                for (int i = 0; i < count; i++)
                {
                    int      locNum = btr.ReadNumber(7);
                    ItemType item   = (ItemType)btr.ReadNumber(5);
                    CustomAssignments[locNum] = item;
                }
            }

            // enemies
            RandoEnemies = btr.ReadBool();

            // palettes
            TilesetPalettes = btr.ReadBool();
            EnemyPalettes   = btr.ReadBool();
            SamusPalettes   = btr.ReadBool();
            BeamPalettes    = btr.ReadBool();
            if (RandomPalettes)
            {
                if (btr.ReadBool())
                {
                    HueMinimum = btr.ReadNumber(8);
                }
                if (btr.ReadBool())
                {
                    HueMaximum = btr.ReadNumber(8);
                }
            }

            // music
            MusicChange = (Change)btr.ReadNumber(2);
            if (MusicChange != Change.Unchanged)
            {
                MusicRooms  = (Swap)btr.ReadNumber(2);
                MusicBosses = (Swap)btr.ReadNumber(2);
                MusicOthers = (Swap)btr.ReadNumber(2);
            }

            // misc
            EnableItemToggle    = btr.ReadBool();
            ObtainUnkItems      = btr.ReadBool();
            HardModeAvailable   = btr.ReadBool();
            PauseScreenInfo     = btr.ReadBool();
            RemoveCutscenes     = btr.ReadBool();
            SkipSuitless        = btr.ReadBool();
            SkipDoorTransitions = btr.ReadBool();
        }