diff options
| -rw-r--r-- | settings.json | 1 | ||||
| -rw-r--r-- | src/assets/backward.wav (renamed from src/assets/MenuBackward.wav) | bin | 34684 -> 34684 bytes | |||
| -rw-r--r-- | src/assets/forward.wav (renamed from src/assets/MenuForward.wav) | bin | 54992 -> 54992 bytes | |||
| -rw-r--r-- | src/assets/hit.wav (renamed from src/assets/Hitsound.wav) | bin | 34820 -> 34820 bytes | |||
| -rw-r--r-- | src/assets/miss.wav (renamed from src/assets/Miss.wav) | bin | 44144 -> 44144 bytes | |||
| -rw-r--r-- | src/assets/settings.json | 4 | ||||
| -rw-r--r-- | src/devmenu/DiffEditor.java | 7 | ||||
| -rw-r--r-- | src/gui/Driver.java | 29 | ||||
| -rw-r--r-- | src/gui/GameOver.java | 2 | ||||
| -rw-r--r-- | src/gui/Settings.java | 1 | ||||
| -rw-r--r-- | src/gui/style.css | 19 | ||||
| -rw-r--r-- | src/main/Difficulty.java | 52 | ||||
| -rw-r--r-- | src/main/Level.java | 55 | ||||
| -rw-r--r-- | src/main/ScoreController.java | 6 | ||||
| -rw-r--r-- | src/main/SettingsController.java | 50 | ||||
| -rw-r--r-- | src/main/SoundController.java | 28 | 
16 files changed, 139 insertions, 115 deletions
| diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..b7be92b --- /dev/null +++ b/settings.json @@ -0,0 +1 @@ +{"musicVol":1.0,"effectsVol":1.0}
\ No newline at end of file diff --git a/src/assets/MenuBackward.wav b/src/assets/backward.wavBinary files differ index e88f58d..e88f58d 100644 --- a/src/assets/MenuBackward.wav +++ b/src/assets/backward.wav diff --git a/src/assets/MenuForward.wav b/src/assets/forward.wavBinary files differ index c7b1a77..c7b1a77 100644 --- a/src/assets/MenuForward.wav +++ b/src/assets/forward.wav diff --git a/src/assets/Hitsound.wav b/src/assets/hit.wavBinary files differ index b9463a2..b9463a2 100644 --- a/src/assets/Hitsound.wav +++ b/src/assets/hit.wav diff --git a/src/assets/Miss.wav b/src/assets/miss.wavBinary files differ index d91a987..d91a987 100644 --- a/src/assets/Miss.wav +++ b/src/assets/miss.wav diff --git a/src/assets/settings.json b/src/assets/settings.json deleted file mode 100644 index 56e4a52..0000000 --- a/src/assets/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{
 -    "musicVol": 100,
 -    "effectsVol": 100,
 -}
\ No newline at end of file diff --git a/src/devmenu/DiffEditor.java b/src/devmenu/DiffEditor.java index bf745e8..727510d 100644 --- a/src/devmenu/DiffEditor.java +++ b/src/devmenu/DiffEditor.java @@ -4,7 +4,6 @@ import java.io.FileNotFoundException;  import java.io.UnsupportedEncodingException;  import gui.Driver; -import gui.LevelSelector;  import gui.LevelSurround;  import gui.MainMenu;  import javafx.scene.Scene; @@ -39,6 +38,9 @@ public class DiffEditor          Text numBeatsLabel = new Text("Number of beats");          TextField numBeats = new TextField(diff.numBeats+""); +        Text priorityLabel = new Text("priority (lower first)"); +        TextField priority = new TextField(diff.priority+""); +          Button editNotes = new Button("Edit notes");          editNotes.setOnAction(e -> {              try { @@ -59,11 +61,12 @@ public class DiffEditor              diff.title = title.getText();              diff.bpm = Double.parseDouble(bpm.getText());              diff.numBeats = Integer.parseInt(numBeats.getText()); +            diff.priority = Integer.parseInt(priority.getText());              diff.writeMetadata();          });          VBox main = new VBox(); -        main.getChildren().addAll(folderNameLabel,folderName,titleLabel,title,bpmLabel,bpm,numBeatsLabel,numBeats,editNotes,editScores,playLevel,save); +        main.getChildren().addAll(folderNameLabel,folderName,titleLabel,title,bpmLabel,bpm,numBeatsLabel,numBeats,priorityLabel,priority,editNotes,editScores,playLevel,save);          Scene scene = new Scene(main);          primaryStage.setScene(scene);          primaryStage.show(); diff --git a/src/gui/Driver.java b/src/gui/Driver.java index b588b22..9e09860 100644 --- a/src/gui/Driver.java +++ b/src/gui/Driver.java @@ -14,28 +14,11 @@ import javafx.scene.layout.BackgroundPosition;  import javafx.scene.layout.BackgroundRepeat;  import javafx.scene.layout.BackgroundSize;  import javafx.scene.layout.Pane; -import javafx.scene.media.Media; -import javafx.scene.media.MediaPlayer; -import javafx.scene.media.MediaView;  import javafx.stage.Stage; -import javafx.util.Duration;  import main.LevelController;  import main.SettingsController;  import main.SoundController; - -import java.nio.file.Paths; - -import javax.sound.sampled.AudioFileFormat; - -// import javafx.scene.image.ImageView; -// import javafx.beans.property.Property; -// import javafx.util.Duration; -// import javafx.animation.KeyFrame; -// import javafx.animation.KeyValue; -// import javafx.animation.Timeline; -  import devmenu.DebugMenu; -import gameplay.SongPlayer;  public class Driver extends Application  @@ -63,8 +46,6 @@ public class Driver extends Application      @Override      public void start(Stage newPrimaryStage)      {    - -                  primaryStage = newPrimaryStage;          Scene primaryScene = new Scene(primaryPane, 800,600); @@ -116,16 +97,6 @@ public class Driver extends Application       */      public static void setBackground(String url) //replaces background with a new one      { -        // 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), diff --git a/src/gui/GameOver.java b/src/gui/GameOver.java index f5b46ec..8571d20 100644 --- a/src/gui/GameOver.java +++ b/src/gui/GameOver.java @@ -25,7 +25,7 @@ public class GameOver extends Pane      {          Text topText = new Text();          topText.setText("Level Complete"); -        topText.getStyleClass().add("t1"); +        topText.getStyleClass().add("t11");          Text levelName = new Text();          levelName.setText(level.getTitle()); diff --git a/src/gui/Settings.java b/src/gui/Settings.java index 2144e16..663353a 100644 --- a/src/gui/Settings.java +++ b/src/gui/Settings.java @@ -101,6 +101,7 @@ public class Settings extends Pane          Button exit = new Button();          exit.setText("Back");          exit.setOnAction(e -> { +            Driver.settingsController.write();              Driver.soundController.playSfx("backward");              Driver.setMenu(new MainMenu());          }); diff --git a/src/gui/style.css b/src/gui/style.css index 70dd775..09e164e 100644 --- a/src/gui/style.css +++ b/src/gui/style.css @@ -73,9 +73,9 @@ TableView {      -fx-background-color: transparent;      -fx-background-radius: 3;      -fx-text-background-color: rgb(255, 255, 255); -    -fx-border-width: 3; -    -fx-border-radius: 5; -    -fx-border-color: transparent; +    /* -fx-border-width: 3; */ +    /* -fx-border-radius: 5; */ +    /* -fx-border-color: transparent; */  }  .table-row-cell:hover { @@ -89,7 +89,7 @@ TableView:focused {  TableView:focused .list-cell:focused {      -fx-background-color: rgb(50, 50, 50, 0.5); -    -fx-border-color: rgb(255, 255, 255); +    /* -fx-border-color: rgb(255, 255, 255); */  }  .table-row-cell:selected { @@ -99,18 +99,18 @@ TableView:focused .list-cell:focused {  .table-row-cell:pressed {      -fx-background-color: rgb(231, 231, 231); -    -fx-border-color: transparent; +    /* -fx-border-color: transparent; */  }  .table-row-cell:empty {      -fx-background-color: transparent; -    -fx-border-color: transparent; +    /* -fx-border-color: transparent; */      -fx-text-background-color: white;  }  .unselectable .table-row-cell{      -fx-background-color: transparent; -    -fx-border-color: transparent; +    /* -fx-border-color: transparent; */      -fx-text-background-color: white;  } @@ -197,6 +197,11 @@ Slider:focused .thumb{      -fx-fill: white;  } +.t11 { +    -fx-font-size: 50; +    -fx-fill: black;  +} +  .t2 {      -fx-font-size: 30;      -fx-fill: white; diff --git a/src/main/Difficulty.java b/src/main/Difficulty.java index 7174c33..3dba47b 100644 --- a/src/main/Difficulty.java +++ b/src/main/Difficulty.java @@ -11,7 +11,7 @@ import org.json.simple.parser.JSONParser;  import javafx.collections.FXCollections;  import javafx.collections.ObservableList; -public class Difficulty +public class Difficulty implements Comparable<Difficulty>  {      public File thisDir;      public String title = "Unnamed"; @@ -21,6 +21,7 @@ public class Difficulty      public int numBeats;      public Level level;      public boolean isValid = false; +    public int priority = 0;      /**       * Creates a new Difficulty and gives it a file path @@ -88,9 +89,46 @@ public class Difficulty  			Object obj = jsonParser.parse(reader);   			JSONObject diffStuff = (JSONObject)(obj); //converts read object to a JSONObject -            title = (String) diffStuff.get("title"); -            bpm = Double.parseDouble(diffStuff.get("bpm")+""); -            numBeats = Integer.parseInt(diffStuff.get("numBeats")+""); +            if (diffStuff.containsKey("title")) +            { +                title = (String) diffStuff.get("title"); +            } +            else +            { +                System.err.println(file+" is missing properety title"); +                isValid = false; +            } + +            if (diffStuff.containsKey("bpm")) +            { +                bpm = Double.parseDouble(diffStuff.get("bpm")+""); +            } +            else +            { +                System.err.println(file+" is missing properety bpm"); +                isValid = false; +            } + +            if (diffStuff.containsKey("numBeats")) +            { +                numBeats = Integer.parseInt(diffStuff.get("numBeats")+""); +            } +            else +            { +                System.err.println(file+" is missing properety numBeats"); +                isValid = false; +            } + +            if (diffStuff.containsKey("priority")) +            { +                priority = Integer.parseInt(diffStuff.get("priority")+""); + +            } +            else +            { +                System.err.println(file+" is missing properety priority"); +                isValid = false; +            }  		}  		catch (Exception e)          { @@ -114,6 +152,7 @@ public class Difficulty              obj.put("title", title);              obj.put("bpm", bpm);              obj.put("numBeats", numBeats); +            obj.put("priority", priority);              obj.writeJSONString(fileWriter);              fileWriter.flush();          }  @@ -213,4 +252,9 @@ public class Difficulty      public String getTitle() {          return title;      } + +    @Override +    public int compareTo(Difficulty d) { +        return priority - d.priority; +    }  } diff --git a/src/main/Level.java b/src/main/Level.java index eb1d92c..79f70e1 100644 --- a/src/main/Level.java +++ b/src/main/Level.java @@ -1,6 +1,7 @@  package main;  import java.io.File; +import java.util.Collections;  import java.util.Comparator;  import javafx.collections.FXCollections; @@ -26,7 +27,7 @@ public class Level      private boolean isValid;      public Image preview; //optional -    public String desc = "No description"; +    public String desc;      public Image background; //optional      public Color[] colors = {Color.RED,Color.BLUE,Color.GREEN,Color.PURPLE,Color.YELLOW};//optional, have default colors      public File song; @@ -71,19 +72,11 @@ public class Level          {              background = new Image(new File(thisDir,"background.png").toURI().toString());          } -        else -        { -            System.out.println(thisDir+" is missing background.png, though it is not required"); -        }          if (new File(thisDir, "preview.png").exists())          {              preview = new Image(new File(thisDir,"preview.png").toURI().toString());          } -        else -        { -            System.out.println(thisDir+" is missing preview.png, though it is not required"); -        }          diffList = FXCollections.observableArrayList();          validDiffList = FXCollections.observableArrayList(); @@ -110,6 +103,8 @@ public class Level              isValid1 = false;          } +        Collections.sort(validDiffList); +        Collections.sort(diffList);          isValid = isValid1;      } @@ -120,18 +115,39 @@ public class Level      {          boolean isValid = true;          JSONParser jsonParser = new JSONParser(); //parser to read the file -		 -		try(FileReader reader = new FileReader(new File(thisDir, "metadata.json"))) +		File file = new File(thisDir, "metadata.json"); +		try(FileReader reader = new FileReader(file))  		{  			Object obj = jsonParser.parse(reader);   			JSONObject levelStuff = new JSONObject();  			levelStuff = (JSONObject)(obj); //converts read object to a JSONObject -            title = (String)(levelStuff.get("title")); -            artist = (String)(levelStuff.get("artist")); -            desc = (String)(levelStuff.get("desc")); +            if (levelStuff.containsKey("title")) +            { +                title = (String) levelStuff.get("title"); +            } +            else +            { +                System.err.println(file+" is missing properety title"); +                isValid = false; +            } -            if(( levelStuff).containsKey("color1")) //check for custom colors in a hexadecimal format +            if (levelStuff.containsKey("artist")) +            { +                artist = (String)(levelStuff.get("artist")); +            } +            else +            { +                System.err.println(file+" is missing properety aritst"); +                isValid = false; +            } + +            if (levelStuff.containsKey("desc")) +            { +                desc = (String) levelStuff.get("desc"); +            } + +            if(( levelStuff).containsKey("color1")) //check for custom colors in a hexadecimal format (zach was lazy for not checking all five colors but i will forgive him)              {                  colors = new Color[5]; @@ -141,10 +157,6 @@ public class Level                  colors[3] = Color.web((String)(levelStuff.get("color4")));                  colors[4] = Color.web((String)(levelStuff.get("color5")));              } -            else -            { -                colors = new Color[]{Color.RED,Color.BLUE,Color.GREEN,Color.PURPLE,Color.YELLOW}; -            }  		}  		catch (Exception e)   		{ @@ -166,7 +178,10 @@ public class Level              JSONObject obj = new JSONObject();              obj.put("title", title);              obj.put("artist", artist); -            obj.put("desc", desc); +            if (desc != null) +            { +                obj.put("desc", desc); +            }              obj.put("color1",colors[0].toString());              obj.put("color2",colors[1].toString());              obj.put("color3",colors[2].toString()); diff --git a/src/main/ScoreController.java b/src/main/ScoreController.java index 54dd960..2b76217 100644 --- a/src/main/ScoreController.java +++ b/src/main/ScoreController.java @@ -20,7 +20,7 @@ public class ScoreController{          score += 300*comboMultiplier;          scoreProperty.setValue(score+"");          comboProperty.setValue(combo +""); -        System.out.println("Perfect!"); +        // System.out.println("Perfect!");      }      /** @@ -31,7 +31,7 @@ public class ScoreController{          score += 100*comboMultiplier;          scoreProperty.setValue(score+"");          comboProperty.setValue(combo+""); -        System.out.println("Good"); +        // System.out.println("Good");      }      /** @@ -43,7 +43,7 @@ public class ScoreController{          comboMultiplier = 1;          scoreProperty.setValue(score+"");          comboProperty.setValue(combo+""); -        System.out.println("Miss"); +        // System.out.println("Miss");      }      /* diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java index 36fda40..b7b2cb9 100644 --- a/src/main/SettingsController.java +++ b/src/main/SettingsController.java @@ -1,57 +1,53 @@  package main;
  import java.io.FileWriter;
 -import java.io.FileNotFoundException;
 +import java.io.File;
  import java.io.FileReader;
  import java.io.IOException;
 -
  import org.json.simple.JSONObject;
  import org.json.simple.parser.JSONParser;
 -import org.json.simple.parser.ParseException;
 -
  import javafx.beans.property.SimpleDoubleProperty;
 -import javafx.beans.property.SimpleIntegerProperty;
  public class SettingsController 
  {
  	public SimpleDoubleProperty effectsVol = new SimpleDoubleProperty(1);
  	public SimpleDoubleProperty musicVol = new SimpleDoubleProperty(1);
 -	private JSONObject settings;
 +	private File file = new File("settings.json");
 +
 +	public SettingsController()
 +	{
 +		read();
 +	}
 -	public void read() throws ParseException
 +	public void read()
  	{
  		JSONParser jsonParser = new JSONParser(); //parser to read the file
 -		
 -		try(FileReader reader = new FileReader("settings.json"))
 +		try(FileReader reader = new FileReader(file))
  		{
  			Object obj = jsonParser.parse(reader); 
 -			
 +			JSONObject settings = new JSONObject();
  			settings = (JSONObject)(obj); //converts read object to a JSONObject
 -			effectsVol.set((double) settings.get("effectsVol"));
 -			musicVol.set((double) settings.get("musicVol"));
 +			effectsVol.set(Double.parseDouble(settings.get("effectsVol")+""));
 +			musicVol.set(Double.parseDouble(settings.get("musicVol")+""));
  		}
 -		catch (FileNotFoundException e) 
 -		{
 -			e.printStackTrace();
 -		} 
 -		catch (IOException e) 
 +		catch (Exception e) 
  		{
  			e.printStackTrace();
 -		}
 -				
 +		}		
  	}
 -	public void write(int newEffVol, int newMusVol)
 +	public void write()
  	{
 -		settings.put("musicVol", newMusVol);
 -		settings.put("effectsVol", newEffVol);
 -		try (FileWriter file = new FileWriter("settings.json")) 
 +		FileWriter fileWriter;
 +		try
  		{
 -            //write the settings JSONObject instance to the file
 -            file.write(settings.toJSONString()); 
 -            file.flush();
 - 
 +			fileWriter = new FileWriter(file);
 +			JSONObject obj = new JSONObject();
 +			obj.put("musicVol", musicVol.getValue());
 +			obj.put("effectsVol", effectsVol.getValue());
 +            obj.writeJSONString(fileWriter);
 +            fileWriter.flush();
          } 
  		catch (IOException e) {
              e.printStackTrace();
 diff --git a/src/main/SoundController.java b/src/main/SoundController.java index b3c6d23..c8e6c8a 100644 --- a/src/main/SoundController.java +++ b/src/main/SoundController.java @@ -11,15 +11,18 @@ public class SoundController  {      public MediaPlayer songMediaPlayer;      public MediaPlayer sfxMediaPlayer; -    private HashMap<String,File> presets = new HashMap<>(); +    private HashMap<String,MediaPlayer> effects = new HashMap<>();      private File mainMenuSong = new File("src/assets/fairyfountain.wav");      public SoundController()       { -        presets.put("forward", new File("src/assets/MenuForward.wav")); -        presets.put("backward", new File("src/assets/MenuBackward.wav")); -        presets.put("hit", new File("src/assets/Hitsound.wav")); -        presets.put("miss", new File("src/assets/Miss.wav")); +        effects.put("hit", new MediaPlayer(new Media(new File("src/assets/hit.wav").toURI().toString()))); +        effects.put("miss", new MediaPlayer(new Media(new File("src/assets/miss.wav").toURI().toString()))); +        effects.put("forward", new MediaPlayer(new Media(new File("src/assets/forward.wav").toURI().toString()))); +        effects.put("backward", new MediaPlayer(new Media(new File("src/assets/backward.wav").toURI().toString()))); +        effects.forEach((key,value) -> { +            value.volumeProperty().bind(Driver.settingsController.effectsVol); +        });          playMenuSong();      } @@ -50,20 +53,9 @@ public class SoundController          }      } -    public void playSfx(File sfxFile)  -    { -        if (sfxMediaPlayer != null) -        { -            sfxMediaPlayer.stop(); -        } -        Media sound = new Media(sfxFile.toURI().toString()); -        sfxMediaPlayer = new MediaPlayer(sound); -        sfxMediaPlayer.volumeProperty().bind(Driver.settingsController.effectsVol); //not working yet -        sfxMediaPlayer.play(); -    } -      public void playSfx(String preset)      { -        playSfx(presets.get(preset)); +        effects.get(preset).stop(); +        effects.get(preset).play();      }  }
\ No newline at end of file | 
