public String getTooltip(BehaviorNodeComponent value) {
return value.description;
}
});
WidgetUtil.trySubscribe(this, "copy", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String data = behaviorEditor.save();
StringSelection contents = new StringSelection(data);
systemClipboard.setContents(contents, contents);
}
});
WidgetUtil.trySubscribe(this, "layout", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
BehaviorTree selection = selectTree.getSelection();
if (selection != null) {
selection.layout(selectedNode);
}
}
});
WidgetUtil.trySubscribe(this, "new", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (selectedNode != null) {
nuiManager.pushScreen("engine:enterTextPopup", EnterTextPopup.class).bindInput(new Binding<String>() {
@Override
public String get() {
return null;
}
@Override
public void set(String value) {
behaviorSystem.createTree(value, selectedNode.getNode());
}
});
}
}
});
WidgetUtil.trySubscribe(this, "assign", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (selectedTree != null && selectedInterpreter != null) {
EntityRef minion = selectedInterpreter.actor().minion();
minion.removeComponent(BehaviorComponent.class);
BehaviorComponent component = new BehaviorComponent();
component.tree = selectedTree;
minion.addComponent(component);
List<Interpreter> interpreter = behaviorSystem.getInterpreter();
selectEntity.setSelection(null);
for (Interpreter i : interpreter) {
if (i.actor().minion() == minion) {
selectEntity.setSelection(i);
break;
}
}
}
}
});
WidgetUtil.trySubscribe(this, "remove", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (selectedNode != null && selectedTree != null) {
RenderableNode targetNode = selectedNode.getInputPort().getTargetNode();
if (targetNode != null) {
for (int i = 0; i < targetNode.getChildrenCount(); i++) {
if (targetNode.getChild(i) == selectedNode) {
targetNode.withModel().removeChild(i);
break;
}
}
}
removeWidget(selectedNode);
behaviorEditor.nodeClicked(null);
behaviorSystem.treeModified(selectedTree);
}
}
});
WidgetUtil.trySubscribe(this, "debug_run", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (debugger != null) {
debugger.run();
}
}
});
WidgetUtil.trySubscribe(this, "debug_pause", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (debugger != null) {
debugger.pause();
}
}
});
WidgetUtil.trySubscribe(this, "debug_reset", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (selectedInterpreter != null) {
selectedInterpreter.reset();
}
}
});
WidgetUtil.trySubscribe(this, "debug_step", new ActivateEventListener() {
@Override
public void onActivated(UIWidget button) {
if (debugger != null) {
debugger.step();
}