diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2023-05-21 00:45:19 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2023-05-21 00:45:19 -0400 |
commit | f49a73c6af7445bb4ae92fcab87e13abba527048 (patch) | |
tree | 218b7b8c6d64ccd54015d3d47921cb04e11ef503 /src/gui | |
parent | 7c106e7dda744e7d3782737262601de693db0dca (diff) | |
download | NPEhero-f49a73c6af7445bb4ae92fcab87e13abba527048.tar.gz NPEhero-f49a73c6af7445bb4ae92fcab87e13abba527048.tar.bz2 NPEhero-f49a73c6af7445bb4ae92fcab87e13abba527048.zip |
add ui scrollbars, game over menu, new font
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/Block.java | 27 | ||||
-rw-r--r-- | src/gui/DebugMenu.java | 41 | ||||
-rw-r--r-- | src/gui/Driver.java | 29 | ||||
-rw-r--r-- | src/gui/GameOver.java | 113 | ||||
-rw-r--r-- | src/gui/Leaderboard.java | 3 | ||||
-rw-r--r-- | src/gui/LevelDetails.java | 73 | ||||
-rw-r--r-- | src/gui/LevelSelector.java | 20 | ||||
-rw-r--r-- | src/gui/LevelSurround.java | 20 | ||||
-rw-r--r-- | src/gui/MainMenu.java | 9 | ||||
-rw-r--r-- | src/gui/Settings.java | 16 | ||||
-rw-r--r-- | src/gui/SettingsController.java | 54 | ||||
-rw-r--r-- | src/gui/SongPlayer2.java | 232 | ||||
-rw-r--r-- | src/gui/style.css | 135 |
13 files changed, 375 insertions, 397 deletions
diff --git a/src/gui/Block.java b/src/gui/Block.java deleted file mode 100644 index 42cedba..0000000 --- a/src/gui/Block.java +++ /dev/null @@ -1,27 +0,0 @@ -//glowing block of color c (jfx node) - -package gui; - -import javafx.scene.effect.BlurType; -import javafx.scene.effect.DropShadow; -import javafx.scene.paint.Color; -import javafx.scene.shape.Rectangle; - -public class Block extends Rectangle -{ - public Block(Color c, double a, double b, int r) - { - super(); - DropShadow dropShadow = new DropShadow(); - dropShadow.setRadius(200.0); - dropShadow.setColor(c); - dropShadow.setBlurType(BlurType.GAUSSIAN); - - super.setFill(c); - super.setWidth(a); - super.setHeight(b); - super.setArcHeight(r); - super.setArcWidth(r); - super.setEffect(dropShadow); - } -}
\ No newline at end of file diff --git a/src/gui/DebugMenu.java b/src/gui/DebugMenu.java new file mode 100644 index 0000000..c014ee0 --- /dev/null +++ b/src/gui/DebugMenu.java @@ -0,0 +1,41 @@ +package gui; + +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import main.Level; + +public class DebugMenu +{ + public Stage primaryStage = new Stage(); + public DebugMenu() + { + Button wallpaperTest = new Button(); + wallpaperTest.setText("wallpaper trees"); + wallpaperTest.setOnAction(e -> Driver.setBackground("assets/trees.png")); + + Button wallpaperTest2 = new Button(); + wallpaperTest2.setText("wallpaper water"); + wallpaperTest2.setOnAction(e -> Driver.setBackground("assets/water.png")); + + Button wallpaperTest3 = new Button(); + wallpaperTest3.setText("wallpaper pico"); + wallpaperTest3.setOnAction(e -> Driver.setBackground("assets/pico.png")); + + Button testfinish = new Button(); + testfinish.setText("launch game end"); + Level temp = new Level(); + temp.title = "Title"; + temp.aritst = "artist"; + testfinish.setOnAction(e -> Driver.setMenu(new GameOver(300, new Settings(), temp, "Easy"))); + + VBox primaryPane = new VBox(); + primaryPane.getChildren().addAll(wallpaperTest,wallpaperTest2,wallpaperTest3,testfinish); + + Scene primaryScene = new Scene(primaryPane); + primaryStage.setScene(primaryScene); + primaryStage.setTitle("debug"); + primaryStage.show(); + } +} diff --git a/src/gui/Driver.java b/src/gui/Driver.java index b93dbce..208756d 100644 --- a/src/gui/Driver.java +++ b/src/gui/Driver.java @@ -1,11 +1,16 @@ package gui; -import java.util.HashMap; - +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; import javafx.application.Application; +import javafx.application.Platform; +import javafx.beans.property.Property; import javafx.geometry.Side; import javafx.scene.Scene; import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.layout.Background; import javafx.scene.layout.BackgroundImage; import javafx.scene.layout.BackgroundPosition; @@ -62,6 +67,16 @@ public class Driver extends Application public static void setBackground(String url) { + // Image image1; + // Image image2; + // ImageView imageView; + // KeyFrame keyFrame1On = new KeyFrame(Duration.seconds(0), new KeyValue(imageView.imageProperty(), image1)); + // KeyFrame startFadeOut = new KeyFrame(Duration.seconds(0.2), new KeyValue(imageView.opacityProperty(), 1.0)); + // KeyFrame endFadeOut = new KeyFrame(Duration.seconds(0.5), new KeyValue(imageView.opacityProperty(), 0.0)); + // KeyFrame keyFrame2On = new KeyFrame(Duration.seconds(0.5), new KeyValue(imageView.imageProperty(), image2)); + // KeyFrame endFadeIn = new KeyFrame(Duration.seconds(0.8), new KeyValue(imageView.opacityProperty(), 1.0)); + // Timeline timelineOn = new Timeline(keyFrame1On, startFadeOut, endFadeOut, keyFrame2On, endFadeIn); + primaryPane.setBackground(new Background( new BackgroundImage( new Image(url), @@ -70,4 +85,14 @@ public class Driver extends Application new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, false, true) ))); } + + public static void quit() + { + try { + Platform.exit(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/src/gui/GameOver.java b/src/gui/GameOver.java new file mode 100644 index 0000000..68b6759 --- /dev/null +++ b/src/gui/GameOver.java @@ -0,0 +1,113 @@ +package gui; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Text; +import main.Level; + +public class GameOver extends Pane +{ + public GameOver(int score2, Pane lastMenu, Level level, String diff) + { + Text topText = new Text(); + topText.setText("Level Complete"); + topText.setFill(Color.WHITE); + topText.setStyle("-fx-font-size: 50;"); + + + Text levelName = new Text(); + levelName.setText(level.title); + levelName.setFill(Color.WHITE); + levelName.setStyle("-fx-font-size: 30;"); + + Text levelArtist = new Text(); + levelArtist.setText(level.aritst+" - "+diff); + levelArtist.setFill(Color.WHITE); + + VBox levelDetailsBox = new VBox(); + levelDetailsBox.getChildren().addAll(levelName,levelArtist); + levelDetailsBox.getStyleClass().add("textBox"); + levelDetailsBox.setPadding(new Insets(5)); + + + Text scoreLabel = new Text(); + scoreLabel.setText("Final score"); + scoreLabel.setFill(Color.WHITE); + + Text score = new Text(); + score.setText(score2+""); + score.setFill(Color.WHITE); + score.setStyle("-fx-font-size: 30;"); + + VBox scoreBox = new VBox(); + scoreBox.getStyleClass().add("textBox"); + scoreBox.getChildren().addAll(scoreLabel,score); + scoreBox.setPadding(new Insets(5)); + + + Text nameLabel = new Text(); + nameLabel.setText("Leaderboard entry"); + nameLabel.setFill(Color.WHITE); + + TextField name = new TextField(); + name.getStyleClass().remove("text-feild"); + name.getStyleClass().add("custom-radio-button"); + name.setText("name"); + + Button save = new Button(); + save.setText("Add"); + save.setOnAction(new EventHandler<ActionEvent>() { + @Override + public void handle(ActionEvent event) { + save.setDisable(true); + name.setDisable(true); + } + }); + + BorderPane b = new BorderPane(); + b.setRight(save); + b.setCenter(name); + + VBox nameBox = new VBox(); + nameBox.getChildren().addAll(nameLabel,b); + nameBox.getStyleClass().add("textBox"); + nameBox.setSpacing(5); + nameBox.setPadding(new Insets(5)); + + + Button exit = new Button(); + exit.setText("Exit"); + exit.setOnAction(e -> Driver.setMenu(lastMenu)); + + Button replay = new Button(); + replay.setText("Replay"); + replay.setOnAction(e -> Driver.setMenu(new LevelSurround(level, diff, lastMenu))); + + BorderPane buttonBox = new BorderPane(); + buttonBox.setLeft(exit); + buttonBox.setRight(replay); + + + VBox centerBox = new VBox(); + centerBox.getChildren().addAll(topText,levelDetailsBox,scoreBox,nameBox,buttonBox); + centerBox.setSpacing(10); + centerBox.setAlignment(Pos.CENTER); + + HBox rootBox = new HBox(); + rootBox.getChildren().add(centerBox); + rootBox.setAlignment(Pos.CENTER); + rootBox.prefWidthProperty().bind(super.prefWidthProperty()); + rootBox.prefHeightProperty().bind(super.prefHeightProperty()); + + super.getChildren().add(rootBox); + } +} diff --git a/src/gui/Leaderboard.java b/src/gui/Leaderboard.java index 2b12d25..4f5604d 100644 --- a/src/gui/Leaderboard.java +++ b/src/gui/Leaderboard.java @@ -16,6 +16,8 @@ public class Leaderboard extends Pane { ListView<String> scores = new ListView<String>(); ObservableList<String> scoreList= FXCollections.observableArrayList ("Test Score 1", "Test Score 2", "Test Score 3", "Test Score 4"); + scores.getStyleClass().remove("list-view"); + scores.getStyleClass().add("unselectable"); scores.setItems(scoreList); scores.prefWidthProperty().bind(super.prefWidthProperty().multiply(0.25)); scores.prefHeightProperty().bind(super.prefHeightProperty().multiply(0.75)); @@ -28,6 +30,7 @@ public class Leaderboard extends Pane centerBox.setAlignment(Pos.CENTER); centerBox.setSpacing(10); centerBox.getChildren().addAll(scores,exit); + centerBox.setMinWidth(400); HBox rootBox = new HBox(); rootBox.prefWidthProperty().bind(super.prefWidthProperty()); diff --git a/src/gui/LevelDetails.java b/src/gui/LevelDetails.java index 427ede0..8ca4811 100644 --- a/src/gui/LevelDetails.java +++ b/src/gui/LevelDetails.java @@ -3,31 +3,28 @@ package gui; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Button; -import javafx.scene.control.ListView; -import javafx.scene.control.ToggleButton; +import javafx.scene.control.RadioButton; +import javafx.scene.control.ScrollPane; import javafx.scene.control.ToggleGroup; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; -import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.text.TextAlignment; +import javafx.scene.text.TextFlow; import main.Level; public class LevelDetails extends VBox { public LevelDetails(Level level) { - VBox details = new VBox(); - details.prefWidthProperty().bind(super.prefWidthProperty()); - details.prefHeightProperty().bind(super.prefHeightProperty().multiply(0.75)); - details.maxWidthProperty().bind(super.prefWidthProperty()); - details.maxHeightProperty().bind(super.prefHeightProperty().multiply(0.75)); - details.getStyleClass().add("textBox"); - details.setPadding(new Insets(10)); + VBox rightBox = new VBox(); + rightBox.prefWidthProperty().bind(super.prefWidthProperty()); + rightBox.prefHeightProperty().bind(super.prefHeightProperty().multiply(0.75)); + rightBox.getStyleClass().add("textBox"); Button play = new Button(); play.setDisable(true); @@ -40,22 +37,33 @@ public class LevelDetails extends VBox desc.setFill(Color.WHITE); desc.wrappingWidthProperty().bind(super.prefWidthProperty().subtract(10)); desc.setTextAlignment(TextAlignment.CENTER); - details.setAlignment(Pos.CENTER); - details.getChildren().addAll(desc); + + rightBox.setAlignment(Pos.CENTER); + rightBox.getChildren().addAll(desc); } else { + VBox details = new VBox(); + + ScrollPane detailsScroll = new ScrollPane(details); + detailsScroll.prefHeightProperty().bind(rightBox.prefHeightProperty()); + detailsScroll.prefWidthProperty().bind(rightBox.prefWidthProperty()); + detailsScroll.getStyleClass().remove("scroll-pane"); + Text title = new Text(); title.setText(level.title); title.setFill(Color.WHITE); - title.setFont(new Font(50)); - title.wrappingWidthProperty().bind(super.prefWidthProperty().subtract(10)); + title.setStyle("-fx-font-size: 50;"); + + Text artist = new Text(); + artist.setText(level.aritst); + artist.setFill(Color.WHITE); + artist.setStyle("-fx-font-size: 30;"); Text desc = new Text(); desc.setText(level.desc); desc.setFill(Color.WHITE); - desc.wrappingWidthProperty().bind(super.prefWidthProperty().subtract(10)); ImageView previewView = new ImageView(); Image preview = level.preview; @@ -63,31 +71,40 @@ public class LevelDetails extends VBox previewView.fitWidthProperty().bind(super.prefWidthProperty().multiply(0.5)); previewView.setPreserveRatio(true); - HBox diffBox = new HBox(); - diffBox.setPadding(new Insets(30,0,0,0)); - HBox diffSelector = new HBox(); + FlowPane diffSelector = new FlowPane(); diffSelector.setAlignment(Pos.CENTER); ToggleGroup diffToggleGroup = new ToggleGroup(); for (String diff : level.diffList) { - ToggleButton temp = new ToggleButton(); + RadioButton temp = new RadioButton(); + temp.getStyleClass().remove("radio-button"); + temp.getStyleClass().add("button"); + temp.getStyleClass().add("custom-radio-button"); temp.setText(diff); + temp.setUserData(diff); diffToggleGroup.getToggles().add(temp); diffSelector.getChildren().add(temp); } play.disableProperty().bind(diffToggleGroup.selectedToggleProperty().isNull()); - + play.setOnAction(e -> Driver.setMenu(new LevelSurround(level, (String)diffToggleGroup.getSelectedToggle().getUserData(), Driver.getMenu()))); + HBox diffBox = new HBox(); + diffSelector.prefWidthProperty().bind(diffBox.widthProperty()); diffBox.getChildren().add(diffSelector); - details.getChildren().addAll(title,desc,previewView, diffBox); - play.setOnAction(e -> Driver.setMenu(new LevelSurround(level, "easy", Driver.getMenu()))); + + details.setSpacing(10); + details.getChildren().addAll(new TextFlow(title), new TextFlow(artist), new TextFlow(desc), previewView, diffBox); + detailsScroll.setFitToWidth(true); + + rightBox.getChildren().add(detailsScroll); + rightBox.setPadding(new Insets(5)); } - VBox rightBox = new VBox(); - rightBox.setAlignment(Pos.CENTER_RIGHT); - rightBox.setSpacing(10); - rightBox.getChildren().addAll(details,play); + VBox rightSide = new VBox(); + rightSide.setAlignment(Pos.CENTER_RIGHT); + rightSide.setSpacing(10); + rightSide.getChildren().addAll(rightBox,play); super.setAlignment(Pos.CENTER_RIGHT); - super.getChildren().add(rightBox); + super.getChildren().add(rightSide); } } diff --git a/src/gui/LevelSelector.java b/src/gui/LevelSelector.java index 38dc15f..0d81c39 100644 --- a/src/gui/LevelSelector.java +++ b/src/gui/LevelSelector.java @@ -1,19 +1,13 @@ package gui; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.ListView; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.text.Font; -import javafx.scene.text.Text; -import main.LevelController; import main.Level; public class LevelSelector extends Pane @@ -24,6 +18,7 @@ public class LevelSelector extends Pane levels.setItems(main.LevelController.levelList); levels.prefWidthProperty().bind(super.prefWidthProperty().multiply(0.25)); levels.prefHeightProperty().bind(super.prefHeightProperty().multiply(0.75)); + levels.setMinWidth(275); Button exit = new Button(); exit.setText("Exit"); @@ -45,7 +40,14 @@ public class LevelSelector extends Pane rootBox.setAlignment(Pos.CENTER); rootBox.setSpacing(10); - levels.setOnMouseClicked(e -> addDetails(rightBox, levels)); + levels.getStyleClass().remove("list-view"); + levels.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Level>() { + + @Override + public void changed(ObservableValue<? extends Level> arg0, Level arg1, Level arg2) { + addDetails(rightBox, levels); + } + }); super.getChildren().add(rootBox); } diff --git a/src/gui/LevelSurround.java b/src/gui/LevelSurround.java index 3371c3e..6b06313 100644 --- a/src/gui/LevelSurround.java +++ b/src/gui/LevelSurround.java @@ -1,6 +1,5 @@ package gui; -import fallTest.Hbox; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Button; @@ -10,7 +9,6 @@ import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.scene.text.Text; import main.Level; @@ -34,15 +32,15 @@ public class LevelSurround extends Pane Text title = new Text(); title.setText(level.title); title.setFill(Color.WHITE); - title.setFont(new Font(50)); + title.setStyle("-fx-font-size: 30;"); - Text diff = new Text(); - diff.setText(diff2); - diff.setFill(Color.WHITE); + Text artist = new Text(); + artist.setText(level.aritst+" - "+diff2); + artist.setFill(Color.WHITE); VBox titleTextBox = new VBox(); titleTextBox.setAlignment(Pos.TOP_RIGHT); - titleTextBox.getChildren().addAll(title,diff); + titleTextBox.getChildren().addAll(title, artist); BorderPane topBar = new BorderPane(); topBar.setLeft(buttonBox); @@ -57,7 +55,7 @@ public class LevelSurround extends Pane Text score = new Text(); score.setText("100000"); score.setFill(Color.WHITE); - score.setFont(new Font(50)); + score.setStyle("-fx-font-size: 50;"); VBox scoreTextBox = new VBox(); scoreTextBox.setAlignment(Pos.BOTTOM_LEFT); @@ -72,7 +70,7 @@ public class LevelSurround extends Pane Text combo = new Text(); combo.setText("100000"); combo.setFill(Color.WHITE); - combo.setFont(new Font(50)); + combo.setStyle("-fx-font-size: 50;"); VBox comboTextBox = new VBox(); comboTextBox.setAlignment(Pos.BOTTOM_RIGHT); @@ -80,8 +78,8 @@ public class LevelSurround extends Pane comboTextBox.setPadding(new Insets(10)); Pane game = new Pane(); - game.prefWidthProperty().bind(super.prefHeightProperty().multiply(0.66)); - game.prefHeightProperty().bind(super.prefHeightProperty()); + game.minWidthProperty().bind(super.prefHeightProperty().multiply(0.66)); + game.minHeightProperty().bind(super.prefHeightProperty()); game.getStyleClass().add("textBox"); HBox centerBox = new HBox(); diff --git a/src/gui/MainMenu.java b/src/gui/MainMenu.java index f3cd75d..347ab3c 100644 --- a/src/gui/MainMenu.java +++ b/src/gui/MainMenu.java @@ -7,7 +7,6 @@ import javafx.scene.effect.DropShadow; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.scene.text.Text; public class MainMenu extends Pane @@ -21,7 +20,7 @@ public class MainMenu extends Pane Text title = new Text(); title.setText("NPE Hero"); - title.setFont(new Font(125)); + title.setStyle("-fx-font-size: 125;"); title.setEffect(dropShadow); title.setFill(Color.WHITE); @@ -37,8 +36,12 @@ public class MainMenu extends Pane leaderboard.setText("Leaderboard"); leaderboard.setOnAction(e -> Driver.setMenu(new Leaderboard())); + Button exit = new Button(); + exit.setText("Quit"); + exit.setOnAction(e -> Driver.quit()); + VBox buttonBox = new VBox(); - buttonBox.getChildren().addAll(play, settings, leaderboard); + buttonBox.getChildren().addAll(play, settings, leaderboard, exit); buttonBox.setAlignment(Pos.CENTER); buttonBox.setSpacing(10); diff --git a/src/gui/Settings.java b/src/gui/Settings.java index c89953f..6e7e578 100644 --- a/src/gui/Settings.java +++ b/src/gui/Settings.java @@ -3,6 +3,8 @@ package gui; import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.Slider; +import javafx.scene.control.Toggle; +import javafx.scene.control.ToggleButton; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; @@ -29,9 +31,16 @@ public class Settings extends Pane sfxVol.setMax(100); sfxVol.setMin(0); + Button fullscreen = new Button(); + fullscreen.setText("Toggle Fullscreen (F11)"); + fullscreen.getStyleClass().remove("toggle-button"); + fullscreen.getStyleClass().add("button"); + fullscreen.getStyleClass().add("custom-radio-button"); + fullscreen.setOnAction(e -> Driver.primaryStage.setFullScreen(!Driver.primaryStage.isFullScreen())); + Button devMenu = new Button(); devMenu.setText("Debug Menu"); - devMenu.setOnAction(e -> Driver.setBackground("assets/trees.png")); + devMenu.setOnAction(e -> new DebugMenu()); Button exit = new Button(); exit.setText("Exit"); @@ -40,8 +49,9 @@ public class Settings extends Pane VBox options = new VBox(); options.setSpacing(10); options.setAlignment(Pos.CENTER); - options.getChildren().addAll(t1,musicVol,t2,sfxVol,devMenu,exit); - options.prefWidthProperty().bind(super.prefWidthProperty().multiply(0.25)); + options.getChildren().addAll(t1,musicVol,t2,sfxVol,fullscreen,devMenu,exit); + options.maxWidthProperty().bind(super.prefWidthProperty().multiply(0.25)); + options.setMinWidth(400); options.prefHeightProperty().bind(super.prefHeightProperty()); HBox rootBox = new HBox(); diff --git a/src/gui/SettingsController.java b/src/gui/SettingsController.java deleted file mode 100644 index 66da588..0000000 --- a/src/gui/SettingsController.java +++ /dev/null @@ -1,54 +0,0 @@ -package gui;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.FileWriter;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.json.simple.JSONObject;
-import org.json.simple.JSONArray;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-
-public class SettingsController
-{
- private int effectsVol;
- private int musicVol;
- private boolean fullscreen;
- private JSONObject settings;
-
- public void saveAndWrite(int newEffVol, int newMusVol, boolean isFull)
- {
-
- }
-
- public void readFile() throws ParseException
- {
- JSONParser jsonParser = new JSONParser(); //parser to read the file
-
- try(FileReader reader = new FileReader("settings.json"))
- {
- Object obj = jsonParser.parse(reader);
-
- settings = (JSONObject)(obj); //converts read object to a JSONObject
-
- effectsVol = (int) settings.get("effectsVol");
- musicVol = (int) settings.get("musicVol");
- fullscreen = (boolean) settings.get("fullscreen");
- }
- catch (FileNotFoundException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/src/gui/SongPlayer2.java b/src/gui/SongPlayer2.java deleted file mode 100644 index ed6476d..0000000 --- a/src/gui/SongPlayer2.java +++ /dev/null @@ -1,232 +0,0 @@ -/*Name: Guitar Hero Project - *Description: Contains the main game loop for gameplay - */ -package gui; - -import javafx.scene.control.Button; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Pane; - -import java.util.*; - -import fallTest.NoteField; -import fallTest.NoteInfo; -import fallTest.Score; -import fallTest.Timer; -//test -public class SongPlayer2 extends Pane -{ - Timer time = new Timer(); - - public static final int HEIGHT = 650; - public static final int LENGTH = 400; - - private final int BLENGTH = LENGTH/7; - private final int BHEIGHT = HEIGHT/20; - - Button d = new Button("D"); - Button f = new Button("F"); - Button space= new Button("..."); - Button j = new Button("J"); - Button k = new Button("K"); - - Queue<NoteInfo> dSends = new LinkedList<NoteInfo>(); //Queue that dictates when to send the notes - ArrayList<NoteField> dLane = new ArrayList<NoteField>(); //Array list containing all the notes currently on the field - ArrayList<Block> dVis = new ArrayList<Block>(); //Array list containing the visual representations of the notes in lanes - - Queue<NoteInfo> fSends = new LinkedList<NoteInfo>(); - ArrayList<NoteField> fLane = new ArrayList<NoteField>(); - ArrayList<Block> fVis = new ArrayList<Block>(); - - Queue<NoteInfo> spaceSends = new LinkedList<NoteInfo>(); - ArrayList<NoteField> spaceLane = new ArrayList<NoteField>(); - ArrayList<Block> spaceVis = new ArrayList<Block>(); - - Queue<NoteInfo> jSends = new LinkedList<NoteInfo>(); - ArrayList<NoteField> jLane = new ArrayList<NoteField>(); - ArrayList<Block> jVis = new ArrayList<Block>(); - - Queue<NoteInfo> kSends = new LinkedList<NoteInfo>(); - ArrayList<NoteField> kLane = new ArrayList<NoteField>(); - ArrayList<Block> kVis = new ArrayList<Block>(); - - Score score = new Score(); - - /** - * Establishes what the chart for the song is going to look like - */ - public void loadSong() { - dSends.add(new NoteInfo(4000)); - dSends.add(new NoteInfo(4333)); - dSends.add(new NoteInfo(4666)); - fSends.add(new NoteInfo(5000)); - kSends.add(new NoteInfo(5500)); - spaceSends.add(new NoteInfo(6000)); - jSends.add(new NoteInfo(6000)); - jSends.add(new NoteInfo(6250)); - dSends.add(new NoteInfo(6500)); - jSends.add(new NoteInfo(6750)); - spaceSends.add(new NoteInfo(7000)); - fSends.add(new NoteInfo(7500)); - jSends.add(new NoteInfo(7750)); - spaceSends.add(new NoteInfo(8000)); - fSends.add(new NoteInfo(8500)); - jSends.add(new NoteInfo(8500)); - dSends.add(new NoteInfo(9000)); - spaceSends.add(new NoteInfo(9000)); - kSends.add(new NoteInfo(9000)); - spaceSends.add(new NoteInfo(9500)); - - kSends.add(new NoteInfo(10000)); - dSends.add(new NoteInfo(10000)); - kSends.add(new NoteInfo(10333)); - fSends.add(new NoteInfo(10333)); - kSends.add(new NoteInfo(10666)); - spaceSends.add(new NoteInfo(10666)); - dSends.add(new NoteInfo(11000)); - spaceSends.add(new NoteInfo(11000)); - dSends.add(new NoteInfo(11333)); - jSends.add(new NoteInfo(11333)); - dSends.add(new NoteInfo(11666)); - kSends.add(new NoteInfo(11666)); - spaceSends.add(new NoteInfo(12000)); - } - - - /** - * Creates the GUI used to play the game - */ - public SongPlayer2() { - - // d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); //makes the button bounds for each button - // f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - // space.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - // j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - // k.setBounds(5*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); - // d.setFocusable(false); //makes it so you can't focus on the button - // f.setFocusable(false); - // space.setFocusable(false); - // j.setFocusable(false); - // k.setFocusable(false); - - - HBox bottom = new HBox(); - bottom.getChildren().add(d); //adds the buttons to the frame - bottom.getChildren().add(f); - bottom.getChildren().add(space); - bottom.getChildren().add(j); - bottom.getChildren().add(k); - super.getChildren().add(bottom); - //frame.setSize(LENGTH, HEIGHT); //sets the size of the frame - //frame.setLayout(null); - //frame.setVisible(true); //makes the frame visible - - - //while (true) { //TRY TO FIND A BETTER SOLUTION FOR THIS?? maybe something like sends.size() > 0 || lanes.size() > 0 - - // update(d, dSends, dLane, dVis, 'd', "dPress", 1); //updates the provided lane - // update(f, fSends, fLane, fVis, 'f', "fPress", 2); - // update(space, spaceSends, spaceLane, spaceVis, ' ', "spacePress", 3); - // update(j, jSends, jLane, jVis, 'j', "jPress", 4); - // update(k, kSends, kLane, kVis, 'k', "kPress", 5); - - // frame.repaint(); //updates the visuals every frame - - // try { - // Thread.sleep(10); //THIS IS PROBABLY NOT THE BEST WAY TO DO THIS - // } catch (InterruptedException e) - // { - // e.printStackTrace(); - // } - //} - } - - /** - * Updates a lane. An update involves: - * Checking to see if a note needs to be sent down a lane - * Checking to see if the user hit the button - * Checking to see if any notes have moved past the lane - * @param sends The sending queue for the given lane - * @param lane The place where note information is stored for notes currently in that lane - * @param vis The place where the visual representation for a note is stored in that lane - * @param key The button on the keyboard corresponding to the button for the lane being updated - * @param id The id for the action map - * @param k The lane number - */ - /* - private void update(JButton button, Queue<NoteInfo> sends, ArrayList<NoteField> lane, ArrayList<JButton> vis, char key, String id, int k) { - if (!sends.isEmpty() && sends.peek().getTime()-time.time()<3) { //checks if any notes in the queue need to be sent at this time - lane.add(new NoteField()); //adds that note's information to the lane list - - vis.add(new JButton()); //creates a visual representation of that note in the visualizer list - frame.add(vis.get(vis.size()-1)); - - sends.remove(); //removes the note just sent from the sending queue - } - - if (lane.size() > 0) { //if there are any notes in the lanes, tests for a button press - button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), id); //Input map and Action map setting - button.getActionMap().put(id, new AbstractAction() { //Defines what happens when the proper button is pressed - public void actionPerformed(ActionEvent e) - { - if (lane.size() > 0) { - int i = getClosestNote(lane); - int dist = (int)Math.abs(lane.get(i).goalDistance()); - - lane.remove(i); //removes the notes and visual representation from the playing field when the button is pressed - frame.remove(vis.get(i)); - vis.remove(i); - - if (dist > 2*BHEIGHT) { //Determines what to add to the score depending on the proximity of the note - score.miss(); - } - else if (dist > BHEIGHT) { - score.combo(); - score.close(); - } - else { - score.combo(); - score.perfect(); - } - - System.out.println("Score: " + score.getScore() + " Combo: " + score.getCombo()); - } - } - }); - } - - for (int i=0; i<lane.size(); i++) { //goes through every note on the field - lane.get(i).gameTick(); //moves every note down - vis.get(i).setBounds(k*BLENGTH, HEIGHT-lane.get(i).getY(), BLENGTH, BHEIGHT); - - if (lane.size() > 0 && lane.get(i).getFailed()) { //if the note has passed into the fail boundary, removes the note from the field - score.miss(); - System.out.println(score.getScore() + " Combo: " + score.getCombo()); - - - lane.remove(i); - frame.remove(vis.get(i)); - vis.remove(i); - - i--; - } - } - } - - /** - * Finds the note closest to the goal - * @return the location in the array list of the closest note - - private int getClosestNote(ArrayList<NoteField> searchLane) { - int pos = 0; - - for (int i=0; i<searchLane.size(); i++) { - if (Math.abs(searchLane.get(i).goalDistance()) < Math.abs(searchLane.get(pos).goalDistance())) { - pos = i; - } - } - - return pos; - } - */ -} diff --git a/src/gui/style.css b/src/gui/style.css index 957025f..267e96a 100644 --- a/src/gui/style.css +++ b/src/gui/style.css @@ -1,9 +1,17 @@ +/* global */ + +@import url('https://fonts.googleapis.com/css2?family=Space+Mono&display=swap'); +.root{ + /* -fx-font-size: 16pt; */ + -fx-font-family: "space mono"; + -fx-text-fill: white; +} + /* button */ Button { -fx-background-color: rgba(0, 0, 0, 0.5); -fx-text-fill: white; - /* -fx-padding: .5em; */ -fx-border-color: transparent; -fx-border-width: 3; -fx-border-radius: 5; @@ -16,10 +24,8 @@ Button:hover { } Button:focused { - /* -fx-background-color: rgb(255, 255, 255); */ -fx-background-color: rgb(50, 50, 50, 0.5); -fx-border-color: rgb(255, 255, 255); - /* -fx-text-fill: rgb(0, 0, 0); */ } Button:pressed { @@ -34,13 +40,16 @@ ListView { -fx-background-color: rgba(0, 0, 0, 0.5); -fx-background-radius: 5; -fx-padding: 5; - -fx-effect: none; + /* -fx-font-size: 15; */ + /* -fx-border-width: 3; + -fx-border-radius: 5; + -fx-border-color: transparent; */ } .list-cell { -fx-padding: .5em; -fx-background-color: transparent; - -fx-background-radius: 5; + -fx-background-radius: 3; -fx-text-fill: rgb(255, 255, 255); -fx-border-width: 3; -fx-border-radius: 5; @@ -52,7 +61,7 @@ ListView { } -.list-cell:focused { +ListView:focused .list-cell:focused { -fx-background-color: rgb(50, 50, 50, 0.5); -fx-border-color: rgb(255, 255, 255); } @@ -62,6 +71,23 @@ ListView { -fx-text-fill: rgb(0, 0, 0); } +.list-cell:pressed { + -fx-background-color: rgb(231, 231, 231); + -fx-border-color: transparent; +} + +.list-cell:empty { + -fx-background-color: transparent; + -fx-border-color: transparent; + -fx-text-fill: white; +} + +.unselectable .list-cell{ + -fx-background-color: transparent; + -fx-border-color: transparent; + -fx-text-fill: white; +} + /* slider */ Slider { @@ -99,25 +125,9 @@ Slider:focused .thumb{ -fx-border-color: rgb(231, 231, 231); } -/* text box */ - -.textBox { - -fx-background-radius: 5; - -fx-background-color: rgba(0, 0, 0, 0.5); - -fx-text-fill: white; -} - -.debug { - -fx-background-radius: 5; - -fx-background-color: rgba(255, 0, 0, 0.281); - -fx-border-color: red; - -fx-text-fill: white; - -fx-border-width: 20; -} - /* toggle button */ -ToggleButton { +.custom-radio-button { -fx-background-color: rgba(0, 0, 0, 0.5); -fx-text-fill: white; -fx-border-color: transparent; @@ -127,23 +137,92 @@ ToggleButton { -fx-background-radius: 5; } -ToggleButton:hover { +.custom-radio-button:hover { -fx-background-color: rgb(50, 50, 50, 0.5); } -ToggleButton:focused { +.custom-radio-button:focused { -fx-background-color: rgb(50, 50, 50, 0.5); -fx-border-color: rgb(255, 255, 255); } -ToggleButton:selected { +.custom-radio-button:selected { -fx-background-color: rgb(255, 255, 255); -fx-text-fill: rgb(0, 0, 0); } -ToggleButton:pressed { +.custom-radio-button:pressed { -fx-background-color: rgb(231, 231, 231); -fx-border-color: transparent; -fx-text-fill: rgb(0, 0, 0); -}
\ No newline at end of file +} + +/* scroll bars */ + +.scroll-bar:horizontal , +.scroll-bar:vertical{ + -fx-font-size: 5px; + -fx-background-color :transparent; + -fx-border-color :transparent; + -fx-background-radius : 0.0em; + -fx-border-radius :2.0em; +} + +.increment-button ,.decrement-button { + -fx-background-color:transparent; + -fx-border-color:transparent; +} + +/* .increment-button:hover , .decrement-button:hover { + -fx-background-color:derive(gray,100%); + -fx-border-color:derive(gray,80%); +}*/ + +.scroll-bar:horizontal .track , +.scroll-bar:vertical .track{ + -fx-background-color: rgba(0, 0, 0, 0.5); + -fx-background-radius: 5em; +} + +/* .scroll-bar:horizontal:hover .track , +.scroll-bar:horizontal:pressed .track , +.scroll-bar:vertical:hover .track, +.scroll-bar:vertical:pressed .track{ + -fx-background-color: derive(#434343,20%); + + -fx-opacity: 0.2; + -fx-background-radius: 0em; +} */ + +.scroll-bar:horizontal .thumb, +.scroll-bar:vertical .thumb { + -fx-background-color:white; + -fx-background-radius: 5em; + -fx-border-width: 0; + +} + +.scroll-bar .thumb:pressed { + -fx-background-color: rgb(231, 231, 231); +} + +/* text box */ + +.textBox { + -fx-background-radius: 5; + -fx-background-color: rgba(0, 0, 0, 0.5); + -fx-text-fill: white; +} + +/* debug */ + +.debug { + -fx-background-radius: 5; + -fx-background-color: rgba(255, 0, 0, 0.281); + -fx-border-color: red; + -fx-text-fill: white; + -fx-border-width: 20; +} + + |