Example #1
0
        private void ValidateMenuBeforeStarting(Menu menu)
        {
            //Can't start a menu if there's no activity running.
            if (!HasActivityRunning())
            {
                throw new Exception("Unable to start Menu : no Activity is currently running.");
            }

            //Can't start a menu if it's allways visible
            if (menu.IsAlwaysVisible())
            {
                throw new Exception("Unable to start Menu : it is allways visible.");
            }

            //Can't start menu if it's not part of the current activity.
            StackedActivity currentActivity = GetCurrentActivity();
            StackedMenu     stackedMenu     = currentActivity.GetMenu(menu);

            if (stackedMenu == null)
            {
                throw new Exception("Unable to start Menu : it is not part of the current Activity.");
            }

            //Can't start menu if it's allready started
            if (menuStack.Contains(stackedMenu))
            {
                throw new Exception("Unable to start Menu : it is already running.");
            }
        }
        private void HideCurrentMenu()
        {
            StackedMenu currentMenu = GetCurrentMenu();

            currentMenu.OnPause();
            currentMenu.OnStop();
        }
        private void ShowCurrentMenu()
        {
            StackedMenu currentMenu = GetCurrentMenu();

            currentMenu.OnCreate(menuStack.Count);
            currentMenu.OnResume();
        }
 protected override void OnInitialize(object enterInformation)
 {
     base.OnInitialize(enterInformation);
     _inputMenu = new StackedMenu(Game)
     {
         Title = "Input"
     };
     _inputMenu.AppendMenuItem(new EnumMenuItem(Game, "Player", new[] { "1", "2", "3", "4" }));
     _inputMenu.AppendMenuItem(new EnumMenuItem(Game, "Device", new[] { "Keyboard", "GamePad" }));
     _inputMenu.AppendMenuItem(new ActionMenuItem(Game, "Configure", () => { }));
     _inputMenu.AppendMenuItem(new ActionMenuItem(Game, "Back", HandleBack, ActionTriggerKind.IsCancel));
 }
Example #5
0
        private void StopCurrentMenuProcedure()
        {
            if (HasMenuRunning())
            {
                StackedMenu currentMenu = GetCurrentMenu();
                currentMenu.Pause();
                currentMenu.Stop();
            }

            PopMenu();

            if (HasMenuRunning())
            {
                StackedMenu currentMenu = GetCurrentMenu();
                currentMenu.Resume();
            }
        }
Example #6
0
        private void StartMenuProcedure(Menu menu, params object[] parameters)
        {
            if (HasMenuRunning())
            {
                StackedMenu currentMenu = GetCurrentMenu();
                currentMenu.Pause();
            }

            PushMenu(menu);

            if (HasMenuRunning())
            {
                StackedMenu currentMenu = GetCurrentMenu();
                currentMenu.Start(menuStack.Count, parameters);
                currentMenu.Resume();
            }
        }
Example #7
0
        protected override void OnInitialize(object enterInformation)
        {
            base.OnInitialize(enterInformation);

            _optionsMenu = new StackedMenu(Game)
            {
                Title = "Options"
            };
            _optionsMenu.AppendMenuItem(new InputMenuItem(Game, "Port", 5, InputType.Numeric)
            {
                InputText = Game.GetPropertyIntOrDefault(MultiPlayerPortPropertyName, 1170).ToString(CultureInfo.InvariantCulture)
            });
            _optionsMenu.AppendMenuItem(new BoolMenuItem(Game, "Sound", DecisionType.OnOff, Game.GetPropertyBoolOrDefault(SoundPropertyName)));
            _optionsMenu.AppendMenuItem(new BoolMenuItem(Game, "FullScreen", DecisionType.YesNo, Game.GetPropertyBoolOrDefault(GameProperty.GameIsFullScreenProperty)));
            _optionsMenu.AppendMenuItem(new EnumMenuItem(Game, "Game Mode", new[] { "2D", "3D" }, Game.GetPropertyStringOrDefault(GameModePropertyName, "2D")));
            _optionsMenu.AppendMenuItem(new EnumMenuItem(Game, "Resolution", GetResolutions(), GetCurrentResultion()));
            _optionsMenu.AppendMenuItem(new ActionMenuItem(Game, "Configure Inputs", HandleConfigureInput));
            _optionsMenu.AppendMenuItem(new ActionMenuItem(Game, "Back", HandleBack, ActionTriggerKind.IsCancel));
        }
        private void PushMenu(Menu menu, object[] parameters)
        {
            if (menu.IsAlwaysVisible())
            {
                throw new ArgumentException("Unable to start Menu : menu is allways visible.");
            }
            if (!HasActivityRunning())
            {
                throw new ArgumentException("Unable to start Menu : no activity running.");
            }
            StackedActivity currentActivity = GetCurrentActivity();
            StackedMenu     stackedMenu     = currentActivity.GetMenu(menu);

            if (stackedMenu == null)
            {
                throw new ArgumentException("Unable to start Menu : menu is not part of the current activity.");
            }
            stackedMenu.SetParameters(parameters);
            menuStack.Push(stackedMenu);
        }
Example #9
0
        private void PushMenu(Menu menu)
        {
            StackedMenu stackedMenu = GetCurrentActivity().GetMenu(menu);

            menuStack.Push(stackedMenu);
        }