Skip to content

Commit 749cd3b

Browse files
committed
Feat: Flow Editor Routing Nodes.
1 parent 7415a6d commit 749cd3b

4 files changed

Lines changed: 550 additions & 203 deletions

File tree

src/main/java/redxax/oxy/remotely/flow/registry/NodeDefinition.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static final class NodeCategory {
2727
public static final NodeCategory EVENT = new NodeCategory("event", "Event", 0xFFFF5555, 100);
2828
public static final NodeCategory ACTION = new NodeCategory("action", "Action", 0xFF5555FF, 200);
2929
public static final NodeCategory LOGIC = new NodeCategory("logic", "Logic", 0xFFFF55FF, 300);
30+
public static final NodeCategory NETWORK = new NodeCategory("network", "Network", 0xFF4F8CFF, 350);
3031
public static final NodeCategory DATA = new NodeCategory("data", "Data", 0xFF55FFFF, 400);
3132
public static final NodeCategory VARIABLE = new NodeCategory("variable", "Variable", 0xFFFFFF55, 500);
3233
public static final NodeCategory FUNCTION = new NodeCategory("function", "Function", 0xFFFFAA55, 600);
@@ -358,20 +359,31 @@ public static class PinDefinition {
358359
private final PinConstraints constraints;
359360
private final Map<String, String> visibleWhen;
360361
private final String description;
362+
private final boolean optional;
361363

362364
public PinDefinition(String name, PinType type, PinDirection direction, FlowDataType dataType) {
363-
this(name, type, direction, dataType, null, null, null, null, null, null, null);
365+
this(name, type, direction, dataType, null, null, null, null, null, null, null, false);
366+
}
367+
368+
public PinDefinition(String name, PinType type, PinDirection direction, FlowDataType dataType, boolean optional) {
369+
this(name, type, direction, dataType, null, null, null, null, null, null, null, optional);
364370
}
365371

366372
public PinDefinition(String name, PinType type, PinDirection direction, FlowDataType dataType,
367373
WidgetType widgetType, List<String> options, String defaultValue,
368374
PinConstraints constraints, Map<String, String> visibleWhen, String description) {
369-
this(name, type, direction, dataType, widgetType, options, null, defaultValue, constraints, visibleWhen, description);
375+
this(name, type, direction, dataType, widgetType, options, null, defaultValue, constraints, visibleWhen, description, false);
370376
}
371377

372378
public PinDefinition(String name, PinType type, PinDirection direction, FlowDataType dataType,
373379
WidgetType widgetType, List<String> options, String optionsSource, String defaultValue,
374380
PinConstraints constraints, Map<String, String> visibleWhen, String description) {
381+
this(name, type, direction, dataType, widgetType, options, optionsSource, defaultValue, constraints, visibleWhen, description, false);
382+
}
383+
384+
public PinDefinition(String name, PinType type, PinDirection direction, FlowDataType dataType,
385+
WidgetType widgetType, List<String> options, String optionsSource, String defaultValue,
386+
PinConstraints constraints, Map<String, String> visibleWhen, String description, boolean optional) {
375387
this.name = name;
376388
this.type = type;
377389
this.direction = direction;
@@ -383,6 +395,7 @@ public PinDefinition(String name, PinType type, PinDirection direction, FlowData
383395
this.constraints = constraints;
384396
this.visibleWhen = visibleWhen != null ? visibleWhen : Collections.emptyMap();
385397
this.description = description;
398+
this.optional = optional;
386399
}
387400

388401
public String getName() {
@@ -428,6 +441,10 @@ public Map<String, String> getVisibleWhen() {
428441
public String getDescription() {
429442
return description;
430443
}
444+
445+
public boolean isOptional() {
446+
return optional;
447+
}
431448
}
432449

433450
public static class Builder {
@@ -641,6 +658,7 @@ public static class PinBuilder {
641658
private PinConstraints constraints;
642659
private Map<String, String> visibleWhen;
643660
private String description;
661+
private boolean optional;
644662

645663
public PinBuilder(String name, PinType type, PinDirection direction, FlowDataType dataType) {
646664
this.name = name;
@@ -695,8 +713,13 @@ public PinBuilder description(String description) {
695713
return this;
696714
}
697715

716+
public PinBuilder optional(boolean optional) {
717+
this.optional = optional;
718+
return this;
719+
}
720+
698721
public PinDefinition build() {
699-
return new PinDefinition(name, type, direction, dataType, widgetType, options, optionsSource, defaultValue, constraints, visibleWhen, description);
722+
return new PinDefinition(name, type, direction, dataType, widgetType, options, optionsSource, defaultValue, constraints, visibleWhen, description, optional);
700723
}
701724
}
702725
}

src/main/java/redxax/oxy/remotely/flow/ui/ContentDesignerScreen.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ private boolean isDesignerPanelMouseOver(double mouseX, double mouseY) {
337337

338338
@Override
339339
public boolean mouseReleased(ReMouseEvent event) {
340+
if (isConnectionDragging()) {
341+
return super.mouseReleased(event);
342+
}
340343
if (activeSearchSelector != null && activeSearchSelector.visible && activeSearchSelector.mouseReleased(event.retarget(activeSearchSelector, event.x(), event.y()))) {
341344
return true;
342345
}
@@ -357,6 +360,9 @@ public boolean mouseReleased(ReMouseEvent event) {
357360

358361
@Override
359362
public boolean mouseDragged(ReMouseEvent event) {
363+
if (isConnectionDragging()) {
364+
return super.mouseDragged(event);
365+
}
360366
if (activeSearchSelector != null && activeSearchSelector.visible && activeSearchSelector.mouseDragged(event.retarget(activeSearchSelector, event.x(), event.y(), event.deltaX(), event.deltaY()))) {
361367
return true;
362368
}
@@ -377,6 +383,9 @@ public boolean mouseDragged(ReMouseEvent event) {
377383

378384
@Override
379385
public boolean mouseScrolled(ReScrollEvent event) {
386+
if (isConnectionDragging()) {
387+
return super.mouseScrolled(event);
388+
}
380389
if (activeSearchSelector != null && activeSearchSelector.visible && activeSearchSelector.mouseScrolled(event.retarget(activeSearchSelector, event.x(), event.y()))) {
381390
return true;
382391
}

0 commit comments

Comments
 (0)