-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
cardshifter-fx/src/main/java/com/cardshifter/client/ActionButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
package com.cardshifter.client; | ||
|
||
import com.cardshifter.server.outgoing.UseableActionMessage; | ||
import javafx.scene.Group; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.input.MouseEvent; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
public class ActionButton extends Group { | ||
|
||
private final UseableActionMessage message; | ||
private final GameClientController controller; | ||
private final double sizeX; | ||
private final double sizeY; | ||
|
||
public ActionButton(UseableActionMessage message, GameClientController controller, double sizeX, double sizeY) { | ||
this.message = message; | ||
this.controller = controller; | ||
this.sizeX = sizeX; | ||
this.sizeY = sizeY; | ||
this.setUpRectangle(); | ||
this.setUpLabel(); | ||
this.setOnMouseClicked(this::actionButtonClicked); | ||
} | ||
private void setUpRectangle() { | ||
Rectangle actionBack = new Rectangle(0, 0, this.sizeX, this.sizeY); | ||
actionBack.setFill(Color.BLUEVIOLET); | ||
this.getChildren().add(actionBack); | ||
} | ||
private void setUpLabel() { | ||
Label actionLabel = new Label(); | ||
actionLabel.setText(this.message.getAction()); | ||
actionLabel.relocate(this.sizeX/2.5, 0); | ||
this.getChildren().add(actionLabel); | ||
} | ||
|
||
private void actionButtonClicked(MouseEvent event) { | ||
this.controller.createAndSendMessage(this.message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters