diff options
-rwxr-xr-x | README.md | 65 | ||||
-rw-r--r-- | src/main/java/net/sowgro/npehero/gui/ControlEditor.java | 106 | ||||
-rw-r--r-- | src/main/java/net/sowgro/npehero/main/Control.java | 37 | ||||
-rw-r--r-- | src/main/java/net/sowgro/npehero/main/Notes.java | 5 | ||||
-rwxr-xr-x | src/main/resources/net/sowgro/npehero/style.css | 4 |
5 files changed, 87 insertions, 130 deletions
@@ -11,74 +11,11 @@ Goals: Notes: - Level creation flow is incomplete - no way to set lastbeat - - notes editor does not write to file - no validation - Everything else in this readme is outdated # Installation -1. Install Java 17 or newer -1. Go to Deployments > Releases. -1. Download the correct archive for your OS -1. Unzip it into an empty directory -1. Run the start file (start.sh or start.bat) - -# Run in IDE -## VSCode -1. Windows: Install git for windows -1. import the repository... -- Method 1 - 1. Click the blue clone button - 1. Click "Visual Studio Code (HTTPS) -- Method 2 - 1. Click the source control button on the sidebar - 1. Click clone repository - 1. Return to GitLab and click the blue clone button - 1. Copy the "Clone with HTTPS" link - 1. Paste the link into the VSCode popup -3. Click the run and debug button on the sidebar -1. Click "create launch.json" and open the file -1. Add the key "vmArgs" and put in the [VM arguements](https://gitlab.sowgro.net/npeinc/npehero#java-vm-arguements) for your OS - -For example: -```json - "configurations": [ - { - "type": "java", - "name": "Driver", - "request": "launch", - "mainClass": "gui.Driver", - "projectName": "GuitarHero", - "vmArgs": "--module-path lib/linux --add-modules javafx.controls,javafx.fxml,javafx.media -Dprism.forceGPU=true" - }, -``` -Do not forget the comma after the second to last item. - -## Eclipse -1. Click the search icon in the upper right corner -2. Search "git repositories" and select it -3. Click "Clone a git repository" -1. Return to GitLab and click the blue clone button -1. Copy the "Clone with HTTPS" link -1. Paste it into the URI box -1. Other information should fill in automatically, click next -1. Ensure that the Main branch is selected and click next -1. Change the directory to your eclipse workspace -1. Check "Import all existing Eclipse projects after clone finishes" -1. Click finish -1. Right click on project > Properties -1. Select Run/Debug Settings > Driver -1. Click Edit -1. Click the Arguments tab -1. Paste in the [VM Arguements](https://gitlab.sowgro.net/npeinc/npehero#java-vm-arguements) for your OS - -## Java VM Arguments -These are automatically run by the start files when installing from an archive. - -#### Windows -`--module-path lib/windows/lib --add-modules javafx.controls,javafx.fxml,javafx.media` - -#### Linux -`--module-path lib/linux --add-modules javafx.controls,javafx.fxml,javafx.media -Dprism.forceGPU=true` +Coming soon. # Development Links diff --git a/src/main/java/net/sowgro/npehero/gui/ControlEditor.java b/src/main/java/net/sowgro/npehero/gui/ControlEditor.java index 637a9d8..ecd2fab 100644 --- a/src/main/java/net/sowgro/npehero/gui/ControlEditor.java +++ b/src/main/java/net/sowgro/npehero/gui/ControlEditor.java @@ -1,23 +1,28 @@ package net.sowgro.npehero.gui; +import javafx.beans.InvalidationListener; +import javafx.beans.binding.DoubleBinding; +import javafx.beans.property.Property; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyStringWrapper; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Pane; -import javafx.scene.layout.VBox; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; import net.sowgro.npehero.Driver; import net.sowgro.npehero.main.Control; import net.sowgro.npehero.main.SoundController; import org.w3c.dom.events.Event; +import java.util.List; +import java.util.Map; + public class ControlEditor extends Pane { public ControlEditor() { @@ -27,8 +32,8 @@ public class ControlEditor extends Pane { scrollPane.getStyleClass().add("box"); scrollPane.setPadding(new Insets(10)); controls.setPadding(new Insets(10)); - controls.setHgap(40); controls.setVgap(20); + controls.setHgap(40); scrollPane.prefWidthProperty().bind(super.prefWidthProperty().multiply(0.35)); @@ -55,51 +60,56 @@ public class ControlEditor extends Pane { rootBox.setAlignment(Pos.CENTER); ToggleGroup tg = new ToggleGroup(); - for (int i = 0; i < Control.values().length; i++) { - Control control = Control.values()[i]; - - - // label - Label label = new Label(control.label); - controls.add(label, 0, i); - - // control button - ToggleButton controlButton = new ToggleButton("<err>"); - controlButton.setText(keyToString(control.keyProperty.get())); - control.keyProperty.addListener(_ -> { - System.out.println(control.label + " set to " + control.keyProperty.get()); - System.out.println(controlButton.getText()); + int i = 0; + for (Map.Entry<String, List<Control>> section : Control.sections) { + // section header + Label sectionLabel = new Label(section.getKey()); + sectionLabel.getStyleClass().add("gray"); + BorderPane sectionBox = new BorderPane(); + sectionBox.setCenter(sectionLabel); + controls.add(sectionBox, 0, i, 3, 1); + i++; + + for (Control control : section.getValue()) { + + // label + Label label = new Label(control.label); + controls.add(label, 0, i); + + // control button + ToggleButton controlButton = new ToggleButton("<err>"); controlButton.setText(keyToString(control.keyProperty.get())); - net.sowgro.npehero.main.Control.writeToFile(); - }); - controlButton.setOnMouseClicked(_ -> { - EventHandler<KeyEvent> keyListener = new EventHandler<>() { - @Override - public void handle(KeyEvent k) { - control.keyProperty.set(k.getCode()); - rootBox.removeEventFilter(KeyEvent.KEY_PRESSED, this); - controlButton.setSelected(false); - k.consume(); + control.keyProperty.addListener(_ -> { + controlButton.setText(keyToString(control.keyProperty.get())); + Control.writeToFile(); + }); + controlButton.setOnMouseClicked(_ -> { + EventHandler<KeyEvent> keyListener = new EventHandler<>() { + @Override + public void handle(KeyEvent k) { + control.keyProperty.set(k.getCode()); + rootBox.removeEventFilter(KeyEvent.KEY_PRESSED, this); + controlButton.setSelected(false); + k.consume(); + } + }; + if (controlButton.isSelected()) { + rootBox.addEventFilter(KeyEvent.KEY_PRESSED, keyListener); + } else { + rootBox.removeEventFilter(KeyEvent.KEY_PRESSED, keyListener); } - }; - if (controlButton.isSelected()) { - System.out.println("Event registered"); - rootBox.addEventFilter(KeyEvent.KEY_PRESSED, keyListener); - } - else { - System.out.println("Event un-registered"); - rootBox.removeEventFilter(KeyEvent.KEY_PRESSED, keyListener); - } - }); - tg.getToggles().add(controlButton); - controls.add(controlButton, 1, i); - - // label button - Button resetButton = new Button("Reset"); - resetButton.setOnMouseClicked(_ -> { - control.keyProperty.set(control.defaultKey); - }); - controls.add(resetButton, 2, i); + }); + tg.getToggles().add(controlButton); + controls.add(controlButton, 1, i); + + // reset button + Button resetButton = new Button("Reset"); + resetButton.setOnMouseClicked(_ -> { + control.keyProperty.set(control.defaultKey); + }); + controls.add(resetButton, 2, i); + i++; + } } diff --git a/src/main/java/net/sowgro/npehero/main/Control.java b/src/main/java/net/sowgro/npehero/main/Control.java index 7bbcfb1..2ec8a61 100644 --- a/src/main/java/net/sowgro/npehero/main/Control.java +++ b/src/main/java/net/sowgro/npehero/main/Control.java @@ -7,28 +7,37 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import java.io.*; +import java.util.*; + +import static java.util.Map.entry; public enum Control { - LANE0 ("Lane 0", KeyCode.D), - LANE1 ("Lane 1", KeyCode.F), - LANE2 ("Lane 2", KeyCode.SPACE), - LANE3 ("Lane 3", KeyCode.J), - LANE4 ("Lane 4", KeyCode.K), - DELETE_NOTE ("Delete note", KeyCode.DELETE), - NOTE_UP ("Move note up", KeyCode.EQUALS), - NOTE_DOWN ("Move note down", KeyCode.MINUS), - SCROLL_LOCK ("Scroll lock", KeyCode.L), + LANE0 ("Lane 1", KeyCode.D), + LANE1 ("Lane 2", KeyCode.F), + LANE2 ("Lane 3", KeyCode.SPACE), + LANE3 ("Lane 4", KeyCode.J), + LANE4 ("Lane 5", KeyCode.K), + DELETE_NOTE ("Delete Note", KeyCode.DELETE), + NOTE_UP ("Move Note Up", KeyCode.EQUALS), + NOTE_DOWN ("Move Note Down", KeyCode.MINUS), + SCROLL_LOCK ("Scroll Lock", KeyCode.L), PLAY_PAUSE ("Play / Pause", KeyCode.P), - CLEAR_SELECTION ("Clear selection", KeyCode.ESCAPE), + CLEAR_SELECTION ("Clear Selection", KeyCode.ESCAPE), SELECT_ALL ("Select All", KeyCode.S), - LEGACY_PRINT ("Print time (Legacy)", KeyCode.Q), - LEGACY_STOP ("Stop edit (Legacy)", KeyCode.ESCAPE); + LEGACY_PRINT ("Print Time", KeyCode.Q), + LEGACY_STOP ("Stop Edit", KeyCode.ESCAPE); public final String label; public final KeyCode defaultKey; public final ObjectProperty<KeyCode> keyProperty = new SimpleObjectProperty<>(); + public static final List<Map.Entry<String, List<Control>>> sections = List.of( + entry("Gameplay", List.of(LANE0, LANE1, LANE2, LANE3, LANE4)), + entry("Editor", List.of(DELETE_NOTE, NOTE_UP, NOTE_DOWN, SCROLL_LOCK, PLAY_PAUSE, CLEAR_SELECTION, SELECT_ALL)), + entry("Legacy Editor", List.of(LEGACY_PRINT, LEGACY_STOP)) + ); + private static final String fileName = "controls.json"; Control(String label, KeyCode key) { @@ -72,7 +81,7 @@ public enum Control { public static void writeToFile() { try { - File file = new File("controls.json"); + File file = new File(fileName); FileWriter fileWriter = new FileWriter(file); JSONObject jsonObject = new JSONObject(); for (Control control : Control.values()) { @@ -87,7 +96,7 @@ public enum Control { } public static void readFromFile() { - File file = new File("controls.json"); + File file = new File(fileName); JSONParser jsonParser = new JSONParser(); try { diff --git a/src/main/java/net/sowgro/npehero/main/Notes.java b/src/main/java/net/sowgro/npehero/main/Notes.java index b0979de..543d6f9 100644 --- a/src/main/java/net/sowgro/npehero/main/Notes.java +++ b/src/main/java/net/sowgro/npehero/main/Notes.java @@ -71,10 +71,7 @@ public class Notes { // TODO handle error } - writer.println(lane + note.time.get()); - writer.flush(); - writer.close(); - // still not working + writer.println(lane + "" + note.time.get()); } } catch (IOException e) { diff --git a/src/main/resources/net/sowgro/npehero/style.css b/src/main/resources/net/sowgro/npehero/style.css index 950be11..b0a0209 100755 --- a/src/main/resources/net/sowgro/npehero/style.css +++ b/src/main/resources/net/sowgro/npehero/style.css @@ -233,6 +233,10 @@ Slider:focused .thumb{ -fx-text-fill: white; } +.gray { + -fx-text-fill: #a8a8a8; +} + /* debug */ .debug { |