Exemple #1
0
        public void Setup(AC.Menu _menu, MenuElement _element, int _slot)
        {
            if (_menu == null)
            {
                return;
            }

            menu = _menu;
            menuElement = _element;
            slot = _slot;
        }
Exemple #2
0
        /**
         * <summary>Performs what should happen when the element is clicked on continuously.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessContinuousClick(AC.Menu _menu, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            if (KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController)
            {
                Change();
            }
            else
            {
                Change(KickStarter.playerInput.GetMousePosition().x - _menu.GetRect().x);
            }
            if (sliderType == AC_SliderType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, 0, (int)_mouseState);
            }
        }
Exemple #3
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">Ignored by this subclass</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);

            if (craftingType == CraftingElementType.Ingredients)
            {
                HandleDefaultClick(_mouseState, _slot);
            }
            else if (craftingType == CraftingElementType.Output)
            {
                ClickOutput(_menu, _mouseState);
            }

            _menu.Recalculate();
        }
        /**
         * <summary>Initialises the linked Unity UI GameObjects.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         */
        public override void LoadUnityUI(AC.Menu _menu, Canvas canvas)
        {
            uiMenu = _menu;

            int i = 0;

            foreach (UISlot uiSlot in uiSlots)
            {
                uiSlot.LinkUIElements(canvas, linkUIGraphic);
                if (uiSlot != null && uiSlot.uiButton != null)
                {
                    int j = i;
                    uiSlot.uiButton.onClick.AddListener(() => {
                        ProcessClickUI(_menu, j, MouseState.SingleClick);
                    });
                    uiSlot.AddClickHandler(_menu, this, j);
                }
                i++;
            }
        }
Exemple #5
0
        protected void CreateUIEvent(UnityEngine.UI.Button uiButton, AC.Menu _menu, UIPointerState uiPointerState = UIPointerState.PointerClick, int _slotIndex = 0, bool liveState = true)
        {
            if (uiPointerState == UIPointerState.PointerClick)
            {
                uiButton.onClick.AddListener(() => {
                    ProcessClickUI(_menu, _slotIndex, liveState ? KickStarter.playerInput.GetMouseState() : MouseState.SingleClick);
                });
            }
            else
            {
                EventTrigger eventTrigger = uiButton.gameObject.GetComponent <EventTrigger>();
                if (eventTrigger == null)
                {
                    eventTrigger = uiButton.gameObject.AddComponent <EventTrigger>();
                }
                EventTrigger.Entry entry = new EventTrigger.Entry();

                if (uiPointerState == UIPointerState.PointerDown)
                {
                    entry.eventID = EventTriggerType.PointerDown;
                }
                else if (uiPointerState == UIPointerState.PointerEnter)
                {
                    entry.eventID = EventTriggerType.PointerEnter;
                }

                entry.callback.AddListener((eventData) => {
                    ProcessClickUI(_menu, _slotIndex, liveState ? KickStarter.playerInput.GetMouseState() : MouseState.SingleClick);
                });

                                #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0
                if (eventTrigger.delegates == null)
                {
                    eventTrigger.delegates = new List <EventTrigger.Entry>();
                }
                eventTrigger.delegates.Add(entry);
                                #else
                eventTrigger.triggers.Add(entry);
                                #endif
            }
        }
Exemple #6
0
        /**
         * <summary>Initialises the linked Unity UI GameObject.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         */
        public override void LoadUnityUI(AC.Menu _menu, Canvas canvas)
        {
            rawImage = null;

            if (_menu.menuSource != MenuSource.AdventureCreator)
            {
                if (cycleUIBasis == CycleUIBasis.Button)
                {
                    uiButton = LinkUIElement <UnityEngine.UI.Button> (canvas);
                    if (uiButton)
                    {
                        rawImage = uiButton.GetComponentInChildren <RawImage>();

                                                #if TextMeshProIsPresent
                        uiText = uiButton.GetComponentInChildren <TMPro.TextMeshProUGUI>();
                                                #else
                        uiText = uiButton.GetComponentInChildren <Text>();
                                                #endif

                        uiButton.onClick.AddListener(() => {
                            ProcessClickUI(_menu, 0, KickStarter.playerInput.GetMouseState());
                        });

                        CreateHoverSoundHandler(uiButton, _menu, 0);
                    }
                }
                else if (cycleUIBasis == CycleUIBasis.Dropdown)
                {
                    uiDropdown = LinkUIElement <Dropdown> (canvas);
                    if (uiDropdown)
                    {
                        uiDropdown.value = selected;
                        uiDropdown.onValueChanged.AddListener(delegate {
                            uiDropdownValueChangedHandler(uiDropdown);
                        });

                        CreateHoverSoundHandler(uiDropdown, _menu, 0);
                    }
                }
            }
        }
Exemple #7
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">The index number of ths slot that was clicked</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState != GameState.DialogOptions)
            {
                return;
            }
            base.ProcessClick(_menu, _slot, _mouseState);

            if (linkedConversation != null &&
                (linkedConversation == overrideConversation || (overrideConversation == null && KickStarter.playerInput.activeConversation)))
            {
                if (fixedOption)
                {
                    linkedConversation.RunOption(optionToShow - 1);
                }
                else
                {
                    linkedConversation.RunOption(_slot + offset);
                }
            }
        }
Exemple #8
0
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState != GameState.DialogOptions)
            {
                return;
            }

            if (KickStarter.playerInput && KickStarter.playerInput.activeConversation)
            {
                if (fixedOption)
                {
                    KickStarter.playerInput.activeConversation.RunOption(optionToShow - 1);
                }
                else
                {
                    KickStarter.playerInput.activeConversation.RunOption(_slot + offset);
                }
            }

            offset = 0;
        }
Exemple #9
0
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            selected++;
            if (selected > optionsArray.Count - 1)
            {
                selected = 0;
            }

            if (cycleType == AC_CycleType.Language)
            {
                if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
                {
                    // Ignore original text by skipping to first language
                    selected = 1;
                }
                Options.SetLanguage(selected);
            }
            else if (cycleType == AC_CycleType.Variable)
            {
                if (varID >= 0)
                {
                    GVar var = RuntimeVariables.GetVariable(varID);
                    if (var.type == VariableType.Integer)
                    {
                        var.val = selected;
                        var.Upload();
                    }
                }
            }

            if (cycleType == AC_CycleType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }
        }
Exemple #10
0
        private void Update()
        {
            if (!Application.isPlaying)
            {
                if (AdvGame.GetReferences())
                {
                    menuManager = AdvGame.GetReferences().menuManager;

                    if (menuManager)
                    {
                        if (menuManager.GetSelectedMenu() != null)
                        {
                            AC.Menu menu = menuManager.GetSelectedMenu();

                            if (menu.IsUnityUI())
                            {
                                return;
                            }

                            foreach (MenuElement element in menu.visibleElements)
                            {
                                for (int i = 0; i < element.GetNumSlots(); i++)
                                {
                                    if (menuManager.GetSelectedElement() == element && element.isClickable && i == 0)
                                    {
                                        element.PreDisplay(i, 0, false);
                                    }

                                    else
                                    {
                                        element.PreDisplay(i, 0, false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void Start()
        {
            if (string.IsNullOrEmpty(menuName) || string.IsNullOrEmpty(elementName))
            {
                return;
            }

                        #if ALLOW_LEGACY_UI
            _guiText = GetComponent <GUIText>();
                        #endif
            textMesh = GetComponent <TextMesh>();

            try
            {
                menu    = PlayerMenus.GetMenuWithName(menuName);
                element = PlayerMenus.GetElementWithName(menuName, elementName);
            }
            catch
            {
                ACDebug.LogWarning("Cannot find Menu Element with name: " + elementName + " on Menu: " + menuName);
            }
        }
        public override void Skip()
        {
            AC.Menu _menu = PlayerMenus.GetMenuWithName(runtimeMenuToChange);
            if (_menu == null)
            {
                if (!string.IsNullOrEmpty(runtimeMenuToChange))
                {
                    ACDebug.LogWarning("Could not find menu of name '" + runtimeMenuToChange + "'");
                }
                return;
            }

            switch (changeType)
            {
            case MenuChangeType.TurnOnMenu:
                if (_menu.IsManualControlled())
                {
                    _menu.TurnOn(false);
                }
                break;

            case MenuChangeType.TurnOffMenu:
                if (_menu.IsManualControlled() || _menu.appearType == AppearType.OnInteraction)
                {
                    _menu.ForceOff();
                }
                break;

            case MenuChangeType.LockMenu:
                _menu.isLocked = true;
                _menu.ForceOff();
                break;

            default:
                RunInstant(_menu);
                break;
            }
        }
Exemple #13
0
        public override void DrawOutline(bool isSelected, AC.Menu _menu)
        {
            if (dragType == DragElementType.EntireMenu)
            {
                DrawStraightLine.DrawBox(_menu.GetRectAbsolute(GetDragRectRelative()), Color.white, 1f, false, 1);
            }
            else
            {
                if (!string.IsNullOrEmpty(elementName))
                {
                    MenuElement element = MenuManager.GetElementWithName(_menu.title, elementName);
                    if (element != null)
                    {
                        Rect dragBox = _menu.GetRectAbsolute(GetDragRectRelative());
                        dragBox.x += element.GetSlotRectRelative(0).x;
                        dragBox.y += element.GetSlotRectRelative(0).y;
                        DrawStraightLine.DrawBox(dragBox, Color.white, 1f, false, 1);
                    }
                }
            }

            base.DrawOutline(isSelected, _menu);
        }
Exemple #14
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">The index number of ths slot that was clicked</param>
         * <param name = "_mouseState The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);

            if (_mouseState == MouseState.SingleClick)
            {
                KickStarter.runtimeInventory.lastClickedItem = GetItem(_slot);
            }

            if (inventoryBoxType == AC_InventoryBoxType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }
            else
            {
                KickStarter.runtimeInventory.ProcessInventoryBoxClick(_menu, this, _slot, _mouseState);
            }
        }
        private void SideMenu(AC.Menu _menu, MenuElement _element)
        {
            GenericMenu menu = new GenericMenu();

            sideElement = _menu.elements.IndexOf(_element);
            sideMenu    = menus.IndexOf(_menu);

            if (_menu.elements.Count > 0)
            {
                menu.AddItem(new GUIContent("Delete"), false, ElementCallback, "Delete");
            }

            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Copy"), false, ElementCallback, "Copy");
            if (MenuManager.copiedElement != null)
            {
                menu.AddItem(new GUIContent("Paste after"), false, ElementCallback, "Paste after");
            }
            if (sideElement > 0 || sideElement < _menu.elements.Count - 1)
            {
                menu.AddSeparator("");
            }

            if (sideElement > 0)
            {
                menu.AddItem(new GUIContent("Move to top"), false, ElementCallback, "Move to top");
                menu.AddItem(new GUIContent("Move up"), false, ElementCallback, "Move up");
            }
            if (sideElement < _menu.elements.Count - 1)
            {
                menu.AddItem(new GUIContent("Move down"), false, ElementCallback, "Move down");
                menu.AddItem(new GUIContent("Move to bottom"), false, ElementCallback, "Move to bottom");
            }

            menu.ShowAsContext();
        }
Exemple #16
0
        private void SideMenu(AC.Menu _menu)
        {
            GenericMenu menu = new GenericMenu();

            sideMenu = menus.IndexOf(_menu);

            menu.AddItem(new GUIContent("Insert after"), false, MenuCallback, "Insert after");
            if (menus.Count > 0)
            {
                menu.AddItem(new GUIContent("Delete"), false, MenuCallback, "Delete");
            }

            menu.AddSeparator(string.Empty);
            menu.AddItem(new GUIContent("Copy"), false, MenuCallback, "Copy");
            if (MenuManager.copiedMenu != null)
            {
                menu.AddItem(new GUIContent("Paste after"), false, MenuCallback, "Paste after");
            }

            if (sideMenu > 0 || sideMenu < menus.Count - 1)
            {
                menu.AddSeparator(string.Empty);
                if (sideMenu > 0)
                {
                    menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, MenuCallback, "Move to top");
                    menu.AddItem(new GUIContent("Re-arrange/Move up"), false, MenuCallback, "Move up");
                }
                if (sideMenu < menus.Count - 1)
                {
                    menu.AddItem(new GUIContent("Re-arrange/Move down"), false, MenuCallback, "Move down");
                    menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, MenuCallback, "Move to bottom");
                }
            }

            menu.ShowAsContext();
        }
Exemple #17
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">Ignored by this subclass</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            base.ProcessClick(_menu, _slot, _mouseState);

            ShowClick();

            if (buttonClickType == AC_ButtonClickType.TurnOffMenu)
            {
                _menu.TurnOff(doFade);
            }
            else if (buttonClickType == AC_ButtonClickType.Crossfade)
            {
                AC.Menu menuToSwitchTo = PlayerMenus.GetMenuWithName(switchMenuTitle);

                if (menuToSwitchTo != null)
                {
                    KickStarter.playerMenus.CrossFade(menuToSwitchTo);
                }
                else
                {
                    ACDebug.LogWarning("Cannot find any menu of name '" + switchMenuTitle + "'");
                }
            }
            else if (buttonClickType == AC_ButtonClickType.OffsetElementSlot)
            {
                if (elementToShift != null)
                {
                    elementToShift.Shift(shiftInventory, shiftAmount);
                    elementToShift.RecalculateSize(_menu.menuSource);
                    _menu.Recalculate();
                }
                else
                {
                    ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'");
                }
            }
            else if (buttonClickType == AC_ButtonClickType.OffsetJournal)
            {
                MenuJournal journalToShift = (MenuJournal)PlayerMenus.GetElementWithName(_menu.title, inventoryBoxTitle);

                if (journalToShift != null)
                {
                    journalToShift.Shift(shiftInventory, loopJournal, shiftAmount);
                    journalToShift.RecalculateSize(_menu.menuSource);
                    _menu.Recalculate();
                }
                else
                {
                    ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'");
                }
            }
            else if (buttonClickType == AC_ButtonClickType.RunActionList)
            {
                if (actionList)
                {
                    AdvGame.RunActionListAsset(actionList, parameterID, parameterValue);
                }
            }
            else if (buttonClickType == AC_ButtonClickType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }
            else if (buttonClickType == AC_ButtonClickType.SimulateInput)
            {
                KickStarter.playerInput.SimulateInput(simulateInput, inputAxis, simulateValue);
            }
        }
Exemple #18
0
 /**
  * <summary>Initialises the linked Unity UI GameObject.</summary>
  * <param name = "_menu">The element's parent Menu</param>
  */
 public override void LoadUnityUI(AC.Menu _menu, Canvas canvas)
 {
     uiText = LinkUIElement <Text> (canvas);
 }
Exemple #19
0
 public override void Initialise(AC.Menu _menu)
 {
     linkedMenu = _menu;
 }
Exemple #20
0
 private void OnDestroy()
 {
     element = null;
     menu = null;
 }
Exemple #21
0
 public override void LoadUnityUI(AC.Menu _menu)
 {
     uiText = LinkUIElement <Text>();
 }
Exemple #22
0
        public void AddClickHandler(AC.Menu _menu, MenuElement _element, int _slot)
        {
            UISlotClick uiSlotClick = uiButton.gameObject.AddComponent <UISlotClick>();

            uiSlotClick.Setup(_menu, _element, _slot);
        }
Exemple #23
0
        private void Start()
        {
            if (menuName == "" || elementName == "")
            {
                return;
            }

            try
            {
                menu = PlayerMenus.GetMenuWithName (menuName);
                element = PlayerMenus.GetElementWithName (menuName, elementName);
            }
            catch
            {
                Debug.LogWarning ("Cannot find Menu Element with name: " + elementName + " on Menu: " + menuName);
            }
        }
Exemple #24
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;
                AC.Menu _menu = PlayerMenus.GetMenuWithName(_menuToChange);

                if (_menu != null)
                {
                    if (changeType == MenuChangeType.TurnOnMenu)
                    {
                        if (_menu.IsManualControlled())
                        {
                            if (!_menu.TurnOn(doFade))
                            {
                                // Menu is already on
                                isRunning = false;
                                return(0f);
                            }

                            if (doFade && willWait)
                            {
                                return(_menu.fadeSpeed);
                            }
                        }
                        else
                        {
                            ACDebug.LogWarning("Can only turn on Menus with an Appear Type of Manual, OnInputKey, OnContainer or OnViewDocument - did you mean 'Unlock Menu'?");
                        }
                    }
                    else if (changeType == MenuChangeType.TurnOffMenu)
                    {
                        if (_menu.IsManualControlled() || _menu.appearType == AppearType.OnInteraction)
                        {
                            if (!_menu.TurnOff(doFade))
                            {
                                // Menu is already off
                                isRunning = false;
                                return(0f);
                            }

                            if (doFade && willWait)
                            {
                                return(_menu.fadeSpeed);
                            }
                        }
                        else
                        {
                            ACDebug.LogWarning("Can only turn off Menus with an Appear Type of Manual, OnInputKey, OnContainer or OnViewDocument - did you mean 'Lock Menu'?");
                        }
                    }
                    else if (changeType == MenuChangeType.LockMenu)
                    {
                        if (doFade)
                        {
                            _menu.TurnOff(true);
                        }
                        else
                        {
                            _menu.ForceOff();
                        }
                        _menu.isLocked = true;

                        if (doFade && willWait)
                        {
                            return(_menu.fadeSpeed);
                        }
                    }
                    else
                    {
                        RunInstant(_menu);
                    }
                }
                else if (menuToChange != "")
                {
                    ACDebug.LogWarning("Could not find menu of name '" + menuToChange + "'");
                }
            }
            else
            {
                isRunning = false;
                return(0f);
            }

            return(0f);
        }
Exemple #25
0
        private void RunInstant(AC.Menu _menu)
        {
            if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement)
            {
                MenuElement _element = PlayerMenus.GetElementWithName(_menuToChange, _elementToChange);
                if (_element != null)
                {
                    if (changeType == MenuChangeType.HideMenuElement)
                    {
                        _element.IsVisible = false;
                        KickStarter.playerMenus.DeselectInputBox(_element);
                    }
                    else
                    {
                        _element.IsVisible = true;
                    }

                    _menu.ResetVisibleElements();
                    _menu.Recalculate();

                    KickStarter.playerMenus.FindFirstSelectedElement();
                }
                else
                {
                    ACDebug.LogWarning("Could not find element of name '" + elementToChange + "' on menu '" + menuToChange + "'");
                }
            }
            else if (changeType == MenuChangeType.UnlockMenu)
            {
                _menu.isLocked = false;
            }
            else if (changeType == MenuChangeType.AddJournalPage)
            {
                MenuElement _element = PlayerMenus.GetElementWithName(_menuToChange, _elementToChange);
                if (_element != null)
                {
                    if (journalText != "")
                    {
                        if (_element is MenuJournal)
                        {
                            MenuJournal journal = (MenuJournal)_element;
                            JournalPage newPage = new JournalPage(lineID, journalText);
                            journal.AddPage(newPage, onlyAddNewJournal, journalPageIndex);

                            if (lineID == -1)
                            {
                                ACDebug.LogWarning("The new Journal page has no ID number, and will not be included in save game files - this can be corrected by clicking 'Gather text' in the Speech Manager");
                            }
                        }
                        else
                        {
                            ACDebug.LogWarning(_element.title + " is not a journal!");
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("No journal text to add!");
                    }
                }
                else
                {
                    ACDebug.LogWarning("Could not find menu element of name '" + elementToChange + "' inside '" + menuToChange + "'");
                }
                _menu.Recalculate();
            }
            else if (changeType == MenuChangeType.RemoveJournalPage)
            {
                MenuElement _element = PlayerMenus.GetElementWithName(_menuToChange, _elementToChange);
                if (_element != null)
                {
                    if (_element is MenuJournal)
                    {
                        MenuJournal journal = (MenuJournal)_element;

                        if (removeJournalPageMethod == RemoveJournalPageMethod.RemoveAllPages)
                        {
                            journal.RemoveAllPages();
                        }
                        else if (removeJournalPageMethod == RemoveJournalPageMethod.RemoveSinglePage)
                        {
                            journal.RemovePage(journalPageIndex);
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning(_element.title + " is not a journal!");
                    }
                }
                else
                {
                    ACDebug.LogWarning("Could not find menu element of name '" + elementToChange + "' inside '" + menuToChange + "'");
                }
                _menu.Recalculate();
            }
        }
Exemple #26
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">Ignored by this subclass</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (!_menu.IsClickable())
            {
                return;
            }

                        #if UNITY_5_3_OR_NEWER
            if (uiDropdown != null)
            {
                selected = uiDropdown.value;
            }
            else
            {
                selected++;
                if (selected > optionsArray.Count - 1)
                {
                    selected = 0;
                }
            }
                        #else
            selected++;
            if (selected > optionsArray.Count - 1)
            {
                selected = 0;
            }
                        #endif

            if (cycleType == AC_CycleType.Language)
            {
                if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1)
                {
                    // Ignore original text by skipping to first language
                    selected = 1;
                }
                Options.SetLanguage(selected);
            }
            else if (cycleType == AC_CycleType.Variable)
            {
                if (varID >= 0)
                {
                    GVar var = GlobalVariables.GetVariable(varID);
                    if (var.type == VariableType.Integer)
                    {
                        var.val = selected;
                        var.Upload();
                    }
                }
            }

            if (cycleType == AC_CycleType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }

            if (actionListOnClick)
            {
                AdvGame.RunActionListAsset(actionListOnClick);
            }

            base.ProcessClick(_menu, _slot, _mouseState);
        }
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">The index number of ths slot that was clicked</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return;
            }

            eventSlot = _slot;
            ClearAllEvents();

            switch (saveListType)
            {
            case AC_SaveListType.Save:
                if (autoHandle)
                {
                    if (PlayerMenus.IsSavingLocked(null, true))
                    {
                        return;
                    }

                    EventManager.OnFinishSaving += OnCompleteSave;
                    EventManager.OnFailSaving   += OnFailSaveLoad;

                    if (newSaveSlot && _slot == (numSlots - 1))
                    {
                        SaveSystem.SaveNewGame();

                        if (KickStarter.settingsManager.orderSavesByUpdateTime)
                        {
                            offset = 0;
                        }
                        else
                        {
                            Shift(AC_ShiftInventory.ShiftNext, 1);
                        }
                    }
                    else
                    {
                        SaveSystem.SaveGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                    }
                }
                else
                {
                    RunActionList(_slot);
                }
                break;

            case AC_SaveListType.Load:
                if (autoHandle)
                {
                    EventManager.OnFinishLoading += OnCompleteLoad;
                    EventManager.OnFailLoading   += OnFailSaveLoad;

                    SaveSystem.LoadGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                }
                else
                {
                    RunActionList(_slot);
                }
                break;

            case AC_SaveListType.Import:
                EventManager.OnFinishImporting += OnCompleteImport;
                EventManager.OnFailImporting   += OnFailImport;

                SaveSystem.ImportGame(_slot + offset, GetOptionID(_slot), fixedOption || allowEmptySlots);
                break;
            }

            base.ProcessClick(_menu, _slot, _mouseState);
        }
Exemple #28
0
        private void StartDrag(AC.Menu _menu)
        {
            menuToDrag = _menu;

            if (dragType == DragElementType.SingleElement)
            {
                if (elementName != "")
                {
                    MenuElement element = PlayerMenus.GetElementWithName (_menu.title, elementName);
                    if (element == null)
                    {
                        ACDebug.LogWarning ("Cannot drag " + elementName + " as it cannot be found on " + _menu.title);
                    }
                    else if (element.positionType == AC_PositionType2.Aligned)
                    {
                        ACDebug.LogWarning ("Cannot drag " + elementName + " as its Position is set to Aligned");
                    }
                    else if (_menu.sizeType == AC_SizeType.Automatic)
                    {
                        ACDebug.LogWarning ("Cannot drag " + elementName + " as its parent Menu's Size is set to Automatic");
                    }
                    else
                    {
                        elementToDrag = element;
                        dragStartPosition = elementToDrag.GetDragStart ();
                    }
                }
            }
            else
            {
                dragStartPosition = _menu.GetDragStart ();
            }
        }
        override public float Run()
        {
            if (string.IsNullOrEmpty(inputName) && (KickStarter.settingsManager.inputMethod != InputMethod.TouchScreen || qteType == QTEType.SingleAxis))
            {
                isRunning = false;
                return(0f);
            }

            if (duration <= 0f)
            {
                isRunning = false;
                return(0f);
            }

            if (!isRunning)
            {
                isRunning = true;

                Animator animator = null;
                if (!string.IsNullOrEmpty(menuName))
                {
                    AC.Menu menu = PlayerMenus.GetMenuWithName(menuName);
                    if (menu != null)
                    {
                        menu.TurnOn(true);
                        if (animateUI && menu.RuntimeCanvas != null && menu.RuntimeCanvas.GetComponent <Animator>())
                        {
                            animator = menu.RuntimeCanvas.GetComponent <Animator>();
                        }
                    }
                }

                if (qteType == QTEType.SingleKeypress)
                {
                    KickStarter.playerQTE.StartSinglePressQTE(inputName, duration, animator, wrongKeyFails);
                }
                else if (qteType == QTEType.SingleAxis)
                {
                    KickStarter.playerQTE.StartSingleAxisQTE(inputName, duration, axisThreshold, animator, wrongKeyFails);
                }
                else if (qteType == QTEType.HoldKey)
                {
                    KickStarter.playerQTE.StartHoldKeyQTE(inputName, duration, holdDuration, animator, wrongKeyFails);
                }
                else if (qteType == QTEType.ButtonMash)
                {
                    KickStarter.playerQTE.StartButtonMashQTE(inputName, duration, targetPresses, doCooldown, cooldownTime, animator, wrongKeyFails);
                }

                return(defaultPauseTime);
            }
            else
            {
                if (KickStarter.playerQTE.GetState() == QTEState.None)
                {
                    return(defaultPauseTime);
                }

                if (!string.IsNullOrEmpty(menuName))
                {
                    AC.Menu menu = PlayerMenus.GetMenuWithName(menuName);
                    if (menu != null)
                    {
                        menu.TurnOff(true);
                    }
                }

                isRunning = false;
                return(0f);
            }
        }
Exemple #30
0
        /**
         * <summary>Performs what should happen when the element is clicked on.</summary>
         * <param name = "_menu">The element's parent Menu</param>
         * <param name = "_slot">Ignored by this subclass</param>
         * <param name = "_mouseState">The state of the mouse button</param>
         */
        public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (!_menu.IsClickable())
            {
                return;
            }

            if (uiDropdown != null)
            {
                selected = uiDropdown.value;
            }
            else
            {
                CycleOption();
            }

            if (cycleType == AC_CycleType.Language)
            {
                if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1)
                {
                    // Ignore original text by skipping to first language
                    selected = 1;
                }

                if (KickStarter.speechManager != null && KickStarter.speechManager.separateVoiceAndTextLanguages)
                {
                    switch (splitLanguageType)
                    {
                    case SplitLanguageType.TextAndVoice:
                        Options.SetLanguage(selected);
                        Options.SetVoiceLanguage(selected);
                        break;

                    case SplitLanguageType.TextOnly:
                        Options.SetLanguage(selected);
                        break;

                    case SplitLanguageType.VoiceOnly:
                        Options.SetVoiceLanguage(selected);
                        break;
                    }
                }
                else
                {
                    Options.SetLanguage(selected);
                }
            }
            else if (cycleType == AC_CycleType.Variable)
            {
                if (linkedVariable != null)
                {
                    linkedVariable.IntegerValue = selected;
                    linkedVariable.Upload();
                }
            }

            if (cycleType == AC_CycleType.CustomScript)
            {
                MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState);
            }

            if (actionListOnClick)
            {
                AdvGame.RunActionListAsset(actionListOnClick);
            }

            base.ProcessClick(_menu, _slot, _mouseState);
        }
 private void OnDestroy()
 {
     element = null;
     menu    = null;
 }
        private void CleanUpAsset()
        {
            string assetPath = AssetDatabase.GetAssetPath(this);

            Object[] objects = AssetDatabase.LoadAllAssetsAtPath(assetPath);

            foreach (Object _object in objects)
            {
                if (_object is Menu)
                {
                    AC.Menu _menu = (Menu)_object;

                    bool found = false;
                    foreach (AC.Menu menu in menus)
                    {
                        if (menu == _menu)
                        {
                            _object.hideFlags = HideFlags.HideInHierarchy;
                            found             = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        ACDebug.Log("Deleted unset menu: " + _menu.title);
                        DestroyImmediate(_object, true);
                    }

                    for (int i = 0; i < _menu.elements.Count; i++)
                    {
                        if (_menu.elements[i] == null)
                        {
                            _menu.elements.RemoveAt(i);
                            i = 0;
                        }
                    }
                }
            }

            foreach (Object _object in objects)
            {
                if (_object is MenuElement)
                {
                    MenuElement _element = (MenuElement)_object;

                    bool found = false;
                    foreach (AC.Menu menu in menus)
                    {
                        foreach (MenuElement element in menu.elements)
                        {
                            if (element == _element)
                            {
                                _object.hideFlags = HideFlags.HideInHierarchy;
                                found             = true;
                                break;
                            }
                        }
                    }

                    if (!found)
                    {
                        ACDebug.Log("Deleted unset element: " + _element.title);
                        DestroyImmediate(_object, true);
                    }
                }
            }

            AssetDatabase.SaveAssets();
        }
Exemple #33
0
 public static void OnElementClick(AC.Menu _menu, MenuElement _element, int _slot, int _buttonPressed)
 {
     // This function is called whenever a clickable element has a click type of "Custom Script".
 }
 private void ActivateMenu(AC.Menu menu)
 {
     menu.isEditing = true;
     selectedMenu   = menu;
 }