protected virtual void DrawNodes(NodeModifier[] nodeList, bool coreNode = false) { for (int i = 0; i < nodeList.Length; i++) { NodeModifier node = nodeList[i]; Rect nodeRect = DrawNodeRect(node, coreNode); //Draw conection bazier line if (node is Decorator) { DrawBazierLine(node, (node as Decorator).ColorLine); } else { DrawBazierLine(node); } //DrawBazierLine(node); //Draw Node DrawNodeSlot(node, nodeRect); DrawNodes(node.GetNextNodes(node)); if (_isConnecting) { continue; } DragNodeEvent(node, nodeRect); } }
protected virtual void DrawRunModeLable(NodeModifier node, Rect nodeRect) { Rect rect = new Rect(nodeRect); rect.position = new Vector2(rect.position.x + (rect.width / 2 - 5), rect.position.y - 15); GUIStyle style = new GUIStyle(); switch (node.RunMode) { case EnumRunMode.DirectRuning: GUI.Box(rect, "<color=#00BFFF>→</color>", style); break; case EnumRunMode.UntilSuccess: GUI.Box(rect, "<color=#00FF00>✔</color>", style); break; case EnumRunMode.ReturnParentNode: GUI.Box(rect, "<color=#FFFF00>←</color>", style); break; case EnumRunMode.StopNodeList: GUI.Box(rect, "<color=red>✘</color>", style); break; } }
protected virtual void DrawHelp(NodeModifier node) { if (node == null) { return; } HelpAttribute help = Attribute.GetCustomAttribute(node.GetType(), typeof(HelpAttribute)) as HelpAttribute; if (help == null) { return; } GUIStyle style = new GUIStyle(); style.fontSize = 13; style.normal.textColor = Color.white;// new Color32(238, 130, 238, 255); style.clipping = TextClipping.Overflow; style.wordWrap = true; GUIContent con = new GUIContent(help.Help); //Vector2 size = style.CalcSize(con); float width = 200;// size.x > 200 ? 200 : size.x; float height = style.CalcHeight(con, width); Rect rect = new Rect(_contentRect.x + 5, _contentRect.y + 70, width, height); //GUI.Box(rect, "", ResourcesManager.GetInstance.skin.box); EditorGUI.LabelField(rect, con, style); }
private void DrawChildNodes(NodeModifier[] nodeList, bool coreNode = false) { for (int i = 0; i < nodeList.Length; i++) { NodeModifier node = nodeList[i]; if (_alreadyDrawNode.Contains(node)) { continue; } DrawNodeRect(node, coreNode); //Draw conection bazier line if (node is Decorator) { DrawBazierLine(node, (node as Decorator).ColorLine); } else { DrawBazierLine(node); } _alreadyDrawNode.Add(node); DrawChildNodes(node.GetNextNodes(node)); } }
protected void LinkCurrentNode() { //强制链接单节点 if (Event.current.control) { _currentNode.AddNextNode(_currentHover); return; } if (!_currentHover.CanSetParent(_currentNode)) { //if (_currentNode.IsParent(_currentHover)) if (!_currentNode.HaveParentNodeInNext()) { _currentNode.AddNextNode(_currentHover); return; } EditorUtility.DisplayDialog("Error", "Not allow connect to twice parent! You must break one connect with parent and then change it.", "OK"); return; } if (NodeModifier.SetParent(_currentHover, _currentNode)) { OnLinkNode(_currentNode, _currentHover); } }
protected override void OnNodeNameChange(NodeModifier node, string oldName) { base.OnNodeNameChange(node, oldName); if (!_window._storyObject.RenameMission(oldName, node._name)) { node._name = oldName; } }
private GUIContent GetDescription(NodeModifier node) { try { return(new GUIContent((node as DialogNode).ToDescription())); } catch (System.Exception) { return(new GUIContent()); } }
protected override void DrawNodes(NodeModifier[] nodeList, bool coreNode = false) { _alreadyDrawNode.Clear(); for (int i = 0; i < nodeList.Length; i++) { NodeModifier node = nodeList[i]; DrawParentNodes(node, coreNode); } }
protected override Rect DrawNodeRect(NodeModifier node, bool coreNode = false) { Rect rect = base.DrawNodeRect(node, coreNode); DragNodeEvent(node, rect); if (coreNode) { DrawRunningNodeLabel(rect); } return(rect); }
public void Set_ChangeAssemblyVersion_ShouldChangeToModifyProject() { var testProject = TestPathHelper.GetTestProjectPath("TO_MODIFY"); var newBuildNumber = Convert.ToInt32((DateTime.Now - DateTime.Today).TotalSeconds); var setAssemblyVersion = $"1.0.{newBuildNumber}"; NodeModifier.Set(testProject, VersionNode.AssemblyVersion, setAssemblyVersion); var assemblyVersion = NodeFinder.GetVersionNodeValue(testProject, VersionNode.AssemblyVersion); assemblyVersion.ValueUnsafe().ShouldBe(setAssemblyVersion); }
protected void DragNodeEvent(NodeModifier node, Rect nodeRect) { #region Drag Event if (Event.current != null) { if (Event.current.button == 0) { if (!Tools.MouseIsInContent()) { return; } if (Event.current.type == EventType.MouseDown) { if (Tools.IsValidMouseAABB(nodeRect)) { _mouseDownCenter = node._position; _currentNode = node; _currentNodeRect = nodeRect; _mouseIsDown = true; } else if (!_mouseIsDown) { _couldMultiSelect = true; } _mouseDownPos = Event.current.mousePosition; } if (Event.current.type == EventType.MouseUp) { _mouseIsDown = false; _couldMultiSelect = false; } if (Event.current.type == EventType.MouseDrag && Event.current.button == 0 && _mouseIsDown) { if (_currentNode == null) { return; } Vector2 offset = Event.current.mousePosition - _mouseDownPos; _currentNode._position = _mouseDownCenter + offset / _window.Zoom; } } } #endregion }
protected virtual Rect DrawNodeRect(NodeModifier node, bool coreNode = false) { Vector2 pos = CalcRealPosition(node._position); Rect nodeRect = Tools.GetNodeRect(pos); GUIStyle style = new GUIStyle(_currentNode == node ? ResourcesManager.GetInstance.skin.box : ResourcesManager.GetInstance.skin.box); style.fontSize = (int)(style.fontSize * _window.Zoom); GUI.Box(nodeRect, coreNode ? "<color=#00FF00>" + node._name + "</color>" : node._name, style); DrawRunModeLable(node, nodeRect); return(nodeRect); }
protected virtual void DrawOrder(NodeModifier node, Color color) { NodeModifier[] nextNodes = node.NextNodes; for (int j = 0; j < nextNodes.Length; j++) { NodeModifier node2 = nextNodes[j]; Vector2 pos2 = CalcRealPosition(new Vector2(node2._position.x, node2._position.y)); pos2 *= Tools.Zoom; float w = 50f * Tools.Zoom; pos2.x = pos2.x - w; pos2.y += Tools.NodeHalfHeightZoomed; GUI.Label(new Rect(pos2, new Vector2(w, w)), "(" + (j + 1) + ")", ResourcesManager.GetInstance.GetFontStyle(13, color)); } }
private void DrawParentNodes(NodeModifier node, bool coreNode = false) { if (node == null) { return; } DrawNodeRect(node, coreNode); //Draw conection bazier line DrawDebugBazierLine(node); DrawChildNodes(node.NextNodes); DrawParentNodes(node.Parent); }
protected void DrawDebugBazierLine(NodeModifier node) { NodeModifier[] nextNodes = node.NextNodes; for (int j = 0; j < nextNodes.Length; j++) { NodeModifier node2 = nextNodes[j]; Rect nodeRect1 = Tools.GetNodeRect(CalcRealPosition(node._position)); Vector2 pos1 = new Vector2(nodeRect1.max.x, nodeRect1.max.y - Tools.NodeHalfHeightZoomed); Vector2 pos2 = CalcRealPosition(new Vector2(node2._position.x, node2._position.y)); pos2 *= Tools.Zoom; pos2.y += Tools.NodeHalfHeightZoomed; Tools.DrawBazier(pos1, pos2, Color.magenta, new Color32(0, 255, 255, 180), 0.1f, 10f); } }
protected override Rect DrawNodeRect(NodeModifier node, bool coreNode = false) { Vector2 pos = CalcRealPosition(node._position); Rect nodeRect = Tools.GetNodeRect(pos); GUIStyle style = ResourcesManager.GetInstance.Node; GUIStyle selectStyle = ResourcesManager.GetInstance.NodeOn; if (node is CryStory.Runtime.Event) { style = ResourcesManager.GetInstance.EventNode; selectStyle = ResourcesManager.GetInstance.EventNodeOn; } else if (node is CryStory.Runtime.Condition) { style = ResourcesManager.GetInstance.ConditionNode; selectStyle = ResourcesManager.GetInstance.ConditionNodeOn; } else if (node is CryStory.Runtime.Action) { style = ResourcesManager.GetInstance.ActionNode; selectStyle = ResourcesManager.GetInstance.ActionNodeOn; } style = new GUIStyle(style); selectStyle = new GUIStyle(selectStyle); style.fontSize = (int)(style.fontSize * Tools.Zoom); selectStyle.fontSize = (int)(selectStyle.fontSize * Tools.Zoom); GUI.Box(nodeRect, coreNode ? "<color=#00FF00>" + node._name + "</color>" : node._name, _currentNode == node ? selectStyle : style); DragNodeEvent(node, nodeRect); DrawRunModeLable(node, nodeRect); if (coreNode) { DrawRunningNodeLabel(nodeRect); } else { DrawDescription(nodeRect, (node as StoryNode).ToDescription()); } return(nodeRect); }
protected void DuplicateNode(NodeModifier targetNode) { NodeModifier node = ReflectionHelper.CreateInstance <NodeModifier>(targetNode.GetType().FullName); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(targetNode), node); node._position = new Vector2(node._position.x + 10, node._position.y + 10); if (targetNode.Parent != null) { NodeModifier.SetParent(node, targetNode.Parent); } else if (targetNode.Content != null) { NodeModifier.SetContent(node, targetNode.Content); } DragModifier d = node.GetContent() as DragModifier; node.SetID(d.GenerateID()); }
protected virtual void DrawNodeSlot(NodeModifier node, Rect nodeRect) { #region Event drag connection line if (Event.current != null) { if (Tools.IsValidMouseAABB(nodeRect)) { _currentHover = node; Rect leftRect = Tools.CalcLeftLinkRect(nodeRect); Rect rightRect = Tools.CalcRightLinkRect(nodeRect); GUIStyle inStyle = new GUIStyle(); GUIStyle outStyle = new GUIStyle(); inStyle.alignment = TextAnchor.MiddleLeft; outStyle.alignment = TextAnchor.MiddleRight; GUI.Box(leftRect, node.Parent == null ? ResourcesManager.GetInstance.texInputSlot : ResourcesManager.GetInstance.texInputSlotActive, inStyle); GUI.Box(rightRect, node.NextNodes.Length < 1 ? ResourcesManager.GetInstance.texOutputSlot : ResourcesManager.GetInstance.texOutputSlotActive, outStyle); //Connect if (Event.current.type == EventType.MouseDown && Tools.IsValidMouseAABB(rightRect)) { _isConnecting = true; _currentNode = node; _currentNodeRect = nodeRect; } //ReConnect if (Event.current.type == EventType.MouseDown && Tools.IsValidMouseAABB(leftRect)) { if (node.HaveParent) { _isConnecting = true; _currentNode = node.Parent as NodeModifier; Vector2 realPos = CalcRealPosition(_currentNode._position); _currentNodeRect = Tools.GetNodeRect(realPos); NodeModifier.SetToDefaltContent(node); //node.DeleteParent(); } } } } #endregion }
private void ShowConnectLine() { if (_isConnecting && _currentNode != null) { Vector2 pos1 = new Vector2(_currentNodeRect.max.x, _currentNodeRect.max.y - Tools.NodeHalfHeightZoomed); Tools.DrawBazier(pos1, Event.current.mousePosition); if (Tools.MouseUp) { _isConnecting = false; if (_currentNode == _currentHover) { return; } if (Tools.IsValidMouseAABB(Tools.GetNodeRect(CalcRealPosition(_currentHover._position)))) { //强制链接单节点 if (Event.current.control) { _currentNode.AddNextNode(_currentHover); return; } if (!_currentHover.CanSetParent(_currentNode)) { //if (_currentNode.IsParent(_currentHover)) if (!_currentNode.HaveParentNodeInNext()) { _currentNode.AddNextNode(_currentHover); return; } EditorUtility.DisplayDialog("Error", "Not allow connect to twice parent! You must break one connect with parent and then change it.", "OK"); return; } if (NodeModifier.SetParent(_currentHover, _currentNode)) { OnLinkNode(_currentNode, _currentHover); } } } } }
protected virtual void DrawBazierLine(NodeModifier node, Color color) { NodeModifier[] nextNodes = node.NextNodes; for (int j = 0; j < nextNodes.Length; j++) { NodeModifier node2 = nextNodes[j]; Rect nodeRect1 = Tools.GetNodeRect(CalcRealPosition(node._position)); Vector2 pos1 = new Vector2(nodeRect1.max.x, nodeRect1.max.y - Tools.NodeHalfHeightZoomed); Vector2 pos2 = CalcRealPosition(new Vector2(node2._position.x, node2._position.y)); pos2 *= Tools.Zoom; pos2.y += Tools.NodeHalfHeightZoomed; bool singleNode = node2.Parent != node; if (singleNode) { Tools.DrawBazier(pos1, pos2, color); } else { Tools.DrawBazier(pos1, pos2); } } }
private void ShowDeleteNodeMenu() { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Duplicate"), false, () => { DuplicateNode(_currentHover); }); menu.AddItem(new GUIContent("Delete"), false, () => { NodeModifier.Delete(_currentHover); MissionData data = _window._storyObject.GetMissionSaveDataByName(_currentHover._name); data.MissionObject._mission = null; if (_currentNode == _currentHover) { _currentNode = null; } _currentHover = null; }); menu.ShowAsContext(); }
public TreeModifier(ParseTreeDrawable parseTree, NodeModifier nodeModifier) { this._parseTree = parseTree; this._nodeModifier = nodeModifier; }
protected virtual void DrawBazierLine(NodeModifier node) { DrawBazierLine(node, Color.green); }
public void Reset() { _currentNode = null; }
protected virtual void OnLinkNode(NodeModifier parent, NodeModifier child) { }
private void ShowLeftSliderArea() { Rect background = new Rect(0, _window._topHeight, _window._leftWidth, _window._windowRect.height); GUI.Box(background, "", ResourcesManager.GetInstance.StyleBackground); _leftScrollPosition = GUI.BeginScrollView(new Rect(0, _window._topHeight, _window._leftWidth, _window._windowRect.height - _window._topHeight), _leftScrollPosition, new Rect(0, _window._topHeight, _window._leftWidth - 30, /*_window._windowRect.height - */ _window._topHeight + _heightLeft), false, true, ResourcesManager.GetInstance.skin.horizontalScrollbar, ResourcesManager.GetInstance.skin.verticalScrollbar); _heightLeft = _window._topHeight + 5; if (_currentNode != null) { #region Modify Name EditorGUI.LabelField(GetGUILeftScrollAreaRect(50, 18, false), "Name: "); Rect editNameRect = GetGUILeftScrollAreaRect(50, 150, 18);// new Rect(50, _heightLeft, 150, 18); string oldName = _currentNode._name; EditorGUI.BeginChangeCheck(); _currentNode._name = EditorGUI.TextField(editNameRect, _currentNode._name); if (EditorGUI.EndChangeCheck()) { OnNodeNameChange(_currentNode, oldName); } if (Event.current != null) { if (Event.current.button == 0) { //Debug.Log(Event.current.type); if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.Ignore) { //Debug.Log(Event.current.type); GUI.FocusControl("Name: "); } } } #endregion #region Next Nodes NodeModifier[] nodes = _currentNode.NextNodes; if (nodes.Length > 0) { LeftHeightSpace(5); GUIStyle style = new GUIStyle(); style.normal.textColor = Color.white; style.fontSize = 14; EditorGUI.LabelField(GetGUILeftScrollAreaRect(_window._leftWidth, 30), "Next Nodes:", style); for (int i = 0; i < nodes.Length; i++) { Rect rect = GetGUILeftScrollAreaRect(_window._leftWidth, 20, false); EditorGUI.LabelField(rect, nodes[i]._name); if (GUI.Button(GetGUILeftScrollAreaRect(_window._leftWidth - 68f, 50f, 20f), "<color=red>Delete</color>", ResourcesManager.GetInstance.skin.button)) { if (nodes[i].Parent == _currentNode) { NodeModifier.SetToDefaltContent(nodes[i]); } else { _currentNode.Remove(nodes[i]); } break; } } } #endregion LeftHeightSpace(10); DrawLeftArribute(_currentNode); } GUI.EndScrollView(); }
protected virtual void OnNodeNameChange(NodeModifier node, string oldName) { }
protected override Rect DrawNodeRect(NodeModifier node, bool coreNode = false) { Vector2 pos = CalcRealPosition(node._position); Rect nodeRect = Tools.GetNodeRect(pos); GUIStyle style = ResourcesManager.GetInstance.DefaultNode; GUIStyle selectStyle = ResourcesManager.GetInstance.DefaultNodeOn; if (node is CryDialog.Runtime.Event) { style = ResourcesManager.GetInstance.EventNode; selectStyle = ResourcesManager.GetInstance.EventNodeOn; } else if (node is CryDialog.Runtime.Condition) { style = ResourcesManager.GetInstance.ConditionNode; selectStyle = ResourcesManager.GetInstance.ConditionNodeOn; } else if (node is CryDialog.Runtime.Action) { style = ResourcesManager.GetInstance.ActionNode; selectStyle = ResourcesManager.GetInstance.ActionNodeOn; } style = new GUIStyle(style); selectStyle = new GUIStyle(selectStyle); style.fontSize = 20; selectStyle.fontSize = 20; style.fontSize = (int)(style.fontSize * Tools.Zoom); selectStyle.fontSize = (int)(selectStyle.fontSize * Tools.Zoom); style = _currentNode == node ? selectStyle : style; GUIContent des = GetDescription(node); //计算额外描述高度 //GUIStyle desStyle = ResourcesManager.GetInstance.GetOverflowFontStyle(12); //float height = desStyle.CalcHeight(des, nodeRect.width); //Rect expandRect = new Rect(nodeRect); //expandRect.height = nodeRect.height + height + 10; Rect expandRect = Tools.GetNodeRect(pos, des.text); GUI.Box(expandRect, coreNode ? "<color=#00FF00>" + node._name + "</color>" : node._name, style); DragNodeEvent(node, expandRect); //处理分割线 float seperateHeight = 40 * Tools.Zoom; Color handleColor = Handles.color; if (_currentNode != node && !Tools.IsValidMouseAABB(expandRect)) { Handles.color = Color.black; } Handles.DrawLine(new Vector3(expandRect.position.x, expandRect.position.y + seperateHeight - 2, 0), new Vector3(expandRect.xMax, expandRect.yMin + seperateHeight - 2)); Handles.DrawLine(new Vector3(expandRect.position.x, expandRect.position.y + seperateHeight, 0), new Vector3(expandRect.xMax, expandRect.yMin + seperateHeight)); Handles.color = handleColor; DrawRunModeLable(node, nodeRect); if (coreNode) { DrawRunningNodeLabel(expandRect); } nodeRect.width = nodeRect.width - 10; nodeRect.position = new Vector2(nodeRect.position.x + 5, nodeRect.position.y); DrawDescription(nodeRect, des.text); return(expandRect); }