Merge remote-tracking branch 'origin/development2' into development2

This commit is contained in:
Hanno Fleischer
2024-12-11 16:50:18 +01:00
9 changed files with 252 additions and 343 deletions

View File

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

View File

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

View File

@@ -9,16 +9,7 @@
* A control that adds highlighting functionality to a node in the game. * 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. * This class extends {@link OutlineControl} to add an outline effect when the node is highlighted.
*/ */
public class NodeControl extends OutlineControl { public class NodeControl extends OutlineOEControl {
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;
/** /**
* Constructs a {@link NodeControl} with the specified application and post processor. * 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. * @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/ */
public NodeControl(MdgaApp app, FilterPostProcessor fpp) { 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() { public Vector3f getLocation() {
return this.getSpatial().getLocalTranslation(); 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. * The {@link SelectObjectOutliner} responsible for managing the outline effect.
*/ */
private final SelectObjectOutliner outlineOwn; private final SelectObjectOutliner selectObjectOutliner;
private static final int THICKNESS_DEFAULT = 6; private final MdgaApp app;
private 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. * 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 app The main application managing the outline control.
* @param fpp The {@code FilterPostProcessor} used for post-processing effects. * @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; 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. * Applies an outline to the spatial object with the given color.
* *
* @param color The {@link ColorRGBA} representing the color of the outline. * @param color The {@link ColorRGBA} representing the color of the outline.
*/ */
public void outline(ColorRGBA color) { // public void outline(ColorRGBA color) {
outlineOwn.select(spatial, color); // selectObjectOutliner.select(spatial, color);
} // }
/** /**
* Applies an outline to the spatial object with the given color and width. * 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. * @param width The width of the outline.
*/ */
public void outline(ColorRGBA color, int width) { public void outline(ColorRGBA color, int width) {
deOutline(); outlineOff();
outlineOwn.select(spatial, color, width); selectObjectOutliner.select(spatial, color, width);
} }
/** /**
* Removes the outline effect from the spatial object. * Removes the outline effect from the spatial object.
*/ */
public void deOutline() { public void outlineOff() {
outlineOwn.deselect(spatial); selectObjectOutliner.deselect(spatial);
} }
/** /**
@@ -91,4 +86,97 @@ public void deOutline() {
public MdgaApp getApp() { public MdgaApp getApp() {
return app; 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, * to provide outline functionality and includes additional features like shield effects,
* hover states, and selection states. * hover states, and selection states.
*/ */
public class PieceControl extends OutlineControl { public class PieceControl extends OutlineOEControl {
private final float initRotation; private final float initRotation;
private final AssetManager assetManager; private final AssetManager assetManager;
private Spatial shieldRing; 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 ColorRGBA SHIELD_SUPPRESSED_COLOR = new ColorRGBA(1f, 0.5f, 0, SHIELD_TRANSPARENCY);
private static final float SHIELD_Z = 0f; 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 final Node parentNode;
private boolean enemy; private boolean enemy;
private boolean hoverable; private boolean hoverable;
@@ -59,18 +49,13 @@ public class PieceControl extends OutlineControl {
* @param fpp The {@link FilterPostProcessor} to apply post-processing effects. * @param fpp The {@link FilterPostProcessor} to apply post-processing effects.
*/ */
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp) { public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp) {
super(app, fpp); super(app, fpp, app.getCamera());
this.parentNode = new Node(); this.parentNode = new Node();
this.initRotation = initRotation; this.initRotation = initRotation;
this.assetManager = assetManager; this.assetManager = assetManager;
this.shieldRing = null; this.shieldRing = null;
this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); this.shieldMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
this.shieldMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); 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() { public Material getMaterial() {
return ((Geometry) getSpatial()).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 { public class CardControl extends OutlineControl {
private static final ColorRGBA OUTLINE_COLOR = ColorRGBA.Yellow;
private static final ColorRGBA HIGHLIGHT_COLOR = ColorRGBA.Yellow; private static final ColorRGBA HIGHLIGHT_COLOR = ColorRGBA.Yellow;
private static final int HIGHLIGHT_WIDTH = 9; 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 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 Node root;
private BitmapText num; private BitmapText num;
public CardControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, Node root) { 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; this.root = root;
@@ -77,67 +75,6 @@ public Node getRoot() {
public void initSpatial() { public void initSpatial() {
} }
public void outline() {
super.outline(OUTLINE_COLOR);
}
private final static Vector3f HIGHLIGHT_Y = new Vector3f(0, 0.4f, 0); 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() { public void clearSelectableCards() {
for (CardControl control : selectableCards) { for (CardControl control : selectableCards) {
control.setSelectable(false); control.selectableOff();
control.setHoverable(false);
control.unHighlight();
control.unSelect();
} }
selectableCards.clear(); selectableCards.clear();
cardSelect = null; cardSelect = null;
@@ -134,21 +131,19 @@ public void setSelectableCards(List<BonusCard> select) {
selectableCards.add(bonusCardControlMap.get(card)); selectableCards.add(bonusCardControlMap.get(card));
} }
for (CardControl control : selectableCards) { for (CardControl control : selectableCards) {
control.setSelectable(true); control.selectableOn();
control.setHoverable(true);
control.setHighlight();
} }
} }
public void selectCard(CardControl cardControl) { public void selectCard(CardControl cardControl) {
if (cardControl.isSelected()) { if (cardControl.isSelected()) {
cardControl.unSelect(); cardControl.selectOff();
cardSelect = null; cardSelect = null;
} else { } else {
for (CardControl control : selectableCards) { for (CardControl control : selectableCards) {
control.unSelect(); control.selectOff();
} }
cardControl.select(); cardControl.selectOn();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl); cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
} }

View File

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