Made it so you can go inbetween screens by pressing enter, allowing for you to speed through the game without pressing buttons.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
@@ -60,7 +61,7 @@ public class BankGUI extends Player{
|
|||||||
hbx1.getChildren().add(b1);
|
hbx1.getChildren().add(b1);
|
||||||
hbx1.getChildren().add(b2);
|
hbx1.getChildren().add(b2);
|
||||||
hbx1.getChildren().add(b3);
|
hbx1.getChildren().add(b3);
|
||||||
|
hbx1.setPadding(new Insets(0,0,20,0));
|
||||||
brdr1.setBottom(hbx1);
|
brdr1.setBottom(hbx1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +82,7 @@ public class BankGUI extends Player{
|
|||||||
vbx1.getChildren().add(l2);
|
vbx1.getChildren().add(l2);
|
||||||
vbx1.getChildren().add(l4);
|
vbx1.getChildren().add(l4);
|
||||||
vbx1.getChildren().add(l5);
|
vbx1.getChildren().add(l5);
|
||||||
|
vbx1.setPadding(new Insets(20,0,0,0));
|
||||||
brdr1.setTop(vbx1);
|
brdr1.setTop(vbx1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
@@ -61,9 +62,11 @@ public class LoanSharkGUI extends Player {
|
|||||||
hbx1.getChildren().add(b1);
|
hbx1.getChildren().add(b1);
|
||||||
hbx1.getChildren().add(b2);
|
hbx1.getChildren().add(b2);
|
||||||
hbx1.getChildren().add(b3);
|
hbx1.getChildren().add(b3);
|
||||||
|
hbx1.setPadding(new Insets(0,0,20,0));
|
||||||
|
|
||||||
brdr1.setBottom(hbx1);
|
brdr1.setBottom(hbx1);
|
||||||
|
|
||||||
|
|
||||||
//Creating the TextField at the center of the screen
|
//Creating the TextField at the center of the screen
|
||||||
hbx2.setAlignment(Pos.CENTER);
|
hbx2.setAlignment(Pos.CENTER);
|
||||||
hbx2.getChildren().add(l3);
|
hbx2.getChildren().add(l3);
|
||||||
@@ -76,6 +79,7 @@ public class LoanSharkGUI extends Player {
|
|||||||
vbx1.getChildren().add(l2);
|
vbx1.getChildren().add(l2);
|
||||||
vbx1.getChildren().add(l4);
|
vbx1.getChildren().add(l4);
|
||||||
vbx1.getChildren().add(l5);
|
vbx1.getChildren().add(l5);
|
||||||
|
vbx1.setPadding(new Insets(20,0,0,0));
|
||||||
brdr1.setTop(vbx1);
|
brdr1.setTop(vbx1);
|
||||||
|
|
||||||
// Set the event handler when the deposit button is clicked
|
// Set the event handler when the deposit button is clicked
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ public class ShipWarfareGUI extends Player{
|
|||||||
setMoney(getMoney() + calculateLoot);
|
setMoney(getMoney() + calculateLoot);
|
||||||
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
|
continueButton.setDefaultButton(true);
|
||||||
return true;
|
return true;
|
||||||
} else if (exitValue == 2) {
|
} else if (exitValue == 2) {
|
||||||
GameEndGUI gameEndGUI = new GameEndGUI(getPlayer());
|
GameEndGUI gameEndGUI = new GameEndGUI(getPlayer());
|
||||||
@@ -285,6 +286,7 @@ public class ShipWarfareGUI extends Player{
|
|||||||
} else if (exitValue == 3) {
|
} else if (exitValue == 3) {
|
||||||
System.out.printf("We made it out at %d%% ship status!\n", getHP());
|
System.out.printf("We made it out at %d%% ship status!\n", getHP());
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
|
continueButton.setDefaultButton(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -324,6 +326,7 @@ public class ShipWarfareGUI extends Player{
|
|||||||
continueButton = new Button();
|
continueButton = new Button();
|
||||||
|
|
||||||
chooseFightOrRun.setVisible(false);
|
chooseFightOrRun.setVisible(false);
|
||||||
|
fightButton.setDefaultButton(true);
|
||||||
|
|
||||||
continueToFight.setPrefWidth(379);
|
continueToFight.setPrefWidth(379);
|
||||||
|
|
||||||
@@ -532,6 +535,7 @@ public class ShipWarfareGUI extends Player{
|
|||||||
fightButton.setId("Button1");
|
fightButton.setId("Button1");
|
||||||
fightButton.setMnemonicParsing(false);
|
fightButton.setMnemonicParsing(false);
|
||||||
fightButton.setText("Fight");
|
fightButton.setText("Fight");
|
||||||
|
fightButton.setDefaultButton(true);
|
||||||
|
|
||||||
runButton.setAlignment(javafx.geometry.Pos.CENTER);
|
runButton.setAlignment(javafx.geometry.Pos.CENTER);
|
||||||
runButton.setId("Button2");
|
runButton.setId("Button2");
|
||||||
@@ -546,20 +550,18 @@ public class ShipWarfareGUI extends Player{
|
|||||||
public void setVisibilitiesAndTransition(Stage stage) {
|
public void setVisibilitiesAndTransition(Stage stage) {
|
||||||
completeWipe();
|
completeWipe();
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
|
continueButton.setDefaultButton(true);
|
||||||
fightButton.setVisible(false);
|
fightButton.setVisible(false);
|
||||||
runButton.setVisible(false);
|
runButton.setVisible(false);
|
||||||
continueButton.setOnAction(new EventHandler<ActionEvent>() {
|
/**
|
||||||
@Override
|
* Switches to Taipan Shop scene
|
||||||
/**
|
* @param event, once button is clicked, executes graphical information
|
||||||
* Switches to Taipan Shop scene
|
*/
|
||||||
* @param event, once button is clicked, executes graphical information
|
continueButton.setOnAction(event -> {
|
||||||
*/
|
TaipanShopGUI shop = new TaipanShopGUI(getPlayer());
|
||||||
public void handle(ActionEvent event) {
|
shop.initializeShop(stage);
|
||||||
TaipanShopGUI shop = new TaipanShopGUI(getPlayer());
|
stage.show();
|
||||||
shop.initializeShop(stage);
|
});
|
||||||
stage.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ public class StartGUI extends Player{
|
|||||||
hBox.getChildren().add(vBox);
|
hBox.getChildren().add(vBox);
|
||||||
vBox0.getChildren().add(title);
|
vBox0.getChildren().add(title);
|
||||||
vBox0.getChildren().add(authors);
|
vBox0.getChildren().add(authors);
|
||||||
|
startButton.setDefaultButton(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds function to the "Start" button, scenario 1 gives the player $400 and a $5000 debt at the start of the game;
|
* Adds function to the "Start" button, scenario 1 gives the player $400 and a $5000 debt at the start of the game;
|
||||||
@@ -202,7 +203,6 @@ public class StartGUI extends Player{
|
|||||||
TaipanShopGUI shop = new TaipanShopGUI(getPlayer());
|
TaipanShopGUI shop = new TaipanShopGUI(getPlayer());
|
||||||
shop.initializeShop(stage);
|
shop.initializeShop(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
//title.setText("SHOP PLACEHOLDER");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -211,6 +211,8 @@ public class StartGUI extends Player{
|
|||||||
stage.setTitle("Start");
|
stage.setTitle("Start");
|
||||||
stage.setResizable(false);
|
stage.setResizable(false);
|
||||||
stage.setScene(root);
|
stage.setScene(root);
|
||||||
|
stage.setHeight(510);
|
||||||
|
stage.setWidth(600);
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ public class TaipanShopGUI extends Player{
|
|||||||
loanButton.setVisible(false);
|
loanButton.setVisible(false);
|
||||||
armsButton.setVisible(false);
|
armsButton.setVisible(false);
|
||||||
quitButton.setVisible(true);
|
quitButton.setVisible(true);
|
||||||
|
quitButton.setDefaultButton(true);
|
||||||
opiumButton.setVisible(false);
|
opiumButton.setVisible(false);
|
||||||
silkButton.setVisible(false);
|
silkButton.setVisible(false);
|
||||||
numberInput.setVisible(false);
|
numberInput.setVisible(false);
|
||||||
@@ -174,6 +175,8 @@ public class TaipanShopGUI extends Player{
|
|||||||
cargoButton.setVisible(false);
|
cargoButton.setVisible(false);
|
||||||
loanButton.setVisible(true);
|
loanButton.setVisible(true);
|
||||||
quitButton.setVisible(true);
|
quitButton.setVisible(true);
|
||||||
|
quitButton.setDefaultButton(true);
|
||||||
|
quitButton.setDefaultButton(true);
|
||||||
opiumButton.setVisible(false);
|
opiumButton.setVisible(false);
|
||||||
silkButton.setVisible(false);
|
silkButton.setVisible(false);
|
||||||
numberInput.setVisible(false);
|
numberInput.setVisible(false);
|
||||||
@@ -188,6 +191,7 @@ public class TaipanShopGUI extends Player{
|
|||||||
loanButton.setVisible(true);
|
loanButton.setVisible(true);
|
||||||
numberInput.setVisible(false);
|
numberInput.setVisible(false);
|
||||||
quitButton.setVisible(true);
|
quitButton.setVisible(true);
|
||||||
|
quitButton.setDefaultButton(true);
|
||||||
opiumButton.setVisible(false);
|
opiumButton.setVisible(false);
|
||||||
silkButton.setVisible(false);
|
silkButton.setVisible(false);
|
||||||
generalButton.setVisible(false);
|
generalButton.setVisible(false);
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class TravelGUI extends Player{
|
|||||||
|
|
||||||
//Text input for where the player needs to go inside of the game world
|
//Text input for where the player needs to go inside of the game world
|
||||||
numberInput.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
|
numberInput.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
|
||||||
numberInput.setText("Enter preferred location.");
|
//numberInput.setText("Enter preferred location.");
|
||||||
numberInput.setOnKeyPressed(event -> {
|
numberInput.setOnKeyPressed(event -> {
|
||||||
if(event.getCode().equals(KeyCode.ENTER)||event.getCode().equals(KeyCode.Z)) {
|
if(event.getCode().equals(KeyCode.ENTER)||event.getCode().equals(KeyCode.Z)) {
|
||||||
int response;
|
int response;
|
||||||
@@ -232,6 +232,7 @@ public class TravelGUI extends Player{
|
|||||||
}
|
}
|
||||||
if (hasTraveled) {
|
if (hasTraveled) {
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
|
continueButton.setDefaultButton(true);
|
||||||
quitButton.setVisible(false);
|
quitButton.setVisible(false);
|
||||||
numberInput.setVisible(false);
|
numberInput.setVisible(false);
|
||||||
shopScene = true;
|
shopScene = true;
|
||||||
@@ -317,6 +318,7 @@ public class TravelGUI extends Player{
|
|||||||
|
|
||||||
hBox0.getChildren().addAll(inventoryText, inventoryHeldText, gunsText, shipStatusText);
|
hBox0.getChildren().addAll(inventoryText, inventoryHeldText, gunsText, shipStatusText);
|
||||||
|
|
||||||
|
numberInput.requestFocus();
|
||||||
flowPane.getChildren().addAll(numberInput, quitButton, continueButton);
|
flowPane.getChildren().addAll(numberInput, quitButton, continueButton);
|
||||||
|
|
||||||
gridPane.getColumnConstraints().add(columnConstraints);
|
gridPane.getColumnConstraints().add(columnConstraints);
|
||||||
@@ -386,6 +388,7 @@ public class TravelGUI extends Player{
|
|||||||
int randGenNum = rand.nextInt(3) + 1;
|
int randGenNum = rand.nextInt(3) + 1;
|
||||||
if (randGenNum == 1) {
|
if (randGenNum == 1) {
|
||||||
continueButton.setVisible(true);
|
continueButton.setVisible(true);
|
||||||
|
continueButton.setDefaultButton(true);
|
||||||
quitButton.setVisible(false);
|
quitButton.setVisible(false);
|
||||||
numberInput.setVisible(false);
|
numberInput.setVisible(false);
|
||||||
textOut.setText(" We see a ship on the horizon " + getName() + "; Prepare for combat!");
|
textOut.setText(" We see a ship on the horizon " + getName() + "; Prepare for combat!");
|
||||||
|
|||||||
Reference in New Issue
Block a user