void mnuCreateTransition_Click(object sender, System.EventArgs e) { AudioStateNode node = (AudioStateNode)Owner; AudioStateGraphEditor editor = Owner.FindInParents <AudioStateGraphEditor>(); editor.BeginConnection(node); }
void mnuDelete_Click(object sender, System.EventArgs e) { AudioStateNode node = (AudioStateNode)Owner; AudioStateGraphEditor editor = Owner.FindInParents <AudioStateGraphEditor>(); editor.RemoveNode(node); }
protected override void BeginShow() { base.BeginShow(); AudioStateNode node = (AudioStateNode)Owner; _MnuSetAsDefault.IsEnabled = !node.IsDefault; }
void mnuSetAsDefault_Click(object sender, System.EventArgs e) { AudioStateNode node = (AudioStateNode)Owner; AudioStateGraphEditor editor = Owner.FindInParents <AudioStateGraphEditor>(); editor.MakeAsDefaultState(node); }
internal void ItemDrag(AudioStateNode node, Vector2 delta) { if (Selection.Contains(node)) { if (!_DragStarted) { foreach (var item in Selection) { if (item is AudioStateNode) { ((AudioStateNode)item).StartDrag.x = ((AudioStateNode)item).X; ((AudioStateNode)item).StartDrag.y = ((AudioStateNode)item).Y; } } _DeltaDrag = Vector3.zero; _DragStarted = true; } _DeltaDrag += delta; delta = _DeltaDrag; foreach (var item in Selection) { if (item is AudioStateNode) { ((AudioStateNode)item).X = ((AudioStateNode)item).StartDrag.x + delta.x; ((AudioStateNode)item).Y = ((AudioStateNode)item).StartDrag.y + delta.y; } } } }
private AudioStateNode CreateNode(AudioState state) { AudioStateNode node = new AudioStateNode(state); node.X = state.X; node.Y = state.Y; _Panel.Controls.Add(node); return(node); }
public void MakeAsDefaultState(AudioStateNode node) { foreach (var c in _Panel.Controls) { if (c is AudioStateNode) { ((AudioStateNode)c).IsDefault = false; } } node.IsDefault = true; }
protected override void Render() { base.Render(); foreach (var c in _Editor._Panel.Controls) { if (c is AudioStateNode) { AudioStateNode node = (AudioStateNode)c; if (node.NextState != null) { DirectConnection.DrawConnection(node.NextPoint, node.NextState.PrePoint, _NextConnectionColor, 16 * _Editor._Panel.ZoomFactor, _NextConnectionColor, Skill.Editor.Resources.UITextures.ArrowHead, 0); } } } }
private void New(Vector2 position) { position -= _Panel.PanPosition; position /= _Panel.ZoomFactor; position.x -= this.RenderArea.x; position.y -= this.RenderArea.y; AudioState state = new AudioState(); state.Name = "new state"; state.X = position.x; state.Y = position.y; AudioStateNode node = CreateNode(state); if (_Panel.Controls.Count == 1) { node.IsDefault = true; } }
public void RemoveNode(AudioStateNode node) { _Panel.Controls.Remove(node); List <AudioConnection> connectionList = new List <AudioConnection>(); foreach (var c in _ConnectionHost.Controls) { if (c is AudioConnection) { AudioConnection ac = (AudioConnection)c; if (ac.Start == node || ac.End == node) { connectionList.Add(ac); } } } foreach (var item in connectionList) { _ConnectionHost.Controls.Remove(item); } connectionList.Clear(); node.NextState = null; foreach (var c in _Panel.Controls) { if (c is AudioStateNode) { AudioStateNode asn = (AudioStateNode)c; if (asn.NextState == node) { asn.NextState = null; } } } }
public AudioStateNodeDragThumb(AudioStateNode node) { this._Node = node; }
public ItemProperties(AudioStateNode node) : base(node) { _Node = node; }
public void BeginConnection(AudioStateNode node) { _ConnectionHost.BeginConnectionDetect(node); }
public void Save() { AudioStateNode defaultState = null; List <AudioStateNode> stateList = new List <AudioStateNode>(); foreach (var item in this._Panel.Controls) { if (item is AudioStateNode) { ((AudioStateNode)item).Transitions.Clear(); stateList.Add((AudioStateNode)item); if (defaultState == null) { if (((AudioStateNode)item).IsDefault) { defaultState = (AudioStateNode)item; } } else { ((AudioStateNode)item).IsDefault = false; } } } if (defaultState == null && stateList.Count > 0) { defaultState = stateList[0]; } foreach (var state in stateList) { state.StateName = GetUniqueStateName(state.StateName, stateList); } foreach (var item in this._ConnectionHost.Controls) { if (item is AudioConnection) { AudioConnection ac = (AudioConnection)item; if (ac.Start != null && ac.End != null) { ac.Transition.Destination = ((AudioStateNode)ac.End).State.Name; ((AudioStateNode)ac.Start).Transitions.Add(ac.Transition); } } } foreach (var state in stateList) { state.Save(); } _Editor.Controller.States = new AudioState[stateList.Count]; for (int i = 0; i < _Editor.Controller.States.Length; i++) { _Editor.Controller.States[i] = stateList[i].State; } if (defaultState != null) { _Editor.Controller.DefaultState = (defaultState != null) ? defaultState.StateName : string.Empty; } _Editor.Controller.Zoom = this._Panel.ZoomFactor; _Editor.Controller.PanX = this._Panel.PanPosition.x; _Editor.Controller.PanY = this._Panel.PanPosition.y; }
public void Rebuild() { Clear(); if (_Editor.Controller != null) { List <AudioStateNode> stateList = new List <AudioStateNode>(); if (_Editor.Controller.States != null) { foreach (var state in _Editor.Controller.States) { stateList.Add(CreateNode(state)); } foreach (var s in _Editor.Controller.States) { AudioStateNode start = FindState(s.Name); if (start != null && s.Transitions != null) { start.Transitions.Clear(); foreach (var t in s.Transitions) { AudioStateNode end = FindState(t.Destination); if (end != null) { start.Transitions.Add(t); AudioConnection ac = new AudioConnection(start, end, t); _ConnectionHost.Controls.Add(ac); } } } } foreach (var state in stateList) { state.NextState = FindState(state.State.NextState); } if (_Editor.Controller.DefaultState != null) { AudioStateNode defaultState = FindState(_Editor.Controller.DefaultState); if (defaultState != null) { defaultState.IsDefault = true; } else { if (_Panel.Controls.Count > 0) { ((AudioStateNode)_Panel.Controls[0]).IsDefault = true; _Editor.Controller.DefaultState = ((AudioStateNode)_Panel.Controls[0]).StateName; } else { _Editor.Controller.DefaultState = string.Empty; } } } } _Panel.ZoomFactor = _Editor.Controller.Zoom; _Panel.PanPosition = new Vector2(_Editor.Controller.PanX, _Editor.Controller.PanY); } }