Example #1
0
        public ProfileScreen(StorageDevice device)
            : base("Profile Management")
        {
            mDevice = device;
            indicator = new MenuEntry("");
            indicator.Position = new Vector2(70, -100);
            indicator.State = UIState.Selected;

            var temp = Profile.LoadAll(mDevice);

            mProfiles = temp.Value;

            string[] profileOptions = { "Delete", "Rename", "Make Active" };
            for (int i = 0; i < mProfiles.Count; i++)
            {
                if (mProfiles[i].ProfileNumber >= mNextProfile)
                    mNextProfile = mProfiles[i].ProfileNumber + 1;

                ButtonGroup profileGroup = new ButtonGroup(mProfiles[i].Name, profileOptions);
                profileGroup.HideInactive = true;

                profileGroup.Buttons[0].Pressed += ConfirmDeleteProfile(mProfiles[i]);
                profileGroup.Buttons[1].Pressed += RenameProfile(mProfiles[i]);
                profileGroup.Buttons[2].Pressed += SetDefaultProfile(mProfiles[i]);

                MenuEntries.Add(profileGroup);
            }

            MenuEntry addMenuEntry = new MenuEntry("Add Profile");
            addMenuEntry.Pressed += MakeProfile;
            MenuEntries.Add(addMenuEntry);

            MenuEntry backMenuEntry = new MenuEntry("Back");
            backMenuEntry.Pressed += OnCancel;
            MenuEntries.Add(backMenuEntry);

            Default = temp.Key;
        }
Example #2
0
        EventHandler<PlayerIndexEventArgs> AddProfile(InputDialog dialog)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                Profile prof = new Profile();
                prof.Name = dialog.Content;
                prof.ProfileNumber = mNextProfile++;

                string[] profileOptions = { "Delete", "Rename", "Make Active" };
                ButtonGroup profileGroup = new ButtonGroup(prof.Name, profileOptions);
                profileGroup.HideInactive = true;
                profileGroup.LoadContent(this);

                profileGroup.Buttons[0].Pressed += ConfirmDeleteProfile(prof);
                profileGroup.Buttons[1].Pressed += RenameProfile(prof);
                profileGroup.Buttons[2].Pressed += SetDefaultProfile(prof);

                MenuEntries.Insert(MenuEntries.Count - 2, profileGroup);
                mProfiles.Add(prof);
                PositionElements();
                prof.Register();

                if (mProfiles.Count == 1)
                {
                    Default = prof.ProfileNumber;
                    Profile.SaveProfile(prof, "default.sav", mDevice);
                    (this.ScreenManager.Game as HalfCakedGame).CurrentProfile = prof;

                    if (ProfileSelected != null)
                        ProfileSelected.Invoke(this, e);
                }
                else
                    Profile.SaveProfile(prof, "profile" + prof.ProfileNumber + ".sav", mDevice);
            };
        }
        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);
        }
        // Keybindings Dialog event generator
        System.EventHandler<PlayerIndexEventArgs> OpenKeybindingDialog(KeybindingKV s, ButtonGroup row, int index)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                MessageBoxScreen dialog = new KeybindingDialog(
                    s.Key,
                    (Keybinding input) => {
                        // update the user's profile with the new keybinding
                        this.SetKeybinding(s, input, row.SelectedButton);

                        //updates the GUI
                        row.Buttons[index].Text = input.ToString();
                        Resize(row.Buttons[index]);
                    }
                );
                ScreenManager.AddScreen(dialog, ControllingPlayer);
            };
        }
        public KeybindingsScreen(Profile curProfile)
            : base("Keybindings")
        {
            ButtonGroup bg1 = new ButtonGroup("A", new string[2] { "1", "3332" });
            ButtonGroup bg2 = new ButtonGroup("BC", new string[2] { "1", "3332" });
            ButtonGroup bg3 = new ButtonGroup("CAC", new string[2] { "---1", "2" });
            ButtonGroup bg4 = new ButtonGroup("DCAB", new string[2] { "12", "23333" });
            ButtonGroup bg5 = new ButtonGroup("EFGBA", new string[2] { "321", "23" });

            MenuEntry backMenuEntry = new MenuEntry("Back");

            backMenuEntry.Pressed += OnCancel;

            MenuEntries.Add(bg1);
            MenuEntries.Add(bg2);
            MenuEntries.Add(bg3);
            MenuEntries.Add(bg4);
            MenuEntries.Add(bg5);
            MenuEntries.Add(backMenuEntry);

            mProfile = curProfile;
        }