public void RemoveConnector(UIConnection _uiConnection) { if (allConnectors != null) { allConnectors.Remove(_uiConnection); } }
private void LookForTimeDelay() { m_timerIsActive = false; UseUpdate = false; if (OutputSockets == null || OutputSockets.Count == 0) { return; } foreach (Socket socket in OutputSockets) { if (!socket.IsConnected) { continue; } UIConnection value = UIConnection.GetValue(socket); if (value.Trigger != UIConnectionTrigger.TimeDelay) { continue; } if (value.TimeDelay < 0) { continue; //sanity check } ActivateTimer(value.TimeDelay, socket); break; } }
public void AddConnector(UIConnection _uiConnection) { if (allConnectors != null) { allConnectors.Add(_uiConnection); } }
private void OnGameEventMessage(GameEventMessage message) { if (OutputSockets == null || OutputSockets.Count == 0) { return; } foreach (Socket socket in OutputSockets) { if (!socket.IsConnected) { continue; } UIConnection value = UIConnection.GetValue(socket); if (value.Trigger != UIConnectionTrigger.GameEvent) { continue; } if (!value.GameEvent.Equals(message.EventName)) { continue; } ActivateOutputSocketInputNode(socket); break; } }
private void OnButtonMessage(UIButtonMessage message) { if (OutputSockets == null || OutputSockets.Count == 0) { return; } UIConnectionTrigger trigger; switch (message.Type) { case UIButtonBehaviorType.OnClick: trigger = UIConnectionTrigger.ButtonClick; break; case UIButtonBehaviorType.OnDoubleClick: trigger = UIConnectionTrigger.ButtonDoubleClick; break; case UIButtonBehaviorType.OnLongClick: trigger = UIConnectionTrigger.ButtonLongClick; break; case UIButtonBehaviorType.OnRightClick: case UIButtonBehaviorType.OnPointerEnter: case UIButtonBehaviorType.OnPointerExit: case UIButtonBehaviorType.OnPointerDown: case UIButtonBehaviorType.OnPointerUp: case UIButtonBehaviorType.OnSelected: case UIButtonBehaviorType.OnDeselected: case UIButtonBehaviorType.OnBeginDrag: case UIButtonBehaviorType.OnDrag: case UIButtonBehaviorType.OnEndDrag: case UIButtonBehaviorType.OnDragOver: case UIButtonBehaviorType.OnDrop: return; default: throw new ArgumentOutOfRangeException(); } foreach (Socket socket in OutputSockets) { if (!socket.IsConnected) { continue; } UIConnection value = UIConnection.GetValue(socket); if (value.Trigger != trigger) { continue; } if (!value.ButtonName.Equals(message.Button != null ? message.Button.ButtonName : message.ButtonName)) { continue; } ActivateOutputSocketInputNode(socket); break; } }
/// <summary> /// Creates a new instance of <see cref="ConnectionDialog">ConnectionDialog</see> dialog. /// </summary> public ConnectionDialog() { InitializeComponent(); _uilink = null; _propertyManagerCache = new Hashtable(); _startingLinkID = 0; _shouldBeSaved = false; _elementSetViewer = new ElementSetViewer(); }
public override void AddDefaultSockets() { base.AddDefaultSockets(); AddInputSocket(ConnectionMode.Multiple, typeof(UIConnection), false, false); AddOutputSocket(ConnectionMode.Override, typeof(UIConnection), true, true); UIConnection value = UIConnection.GetValue(OutputSockets[0]); value.Trigger = UIConnectionTrigger.ButtonClick; value.ButtonCategory = NamesDatabase.GENERAL; value.ButtonName = NamesDatabase.BACK; UIConnection.SetValue(OutputSockets[0], value); }
public ConnectionDialog(UIConnection connection) { InitializeComponent(); currentLink = new Link(); this.connection = connection; this.Text = connection.SourceModel.LinkableComponent.Caption + " => " + connection.TargetModel.LinkableComponent.Caption; elementSetViewer = new ElementSetViewer(); updateTargetsTreeView(); updateSourcesTreeView(); listBoxConnections.DataSource = connection.Links; }
/// <summary> /// Populates this <see cref="ConnectionDialog">ConnectionDialog</see> with specific connection. /// </summary> /// <param name="uilink"></param> public void PopulateDialog(UIConnection uilink) { _uilink = uilink; _propertyManagerCache = new Hashtable(); _shouldBeSaved = false; _treeSource.TreePopulate( uilink, _treeOptionsSources); _treeTarget.TreePopulate( uilink, _treeOptionsTargets); ElementTypeFilterCheckBox.Checked = false; DimensionFilterCheckBox.Checked = false; UpdateListLinks(); Text = "Connection: " + uilink.SourceModel.InstanceCaption + " => " + uilink.TargetModel.InstanceCaption; }
public void TreePopulate(UIConnection connection, TreeOptions options) { ITimeSpaceComponent source = connection.SourceModel.LinkableComponent; ITimeSpaceComponent target = connection.TargetModel.LinkableComponent; List <UIOutputItem> extraSources = new List <UIOutputItem>(); UIOutputItem src; foreach (Link pair in connection.Links) { src = pair.Source; //while (src.Parent != null) // decorator //{ // extraSources.Add(src); // src = src.Parent; //} } TreePopulate(source, target, extraSources, options); }
/// <summary> /// Populates this <see cref="ConnectionDialog">ConnectionDialog</see> with specific connection. /// </summary> /// <param name="uilink"></param> /// <param name="startingLinkID"></param> public void PopulateDialog(UIConnection uilink, int startingLinkID) { _uilink = uilink; _startingLinkID = startingLinkID; _propertyManagerCache = new Hashtable(); _shouldBeSaved = false; ElementTypeFilterCheckBox.Checked = false; DimensionFilterCheckBox.Checked = false; int count; ILinkableComponent component; component = uilink.ProvidingModel.LinkableComponent; IExchangeItem[] outputExchangeItems = new IExchangeItem[component.OutputExchangeItemCount]; count = component.OutputExchangeItemCount; for (int i = 0; i < count; i++) { outputExchangeItems[i] = component.GetOutputExchangeItem(i); } providerExchangeItemSelector.PopulateExchangeItemTree(outputExchangeItems, true); component = uilink.AcceptingModel.LinkableComponent; IExchangeItem[] inputExchangeItems = new IExchangeItem[component.InputExchangeItemCount]; count = component.InputExchangeItemCount; for (int i = 0; i < count; i++) { inputExchangeItems[i] = component.GetInputExchangeItem(i); } acceptorExchangeItemSelector.PopulateExchangeItemTree(inputExchangeItems, true); UpdateListLinks(); labelInfo.Text = "Connection " + uilink.ProvidingModel.ModelID + " => " + uilink.AcceptingModel.ModelID; }
/// <summary> /// Creates a new instance of <see cref="ConnectionDialog">ConnectionDialog</see> dialog. /// </summary> public ConnectionDialog(List <UIModel> models) { _models = models; InitializeComponent(); _uilink = null; _propertyManagerCache = new Hashtable(); _shouldBeSaved = false; _elementSetViewer = new ElementSetViewer(); _treeOptionsSources.IsSource = true; _treeOptionsSources.ShowCheckboxs = true; _treeOptionsTargets.IsTarget = true; _treeOptionsTargets.ShowCheckboxs = true; _tooltips = new ToolTip(); _tooltips.AutoPopDelay = 5000; _tooltips.InitialDelay = 1000; _tooltips.ReshowDelay = 500; _tooltips.ShowAlways = true; _tooltips.IsBalloon = true; _tooltips.ToolTipIcon = ToolTipIcon.Info; string active = "\r\nOnly active when both source and target items are ticked"; _tooltips.SetToolTip(btnLinkAdd, "Create a new link from ticked source and target" + active); _tooltips.SetToolTip(btnLinkRemove, "Remove a link\r\nOnly active when a link is selected"); _tooltips.SetToolTip(btnViewer, "View spatial representation of source and target" + active); _tooltips.SetToolTip(btnAddSources, "Add additional sources from 'Source Model' or '3rd party dll'" + active); _tooltips.SetToolTip(btnArgEdit, "Edit adapted source arguments\r\nOnly active when an adapted source is ticked"); }
// Update is called once per frame void Update() { currentUI = allConnectors.Count; //Unselect Option if it becomes unavailable if (currentUIConnection != null && !currentUIConnection.isActiveAndEnabled) { currentUIConnection = null; } //Clear all Null Button allConnectors.RemoveAll(IsNull); bool mouseOnAnything = false; foreach (UIConnection uiConnector in allConnectors.ToArray()) { RectTransform rectTransform = uiConnector.GetComponent <RectTransform>(); Button button = uiConnector.GetComponent <Button>(); Toggle toggle = uiConnector.GetComponent <Toggle>(); InputField inputField = uiConnector.GetComponent <InputField>(); //Do Open and Close if Button if (uiConnector.isActiveAndEnabled && rectTransform != null && (button != null || inputField != null || toggle != null)) { //Set as default if (currentUIConnection == null && uiConnector.priority) { currentUIConnection = uiConnector; } if (Cursor.visible && (playerCanUse == 0 || (playerCanUse - 1) == InputManager.GetMousePlayer())) { if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main)) { currentUIConnection = uiConnector; mouseOnAnything = true; } } if (currentUIConnection == uiConnector) { uiConnector.OnSelected(); } else { uiConnector.OnUnSelected(); } } } submitInput = false; cancelInput = false; if (eventSystem == null) { eventSystem = FindObjectOfType <EventSystem>(); } else if (eventSystem.isActiveAndEnabled) { //Do Input for (int i = 0; i < InputManager.controllers.Count; i++) { if (playerCanUse == 0 || playerCanUse == i + 1) { InputDevice player = InputManager.controllers[i]; if (currentUIConnection != null) { if (player.GetRawButtonWithLock("Submit", true)) { if (currentUIConnection.GetComponent <Button>() != null) { currentUIConnection.GetComponent <Button>().onClick.Invoke(); } if (currentUIConnection.GetComponent <Toggle>() != null) { currentUIConnection.GetComponent <Toggle>().onValueChanged.Invoke(!currentUIConnection.GetComponent <Toggle>().isOn); } currentUIConnection.OnClicked(i); submitInput = true; } if (player.GetRawButtonWithLock("Cancel", true)) { cancelInput = true; } if (currentUIConnection.GetComponent <InputField>() != null && mouseOnAnything && player.inputType == InputType.Keyboard && InputManager.GetClick(0)) { currentUIConnection.OnClicked(i); } if (!mouseOnAnything) { int hori = player.GetRawIntInputWithDelay("MenuHorizontal", 0.25f, Time.unscaledDeltaTime); int vert = player.GetRawIntInputWithDelay("MenuVertical", 0.25f, Time.unscaledDeltaTime); //Navigation if (hori > 0 && currentUIConnection.OnRight != null) { currentUIConnection = currentUIConnection.OnRight; } if (hori < 0 && currentUIConnection.OnLeft != null) { currentUIConnection = currentUIConnection.OnLeft; } if (vert < 0 && currentUIConnection.OnUp != null) { currentUIConnection = currentUIConnection.OnUp; } if (vert > 0 && currentUIConnection.OnDown != null) { currentUIConnection = currentUIConnection.OnDown; } } } } } } }
private static bool IsNull(UIConnection s) { return(s == null); }
void UpdateSaveList(bool isSave) { if (saveSlots != null) { foreach (SaveSlot save in saveSlots) { Destroy(save.gameObject); } } GameObject menu = isSave ? saveMenu : loadMenu; GameObject buttonPrefab = isSave ? saveButtonPrefab : loadButtonPrefab; buttonPrefab.SetActive(true); saveSlots = new List <SaveSlot>(); GameObject scrollView = menu.GetComponentInChildren <ScrollRect>().content.gameObject; string[] allSaveFiles = Directory.GetFiles(Application.persistentDataPath); validFiles = new List <string>(); UIConnection backButton = menu.transform.Find("Back").GetComponent <UIConnection>(); foreach (string saveFile in allSaveFiles) { string[] extensionCheck = saveFile.Split('.'); if (extensionCheck[extensionCheck.Length - 1] == "gd") { if (File.Exists(saveFile)) { BinaryReader br = new BinaryReader(File.Open(saveFile, FileMode.Open)); SaveData tempSaveData = new SaveData(); int version = br.ReadInt32(); if (version <= SaveData.saveVersion) { bool allowSave = false; //Load Save Data try { tempSaveData.LoadAllData(version, br); allowSave = true; } catch { Debug.Log("Dodgy Save"); } finally { br.Close(); if (allowSave) { SaveSlot slot; slot.location = saveFile; slot.gameObject = Instantiate(buttonPrefab, transform); saveSlots.Add(slot); slot.gameObject.transform.SetParent(buttonPrefab.transform.parent); RectTransform rectTransform = slot.gameObject.GetComponent <RectTransform>(); rectTransform.anchoredPosition = buttonPrefab.GetComponent <RectTransform>().anchoredPosition - new Vector2(0, (rectTransform.sizeDelta.y + 10) * (saveSlots.Count - 1)); Text text = slot.gameObject.GetComponentInChildren <Text>(); string[] fileNameSplit = saveFile.Split('\\'); text.text = fileNameSplit[fileNameSplit.Length - 1].Remove(fileNameSplit[fileNameSplit.Length - 1].Length - 3); int count = validFiles.Count; Debug.Log("validFiles.Count:" + validFiles.Count); Debug.Log("Loaded Save:" + text.text); validFiles.Add(saveFile); } } } } } } for (int i = 0; i < saveSlots.Count; i++) { UIConnection button = saveSlots[i].gameObject.GetComponent <UIConnection>(); string location = saveSlots[i].location; if (!isSave) { button.GetComponent <Button>().onClick.AddListener(delegate { LoadLevel(location); }); } else { button.GetComponent <Button>().onClick.AddListener(delegate { OverwriteSave(location); }); } if (i == 0) { if (isSave) { saveAsNewFile.OnDown = button; button.OnUp = saveAsNewFile; backButton.OnDown = inputField.GetComponent <UIConnection>(); } else { backButton.OnDown = button; button.priority = true; button.OnUp = backButton; } } if (i < saveSlots.Count - 1) { UIConnection nextButton = saveSlots[i + 1].gameObject.GetComponent <UIConnection>(); button.OnDown = nextButton; nextButton.OnUp = button; } else { button.OnDown = backButton; backButton.OnUp = button; } } if (!isSave) { if (saveSlots.Count == 0) { backButton.priority = true; } else { backButton.priority = false; } } scrollView.GetComponent <RectTransform>().sizeDelta = new Vector2(scrollView.GetComponent <RectTransform>().sizeDelta.x, (saveSlots.Count * 110f) + 75f); buttonPrefab.SetActive(false); }
private void UpdateSocketValue(Socket socket, UIConnection value) { UIConnection.SetValue(socket, value); GraphEvent.Send(GraphEvent.EventType.EVENT_NODE_UPDATED, TargetNode.Id); }
protected override Rect DrawSocket(Socket socket) { Rect socketRect = base.DrawSocket(socket); if (ZoomedBeyondSocketDrawThreshold) { return(socketRect); } if (socket.IsInput) { return(socketRect); } UIConnection socketValue = UIConnection.GetValue(socket); m_areaRect = new Rect(socket.GetX() + 24, socket.GetY(), socket.GetWidth() - 48, socket.GetHeight()); GUIStyle triggerIcon; switch (socketValue.Trigger) { case UIConnectionTrigger.ButtonClick: triggerIcon = Styles.GetStyle(Styles.StyleName.IconButtonClick); break; case UIConnectionTrigger.ButtonDoubleClick: triggerIcon = Styles.GetStyle(Styles.StyleName.IconButtonDoubleClick); break; case UIConnectionTrigger.ButtonLongClick: triggerIcon = Styles.GetStyle(Styles.StyleName.IconButtonLongClick); break; case UIConnectionTrigger.GameEvent: triggerIcon = Styles.GetStyle(Styles.StyleName.IconGameEventListener); break; case UIConnectionTrigger.TimeDelay: triggerIcon = Styles.GetStyle(Styles.StyleName.IconTime); break; default: throw new ArgumentOutOfRangeException(); } float socketOpacity = socket.IsConnected ? NodySettings.Instance.SocketConnectedOpacity : NodySettings.Instance.SocketNotConnectedOpacity; Color iconAndTextColor = (DGUI.Utility.IsProSkin ? Color.white.Darker() : Color.black.Lighter()).WithAlpha(socketOpacity); string label; switch (socketValue.Trigger) { case UIConnectionTrigger.ButtonClick: case UIConnectionTrigger.ButtonDoubleClick: case UIConnectionTrigger.ButtonLongClick: label = socketValue.ButtonName; break; case UIConnectionTrigger.GameEvent: label = socketValue.GameEvent; break; case UIConnectionTrigger.TimeDelay: label = socketValue.TimeDelay + " " + UILabels.SecondsDelay; if (socket.IsConnected) { m_progressBarRect = new Rect(m_areaRect.x + kSocketIconSize + DGUI.Properties.Space(4), m_areaRect.yMax - DGUI.Properties.Space(2), m_areaRect.width - kSocketIconSize, DGUI.Properties.Space()); DrawProgressBar(m_progressBarRect, TargetNode.TimerProgress, m_progressBarRect.height, false); } break; default: throw new ArgumentOutOfRangeException(); } GUILayout.BeginArea(m_areaRect); { GUILayout.BeginHorizontal(); { m_iconRect = new Rect(0, socket.GetHeight() / 2 - kSocketIconSize / 2, kSocketIconSize, kSocketIconSize); DGUI.Icon.Draw(m_iconRect, triggerIcon, iconAndTextColor); GUILayout.Space(DGUI.Properties.Space(2) + kSocketIconSize + DGUI.Properties.Space(2)); DGUI.Label.Draw(label, DGUI.Colors.ColorTextOfGUIStyle(DGUI.Label.Style(Editor.Size.M, TextAlign.Left), iconAndTextColor), socket.GetHeight()); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); return(socket.GetRect()); }
// Update is called once per frame void Update() { //Ensure we have enough current UI Connections if (userControlMode == UserControlMode.CursorPerPlayer) { //Controller Adding foreach (KeyValuePair <int, InputDevice> controller in InputManager.controllers) { if (!currentUIConnection.ContainsKey(controller.Key)) { currentUIConnection.Add(controller.Key, null); } } //Controller Removing List <int> indexToRemove = new List <int>(); foreach (KeyValuePair <int, UIConnection> connection in currentUIConnection) { if (!InputManager.controllers.ContainsKey(connection.Key)) { indexToRemove.Add(connection.Key); } } foreach (int index in indexToRemove) { currentUIConnection.Remove(index); } } else { if (InputManager.controllers.Count == 0 && currentUIConnection.Count > 0) { currentUIConnection.Remove(-1); } else if (InputManager.controllers.Count > 0 && currentUIConnection.Count == 0) { currentUIConnection.Add(-1, null); } } //Clear all Null Button allConnectors.RemoveAll(IsNull); //Mouse Input and Selected/Unselected Behaviour bool mouseOnAnything = false; foreach (UIConnection uiConnector in allConnectors.ToArray()) { RectTransform rectTransform = uiConnector.GetComponent <RectTransform>(); Button button = uiConnector.GetComponent <Button>(); Toggle toggle = uiConnector.GetComponent <Toggle>(); InputField inputField = uiConnector.GetComponent <InputField>(); //Do Open and Close if Button if (uiConnector.isActiveAndEnabled && rectTransform != null && (button != null || inputField != null || toggle != null)) { //Mouse Checks if (Cursor.visible && (playerCanUse == -1 || (playerCanUse) == InputManager.GetMousePlayer())) { if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, null)) { currentUIConnection[playerCanUse] = uiConnector; mouseOnAnything = true; } } bool selected = false; foreach (KeyValuePair <int, UIConnection> connection in new Dictionary <int, UIConnection>(currentUIConnection)) { //Set as default for each input if Priority if (connection.Value == null && uiConnector.priority) { currentUIConnection[connection.Key] = uiConnector; } //Do On Selected if Player has selected this if (connection.Value == uiConnector) { selected = true; break; } } if (selected) { uiConnector.OnSelected(); } else { uiConnector.OnUnSelected(); } } } //Behaviour for each Controller foreach (KeyValuePair <int, UIConnection> connection in new Dictionary <int, UIConnection>(currentUIConnection)) { //Unselect Option if it becomes unavailable if (connection.Value != null && !connection.Value.isActiveAndEnabled) { currentUIConnection[connection.Key] = null; } } if (eventSystem == null) { eventSystem = FindObjectOfType <EventSystem>(); } else if (eventSystem.isActiveAndEnabled) { //Do Input foreach (KeyValuePair <int, InputDevice> controller in InputManager.controllers) { int playerID = playerCanUse == -1 ? controller.Key : playerCanUse; int uiConnectionIndex = userControlMode == UserControlMode.CursorPerPlayer ? playerID : -1; if (playerID == controller.Key) { InputDevice player = controller.Value; UIConnection playerConnection = currentUIConnection[uiConnectionIndex]; if (playerConnection) { if (player.GetRawButtonWithLock("Submit", LockOverride.OverrideLocalLock)) { if (playerConnection.GetComponent <Button>() != null) { playerConnection.GetComponent <Button>().onClick.Invoke(); } if (playerConnection.GetComponent <Toggle>() != null) { playerConnection.GetComponent <Toggle>().onValueChanged.Invoke(!playerConnection.GetComponent <Toggle>().isOn); } playerConnection.OnSubmit(playerID); } if (player.GetRawButtonWithLock("Cancel", LockOverride.OverrideLocalLock)) { playerConnection.OnCancelled(playerID); } if (mouseOnAnything && player.inputType == InputType.Keyboard && InputManager.GetClick(0)) { playerConnection.OnClicked(playerID); } if (!mouseOnAnything) { int hori = player.GetRawIntInputWithDelay("MenuHorizontal", 0.25f, Time.unscaledDeltaTime); int vert = player.GetRawIntInputWithDelay("MenuVertical", 0.25f, Time.unscaledDeltaTime); //Navigation if (hori > 0 && playerConnection.OnRight != null) { currentUIConnection[uiConnectionIndex] = playerConnection.OnRight; } if (hori < 0 && playerConnection.OnLeft != null) { currentUIConnection[uiConnectionIndex] = playerConnection.OnLeft; } if (vert < 0 && playerConnection.OnUp != null) { currentUIConnection[uiConnectionIndex] = playerConnection.OnUp; } if (vert > 0 && playerConnection.OnDown != null) { currentUIConnection[uiConnectionIndex] = playerConnection.OnDown; } } } } } } debugArray = new UIConnection[currentUIConnection.Count]; int count = 0; foreach (KeyValuePair <int, UIConnection> controller in currentUIConnection) { debugArray[count] = currentUIConnection[controller.Key]; count++; } } // Update