diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..96ee3d150326382031346a657760fffee06365d5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000000000000000000000000000000000..b3ab6717c65b26b2dc16f798ca0ac0a0ccc6ff56 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,20 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "java", + "mainClass": "Main", + "targetPath": "${workspaceFolder}/${workspaceFolderBasename}.jar", + "elements": [ + "${compileOutput}", + "${dependencies}" + ], + "problemMatcher": [], + "label": "java: exportjar:Random Step Creator", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7c03a5324c7c44fcffc47e69d89a9d29c5e528b4 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Random Step Creator.jar b/Random Step Creator.jar new file mode 100644 index 0000000000000000000000000000000000000000..da16a1b22d84e2d138e6d2a34b04e9f711d7c6d2 Binary files /dev/null and b/Random Step Creator.jar differ diff --git a/bin/AdjustBPMThread.class b/bin/AdjustBPMThread.class new file mode 100644 index 0000000000000000000000000000000000000000..cf744e486b3f1c936333ca05986ac2815f06aa2d Binary files /dev/null and b/bin/AdjustBPMThread.class differ diff --git a/bin/AdjustBPMWindow$1.class b/bin/AdjustBPMWindow$1.class new file mode 100644 index 0000000000000000000000000000000000000000..bbedd9468e1d08bdeb9b02309317c745846be12f Binary files /dev/null and b/bin/AdjustBPMWindow$1.class differ diff --git a/bin/AdjustBPMWindow$2.class b/bin/AdjustBPMWindow$2.class new file mode 100644 index 0000000000000000000000000000000000000000..536ce9ab15ba175199a0bd9a80447f5eb1070da1 Binary files /dev/null and b/bin/AdjustBPMWindow$2.class differ diff --git a/bin/AdjustBPMWindow$3.class b/bin/AdjustBPMWindow$3.class new file mode 100644 index 0000000000000000000000000000000000000000..f5f8c513e2c9a43933d45f00f3ed09e6a5508dca Binary files /dev/null and b/bin/AdjustBPMWindow$3.class differ diff --git a/bin/AdjustBPMWindow$4.class b/bin/AdjustBPMWindow$4.class new file mode 100644 index 0000000000000000000000000000000000000000..7c4a72784145325544d1481366e21ef287959b01 Binary files /dev/null and b/bin/AdjustBPMWindow$4.class differ diff --git a/bin/AdjustBPMWindow$ArrowKeyListener.class b/bin/AdjustBPMWindow$ArrowKeyListener.class new file mode 100644 index 0000000000000000000000000000000000000000..b4e80a681bbbbe239ec10014eec348dc880a17f2 Binary files /dev/null and b/bin/AdjustBPMWindow$ArrowKeyListener.class differ diff --git a/bin/AdjustBPMWindow$PlaySoundThread.class b/bin/AdjustBPMWindow$PlaySoundThread.class new file mode 100644 index 0000000000000000000000000000000000000000..d0d1e569dcdb3e228508d0ccb5436168be7b2c95 Binary files /dev/null and b/bin/AdjustBPMWindow$PlaySoundThread.class differ diff --git a/bin/AdjustBPMWindow$TimingThread.class b/bin/AdjustBPMWindow$TimingThread.class new file mode 100644 index 0000000000000000000000000000000000000000..732230fb1a44f7706d758b722751c20f0e29d5b0 Binary files /dev/null and b/bin/AdjustBPMWindow$TimingThread.class differ diff --git a/bin/AdjustBPMWindow$UpdateIconThread.class b/bin/AdjustBPMWindow$UpdateIconThread.class new file mode 100644 index 0000000000000000000000000000000000000000..daf4f4d513a12cd286515f1d8a6d8c148d2cda34 Binary files /dev/null and b/bin/AdjustBPMWindow$UpdateIconThread.class differ diff --git a/bin/AdjustBPMWindow.class b/bin/AdjustBPMWindow.class new file mode 100644 index 0000000000000000000000000000000000000000..e016fd3ad0b12353d2cc9296937e48789b568fa5 Binary files /dev/null and b/bin/AdjustBPMWindow.class differ diff --git a/bin/CalculateMeasureWindow$1.class b/bin/CalculateMeasureWindow$1.class new file mode 100644 index 0000000000000000000000000000000000000000..b9886f2255166cb076b915db123b69d99912bfc4 Binary files /dev/null and b/bin/CalculateMeasureWindow$1.class differ diff --git a/bin/CalculateMeasureWindow$2.class b/bin/CalculateMeasureWindow$2.class new file mode 100644 index 0000000000000000000000000000000000000000..593bda96f488529a78244d055b31a4e164b3f744 Binary files /dev/null and b/bin/CalculateMeasureWindow$2.class differ diff --git a/bin/CalculateMeasureWindow$3.class b/bin/CalculateMeasureWindow$3.class new file mode 100644 index 0000000000000000000000000000000000000000..e0307b78c1684e331eecce2941534941ac3fb911 Binary files /dev/null and b/bin/CalculateMeasureWindow$3.class differ diff --git a/bin/CalculateMeasureWindow.class b/bin/CalculateMeasureWindow.class new file mode 100644 index 0000000000000000000000000000000000000000..e7ee8b2ff2a264630ebcf45a253d8372584af14b Binary files /dev/null and b/bin/CalculateMeasureWindow.class differ diff --git a/bin/EditSongInfoWindow$1.class b/bin/EditSongInfoWindow$1.class new file mode 100644 index 0000000000000000000000000000000000000000..4986e1b32925660f7de325413d859baa940504b7 Binary files /dev/null and b/bin/EditSongInfoWindow$1.class differ diff --git a/bin/EditSongInfoWindow$2.class b/bin/EditSongInfoWindow$2.class new file mode 100644 index 0000000000000000000000000000000000000000..905d01817c2051921ac52961a21b95f220a87d67 Binary files /dev/null and b/bin/EditSongInfoWindow$2.class differ diff --git a/bin/EditSongInfoWindow$3.class b/bin/EditSongInfoWindow$3.class new file mode 100644 index 0000000000000000000000000000000000000000..d9ab536590599441381731621c23b7d4f7ef85b4 Binary files /dev/null and b/bin/EditSongInfoWindow$3.class differ diff --git a/bin/EditSongInfoWindow$4.class b/bin/EditSongInfoWindow$4.class new file mode 100644 index 0000000000000000000000000000000000000000..3ae28f7faa6ed709e522a372b340a0b7ee3c8c6e Binary files /dev/null and b/bin/EditSongInfoWindow$4.class differ diff --git a/bin/EditSongInfoWindow$5.class b/bin/EditSongInfoWindow$5.class new file mode 100644 index 0000000000000000000000000000000000000000..ee6a9f9a4ccc023253511c654b9c4ccf03e08335 Binary files /dev/null and b/bin/EditSongInfoWindow$5.class differ diff --git a/bin/EditSongInfoWindow.class b/bin/EditSongInfoWindow.class new file mode 100644 index 0000000000000000000000000000000000000000..1c405b1fec07b7904bc44fb695b80a1401dd4890 Binary files /dev/null and b/bin/EditSongInfoWindow.class differ diff --git a/bin/IntegerOverflowException.class b/bin/IntegerOverflowException.class new file mode 100644 index 0000000000000000000000000000000000000000..851c7a6ff1fedef245f2983baaab3c2cff584264 Binary files /dev/null and b/bin/IntegerOverflowException.class differ diff --git a/bin/InvalidPercentageException.class b/bin/InvalidPercentageException.class new file mode 100644 index 0000000000000000000000000000000000000000..de8f77a49d8553f55aa1c282030ef2e4713c447e Binary files /dev/null and b/bin/InvalidPercentageException.class differ diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..fe22c6277a3055615255e8f4bbd64650d3199d57 Binary files /dev/null and b/bin/Main.class differ diff --git a/bin/MainWindow$1.class b/bin/MainWindow$1.class new file mode 100644 index 0000000000000000000000000000000000000000..5ddd441fcead51d469e3c524a3529bdde7277035 Binary files /dev/null and b/bin/MainWindow$1.class differ diff --git a/bin/MainWindow$10.class b/bin/MainWindow$10.class new file mode 100644 index 0000000000000000000000000000000000000000..7ba49bc8c539d7a694ebccdb75bef7e80cf8026b Binary files /dev/null and b/bin/MainWindow$10.class differ diff --git a/bin/MainWindow$2.class b/bin/MainWindow$2.class new file mode 100644 index 0000000000000000000000000000000000000000..6293c8834ca1c95205f9496a31ce365421387db1 Binary files /dev/null and b/bin/MainWindow$2.class differ diff --git a/bin/MainWindow$3.class b/bin/MainWindow$3.class new file mode 100644 index 0000000000000000000000000000000000000000..8c02da5f2194bc20eb4e27478e9b1d0094e2d61d Binary files /dev/null and b/bin/MainWindow$3.class differ diff --git a/bin/MainWindow$4.class b/bin/MainWindow$4.class new file mode 100644 index 0000000000000000000000000000000000000000..6f59a2622a9cf70be8ca104c1105fab0feb5b45f Binary files /dev/null and b/bin/MainWindow$4.class differ diff --git a/bin/MainWindow$5.class b/bin/MainWindow$5.class new file mode 100644 index 0000000000000000000000000000000000000000..39d1976387e5a89b377466c3734c3adee3f22e0e Binary files /dev/null and b/bin/MainWindow$5.class differ diff --git a/bin/MainWindow$6.class b/bin/MainWindow$6.class new file mode 100644 index 0000000000000000000000000000000000000000..9c71d465b26fcdf184b10e61fca81163c5265a59 Binary files /dev/null and b/bin/MainWindow$6.class differ diff --git a/bin/MainWindow$7.class b/bin/MainWindow$7.class new file mode 100644 index 0000000000000000000000000000000000000000..34e9b718e3ddb97df427bd20b88cfc7a74e878a0 Binary files /dev/null and b/bin/MainWindow$7.class differ diff --git a/bin/MainWindow$8.class b/bin/MainWindow$8.class new file mode 100644 index 0000000000000000000000000000000000000000..f72ba2f3e5cfaa8feccb27f06a02f79732b76401 Binary files /dev/null and b/bin/MainWindow$8.class differ diff --git a/bin/MainWindow$9.class b/bin/MainWindow$9.class new file mode 100644 index 0000000000000000000000000000000000000000..eafee05539a87b6b669160e7a455d488fa4a96c6 Binary files /dev/null and b/bin/MainWindow$9.class differ diff --git a/bin/MainWindow$Difficulty.class b/bin/MainWindow$Difficulty.class new file mode 100644 index 0000000000000000000000000000000000000000..c4879ee049a15f6ae35f03bcf08b9bb11087dfda Binary files /dev/null and b/bin/MainWindow$Difficulty.class differ diff --git a/bin/MainWindow.class b/bin/MainWindow.class new file mode 100644 index 0000000000000000000000000000000000000000..290c539f50c8c64379a41a54337c4bc027eda09e Binary files /dev/null and b/bin/MainWindow.class differ diff --git a/bin/PercentageOverException.class b/bin/PercentageOverException.class new file mode 100644 index 0000000000000000000000000000000000000000..bb46ba260ea2680edd5b9d0ef8ba29a77fb7d468 Binary files /dev/null and b/bin/PercentageOverException.class differ diff --git a/bin/Uusi tekstiasiakirja.bat b/bin/Uusi tekstiasiakirja.bat new file mode 100644 index 0000000000000000000000000000000000000000..6efc1cd5c6ccc49889b1ed6b86ad52fdd13daf0d --- /dev/null +++ b/bin/Uusi tekstiasiakirja.bat @@ -0,0 +1,2 @@ +javac Main.java +pause \ No newline at end of file diff --git a/images/note.png b/images/note.png new file mode 100644 index 0000000000000000000000000000000000000000..69487768eacafd9170e7675fb5ab4ddf5f449147 Binary files /dev/null and b/images/note.png differ diff --git a/images/note_lit.png b/images/note_lit.png new file mode 100644 index 0000000000000000000000000000000000000000..4b4918fe1f9c331797711ead2ca04e74b39b4f40 Binary files /dev/null and b/images/note_lit.png differ diff --git a/images/notes.png b/images/notes.png new file mode 100644 index 0000000000000000000000000000000000000000..0b7834b2a04f9a5fd50d355cfce92d939d816558 Binary files /dev/null and b/images/notes.png differ diff --git a/images/notes_lit.png b/images/notes_lit.png new file mode 100644 index 0000000000000000000000000000000000000000..7f2d29daad9901172770ac0534b4d31d3cd96537 Binary files /dev/null and b/images/notes_lit.png differ diff --git a/lib/jaco-mp3-player-0.9.4.jar b/lib/jaco-mp3-player-0.9.4.jar new file mode 100644 index 0000000000000000000000000000000000000000..08b8e8f4664b5c9f902d60b05fc403bc22168d3c Binary files /dev/null and b/lib/jaco-mp3-player-0.9.4.jar differ diff --git a/puuttuvat toteutukset.txt b/puuttuvat toteutukset.txt new file mode 100644 index 0000000000000000000000000000000000000000..3517458f81fd1196e93d66e91562134b06f0d321 --- /dev/null +++ b/puuttuvat toteutukset.txt @@ -0,0 +1,3 @@ +-tyhjien säkeiden määrän laskeminen olemassaolevasta tiedostosta +-tietovirran analysointi (mp3, ogg) +-säkeiden puolittaminen/jakaminen (helpommat vaikeusasteet) \ No newline at end of file diff --git a/src/AdjustBPMThread.java b/src/AdjustBPMThread.java new file mode 100644 index 0000000000000000000000000000000000000000..8cd5a7f7ad91945aa25c14e07011b28c8fe88737 --- /dev/null +++ b/src/AdjustBPMThread.java @@ -0,0 +1,3 @@ +public class AdjustBPMThread extends Thread{ + +} diff --git a/src/AdjustBPMWindow.java b/src/AdjustBPMWindow.java new file mode 100644 index 0000000000000000000000000000000000000000..2d23dd21ea1b92860472619bdd139ffa2d47920b --- /dev/null +++ b/src/AdjustBPMWindow.java @@ -0,0 +1,488 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.SwingUtilities.*; +import javax.swing.border.Border; +import javax.sound.sampled.*; +import java.net.URL; +import java.security.Key; +import java.io.*; +import java.net.MalformedURLException; +import jaco.mp3.player.MP3Player; + +public class AdjustBPMWindow { + + JFrame adjustBPMWindow; + JLabel bpmTxt, offsetTxt, checkElement, delayMsTxt, delayNanoTxt, keyTimingTxt, keyTimingValTxt, keyTimingValTxt2, keyTimingValTxt3, fileNotFoundTxt; + JTextArea bpmTxtArea, offsetTxtArea; + JButton setButton, cancelButton, playButton, stopButton; + TimingThread thread1 = new TimingThread(); + PlaySoundThread thread2 = new PlaySoundThread(); + UpdateIconThread thread3 = new UpdateIconThread(); + boolean checkElementStopped = false, threadRunning = false; + int offsetus, offsetusInvert; + long g_correct_nanoTime, g_correctDelay; + Clip clip; + MP3Player player; + + public AdjustBPMWindow() { + + adjustBPMWindow = new JFrame(); + adjustBPMWindow.setVisible(false); + adjustBPMWindow.setBounds(MainWindow.ikkuna.getBounds().x+100, MainWindow.ikkuna.getBounds().y+100, 500, 400); + adjustBPMWindow.setLayout(null); + adjustBPMWindow.setResizable(false); + adjustBPMWindow.setTitle("Adjust BPM and Offset"); + adjustBPMWindow.setFocusable(true); + + checkElement = new JLabel(new ImageIcon("images/notes.png")); + checkElement.setVisible(true); + checkElement.setBounds(120, 80, 256, 64); + + delayMsTxt = new JLabel("Delay:"); + delayMsTxt.setVisible(true); + delayMsTxt.setBounds(120, 60, 256, 20); + + delayNanoTxt = new JLabel("Delay:"); + delayNanoTxt.setVisible(true); + delayNanoTxt.setBounds(120, 40, 256, 20); + + keyTimingTxt = new JLabel("Stopped"); + keyTimingTxt.setVisible(true); + keyTimingTxt.setBounds(10, 80, 256, 20); + + keyTimingValTxt = new JLabel("Correct Time"); + keyTimingValTxt.setVisible(false); + keyTimingValTxt.setBounds(10, 40, 256, 20); + + keyTimingValTxt2 = new JLabel("Time at Key Press"); + keyTimingValTxt2.setVisible(false); + keyTimingValTxt2.setBounds(10, 60, 256, 20); + + keyTimingValTxt3 = new JLabel("Result"); + keyTimingValTxt3.setVisible(true); + keyTimingValTxt3.setBounds(10, 100, 256, 20); + + playButton = new JButton("Play"); + playButton.setVisible(true); + playButton.setBounds(70, 180, 170, 30); + playButton.addKeyListener(new ArrowKeyListener()); + playButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + checkValues(); + checkElementStopped = false; + + keyTimingTxt.setText("Press Arrow Keys!"); + } + } + }); + + stopButton = new JButton("Stop"); + stopButton.setVisible(true); + stopButton.setBounds(240, 180, 170, 30); + stopButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + checkElementStopped = true; + player.stop(); + threadRunning = false; + + keyTimingTxt.setText("Stopped"); + keyTimingValTxt.setText("Correct Time"); + keyTimingValTxt2.setText("Time at key Press"); + keyTimingValTxt3.setText("Result"); + } + } + }); + + bpmTxt = new JLabel("BPM"); + bpmTxt.setVisible(true); + bpmTxt.setBounds(20, 220, 210, 20); + + bpmTxtArea = new JTextArea(MainWindow.mainBPM); + bpmTxtArea.setVisible(true); + bpmTxtArea.setBounds(20, 240, 210, 20); + bpmTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + offsetTxt = new JLabel("Offset"); + offsetTxt.setVisible(true); + offsetTxt.setBounds(250, 220, 210, 20); + + offsetTxtArea = new JTextArea(MainWindow.mainOffset); + offsetTxtArea.setVisible(true); + offsetTxtArea.setBounds(250, 240, 210, 20); + offsetTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + setButton = new JButton("Set"); + setButton.setVisible(true); + setButton.setBounds(20, 300, 210, 30); + setButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + try { + Double.parseDouble(bpmTxtArea.getText()); + Double.parseDouble(offsetTxtArea.getText()); + MainWindow.mainBPM = bpmTxtArea.getText(); + MainWindow.mainOffset = offsetTxtArea.getText(); + adjustBPMWindow.setVisible(false); + + int i = MainWindow.mainSongInfo.indexOf("#BPMS"); + String strStart; + String strEnd; + if (i == -1) { + + } + else { + //i += 12; + strStart = MainWindow.mainSongInfo.substring(0, i); + while (MainWindow.mainSongInfo.charAt(i) != ';') { + i++; + } + strEnd = MainWindow.mainSongInfo.substring(i); + MainWindow.mainSongInfo = strStart + "#BPMS:0.000=" + MainWindow.mainBPM + strEnd; + } + + i = MainWindow.mainSongInfo.indexOf("#OFFSET"); + if (i == -1) { + + } + else { + //i += 12; + strStart = MainWindow.mainSongInfo.substring(0, i); + while (MainWindow.mainSongInfo.charAt(i) != ';') { + i++; + } + strEnd = MainWindow.mainSongInfo.substring(i); + MainWindow.mainSongInfo = strStart + "#OFFSET=" + MainWindow.mainOffset + strEnd; + } + } + catch (NumberFormatException nfe) { + JOptionPane.showMessageDialog(null, "BPM and offset must be a float or an integer number", "Number format error", JOptionPane.ERROR_MESSAGE); + } + finally { + checkElementStopped = true; + player.stop(); + } + } + } + }); + + cancelButton = new JButton("Cancel"); + cancelButton.setVisible(true); + cancelButton.setBounds(250, 300, 210, 30); + cancelButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + adjustBPMWindow.setVisible(false); + checkElementStopped = true; + player.stop(); + } + } + }); + + fileNotFoundTxt = new JLabel(""); + fileNotFoundTxt.setVisible(true); + fileNotFoundTxt.setBounds(20, 20, 210, 20); + + adjustBPMWindow.add(bpmTxt); + adjustBPMWindow.add(bpmTxtArea); + adjustBPMWindow.add(offsetTxt); + adjustBPMWindow.add(offsetTxtArea); + adjustBPMWindow.add(checkElement); + adjustBPMWindow.add(delayMsTxt); + adjustBPMWindow.add(delayNanoTxt); + adjustBPMWindow.add(keyTimingTxt); + adjustBPMWindow.add(keyTimingValTxt); + adjustBPMWindow.add(keyTimingValTxt2); + adjustBPMWindow.add(keyTimingValTxt3); + adjustBPMWindow.add(playButton); + adjustBPMWindow.add(stopButton); + adjustBPMWindow.add(setButton); + adjustBPMWindow.add(cancelButton); + + adjustBPMWindow.revalidate(); + adjustBPMWindow.repaint(); + } + + void checkValues() { + try { + double bpm = Double.parseDouble(bpmTxtArea.getText()); + double offset = Double.parseDouble(offsetTxtArea.getText()); + offsetus = (int)(offset*1000000); + offsetusInvert = offsetus*-1; + + if (!threadRunning) { + threadRunning = true; + //System.out.println(offset); + //System.out.println(offsetus); + + thread1 = new TimingThread(); + thread1.start(); + thread2 = new PlaySoundThread(); + thread2.start(); + thread3 = new UpdateIconThread(); + thread3.start(); + + } + } + catch (NumberFormatException e) { + JOptionPane.showMessageDialog(null, "Invalid Input. Input must be positive integer number.\n\nSet 0 to empty fields.", "Number format error", JOptionPane.ERROR_MESSAGE); + } + } + + public static void busyWaitMicros(long micros){ + long waitUntil = System.nanoTime() + (micros * 1_000); + while(waitUntil > System.nanoTime()){ + ; + } + } + + private class ArrowKeyListener implements KeyListener { + + @Override + public void keyTyped(KeyEvent e) { + + switch (e.getKeyCode()) { + case KeyEvent.VK_LEFT: + System.out.println("Left Arrow Key Typed"); + break; + case KeyEvent.VK_RIGHT: + System.out.println("Right Arrow Key Typed"); + break; + case KeyEvent.VK_DOWN: + System.out.println("Down Arrow Key Typed"); + break; + case KeyEvent.VK_UP: + System.out.println("Up Arrow Key Typed"); + break; + default: + System.out.println("Other Key Typed"); + break; + } + + } + + @Override + public void keyPressed(KeyEvent e) { + + long correctNanoTime = g_correct_nanoTime/1_000_000; + long pressedNanoTime = System.nanoTime()/1_000_000; + long correctDelay = g_correctDelay/1_000_000; + long diff = pressedNanoTime - correctNanoTime; + long diffNeg; + keyTimingValTxt.setText("" + correctNanoTime); + keyTimingValTxt2.setText("" + pressedNanoTime); + + if (diff == 0) { + keyTimingValTxt3.setText("Exact!"); + } + else { + if (diff > correctDelay/2) { + diffNeg = correctDelay - diff; + keyTimingValTxt3.setText("" + diffNeg + " ms early"); + } + else { + keyTimingValTxt3.setText("" + diff + " ms late"); + } + } + + switch (e.getKeyCode()) { + case KeyEvent.VK_LEFT: + System.out.println("Left Arrow Key Pressed"); + keyTimingTxt.setText("Left"); + break; + case KeyEvent.VK_RIGHT: + System.out.println("Right Arrow Key Pressed"); + keyTimingTxt.setText("Right"); + break; + case KeyEvent.VK_DOWN: + System.out.println("Down Arrow Key Pressed"); + keyTimingTxt.setText("Down"); + break; + case KeyEvent.VK_UP: + System.out.println("Up Arrow Key Pressed"); + keyTimingTxt.setText("Up"); + break; + default: + System.out.println("Other Key Pressed"); + keyTimingTxt.setText("Other"); + break; + } + + } + + @Override + public void keyReleased(KeyEvent e) { + + switch (e.getKeyCode()) { + case KeyEvent.VK_LEFT: + System.out.println("Left Arrow Key Released"); + break; + case KeyEvent.VK_RIGHT: + System.out.println("Right Arrow Key Released"); + break; + case KeyEvent.VK_DOWN: + System.out.println("Down Arrow Key Released"); + break; + case KeyEvent.VK_UP: + System.out.println("Up Arrow Key Released"); + break; + default: + System.out.println("Other Key Released"); + break; + } + + } + + } + + private class TimingThread extends Thread { + + void updateTimings(int usec) { + long timeStart = System.nanoTime(); + long timeEnd = System.nanoTime(); + long timeDiff; + double realBPM; + + g_correct_nanoTime = timeStart; + busyWaitMicros(usec); + timeEnd = System.nanoTime(); + + timeDiff = timeEnd - timeStart; + g_correctDelay = timeDiff; + double timeDiffFloat = (double)timeDiff; + realBPM = (1000000000/timeDiffFloat)*60; + delayMsTxt.setText("Delay: " + timeDiff/1000000 + " ms; " + "Real BPM: " + realBPM); + delayNanoTxt.setText("Delay: " + timeDiff + " ns"); + + } + + void checkValuesForTiming() { + try { + double bpm = Double.parseDouble(bpmTxtArea.getText()); + double offset = Double.parseDouble(offsetTxtArea.getText()); + if (offsetus > 0) { + busyWaitMicros(offsetus); + } + + double bps = bpm / 60; + int uspb = (int)(1000000 / bps); + + while (!checkElementStopped) { + updateTimings(uspb); + } + } + catch (NumberFormatException e) { + JOptionPane.showMessageDialog(null, "Invalid Input. Input must be positive integer number.\n\nSet 0 to empty fields.", "Number format error", JOptionPane.ERROR_MESSAGE); + } + } + + public static void busyWaitMicros(long micros){ + long waitUntil = System.nanoTime() + (micros * 1_000); + while(waitUntil > System.nanoTime()){ + ; + } + } + + public void run() { + checkValuesForTiming(); + } + } + + private class UpdateIconThread extends Thread { + + void updateTestLabelPosition(int mspbHold, int mspbRel) { + + checkElement.setIcon(new ImageIcon("images/notes_lit.png")); + busyWaitMicros(mspbHold); + checkElement.setIcon(new ImageIcon("images/notes.png")); + busyWaitMicros(mspbRel); + } + + void checkValuesForIcon() { + try { + double bpm = Double.parseDouble(bpmTxtArea.getText()); + double offset = Double.parseDouble(offsetTxtArea.getText()); + if (offsetus > 0) { + busyWaitMicros(offsetus); + } + + double bps = bpm / 60; + //int mspb = (int)(1000 / bps); + int uspb = (int)(1000000 / bps); + //int mspbHold = 100; + int uspbHold = 100000; + if (uspb < 100000) { + uspbHold = uspb/2; + } + //int mspbRel = mspb - mspbHold; + int uspbRel = uspb - uspbHold; + + while (!checkElementStopped) { + updateTestLabelPosition(uspbHold, uspbRel); + } + } + catch (NumberFormatException e) { + JOptionPane.showMessageDialog(null, "Invalid Input. Input must be positive integer number.\n\nSet 0 to empty fields.", "Number format error", JOptionPane.ERROR_MESSAGE); + } + } + + public static void busyWaitMicros(long micros){ + long waitUntil = System.nanoTime() + (micros * 1_000); + while(waitUntil > System.nanoTime()){ + ; + } + } + public void run() { + checkValuesForIcon(); + } + } + + private class PlaySoundThread extends Thread { + + void playWave() { + try { + // Open an audio input stream. + //URL url = this.getClass().getClassLoader().getResource("bob.mp3"); + File f = new File("bob.wav"); + AudioInputStream audioIn = AudioSystem.getAudioInputStream(f.toURI().toURL()); + // Get a sound clip resource. + clip = AudioSystem.getClip(); + // Open audio clip and load samples from the audio input stream. + clip.open(audioIn); + clip.start(); + } catch (UnsupportedAudioFileException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (LineUnavailableException e) { + e.printStackTrace(); + } + } + + void playMp3() throws FileNotFoundException{ + player = new MP3Player(MainWindow.audioFile); + player.play(); + } + + public void run() { + //playWave(); + if (offsetus < 0) { + busyWaitMicros(offsetusInvert); + } + try{ + fileNotFoundTxt.setText(""); + playMp3(); + } + catch (FileNotFoundException e) { + fileNotFoundTxt.setText("File " + MainWindow.audioFile.getName() + " was not found"); + } + } + } +} diff --git a/src/CalculateMeasureWindow.java b/src/CalculateMeasureWindow.java new file mode 100644 index 0000000000000000000000000000000000000000..f399069c3009a7f0e53c9abb94f2fab50d8f4e8a --- /dev/null +++ b/src/CalculateMeasureWindow.java @@ -0,0 +1,159 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.SwingUtilities.*; +import javax.swing.border.Border; + +import java.io.FileReader; +import java.io.FileWriter; +import java.io.*; +import java.io.IOException; +import java.util.Random; +import java.util.Scanner; + +public class CalculateMeasureWindow { + + JFrame calculateMeasureWindow; + JLabel songLenTxt, songLenMinTxt, songLenSecTxt, bpmTxt, resultTxt; + JTextArea songLenMinTxtArea, songLenSecTxtArea, bpmTxtArea, resultTxtArea; + JButton calculateButton, setButton, cancelButton; + + public CalculateMeasureWindow() { + + calculateMeasureWindow = new JFrame(); + calculateMeasureWindow.setVisible(false); + calculateMeasureWindow.setBounds(100, 100, 500, 400); + calculateMeasureWindow.setLayout(null); + calculateMeasureWindow.setResizable(false); + calculateMeasureWindow.setTitle("Calculate Measures"); + + songLenTxt = new JLabel("Song Length", SwingConstants.CENTER); + songLenTxt.setVisible(true); + songLenTxt.setBounds(20, 30, 440, 20); + + songLenMinTxt = new JLabel("Minutes"); + songLenMinTxt.setVisible(true); + songLenMinTxt.setBounds(20, 60, 210, 20); + + songLenMinTxtArea = new JTextArea(); + songLenMinTxtArea.setVisible(true); + songLenMinTxtArea.setBounds(20, 80, 210, 20); + songLenMinTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + songLenSecTxt = new JLabel("Seconds"); + songLenSecTxt.setVisible(true); + songLenSecTxt.setBounds(250, 60, 210, 20); + + songLenSecTxtArea = new JTextArea(); + songLenSecTxtArea.setVisible(true); + songLenSecTxtArea.setBounds(250, 80, 210, 20); + songLenSecTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + bpmTxt = new JLabel("BPM", SwingConstants.CENTER); + bpmTxt.setVisible(true); + bpmTxt.setBounds(20, 120, 440, 20); + + bpmTxtArea = new JTextArea(); + bpmTxtArea.setVisible(true); + bpmTxtArea.setBounds(20, 140, 440, 20); + bpmTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + resultTxt = new JLabel("Measures", SwingConstants.CENTER); + resultTxt.setVisible(true); + resultTxt.setBounds(20, 220, 440, 20); + + resultTxtArea = new JTextArea(); + resultTxtArea.setVisible(true); + resultTxtArea.setBounds(20, 240, 450, 20); + + calculateButton = new JButton("Calculate"); + calculateButton.setVisible(true); + calculateButton.setBounds(70, 180, 340, 30); + calculateButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + checkValues(); + } + } + }); + + setButton = new JButton("Set"); + setButton.setVisible(true); + setButton.setBounds(20, 300, 210, 30); + setButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + MainWindow.msrTxtField.setText(resultTxtArea.getText()); + calculateMeasureWindow.setVisible(false); + } + } + }); + + cancelButton = new JButton("Cancel"); + cancelButton.setVisible(true); + cancelButton.setBounds(250, 300, 210, 30); + cancelButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + calculateMeasureWindow.setVisible(false); + } + } + }); + + calculateMeasureWindow.add(songLenTxt); + calculateMeasureWindow.add(songLenMinTxt); + calculateMeasureWindow.add(songLenMinTxtArea); + calculateMeasureWindow.add(songLenSecTxt); + calculateMeasureWindow.add(songLenSecTxtArea); + calculateMeasureWindow.add(bpmTxt); + calculateMeasureWindow.add(bpmTxtArea); + calculateMeasureWindow.add(resultTxt); + calculateMeasureWindow.add(resultTxtArea); + calculateMeasureWindow.add(calculateButton); + calculateMeasureWindow.add(setButton); + calculateMeasureWindow.add(cancelButton); + + calculateMeasureWindow.revalidate(); + calculateMeasureWindow.repaint(); + } + + void checkValues() { + try { + int lenMin = Integer.parseInt(songLenMinTxtArea.getText()); + int lenSec = Integer.parseInt(songLenSecTxtArea.getText()); + int bpm = Integer.parseInt(bpmTxtArea.getText()); + + if (lenMin < 0 || lenSec < 0 || bpm < 0) { + throw new NumberFormatException(); + } + else { + calculateMeasures(lenMin, lenSec, bpm); + } + } + catch (NumberFormatException e) { + JOptionPane.showMessageDialog(null, "Invalid Input. Input must be positive integer number.\n\nSet 0 to empty fields.", "Number format error", JOptionPane.ERROR_MESSAGE); + } + } + + void calculateMeasures(int min, int sec, int bpm) { + try { + double result = 0; + int resultInt = 0; + double timeinMinutes = (double)min + (double)sec / 60; + double beatCount = timeinMinutes * bpm; + result = beatCount / 4; + resultInt = (int)result; + resultTxtArea.setText("" + resultInt); + if (resultInt > 2147483646) { + throw new IntegerOverflowException(); + } + } + catch (IntegerOverflowException e) { + JOptionPane.showMessageDialog(null, "Error: Overflow.", "Integer overflow error", JOptionPane.ERROR_MESSAGE); + } + } +} diff --git a/src/EditSongInfoWindow.java b/src/EditSongInfoWindow.java new file mode 100644 index 0000000000000000000000000000000000000000..1cb7df59e657d3059e3ec09aa4ced7cca9875f57 --- /dev/null +++ b/src/EditSongInfoWindow.java @@ -0,0 +1,766 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.SwingUtilities.*; +import javax.swing.border.Border; + +import java.io.FileReader; +import java.io.FileWriter; +import java.io.*; +import java.io.IOException; +import java.util.Random; +import java.util.Scanner; + +public class EditSongInfoWindow { + + JFrame editTextWindow, editTextWindowSimple; + JLabel edit, colorInfo, colorInfo2, colorInfo3, tip, tip2; + JTextArea editTextArea; + JButton okButton, cancelButton, editTextfileButton, okButtonSimple, cancelButtonSimple; + JScrollPane scrollableTxtPanel; + String songInfo; + + JLabel titleTxt, subtitleTxt, artistTxt, titletranslitTxt, subtitletranslitTxt, artisttranslitTxt, genreTxt, creditTxt, bannerTxt, backgroundTxt; + JTextArea titleTxtArea, subtitleTxtArea, artistTxtArea, titletranslitTxtArea, subtitletranslitTxtArea, artisttranslitTxtArea, genreTxtArea, creditTxtArea, bannerTxtArea, backgroundTxtArea; + String title, subtitle, artist, titletranslit, subtitletranslit, artisttranslit, genre, credit, banner, background; + JLabel lyricspathTxt, cdtitleTxt, musicTxt, offsetTxt, samplestartTxt, samplelengthTxt, lastbeatTxt, selectableTxt, bpmsTxt, stopsTxt, bgchangesTxt, keysoundsTxt; + JTextArea lyricspathTxtArea, cdtitleTxtArea, musicTxtArea, offsetTxtArea, samplestartTxtArea, samplelengthTxtArea, lastbeatTxtArea, selectableTxtArea, bpmsTxtArea, stopsTxtArea, bgchangesTxtArea, keysoundsTxtArea; + String lyricspath, cdtitle, music, offset, samplestart, samplelength, lastbeat, selectable, bpms, stops, bgchanges, keysounds; + + EditSongInfoWindow(String songData) { + + editTextWindow = new JFrame(); + editTextWindow.setVisible(false); + editTextWindow.setBounds(MainWindow.ikkuna.getBounds().x+100, MainWindow.ikkuna.getBounds().y+10, 500, 900); + editTextWindow.setLayout(null); + editTextWindow.setResizable(false); + editTextWindow.setTitle("Edit Song Info"); + + editTextWindowSimple = new JFrame(); + editTextWindowSimple.setVisible(false); + editTextWindowSimple.setBounds(editTextWindow.getBounds().x+20, editTextWindow.getBounds().y+100, 500, 560); + editTextWindowSimple.setLayout(null); + editTextWindowSimple.setResizable(false); + editTextWindowSimple.setTitle("Edit Song Info"); + + edit = new JLabel("Edit Song Info"); + edit.setBounds(20, 10, 460, 20); + edit.setVisible(true); + + editTextArea = new JTextArea(); + editTextArea.setBounds(20, 30, 440, 380); + editTextArea.setVisible(true); + editTextArea.setText(songData); + + scrollableTxtPanel = new JScrollPane(editTextArea); + scrollableTxtPanel.setBounds(20, 30, 440, 380); + scrollableTxtPanel.setVisible(true); + scrollableTxtPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollableTxtPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + //scrollableTxtPanel.add(editTextArea); + + + colorInfo = new JLabel("Red: Necessary"); + colorInfo.setBounds(20, 680, 460, 20); + colorInfo.setVisible(true); + + colorInfo2 = new JLabel("Blue: Important"); + colorInfo2.setBounds(20, 700, 460, 20); + colorInfo2.setVisible(true); + + colorInfo3 = new JLabel("Black: Non-essential"); + colorInfo3.setBounds(20, 720, 460, 20); + colorInfo3.setVisible(true); + + okButton = new JButton("OK"); + okButton.setBounds(20, 820, 210, 30); + okButton.setVisible(true); + okButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + saveSongInfo(); + editTextWindow.setVisible(false); + } + } + }); + + cancelButton = new JButton("Cancel"); + cancelButton.setBounds(250, 820, 210, 30); + cancelButton.setVisible(true); + cancelButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + editTextWindow.setVisible(false); + } + } + }); + + editTextfileButton = new JButton("Edit Text in File"); + editTextfileButton.setBounds(20, 780, 440, 30); + editTextfileButton.setVisible(true); + editTextfileButton.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + editTextWindow.setVisible(false); + editTextWindowSimple.setVisible(true); + } + } + }); + + tip = new JLabel("Tip: If you mess up the file, you can create a fresh one by selecting"); + tip.setBounds(20, 430, 440, 20); + tip.setVisible(true); + + tip2 = new JLabel("Create using audio file"); + tip2.setBounds(20, 450, 440, 20); + tip2.setVisible(true); + + okButtonSimple = new JButton("OK"); + okButtonSimple.setBounds(20, 480, 210, 30); + okButtonSimple.setVisible(true); + okButtonSimple.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + MainWindow.mainSongInfo = editTextArea.getText(); + setSongInfoValues(); + editTextWindow.setVisible(true); + editTextWindowSimple.setVisible(false); + } + } + }); + + cancelButtonSimple = new JButton("Cancel"); + cancelButtonSimple.setBounds(250, 480, 210, 30); + cancelButtonSimple.setVisible(true); + cancelButtonSimple.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + editTextWindow.setVisible(true); + editTextWindowSimple.setVisible(false); + } + } + }); + + + titleTxt = new JLabel("Title"); + titleTxt.setVisible(true); + titleTxt.setBounds(20, 20, 200, 20); + + titleTxtArea = new JTextArea(); + titleTxtArea.setVisible(true); + titleTxtArea.setBounds(20, 40, 200, 20); + titleTxtArea.setBorder(BorderFactory.createLineBorder(Color.red, 1, false)); + + subtitleTxt = new JLabel("Subitle"); + subtitleTxt.setVisible(true); + subtitleTxt.setBounds(20, 80, 200, 20); + + subtitleTxtArea = new JTextArea(); + subtitleTxtArea.setVisible(true); + subtitleTxtArea.setBounds(20, 100, 200, 20); + subtitleTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + artistTxt = new JLabel("Artist"); + artistTxt.setVisible(true); + artistTxt.setBounds(20, 140, 200, 20); + + artistTxtArea = new JTextArea(); + artistTxtArea.setVisible(true); + artistTxtArea.setBounds(20, 160, 200, 20); + artistTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + titletranslitTxt = new JLabel("Title Translit"); + titletranslitTxt.setVisible(true); + titletranslitTxt.setBounds(20, 200, 200, 20); + + titletranslitTxtArea = new JTextArea(); + titletranslitTxtArea.setVisible(true); + titletranslitTxtArea.setBounds(20, 220, 200, 20); + titletranslitTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + subtitletranslitTxt = new JLabel("Subitle Translit"); + subtitletranslitTxt.setVisible(true); + subtitletranslitTxt.setBounds(20, 260, 200, 20); + + subtitletranslitTxtArea = new JTextArea(); + subtitletranslitTxtArea.setVisible(true); + subtitletranslitTxtArea.setBounds(20, 280, 200, 20); + subtitletranslitTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + artisttranslitTxt = new JLabel("Artist Translit"); + artisttranslitTxt.setVisible(true); + artisttranslitTxt.setBounds(20, 320, 200, 20); + + artisttranslitTxtArea = new JTextArea(); + artisttranslitTxtArea.setVisible(true); + artisttranslitTxtArea.setBounds(20, 340, 200, 20); + artisttranslitTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + genreTxt = new JLabel("Genre"); + genreTxt.setVisible(true); + genreTxt.setBounds(20, 380, 200, 20); + + genreTxtArea = new JTextArea(); + genreTxtArea.setVisible(true); + genreTxtArea.setBounds(20, 400, 200, 20); + genreTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + creditTxt = new JLabel("Credit"); + creditTxt.setVisible(true); + creditTxt.setBounds(20, 440, 200, 20); + + creditTxtArea = new JTextArea(); + creditTxtArea.setVisible(true); + creditTxtArea.setBounds(20, 460, 200, 20); + creditTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + bannerTxt = new JLabel("Banner"); + bannerTxt.setVisible(true); + bannerTxt.setBounds(20, 500, 200, 20); + + bannerTxtArea = new JTextArea(); + bannerTxtArea.setVisible(true); + bannerTxtArea.setBounds(20, 520, 200, 20); + bannerTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + backgroundTxt = new JLabel("Background"); + backgroundTxt.setVisible(true); + backgroundTxt.setBounds(20, 560, 200, 20); + + backgroundTxtArea = new JTextArea(); + backgroundTxtArea.setVisible(true); + backgroundTxtArea.setBounds(20, 580, 200, 20); + backgroundTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + + lyricspathTxt = new JLabel("Lyrics Path"); + lyricspathTxt.setVisible(true); + lyricspathTxt.setBounds(20, 620, 200, 20); + + lyricspathTxtArea = new JTextArea(); + lyricspathTxtArea.setVisible(true); + lyricspathTxtArea.setBounds(20, 640, 200, 20); + lyricspathTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + cdtitleTxt = new JLabel("CD Title"); + cdtitleTxt.setVisible(true); + cdtitleTxt.setBounds(250, 20, 200, 20); + + cdtitleTxtArea = new JTextArea(); + cdtitleTxtArea.setVisible(true); + cdtitleTxtArea.setBounds(250, 40, 200, 20); + cdtitleTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + musicTxt = new JLabel("Music"); + musicTxt.setVisible(true); + musicTxt.setBounds(250, 80, 200, 20); + + musicTxtArea = new JTextArea(); + musicTxtArea.setVisible(true); + musicTxtArea.setBounds(250, 100, 200, 20); + musicTxtArea.setBorder(BorderFactory.createLineBorder(Color.red, 1, false)); + + offsetTxt = new JLabel("Offset"); + offsetTxt.setVisible(true); + offsetTxt.setBounds(250, 140, 200, 20); + + offsetTxtArea = new JTextArea(); + offsetTxtArea.setVisible(true); + offsetTxtArea.setBounds(250, 160, 200, 20); + offsetTxtArea.setBorder(BorderFactory.createLineBorder(Color.blue, 1, false)); + + samplestartTxt = new JLabel("Sample Start"); + samplestartTxt.setVisible(true); + samplestartTxt.setBounds(250, 200, 200, 20); + + samplestartTxtArea = new JTextArea(); + samplestartTxtArea.setVisible(true); + samplestartTxtArea.setBounds(250, 220, 200, 20); + samplestartTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + samplelengthTxt = new JLabel("Sample Length"); + samplelengthTxt.setVisible(true); + samplelengthTxt.setBounds(250, 260, 200, 20); + + samplelengthTxtArea = new JTextArea(); + samplelengthTxtArea.setVisible(true); + samplelengthTxtArea.setBounds(250, 280, 200, 20); + samplelengthTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + lastbeatTxt = new JLabel("Last Beat"); + lastbeatTxt.setVisible(true); + lastbeatTxt.setBounds(250, 320, 200, 20); + + lastbeatTxtArea = new JTextArea(); + lastbeatTxtArea.setVisible(true); + lastbeatTxtArea.setBounds(250, 340, 200, 20); + lastbeatTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + selectableTxt = new JLabel("Selectable"); + selectableTxt.setVisible(true); + selectableTxt.setBounds(250, 380, 200, 20); + + selectableTxtArea = new JTextArea(); + selectableTxtArea.setVisible(true); + selectableTxtArea.setBounds(250, 400, 200, 20); + selectableTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + bpmsTxt = new JLabel("BPM"); + bpmsTxt.setVisible(true); + bpmsTxt.setBounds(250, 440, 200, 20); + + bpmsTxtArea = new JTextArea(); + bpmsTxtArea.setVisible(true); + bpmsTxtArea.setBounds(250, 460, 200, 20); + bpmsTxtArea.setBorder(BorderFactory.createLineBorder(Color.blue, 1, false)); + + stopsTxt = new JLabel("Stops"); + stopsTxt.setVisible(true); + stopsTxt.setBounds(250, 500, 200, 20); + + stopsTxtArea = new JTextArea(); + stopsTxtArea.setVisible(true); + stopsTxtArea.setBounds(250, 520, 200, 20); + stopsTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + bgchangesTxt = new JLabel("Background Changes"); + bgchangesTxt.setVisible(true); + bgchangesTxt.setBounds(250, 560, 200, 20); + + bgchangesTxtArea = new JTextArea(); + bgchangesTxtArea.setVisible(true); + bgchangesTxtArea.setBounds(250, 580, 200, 20); + bgchangesTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + keysoundsTxt = new JLabel("Key Sounds"); + keysoundsTxt.setVisible(true); + keysoundsTxt.setBounds(250, 620, 200, 20); + + keysoundsTxtArea = new JTextArea(); + keysoundsTxtArea.setVisible(true); + keysoundsTxtArea.setBounds(250, 640, 200, 20); + keysoundsTxtArea.setBorder(BorderFactory.createLineBorder(Color.black, 1, false)); + + + + editTextWindowSimple.add(edit); + editTextWindowSimple.add(scrollableTxtPanel); + editTextWindowSimple.add(okButtonSimple); + editTextWindowSimple.add(cancelButtonSimple); + editTextWindowSimple.add(tip); + editTextWindowSimple.add(tip2); + + editTextWindow.add(okButton); + editTextWindow.add(cancelButton); + editTextWindow.add(editTextfileButton); + editTextWindow.add(colorInfo); + editTextWindow.add(colorInfo2); + editTextWindow.add(colorInfo3); + + editTextWindow.add(titleTxt); + editTextWindow.add(titleTxtArea); + editTextWindow.add(subtitleTxt); + editTextWindow.add(subtitleTxtArea); + editTextWindow.add(artistTxt); + editTextWindow.add(artistTxtArea); + editTextWindow.add(titletranslitTxt); + editTextWindow.add(titletranslitTxtArea); + editTextWindow.add(subtitletranslitTxt); + editTextWindow.add(subtitletranslitTxtArea); + editTextWindow.add(artisttranslitTxt); + editTextWindow.add(artisttranslitTxtArea); + editTextWindow.add(genreTxt); + editTextWindow.add(genreTxtArea); + editTextWindow.add(creditTxt); + editTextWindow.add(creditTxtArea); + editTextWindow.add(bannerTxt); + editTextWindow.add(bannerTxtArea); + editTextWindow.add(backgroundTxt); + editTextWindow.add(backgroundTxtArea); + editTextWindow.add(lyricspathTxt); + editTextWindow.add(lyricspathTxtArea); + editTextWindow.add(cdtitleTxt); + editTextWindow.add(cdtitleTxtArea); + editTextWindow.add(musicTxt); + editTextWindow.add(musicTxtArea); + editTextWindow.add(offsetTxt); + editTextWindow.add(offsetTxtArea); + editTextWindow.add(samplestartTxt); + editTextWindow.add(samplestartTxtArea); + editTextWindow.add(samplelengthTxt); + editTextWindow.add(samplelengthTxtArea); + editTextWindow.add(lastbeatTxt); + editTextWindow.add(lastbeatTxtArea); + editTextWindow.add(selectableTxt); + editTextWindow.add(selectableTxtArea); + editTextWindow.add(bpmsTxt); + editTextWindow.add(bpmsTxtArea); + editTextWindow.add(stopsTxt); + editTextWindow.add(stopsTxtArea); + editTextWindow.add(bgchangesTxt); + editTextWindow.add(bgchangesTxtArea); + editTextWindow.add(keysoundsTxt); + editTextWindow.add(keysoundsTxtArea); + + editTextWindow.revalidate(); + editTextWindow.repaint(); + + this.songInfo = songData; + + setSongInfoValues(); + } + + void setSongInfoValues() { + + int i = MainWindow.mainSongInfo.indexOf("#TITLE"); + if (i == -1) { + titleTxtArea.setText(""); + } + else { + i += 7; + title = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + title += MainWindow.mainSongInfo.charAt(i); + i++; + } + titleTxtArea.setText(title); + } + + i = MainWindow.mainSongInfo.indexOf("#SUBTITLE"); + if (i == -1){ + subtitleTxtArea.setText(""); + } + else { + i += 10; + subtitle = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + subtitle += MainWindow.mainSongInfo.charAt(i); + i++; + } + subtitleTxtArea.setText(subtitle); + } + + i = MainWindow.mainSongInfo.indexOf("#ARTIST"); + if (i == -1) { + artistTxtArea.setText(""); + } + else { + i += 8; + artist = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + artist += MainWindow.mainSongInfo.charAt(i); + i++; + } + artistTxtArea.setText(artist); + } + + i = MainWindow.mainSongInfo.indexOf("#TITLETRANSLIT"); + if (i == -1) { + titletranslitTxtArea.setText(""); + } + else { + i += 15; + titletranslit = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + titletranslit += MainWindow.mainSongInfo.charAt(i); + i++; + } + titletranslitTxtArea.setText(titletranslit); + } + + i = MainWindow.mainSongInfo.indexOf("#SUBTITLETRANSLIT"); + if (i == -1) { + subtitletranslitTxtArea.setText(""); + } + else { + i += 18; + subtitletranslit = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + subtitletranslit += MainWindow.mainSongInfo.charAt(i); + i++; + } + subtitletranslitTxtArea.setText(subtitletranslit); + } + + i = MainWindow.mainSongInfo.indexOf("#ARTISTTRANSLIT"); + if (i == -1) { + artisttranslitTxtArea.setText(""); + } + else { + i += 16; + artisttranslit = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + artisttranslit += MainWindow.mainSongInfo.charAt(i); + i++; + } + artisttranslitTxtArea.setText(artisttranslit); + } + + i = MainWindow.mainSongInfo.indexOf("#GENRE"); + if (i == -1) { + genreTxtArea.setText(""); + } + else { + i += 7; + genre = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + genre += MainWindow.mainSongInfo.charAt(i); + i++; + } + genreTxtArea.setText(genre); + } + + i = MainWindow.mainSongInfo.indexOf("#CREDIT"); + if (i == -1) { + creditTxtArea.setText(""); + } + else { + i += 8; + credit = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + credit += MainWindow.mainSongInfo.charAt(i); + i++; + } + creditTxtArea.setText(credit); + } + + i = MainWindow.mainSongInfo.indexOf("#BANNER"); + if (i == -1) { + bannerTxtArea.setText(""); + } + else { + i += 8; + banner = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + banner += MainWindow.mainSongInfo.charAt(i); + i++; + } + bannerTxtArea.setText(banner); + } + + i = MainWindow.mainSongInfo.indexOf("#BACKGROUND"); + if (i == -1) { + backgroundTxtArea.setText(""); + } + else { + i += 12; + background = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + background += MainWindow.mainSongInfo.charAt(i); + i++; + } + backgroundTxtArea.setText(background); + } + + i = MainWindow.mainSongInfo.indexOf("#LYRICSPATH"); + if (i == -1) { + lyricspathTxtArea.setText(""); + } + else { + i += 12; + lyricspath = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + lyricspath += MainWindow.mainSongInfo.charAt(i); + i++; + } + lyricspathTxtArea.setText(lyricspath); + } + + i = MainWindow.mainSongInfo.indexOf("#CDTITLE"); + if (i == -1) { + cdtitleTxtArea.setText(""); + } + else { + i += 9; + cdtitle = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + cdtitle += MainWindow.mainSongInfo.charAt(i); + i++; + } + cdtitleTxtArea.setText(cdtitle); + } + + i = MainWindow.mainSongInfo.indexOf("#MUSIC"); + if (i == -1) { + musicTxtArea.setText(""); + } + else { + i += 7; + music = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + music += MainWindow.mainSongInfo.charAt(i); + i++; + } + musicTxtArea.setText(music); + } + + i = MainWindow.mainSongInfo.indexOf("#OFFSET"); + if (i == -1) { + offsetTxtArea.setText(""); + } + else { + i += 8; + offset = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + offset += MainWindow.mainSongInfo.charAt(i); + i++; + } + offsetTxtArea.setText(offset); + } + + i = MainWindow.mainSongInfo.indexOf("#SAMPLESTART"); + if (i == -1) { + samplelengthTxtArea.setText(""); + } + else { + i += 13; + samplestart = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + samplestart += MainWindow.mainSongInfo.charAt(i); + i++; + } + samplestartTxtArea.setText(samplestart); + } + + i = MainWindow.mainSongInfo.indexOf("#SAMPLELENGTH"); + if (i == -1) { + samplelengthTxtArea.setText(""); + } + else { + i += 14; + samplelength = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + samplelength += MainWindow.mainSongInfo.charAt(i); + i++; + } + samplelengthTxtArea.setText(samplelength); + } + + i = MainWindow.mainSongInfo.indexOf("#LASTBEAT"); + if (i == -1) { + lastbeatTxtArea.setText(""); + } + else { + i += 10; + lastbeat = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + lastbeat += MainWindow.mainSongInfo.charAt(i); + i++; + } + lastbeatTxtArea.setText(lastbeat); + } + + i = MainWindow.mainSongInfo.indexOf("#SELECTABLE"); + if (i == -1) { + selectableTxtArea.setText(""); + } + else { + i += 12; + selectable = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + selectable += MainWindow.mainSongInfo.charAt(i); + i++; + } + selectableTxtArea.setText(selectable); + } + + i = MainWindow.mainSongInfo.indexOf("#BPMS"); + if (i == -1) { + bpmsTxtArea.setText(""); + } + else { + i += 6; + bpms = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + bpms += MainWindow.mainSongInfo.charAt(i); + i++; + } + bpmsTxtArea.setText(bpms); + } + + i = MainWindow.mainSongInfo.indexOf("#STOPS"); + if (i == -1) { + stopsTxtArea.setText(""); + } + else { + i += 7; + stops = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + stops += MainWindow.mainSongInfo.charAt(i); + i++; + } + stopsTxtArea.setText(stops); + } + + i = MainWindow.mainSongInfo.indexOf("#BGCHANGES"); + if (i == -1) { + bgchangesTxtArea.setText(""); + } + else { + i += 11; + bgchanges = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + bgchanges += MainWindow.mainSongInfo.charAt(i); + i++; + } + bgchangesTxtArea.setText(bgchanges); + } + + i = MainWindow.mainSongInfo.indexOf("#KEYSOUNDS"); + if (i == -1) { + keysoundsTxtArea.setText(""); + } + else { + i += 11; + keysounds = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + keysounds += MainWindow.mainSongInfo.charAt(i); + i++; + } + keysoundsTxtArea.setText(keysounds); + } + + //bpmsTxtArea.setText("0.000=" + MainWindow.mainBPM); + //offsetTxtArea.setText(MainWindow.mainOffset); + + saveSongInfo(); + } + + void saveSongInfo() { + MainWindow.mainSongInfo = + "#TITLE:" + titleTxtArea.getText() + ";\n" + + "#SUBTITLE:" + subtitleTxtArea.getText() + ";\n" + + "#ARTIST:" + artistTxtArea.getText() + ";\n" + + "#TITLETRANSLIT:" + titletranslitTxtArea.getText() + ";\n" + + "#SUBTITLETRANSLIT:" + subtitletranslitTxtArea.getText() + ";\n" + + "#ARTISTTRANSLIT:" + artisttranslitTxtArea.getText() + ";\n" + + "#GENRE:" + genreTxtArea.getText() + ";\n" + + "#CREDIT:" + creditTxtArea.getText() + ";\n" + + "#BANNER:" + bannerTxtArea.getText() + ";\n" + + "#BACKGROUND:" + backgroundTxtArea.getText() + ";\n" + + "#LYRICSPATH:" + lyricspathTxtArea.getText() + ";\n" + + "#CDTITLE:" + cdtitleTxtArea.getText() + ";\n" + + "#MUSIC:" + musicTxtArea.getText() + ";\n" + + "#OFFSET:" + offsetTxtArea.getText() + ";\n" + + "#SAMPLESTART:" + samplestartTxtArea.getText() + ";\n" + + "#SAMPLELENGTH:" + samplelengthTxtArea.getText() + ";\n" + + "#LASTBEAT:" + lastbeatTxtArea.getText() + ";\n" + + "#SELECTABLE:" + selectableTxtArea.getText() + ";\n" + + "#BPMS:" + bpmsTxtArea.getText() + ";\n" + + "#STOPS:" + stopsTxtArea.getText() + ";\n" + + "#BGCHANGES:" + bgchangesTxtArea.getText() + ";\n" + + "#KEYSOUNDS:" + keysoundsTxtArea.getText() + ";\n"; + MainWindow.mainBPM = bpmsTxtArea.getText().substring(6); + MainWindow.mainOffset = offsetTxtArea.getText(); + } + + String getSongInfo() { + return songInfo; + } +} diff --git a/src/IntegerOverflowException.java b/src/IntegerOverflowException.java new file mode 100644 index 0000000000000000000000000000000000000000..be3dd4d188ec880e34837db451a7e51100208c11 --- /dev/null +++ b/src/IntegerOverflowException.java @@ -0,0 +1,3 @@ +public class IntegerOverflowException extends Exception{ + +} diff --git a/src/InvalidPercentageException.java b/src/InvalidPercentageException.java new file mode 100644 index 0000000000000000000000000000000000000000..d4ba5406eff58e25fb78de120ac7b302a8246903 --- /dev/null +++ b/src/InvalidPercentageException.java @@ -0,0 +1,3 @@ +public class InvalidPercentageException extends Exception{ + +} diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..d3316cd7041eb4723bb205f9c01d1e3dae82e848 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + MainWindow.startMainWindow(); + } +} diff --git a/src/MainWindow.java b/src/MainWindow.java new file mode 100644 index 0000000000000000000000000000000000000000..80343f71554f3ab7448c6040ea3a34280bd93976 --- /dev/null +++ b/src/MainWindow.java @@ -0,0 +1,1469 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.SwingUtilities.*; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.*; +import java.io.IOException; +import java.util.Random; +import java.util.Scanner; + +public class MainWindow { + + static String mainSongInfo; + static String mainBPM; + static String mainOffset; + + static JFrame ikkuna; + static JLabel begEmptyTxt, msrTxt, endEmptyTxt; + static JTextArea begEmptyTxtField, msrTxtField, endEmptyTxtField; + static JButton create; + static JLabel difficultyTxt, difficultyNoTxt, creatorTxt; + static JList<String> difficulty; + static JTextArea difficultyNoTxtField, creatorTxtField; + static JLabel noFileSign; + + static JLabel beatsTxt, bStepsTxt, bStepsPcentTxt, bJumpsTxt, bJumpsPcentTxt, bHoldsTxt, bHoldsPcentTxt, bMinesTxt, bMinesPcentTxt; + static JLabel halfBeatsTxt, hbStepsTxt, hbStepsPcentTxt, hbJumpsTxt, hbJumpsPcentTxt, hbHoldsTxt, hbHoldsPcentTxt, hbMinesTxt, hbMinesPcentTxt; + static JLabel quarterBeatsTxt, qbStepsTxt, qbStepsPcentTxt, qbJumpsTxt, qbJumpsPcentTxt, qbHoldsTxt, qbHoldsPcentTxt, qbMinesTxt, qbMinesPcentTxt; + static JCheckBox bStepsEnabled, bJumpsEnabled, bHoldsEnabled, bMinesEnabled, hbStepsEnabled, hbJumpsEnabled, hbHoldsEnabled, hbMinesEnabled, qbStepsEnabled, qbJumpsEnabled, qbHoldsEnabled, qbMinesEnabled; + static JTextArea bStepsPcentTxtField, bJumpsPcentTxtField, bHoldsPcentTxtField, bMinesPcentTxtField, hbStepsPcentTxtField, hbJumpsPcentTxtField, hbHoldsPcentTxtField, hbMinesPcentTxtField, qbStepsPcentTxtField, qbJumpsPcentTxtField, qbHoldsPcentTxtField, qbMinesPcentTxtField; + + static String[] difficulties = {"Beginner", "Easy", "Medium", "Hard", "Challenge", "Edit"}; + static String[] difficultiesShown = {"Beginner (Novice)", "Easy", "Medium", "Hard", "Challenge (Expert)", "Edit (Custon name)"}; + static int difficultyChoice; + static int difficultyNumber; + static short emptyMsrsBeginning, msrs, emptyMsrsEnd; + static byte stepPercentage, jumpPercentage, holdPercentage, minePercentage; + static byte halfStepPercentage, halfJumpPercentage, halfHoldPercentage, halfMinePercentage; + static byte quarterStepPercentage, quarterJumpPercentage, quarterHoldPercentage, quarterMinePercentage; + static String creator = "me"; + static String songInfo; + static String foundChartsInfo = ""; + static int foundCharts = 0; + static String[] chartData; + static String[] chartDataDifficultyInfo; + static int[] stepsInChart, jumpsInChart, handsInChart, minesInChart; + static String combinedStepfileData = "", combinedChartData = ""; + + static JMenuBar mb; + static JMenu file, edit, view, tools; + static JMenuItem open, createUsingAudioFile, saveFile; + static JMenuItem editSongInfo, calculateMeasures, adjustBPM; + static JMenuItem viewSongInfo, viewChartInfo; + + static File stepFile; + static File audioFile; + + String defaultEmptySongInfo = "#TITLE:;\n#SUBTITLE:;\n#ARTIST:;\n#TITLETRANSLIT:;\n#SUBTITLETRANSLIT:;\n#ARTISTTRANSLIT:;\n#CREDIT:;\n#BANNER:;\n#BACKGROUND:;\n#LYRICSPATH:;\n#CDTITLE:;\n#MUSIC:;\n#OFFSET:;\n#SAMPLESTART:;\n#SAMPLELENGTH:;\n#LASTBEAT:;\n#SELECTABLE:YES;\n#BPMS:0.000=;\n#STOPS:;\n#BGCHANGES:;"; + + public static void startMainWindow() { + + ikkuna = new JFrame(); + ikkuna.setVisible(true); + ikkuna.setBounds(100, 100, 800, 600); + ikkuna.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + ikkuna.setLayout(null); + ikkuna.setTitle("Random Step Creator"); + ikkuna.setBackground(Color.GRAY); + ikkuna.setResizable(false); + + create = new JButton(); + create.setVisible(false); + create.setText("Create"); + create.setBounds(20, 500, 740, 50); + create.addMouseListener(new MouseAdapter() { + + public void mousePressed (MouseEvent e) { + if (!SwingUtilities.isRightMouseButton(e)) { + verifyValues(); + } + } + }); + + begEmptyTxt = new JLabel("Empty Measures in the Beginning", SwingConstants.CENTER); + begEmptyTxt.setVisible(false); + begEmptyTxt.setBounds(20, 40, 360, 20); + + begEmptyTxtField = new JTextArea(); + begEmptyTxtField.setVisible(false); + begEmptyTxtField.setBounds(20, 60, 360, 20); + begEmptyTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + + msrTxt = new JLabel("Measures", SwingConstants.CENTER); + msrTxt.setVisible(false); + msrTxt.setBounds(20, 100, 360, 20); + + msrTxtField = new JTextArea(); + msrTxtField.setVisible(false); + msrTxtField.setBounds(20, 120, 360, 20); + msrTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + + endEmptyTxt = new JLabel("Empty Measures in the End", SwingConstants.CENTER); + endEmptyTxt.setVisible(false); + endEmptyTxt.setBounds(20, 160, 360, 20); + + endEmptyTxtField = new JTextArea(); + endEmptyTxtField.setVisible(false); + endEmptyTxtField.setBounds(20, 180, 360, 20); + endEmptyTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + + difficultyTxt = new JLabel("Difficulty", SwingConstants.CENTER); + difficultyTxt.setVisible(false); + difficultyTxt.setBounds(20, 220, 360, 20); + + difficulty = new JList<String>(difficultiesShown); + difficulty.setVisible(false); + difficulty.setBounds(20, 240, 360, 110); + difficulty.setVisibleRowCount(5); + difficulty.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + difficulty.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + difficulty.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) {; + difficultyChoice = difficulty.getSelectedIndex(); + }; + }); + + difficultyNoTxt = new JLabel("Difficulty (Number)", SwingConstants.CENTER); + difficultyNoTxt.setVisible(false); + difficultyNoTxt.setBounds(20, 370, 360, 20); + + difficultyNoTxtField = new JTextArea(); + difficultyNoTxtField.setVisible(false); + difficultyNoTxtField.setBounds(20, 390, 360, 20); + difficultyNoTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + + creatorTxt = new JLabel("Creator (or Chart Name)", SwingConstants.CENTER); + creatorTxt.setVisible(false); + creatorTxt.setBounds(20, 430, 360, 20); + + creatorTxtField = new JTextArea(); + creatorTxtField.setVisible(false); + creatorTxtField.setBounds(20, 450, 360, 20); + creatorTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + + + + beatsTxt = new JLabel("Beats (Red Arrows)", SwingConstants.CENTER); + beatsTxt.setVisible(false); + beatsTxt.setBounds(410, 40, 280, 20); + + bStepsTxt = new JLabel("Steps: "); + bStepsTxt.setVisible(false); + bStepsTxt.setBounds(460, 60, 80, 20); + + bStepsEnabled = new JCheckBox(); + bStepsEnabled.setVisible(false); + bStepsEnabled.setBounds(520, 60, 20, 20); + bStepsEnabled.setSelected(true); + + bStepsPcentTxt = new JLabel("Percent: "); + bStepsPcentTxt.setVisible(false); + bStepsPcentTxt.setBounds(560, 60, 80, 20); + + bStepsPcentTxtField = new JTextArea(); + bStepsPcentTxtField.setVisible(false); + bStepsPcentTxtField.setBounds(640, 60, 80, 20); + bStepsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + bStepsPcentTxtField.setText("100"); + + bJumpsTxt = new JLabel("Jumps: "); + bJumpsTxt.setVisible(false); + bJumpsTxt.setBounds(460, 80, 80, 20); + + bJumpsEnabled = new JCheckBox(); + bJumpsEnabled.setVisible(false); + bJumpsEnabled.setBounds(520, 80, 20, 20); + bJumpsEnabled.setSelected(true); + + bJumpsPcentTxt = new JLabel("Percent: "); + bJumpsPcentTxt.setVisible(false); + bJumpsPcentTxt.setBounds(560, 80, 80, 20); + + bJumpsPcentTxtField = new JTextArea(); + bJumpsPcentTxtField.setVisible(false); + bJumpsPcentTxtField.setBounds(640, 80, 80, 20); + bJumpsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + bJumpsPcentTxtField.setText("0"); + + bHoldsTxt = new JLabel("Hands: "); + bHoldsTxt.setVisible(false); + bHoldsTxt.setBounds(460, 100, 80, 20); + + bHoldsEnabled = new JCheckBox(); + bHoldsEnabled.setVisible(false); + bHoldsEnabled.setBounds(520, 100, 20, 20); + bHoldsEnabled.setSelected(true); + + bHoldsPcentTxt = new JLabel("Percent: "); + bHoldsPcentTxt.setVisible(false); + bHoldsPcentTxt.setBounds(560, 100, 80, 20); + + bHoldsPcentTxtField = new JTextArea(); + bHoldsPcentTxtField.setVisible(false); + bHoldsPcentTxtField.setBounds(640, 100, 80, 20); + bHoldsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + bHoldsPcentTxtField.setText("0"); + + bMinesTxt = new JLabel("Mines: "); + bMinesTxt.setVisible(false); + bMinesTxt.setBounds(460, 120, 80, 20); + + bMinesEnabled = new JCheckBox(); + bMinesEnabled.setVisible(false); + bMinesEnabled.setBounds(520, 120, 20, 20); + bMinesEnabled.setSelected(true); + + bMinesPcentTxt = new JLabel("Percent: "); + bMinesPcentTxt.setVisible(false); + bMinesPcentTxt.setBounds(560, 120, 80, 20); + + bMinesPcentTxtField = new JTextArea(); + bMinesPcentTxtField.setVisible(false); + bMinesPcentTxtField.setBounds(640, 120, 80, 20); + bMinesPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + bMinesPcentTxtField.setText("0"); + + + halfBeatsTxt = new JLabel("Half Beats (Blue Arrows)", SwingConstants.CENTER); + halfBeatsTxt.setVisible(false); + halfBeatsTxt.setBounds(410, 160, 280, 20); + + hbStepsTxt = new JLabel("Steps: "); + hbStepsTxt.setVisible(false); + hbStepsTxt.setBounds(460, 180, 80, 20); + + hbStepsEnabled = new JCheckBox(); + hbStepsEnabled.setVisible(false); + hbStepsEnabled.setBounds(520, 180, 20, 20); + hbStepsEnabled.setSelected(true); + + hbStepsPcentTxt = new JLabel("Percent: "); + hbStepsPcentTxt.setVisible(false); + hbStepsPcentTxt.setBounds(560, 180, 80, 20); + + hbStepsPcentTxtField = new JTextArea(); + hbStepsPcentTxtField.setVisible(false); + hbStepsPcentTxtField.setBounds(640, 180, 80, 20); + hbStepsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + hbStepsPcentTxtField.setText("0"); + + hbJumpsTxt = new JLabel("Jumps: "); + hbJumpsTxt.setVisible(false); + hbJumpsTxt.setBounds(460, 200, 80, 20); + + hbJumpsEnabled = new JCheckBox(); + hbJumpsEnabled.setVisible(false); + hbJumpsEnabled.setBounds(520, 200, 20, 20); + hbJumpsEnabled.setSelected(true); + + hbJumpsPcentTxt = new JLabel("Percent: "); + hbJumpsPcentTxt.setVisible(false); + hbJumpsPcentTxt.setBounds(560, 200, 80, 20); + + hbJumpsPcentTxtField = new JTextArea(); + hbJumpsPcentTxtField.setVisible(false); + hbJumpsPcentTxtField.setBounds(640, 200, 80, 20); + hbJumpsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + hbJumpsPcentTxtField.setText("0"); + + hbHoldsTxt = new JLabel("Hands: "); + hbHoldsTxt.setVisible(false); + hbHoldsTxt.setBounds(460, 220, 80, 20); + + hbHoldsEnabled = new JCheckBox(); + hbHoldsEnabled.setVisible(false); + hbHoldsEnabled.setBounds(520, 220, 20, 20); + hbHoldsEnabled.setSelected(true); + + hbHoldsPcentTxt = new JLabel("Percent: "); + hbHoldsPcentTxt.setVisible(false); + hbHoldsPcentTxt.setBounds(560, 220, 80, 20); + + hbHoldsPcentTxtField = new JTextArea(); + hbHoldsPcentTxtField.setVisible(false); + hbHoldsPcentTxtField.setBounds(640, 220, 80, 20); + hbHoldsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + hbHoldsPcentTxtField.setText("0"); + + hbMinesTxt = new JLabel("Mines: "); + hbMinesTxt.setVisible(false); + hbMinesTxt.setBounds(460, 240, 80, 20); + + hbMinesEnabled = new JCheckBox(); + hbMinesEnabled.setVisible(false); + hbMinesEnabled.setBounds(520, 240, 20, 20); + hbMinesEnabled.setSelected(true); + + hbMinesPcentTxt = new JLabel("Percent: "); + hbMinesPcentTxt.setVisible(false); + hbMinesPcentTxt.setBounds(560, 240, 80, 20); + + hbMinesPcentTxtField = new JTextArea(); + hbMinesPcentTxtField.setVisible(false); + hbMinesPcentTxtField.setBounds(640, 240, 80, 20); + hbMinesPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + hbMinesPcentTxtField.setText("0"); + + + quarterBeatsTxt = new JLabel("Quarter Beats (Green Arrows)", SwingConstants.CENTER); + quarterBeatsTxt.setVisible(false); + quarterBeatsTxt.setBounds(410, 280, 280, 20); + + qbStepsTxt = new JLabel("Steps: "); + qbStepsTxt.setVisible(false); + qbStepsTxt.setBounds(460, 300, 80, 20); + + qbStepsEnabled = new JCheckBox(); + qbStepsEnabled.setVisible(false); + qbStepsEnabled.setBounds(520, 300, 20, 20); + qbStepsEnabled.setSelected(true); + + qbStepsPcentTxt = new JLabel("Percent: "); + qbStepsPcentTxt.setVisible(false); + qbStepsPcentTxt.setBounds(560, 300, 80, 20); + + qbStepsPcentTxtField = new JTextArea(); + qbStepsPcentTxtField.setVisible(false); + qbStepsPcentTxtField.setBounds(640, 300, 80, 20); + qbStepsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + qbStepsPcentTxtField.setText("0"); + + qbJumpsTxt = new JLabel("Jumps: "); + qbJumpsTxt.setVisible(false); + qbJumpsTxt.setBounds(460, 320, 80, 20); + + qbJumpsEnabled = new JCheckBox(); + qbJumpsEnabled.setVisible(false); + qbJumpsEnabled.setBounds(520, 320, 20, 20); + qbJumpsEnabled.setSelected(true); + + qbJumpsPcentTxt = new JLabel("Percent: "); + qbJumpsPcentTxt.setVisible(false); + qbJumpsPcentTxt.setBounds(560, 320, 80, 20); + + qbJumpsPcentTxtField = new JTextArea(); + qbJumpsPcentTxtField.setVisible(false); + qbJumpsPcentTxtField.setBounds(640, 320, 80, 20); + qbJumpsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + qbJumpsPcentTxtField.setText("0"); + + qbHoldsTxt = new JLabel("Hands: "); + qbHoldsTxt.setVisible(false); + qbHoldsTxt.setBounds(460, 340, 80, 20); + + qbHoldsEnabled = new JCheckBox(); + qbHoldsEnabled.setVisible(false); + qbHoldsEnabled.setBounds(520, 340, 20, 20); + qbHoldsEnabled.setSelected(true); + + qbHoldsPcentTxt = new JLabel("Percent: "); + qbHoldsPcentTxt.setVisible(false); + qbHoldsPcentTxt.setBounds(560, 340, 80, 20); + + qbHoldsPcentTxtField = new JTextArea(); + qbHoldsPcentTxtField.setVisible(false); + qbHoldsPcentTxtField.setBounds(640, 340, 80, 20); + qbHoldsPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + qbHoldsPcentTxtField.setText("0"); + + qbMinesTxt = new JLabel("Mines: "); + qbMinesTxt.setVisible(false); + qbMinesTxt.setBounds(460, 360, 80, 20); + + qbMinesEnabled = new JCheckBox(); + qbMinesEnabled.setVisible(false); + qbMinesEnabled.setBounds(520, 360, 20, 20); + qbMinesEnabled.setSelected(true); + + qbMinesPcentTxt = new JLabel("Percent: "); + qbMinesPcentTxt.setVisible(false); + qbMinesPcentTxt.setBounds(560, 360, 80, 20); + + qbMinesPcentTxtField = new JTextArea(); + qbMinesPcentTxtField.setVisible(false); + qbMinesPcentTxtField.setBounds(640, 360, 80, 20); + qbMinesPcentTxtField.setBorder(BorderFactory.createLineBorder(Color.black, 1, true)); + qbMinesPcentTxtField.setText("0"); + + + + noFileSign = new JLabel("No file selected", SwingConstants.CENTER); + noFileSign.setVisible(true); + noFileSign.setBounds(20, 20, 720, 520); + + + + open = new JMenuItem("Open Step File"); + open.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(e.getSource()==open){ + JFileChooser fc=new JFileChooser(".\\"); + FileNameExtensionFilter filter = new FileNameExtensionFilter("StepMania Files (.sm)", "sm"); + fc.setFileFilter(filter); + int i=fc.showOpenDialog(ikkuna); + if(i==JFileChooser.APPROVE_OPTION){ + File f=fc.getSelectedFile(); + String filepath=f.getPath(); + try{ + stepFile = new File(f.getName()); + audioFile = new File(f.getName().substring(0, f.getName().length()-3) + ".mp3"); + } + catch (Exception ex) { + ex.printStackTrace(); + } + + foundChartsInfo = ""; + readSongInfo(); + readChartData(); + readChartInfo(); + readChartDifficultyInfo(); + readMeasureCount(); + combinedChartData = findExistingChartsAtFileOpen(); + System.out.println(combinedChartData); + setComponentVisibility(true); + if (foundChartsInfo == "" || foundChartsInfo == null || foundCharts == 0) { + infoBox("No charts were found.", "Chart Info"); + } + else { + infoBox(foundChartsInfo, "Chart Info"); + } + } + } + + } + }); + + createUsingAudioFile = new JMenuItem("Create Using Audio File"); + createUsingAudioFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(e.getSource()==createUsingAudioFile){ + JFileChooser fc=new JFileChooser(".\\"); + FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio Files (.mp3; .ogg)", "mp3", "ogg"); + fc.setFileFilter(filter); + int i=fc.showOpenDialog(ikkuna); + if(i==JFileChooser.APPROVE_OPTION){ + File f=fc.getSelectedFile(); + String filepath=f.getPath(); + try{ + audioFile = new File(f.getName()); + stepFile = new File(f.getName().substring(0, f.getName().length()-4) + ".sm"); + } + catch (Exception ex) { + ex.printStackTrace(); + } + MainWindow.mainSongInfo = "#TITLE:" + audioFile.getName().substring(0, audioFile.getName().length()-4) + ";\n#SUBTITLE:;\n#ARTIST:;\n#TITLETRANSLIT:;\n#SUBTITLETRANSLIT:;\n#ARTISTTRANSLIT:;\n#GENRE:;\n#CREDIT:;\n#BANNER:;\n#BACKGROUND:;\n#LYRICSPATH:;\n#CDTITLE:;\n#MUSIC:" + audioFile.getName() + ";\n#OFFSET:0;\n#SAMPLESTART:;\n#SAMPLELENGTH:;\n#LASTBEAT:;\n#SELECTABLE:YES;\n#BPMS:0.000=0;\n#STOPS:;\n#BGCHANGES:;\n#KEYSOUNDS:;\n"; + EditSongInfoWindow editSongWindow = new EditSongInfoWindow(MainWindow.mainSongInfo); + editSongWindow.editTextWindow.setVisible(true); + songInfo = MainWindow.mainSongInfo; + + createNewFile(); + readSongInfo(); + readChartData(); + readChartInfo(); + readChartDifficultyInfo(); + setComponentVisibility(true); + } + } + } + }); + + saveFile = new JMenuItem("Save File"); + saveFile.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + if(e.getSource()==saveFile){ + combinedStepfileData = MainWindow.mainSongInfo + combinedChartData; + writeIntoFile(combinedStepfileData); + } + } + catch (NullPointerException npe) { + errorBox("Please select a file first", "File not found"); + } + } + }); + + file = new JMenu("File"); + file.add(open); + file.add(createUsingAudioFile); + file.add(saveFile); + + editSongInfo = new JMenuItem("Edit Song Info"); + editSongInfo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + EditSongInfoWindow editSongWindow = new EditSongInfoWindow(MainWindow.mainSongInfo); + editSongWindow.editTextWindow.setVisible(true); + songInfo = MainWindow.mainSongInfo; + } + catch (NullPointerException npe) { + errorBox("Please select a file first", "File not found"); + } + } + }); + + edit = new JMenu("Edit"); + edit.add(editSongInfo); + + viewSongInfo = new JMenuItem("View Song Info"); + viewSongInfo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(e.getSource()==viewSongInfo){ + songInfo = MainWindow.mainSongInfo; + if (songInfo == null || !songInfo.startsWith("#")) { + infoBox("No song info was found.", "Song Info"); + } + else { + infoBox(songInfo, "Song Info"); + } + } + } + }); + + viewChartInfo = new JMenuItem("View Chart Info"); + viewChartInfo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(e.getSource()==viewChartInfo){ + foundChartsInfo = ""; + readChartData(); + readChartInfo(); + if (foundChartsInfo == "" || foundChartsInfo == null || findChartAmount() == 0) { + infoBox("No charts were found.", "Chart Info"); + } + else { + infoBox(foundChartsInfo, "Chart Info"); + } + } + } + }); + + view = new JMenu("View"); + view.add(viewSongInfo); + view.add(viewChartInfo); + + calculateMeasures = new JMenuItem("Calculate Measures"); + calculateMeasures.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + CalculateMeasureWindow calcMeasureWindow = new CalculateMeasureWindow(); + calcMeasureWindow.calculateMeasureWindow.setVisible(true); + } + catch (NullPointerException npe) { + errorBox("Please select a file first", "File not found"); + } + } + }); + + adjustBPM = new JMenuItem("Adjust BPM and Offset"); + adjustBPM.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + AdjustBPMWindow adjBpmWindow = new AdjustBPMWindow(); + adjBpmWindow.adjustBPMWindow.setVisible(true); + } + catch (NullPointerException npe) { + errorBox("Please select a file first", "File not found"); + } + } + }); + + tools = new JMenu("Tools"); + tools.add(calculateMeasures); + tools.add(adjustBPM); + + + mb = new JMenuBar(); + mb.setBounds(0,0,800,20); + mb.add(file); + mb.add(edit); + mb.add(view); + mb.add(tools); + + + + ikkuna.add(create); + ikkuna.add(mb); + + ikkuna.add(begEmptyTxt); + ikkuna.add(begEmptyTxtField); + ikkuna.add(msrTxt); + ikkuna.add(msrTxtField); + ikkuna.add(endEmptyTxt); + ikkuna.add(endEmptyTxtField); + + ikkuna.add(difficultyTxt); + ikkuna.add(difficulty); + ikkuna.add(difficultyNoTxt); + ikkuna.add(difficultyNoTxtField); + ikkuna.add(creatorTxt); + ikkuna.add(creatorTxtField); + ikkuna.add(noFileSign); + + ikkuna.add(beatsTxt); + ikkuna.add(bStepsTxt); + ikkuna.add(bStepsEnabled); + ikkuna.add(bStepsPcentTxt); + ikkuna.add(bStepsPcentTxtField); + ikkuna.add(bJumpsTxt); + ikkuna.add(bJumpsEnabled); + ikkuna.add(bJumpsPcentTxt); + ikkuna.add(bJumpsPcentTxtField); + ikkuna.add(bHoldsTxt); + ikkuna.add(bHoldsEnabled); + ikkuna.add(bHoldsPcentTxt); + ikkuna.add(bHoldsPcentTxtField); + ikkuna.add(bMinesTxt); + ikkuna.add(bMinesEnabled); + ikkuna.add(bMinesPcentTxt); + ikkuna.add(bMinesPcentTxtField); + + ikkuna.add(halfBeatsTxt); + ikkuna.add(hbStepsTxt); + ikkuna.add(hbStepsEnabled); + ikkuna.add(hbStepsPcentTxt); + ikkuna.add(hbStepsPcentTxtField); + ikkuna.add(hbJumpsTxt); + ikkuna.add(hbJumpsEnabled); + ikkuna.add(hbJumpsPcentTxt); + ikkuna.add(hbJumpsPcentTxtField); + ikkuna.add(hbHoldsTxt); + ikkuna.add(hbHoldsEnabled); + ikkuna.add(hbHoldsPcentTxt); + ikkuna.add(hbHoldsPcentTxtField); + ikkuna.add(hbMinesTxt); + ikkuna.add(hbMinesEnabled); + ikkuna.add(hbMinesPcentTxt); + ikkuna.add(hbMinesPcentTxtField); + + ikkuna.add(quarterBeatsTxt); + ikkuna.add(qbStepsTxt); + ikkuna.add(qbStepsEnabled); + ikkuna.add(qbStepsPcentTxt); + ikkuna.add(qbStepsPcentTxtField); + ikkuna.add(qbJumpsTxt); + ikkuna.add(qbJumpsEnabled); + ikkuna.add(qbJumpsPcentTxt); + ikkuna.add(qbJumpsPcentTxtField); + ikkuna.add(qbHoldsTxt); + ikkuna.add(qbHoldsEnabled); + ikkuna.add(qbHoldsPcentTxt); + ikkuna.add(qbHoldsPcentTxtField); + ikkuna.add(qbMinesTxt); + ikkuna.add(qbMinesEnabled); + ikkuna.add(qbMinesPcentTxt); + ikkuna.add(qbMinesPcentTxtField); + + ikkuna.revalidate(); + ikkuna.repaint(); + + + } + + static void infoBox(String infoMessage, String titleBar) { + JOptionPane.showMessageDialog(null, infoMessage, titleBar, JOptionPane.INFORMATION_MESSAGE); + } + + static void errorBox(String errorMessage, String titleBar) { + JOptionPane.showMessageDialog(null, errorMessage, titleBar, JOptionPane.ERROR_MESSAGE); + } + + static void exclamationBox(String exclamationMessage, String titleBar) { + JOptionPane.showConfirmDialog(null, exclamationMessage, titleBar, JOptionPane.WARNING_MESSAGE); + } + + + static void setComponentVisibility(boolean visibility) { + begEmptyTxt.setVisible(visibility); + begEmptyTxtField.setVisible(visibility); + msrTxt.setVisible(visibility); + msrTxtField.setVisible(visibility); + endEmptyTxt.setVisible(visibility); + endEmptyTxtField.setVisible(visibility); + creatorTxt.setVisible(visibility); + creatorTxtField.setVisible(visibility); + create.setVisible(visibility); + difficultyTxt.setVisible(visibility); + difficulty.setVisible(visibility); + difficultyNoTxt.setVisible(visibility); + difficultyNoTxtField.setVisible(visibility); + + beatsTxt.setVisible(visibility); + bStepsTxt.setVisible(visibility); + bStepsEnabled.setVisible(visibility); + bStepsPcentTxt.setVisible(visibility); + bStepsPcentTxtField.setVisible(visibility); + bJumpsTxt.setVisible(visibility); + bJumpsEnabled.setVisible(visibility); + bJumpsPcentTxt.setVisible(visibility); + bJumpsPcentTxtField.setVisible(visibility); + bHoldsTxt.setVisible(visibility); + bHoldsEnabled.setVisible(visibility); + bHoldsPcentTxt.setVisible(visibility); + bHoldsPcentTxtField.setVisible(visibility); + bMinesTxt.setVisible(visibility); + bMinesEnabled.setVisible(visibility); + bMinesPcentTxt.setVisible(visibility); + bMinesPcentTxtField.setVisible(visibility); + + halfBeatsTxt.setVisible(visibility); + hbStepsTxt.setVisible(visibility); + hbStepsEnabled.setVisible(visibility); + hbStepsPcentTxt.setVisible(visibility); + hbStepsPcentTxtField.setVisible(visibility); + hbJumpsTxt.setVisible(visibility); + hbJumpsEnabled.setVisible(visibility); + hbJumpsPcentTxt.setVisible(visibility); + hbJumpsPcentTxtField.setVisible(visibility); + hbHoldsTxt.setVisible(visibility); + hbHoldsEnabled.setVisible(visibility); + hbHoldsPcentTxt.setVisible(visibility); + hbHoldsPcentTxtField.setVisible(visibility); + hbMinesTxt.setVisible(visibility); + hbMinesEnabled.setVisible(visibility); + hbMinesPcentTxt.setVisible(visibility); + hbMinesPcentTxtField.setVisible(visibility); + + quarterBeatsTxt.setVisible(visibility); + qbStepsTxt.setVisible(visibility); + qbStepsEnabled.setVisible(visibility); + qbStepsPcentTxt.setVisible(visibility); + qbStepsPcentTxtField.setVisible(visibility); + qbJumpsTxt.setVisible(visibility); + qbJumpsEnabled.setVisible(visibility); + qbJumpsPcentTxt.setVisible(visibility); + qbJumpsPcentTxtField.setVisible(visibility); + qbHoldsTxt.setVisible(visibility); + qbHoldsEnabled.setVisible(visibility); + qbHoldsPcentTxt.setVisible(visibility); + qbHoldsPcentTxtField.setVisible(visibility); + qbMinesTxt.setVisible(visibility); + qbMinesEnabled.setVisible(visibility); + qbMinesPcentTxt.setVisible(visibility); + qbMinesPcentTxtField.setVisible(visibility); + + noFileSign.setVisible(!visibility); + } + + + static void verifyValues() { + + boolean chartFree = true; + updateChartData(); + + try { + difficultyNumber = Short.parseShort(difficultyNoTxtField.getText()); + emptyMsrsBeginning = Short.parseShort(begEmptyTxtField.getText()); + msrs = Short.parseShort(msrTxtField.getText()); + emptyMsrsEnd = Short.parseShort(endEmptyTxtField.getText()); + + stepPercentage = Byte.parseByte(bStepsPcentTxtField.getText()); + jumpPercentage = Byte.parseByte(bJumpsPcentTxtField.getText()); + holdPercentage = Byte.parseByte(bHoldsPcentTxtField.getText()); + minePercentage = Byte.parseByte(bMinesPcentTxtField.getText()); + + halfStepPercentage = Byte.parseByte(hbStepsPcentTxtField.getText()); + halfJumpPercentage = Byte.parseByte(hbJumpsPcentTxtField.getText()); + halfHoldPercentage = Byte.parseByte(hbHoldsPcentTxtField.getText()); + halfMinePercentage = Byte.parseByte(hbMinesPcentTxtField.getText()); + + quarterStepPercentage = Byte.parseByte(qbStepsPcentTxtField.getText()); + quarterJumpPercentage = Byte.parseByte(qbJumpsPcentTxtField.getText()); + quarterHoldPercentage = Byte.parseByte(qbHoldsPcentTxtField.getText()); + quarterMinePercentage = Byte.parseByte(qbMinesPcentTxtField.getText()); + + if (difficultyNumber < 1 || emptyMsrsBeginning < 0 || msrs < 0 || emptyMsrsEnd < 0) { + throw new NumberFormatException(); + } + else if (stepPercentage < 0 || stepPercentage > 100 || + jumpPercentage < 0 || jumpPercentage > 100 || + holdPercentage < 0 || holdPercentage > 100 || + minePercentage < 0 || minePercentage > 100 || + halfStepPercentage < 0 || halfStepPercentage > 100 || + halfJumpPercentage < 0 || halfJumpPercentage > 100 || + halfHoldPercentage < 0 || halfHoldPercentage > 100 || + halfMinePercentage < 0 || halfMinePercentage > 100 || + quarterStepPercentage < 0 || quarterStepPercentage > 100 || + quarterJumpPercentage < 0 || quarterJumpPercentage > 100 || + quarterHoldPercentage < 0 || quarterHoldPercentage > 100 || + quarterMinePercentage < 0 || quarterMinePercentage > 100 + ){ + System.out.println(stepPercentage); + throw new InvalidPercentageException(); + } + else if (stepPercentage + jumpPercentage + holdPercentage + minePercentage > 100 || + halfStepPercentage + halfJumpPercentage + halfHoldPercentage + halfMinePercentage > 100 || + quarterStepPercentage + quarterJumpPercentage + quarterHoldPercentage + quarterMinePercentage > 100 + ) { + throw new PercentageOverException(); + } + else { + for (int i = 0; i < chartDataDifficultyInfo.length; i++) { + if (difficulties[difficultyChoice].charAt(0) == chartDataDifficultyInfo[i].charAt(0) && difficulties[difficultyChoice].charAt(1) == chartDataDifficultyInfo[i].charAt(1)) { + System.out.println(difficulties[difficultyChoice]); + System.out.println(chartDataDifficultyInfo[i]); + int selection = JOptionPane.showConfirmDialog(null, "Chart " + difficulties[difficultyChoice] + " already exists. Do you want to replace it?", "Chart already exists", JOptionPane.WARNING_MESSAGE); + if (selection == JOptionPane.OK_OPTION) { + chartFree = true; + break; + } + else { + chartFree = false; + break; + } + } + } + if (chartFree) { + createSteps(); + } + } + } + catch (NumberFormatException e) { + errorBox("Invalid input. Please make sure input value is proper integer number.\n\nValue for measures: 0 to 32767 (Non-negative Short)\nValue for difficulty: 1 to 32767 (Positive Short)\nValue for percentage: 0 to 100", "Number format error"); + } + catch (IndexOutOfBoundsException e) { + errorBox("Something went wrong", "Index ouf of Bounds Exception"); + } + catch (PercentageOverException e) { + errorBox("Percentage of steps in one type of beats cannot exceed 100.\nE.g. 65% (Steps) + 25% (Jumps) + 5% (Hands) + 5% (Mines) = 100% (Total)", "Invalid Percentage"); + } + catch (InvalidPercentageException e) { + errorBox("Percentage must be between 0 and 100.", "Number format error"); + } + + + } + + static void readSongInfo() { + + try { + Scanner sc = new Scanner(stepFile); + String foundInfo = ""; + int foundInfoLines = 0; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + break; + } + foundInfo += line + "\n"; + foundInfoLines++; + } + songInfo = foundInfo; + MainWindow.mainSongInfo = foundInfo; + System.out.println("Song info: " + songInfo); + sc.close(); + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + + if (MainWindow.mainSongInfo != null) { + int i = MainWindow.mainSongInfo.indexOf("#BPMS"); + String bpms; + if (i == -1) { + mainBPM = ""; + } + else { + i += 6; + bpms = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + bpms += MainWindow.mainSongInfo.charAt(i); + i++; + } + mainBPM = bpms.substring(6); + } + + i = MainWindow.mainSongInfo.indexOf("#OFFSET"); + String offset; + if (i == -1) { + mainOffset = ""; + } + else { + i += 8; + offset = ""; + while (MainWindow.mainSongInfo.charAt(i) != ';') { + offset += MainWindow.mainSongInfo.charAt(i); + i++; + } + mainOffset = offset; + } + } + } + + static void readChartInfo() { + + try { + Scanner sc = new Scanner(stepFile); + int stepArrayIndex = 0; + String foundInfo; + String foundNum; + foundChartsInfo += "Found Charts: \n\n"; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + sc.nextLine(); + sc.nextLine(); + sc.nextLine(); + foundInfo = sc.nextLine(); + foundNum = sc.nextLine(); + + foundChartsInfo += "" + foundInfo + "\n Difficulty: " + foundNum + "\n Steps: " + stepsInChart[stepArrayIndex] + "\n Jumps: " + jumpsInChart[stepArrayIndex] + "\n Hands: " + handsInChart[stepArrayIndex] + "\n Mines: " + minesInChart[stepArrayIndex] + "\n\n"; + foundCharts++; + stepArrayIndex++; + } + } + + sc.close(); + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + } + + static int findChartAmount() { + int foundCharts = 0; + try { + Scanner sc = new Scanner(stepFile); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + while (!line.startsWith(";")) { + line = sc.nextLine(); + } + foundCharts++; + } + } + + sc.close(); + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + return foundCharts; + } + + static void readChartData() { + + try { + Scanner sc = new Scanner(stepFile); + String foundData = ""; + int foundCharts = findChartAmount(); + int foundChartIndex = 0; + int stepCount = 0; + int jumpCount = 0; + int handCount = 0; + int mineCount = 0; + chartData = new String[foundCharts]; + stepsInChart = new int[foundCharts]; + jumpsInChart = new int[foundCharts]; + handsInChart = new int[foundCharts]; + minesInChart = new int[foundCharts]; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + while (!line.startsWith(";") && line != null && line != "") { + foundData += line + "\n"; + if (line.charAt(0) == '1' && line.charAt(1) == '0' && line.charAt(2) == '0' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '1' && line.charAt(2) == '0' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '0' && line.charAt(2) == '1' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '0' && line.charAt(2) == '0' && line.charAt(3) == '1') { + stepCount++; + } + if (line.charAt(0) == '1' && line.charAt(1) == '1' && line.charAt(2) == '0' && line.charAt(3) == '0' || + line.charAt(0) == '1' && line.charAt(1) == '0' && line.charAt(2) == '1' && line.charAt(3) == '0' || + line.charAt(0) == '1' && line.charAt(1) == '0' && line.charAt(2) == '0' && line.charAt(3) == '1' || + line.charAt(0) == '0' && line.charAt(1) == '1' && line.charAt(2) == '1' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '1' && line.charAt(2) == '0' && line.charAt(3) == '1' || + line.charAt(0) == '0' && line.charAt(1) == '0' && line.charAt(2) == '1' && line.charAt(3) == '1' ) { + jumpCount++; + } + if (line.charAt(0) == '1' && line.charAt(1) == '1' && line.charAt(2) == '1' && line.charAt(3) == '0' || + line.charAt(0) == '1' && line.charAt(1) == '1' && line.charAt(2) == '0' && line.charAt(3) == '1' || + line.charAt(0) == '1' && line.charAt(1) == '0' && line.charAt(2) == '1' && line.charAt(3) == '1' || + line.charAt(0) == '0' && line.charAt(1) == '1' && line.charAt(2) == '1' && line.charAt(3) == '1') { + handCount++; + } + if (line.charAt(0) == 'M' && line.charAt(1) == '0' && line.charAt(2) == '0' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == 'M' && line.charAt(2) == '0' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '0' && line.charAt(2) == 'M' && line.charAt(3) == '0' || + line.charAt(0) == '0' && line.charAt(1) == '0' && line.charAt(2) == '0' && line.charAt(3) == 'M') { + mineCount++; + } + line = sc.nextLine(); + } + chartData[foundChartIndex] = foundData + ";\n"; + stepsInChart[foundChartIndex] = stepCount; + jumpsInChart[foundChartIndex] = jumpCount; + handsInChart[foundChartIndex] = handCount; + minesInChart[foundChartIndex] = mineCount; + foundChartIndex++; + foundData = ""; + stepCount = 0; + jumpCount = 0; + handCount = 0; + mineCount = 0; + } + } + + sc.close(); + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + } + + static void readMeasureCount() { + try { + Scanner sc = new Scanner(stepFile); + int measureCount = 0; + boolean is1stChart = true; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + while (!line.startsWith(";") && line != null && line != "") { + if (line.charAt(0) == ',' && is1stChart) { + measureCount++; + } + line = sc.nextLine(); + } + if (is1stChart) { + msrTxtField.setText("" + measureCount); + is1stChart = false; + } + measureCount = 0; + } + } + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + } + + static void readChartDifficultyInfo() { + + try { + Scanner sc = new Scanner(stepFile); + int foundCharts = findChartAmount(); + chartDataDifficultyInfo = new String[foundCharts]; + int foundChartIndex = 0; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + line = sc.nextLine(); + line = sc.nextLine(); + line = sc.nextLine(); + line = sc.nextLine(); + chartDataDifficultyInfo[foundChartIndex] = line.substring(5, line.length()-1); + System.out.println(chartDataDifficultyInfo[foundChartIndex]); + while (!line.startsWith(";")) { + line = sc.nextLine(); + } + foundChartIndex++; + } + } + + sc.close(); + } + catch (FileNotFoundException e) { + System.out.println("No file found!"); + } + } + + static String findOldCharts() { + String oldChartsData = ""; + for (int i = 0; i < chartData.length; i++) { + if (!(chartDataDifficultyInfo[i].charAt(0) == difficulties[difficultyChoice].charAt(0) && chartDataDifficultyInfo[i].charAt(1) == difficulties[difficultyChoice].charAt(1))) { + oldChartsData += chartData[i]; + } + System.out.println("Previous chart: " + chartDataDifficultyInfo[i]); + } + return oldChartsData; + } + + static String findExistingChartsAtFileOpen() { + String exChartsData = ""; + if (chartData != null) { + for (int i = 0; i < chartData.length; i++) { + exChartsData += chartData[i]; + } + } + return exChartsData; + } + + static void updateChartData() { + + Scanner sc; + String foundData = ""; + int foundCharts = 0; + int foundChartIndex = 0; + + + sc = new Scanner(combinedChartData); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + while (!line.startsWith(";")) { + line = sc.nextLine(); + } + foundCharts++; + } + } + + sc.close(); + + chartData = new String[foundCharts]; + chartDataDifficultyInfo = new String[foundCharts]; + + sc = new Scanner(combinedChartData); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + while (!line.startsWith(";") && line != null && line != "") { + foundData += line + "\n"; + line = sc.nextLine(); + } + chartData[foundChartIndex] = foundData + ";\n"; + foundChartIndex++; + foundData = ""; + } + } + + sc.close(); + + sc = new Scanner(combinedChartData); + foundChartIndex = 0; + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.startsWith("/")) { + line = sc.nextLine(); + line = sc.nextLine(); + line = sc.nextLine(); + line = sc.nextLine(); + chartDataDifficultyInfo[foundChartIndex] = line.substring(5, line.length()-1); + System.out.println(chartDataDifficultyInfo[foundChartIndex]); + while (!line.startsWith(";")) { + line = sc.nextLine(); + } + foundChartIndex++; + } + } + + sc.close(); + } + + static void createSteps() { + try { + + creator = creatorTxtField.getText(); + boolean enableBeats = bStepsEnabled.isSelected(); + + String outputText = ""; + String oldChartsData = ""; + + outputText += "//--------------- dance-single - " + creator + " ----------------\n"; + outputText += "#NOTES:\n dance-single:\n " + creator + ":\n " + difficulties[difficultyChoice] + ":\n "+ difficultyNumber +":\n 0,0,0,0,0:\n"; + + for (int i = 0; i < emptyMsrsBeginning; i++) { + outputText += ("0000" + "\n" + "0000" + "\n" + "0000" + "\n" + "0000" + "\n" + ",\n"); + } + if (enableBeats) { + for (int i = 0; i < msrs; i++) { + outputText += (generateMeasure(stepPercentage, jumpPercentage, holdPercentage, minePercentage, halfStepPercentage, halfJumpPercentage, halfHoldPercentage, halfMinePercentage, quarterStepPercentage, quarterJumpPercentage, quarterHoldPercentage, quarterMinePercentage) + ",\n"); + } + } + for (int i = 0; i < emptyMsrsEnd; i++) { + outputText += ("0000" + "\n" + "0000" + "\n" + "0000" + "\n" + "0000" + "\n" + ",\n"); + } + + System.out.println(outputText.charAt(outputText.length()-2)); + if (outputText.charAt(outputText.length()-2) == ',') { + outputText = outputText.substring(0, outputText.length()-2); + } + outputText += ";"; + updateChartData(); + oldChartsData = findOldCharts(); + combinedChartData = oldChartsData + outputText; + infoBox("Steps created:\n" + difficulties[difficultyChoice] + ": " + difficultyNumber + "\nCreator: " + creator, " "); + } + catch (NullPointerException e) { + errorBox("Please select a file first.", "File not found!"); + } + catch (NumberFormatException e) { + errorBox("Percentage must be between 0 and 100.", "Number format error"); + } + } + + static String generateMeasure(int bStepP, int bJumpP, int bTripleP, int bMineP, int hbStepP, int hbJumpP, int hbTripleP, int hbMineP, int qbStepP, int qbJumpP, int qbTripleP, int qbMineP) { + Random r = new Random(); + int randomValue = r.nextInt(100); + String newBeat = ""; + boolean isBeat = false, isHBeat = false, isQBeat = false; + String[] beatsInMeasure = new String[16]; + + beatsInMeasure[0] = generateBeat(bStepP, bJumpP, bTripleP, bMineP); + if (beatsInMeasure[0] != "0000") { + isBeat = true; + } + beatsInMeasure[1] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[1] != "0000") { + isQBeat = true; + } + beatsInMeasure[2] = generateBeat(hbStepP, hbJumpP, hbTripleP, hbMineP); + if (beatsInMeasure[2] != "0000") { + isHBeat = true; + } + beatsInMeasure[3] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[3] != "0000") { + isQBeat = true; + } + beatsInMeasure[4] = generateBeat(bStepP, bJumpP, bTripleP, bMineP); + if (beatsInMeasure[4] != "0000") { + isBeat = true; + } + beatsInMeasure[5] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[5] != "0000") { + isQBeat = true; + } + beatsInMeasure[6] = generateBeat(hbStepP, hbJumpP, hbTripleP, hbMineP); + if (beatsInMeasure[6] != "0000") { + isHBeat = true; + } + beatsInMeasure[7] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[7] != "0000") { + isQBeat = true; + } + beatsInMeasure[8] = generateBeat(bStepP, bJumpP, bTripleP, bMineP); + if (beatsInMeasure[8] != "0000") { + isBeat = true; + } + beatsInMeasure[9] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[9] != "0000") { + isQBeat = true; + } + beatsInMeasure[10] = generateBeat(hbStepP, hbJumpP, hbTripleP, hbMineP); + if (beatsInMeasure[10] != "0000") { + isHBeat = true; + } + beatsInMeasure[11] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[11] != "0000") { + isQBeat = true; + } + beatsInMeasure[12] = generateBeat(bStepP, bJumpP, bTripleP, bMineP); + if (beatsInMeasure[12] != "0000") { + isBeat = true; + } + beatsInMeasure[13] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[13] != "0000") { + isQBeat = true; + } + beatsInMeasure[14] = generateBeat(hbStepP, hbJumpP, hbTripleP, hbMineP); + if (beatsInMeasure[14] != "0000") { + isHBeat = true; + } + beatsInMeasure[15] = generateBeat(qbStepP, qbJumpP, qbTripleP, qbMineP); + if (beatsInMeasure[15] != "0000") { + isQBeat = true; + } + + + if (isQBeat) { + for (int i = 0; i <= 15; i++) { + newBeat += beatsInMeasure[i] + "\n"; + } + } + else if (isHBeat) { + for (int i = 0; i < 15; i++) { + if (i % 2 == 0) { + newBeat += beatsInMeasure[i] + "\n"; + } + } + } + else { + for (int i = 0; i < 15; i++) { + if (i % 4 == 0) { + newBeat += beatsInMeasure[i] + "\n"; + } + } + } + + return newBeat; + } + + static String generateBeat(int beatPcge, int jumpPcge, int triplePcge, int minePcge) { + Random r = new Random(); + int tRng = r.nextInt(100); + int tBeatPcge = beatPcge; + int tJumpPcge = beatPcge + jumpPcge; + int tTriplePcge = tJumpPcge + triplePcge; + int tMinePcge = tTriplePcge + minePcge; + + if (tRng < tBeatPcge) { + return generateRandomStep(); + } + else if (tRng < tJumpPcge) { + return generateRandomJump(); + } + else if (tRng < tTriplePcge) { + return generateRandomTriple(); + } + else if (tRng < tMinePcge) { + return generateRandomMine(); + } + else { + return "0000"; + } + } + + static String generateRandomStep() { + Random r = new Random(); + int stepType; + String step; + stepType = r.nextInt(4); + + switch (stepType) { + case 0: + step = "1000"; //Left + break; + case 1: + step = "0100"; //Down + break; + case 2: + step = "0010"; //Up + break; + case 3: + step = "0001"; //Right + break; + default: + step = "0000"; //Nothing + break; + } + return step; + } + + static String generateRandomJump() { + Random r = new Random(); + int stepType; + String step; + stepType = r.nextInt(6); + + switch (stepType) { + case 0: + step = "1100"; //Left + Down + break; + case 1: + step = "1010"; //Left + Up + break; + case 2: + step = "1001"; //Left + Right + break; + case 3: + step = "0110"; //Down + Up + break; + case 4: + step = "0101"; //Down + Right + break; + case 5: + step = "0011"; //Up + Right + break; + default: + step = "0000"; //Nothing + break; + } + return step; + } + + static String generateRandomTriple() { + Random r = new Random(); + int stepType; + String step; + stepType = r.nextInt(4); + + switch (stepType) { + case 0: + step = "1110"; //Left + Down + Up + break; + case 1: + step = "1101"; //Left + Down + Right + break; + case 2: + step = "1011"; //Left + Up + Right + break; + case 3: + step = "0111"; //Down + Up + Right + break; + default: + step = "0000"; //Nothing + break; + } + return step; + } + + static String generateRandomMine() { + Random r = new Random(); + int stepType; + String step; + stepType = r.nextInt(4); + + switch (stepType) { + case 0: + step = "M000"; //Left + break; + case 1: + step = "0M00"; //Down + break; + case 2: + step = "00M0"; //Up + break; + case 3: + step = "000M"; //Right + break; + default: + step = "0000"; //Nothing + break; + } + return step; + } + + static void writeIntoFile(String text) { + try { + FileWriter writer = new FileWriter(stepFile); + writer.write(text); + writer.close(); + infoBox("File Saved.", ""); + } + catch (IOException e) { + + } + } + + static void createNewFile() { + try { + FileWriter writer = new FileWriter(stepFile); + + writer.write(MainWindow.mainSongInfo); + writer.close(); + infoBox("New step file created.\nRemember to set at least following values:\n\nTitle\nMusic\nBPM\nOffset\n\nOtherwise the stepfile might have issues.", "New step file created"); + } + catch (IOException e) { + errorBox("Please select a file first.", "File not found!"); + } + catch (NullPointerException e) { + errorBox("Please select a file first.", "File not found!"); + } + } + + private enum Difficulty{ + BEGINNER, EASY, MEDIUM, HARD, CHALLENGE + } + + static void setMeasureTxtField(String value) { + msrTxtField.setText(""); + } + + public static void main(String[] args) throws Exception { + startMainWindow(); + //MainWindow window1 = new MainWindow(); + } +} diff --git a/src/PercentageOverException.java b/src/PercentageOverException.java new file mode 100644 index 0000000000000000000000000000000000000000..fcd566163ccdee49724d01d545f3ae6e31ba4cc9 --- /dev/null +++ b/src/PercentageOverException.java @@ -0,0 +1,3 @@ +public class PercentageOverException extends Exception{ + +} diff --git a/src/Uusi tekstiasiakirja.bat b/src/Uusi tekstiasiakirja.bat new file mode 100644 index 0000000000000000000000000000000000000000..6efc1cd5c6ccc49889b1ed6b86ad52fdd13daf0d --- /dev/null +++ b/src/Uusi tekstiasiakirja.bat @@ -0,0 +1,2 @@ +javac Main.java +pause \ No newline at end of file