started adding notifications
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
import pp.mdga.client.board.PieceControl;
|
||||
import pp.mdga.client.gui.CardControl;
|
||||
import pp.mdga.client.view.GameView;
|
||||
import pp.mdga.game.Piece;
|
||||
|
||||
public class InputSynchronizer {
|
||||
|
||||
@@ -27,12 +28,14 @@ public class InputSynchronizer {
|
||||
private float rotationAngle = 180f;
|
||||
private int scrollValue = 0;
|
||||
private CardControl hoverCard;
|
||||
private PieceControl hoverPiece;
|
||||
|
||||
InputSynchronizer(MdgaApp app) {
|
||||
this.app = app;
|
||||
|
||||
this.inputManager = app.getInputManager();
|
||||
hoverCard = null;
|
||||
hoverPiece = null;
|
||||
setupInput();
|
||||
}
|
||||
|
||||
@@ -76,13 +79,13 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if(cardLayerSelect == null && boardSelect != null) {
|
||||
//boardSelect
|
||||
if(boardSelect instanceof PieceControl pieceControl){
|
||||
pieceControl.outline(true);
|
||||
pieceControl.setSelect();
|
||||
}
|
||||
if(boardSelect instanceof NodeControl nodeControl){
|
||||
nodeControl.outline();
|
||||
// nodeControl.outline();
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
//both null
|
||||
}
|
||||
}
|
||||
@@ -111,7 +114,7 @@ else if (name.equals("MouseScrollDown")) {
|
||||
scrollValue = Math.min(100, scrollValue + 5);
|
||||
}
|
||||
else if (name.equals("MouseLeft") || name.equals("MouseRight") || name.equals("MouseVertical")){
|
||||
// hoverCardOutline();
|
||||
hoverPiece();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -126,23 +129,52 @@ private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T>
|
||||
return null;
|
||||
}
|
||||
|
||||
private void hoverPiece() {
|
||||
if (app.getView() instanceof GameView gameView) {
|
||||
PieceControl control = checkPiece();
|
||||
if (control != null) {
|
||||
if(control != hoverPiece){
|
||||
pieceOff();
|
||||
hoverPiece = control;
|
||||
hoverPiece.hover();
|
||||
}
|
||||
}
|
||||
else pieceOff();
|
||||
}
|
||||
}
|
||||
|
||||
private void hoverCardOutline() {
|
||||
if (app.getView() instanceof GameView gameView) {
|
||||
CardControl control = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class);
|
||||
if (control != null) {
|
||||
if(control != hoverCard){
|
||||
hoverCardOff();
|
||||
pieceOff();
|
||||
hoverCard = control;
|
||||
hoverCard.outline();
|
||||
}
|
||||
}
|
||||
else hoverCardOff();
|
||||
else pieceOff();
|
||||
}
|
||||
}
|
||||
|
||||
private void hoverCardOff() {
|
||||
if (hoverCard != null) hoverCard.deOutline();
|
||||
hoverCard = null;
|
||||
private void hoverAction(){
|
||||
|
||||
}
|
||||
|
||||
private PieceControl checkPiece(){
|
||||
return checkHover(app.getCamera(), app.getRootNode(), PieceControl.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void outlineOff(OutlineControl outline) {
|
||||
if (outline != null) outline.deOutline();
|
||||
outline = null;
|
||||
}
|
||||
|
||||
private void pieceOff(){
|
||||
if(hoverPiece != null) hoverPiece.hoverOff();
|
||||
hoverPiece = null;
|
||||
}
|
||||
|
||||
private Vector3f getMousePos(Camera cam){
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
import pp.mdga.client.animation.AnimationHandler;
|
||||
import com.jme3.system.AppSettings;
|
||||
import pp.mdga.client.view.*;
|
||||
import pp.mdga.game.Color;
|
||||
import pp.mdga.notification.PlayerInGameNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MdgaApp extends SimpleApplication {
|
||||
private AnimationHandler animationHandler;
|
||||
@@ -55,6 +61,18 @@ public void simpleInitApp() {
|
||||
GuiGlobals.initialize(this);
|
||||
|
||||
enter(state);
|
||||
|
||||
List<UUID> test = new ArrayList<>();
|
||||
UUID player0 = UUID.randomUUID();
|
||||
test.add(player0);
|
||||
UUID player1 = UUID.randomUUID();
|
||||
test.add(player1);
|
||||
test.add(UUID.randomUUID());
|
||||
test.add(UUID.randomUUID());
|
||||
|
||||
notificationSynchronizer.addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, test, "Player 1"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ public void addTestNotification(Notification n) {
|
||||
|
||||
public void update() {
|
||||
//TODO fetch model notifications
|
||||
|
||||
for (Notification n : notifications) {
|
||||
switch (app.getState()) {
|
||||
case MAIN:
|
||||
@@ -40,6 +39,7 @@ public void update() {
|
||||
throw new RuntimeException("no notification expected: " + n.toString());
|
||||
}
|
||||
}
|
||||
notifications.clear();
|
||||
}
|
||||
|
||||
private void handleMain(Notification notification) {
|
||||
@@ -98,8 +98,12 @@ private void handleGame(Notification notification) {
|
||||
// Handle PieceInGameNotification
|
||||
} else if (notification instanceof PlayCardNotification) {
|
||||
// Handle PlayCardNotification
|
||||
} else if (notification instanceof PlayerInGameNotification) {
|
||||
} else if (notification instanceof PlayerInGameNotification n) {
|
||||
// Handle PlayerInGameNotification
|
||||
gameView.getBoardHandler().addPlayer(n.getColor(),n.getPiecesList());
|
||||
gameView.getGuiHandler().addPlayer(n.getColor(),n.getName());
|
||||
gameView.getBoardHandler().enableHover(n.getPiecesList().get(0));
|
||||
gameView.getBoardHandler().highlight(n.getPiecesList().get(0), true);
|
||||
} else if (notification instanceof ResumeNotification) {
|
||||
// Handle ResumeNotification
|
||||
} else if (notification instanceof RollDiceNotification) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package pp.mdga.client.board;
|
||||
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
@@ -306,9 +305,9 @@ public void swapPieces(UUID piece1, UUID piece2){
|
||||
}
|
||||
|
||||
public void init() {
|
||||
outlineControls.forEach((outlineControl) -> {
|
||||
outlineControl.outline(outlineControl.getColor());
|
||||
});
|
||||
// outlineControls.forEach((outlineControl) -> {
|
||||
// outlineControl.outline(outlineControl.getColor());
|
||||
// });
|
||||
|
||||
isInitialised = true;
|
||||
scheduleInit = false;
|
||||
@@ -327,12 +326,12 @@ public void shutdown(){
|
||||
|
||||
//List<Pieces>
|
||||
//List<NodesIndexe>
|
||||
public void outline(UUID uuid, boolean bool){
|
||||
public void highlight(UUID uuid, boolean bool){
|
||||
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
||||
|
||||
pieces.get(uuid).outline(bool);
|
||||
pieces.get(uuid).highlight(bool);
|
||||
pieces.get(uuid).setSelectable(bool);
|
||||
|
||||
outlineControls.add(pieces.get(uuid));
|
||||
}
|
||||
|
||||
public void deOutline(UUID uuid){
|
||||
@@ -354,4 +353,10 @@ public void deOutline(int index){
|
||||
|
||||
outlineControls.remove(infield.get(index));
|
||||
}
|
||||
|
||||
public void enableHover(UUID uuid){
|
||||
pieces.get(uuid).setHoverable(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ public void select(Spatial model, ColorRGBA color) {
|
||||
}
|
||||
}
|
||||
|
||||
public void select(Spatial model, ColorRGBA color, int width) {
|
||||
if(!selected){
|
||||
selected = true;
|
||||
showOutlineFilterEffect(model, width, color);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideOutlineFilterEffect(Spatial model) {
|
||||
outlineFilter.setEnabled(false);
|
||||
outlineFilter.getOutlinePreFilter().setEnabled(false);
|
||||
|
||||
@@ -13,7 +13,6 @@ public class OutlineControl extends AbstractControl {
|
||||
private static final int THICKNESS_DEFAULT = 6;
|
||||
private final SelectObjectOutliner outlineOwn;
|
||||
|
||||
ColorRGBA color;
|
||||
|
||||
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
|
||||
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera());
|
||||
@@ -27,11 +26,13 @@ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thic
|
||||
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam);
|
||||
}
|
||||
|
||||
|
||||
public void outline(ColorRGBA color){
|
||||
outlineOwn.select(spatial, color);
|
||||
}
|
||||
|
||||
this.color = color;
|
||||
public void outline(ColorRGBA color, int width){
|
||||
deOutline();
|
||||
outlineOwn.select(spatial, color, width);
|
||||
}
|
||||
|
||||
public void deOutline(){
|
||||
@@ -47,8 +48,4 @@ protected void controlUpdate(float tpf) {
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
|
||||
}
|
||||
|
||||
public ColorRGBA getColor() {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,12 @@
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.post.FilterPostProcessor;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
import pp.mdga.client.Asset;
|
||||
import pp.mdga.client.MdgaApp;
|
||||
import pp.mdga.client.board.Outline.SelectObjectOutliner;
|
||||
|
||||
public class PieceControl extends OutlineControl {
|
||||
private final float initRotation;
|
||||
@@ -32,8 +28,19 @@ public class PieceControl 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_SELECT_COLOR = ColorRGBA.Blue;
|
||||
private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
|
||||
private static final int OUTLINE_HOVER_WIDTH = 6;
|
||||
private static final int OUTLINE_SELECT_WIDTH = 8;
|
||||
|
||||
private final Node parentNode;
|
||||
private boolean enemy;
|
||||
private boolean hoverable;
|
||||
private boolean highlight;
|
||||
private boolean selectable;
|
||||
private boolean select;
|
||||
|
||||
|
||||
public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app, FilterPostProcessor fpp){
|
||||
@@ -44,6 +51,11 @@ public PieceControl(float initRotation, AssetManager assetManager, MdgaApp app,
|
||||
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;
|
||||
}
|
||||
|
||||
public float getRotation() {
|
||||
@@ -128,8 +140,49 @@ public Material getMaterial(){
|
||||
return ((Geometry) this.spatial).getMaterial();
|
||||
}
|
||||
|
||||
public void outline(boolean enemy) {
|
||||
super.outline(enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR);
|
||||
|
||||
//highlight own/enemy figure to select
|
||||
public void highlight(boolean enemy) {
|
||||
this.enemy = enemy;
|
||||
highlight = true;
|
||||
super.outline(enemy ? OUTLINE_ENEMY_COLOR : OUTLINE_OWN_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
|
||||
}
|
||||
|
||||
public void unHighlight(){
|
||||
highlight = false;
|
||||
}
|
||||
|
||||
|
||||
public void hover(){
|
||||
if(!hoverable) return;
|
||||
super.outline(enemy ? OUTLINE_ENEMY_HOVER_COLOR : OUTLINE_OWN_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
|
||||
}
|
||||
|
||||
public void hoverOff(){
|
||||
if(!hoverable) return;
|
||||
|
||||
if(select) select();
|
||||
else if(highlight) highlight(enemy);
|
||||
else deOutline();
|
||||
}
|
||||
|
||||
public void select(){
|
||||
super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
|
||||
}
|
||||
|
||||
public void setSelect(){
|
||||
if(!selectable) return;
|
||||
select = !select;
|
||||
if(select) select();
|
||||
}
|
||||
|
||||
public void setSelectable(boolean selectable){
|
||||
this.selectable = selectable;
|
||||
}
|
||||
|
||||
|
||||
public void setHoverable(boolean hoverable) {
|
||||
this.hoverable = hoverable;
|
||||
}
|
||||
|
||||
public void deOutline() {
|
||||
|
||||
@@ -143,6 +143,12 @@ public void setPlayers(List<String> names, List<Color> colors){
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
public void addPlayer(Color color, String name){
|
||||
colorNameMap.put(color, name);
|
||||
playerOrder.add(color);
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
public void setActivePlayer(Color color){
|
||||
Color lastFirst = playerOrder.remove(0);
|
||||
playerOrder.remove(color);
|
||||
|
||||
@@ -60,15 +60,16 @@ public void onEnter() {
|
||||
guiHandler.init();
|
||||
continueButton.show();
|
||||
|
||||
List<UUID> test = new ArrayList<>();
|
||||
UUID player0 = UUID.randomUUID();
|
||||
test.add(player0);
|
||||
test.add(UUID.randomUUID());
|
||||
test.add(UUID.randomUUID());
|
||||
test.add(UUID.randomUUID());
|
||||
|
||||
boardHandler.addPlayer(Color.AIRFORCE, test);
|
||||
boardHandler.movePieceStart(player0, 0);
|
||||
|
||||
// boardHandler.addPlayer(Color.AIRFORCE, test);
|
||||
// boardHandler.movePieceStart(player0, 0);
|
||||
// boardHandler.enableHover(player0);
|
||||
// boardHandler.enableHover(player1);
|
||||
// boardHandler.highlight(player0, true);
|
||||
|
||||
|
||||
|
||||
// boardHandler.outline(player0, true);
|
||||
|
||||
// boardHandler.outline(10);
|
||||
|
||||
@@ -12,8 +12,8 @@ MaterialDef Cartoon Edge {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL100: MatDefs/SelectObjectOutliner/Post15.vert
|
||||
FragmentShader GLSL100: MatDefs/SelectObjectOutliner/OutlinePro.frag
|
||||
VertexShader GLSL150: MatDefs/SelectObjectOutliner/Post15.vert
|
||||
FragmentShader GLSL150: MatDefs/SelectObjectOutliner/OutlinePro.frag
|
||||
|
||||
WorldParameters {
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
import pp.mdga.game.Color;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Notification that a player is in the game.
|
||||
*/
|
||||
@@ -9,15 +12,17 @@ public class PlayerInGameNotification extends Notification {
|
||||
|
||||
private Color color;
|
||||
private String name;
|
||||
private List<UUID> piecesList;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param color the color of the player that is in the game.
|
||||
* @param name the name of the player that is in the game.
|
||||
*/
|
||||
PlayerInGameNotification(Color color, String name) {
|
||||
public PlayerInGameNotification(Color color, List<UUID> piecesList, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
this.piecesList = piecesList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,4 +40,8 @@ public Color getColor() {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<UUID> getPiecesList() {
|
||||
return piecesList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user