-
Notifications
You must be signed in to change notification settings - Fork 0
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
25 changed files
with
272 additions
and
99 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.*?> | ||
<?import java.util.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<?import javafx.scene.paint.*?> | ||
<?import javafx.scene.canvas.Canvas?> | ||
|
||
|
||
<AnchorPane fx:id="innerLayout" xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUI.PromotionPrompt"> | ||
<Button layoutX="10" layoutY="10" prefWidth="75" text="Queen" onAction="#handleSubmitButton" /> | ||
<Button layoutX="90" layoutY="10" prefWidth="75" text="Rook" onAction="#handleSubmitButton" /> | ||
<Button layoutX="10" layoutY="40" prefWidth="75" text="Bishop" onAction="#handleSubmitButton" /> | ||
<Button layoutX="90" layoutY="40" prefWidth="75" text="Knight" onAction="#handleSubmitButton" /> | ||
<Button layoutX="10" layoutY="70" prefWidth="75" text="Unicorn" onAction="#handleSubmitButton" /> | ||
<Button layoutX="90" layoutY="70" prefWidth="75" text="Dragon" onAction="#handleSubmitButton" /> | ||
</AnchorPane> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package GUI; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class EventSource { | ||
ArrayList<MessageListener> subscribers; | ||
|
||
public EventSource() { | ||
subscribers = new ArrayList<MessageListener>(); | ||
} | ||
|
||
public void addListener(MessageListener sub) { | ||
subscribers.add(sub); | ||
} | ||
|
||
public void broadcastEvent(MessageEvent e) { | ||
for(MessageListener sub: subscribers) { | ||
sub.handleMessage(e); | ||
} | ||
} | ||
} | ||
|
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,5 @@ | ||
package GUI; | ||
|
||
public class Globals { | ||
public static EventSource es; | ||
} |
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,11 @@ | ||
package GUI; | ||
|
||
public class MessageEvent { | ||
public static final int Promotion = 1; | ||
|
||
public int type; | ||
public int imess; | ||
public String Message; | ||
public Object Source; | ||
|
||
} |
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,5 @@ | ||
package GUI; | ||
|
||
public interface MessageListener { | ||
public void handleMessage(MessageEvent m); | ||
} |
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,49 @@ | ||
package GUI; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.layout.AnchorPane; | ||
import javafx.stage.Stage; | ||
|
||
public class PromotionPrompt { | ||
@FXML | ||
AnchorPane innerLayout; | ||
|
||
@FXML | ||
void initialize() { | ||
innerLayout.setPrefWidth(200); | ||
innerLayout.setPrefHeight(300); | ||
} | ||
|
||
public PromotionPrompt() { | ||
|
||
} | ||
|
||
@FXML | ||
private void handleSubmitButton(ActionEvent e) { | ||
MessageEvent m = new MessageEvent(); | ||
m.type = MessageEvent.Promotion; | ||
Button b = (Button) (e.getSource()); | ||
String text = b.getText(); | ||
int promotionType = 0; | ||
if(text.equals("Queen")) { | ||
promotionType = 6; | ||
}else if(text.equals("Rook")) { | ||
promotionType = 4; | ||
}else if(text.equals("Bishop")) { | ||
promotionType = 3; | ||
}else if(text.equals("Knight")) { | ||
promotionType = 2; | ||
}else if(text.equals("Dragon")) { | ||
promotionType = 9; | ||
}else if(text.equals("Unicorn")) { | ||
promotionType = 8; | ||
} | ||
m.imess = promotionType; | ||
Globals.es.broadcastEvent(m); | ||
Stage stage = (Stage) innerLayout.getScene().getWindow(); | ||
stage.close(); | ||
} | ||
} |
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
Oops, something went wrong.