void Update()
        {
            if (!Input.anyKeyDown || gameObject != CardGameManager.TopMenuCanvas?.gameObject)
            {
                return;
            }

            if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && joinButton.interactable)
            {
                Join();
            }
            else if (Input.GetKeyDown(Inputs.BluetoothReturn) && Toggles.Contains(EventSystem.current.currentSelectedGameObject))
            {
                EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>().isOn = true;
            }
            else if (Input.GetButtonDown(Inputs.New))
            {
                Host();
            }
            else if (Input.GetButtonDown(Inputs.Vertical))
            {
                ScrollToggles(Input.GetAxis(Inputs.Vertical) > 0);
            }
            else if (Input.GetButtonDown(Inputs.Page))
            {
                ScrollPage(Input.GetAxis(Inputs.Page) < 0);
            }
            else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
            {
                Hide();
            }
        }
Exemple #2
0
        void Update()
        {
            if (!_modal.IsFocused)
            {
                return;
            }

            if (Input.GetButtonDown(Inputs.Vertical) || Input.GetAxis(Inputs.Vertical) != 0)
            {
                if (Input.GetAxis(Inputs.Vertical) > 0 && !_wasUp)
                {
                    SelectPrevious();
                }
                else if (Input.GetAxis(Inputs.Vertical) < 0 && !_wasDown)
                {
                    SelectNext();
                }
            }

            if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && joinButton.interactable)
            {
                Join();
            }
            else if (Input.GetKeyDown(Inputs.BluetoothReturn) && Toggles.Contains(EventSystem.current.currentSelectedGameObject))
            {
                EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>().isOn = true;
            }
            else if (Input.GetButtonDown(Inputs.New))
            {
                Host();
            }
            else if ((Input.GetButtonDown(Inputs.PageVertical) || Input.GetAxis(Inputs.PageVertical) != 0) && !_wasPage)
            {
                ScrollPage(Input.GetAxis(Inputs.PageVertical));
            }
            else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
            {
                Hide();
            }

            _wasDown = Input.GetAxis(Inputs.Vertical) < 0;
            _wasUp   = Input.GetAxis(Inputs.Vertical) > 0;
            _wasPage = Input.GetAxis(Inputs.PageVertical) != 0;
        }
Exemple #3
0
        /// <summary>
        /// Appends the toggle to the end of the main content (see <see cref="Content"/>).
        /// The toggle will also be added to the <see cref="Toggles"/> array if it is not
        /// included in that array yet.
        /// </summary>
        /// <param name="toggle">Toggle.</param>
        public void AppendToggle(Toggle toggle)
        {
            if (toggle == null)
            {
                return;
            }

            // Append the toggle-represent text into the main content.
            string element = TogglePattern + "Id = " + toggle.Id + ">";

            AppendText(element);

            // Add the toggle into the array if needed.
            if (!Toggles.Contains(toggle))
            {
                var list = new List <Toggle>(Toggles);
                list.Add(toggle);
                Toggles = list.ToArray();
            }
        }
        void Update()
        {
            if (urlInput.isFocused || !Input.anyKeyDown || gameObject != CardGameManager.TopMenuCanvas?.gameObject)
            {
                return;
            }

            if (downloadPanel.gameObject.activeSelf)
            {
                if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && downloadButton.interactable)
                {
                    StartDownload();
                }
                else if ((Input.GetButtonDown(Inputs.New) || Input.GetButtonDown(Inputs.Load)) && urlInput.interactable)
                {
                    Clear();
                }
                else if (Input.GetButtonDown(Inputs.Save) && urlInput.interactable)
                {
                    Paste();
                }
                else if (Input.GetButtonDown(Inputs.FocusName) && urlInput.interactable)
                {
                    urlInput.ActivateInputField();
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    HideDownloadPanel();
                }
            }
            else
            {
                if (Input.GetKeyDown(Inputs.BluetoothReturn) && Toggles.Contains(EventSystem.current.currentSelectedGameObject))
                {
                    EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>().isOn = true;
                }
                else if (Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit))
                {
                    Hide();
                }
                else if (Input.GetButtonDown(Inputs.Sort))
                {
                    Share();
                }
                else if (Input.GetButtonDown(Inputs.New) || Input.GetButtonDown(Inputs.Load))
                {
                    ShowDownloadPanel();
                }
                else if (Input.GetButtonDown(Inputs.Delete))
                {
                    Delete();
                }
                else if (Input.GetButtonDown(Inputs.Horizontal))
                {
                    if (Input.GetAxis(Inputs.Horizontal) < 0)
                    {
                        CardGameManager.Instance.SelectLeft();
                    }
                    else
                    {
                        CardGameManager.Instance.SelectRight();
                    }
                    Rebuild(CardGameManager.Instance.AllCardGames.Keys.ToList(), SelectGame, CardGameManager.Current.Name);
                }
                else if (Input.GetButtonDown(Inputs.Vertical))
                {
                    ScrollToggles(Input.GetAxis(Inputs.Vertical) > 0);
                }
                else if (Input.GetButtonDown(Inputs.Page))
                {
                    ScrollPage(Input.GetAxis(Inputs.Page) < 0);
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    Hide();
                }
            }
        }
Exemple #5
0
        void LateUpdate()
        {
            if (nameInputField.isFocused || !Input.anyKeyDown || gameObject != CardGameManager.TopMenuCanvas?.gameObject)
            {
                return;
            }

            if (newDeckPanel.gameObject.activeSelf)
            {
                if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && EventSystem.current.currentSelectedGameObject == null)
                {
                    DoSaveDontOverwrite();
                }
                else if (Input.GetButtonDown(Inputs.New) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.text = string.Empty;
                }
                else if (Input.GetButtonDown(Inputs.FocusName) && EventSystem.current.currentSelectedGameObject == null)
                {
                    nameInputField.ActivateInputField();
                }
                else if (Input.GetButtonDown(Inputs.FocusText) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.ActivateInputField();
                }
                else if (Input.GetButtonDown(Inputs.Save) && EventSystem.current.currentSelectedGameObject == null)
                {
                    PasteClipboardIntoText();
                }
                else if (Input.GetButtonDown(Inputs.Delete) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.text = string.Empty;
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    HideNewDeckPanel();
                }
            }
            else
            {
                if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && loadFromFileButton.interactable)
                {
                    LoadFromFileAndHide();
                }
                else if (Input.GetKeyDown(Inputs.BluetoothReturn) && Toggles.Contains(EventSystem.current.currentSelectedGameObject))
                {
                    EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>().isOn = true;
                }
                else if (Input.GetButtonDown(Inputs.Sort) && shareFileButton.interactable)
                {
                    Share();
                }
                else if (Input.GetButtonDown(Inputs.New))
                {
                    ShowNewDeckPanel();
                }
                else if (Input.GetButtonDown(Inputs.Delete) && deleteFileButton.interactable)
                {
                    PromptForDeleteFile();
                }
                else if (Input.GetButtonDown(Inputs.Vertical))
                {
                    ScrollToggles(Input.GetAxis(Inputs.Vertical) > 0);
                }
                else if (Input.GetButtonDown(Inputs.Page))
                {
                    ScrollPage(Input.GetAxis(Inputs.Page) < 0);
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    Hide();
                }
            }
        }
        void Update()
        {
            if (!_modal.IsFocused || nameInputField.isFocused)
            {
                return;
            }

            if (newDeckPanel.gameObject.activeSelf)
            {
                if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && EventSystem.current.currentSelectedGameObject == null)
                {
                    DoSaveDontOverwrite();
                }
                else if (Input.GetButtonDown(Inputs.New) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.text = string.Empty;
                }
                else if ((Input.GetButtonDown(Inputs.FocusBack) || Input.GetAxis(Inputs.FocusBack) != 0) && EventSystem.current.currentSelectedGameObject == null)
                {
                    nameInputField.ActivateInputField();
                }
                else if ((Input.GetButtonDown(Inputs.FocusNext) || Input.GetAxis(Inputs.FocusNext) != 0) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.ActivateInputField();
                }
                else if (Input.GetButtonDown(Inputs.Save) && EventSystem.current.currentSelectedGameObject == null)
                {
                    PasteClipboardIntoText();
                }
                else if (Input.GetButtonDown(Inputs.Option) && EventSystem.current.currentSelectedGameObject == null)
                {
                    textInputField.text = string.Empty;
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    HideNewDeckPanel();
                }
            }
            else
            {
                if (Input.GetButtonDown(Inputs.Vertical) || Input.GetAxis(Inputs.Vertical) != 0)
                {
                    if (Input.GetAxis(Inputs.Vertical) > 0 && !_wasUp)
                    {
                        SelectPrevious();
                    }
                    else if (Input.GetAxis(Inputs.Vertical) < 0 && !_wasDown)
                    {
                        SelectNext();
                    }
                }

                if ((Input.GetKeyDown(Inputs.BluetoothReturn) || Input.GetButtonDown(Inputs.Submit)) && loadFromFileButton.interactable)
                {
                    LoadFromFileAndHide();
                }
                else if (Input.GetKeyDown(Inputs.BluetoothReturn) && Toggles.Contains(EventSystem.current.currentSelectedGameObject))
                {
                    EventSystem.current.currentSelectedGameObject.GetComponent <Toggle>().isOn = true;
                }
                else if (Input.GetButtonDown(Inputs.Sort) && shareFileButton.interactable)
                {
                    Share();
                }
                else if (Input.GetButtonDown(Inputs.New))
                {
                    ShowNewDeckPanel();
                }
                else if (Input.GetButtonDown(Inputs.Option) && deleteFileButton.interactable)
                {
                    PromptForDeleteFile();
                }
                else if ((Input.GetButtonDown(Inputs.PageVertical) || Input.GetAxis(Inputs.PageVertical) != 0) && !_wasPage)
                {
                    ScrollPage(Input.GetAxis(Inputs.PageVertical));
                }
                else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
                {
                    Hide();
                }
            }

            _wasDown = Input.GetAxis(Inputs.Vertical) < 0;
            _wasUp   = Input.GetAxis(Inputs.Vertical) > 0;
            _wasPage = Input.GetAxis(Inputs.PageVertical) != 0;
        }