Exemple #1
0
        private bool MakeValid()
        {
            bool madeChanges = false;

            this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, Level.MAX_LEVELS - 1);

            if (LevelStatistics == null)
            {
                this.LevelStatistics = new Statistics[Level.MAX_LEVELS];
                madeChanges = true;
            }

            if (LevelStatistics.Length < Level.MAX_LEVELS)
            {
                this.LevelStatistics = LevelStatistics.Union(new Statistics[Level.MAX_LEVELS - LevelStatistics.Length]).ToArray();
                madeChanges = true;
            }
            else if (LevelStatistics.Length > Level.MAX_LEVELS)
            {
                this.LevelStatistics = LevelStatistics.Take(Level.MAX_LEVELS).ToArray();
                madeChanges = true;
            }

            if (Name == null || this.Name.Length <= 0)
            {
                this.Name = " ";
                madeChanges = true;
            }

            if (this.Audio == null)
            {
                this.Audio = new AudioSettings();
                madeChanges = true;
            }

            if (this.Graphics == null)
            {
                this.Graphics = new GraphicsSettings();
                madeChanges = true;
            }

            if (this.KeyBindings == null)
            {
                this.KeyBindings = new Keybindings();
                madeChanges = true;
            }

            return !madeChanges;
        }
Exemple #2
0
        private bool MakeValid()
        {
            bool madeChanges = false;

            int maxLevels = Level.INIT_LID_FOR_WORLD.Last();
            this.CurrentLevel = (int)MathHelper.Clamp(this.CurrentLevel, 0, maxLevels);

            if (LevelStatistics == null)
            {
                this.LevelStatistics = new Statistics[maxLevels];
                madeChanges = true;
            }

            if (LevelStatistics.Length < maxLevels)
            {
                var stats = LevelStatistics.ToList();
                stats.AddRange(new Statistics[maxLevels - LevelStatistics.Length]);
                LevelStatistics = stats.ToArray();

                madeChanges = true;
            }
            else if (LevelStatistics.Length > maxLevels)
            {
                this.LevelStatistics = LevelStatistics.Take(maxLevels).ToArray();
                madeChanges = true;
            }

            if (Name == null || this.Name.Length <= 0)
            {
                this.Name = "No Namer";
                madeChanges = true;
            }

            if (this.Audio == null)
            {
                this.Audio = new AudioSettings();
                madeChanges = true;
            }

            if (this.Graphics == null)
            {
                this.Graphics = new GraphicsSettings();
                madeChanges = true;
            }

            if (this.KeyBindings == null)
            {
                this.KeyBindings = new Keybindings();
                madeChanges = true;
            }

            return !madeChanges;
        }
        public KeybindingsScreen(Profile curProfile)
            : base("Keybindings")
        {
            mProfile = curProfile;
            originalBindings = curProfile.KeyBindings.Clone();

            // Creates the keybindings menu...
            menuList = new List<KeybindingKV>() {
                new KeybindingKV("Move Forward",        curProfile.KeyBindings.MoveForward){},
                new KeybindingKV("Move Backwards",      curProfile.KeyBindings.MoveBackwards){},
                new KeybindingKV("Crouch",              curProfile.KeyBindings.Crouch){},
                new KeybindingKV("Jump",                curProfile.KeyBindings.Jump){},
                new KeybindingKV("Interact",            curProfile.KeyBindings.Interact){},
                new KeybindingKV("Pause",               curProfile.KeyBindings.Pause){},
                new KeybindingKV("Portal 1 (Pink) Fire", curProfile.KeyBindings.Portal1){},
                new KeybindingKV("Portal 2 (Red) Fire",  curProfile.KeyBindings.Portal2){},
            };

            foreach (KeybindingKV keyItem in menuList)
            {
                string title = keyItem.Key;
                string[] choices = new string[2];
                choices[0] = keyItem.Value[0].ToString();
                choices[1] = keyItem.Value[1].ToString();
                ButtonGroup buttonRow = new ButtonGroup(title, choices);
                buttonRow.Buttons[0].Pressed += OpenKeybindingDialog(keyItem, buttonRow, 0);
                buttonRow.Buttons[1].Pressed += OpenKeybindingDialog(keyItem, buttonRow, 1);
                MenuEntries.Add(buttonRow);
            }

            // Menu Items that are special
            MenuEntry acceptMenuEntry = new MenuEntry("Accept");
            MenuEntry cancelMenuEntry = new MenuEntry("Cancel");

            // Event bindings
            acceptMenuEntry.Pressed += SaveButton;
            acceptMenuEntry.Pressed += OnCancel;
            cancelMenuEntry.Pressed += CancelButton;

            // Menu entries on our list
            StackPanel btmPanel = new StackPanel(new UIElement[] { acceptMenuEntry, cancelMenuEntry });
            MenuEntries.Add(btmPanel);
        }