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();
if (control != null) {
if (control != hoverPiece) {
pieceOff();
pieceOff(gameView);
hoverPiece = control;
hoverPiece.hover();
// hoverPiece.hover();
gameView.getBoardHandler().pieceHoverOn(hoverPiece);
}
} else {
pieceOff();
pieceOff(gameView);
}
}
}
@@ -305,8 +306,11 @@ private CardControl checkCard(GameView gameView) {
/**
* Disables the hover effect on the currently hovered piece, if any.
*/
private void pieceOff() {
if (hoverPiece != null) hoverPiece.hoverOff();
private void pieceOff(GameView gameView) {
if (hoverPiece != null) {
gameView.getBoardHandler().pieceHoverOff(hoverPiece);
// hoverPiece.hoverOff();
}
hoverPiece = null;
}

View File

@@ -670,6 +670,7 @@ public void pieceSelect(PieceControl pieceSelected) {
if(selectableOwnPieces.contains(pieceSelected)){
for(PieceControl p : selectableOwnPieces) {
p.unSelect();
if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
}
if (!isSelected) {
pieceSelected.select();
@@ -678,7 +679,7 @@ public void pieceSelect(PieceControl pieceSelected) {
}
else {
pieceSelected.unSelect();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).highlight();
if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
selectedOwnPiece = null;
}
}
@@ -700,6 +701,16 @@ else if(selectableEnemyPieces.contains(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 pieceHoverOff(PieceControl hoverPiece){
hoverPiece.hoverOff();
if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
}
/**
* 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 int OUTLINE_HIGHLIGHT_WIDTH = 6;
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.
@@ -40,15 +44,34 @@ public Vector3f getLocation(){
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);
}
public void select() {
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();
}
}