Skip to content

Commit 8266e7e

Browse files
committed
refactoring of graph editor
1 parent 8eadd3f commit 8266e7e

File tree

4 files changed

+24
-35
lines changed

4 files changed

+24
-35
lines changed

Code/Editor/Window/GraphEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class GraphEditorWindow : EditorWindow
3131
public int OnGuiCounter => _onGuiCounter;
3232
public GraphCamera Camera => _camera;
3333
public bool GridSnapping => _toolbar.GridToggle;
34-
public TransitionViewType TransitionView => _toolbar.TransitionView;
34+
public bool ShowPorts => _toolbar.ShowPorts;
3535
public GraphEditorSettings Settings => _settings;
3636
public GraphMap Map => _map;
3737
public bool FullDrawing => !_toolbar.HideContentToggle;

Code/Editor/Window/NodeBased/GraphMap.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5-
using System.Runtime.CompilerServices;
65
using OlegHcp;
76
using OlegHcp.CSharp;
87
using OlegHcp.CSharp.Collections;
@@ -272,20 +271,15 @@ private void DrawConnectionLine(Event e)
272271
if (_selectedPort == null)
273272
return;
274273

275-
switch (_window.TransitionView)
274+
if (_window.ShowPorts)
276275
{
277-
case TransitionViewType.Splines:
278-
Vector2 startTangentDir = _selectedPort.Type == PortType.In ? Vector2.left : Vector2.right;
279-
Vector2 endTangentDir = _selectedPort.Type == PortType.In ? Vector2.right : Vector2.left;
280-
TransitionViewer.DrawSpline(_selectedPort.ScreenRect.center, e.mousePosition, startTangentDir, endTangentDir);
281-
break;
282-
283-
case TransitionViewType.Arrows:
284-
TransitionViewer.DrawDirection(_selectedPort.Node.ScreenRect.center, e.mousePosition);
285-
break;
286-
287-
default:
288-
throw new SwitchExpressionException(_window.TransitionView);
276+
Vector2 startTangentDir = _selectedPort.Type == PortType.In ? Vector2.left : Vector2.right;
277+
Vector2 endTangentDir = _selectedPort.Type == PortType.In ? Vector2.right : Vector2.left;
278+
TransitionViewer.DrawSpline(_selectedPort.ScreenRect.center, e.mousePosition, startTangentDir, endTangentDir);
279+
}
280+
else
281+
{
282+
TransitionViewer.DrawDirection(_selectedPort.Node.ScreenRect.center, e.mousePosition);
289283
}
290284

291285
GUI.changed = true;

Code/Editor/Window/NodeBased/GraphToolbar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal class GraphToolbar
4040
public bool HideContentToggle => _hideContentToggle;
4141
public bool SidePanelToggle => _sidePanelToggle;
4242
public bool GridToggle => _gridSnapToggle;
43-
public TransitionViewType TransitionView => (TransitionViewType)_transitionViewType;
43+
public bool ShowPorts => _transitionViewType == (int)TransitionViewType.Splines;
4444

4545
public GraphToolbar(GraphEditorWindow window)
4646
{

Code/Editor/Window/NodeBased/NodeDrawing/NodeViewer.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void Draw()
216216

217217
void drawPorts()
218218
{
219-
if (_window.TransitionView == TransitionViewType.Splines)
219+
if (_window.ShowPorts)
220220
{
221221
if (_type != NodeType.Common) _in.Draw();
222222
if (_type != NodeType.Exit) _out.Draw();
@@ -226,24 +226,19 @@ void drawPorts()
226226

227227
public void DrawTransitions()
228228
{
229-
switch (_window.TransitionView)
229+
if (_window.ShowPorts)
230230
{
231-
case TransitionViewType.Splines:
232-
for (int i = 0; i < _transitionViewers.Count; i++)
233-
{
234-
_transitionViewers[i].DrawSpline();
235-
}
236-
break;
237-
238-
case TransitionViewType.Arrows:
239-
for (int i = 0; i < _transitionViewers.Count; i++)
240-
{
241-
_transitionViewers[i].DrawArrow();
242-
}
243-
break;
244-
245-
default:
246-
throw new SwitchExpressionException(_window.TransitionView);
231+
for (int i = 0; i < _transitionViewers.Count; i++)
232+
{
233+
_transitionViewers[i].DrawSpline();
234+
}
235+
}
236+
else
237+
{
238+
for (int i = 0; i < _transitionViewers.Count; i++)
239+
{
240+
_transitionViewers[i].DrawArrow();
241+
}
247242
}
248243
}
249244

@@ -360,7 +355,7 @@ private void ProcessContextMenu()
360355
Vector2 clickPosition = Event.current.mousePosition;
361356
GenericMenu genericMenu = new GenericMenu();
362357

363-
bool arrows = _window.TransitionView == TransitionViewType.Arrows;
358+
bool arrows = !_window.ShowPorts;
364359
string addTransition = "Add Transition";
365360
string delete = "Delete";
366361
string info = "Info";

0 commit comments

Comments
 (0)