public override float Run() { if (!string.IsNullOrEmpty(menuName)) { Menu menu = PlayerMenus.GetMenuWithName(menuName); if (menu != null) { if (selectFirstVisible) { GameObject elementObject = menu.GetObjectToSelect(); if (elementObject != null) { KickStarter.playerMenus.SelectUIElement(elementObject); } } else if (!string.IsNullOrEmpty(elementName)) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null) { menu.Select(elementName, slotIndex); } } } } return(0f); }
/** * <summary>Triggers the OnMenuElementClick event.</summary> * <param name = "_menu">The Menu that the clicked MenuElement is a part of</param> * <param name = "_element">The MenuElement that was clicked on</param> * <param name = "_slot">The slot index that was clicked, if the MenuElement consists of multiple slots (0 otherwise)</param> * <param name = "_buttonPressed">Equals 1 if a left-click, or 2 if a right-click</param> */ public void Call_OnMenuElementClick(AC.Menu _menu, MenuElement _element, int _slot, int _buttonPressed) { if (OnMenuElementClick != null) { OnMenuElementClick(_menu, _element, _slot, _buttonPressed); } }
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 up"), false, ElementCallback, "Move up"); } if (sideElement < _menu.elements.Count - 1) { menu.AddItem(new GUIContent("Move down"), false, ElementCallback, "Move down"); } menu.ShowAsContext(); }
override public bool CheckCondition() { AC.Menu _menu = PlayerMenus.GetMenuWithName(menuToCheck); if (_menu != null) { if (checkType == MenuCheckType.MenuIsVisible) { return(_menu.IsVisible()); } else if (checkType == MenuCheckType.MenuIsLocked) { return(_menu.isLocked); } else if (checkType == MenuCheckType.ElementIsVisible) { MenuElement _element = PlayerMenus.GetElementWithName(menuToCheck, elementToCheck); if (_element != null) { return(_element.IsVisible); } } } return(false); }
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(); } }
public override void Initialise(AC.Menu _menu) { if (buttonClickType == AC_ButtonClickType.OffsetElementSlot || buttonClickType == AC_ButtonClickType.OffsetJournal) { elementToShift = _menu.GetElementWithName(inventoryBoxTitle); } }
public virtual void Copy (MenuElement _element) { ID = _element.ID; isEditing = false; title = _element.title; slotSize = _element.slotSize; sizeType = _element.sizeType; positionType = _element.positionType; relativeRect = _element.relativeRect; numSlots = _element.numSlots; lineID = _element.lineID; slotSpacing = _element.slotSpacing; font = _element.font; fontScaleFactor = _element.fontScaleFactor; fontColor = _element.fontColor; fontHighlightColor = _element.fontHighlightColor; highlightTexture = _element.highlightTexture; isVisible = _element.isVisible; isClickable = _element.isClickable; orientation = _element.orientation; gridWidth = _element.gridWidth; backgroundTexture = _element.backgroundTexture; hoverSound = _element.hoverSound; clickSound = _element.clickSound; relativePosition = _element.relativePosition; dragOffset = Vector2.zero; }
public override void PreDisplay(int _slot, int languageNumber, bool isActive) { if (buttonClickType == AC_ButtonClickType.OffsetElementSlot && onlyShowWhenEffective && inventoryBoxTitle != "" && Application.isPlaying) { if (elementToShift == null) { foreach (AC.Menu _menu in PlayerMenus.GetMenus()) { if (_menu != null && _menu.elements.Contains(this)) { elementToShift = PlayerMenus.GetElementWithName(_menu.title, inventoryBoxTitle); break; } } } if (elementToShift != null) { isVisible = elementToShift.CanBeShifted(shiftInventory); } } fullText = TranslateLabel(label, languageNumber); if (uiButton != null) { UpdateUIElement(uiButton); if (uiText != null) { uiText.text = fullText; } } }
private void OnMouseOverMenu(AC.Menu _menu, MenuElement _element, int _slot) { /** * Whenever a new Menu Element slot is hovered over, begin the countdown. * Since this is called every frame that the mouse is over an Element slot, we'll construct an "elementOverIdentifer" string * from the arguments to determine if this is the first frame that the hover-over occurs. */ string newElementOverIdentifier = ""; if (_element != null) { newElementOverIdentifier = _menu.id.ToString() + " " + _element.ID.ToString() + " " + _slot.ToString(); } if (newElementOverIdentifier != "" && newElementOverIdentifier != elementOverIdentifier) { hotspotHoverDuration = 0f; menuHoverDuration = hoverDuration; hoverMenu = _menu; hoverElement = _element; hoverSlot = _slot; } elementOverIdentifier = newElementOverIdentifier; }
/** * <summary>Triggers the OnMenuElementShift</summary> * <param name = "_element">The MenuElement whose slots have been shifted</param> * <param name = "shiftType">The direction in which the slots where shifted (ShiftLeft, ShiftRight)</param> */ public void Call_OnMenuElementShift(MenuElement _element, AC_ShiftInventory shiftType) { if (OnMenuElementShift != null) { OnMenuElementShift(_element, shiftType); } }
/** * <summary>Triggers the OnMouseOverMenuElement event.</summary> * <param name = "_menu">The Menu that the mouse is over</param> * <param name = "_element">The MenuElement that the mouse is over</param> * <param name = "_slot">The slot index that the mouse is over, if the MenuElement consists of multiple slots (0 otherwise)</param> */ public void Call_OnMouseOverMenuElement(AC.Menu _menu, MenuElement _element, int _slot) { if (OnMouseOverMenu != null) { OnMouseOverMenu(_menu, _element, _slot); } }
override public float Run() { if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName)) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement is MenuInput) { MenuInput menuInput = (MenuInput)menuElement; if (setMenuInputBoxSource == SetMenuInputBoxSource.EnteredHere) { menuInput.SetLabel(newLabel); } else if (setMenuInputBoxSource == SetMenuInputBoxSource.FromGlobalVariable) { menuInput.SetLabel(GlobalVariables.GetStringValue(varID)); } } else { ACDebug.LogWarning("Cannot find Element '" + elementName + "' within Menu '" + menuName + "'"); } } return(0f); }
public override void AssignValues(List <ActionParameter> parameters) { if (useActive) { runtimeContainer = KickStarter.playerInput.activeContainer; } else { runtimeContainer = AssignFile <Container> (parameters, parameterID, constantID, container); } if (!useActive && setElement && !string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(containerElementName)) { string runtimeMenuName = AssignString(parameters, menuParameterID, menuName); string runtimeContainerElementName = AssignString(parameters, elementParameterID, containerElementName); runtimeMenuName = AdvGame.ConvertTokens(runtimeMenuName, Options.GetLanguage(), localVariables, parameters); runtimeContainerElementName = AdvGame.ConvertTokens(runtimeContainerElementName, Options.GetLanguage(), localVariables, parameters); MenuElement element = PlayerMenus.GetElementWithName(runtimeMenuName, runtimeContainerElementName); if (element != null) { runtimeInventoryBox = element as MenuInventoryBox; } } }
public virtual void Copy(MenuElement _element) { linkedUiID = _element.linkedUiID; ID = _element.ID; isEditing = false; title = _element.title; slotSize = _element.slotSize; sizeType = _element.sizeType; positionType = _element.positionType; relativeRect = _element.relativeRect; numSlots = _element.numSlots; lineID = _element.lineID; slotSpacing = _element.slotSpacing; font = _element.font; fontScaleFactor = _element.fontScaleFactor; fontColor = _element.fontColor; fontHighlightColor = _element.fontHighlightColor; highlightTexture = _element.highlightTexture; isVisible = _element.isVisible; isClickable = _element.isClickable; orientation = _element.orientation; gridWidth = _element.gridWidth; backgroundTexture = _element.backgroundTexture; hoverSound = _element.hoverSound; clickSound = _element.clickSound; relativePosition = _element.relativePosition; dragOffset = Vector2.zero; }
private void PasteElement(int i, int j) { if (MenuManager.copiedElement != null) { Undo.RecordObject(this, "Paste element"); int[] idArray = GetElementIDArray(i); MenuElement newElement = MenuManager.copiedElement.DuplicateSelf(true); newElement.linkedUiID = 0; foreach (MenuElement menuElement in menus[i].elements) { if (menuElement.title == newElement.title) { newElement.title += " (Copy)"; break; } } newElement.UpdateID(idArray); newElement.lineID = -1; newElement.hideFlags = HideFlags.HideInHierarchy; menus[i].elements.Insert(j + 1, newElement); AssetDatabase.AddObjectToAsset(newElement, this); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newElement)); AssetDatabase.SaveAssets(); CleanUpAsset(); } }
private void PasteElement(int menuIndex, int elementIndex) { if (MenuManager.copiedElement != null) { Undo.RegisterCompleteObjectUndo(menus[menuIndex], "Paste menu element"); int[] idArray = GetElementIDArray(menuIndex); MenuElement newElement = MenuManager.copiedElement.DuplicateSelf(true, false); newElement.linkedUiID = 0; foreach (MenuElement menuElement in menus[menuIndex].elements) { if (menuElement.title == newElement.title) { newElement.title += " (Copy)"; break; } } newElement.UpdateID(idArray); newElement.lineID = -1; newElement.hideFlags = HideFlags.HideInHierarchy; menus[menuIndex].elements.Insert(elementIndex + 1, newElement); AssetDatabase.AddObjectToAsset(newElement, this); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newElement)); AssetDatabase.SaveAssets(); CleanUpAsset(); EditorUtility.SetDirty(this); } }
private void ElementCallback(object obj) { if (sideElement >= 0 && sideMenu >= 0) { switch (obj.ToString()) { case "Copy": MenuManager.copiedElement = menus[sideMenu].elements[sideElement].DuplicateSelf(true); break; case "Paste after": PasteElement(sideMenu, sideElement); break; case "Delete": Undo.RecordObject(this, "Delete menu element"); DeactivateAllElements(menus[sideMenu]); selectedMenuElement = null; MenuElement tempElement = menus[sideMenu].elements[sideElement]; menus[sideMenu].elements.RemoveAt(sideElement); UnityEngine.Object.DestroyImmediate(tempElement, true); AssetDatabase.SaveAssets(); CleanUpAsset(); break; case "Move up": Undo.RecordObject(this, "Move menu element up"); menus[sideMenu].elements = SwapElements(menus[sideMenu].elements, sideElement, sideElement - 1); menus[sideMenu].ResetVisibleElements(); AssetDatabase.SaveAssets(); break; case "Move down": Undo.RecordObject(this, "Move menu element down"); menus[sideMenu].elements = SwapElements(menus[sideMenu].elements, sideElement, sideElement + 1); menus[sideMenu].ResetVisibleElements(); AssetDatabase.SaveAssets(); break; case "Move to top": Undo.RecordObject(this, "Move menu element to top"); menus[sideMenu].elements = MoveElementToTop(menus[sideMenu].elements, sideElement); menus[sideMenu].ResetVisibleElements(); AssetDatabase.SaveAssets(); break; case "Move to bottom": Undo.RecordObject(this, "Move menu element to bottom"); menus[sideMenu].elements = MoveElementToBottom(menus[sideMenu].elements, sideElement); menus[sideMenu].ResetVisibleElements(); AssetDatabase.SaveAssets(); break; } } sideMenu = -1; sideElement = -1; SaveAllMenus(); }
private List <MenuElement> MoveElementToBottom(List <MenuElement> list, int a1) { MenuElement tempElement = list[a1]; list.Add(tempElement); list.RemoveAt(a1); return(list); }
private List <MenuElement> SwapElements(List <MenuElement> list, int a1, int a2) { MenuElement tempElement = list[a1]; list[a1] = list[a2]; list[a2] = tempElement; return(list); }
private List <MenuElement> MoveElementToTop(List <MenuElement> list, int a1) { MenuElement tempElement = list[a1]; list.Insert(0, tempElement); list.RemoveAt(a1 + 1); return(list); }
private void DeactivateAllMenus() { foreach (AC.Menu menu in menus) { menu.isEditing = false; } selectedMenu = null; selectedMenuElement = null; }
/** * <summary>Adds a UISlotClick component to the Button, which acts as a click-handler.</summary> * <param name = "_menu">The Menu that the Button is linked to</param> * <param name = "_element">The MenuElement within _menu that the Button is linked to</param> * <param name = "_slot">The index number of the slot within _element that the Button is linked to</param> */ public void AddClickHandler(AC.Menu _menu, MenuElement _element, int _slot) { UISlotClick uiSlotClick = uiButton.gameObject.GetComponent <UISlotClick>(); if (uiSlotClick == null) { uiSlotClick = uiButton.gameObject.AddComponent <UISlotClick>(); } uiSlotClick.Setup(_menu, _element, _slot, true); }
private void DeactivateAllMenus() { foreach (AC.Menu menu in menus) { menu.isEditing = false; } selectedMenu = null; selectedMenuElement = null; EditorGUIUtility.editingTextField = false; }
public override void Initialise(AC.Menu _menu) { if (journalType == JournalType.DisplayExistingJournal) { MenuElement sharedElement = _menu.GetElementWithName(otherJournalTitle); if (sharedElement != null && sharedElement is MenuJournal) { otherJournal = (MenuJournal)sharedElement; } } }
/** * <summary>Syncs the component to a slot within a menu.</summary> * <param name = "_menu">The Menu that the Button is linked to</param> * <param name = "_element">The MenuElement within _menu that the Button is linked to</param> * <param name = "_slot">The index number of the slot within _element that the Button is linked to</param> */ public void Setup(AC.Menu _menu, MenuElement _element, int _slot) { if (_menu == null) { return; } menu = _menu; menuElement = _element; slot = _slot; }
/** * <summary>Selects a MenuElement within a Menu and display its properties.</summary> * <param name = "_menu">The Menu that the MenuElement is a part of</param> * <param name = "_element">The MenuElement to select</param> */ public void SelectElementFromPreview(AC.Menu _menu, MenuElement _element) { if (_menu.elements.Contains(_element)) { if (selectedMenuElement != _element) { DeactivateAllElements(_menu); ActivateElement(_element); } } }
private void OnEnable() { if (element == null && KickStarter.playerMenus != null) { Menu menu = KickStarter.playerMenus.GetMenuWithCanvas(GetComponent <Canvas>()); if (menu != null && !string.IsNullOrEmpty(elementToScroll)) { element = menu.GetElementWithName(elementToScroll); } } }
public void Setup(AC.Menu _menu, MenuElement _element, int _slot) { if (_menu == null) { return; } menu = _menu; menuElement = _element; slot = _slot; }
/** * <summary>Syncs the component to a slot within a menu.</summary> * <param name = "_menu">The Menu that the Button is linked to</param> * <param name = "_element">The MenuElement within _menu that the Button is linked to</param> * <param name = "_slot">The index number of the slot within _element that the Button is linked to</param> * <param name = "_reactToRightClick">If True, the component will listen and react to right-clicks</param> */ public void Setup(AC.Menu _menu, MenuElement _element, int _slot, bool _reactToRightClick) { if (_menu == null) { return; } menu = _menu; menuElement = _element; slot = _slot; reactToRightClick = _reactToRightClick; }
private void SetStyles(MenuElement element) { normalStyle = new GUIStyle(); normalStyle.normal.textColor = element.fontColor; normalStyle.font = element.font; normalStyle.fontSize = element.GetFontSize(); normalStyle.alignment = TextAnchor.MiddleCenter; highlightedStyle = new GUIStyle(); highlightedStyle.font = element.font; highlightedStyle.fontSize = element.GetFontSize(); highlightedStyle.normal.textColor = element.fontHighlightColor; highlightedStyle.normal.background = element.highlightTexture; highlightedStyle.alignment = TextAnchor.MiddleCenter; }
private void SetStyles (MenuElement element) { normalStyle = new GUIStyle(); normalStyle.normal.textColor = element.fontColor; normalStyle.font = element.font; normalStyle.fontSize = element.GetFontSize (); normalStyle.alignment = TextAnchor.MiddleCenter; highlightedStyle = new GUIStyle(); highlightedStyle.font = element.font; highlightedStyle.fontSize = element.GetFontSize (); highlightedStyle.normal.textColor = element.fontHighlightColor; highlightedStyle.normal.background = element.highlightTexture; highlightedStyle.alignment = TextAnchor.MiddleCenter; }
public int GetMenuElementReferences(Menu menu, MenuElement element) { int totalNumReferences = 0; foreach (Action action in actions) { int thisNumReferences = action.GetMenuReferences(menu.title, element.title); if (thisNumReferences > 0) { totalNumReferences += thisNumReferences; ACDebug.Log("Found " + thisNumReferences + " references to element '" + element.title + "' in Action #" + actions.IndexOf(action) + " of ActionList asset '" + name + "'", this); } } return(totalNumReferences); }
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 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); } }
public override void PreDisplay(int _slot, int languageNumber, bool isActive) { if (buttonClickType == AC_ButtonClickType.OffsetElementSlot && onlyShowWhenEffective && inventoryBoxTitle != "" && Application.isPlaying) { if (elementToShift == null) { foreach (AC.Menu _menu in PlayerMenus.GetMenus ()) { if (_menu != null && _menu.elements.Contains (this)) { elementToShift = PlayerMenus.GetElementWithName (_menu.title, inventoryBoxTitle); break; } } } if (elementToShift != null) { isVisible = elementToShift.CanBeShifted (shiftInventory); } } fullText = TranslateLabel (label, languageNumber); if (uiButton != null) { UpdateUIElement (uiButton); if (uiText != null) { uiText.text = fullText; } } }
private void ExtractElement (MenuElement element, string elementLabel, bool onlySeekNew) { if (onlySeekNew && element.lineID == -1) { // Assign a new ID on creation SpeechLine newLine; newLine = new SpeechLine (GetIDArray(), "", element.title, elementLabel, languages.Count - 1, AC_TextType.MenuElement); element.lineID = newLine.lineID; lines.Add (newLine); } else if (!onlySeekNew && element.lineID > -1) { // Already has an ID, so don't replace lines.Add (new SpeechLine (element.lineID, "", element.title, elementLabel, languages.Count - 1, AC_TextType.MenuElement)); } }
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 ElementCallback(object obj) { if (sideElement >= 0 && sideMenu >= 0) { switch (obj.ToString ()) { case "Copy": MenuManager.copiedElement = menus[sideMenu].elements[sideElement]; break; case "Paste after": PasteElement (sideMenu, sideElement); break; case "Delete": Undo.RecordObject (this, "Delete menu element"); DeactivateAllElements (menus[sideMenu]); selectedMenuElement = null; MenuElement tempElement = menus[sideMenu].elements[sideElement]; menus[sideMenu].elements.RemoveAt (sideElement); UnityEngine.Object.DestroyImmediate (tempElement, true); AssetDatabase.SaveAssets(); CleanUpAsset (); break; case "Move up": Undo.RecordObject (this, "Move menu element up"); menus[sideMenu].elements = SwapElements (menus[sideMenu].elements, sideElement, sideElement-1); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets(); break; case "Move down": Undo.RecordObject (this, "Move menu element down"); menus[sideMenu].elements = SwapElements (menus[sideMenu].elements, sideElement, sideElement+1); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets(); break; case "Move to top": Undo.RecordObject (this, "Move menu element to top"); menus[sideMenu].elements = MoveElementToTop (menus[sideMenu].elements, sideElement); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets(); break; case "Move to bottom": Undo.RecordObject (this, "Move menu element to bottom"); menus[sideMenu].elements = MoveElementToBottom (menus[sideMenu].elements, sideElement); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets(); break; } } sideMenu = -1; sideElement = -1; SaveAllMenus (); }
public static void SimulateClick (string menuName, MenuElement _element, int _slot) { if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <PlayerMenus>()) { Menu menu = PlayerMenus.GetMenuWithName (menuName); GameObject.FindWithTag (Tags.persistentEngine).GetComponent <PlayerMenus>().CheckClick (menu, _element, _slot, MouseState.SingleClick); } }
public override void Display (GUIStyle _style, int _slot, float zoom, bool isActive) { if (buttonClickType == AC_ButtonClickType.OffsetInventoryOrDialogue && onlyShowWhenEffective && inventoryBoxTitle != "" && Application.isPlaying) { if (elementToShift == null) { foreach (Menu _menu in PlayerMenus.GetMenus ()) { if (_menu != null && _menu.elements.Contains (this)) { foreach (MenuElement _element in _menu.elements) { if (_element != null && _element.title == inventoryBoxTitle) { elementToShift = _element; break; } } } } } if (elementToShift != null) { if (!elementToShift.CanBeShifted (shiftInventory)) { return; } } } if (clickAlpha > 0f) { if (clickTexture) { Color tempColor = GUI.color; tempColor.a = clickAlpha; GUI.color = tempColor; GUI.DrawTexture (ZoomRect (GetSlotRectRelative (_slot), zoom), clickTexture, ScaleMode.StretchToFill, true, 0f); tempColor.a = 1f; GUI.color = tempColor; } clickAlpha -= Time.deltaTime; if (clickAlpha < 0f) { clickAlpha = 0f; } } base.Display (_style, _slot, zoom, isActive); _style.alignment = anchor; if (zoom < 1f) { _style.fontSize = (int) ((float) _style.fontSize * zoom); } if (textEffects != TextEffects.None) { AdvGame.DrawTextEffect (ZoomRect (relativeRect, zoom), TranslateLabel (label), _style, Color.black, _style.normal.textColor, 2, textEffects); } else { GUI.Label (ZoomRect (relativeRect, zoom), TranslateLabel (label), _style); } }
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 (); } }
private void AddElement (string className, 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); _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 (); }
private bool CanElementBeDroppedOnto(MenuElement element) { if (element is MenuInventoryBox) { MenuInventoryBox inventoryBox = (MenuInventoryBox) element; if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Default || inventoryBox.inventoryBoxType == AC_InventoryBoxType.CustomScript) { return true; } } else if (element is MenuCrafting) { MenuCrafting crafting = (MenuCrafting) element; if (crafting.craftingType == CraftingElementType.Ingredients) { return true; } } return false; }
public override void Initialise(AC.Menu _menu) { if (buttonClickType == AC_ButtonClickType.OffsetElementSlot || buttonClickType == AC_ButtonClickType.OffsetJournal) { elementToShift = _menu.GetElementWithName (inventoryBoxTitle); } }
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 (); }
/** * <summary>Selects a MenuElement within a Menu and display its properties.</summary> * <param name = "_menu">The Menu that the MenuElement is a part of</param> * <param name = "_element">The MenuElement to select</param> */ public void SelectElementFromPreview(AC.Menu _menu, MenuElement _element) { if (_menu.elements.Contains (_element)) { if (selectedMenuElement != _element) { DeactivateAllElements (_menu); ActivateElement (_element); } } }
private void ActivateElement(MenuElement menuElement) { menuElement.isEditing = true; selectedMenuElement = menuElement; }
private bool SlotIsInteractive(AC.Menu menu, MenuElement element, int i) { if (menu.IsVisible () && element.isClickable && ((KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || (KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController && KickStarter.stateHandler.gameState == GameState.Normal && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || ((KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController && KickStarter.stateHandler.gameState != GameState.Normal && menu.selected_element == element && menu.selected_slot == i)))) { return true; } return false; }
private void ExtractElement(MenuElement element, string elementLabel, bool onlySeekNew) { if (elementLabel == null || elementLabel.Length == 0) { element.lineID = -1; return; } if (onlySeekNew && element.lineID == -1) { // Assign a new ID on creation SpeechLine newLine = new SpeechLine (GetIDArray(), "", element.title, elementLabel, languages.Count - 1, AC_TextType.MenuElement); element.lineID = newLine.lineID; lines.Add (newLine); } else if (!onlySeekNew && element.lineID > -1) { // Already has an ID, so don't replace SpeechLine existingLine = new SpeechLine (element.lineID, "", element.title, elementLabel, languages.Count - 1, AC_TextType.MenuElement); int lineID = SmartAddLine (existingLine); if (lineID >= 0) element.lineID = lineID; } }
private void MenuCallback (object obj) { if (sideMenu >= 0) { switch (obj.ToString ()) { case "Copy": MenuManager.copiedMenu = menus[sideMenu]; break; case "Paste after": PasteMenu (sideMenu); break; case "Insert after": Undo.RecordObject (this, "Insert menu"); Menu newMenu = (Menu) CreateInstance <Menu>(); newMenu.Declare (GetIDArray ()); menus.Insert (sideMenu+1, newMenu); DeactivateAllMenus (); ActivateMenu (newMenu); newMenu.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset (newMenu, this); AssetDatabase.ImportAsset (AssetDatabase.GetAssetPath (newMenu)); break; case "Delete": Undo.RecordObject (this, "Delete menu"); if (menus[sideMenu] == selectedMenu) { DeactivateAllElements (menus[sideMenu]); DeleteAllElements (menus[sideMenu]); selectedMenuElement = null; } DeactivateAllMenus (); Menu tempMenu = menus[sideMenu]; foreach (MenuElement element in tempMenu.elements) { UnityEngine.Object.DestroyImmediate (element, true); } menus.RemoveAt (sideMenu); UnityEngine.Object.DestroyImmediate (tempMenu, true); AssetDatabase.SaveAssets (); CleanUpAsset (); break; case "Move up": Undo.RecordObject (this, "Move menu up"); menus = SwapMenus (menus, sideMenu, sideMenu-1); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets (); break; case "Move down": Undo.RecordObject (this, "Move menu down"); menus = SwapMenus (menus, sideMenu, sideMenu+1); menus[sideMenu].ResetVisibleElements (); AssetDatabase.SaveAssets (); break; } } sideMenu = -1; sideElement = -1; SaveAllMenus (); }
/** * <summary>Adds a UISlotClick component to the Button, which acts as a click-handler.</summary> * <param title = "_menu">The Menu that the Button is linked to</param> * <param title = "_element">The MenuElement within _menu that the Button is linked to</param> * <param title = "_slot">The index number of the slot within _element that the Button is linked to</param> */ public void AddClickHandler(AC.Menu _menu, MenuElement _element, int _slot) { UISlotClick uiSlotClick = uiButton.gameObject.AddComponent <UISlotClick>(); uiSlotClick.Setup (_menu, _element, _slot); }
private void DeactivateAllMenus () { foreach (Menu menu in menus) { menu.isEditing = false; } selectedMenu = null; selectedMenuElement = null; }
private void OnDestroy() { element = null; menu = null; }
private void CheckContinuousClick (Menu _menu, MenuElement _element, int _slot, MouseState _mouseState) { if (_element is MenuButton) { MenuButton button = (MenuButton) _element; if (button.buttonClickType == AC_ButtonClickType.SimulateInput) { playerInput.SimulateInput (button.simulateInput, button.inputAxis, button.simulateValue); } else if (button.buttonClickType == AC_ButtonClickType.CustomScript && button.allowContinuousClick) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } } else if (_element is MenuSlider) { MenuSlider slider = (MenuSlider) _element; if (settingsManager.inputMethod == InputMethod.KeyboardOrController) { slider.Change (); } else { slider.Change (playerInput.GetMousePosition ().x - _menu.GetRect ().x); } if (slider.sliderType == AC_SliderType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } } }
private void CheckContinuousClick(AC.Menu _menu, MenuElement _element, int _slot, MouseState _mouseState) { _element.ProcessContinuousClick (_menu, _mouseState); }
private void CheckClick (Menu _menu, MenuElement _element, int _slot, MouseState _mouseState) { playerInput.mouseState = MouseState.Normal; if (_mouseState == MouseState.LetGo) { if (settingsManager.inputMethod == InputMethod.TouchScreen && !settingsManager.offsetTouchCursor && runtimeInventory.selectedItem == null && !(_element is MenuInventoryBox) && !(_element is MenuCrafting)) { _mouseState = MouseState.SingleClick; } else { _mouseState = MouseState.Normal; return; } } if (_mouseState != MouseState.Normal) { if (_element.clickSound != null && sceneSettings != null) { sceneSettings.PlayDefaultSound (_element.clickSound, false); } if (_element is MenuDialogList) { MenuDialogList dialogList = (MenuDialogList) _element; dialogList.RunOption (_slot); } else if (_element is MenuSavesList) { MenuSavesList savesList = (MenuSavesList) _element; if (savesList.ProcessClick (_slot)) { if (savesList.saveListType == AC_SaveListType.Save) { _menu.TurnOff (true); } else if (savesList.saveListType == AC_SaveListType.Load) { _menu.TurnOff (false); } } } else if (_element is MenuButton) { MenuButton button = (MenuButton) _element; button.ShowClick (); if (button.buttonClickType == AC_ButtonClickType.TurnOffMenu) { _menu.TurnOff (button.doFade); } else if (button.buttonClickType == AC_ButtonClickType.Crossfade) { Menu menuToSwitchTo = GetMenuWithName (button.switchMenuTitle); if (menuToSwitchTo != null) { CrossFade (menuToSwitchTo); } else { Debug.LogWarning ("Cannot find any menu of name '" + button.switchMenuTitle + "'"); } } else if (button.buttonClickType == AC_ButtonClickType.OffsetInventoryOrDialogue) { MenuElement elementToShift = GetElementWithName (_menu.title, button.inventoryBoxTitle); if (elementToShift != null) { elementToShift.Shift (button.shiftInventory, button.shiftAmount); elementToShift.RecalculateSize (); } else { Debug.LogWarning ("Cannot find '" + button.inventoryBoxTitle + "' inside '" + _menu.title + "'"); } } else if (button.buttonClickType == AC_ButtonClickType.OffsetJournal) { MenuJournal journalToShift = (MenuJournal) GetElementWithName (_menu.title, button.inventoryBoxTitle); if (journalToShift != null) { journalToShift.Shift (button.shiftInventory, button.loopJournal); journalToShift.RecalculateSize (); } else { Debug.LogWarning ("Cannot find '" + button.inventoryBoxTitle + "' inside '" + _menu.title + "'"); } } else if (button.buttonClickType == AC_ButtonClickType.RunActionList) { if (button.actionList) { AdvGame.RunActionListAsset (button.actionList); } } else if (button.buttonClickType == AC_ButtonClickType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } else if (button.buttonClickType == AC_ButtonClickType.SimulateInput) { playerInput.SimulateInput (button.simulateInput, button.inputAxis, button.simulateValue); } } else if (_element is MenuSlider) { MenuSlider slider = (MenuSlider) _element; if (settingsManager.inputMethod == InputMethod.KeyboardOrController) { slider.Change (); } else { slider.Change (playerInput.GetMousePosition ().x - _menu.GetRect ().x); } if (slider.sliderType == AC_SliderType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } } else if (_element is MenuCycle) { MenuCycle cycle = (MenuCycle) _element; cycle.Cycle (); if (cycle.cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } } else if (_element is MenuToggle) { MenuToggle toggle = (MenuToggle) _element; toggle.Toggle (); if (toggle.toggleType == AC_ToggleType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } } else if (_element is MenuInventoryBox) { MenuInventoryBox inventoryBox = (MenuInventoryBox) _element; if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.CustomScript) { MenuSystem.OnElementClick (_menu, _element, _slot, (int) _mouseState); } else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Default || inventoryBox.inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected) { if (settingsManager.inventoryInteractions == InventoryInteractions.Multiple && settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingCursorAndClickingHotspot) { if (_mouseState == MouseState.SingleClick) { playerInteraction.ClickInvItemToInteract (); } } else if (settingsManager.inventoryInteractions == InventoryInteractions.Multiple && playerInput.interactionMenuIsOn && settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingMenuAndClickingHotspot && runtimeInventory.selectedItem == runtimeInventory.hoverItem) { SetInteractionMenus (false); playerInteraction.ClickInvItemToInteract (); } else if (settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Single) { inventoryBox.HandleDefaultClick (_mouseState, _slot, AC_InteractionMethod.ContextSensitive); } else { inventoryBox.HandleDefaultClick (_mouseState, _slot, settingsManager.interactionMethod); } _menu.Recalculate (); } else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Container) { inventoryBox.ClickContainer (_mouseState, _slot, playerInput.activeContainer); _menu.Recalculate (); } else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.HostpotBased) { if (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction) { if (runtimeInventory.selectedItem != null) { runtimeInventory.Combine (inventoryBox.items [_slot]); } else if (playerInteraction.GetActiveHotspot ()) { InvItem _item = inventoryBox.items [_slot]; if (_item != null) { runtimeInventory.SelectItem (_item); _menu.TurnOff (false); playerInteraction.ClickButton (InteractionType.Inventory, -2, _item.id); 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."); } } } else if (_element is MenuCrafting) { MenuCrafting recipe = (MenuCrafting) _element; if (recipe.craftingType == CraftingElementType.Ingredients) { recipe.HandleDefaultClick (_mouseState, _slot); } else if (recipe.craftingType == CraftingElementType.Output) { recipe.ClickOutput (_menu, _mouseState); } _menu.Recalculate (); } else if (_element is MenuInteraction) { MenuInteraction interaction = (MenuInteraction) _element; if (settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive) { Debug.LogWarning ("This element is not compatible with the Context-Sensitive interaction method."); } else if (settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot) { playerCursor.SetCursorFromID (interaction.iconID); } else if (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction) { if (runtimeInventory.selectedItem != null) { _menu.ForceOff (); runtimeInventory.RunInteraction (false, interaction.iconID); } else if (playerInteraction.GetActiveHotspot ()) { _menu.ForceOff (); playerInteraction.ClickButton (InteractionType.Use, interaction.iconID, -1); } } } else if (_element is MenuInput) { SelectInputBox ((MenuInput) _element); } else if (_element is MenuDrag) { if (_mouseState == MouseState.SingleClick) { MenuDrag drag = (MenuDrag) _element; drag.StartDrag (_menu); playerInput.activeDragElement = drag; } } PlayerMenus.ResetInventoryBoxes (); } }
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 { Debug.LogWarning ("Cannot find any menu of name '" + switchMenuTitle + "'"); } } else if (buttonClickType == AC_ButtonClickType.OffsetElementSlot) { if (elementToShift == null) { elementToShift = PlayerMenus.GetElementWithName (_menu.title, inventoryBoxTitle); } if (elementToShift != null) { elementToShift.Shift (shiftInventory, shiftAmount); elementToShift.RecalculateSize (_menu.menuSource); } else { Debug.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); journalToShift.RecalculateSize (_menu.menuSource); } else { Debug.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 CheckClick(AC.Menu _menu, MenuElement _element, int _slot, MouseState _mouseState) { KickStarter.playerInput.ResetMouseClick (); if (_mouseState == MouseState.LetGo) { if (_menu.appearType == AppearType.OnInteraction && KickStarter.settingsManager.ReleaseClickInteractions () && !KickStarter.settingsManager.CanDragCursor () && KickStarter.runtimeInventory.selectedItem == null) { _mouseState = MouseState.SingleClick; } else if (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen && !KickStarter.settingsManager.CanDragCursor () && KickStarter.runtimeInventory.selectedItem == null && !(_element is MenuInventoryBox) && !(_element is MenuCrafting)) { _mouseState = MouseState.SingleClick; } else { _mouseState = MouseState.Normal; return; } } if (_mouseState != MouseState.Normal) { _element.ProcessClick (_menu, _slot, _mouseState); PlayerMenus.ResetInventoryBoxes (); } }
/** * <summary>Simulates the clicking of a MenuElement.</summary> * <param name = "menuName">The name (title) of the Menu that contains the MenuElement</param> * <param name = "_element">The MenuElement</param> * <param name = "slot">The index number of the slot, if the MenuElement has multiple slots</param> */ public static void SimulateClick(string menuName, MenuElement _element, int _slot = 1) { if (KickStarter.playerMenus) { AC.Menu menu = PlayerMenus.GetMenuWithName (menuName); KickStarter.playerMenus.CheckClick (menu, _element, _slot, MouseState.SingleClick); } }