Example #1
0
 public override void Update(GameTime gameTime)
 {
     //TODO: Replace these with event registers
     if (InputManager.IsButtonReleased(OpenTK.Input.Buttons.A))
     {
         OptionSelected?.Invoke(options[selectedIndex]);
         selectedIndex = 0;
         InterfaceManager.RefreshUI = true;
     }
     if (InputManager.IsDpadButtonReleased(OpenTK.Input.Buttons.DPadDown))
     {
         selectedIndex++;
         if (selectedIndex == options.Length)
         {
             selectedIndex = 0;
         }
         Load();
     }
     else if (InputManager.IsDpadButtonReleased(OpenTK.Input.Buttons.DPadUp))
     {
         selectedIndex--;
         if (selectedIndex == -1)
         {
             selectedIndex = options.Length - 1;
         }
         Load();
     }
 }
Example #2
0
        void ListItemSelected(object sender, ItemClickEventArgs e)
        {
            var selection = (string)e.ClickedItem;

            options.SetResult(selection);

            OptionSelected?.Invoke(this, null);
        }
Example #3
0
        void ActionButtonClicked(object sender, RoutedEventArgs e)
        {
            var button    = (Windows.UI.Xaml.Controls.Button)sender;
            var selection = (string)button.Content;

            options.SetResult(selection);

            OptionSelected?.Invoke(this, null);
        }
Example #4
0
        private void _switch_Toggled(object sender, ToggledEventArgs e)
        {
            Field.Value = e.Value ? "true" : "false";
            IsDirty     = OriginalValue != Field.Value;

            OptionSelected?.Invoke(this, new OptionSelectedEventArgs()
            {
                Key = Field.Name.ToPropertyName(), Value = Field.Value
            });
        }
Example #5
0
        //Show this menu to the screen
        public void Show()
        {
            InitScreen();
            //Remember current background/text color
            var currentBgColor  = Console.BackgroundColor;
            var currentTxtColor = Console.ForegroundColor;

            //Keep in this menu until isFinished = true
            while (!isFinished)
            {
                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.Black;
                ConsoleFunctions.writeToCenter($"({selectedOption}) {_MenuOptions[selectedOption-1].ToString()}", 4 + selectedOption - 1);
                Console.ForegroundColor = currentTxtColor;
                Console.BackgroundColor = currentBgColor;

                //Read user input
                var pressedKey = Console.ReadKey();
                switch (pressedKey.Key)
                {
                //Options are printed from top to bottom
                case ConsoleKey.UpArrow:
                    if (!(selectedOption == 1))
                    {
                        selectedOption--;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (!(selectedOption == _MenuOptions.Length))
                    {
                        selectedOption++;
                    }
                    break;

                //Raise OptionSelected event with SelectedOption
                case ConsoleKey.Enter:
                    OptionSelected.Invoke(this, selectedOption);
                    InitScreen();     //Reinit the screen after returning to this menu
                    break;

                //Exit Menu
                case ConsoleKey.Backspace:
                    isFinished = true;
                    break;
                }
                //draw all Options again
                for (int i = 0; i < _MenuOptions.Length; i++)
                {
                    ConsoleFunctions.writeToCenter($"({i+1}) {_MenuOptions[i].ToString()}", 4 + i);
                }
            }
        }
Example #6
0
    /// <summary>
    /// tell whoever's listening what the user decided,
    /// re-enable the stuff we disabled,
    /// and disable ourselves
    /// </summary>
    /// <param name="choice"></param>
    public void SelectOption(bool choice)
    {
        AnimatePanelsIn();
        OptionSelected.Invoke(choice);
        IEnumerator coroutine = AnimateOut();

        //check if the game object is active before calling it
        if (gameObject.activeSelf)
        {
            StartCoroutine(coroutine);
        }
    }
Example #7
0
 public void Update()
 {
     if (Visible)
     {
         if (GameboyInputs.UpPressed())
         {
             Index--;
             if (Index < 0)
             {
                 Index = _options.Length - 1;
             }
         }
         else if (GameboyInputs.DownPressed())
         {
             Index++;
             if (Index == _options.Length)
             {
                 Index = 0;
             }
         }
         else if (CanCancel && GameboyInputs.BPressed())
         {
             if (_options.Length > _cancelIndex)
             {
                 OptionSelected?.Invoke(_options[_cancelIndex], _cancelIndex);
             }
             else
             {
                 // option to cancel is not in the options set
                 OptionSelected?.Invoke(null, _cancelIndex);
             }
             if (CloseAfterSelection)
             {
                 Close();
             }
         }
         else if (GameboyInputs.APressed())
         {
             OptionSelected?.Invoke(_options[Index], Index);
             if (CloseAfterSelection)
             {
                 Close();
             }
         }
     }
 }
Example #8
0
        private void _picker_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_picker.SelectedIndex == 0)
            {
                _validationMessage.IsVisible = Field.IsRequired;
                Field.Value = null;
            }
            else
            {
                _validationMessage.IsVisible = false;
                Field.Value = Field.Options[_picker.SelectedIndex - 1].Key;
            }

            IsDirty = OriginalValue != Field.Value;

            OptionSelected?.Invoke(this, new OptionSelectedEventArgs()
            {
                Key = Field.Name.ToPropertyName(), Value = Field.Value
            });
        }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        transform.position = gameObject.transform.position;
        transform.rotation = gameObject.transform.rotation;

        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit))
        {
            line.useWorldSpace = true;
            line.SetPosition(0, transform.position);
            line.SetPosition(1, hit.point);
            if (!triggerDown && controller.TriggerValue > 0.8f)
            {
                triggerDown = true;
                if (hit.transform.tag != null)
                {
                    OptionSelected?.Invoke(hit.transform.tag);
                }
            }
        }
        else
        {
            line.useWorldSpace = false;
            line.SetPosition(0, transform.position);
            line.SetPosition(1, Vector3.forward * 5);
        }

        if (!triggerDown && controller.TriggerValue > 0.8f)
        {
            triggerDown = true;
        }
        if (controller.TriggerValue < 0.2f)
        {
            triggerDown = false;
        }
    }
Example #10
0
        void OnOptionSelected(object sender, SelectionChangedEventArgs e)
        {
            if (!OptionSelectionHandled)
            {
                var option = e.AddedItems.FirstOrDefault()?.As <DateTime>();

                if (option != null)
                {
                    var result = option.Value.TimeOfDay;
                    SetCurrentValue(ValueProperty.Property, result);

                    OptionSelectionHandled     = true;
                    PART_Options.SelectedIndex = -1;
                    OptionSelectionHandled     = false;

                    OptionSelected?.Invoke(this, new EventArgs <TimeSpan>(result));
                }

                if (!StaysOpenOnSelection)
                {
                    SetCurrentValue(IsDropDownOpenProperty, false);
                }
            }
        }
Example #11
0
 void OptionUpdateInternal(int newIndex)
 {
     _index = newIndex;
     UpdateDisplay();
     OptionSelected?.Invoke(this, _index, _options[_index]);
 }
Example #12
0
 void ExamplesListView_ItemTapped(object sender, ItemTappedEventArgs e) => OptionSelected?.Invoke(this, new OptionSelectedEventArgs((e.Item as Example).ExampleClass));
Example #13
0
 private void OnClick()
 {
     OptionSelected?.Invoke(_option);
 }
Example #14
0
 public void InvokeOptionSelected(OptionSelectedEventArgs optionSelectedEventArgs)
 {
     OptionSelected?.Invoke(this, optionSelectedEventArgs);
 }