added highlight/hover/select to nodes

This commit is contained in:
Cedric Beck
2024-12-11 14:23:24 +01:00
parent 574f8bb681
commit b8df688ba3
9 changed files with 252 additions and 343 deletions

View File

@@ -14,6 +14,7 @@
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.board.NodeControl;
import pp.mdga.client.board.OutlineControl;
import pp.mdga.client.board.OutlineOEControl;
import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl;
import pp.mdga.client.gui.DiceControl;
@@ -32,7 +33,7 @@ public class InputSynchronizer {
private float rotationAngle = 180f;
private int scrollValue = 0;
private CardControl hoverCard;
private PieceControl hoverPiece;
private OutlineOEControl hoverPiece;
private boolean clickAllowed = true;
@@ -113,7 +114,7 @@ public void onAction(String name, boolean isPressed, float tpf) {
if (app.getView() instanceof GameView gameView) {
DiceControl diceSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), DiceControl.class);
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
OutlineOEControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineOEControl.class);
if (diceSelect != null) {
app.getModelSynchronize().rolledDice();
@@ -122,12 +123,7 @@ public void onAction(String name, boolean isPressed, float tpf) {
if (cardLayerSelect.isSelectable()) gameView.getGuiHandler().selectCard(cardLayerSelect);
} else if (boardSelect != null) {
//boardSelect
if (boardSelect instanceof PieceControl pieceControl) {
if (pieceControl.isSelectable()) gameView.getBoardHandler().pieceSelect(pieceControl);
}
if (boardSelect instanceof NodeControl nodeControl) {
//
}
gameView.getBoardHandler().pieceSelect(boardSelect);
} else {
//both null
}
@@ -235,13 +231,12 @@ private <T extends AbstractControl> T checkHoverOrtho(Camera cam, Node root, Cla
*/
private void hoverPiece() {
if (app.getView() instanceof GameView gameView) {
PieceControl control = checkPiece();
OutlineOEControl control = checkPiece();
if (control != null) {
if (control != hoverPiece) {
pieceOff(gameView);
hoverPiece = control;
// hoverPiece.hover();
gameView.getBoardHandler().pieceHoverOn(hoverPiece);
if(hoverPiece.isHoverable()) gameView.getBoardHandler().hoverOn(hoverPiece);
}
} else {
pieceOff(gameView);
@@ -260,7 +255,7 @@ private void hoverCard() {
if (control != hoverCard) {
cardOff();
hoverCard = control;
hoverCard.hover();
hoverCard.hoverOn();
}
} else {
cardOff();
@@ -273,8 +268,8 @@ private void hoverCard() {
*
* @return The PieceControl of the hovered piece, or null if no piece is hovered.
*/
private PieceControl checkPiece() {
return checkHover(app.getCamera(), app.getRootNode(), PieceControl.class);
private OutlineOEControl checkPiece() {
return checkHover(app.getCamera(), app.getRootNode(), OutlineOEControl.class);
}
/**
@@ -296,8 +291,7 @@ private CardControl checkCard(GameView gameView) {
*/
private void pieceOff(GameView gameView) {
if (hoverPiece != null) {
gameView.getBoardHandler().pieceHoverOff(hoverPiece);
// hoverPiece.hoverOff();
if(hoverPiece.isHoverable()) gameView.getBoardHandler().hoverOff(hoverPiece);
}
hoverPiece = null;
}

View File

@@ -15,6 +15,7 @@
import pp.mdga.client.animation.*;
import pp.mdga.client.gui.DiceControl;
import pp.mdga.game.Color;
import pp.mdga.game.Piece;
import java.util.*;
@@ -603,10 +604,8 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
} else {
nodeControl = infield.get(moveIndexe.get(i));
}
nodeControl.highlight();
pieceControl.highlight(false);
pieceControl.setHoverable(true);
pieceControl.setSelectable(true);
pieceControl.selectableOwn();
nodeControl.selectableOwn();
outlineNodes.add(nodeControl);
selectableOwnPieces.add(pieceControl);
selectedPieceNodeMap.put(pieceControl, nodeControl);
@@ -628,16 +627,12 @@ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces) {
for (UUID uuid : ownPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
p.setSelectable(true);
p.selectableOwn();
selectableOwnPieces.add(p);
}
for (UUID uuid : enemyPieces) {
PieceControl p = pieces.get(uuid);
p.highlight(true);
p.setHoverable(true);
p.setSelectable(true);
p.selectableOff();
selectableEnemyPieces.add(p);
}
}
@@ -655,9 +650,7 @@ public void outlineShield(List<UUID> pieces) {
for (UUID uuid : pieces) {
PieceControl p = this.pieces.get(uuid);
p.highlight(false);
p.setHoverable(true);
p.setSelectable(true);
p.selectableOwn();
selectableOwnPieces.add(p);
}
}
@@ -667,31 +660,35 @@ public void outlineShield(List<UUID> pieces) {
*
* @param pieceSelected the PieceControl instance representing the piece selected by the user
*/
public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected();
if (selectableOwnPieces.contains(pieceSelected)) {
public void pieceSelect(OutlineOEControl selected) {
PieceControl piece = getPieceByOE(selected);
NodeControl node = selectedPieceNodeMap.get(piece);
boolean isSelected = piece.isSelected();
if (selectableOwnPieces.contains(piece)) {
for (PieceControl p : selectableOwnPieces) {
p.unSelect();
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
p.selectOff();
NodeControl n = selectedPieceNodeMap.get(p);
if (n != null) n.selectOff();
}
if (!isSelected) {
pieceSelected.select();
if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).select();
selectedOwnPiece = pieceSelected;
piece.selectOn();
if (node != null) node.selectOn();
selectedOwnPiece = piece;
} else {
pieceSelected.unSelect();
if (selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
piece.selectOff();
if (node != null) node.selectOff();;
selectedOwnPiece = null;
}
} else if (selectableEnemyPieces.contains(pieceSelected)) {
} else if (selectableEnemyPieces.contains(piece)) {
for (PieceControl p : selectableEnemyPieces) {
p.unSelect();
p.selectOff();
}
if (!isSelected) {
pieceSelected.select();
selectedEnemyPiece = pieceSelected;
piece.selectOn();
selectedEnemyPiece = piece;
} else {
pieceSelected.unSelect();
piece.selectOff();
selectedEnemyPiece = null;
}
} else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
@@ -699,37 +696,47 @@ public void pieceSelect(PieceControl pieceSelected) {
app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece));
}
public void pieceHoverOn(PieceControl hoverPiece) {
hoverPiece.hover();
if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover();
public void hoverOn(OutlineOEControl hover) {
PieceControl piece = getPieceByOE(hover);
NodeControl node = selectedPieceNodeMap.get(piece);
piece.hoverOn();
if(node != null) node.hoverOn();
}
public void pieceHoverOff(PieceControl hoverPiece) {
hoverPiece.hoverOff();
if (selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
public void hoverOff(OutlineOEControl hover) {
PieceControl piece = getPieceByOE(hover);
NodeControl node = selectedPieceNodeMap.get(piece);
piece.hoverOff();
if(node != null) node.hoverOff();
}
private PieceControl getPieceByOE(OutlineOEControl control){
PieceControl piece;
if (control instanceof PieceControl p){
piece = p;
}
else if (control instanceof NodeControl n){
piece = getKeyByValue(selectedPieceNodeMap, n);
}
else throw new RuntimeException("selected is not instanceof piece or node");
return piece;
}
/**
* Clears all highlighted, selectable, and selected pieces and nodes.
*/
public void clearSelectable() {
for (PieceControl p : selectableEnemyPieces) {
p.unSelect();
p.unHighlight();
p.setSelectable(false);
p.setHoverable(false);
}
for (PieceControl p : selectableOwnPieces) {
p.unSelect();
p.unHighlight();
p.setSelectable(false);
p.setHoverable(false);
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
if (selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unHighlight();
p.selectableOff();
NodeControl n = selectedPieceNodeMap.get(p);
if(n != null) n.selectableOff();
}
for (NodeControl n : outlineNodes) {
n.deOutline();
for (PieceControl p : selectableEnemyPieces) {
p.selectableOff();
}
outlineNodes.clear();
selectableEnemyPieces.clear();
selectableOwnPieces.clear();

View File

@@ -9,16 +9,7 @@
* A control that adds highlighting functionality to a node in the game.
* This class extends {@link OutlineControl} to add an outline effect when the node is highlighted.
*/
public class NodeControl extends OutlineControl {
private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
private static final ColorRGBA OUTLINE_SELECT_COLOR = ColorRGBA.Cyan;
private static final int OUTLINE_SELECT_WIDTH = 8;
private static final ColorRGBA OUTLINE_HOVER_COLOR = ColorRGBA.Yellow;
private static final int OUTLINE_HOVER_WIDTH = 6;
private boolean select = false;
private boolean highlight = false;
public class NodeControl extends OutlineOEControl {
/**
* Constructs a {@link NodeControl} with the specified application and post processor.
@@ -28,7 +19,7 @@ public class NodeControl extends OutlineControl {
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/
public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp);
super(app, fpp, app.getCamera());
}
/**
@@ -40,35 +31,4 @@ public NodeControl(MdgaApp app, FilterPostProcessor fpp) {
public Vector3f getLocation() {
return this.getSpatial().getLocalTranslation();
}
public void highlight() {
highlight = true;
super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
}
public void unHighlight() {
highlight = false;
deOutline();
}
public void select() {
select = true;
super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
}
public void unSelect() {
select = false;
if (highlight) highlight();
else deOutline();
}
public void hover() {
super.outline(OUTLINE_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
}
public void hoverOff() {
if (select) select();
else if (highlight) highlight();
else deOutline();
}
}

View File

@@ -16,9 +16,18 @@ public class OutlineControl extends InitControl {
/**
* The {@link SelectObjectOutliner} responsible for managing the outline effect.
*/
private final SelectObjectOutliner outlineOwn;
private static final int THICKNESS_DEFAULT = 6;
private MdgaApp app;
private final SelectObjectOutliner selectObjectOutliner;
private final MdgaApp app;
private boolean hoverable = false;
private boolean highlight = false;
private boolean selectable = false;
private boolean select = false;
private ColorRGBA highlightColor;
private int highlightWidth;
private ColorRGBA hoverColor;
private int hoverWidth;
private ColorRGBA selectColor;
private int selectWidth;
/**
* Constructs an {@code OutlineControl} with default thickness for the object outline.
@@ -26,44 +35,30 @@ public class OutlineControl extends InitControl {
* @param app The main application managing the outline control.
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
*/
public OutlineControl(MdgaApp app, FilterPostProcessor fpp) {
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam,
ColorRGBA highlightColor, int highlightWidth,
ColorRGBA hoverColor, int hoverWidth,
ColorRGBA selectColor, int selectWidth
) {
this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
this.highlightColor = highlightColor;
this.highlightWidth = highlightWidth;
this.hoverColor = hoverColor;
this.hoverWidth = hoverWidth;
this.selectColor = selectColor;
this.selectWidth = selectWidth;
selectObjectOutliner = new SelectObjectOutliner(fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
/**
* Constructs an {@code OutlineControl} with default thickness, allowing a custom camera to be specified.
*
* @param app The main application managing the outline control.
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
* @param cam The camera used for rendering the outlined objects.
*/
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam) {
this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
/**
* Constructs an {@code OutlineControl} with a specified thickness and custom camera.
*
* @param app The main application managing the outline control.
* @param fpp The {@code FilterPostProcessor} used for post-processing effects.
* @param cam The camera used for rendering the outlined objects.
* @param thickness The thickness of the outline.
*/
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness) {
this.app = app;
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
}
/**
* Applies an outline to the spatial object with the given color.
*
* @param color The {@link ColorRGBA} representing the color of the outline.
*/
public void outline(ColorRGBA color) {
outlineOwn.select(spatial, color);
}
// public void outline(ColorRGBA color) {
// selectObjectOutliner.select(spatial, color);
// }
/**
* Applies an outline to the spatial object with the given color and width.
@@ -72,15 +67,15 @@ public void outline(ColorRGBA color) {
* @param width The width of the outline.
*/
public void outline(ColorRGBA color, int width) {
deOutline();
outlineOwn.select(spatial, color, width);
outlineOff();
selectObjectOutliner.select(spatial, color, width);
}
/**
* Removes the outline effect from the spatial object.
*/
public void deOutline() {
outlineOwn.deselect(spatial);
public void outlineOff() {
selectObjectOutliner.deselect(spatial);
}
/**
@@ -91,4 +86,97 @@ public void deOutline() {
public MdgaApp getApp() {
return app;
}
public void highlightOn() {
highlight = true;
outline(highlightColor, highlightWidth);
}
public void highlightOff() {
highlight = false;
outlineOff();
}
public void hoverOn() {
if (!hoverable) return;
outline(hoverColor, hoverWidth);
}
public void hoverOff() {
if (!hoverable) return;
if (select) selectOn();
else if (highlight) highlightOn();
else outlineOff();
}
public void selectOn() {
if (!selectable) return;
select = true;
outline(selectColor, selectWidth);
}
public void selectOff() {
select = false;
if (highlight) highlightOn();
else outlineOff();
}
public void selectableOn(){
setSelectable(true);
setHoverable(true);
highlightOn();
select = false;
}
public void selectableOff(){
setSelectable(false);
setHoverable(false);
highlightOff();
select = false;
}
private void setSelectable(boolean selectable) {
this.selectable = selectable;
}
public boolean isSelected() {
return select;
}
public boolean isSelectable() {
return selectable;
}
public boolean isHoverable() {
return hoverable;
}
private void setHoverable(boolean hoverable) {
this.hoverable = hoverable;
}
public void setHighlightColor(ColorRGBA color){
highlightColor = color;
}
public void setHighlightWidth(int width){
highlightWidth = width;
}
public void setHoverColor(ColorRGBA color){
hoverColor = color;
}
public void setHoverWidth(int width){
hoverWidth = width;
}
public void setSelectColor(ColorRGBA color){
selectColor = color;
}
public void setSelectWidth(int width){
selectWidth = width;
}
}

View File

@@ -0,0 +1,40 @@
package pp.mdga.client.board;
import com.jme3.math.ColorRGBA;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import pp.mdga.client.MdgaApp;
public class OutlineOEControl extends OutlineControl{
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red;
private static final ColorRGBA OUTLINE_OWN_HOVER_COLOR = ColorRGBA.Yellow;
private static final ColorRGBA OUTLINE_ENEMY_HOVER_COLOR = ColorRGBA.Green;
private static final ColorRGBA OUTLINE_OWN_SELECT_COLOR = ColorRGBA.Cyan;
private static final ColorRGBA OUTLINE_ENEMY_SELECT_COLOR = ColorRGBA.Orange;
private static final int OUTLINE_HIGHLIGHT_WIDTH = 8;
private static final int OUTLINE_HOVER_WIDTH = 8;
private static final int OUTLINE_SELECT_WIDTH = 10;
public OutlineOEControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
super(app, fpp, cam,
OUTLINE_OWN_COLOR, OUTLINE_HIGHLIGHT_WIDTH,
OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH,
OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH
);
}
public void selectableOwn(){
setHighlightColor(OUTLINE_OWN_COLOR);
setHoverColor(OUTLINE_OWN_HOVER_COLOR);
setSelectColor(OUTLINE_OWN_SELECT_COLOR);
selectableOn();
}
public void selectableEnemy(){
setHighlightColor(OUTLINE_ENEMY_COLOR);
setHoverColor(OUTLINE_ENEMY_HOVER_COLOR);
setSelectColor(OUTLINE_ENEMY_SELECT_COLOR);
selectableOn();
}
}

View File

@@ -20,7 +20,7 @@
* to provide outline functionality and includes additional features like shield effects,
* hover states, and selection states.
*/
public class PieceControl extends OutlineControl {
public class PieceControl extends OutlineOEControl {
private final float initRotation;
private final AssetManager assetManager;
private Spatial shieldRing;
@@ -32,16 +32,6 @@ public class PieceControl extends OutlineControl {
private static final ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY);
private static final float SHIELD_Z = 0f;
private static final ColorRGBA OUTLINE_OWN_COLOR = ColorRGBA.White;
private static final ColorRGBA OUTLINE_ENEMY_COLOR = ColorRGBA.Red;
private static final ColorRGBA OUTLINE_OWN_HOVER_COLOR = ColorRGBA.Yellow;
private static final ColorRGBA OUTLINE_ENEMY_HOVER_COLOR = ColorRGBA.Green;
private static final ColorRGBA OUTLINE_OWN_SELECT_COLOR = ColorRGBA.Cyan;
private static final ColorRGBA OUTLINE_ENEMY_SELECT_COLOR = ColorRGBA.Orange;
private static final int OUTLINE_HIGHLIGHT_WIDTH = 8;
private static final int OUTLINE_HOVER_WIDTH = 8;
private static final int OUTLINE_SELECT_WIDTH = 10;
private final Node parentNode;
private boolean enemy;
private boolean hoverable;
@@ -59,18 +49,13 @@ public class PieceControl extends OutlineControl {
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp);
super(app, fpp, app.getCamera());
this.parentNode = new Node();
this.initRotation = initRotation;
this.assetManager = assetManager;
this.shieldRing = null;
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
enemy = false;
hoverable = false;
highlight = false;
selectable = false;
select = false;
}
/**
@@ -190,99 +175,4 @@ public void setMaterial(Material mat) {
public Material getMaterial() {
return ((Geometry) getSpatial()).getMaterial();
}
/**
* Highlights the piece with the appropriate outline color based on whether it is an enemy or not.
*
* @param enemy True if the piece is an enemy, false if it is owned by the player.
*/
public void highlight(boolean enemy) {
this.enemy = enemy;
highlight = true;
super.outline(enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
}
/**
* Removes the highlight effect from the piece.
*/
public void unHighlight() {
highlight = false;
deOutline();
}
/**
* Applies a hover effect on the piece if it is hoverable.
*/
public void hover() {
if (!hoverable) return;
super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
}
/**
* Removes the hover effect from the piece.
*/
public void hoverOff() {
if (!hoverable) return;
if (select) select();
else if (highlight) highlight(enemy);
else deOutline();
}
/**
* Deselects the piece and removes the selection outline. If the piece was highlighted,
* it will be re-highlighted. Otherwise, the outline is removed.
*/
public void unSelect() {
select = false;
if (highlight) highlight(enemy);
else deOutline();
}
/**
* Selects the piece and applies the selection outline. If the piece is an enemy, it will
* be outlined with the enemy selection color; otherwise, the own selection color will be used.
*/
public void select() {
if (!selectable) return;
select = true;
super.outline(enemy ? OUTLINE_ENEMY_SELECT_COLOR : OUTLINE_OWN_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
}
/**
* Sets whether the piece is selectable.
*
* @param selectable True if the piece can be selected, false otherwise.
*/
public void setSelectable(boolean selectable) {
this.selectable = selectable;
}
/**
* Checks if the piece is selected.
*
* @return True if the piece is selected, false otherwise.
*/
public boolean isSelected() {
return select;
}
/**
* Checks if the piece is selectable.
*
* @return True if the piece is selectable, false otherwise.
*/
public boolean isSelectable() {
return selectable;
}
/**
* Sets whether the piece is hoverable.
*
* @param hoverable True if the piece can be hovered over, false otherwise.
*/
public void setHoverable(boolean hoverable) {
this.hoverable = hoverable;
}
}

View File

@@ -15,8 +15,6 @@
public class CardControl extends OutlineControl {
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow;
private static final ColorRGBA HIGHLIGHT_COLOR = ColorRGBA.Yellow;
private static final int HIGHLIGHT_WIDTH = 9;
@@ -27,16 +25,16 @@ public class CardControl extends OutlineControl {
private static final int SELECT_WIDTH = 13;
private static final int OUTLINE_THICKNESS = 9;
private boolean hoverable;
private boolean highlight;
private boolean selectable;
private boolean select;
private Node root;
private BitmapText num;
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root) {
super(app, fpp, cam, OUTLINE_THICKNESS);
super(app, fpp, cam,
HIGHLIGHT_COLOR, HIGHLIGHT_WIDTH,
HOVER_COLOR, HOVER_WIDTH,
SELECT_COLOR, SELECT_WIDTH
);
this.root = root;
@@ -77,67 +75,6 @@ public Node getRoot() {
public void initSpatial() {
}
public void outline() {
super.outline(OUTLINE_COLOR);
}
private final static Vector3f HIGHLIGHT_Y = new Vector3f(0, 0.4f, 0);
public void setHighlight() {
this.highlight = true;
root.setLocalTranslation(root.getLocalTranslation().add(HIGHLIGHT_Y));
highlight();
}
public void highlight() {
super.outline(HIGHLIGHT_COLOR, HIGHLIGHT_WIDTH);
}
public void unHighlight() {
highlight = false;
root.setLocalTranslation(root.getLocalTranslation().subtract(HIGHLIGHT_Y));
deOutline();
}
public void hover() {
if (!hoverable) return;
super.outline(HOVER_COLOR, HOVER_WIDTH);
}
public void hoverOff() {
if (!hoverable) return;
if (select) select();
else if (highlight) highlight();
else deOutline();
}
public void select() {
if (!selectable) return;
select = true;
super.outline(SELECT_COLOR, SELECT_WIDTH);
}
public void unSelect() {
if (!selectable) return;
select = false;
if (highlight) highlight();
else deOutline();
}
public void setSelectable(boolean selectable) {
this.selectable = selectable;
}
public boolean isSelected() {
return select;
}
public boolean isSelectable() {
return selectable;
}
public void setHoverable(boolean hoverable) {
this.hoverable = hoverable;
}
}

View File

@@ -104,10 +104,7 @@ public void removeCard(BonusCard card) {
public void clearSelectableCards() {
for (CardControl control : selectableCards) {
control.setSelectable(false);
control.setHoverable(false);
control.unHighlight();
control.unSelect();
control.selectableOff();
}
selectableCards.clear();
cardSelect = null;
@@ -134,21 +131,19 @@ public void setSelectableCards(List<BonusCard> select) {
selectableCards.add(bonusCardControlMap.get(card));
}
for (CardControl control : selectableCards) {
control.setSelectable(true);
control.setHoverable(true);
control.setHighlight();
control.selectableOn();
}
}
public void selectCard(CardControl cardControl) {
if (cardControl.isSelected()) {
cardControl.unSelect();
cardControl.selectOff();
cardSelect = null;
} else {
for (CardControl control : selectableCards) {
control.unSelect();
control.selectOff();
}
cardControl.select();
cardControl.selectOn();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
}

View File

@@ -15,20 +15,18 @@ public class SelectObjectOutliner {
private final RenderManager renderManager;
private final AssetManager assetManager;
private final Camera cam;
private final int width;
private boolean selected;
private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
public SelectObjectOutliner(FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
this.selected = false;
this.fpp = fpp;
this.renderManager = renderManager;
this.assetManager = assetManager;
this.cam = cam;
this.width = width;
this.app = app;
}
@@ -39,12 +37,12 @@ public void deselect(Spatial model) {
}
}
public void select(Spatial model, ColorRGBA color) {
if (!selected) {
selected = true;
showOutlineFilterEffect(model, width, color);
}
}
// public void select(Spatial model, ColorRGBA color) {
// if (!selected) {
// selected = true;
// showOutlineFilterEffect(model, width, color);
// }
// }
public void select(Spatial model, ColorRGBA color, int width) {
if (!selected) {