コード例 #1
0
        protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
        {
            if (input.x == settings.submitAction)
            {
                if (data != null)
                {
                    int buttonSelect = (int)data[0];

                    if (buttonSelect < 4)
                    {
                        bool origValue = (bool)data[1];
                        switch (buttonSelect)
                        {
                        case 0: UIManager.uiSettings.showCrosshair = !origValue; break;

                        case 1: UIManager.uiSettings.showCompass = !origValue; break;

                        case 2: UIManager.uiSettings.showSubtitles = !origValue; break;

                        case 3: UIManager.uiSettings.showMiniMap = !origValue; break;
                        }
                        UpdateUIButtons(panelIndex);//, false);
                        SaveLoad.SaveSettingsOptions();
                    }
                    else
                    {
                        OnChangeColor(buttonSelect - 4);
                    }
                }
            }
        }
コード例 #2
0
ファイル: UIPopups.cs プロジェクト: hafewa/MinimalUI
 static void MakeButton(UISelectable element, string text, object[] data)
 {
     element.uiText.SetText(text);//, -1);
     element.data = data;
     element.EnableFlair(0, false);
     element.EnableFlair(1, false);
 }
コード例 #3
0
        // public string fullTradeMenuName = "FullTradeMenu";
        // [Action] public int singleTradeAction = 0, tradeAllAction = 1, switchToFullTradeAction = 2;

        // protected override void GetActionsAndHints (out List<int> actions, out List<string> hints) {
        //     actions = GetActions();
        //     hints = new List<string>() { "Take", "Take All", "Trade" };
        // }

        // protected override List<int> GetActions () {
        //     return new List<int> () { singleTradeAction, tradeAllAction, switchToFullTradeAction };
        // }

        protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
        {
            bool updateButtons = false;


            // single trade
            // if (input.x == singleTradeAction){
            //     if (data != null) {
            //         InventorySlot item = data[0] as InventorySlot;
            //         if (item != null) {
            //             showingInventory.TransferItemAlreadyInInventoryTo(item, item.count, takingInventory, sendMessage: false);
            //             updateButtons = true;
            //         }
            //     }
            // }
            // // take all
            // else if (input.x == tradeAllAction){
            //     // TODO: check if shown inventory has anything
            //     showingInventory.TransferInventoryContentsTo(takingInventory, sendMessage: false);
            //     updateButtons = true;
            // }
            // else if (input.x == switchToFullTradeAction){
            //     manualMenu.CloseMenu();

            //     //maybe use update mananger....
            //     StartCoroutine(OpenFullTrade());
            // }

            if (updateButtons)
            {
                UpdateUIButtons(panelIndex);//, true);
            }
        }
コード例 #4
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
        // bool isCollection { get { return (uiObject as UIWithInputCollection) != null; } }
        // bool usesRadial { get { return (uiObject as UIRadial) != null; } }
        // bool isPaginated { get { return !usesRadial && MaxButtons() > 0; } }


        void OnEnable()
        {
            // defaultActions = new List<int> () { settings.submitAction };
            // defaultHints = new List<string> () { "Select" };

            int maxUIPanels = 1;
            UIWithInputCollection collection;

            if (IsCollection(out collection))
            {
                maxUIPanels = collection.subHolders.Length;
            }
            buttonReferences       = new UISelectable[maxUIPanels][];
            paginatedOffsets       = new int[maxUIPanels];
            lastElementsShownCount = new int[maxUIPanels];


            BuildActionsAndHints(out pageActions, out pageActionHints);

            if (allowCancel)
            {
                pageActions.Add(settings.cancelAction);
                pageActionHints.Add("Cancel/Back");
            }
        }
コード例 #5
0
        UISelectable GetCurrentSelectedData(out object[] data)
        {
            data = null;

            GameObject currentSelected = UIManager.CurrentSelected();

            if (currentSelected == null)
            {
                return(null);
            }

            if (!CurrentSelectedIsOurs(currentSelected))
            {
                Debug.LogError("Getting Input for" + name + " but current selected isnt part of our set, " + currentSelected.name);
                return(null);
            }

            UISelectable currentSelectedCheck = currentSelected.GetComponent <UISelectable>();

            if (currentSelectedCheck == null)
            {
                return(null);
            }

            data = currentSelectedCheck.data;
            return(currentSelectedCheck);
        }
コード例 #6
0
        public override void UpdateElementLayout() //bool firstBuild) {
        {
            rectTransform.sizeDelta = Vector2.one * parameters.panelSize;

            float sliceAngle   = 360.0f / Mathf.Max(showElements.Count, 1);
            float radialAmount = 1f / Mathf.Max(showElements.Count, 1);

            Quaternion radialAngleRotation = Quaternion.Euler(0, 0, sliceAngle * .5f);


            float textHeight = 0;

            for (int i = 0; i < showElements.Count; i++)
            {
                float elementAngle = -i * sliceAngle;

                UISelectable element = showElements[i];

                UIBaseParameters.CopyParameters(ref (element as UIRadialSelectable).parameters, parameters.selectableParams);


                element.transform.localRotation = Quaternion.Euler(0, 0, elementAngle);

                element.image.mainGraphic.fillAmount = radialAmount;
                element.image.mainGraphic.rectTransform.localRotation = radialAngleRotation;

                element.uiText.transform.localRotation = Quaternion.Euler(0, 0, -elementAngle);

                if (elementAngle == 0 || elementAngle == -180)
                {
                    element.uiText.SetAnchor(TextAnchor.MiddleCenter, false, Vector2.zero);
                }
                else
                {
                    element.uiText.SetAnchor(elementAngle < -180f ? TextAnchor.MiddleRight : TextAnchor.MiddleLeft, false, Vector2.zero);
                }

                // Vector2 elementTextSize =
                element.UpdateElementLayout();//firstBuild);
                if (i == 0)
                {
                    textHeight = (element as UIRadialSelectable).textHeight; //elementTextSize.y;
                }
            }

            UIBaseParameters.CopyParameters(ref panel.parameters, parameters.panelParams);

            panel.UpdateElementLayout(); //firstBuild);

            float h = textHeight;        //allElements.Count == 0 ? 0 : allElements[0].uiText.getHeight;

            actionHintsPanel.transform.localPosition = new Vector3(0, -(parameters.panelSize * .5f + (h) + parameters.hintsSpace), 0);
            UIBaseParameters.CopyParameters(ref actionHintsPanel.parameters, parameters.controlHintsParams);

            actionHintsPanel.UpdateElementLayout();//firstBuild);

            // return Vector2.zero;
        }
コード例 #7
0
        protected override void SetFlairs(UISelectable element, ManualMenuButton button, int panelIndex)
        {
            int slotSelect = (int)button.data[0];

            if (SaveLoad.SaveExists(slotSelect))
            {
                element.EnableFlair(0, true);
            }
        }
コード例 #8
0
        protected override void SetFlairs(UISelectable element, ManualMenuButton button, int panelIndex)
        {
            int buttonSelect = (int)button.data[0];

            if (buttonSelect < 4)
            {
                element.EnableFlair(0, (bool)button.data[1]);
            }
        }
コード例 #9
0
ファイル: LoadGamePage.cs プロジェクト: hafewa/MinimalUI
 protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
 {
     if (input.x == settings.submitAction)
     {
         if (data != null)
         {
             int slotSelect = (int)data[0];
             LoadGame(slotSelect);
         }
     }
 }
コード例 #10
0
 public void BroadcastSelectEvent(UISelectable buttonObject, object[] data)
 {
     if ((object)parent != null)
     {
         parent.BroadcastSelectEvent(buttonObject, data);
         return;
     }
     if (_onSelect != null)
     {
         _onSelect(buttonObject, data);
     }
 }
コード例 #11
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
        void MakeButton(UISelectable element, string text, ManualMenuButton button, int panelIndex, object[] data, bool enableFlairs)
        {
            element.uiText.SetText(text);
            element.data = data;

            element.EnableFlair(0, false);
            element.EnableFlair(1, false);
            if (enableFlairs)
            {
                SetFlairs(element, button, panelIndex);
            }
        }
コード例 #12
0
        protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
        {
            if (input.x == settings.submitAction)
            {
                manualMenu.CloseMenu();

                if (data != null)
                {
                    // InventorySlot item = data[0] as InventorySlot;
                    // if (item != null) item.item.OnConsume(showingInventory, count: 1, input.y);
                }
            }
        }
コード例 #13
0
 public void BroadcastActionEvent(UISelectable selected, object[] data, Vector2Int submit)
 {
     // Debug.Log("Boradcast action" + name);
     if ((object)parent != null)
     {
         parent.BroadcastActionEvent(selected, data, submit);
         return;
     }
     if (_onAction != null)
     {
         _onAction(selected, data, submit);
     }
 }
コード例 #14
0
        public void DoAction(Vector2Int action)
        {
            if (parent != null)
            {
                parent.DoAction(action);
                return;
            }

            object[]     data;
            UISelectable selected = GetCurrentSelectedData(out data);

            BroadcastActionEvent(selected, data, action);
        }
コード例 #15
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
 public virtual void OnUISelect(UISelectable selectedObject, object[] data)
 {
     if (uiObject.textPanel != null)
     {
         if (data != null)
         {
             ManualMenuButton menuButton = data[0] as ManualMenuButton;
             if (menuButton != null)
             {
                 uiObject.SetPanelText(menuButton.displayDescription);
             }
             // uiObject.textPanel.SetTexts(string.Empty, menuButton.displayDescription, true);
             // uiObject.textPanel.mainText.SetText(menuButton.displayDescription);
         }
     }
 }
コード例 #16
0
ファイル: UIPopups.cs プロジェクト: hafewa/MinimalUI
 static void OnSliderSubmit(UISelectable selectedObject, object[] data, Vector2Int input)
 {
     if (input.x == settings.cancelAction)
     {
         OnCancelSliderUI();
         return;
     }
     else if (input.x == settings.submitAction)
     {
         HidePopup(sliderPopup);//UISliderPopup.instance);
         if (sliderReturnCallback != null)
         {
             sliderReturnCallback(true, (int)sliderPopup.sliderValue);
         }
     }
 }
コード例 #17
0
ファイル: MainMenuPage.cs プロジェクト: hafewa/MinimalUI
 protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
 {
     if (input.x == settings.submitAction)
     {
         if (data != null)
         {
             int methodSelect = (int)data[0];
             if (methodSelect == 0)
             {
                 OnStartNewGame();
             }
             else if (methodSelect == 1)
             {
                 OnQuitGame();
             }
         }
     }
 }
コード例 #18
0
        public virtual void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input)
        {
            if (input.x == settings.submitAction)
            {
                Debug.LogError("PRESSED SUBMIT");

                if (actionsShowing)
                {
                    uiVideoPlayer.Stop();
                }
                else
                {
                    ShowActionHints();
                }

                // if action hints panel showing, stop movie
                // else fade in action hints panel
            }
        }
コード例 #19
0
ファイル: UIPopups.cs プロジェクト: hafewa/MinimalUI
        static void OnSelectionSubmit(UISelectable selectedObject, object[] data, Vector2Int input)
        {
            if (input.x == settings.cancelAction)
            {
                OnCancelSelectionUI();
                return;
            }
            else if (input.x == settings.submitAction)
            {
                HidePopup(selectionPopup);//.instance);

                if (selectionReturnCallback != null)
                {
                    selectionReturnCallback(true, (int)data[0]);

                    // not setting to null because callback might bring up another popup...
                    // selectionReturnCallback = null;
                }
            }
        }
コード例 #20
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
        public virtual void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input)
        {
            if (allowCancel)
            {
                if (input.x == settings.cancelAction)
                {
                    // Debug.Log("GOINGBAKC");
                    manualMenu.GoToPage(backPage);
                    return;
                }
            }

            if (data != null)
            {
                ManualMenuButton menuButton = data[0] as ManualMenuButton;
                if (menuButton != null)
                {
                    if (input.x == settings.submitAction)
                    {
                        if (menuButton.goToPage != null)
                        {
                            // Debug.Log("GOING TO PAGE");
                            menuButton.goToPage.backPage = this;
                            manualMenu.GoToPage(menuButton.goToPage);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(menuButton.callStaticMethod))
                            {
                                SystemTools.CallStaticMethodSimple(menuButton.callStaticMethod);
                            }
                        }
                    }

                    int panelIndex = (int)data[1];

                    OnUIInput(selectedObject, menuButton.data, input, panelIndex);
                }
            }
        }
コード例 #21
0
        UISelectable GetAvailableSelectable()
        {
            UISelectable s = selectablePool.GetAvailable(ElementPrefab(), null, false, null);

            s.selected = false;
            s.parentUI = this;
            // s.transform.SetParent(transform);
            s.transform.SetParent(transform, Vector3.zero, Quaternion.identity, Vector3.one);

            Button button = s.button;//.GetComponent<Button>();

            if (button)
            {
                Navigation customNav = button.navigation;
                customNav.mode = Navigation.Mode.Automatic;// : Navigation.Mode.None;
                // customNav.mode = active ? Navigation.Mode.Horizontal : Navigation.Mode.None;
                button.navigation = customNav;
            }

            s.gameObject.SetActive(true);

            return(s);
        }
コード例 #22
0
        // just debugging....
        public UISelectable AddNewElement(string elementText, bool updateHolder)
        {
            // if (isHoldersCollection) return null;

            UISelectable newElement = Instantiate(ElementPrefab());

            newElement.parentUI = this;
            newElement.transform.SetParent(transform, Vector3.zero, Quaternion.identity, Vector3.one);
            // newElement.transform.localPosition = Vector3.zero;
            // newElement.transform.localRotation = Quaternion.identity;
            // newElement.transform.localScale = Vector3.one;

            // allElements.Add(newElement);
            showElements.Add(newElement);

            newElement.uiText.SetText(elementText);  //, -1);

            if (updateHolder)
            {
                // Debug.Log("Updating after Add");
                UpdateElementLayout();//true, true);// UpdateSelectableElementHolder();
            }
            return(newElement);
        }
コード例 #23
0
 protected override void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex)
 {
 }
コード例 #24
0
 protected override void SetFlairs(UISelectable element, ManualMenuButton button, int panelIndex)
 {
 }
コード例 #25
0
ファイル: UIPopups.cs プロジェクト: hafewa/MinimalUI
        static void OnSliderChange(UISelectable selected, object[] data)
        {
            float value = (float)data[0];

            sliderChangeCallback((int)value);
        }
コード例 #26
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
        // ManualMenuButtonBuilder[] _buttonBuilders;
        // ManualMenuButtonBuilder[] buttonBuilders { get { return gameObject.GetComponentsIfNull<ManualMenuButtonBuilder>(ref _buttonBuilders); } }

        // handle paginated scrolling
        void OnPaginatedUISelect(UISelectable selectedObject, object[] data)
        {
            if (data != null)
            {
                string buttonSelectText = data[0] as string;
                if (buttonSelectText != null)
                {
                    int panelIndex = (int)data[1];

                    bool         updateButtons = false;
                    UISelectable newSelection  = null;

                    // hovered over the page up button
                    if (buttonSelectText == "B")
                    {
                        paginatedOffsets[panelIndex]--;

                        if (paginatedOffsets[panelIndex] != 0)
                        {
                            newSelection = buttonReferences[panelIndex][1];
                        }

                        if (paginatedOffsets[panelIndex] == 1)
                        {
                            paginatedOffsets[panelIndex]--;
                        }

                        updateButtons = true;
                    }

                    // hovered over the page down button
                    else if (buttonSelectText == "F")
                    {
                        paginatedOffsets[panelIndex]++;


                        // bool isAtEnd = paginatedOffsets[panelIndex] >= lastElementsShownCount[panelIndex] - MaxButtons();
                        // bool isAtEnd = paginatedOffsets[panelIndex] + (MaxButtons() - (paginatedOffsets[panelIndex] != 0 ? 2 : 0)) >= ((lastElementsShownCount[panelIndex]));
                        bool isAtEnd = paginatedOffsets[panelIndex] + (MaxButtons() - (1)) >= ((lastElementsShownCount[panelIndex]));

                        if (!isAtEnd)
                        {
                            newSelection = buttonReferences[panelIndex][MaxButtons() - 2];
                            paginatedOffsets[panelIndex]++;
                        }


                        updateButtons = true;
                    }

                    if (updateButtons)
                    {
                        UpdateUIButtons(panelIndex);  //, false );

                        if (newSelection != null)
                        {
                            UIManager.SetSelectionDelayed(newSelection.gameObject);
                        }
                    }
                }
            }
        }
コード例 #27
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
 protected abstract void OnUIInput(UISelectable selectedObject, object[] data, Vector2Int input, int panelIndex);
コード例 #28
0
        // protected override void OnDisable () {
        //     base.OnDisable();

        //     // Debug.LogError("setting selected false");
        //     for (int i =0 ; i < allElements.Count; i++) allElements[i].selected = false;
        // }


        public UISelectable[] GetAllSelectableElements(int targetCount, bool updateLayout)
        {
            // if (isHoldersCollection) return null;

            int c = showElements.Count;

            if (c < targetCount)
            {
                // for (int i = 0 ; i < c; i++) {
                //     if (!shownElements[i].gameObject.activeSelf)
                //         shownElements[i].gameObject.SetActive(true);
                // }

                int cnt = targetCount - c;
                for (int i = 0; i < cnt; i++)
                {
                    // if (allElements.Count > 0) {
                    //     UISelectable s = allElements[0];
                    //     allElements.Remove(s);
                    //     showElements.Add(s);
                    //     s.gameObject.SetActive(true);

                    // }
                    // else {

                    showElements.Add(GetAvailableSelectable());

                    // AddNewElement("Adding new", updateLayout && i == (cnt - 1));
                    // }
                }

                // UpdateElementLayout();//true, true);// UpdateSelectableElementHolder();
            }
            else if (c > targetCount)
            {
                // for (int i =0 ; i < targetCount; i++) {
                //     if (!shownElements[i].gameObject.activeSelf)
                //         shownElements[i].gameObject.SetActive(true);
                // }

                for (int i = c - 1; i >= targetCount; i--) // targetCount; i < c; i++) {
                {
                    UISelectable s = showElements[i];
                    s.gameObject.SetActive(false);
                    showElements.Remove(s);
                    // allElements.Add(s);


                    // if (shownElements[i].gameObject.activeSelf)
                    //     shownElements[i].gameObject.SetActive(false);

                    s.transform.SetParent(UIMainCanvas.instance.transform);

                    // shownElements.Remove(shownElements[i]);
                }

                // WiggleActive();

                // List<UISelectable> r = new List<UISelectable>();
                // for (int i = 0; i < targetCount; i++) {
                //     r.Add(shownElements[i]);
                // }


                // UpdateElementLayout();//true, true);// UpdateSelectableElementHolder();

                // return shownElements.ToArray();//
                // return r.ToArray();
            }

            UpdateElementLayout();

            // SetSelectablesActive(true);

            // WiggleActive();
            return(showElements.ToArray());
        }
コード例 #29
0
ファイル: MenuPage.cs プロジェクト: hafewa/MinimalUI
 protected abstract void SetFlairs(UISelectable element, ManualMenuButton button, int panelIndex);