/** * Initialises the element when it is created within MenuManager. */ public override void Declare() { uiText = null; label = "Label"; isVisible = true; isClickable = false; numSlots = 1; anchor = TextAnchor.MiddleCenter; SetSize(new Vector2(10f, 5f)); labelType = AC_LabelType.Normal; variableID = 0; useCharacterColour = false; autoAdjustHeight = true; textEffects = TextEffects.None; outlineSize = 2f; newLabel = ""; updateIfEmpty = false; showPendingWhileMovingToHotspot = false; inventoryPropertyType = InventoryPropertyType.SelectedItem; selectedObjectiveLabelType = SelectedObjectiveLabelType.Title; itemPropertyID = 0; itemSlotNumber = 0; multiplyByItemCount = false; base.Declare(); }
private void CopyLabel(MenuLabel _element, bool ignoreUnityUI) { if (ignoreUnityUI) { uiText = null; } else { uiText = _element.uiText; } label = _element.label; anchor = _element.anchor; textEffects = _element.textEffects; outlineSize = _element.outlineSize; labelType = _element.labelType; variableID = _element.variableID; useCharacterColour = _element.useCharacterColour; autoAdjustHeight = _element.autoAdjustHeight; updateIfEmpty = _element.updateIfEmpty; showPendingWhileMovingToHotspot = _element.showPendingWhileMovingToHotspot; newLabel = string.Empty; inventoryPropertyType = _element.inventoryPropertyType; selectedObjectiveLabelType = _element.selectedObjectiveLabelType; itemPropertyID = _element.itemPropertyID; itemSlotNumber = _element.itemSlotNumber; multiplyByItemCount = _element.multiplyByItemCount; base.Copy(_element); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuLabel)"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); if (source != MenuSource.AdventureCreator) { #if TextMeshProIsPresent uiText = LinkedUiGUI <TMPro.TextMeshProUGUI> (uiText, "Linked Text:", source); #else uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); #endif EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); } labelType = (AC_LabelType)CustomGUILayout.EnumPopup("Label type:", labelType, apiPrefix + ".labelType", "What kind of text the label displays"); if (labelType == AC_LabelType.Normal) { label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label", "The display text"); } else if (source == MenuSource.AdventureCreator) { label = CustomGUILayout.TextField("Placeholder text:", label, apiPrefix + ".label"); } if (labelType == AC_LabelType.GlobalVariable) { variableID = AdvGame.GlobalVariableGUI("Global Variable:", variableID, "The Global Variable whose value will be displayed"); } else if (labelType == AC_LabelType.DialogueLine) { useCharacterColour = CustomGUILayout.Toggle("Use Character text colour?", useCharacterColour, apiPrefix + ".useCharacterColour", "If True, then the displayed subtitle text will use the speaking character's subtitle text colour"); if (sizeType == AC_SizeType.Manual && source == MenuSource.AdventureCreator) { autoAdjustHeight = CustomGUILayout.Toggle("Auto-adjust height to fit?", autoAdjustHeight, apiPrefix + ".autoAdjustHeight", "If True, then the label's height will adjust itself to fit the text within it"); } } else if (labelType == AC_LabelType.SelectedObjective) { selectedObjectiveLabelType = (SelectedObjectiveLabelType)CustomGUILayout.EnumPopup("Objective text:", selectedObjectiveLabelType, apiPrefix + ".selectedObjectiveLabelType", "Which associated text of the selected Objective to display"); } if (labelType == AC_LabelType.Hotspot || labelType == AC_LabelType.DialogueLine || labelType == AC_LabelType.DialogueSpeaker) { updateIfEmpty = CustomGUILayout.Toggle("Update if string is empty?", updateIfEmpty, apiPrefix + ".updateIfEmpty", "If True, then the display text buffer can be empty "); if (labelType == AC_LabelType.Hotspot) { showPendingWhileMovingToHotspot = CustomGUILayout.ToggleLeft("Show pending Interaction while moving to Hotspot?", showPendingWhileMovingToHotspot, apiPrefix + ".showPendingWhileMovingToHotspot", "If True, then the label will not change while the player is moving towards a Hotspot in order to run an interaction"); } } else if (labelType == AC_LabelType.InventoryProperty) { if (AdvGame.GetReferences().inventoryManager) { if (AdvGame.GetReferences().inventoryManager.invVars != null && AdvGame.GetReferences().inventoryManager.invVars.Count > 0) { InvVar[] invVars = AdvGame.GetReferences().inventoryManager.invVars.ToArray(); List <string> invVarNames = new List <string>(); int itemPropertyNumber = 0; for (int i = 0; i < invVars.Length; i++) { if (invVars[i].id == itemPropertyID) { itemPropertyNumber = i; } invVarNames.Add(invVars[i].id + ": " + invVars[i].label); } itemPropertyNumber = CustomGUILayout.Popup("Inventory property:", itemPropertyNumber, invVarNames.ToArray(), apiPrefix + ".itemPropertyNumber", "The inventory property to show"); itemPropertyID = invVars[itemPropertyNumber].id; inventoryPropertyType = (InventoryPropertyType)CustomGUILayout.EnumPopup("Inventory item source:", inventoryPropertyType, apiPrefix + ".inventoryPropertyType", "What kind of item to display properties for"); if (invVars[itemPropertyNumber].type == VariableType.Float || invVars[itemPropertyNumber].type == VariableType.Integer) { multiplyByItemCount = CustomGUILayout.Toggle("Multiply by item count?", multiplyByItemCount, apiPrefix + ".multiplyByItemCount", "If True, then the property's value will be multipled by the item's count."); } } else { EditorGUILayout.HelpBox("No Inventory properties defined!", MessageType.Warning); } } else { EditorGUILayout.HelpBox("No Inventory Manager assigned!", MessageType.Warning); } } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }