Skip to content

Commit

Permalink
Prepare for alpha release.
Browse files Browse the repository at this point in the history
  • Loading branch information
DC37 committed Dec 26, 2013
1 parent 1a38e5a commit fe352da
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 61 deletions.
2 changes: 1 addition & 1 deletion MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<children>
<HBox alignment="CENTER" prefHeight="55.9998779296875" prefWidth="100.0">
<children>
<ImageView fitHeight="28.0" fitWidth="80.0" pickOnBounds="true" preserveRatio="true">
<ImageView fx:id="optionsButton" fitHeight="28.0" fitWidth="80.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@sprites/OPTIONS.png" preserveRatio="false" smooth="false" />
</image>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Tasklist:
* Volume bars implemented (done - December 17, 2013)
* Save & Load songs (done - December 18, 2013)
* Loop button loops the song (done - December 18, 2013)
* End-of-File Behaviour fix
* Release to a smallish test group (v0.9 - **Alpha Release** - Scheduled December 25, 2013)
* End-of-File Behaviour fix (done - December 25, 2013)
* Release to a smallish test group (v0.9 - **Alpha Release** - December 25, 2013)
* Measure line numbers
* Staff extension lines
* Splash screen is actually a splash screen
Expand Down
10 changes: 1 addition & 9 deletions src/smp/SuperMarioPaint.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@
import java.net.MalformedURLException;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import smp.fx.SMPFXController;
import smp.fx.SplashScreen;
import smp.stateMachine.Settings;
Expand All @@ -37,7 +29,7 @@
* The GUI is primarily written with JavaFX2.2. <br>
* @author RehdBlob
* @since 2012.08.16
* @version 0.85
* @version 0.90
*/
public class SuperMarioPaint extends Application {

Expand Down
4 changes: 2 additions & 2 deletions src/smp/components/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class Values {

/** The current version number of the program. */
public static double VERSION = 0.85;
public static double VERSION = 0.90;

/** The number of instruments. */
public static int NUMINSTRUMENTS = 19;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class Values {
* The number of lines in the staff, by default. This number
* is typically 384.
*/
public static int DEFAULT_LINES_PER_SONG = 384;
public static int DEFAULT_LINES_PER_SONG = 400;

/** The default speed. */
public static int DEFAULT_TEMPO = 400;
Expand Down
60 changes: 40 additions & 20 deletions src/smp/components/controls/LoadButton.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package smp.components.controls;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.FileChooser;
import smp.components.general.ImagePushButton;
import smp.components.staff.Staff;
import smp.components.staff.sequences.StaffSequence;
import smp.fx.Dialog;
import smp.fx.SMPFXController;
import smp.stateMachine.StateMachine;

Expand Down Expand Up @@ -52,26 +55,43 @@ public void setStaff(Staff s) {

/** This loads the song. */
private void load() {
try {
String outputFile = SMPFXController.getSongName().getText();
outputFile = outputFile + ".txt";
FileInputStream f_in = new
FileInputStream (outputFile);
ObjectInputStream o_in = new
ObjectInputStream(f_in);
StaffSequence loaded = (StaffSequence) o_in.readObject();
theStaff.setSequence(loaded);
StateMachine.setTempo(loaded.getTempo());
theStaff.getControlPanel().updateCurrTempo();
theStaff.getNoteMatrix().redraw();
o_in.close();
f_in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
boolean cont = true;
if (StateMachine.isModified())
cont = Dialog.showYesNoDialog("The current song has been modified!\n"
+ "Load the song anyway?");
if (cont) {
try {
FileChooser f = new FileChooser();
f.setInitialDirectory(new File(System.getProperty("user.dir")));
File inputFile = f.showOpenDialog(null);
if (inputFile == null)
return;
FileInputStream f_in = new
FileInputStream (inputFile);
ObjectInputStream o_in = new
ObjectInputStream(f_in);
StaffSequence loaded = (StaffSequence) o_in.readObject();
theStaff.setSequence(loaded);
StateMachine.setTempo(loaded.getTempo());
theStaff.getControlPanel().updateCurrTempo();
theStaff.getNoteMatrix().redraw();
o_in.close();
f_in.close();
String fname = inputFile.getName();
try {
fname = fname.substring(0, fname.indexOf("."));
} catch (IndexOutOfBoundsException e) {

}
SMPFXController.getSongName().setText(fname);
StateMachine.setModified(false);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/smp/components/controls/MuteInstButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import smp.ImageIndex;
import smp.components.general.ImageRadioButton;
import smp.components.general.ImageToggleButton;
import smp.stateMachine.StateMachine;

Expand Down
4 changes: 1 addition & 3 deletions src/smp/components/controls/NewButton.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package smp.components.controls;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import smp.components.general.ImagePushButton;
Expand Down Expand Up @@ -63,6 +60,7 @@ private void newSong() {
if (cont) {
theStaff.setSequence(new StaffSequence());
theStaff.getNoteMatrix().redraw();
StateMachine.setModified(false);
}
}

Expand Down
21 changes: 14 additions & 7 deletions src/smp/components/controls/SaveButton.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package smp.components.controls;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -8,12 +9,13 @@

import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import smp.components.Values;
import smp.components.general.ImagePushButton;
import smp.components.staff.Staff;
import smp.components.staff.sequences.StaffNoteLine;
import smp.components.staff.sequences.StaffSequence;
import smp.fx.Dialog;
import smp.fx.SMPFXController;
import smp.stateMachine.StateMachine;

Expand All @@ -31,7 +33,7 @@ public class SaveButton extends ImagePushButton {
* Sort of hacky move here, but we're going to save a few songs
* in a different format, so this exists.
*/
private boolean saveTxt = true;
private boolean saveTxt = false;

/** This is the staff that we want to save a song from. */
private Staff theStaff;
Expand Down Expand Up @@ -70,7 +72,6 @@ private void save() {
} else {
saveTxt();
}
Dialog.showDialog("Song saved!");
}


Expand All @@ -81,18 +82,24 @@ private void save() {
*/
private void saveObject() {
try {
String outputFile = SMPFXController.getSongName().getText();
outputFile = outputFile + ".txt";
FileChooser f = new FileChooser();
f.setInitialDirectory(new File(System.getProperty("user.dir")));
f.setInitialFileName(SMPFXController.getSongName().getText());
f.getExtensionFilters().add(new ExtensionFilter(
"Text file", "*.txt"));
File outputFile = f.showSaveDialog(null);
if (outputFile == null)
return;
FileOutputStream f_out = new
FileOutputStream("./" + outputFile);
FileOutputStream(outputFile);
ObjectOutputStream o_out = new
ObjectOutputStream(f_out);
StaffSequence out = theStaff.getSequence();
out.setTempo(StateMachine.getTempo());
o_out.writeObject(out);
o_out.close();
f_out.close();

StateMachine.setModified(false);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down
5 changes: 2 additions & 3 deletions src/smp/components/staff/Staff.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import smp.components.staff.sequences.StaffNote;
import smp.components.staff.sequences.StaffNoteLine;
import smp.components.staff.sequences.StaffSequence;
import smp.components.staff.sounds.SMPSequencer;
import smp.fx.SMPFXController;
import smp.stateMachine.Settings;
import smp.stateMachine.StateMachine;
Expand Down Expand Up @@ -388,13 +387,13 @@ class AnimationTask extends Task<Staff> {
protected Staff call() throws Exception {
playBars = staffImages.getPlayBars();
currMeasureLine = StateMachine.getMeasureLineNum();
int counter = 0;
int counter = currMeasureLine;
do {
playNextLine();
counter++;
if (counter % Values.NOTELINES_IN_THE_WINDOW == 0)
currMeasureLine += Values.NOTELINES_IN_THE_WINDOW;
if (counter % 4 == 0 && counter >= lastLine) {
if (counter % 4 == 0 && counter > lastLine) {
if (StateMachine.isLoopPressed()) {
currMeasureLine = 0;
counter = 0;
Expand Down
7 changes: 6 additions & 1 deletion src/smp/components/staff/StaffInstrumentEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,15 @@ private void placeNote(InstrumentIndex theInd) {
theStaffNote.setImage(
ImageLoader.getSpriteFX(
theInd.imageIndex()));
} else {
} else if (mute) {
theStaffNote.setImage(
ImageLoader.getSpriteFX(
theInd.imageIndex().alt()));
} else if (muteA) {
theStaffNote.setImage(
ImageLoader.getSpriteFX(
theInd.imageIndex().silhouette()));
} else if (muteA) {
}

accidental = new StaffAccidental(theStaffNote);
Expand Down
39 changes: 27 additions & 12 deletions src/smp/fx/Dialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;

/**
* Generates a dialog box, depending on what we do.
Expand All @@ -27,17 +24,36 @@ public class Dialog {

/**
* Shows a dialog box with the text given to this method.
* @param s The text to show.
* @param txt The text to show.
*/
public static void showDialog(String s) {
Stage dialog = new Stage();
public static void showDialog(String txt) {
final Stage dialog = new Stage();
dialog.setHeight(150);
dialog.setWidth(250);
dialog.setResizable(false);
dialog.setHeight(100);
dialog.setWidth(100);
dialog.initStyle(StageStyle.UTILITY);
Scene scene = new Scene(new Group(new Text(10, 30, s)));
dialog.setScene(scene);
dialog.show();
Label label = new Label(txt);
Button okButton = new Button("OK");

okButton.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
dialog.close();
}

});

FlowPane pane = new FlowPane(10, 10);
pane.setAlignment(Pos.CENTER);
pane.getChildren().addAll(okButton);
VBox vBox = new VBox(10);
vBox.setAlignment(Pos.CENTER);
vBox.getChildren().addAll(label, pane);
Scene scene1 = new Scene(vBox);
dialog.setScene(scene1);
dialog.showAndWait();

}

/**
Expand Down Expand Up @@ -83,7 +99,6 @@ public void handle(ActionEvent event) {
Scene scene1 = new Scene(vBox);
dialog.setScene(scene1);
dialog.showAndWait();
System.out.println(choice);
return choice;
}

Expand Down

0 comments on commit fe352da

Please sign in to comment.