private void CheckScreenSize(AC.Menu menu) { #if UNITY_5_4_OR_NEWER menu.Recalculate(); #endif if (!Mathf.Approximately(screenSize.x, Screen.width) || !Mathf.Approximately(screenSize.y, Screen.height)) { screenSize = new Vector2(Screen.width, Screen.height); menu.Recalculate(); } }
private void CheckScreenSize(AC.Menu menu) { #if UNITY_5_4_OR_NEWER menu.Recalculate(); #endif if (screenSize.x != Screen.width || screenSize.y != Screen.height) { screenSize = new Vector2(Screen.width, Screen.height); menu.Recalculate(); } }
public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return(false); } bool clickConsumed = false; switch (craftingType) { case CraftingElementType.Ingredients: clickConsumed = HandleDefaultClick(_mouseState, _slot); break; case CraftingElementType.Output: clickConsumed = ClickOutput(_menu, _mouseState); break; default: break; } PlayerMenus.ResetInventoryBoxes(); _menu.Recalculate(); if (clickConsumed) { base.ProcessClick(_menu, _slot, _mouseState); return(true); } return(false); }
private void CheckScreenSize(AC.Menu menu) { if (screenSize.x != Screen.width || screenSize.y != Screen.height) { screenSize = new Vector2(Screen.width, Screen.height); menu.Recalculate(); } }
public static void OnMenuEnable(AC.Menu _menu) { // This function is called whenever a menu is enabled. if (_menu.title == "Pause") { MenuElement saveButton = _menu.GetElementWithName("SaveButton"); if (saveButton) { saveButton.isVisible = !PlayerMenus.IsSavingLocked(); } _menu.Recalculate(); } }
private void AddElement(string className, AC.Menu _menu) { Undo.RecordObject(_menu, "Add element"); List <int> idArray = new List <int>(); foreach (MenuElement _element in _menu.elements) { if (_element != null) { idArray.Add(_element.ID); } } idArray.Sort(); className = "Menu" + className; MenuElement newElement = (MenuElement)CreateInstance(className); newElement.Declare(); newElement.title = className.Substring(4); // Update id based on array foreach (int _id in idArray.ToArray()) { if (newElement.ID == _id) { newElement.ID++; } } _menu.elements.Add(newElement); if (!Application.isPlaying) { _menu.Recalculate(); } DeactivateAllElements(_menu); newElement.isEditing = true; selectedMenuElement = newElement; newElement.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(newElement, this); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newElement)); AssetDatabase.SaveAssets(); CleanUpAsset(); }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } if (craftingType == CraftingElementType.Ingredients) { HandleDefaultClick(_mouseState, _slot); } else if (craftingType == CraftingElementType.Output) { ClickOutput(_menu, _mouseState); } _menu.Recalculate(); }
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(); } }
/** * <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); } }
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; } 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); } 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; 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(); } }
public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable() || _mouseState != MouseState.SingleClick) { return(false); } ShowClick(); switch (buttonClickType) { case AC_ButtonClickType.TurnOffMenu: _menu.TurnOff(doFade); break; case AC_ButtonClickType.Crossfade: Menu menuToSwitchTo = PlayerMenus.GetMenuWithName(switchMenuTitle); if (menuToSwitchTo != null) { KickStarter.playerMenus.CrossFade(menuToSwitchTo); } else { ACDebug.LogWarning("Cannot find any menu of name '" + switchMenuTitle + "'"); } break; case 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 + "'"); } break; case 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 + "'"); } break; case AC_ButtonClickType.RunActionList: if (actionList) { if (!actionList.canRunMultipleInstances) { KickStarter.actionListAssetManager.EndAssetList(actionList); } AdvGame.RunActionListAsset(actionList, parameterID, parameterValue); } break; case AC_ButtonClickType.CustomScript: MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); break; case AC_ButtonClickType.SimulateInput: KickStarter.playerInput.SimulateInput(simulateInput, inputAxis, simulateValue); break; default: break; } return(base.ProcessClick(_menu, _slot, _mouseState)); }
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 or OnContainer - did you mean 'Unlock Menu'?"); } } else if (changeType == MenuChangeType.TurnOffMenu) { if (_menu.IsManualControlled()) { 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 or OnContainer - did you mean 'Lock Menu'?"); } } else if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (changeType == MenuChangeType.HideMenuElement) { _element.isVisible = false; } 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.LockMenu) { if (doFade) { _menu.TurnOff(true); } else { _menu.ForceOff(); } _menu.isLocked = true; if (doFade && willWait) { return(_menu.fadeSpeed); } } 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); } 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 + "'"); } } } else if (menuToChange != "") { ACDebug.LogWarning("Could not find menu of name '" + menuToChange + "'"); } } else { isRunning = false; return(0f); } return(0f); }
override public void Skip() { AC.Menu _menu = PlayerMenus.GetMenuWithName(menuToChange); if (_menu != null) { if (changeType == MenuChangeType.TurnOnMenu) { if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey) { _menu.TurnOn(false); } } else if (changeType == MenuChangeType.TurnOffMenu) { if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey || _menu.appearType == AppearType.OnContainer) { _menu.ForceOff(); } } else if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (changeType == MenuChangeType.HideMenuElement) { _element.isVisible = false; } else { _element.isVisible = true; } _menu.ResetVisibleElements(); _menu.Recalculate(); } } else if (changeType == MenuChangeType.LockMenu) { _menu.isLocked = true; _menu.ForceOff(); } 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); } } } } } }
public void ProcessInventoryBoxClick(AC.Menu _menu, MenuInventoryBox inventoryBox, int _slot, MouseState _mouseState) { if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Default || inventoryBox.inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected) { if (KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && KickStarter.playerInput.interactionMenuIsOn) { KickStarter.playerMenus.SetInteractionMenus(false); KickStarter.playerInteraction.ClickInvItemToInteract(); } else if (KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && KickStarter.settingsManager.SelectInteractionMethod() == AC.SelectInteractions.CyclingCursorAndClickingHotspot) { if (KickStarter.settingsManager.autoCycleWhenInteract && _mouseState == MouseState.SingleClick && (selectedItem == null || KickStarter.settingsManager.cycleInventoryCursors)) { int originalIndex = KickStarter.playerInteraction.GetInteractionIndex(); KickStarter.playerInteraction.SetNextInteraction(); KickStarter.playerInteraction.SetInteractionIndex(originalIndex); } if (!KickStarter.settingsManager.cycleInventoryCursors && selectedItem != null) { inventoryBox.HandleDefaultClick(_mouseState, _slot, KickStarter.settingsManager.interactionMethod); } else if (_mouseState != MouseState.RightClick) { KickStarter.playerMenus.SetInteractionMenus(false); KickStarter.playerInteraction.ClickInvItemToInteract(); } if (KickStarter.settingsManager.autoCycleWhenInteract && _mouseState == MouseState.SingleClick) { KickStarter.playerInteraction.RestoreInventoryInteraction(); } } else if (KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Single) { inventoryBox.HandleDefaultClick(_mouseState, _slot, AC_InteractionMethod.ContextSensitive); } else { inventoryBox.HandleDefaultClick(_mouseState, _slot, KickStarter.settingsManager.interactionMethod); } _menu.Recalculate(); } else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Container) { inventoryBox.ClickContainer(_mouseState, _slot, KickStarter.playerInput.activeContainer); _menu.Recalculate(); } else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.HostpotBased) { if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction) { if (hoverItem != null) { Combine(hoverItem, inventoryBox.items [_slot]); } else if (KickStarter.playerInteraction.GetActiveHotspot()) { InvItem _item = inventoryBox.items [_slot]; if (_item != null) { SelectItem(_item, SelectItemMode.Use); _menu.TurnOff(false); KickStarter.playerInteraction.ClickButton(InteractionType.Inventory, -2, _item.id); KickStarter.playerCursor.ResetSelectedCursor(); } } else { Debug.LogWarning("Cannot handle inventory click since there is no active Hotspot."); } } else { Debug.LogWarning("This type of InventoryBox only works with the Choose Hotspot Then Interaction method of interaction."); } } }