Merge commit

This commit is contained in:
Felix Koppe
2024-12-09 01:18:47 +01:00
3 changed files with 51 additions and 13 deletions

View File

@@ -250,12 +250,13 @@ private void hoverPiece() {
PieceControl control = checkPiece(); PieceControl control = checkPiece();
if (control != null) { if (control != null) {
if (control != hoverPiece) { if (control != hoverPiece) {
pieceOff(); pieceOff(gameView);
hoverPiece = control; hoverPiece = control;
hoverPiece.hover(); // hoverPiece.hover();
gameView.getBoardHandler().pieceHoverOn(hoverPiece);
} }
} else { } else {
pieceOff(); pieceOff(gameView);
} }
} }
} }
@@ -305,8 +306,11 @@ private CardControl checkCard(GameView gameView) {
/** /**
* Disables the hover effect on the currently hovered piece, if any. * Disables the hover effect on the currently hovered piece, if any.
*/ */
private void pieceOff() { private void pieceOff(GameView gameView) {
if (hoverPiece != null) hoverPiece.hoverOff(); if (hoverPiece != null) {
gameView.getBoardHandler().pieceHoverOff(hoverPiece);
// hoverPiece.hoverOff();
}
hoverPiece = null; hoverPiece = null;
} }

View File

@@ -670,6 +670,7 @@ public void pieceSelect(PieceControl pieceSelected) {
if(selectableOwnPieces.contains(pieceSelected)){ if(selectableOwnPieces.contains(pieceSelected)){
for(PieceControl p : selectableOwnPieces) { for(PieceControl p : selectableOwnPieces) {
p.unSelect(); p.unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
} }
if (!isSelected) { if (!isSelected) {
pieceSelected.select(); pieceSelected.select();
@@ -678,7 +679,7 @@ public void pieceSelect(PieceControl pieceSelected) {
} }
else { else {
pieceSelected.unSelect(); pieceSelected.unSelect();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).highlight(); if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
selectedOwnPiece = null; selectedOwnPiece = null;
} }
} }
@@ -700,6 +701,16 @@ else if(selectableEnemyPieces.contains(pieceSelected)) {
app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece)); 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 pieceHoverOff(PieceControl hoverPiece){
hoverPiece.hoverOff();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
}
/** /**
* Clears all highlighted, selectable, and selected pieces and nodes. * Clears all highlighted, selectable, and selected pieces and nodes.
*/ */

View File

@@ -17,7 +17,11 @@ public class NodeControl extends OutlineControl {
private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White; private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
private static final int OUTLINE_HIGHLIGHT_WIDTH = 6; private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
private static final ColorRGBA OUTLINE_SELECT_COLOR = ColorRGBA.Cyan; private static final ColorRGBA OUTLINE_SELECT_COLOR = ColorRGBA.Cyan;
private static final int OUTLINE_SELECT_WIDTH = 6; 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.
@@ -40,15 +44,34 @@ public Vector3f getLocation(){
return this.getSpatial().getLocalTranslation(); return this.getSpatial().getLocalTranslation();
} }
/**
* Highlights the node by applying an outline effect.
* The outline color and width are predefined as white and 6, respectively.
*/
public void highlight(){ public void highlight(){
highlight = true;
super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH); super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
} }
public void unHighlight(){
highlight = false;
deOutline();
}
public void select(){ public void select(){
select = true;
super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH); 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();
}
} }