Skip to content

Commit

Permalink
WIP #12: DAMCON orders UI portion done; systems no longer selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmaxfrank committed Jan 30, 2016
1 parent d30e90c commit e086ff4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
11 changes: 11 additions & 0 deletions src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.dhleong.acl.util.GridCoord;
import net.dhleong.acl.vesseldata.VesselNode;
import net.dhleong.acl.vesseldata.VesselNodeConnection;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class Damcon implements MouseListener, MouseMotionListener, MouseWheelListener {
private static final int WIDTH = 400, HEIGHT = 300;
Expand Down Expand Up @@ -71,6 +72,8 @@ public class Damcon implements MouseListener, MouseMotionListener, MouseWheelLis
private Map<Node, InternalSelectable> nodesToSelectables = new HashMap<>(); // TODO: use setUserData() on nodes rather than table lookup?
private static final float PICK_TOLERANCE = 0.1f;

private InternalTeam selected = null;

public Damcon(EngineeringConsoleManager engineeringConsoleManager) {
this.engineeringConsoleManager = engineeringConsoleManager;

Expand Down Expand Up @@ -300,6 +303,14 @@ public void mouseClicked(MouseEvent e) {
i.setSelected(internal != null && i.equals(internal));
}
}

if (internal.getClass().equals(InternalTeam.class)) {
selected = (InternalTeam)internal;
} else { // if (internal.getClass().equals(InternalNode.class))
if (selected != null) {
selected.setOrders((InternalNode)internal);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ protected boolean visible() {
return isSystemNode();
}

@Override
protected boolean selected() {
return false;
}

private boolean isSystemNode() {
return this.vesselNode.getSystem() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class InternalSelectable extends Internal {
protected static final Color3f BLACK = new Color3f(0f, 0f, 0f), WHITE = new Color3f(1f, 1f, 1f);
private static final float TRANSPARENT = 1f, OPAQUE = 0f;

protected boolean selected = false, hovered = false;
protected boolean hovered = false;
protected float healthPct = 1f;

protected Sphere sphere;
Expand All @@ -28,10 +28,11 @@ protected Appearance appearanceFromHealthPercentage() {
TransparencyAttributes transparency;
if (!this.visible()) {
transparency = new TransparencyAttributes(TransparencyAttributes.NICEST, TRANSPARENT);
} else if (this.selected) {
// TODO: show some sort of indicator when hovering over non-system node (billboards would help with this)
} else if (this.selected()) {
transparency = new TransparencyAttributes(TransparencyAttributes.NICEST, OPAQUE);
app.setMaterial(new Material(BLACK, getColorFromHealth(this.healthPct), WHITE, BLACK, SHININESS));
} else if (this.hovered) {
} else if (this.hovered()) {
transparency = new TransparencyAttributes(TransparencyAttributes.NICEST, OPAQUE);
} else { // if (this.visible())
transparency = new TransparencyAttributes(TransparencyAttributes.NICEST, alpha);
Expand All @@ -43,10 +44,18 @@ protected Appearance appearanceFromHealthPercentage() {
return app;
}

public void setSelected(boolean selected) { }

protected boolean visible() {
return true;
}

protected abstract boolean selected();

protected boolean hovered() {
return this.hovered;
}

protected void setPickable(Shape3D shape) {
shape.setCapability(Shape3D.ENABLE_PICK_REPORTING);
shape.setPickable(true);
Expand All @@ -64,18 +73,6 @@ protected Color3f getColorFromHealth(float pct) {
return new Color3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f);
}

public void setSelected(boolean selected) {
if (selected) {
System.out.println("Selecting " + this);
}

this.selected = selected;
this.sphere.setAppearance(appearanceFromHealthPercentage());

// TODO: >>> selection is only relevant for damcon teams, not nodes, right?
// Need to track who's selected and issue orders on click of system node when selection != null
}

public void setHovered(boolean hovered) {
this.hovered = hovered;
this.sphere.setAppearance(appearanceFromHealthPercentage());
Expand Down
22 changes: 22 additions & 0 deletions src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class InternalTeam extends InternalSelectable {
private TransformGroup transformGroup;
private EnhancedDamconStatus status;
protected boolean selected = false;

// TODO: use a Box instead of a sphere or something (set every side to be pickable or use billboards)

Expand Down Expand Up @@ -50,6 +51,27 @@ public void updateHealth(float pct) {
sphere.setAppearance(appearanceFromHealthPercentage());
}

@Override
public void setSelected(boolean selected) {
if (selected) {
System.out.println("Selecting " + this);
}

this.selected = selected;
this.sphere.setAppearance(appearanceFromHealthPercentage());

// TODO: >>> Track who's selected and issue orders on click of system node when selection != null
}

@Override
protected boolean selected() {
return this.selected;
}

public void setOrders(InternalNode target) {
System.out.println("Ordering " + this + " to " + target);
}

@Override
public String toString() {
return this.status.toString();
Expand Down

0 comments on commit e086ff4

Please sign in to comment.