From aa6611ff2f311f6982f50e6b6971d3f98b81540b Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Tue, 12 Oct 2021 06:05:12 +0000 Subject: [PATCH] Draw Editor Notes and Beat lines. Co-authored-by: sigonasr2 --- LLSIG/src/main/java/LLSIG/Canvas.java | 161 +++++++++++++++----------- LLSIG/src/main/java/LLSIG/LLSIG.java | 32 ++--- 2 files changed, 115 insertions(+), 78 deletions(-) diff --git a/LLSIG/src/main/java/LLSIG/Canvas.java b/LLSIG/src/main/java/LLSIG/Canvas.java index b207ef7..1e69cd5 100644 --- a/LLSIG/src/main/java/LLSIG/Canvas.java +++ b/LLSIG/src/main/java/LLSIG/Canvas.java @@ -6,6 +6,8 @@ import java.awt.geom.Rectangle2D; import java.awt.font.FontRenderContext; import java.awt.Font; import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import javax.swing.JPanel; @@ -55,80 +57,109 @@ public class Canvas extends JPanel implements AudioSpectrumListener{ SpectrographBar sb = spectrograph.get(i); sb.draw(g,SPECTROBAR_SIZE*i,SPECTROBAR_SIZE,this.getHeight()); } - g.setColor(Color.WHITE); g.drawString(Double.toString(LLSIG.game.musicPlayer.getPlayPosition()),0,32); - if (LLSIG.game.BPM_MEASURE) { - g.drawString("Average BPM: "+LLSIG.approximateBPM(),MIDDLE_X-128,MIDDLE_Y+64); - } else - if (LLSIG.game.METRONOME) { - g.drawString("Offset: "+LLSIG.testOffset,MIDDLE_X-128,MIDDLE_Y+64); + + if (LLSIG.game.EDITOR) { + final int MARGIN_X = 32; + final int BEAT_RANGE = 6; + final int BEAT_SPACING = 64; + final int NOTE_Y=(int)(MIDDLE_Y-NOTE_SIZE/2); + for (int y=-BEAT_RANGE;y notes = lane.noteChart.stream().filter((note)->Math.abs(LLSIG.EDITOR_CURSOR_BEAT-note.beatSnapStart) - { - // This block will be executed on JavaFX Thread - }); + Platform.startup(()->{}); this.window = f; @@ -113,7 +116,9 @@ public class LLSIG implements KeyListener{ PLAYING = new File("music/"+song+".mp3").exists(); if (PLAYING) { this.musicPlayer = new Player(Paths.get("music/"+song+".mp3").toUri().toString()); - musicPlayer.play(); + if (!EDITOR) { + musicPlayer.play(); + } LoadSongData(song,lanes); } @@ -136,6 +141,7 @@ public class LLSIG implements KeyListener{ bpm=bt.bpm; offset=bt.offset; beatDelay = ((1/((double)bpm/60))*1000); + beatNumber=0; System.out.println("BPM is "+bpm+". Delay is "+beatDelay); } } @@ -298,15 +304,15 @@ public class LLSIG implements KeyListener{ case KeyEvent.VK_P:{if (LLSIG.game.PLAYING&&musicPlayer.isPaused()) {musicPlayer.resume();} else {musicPlayer.pause();}}break; case KeyEvent.VK_Q:{if (LLSIG.game.PLAYING) {musicPlayer.pause();SaveSongData(song,lanes);}}break; } - if (LLSIG.game.PLAYING&&lane!=-1&&EDITMODE) { - Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()); - n.active=false; - System.out.println(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*4)/(double)4); - n.setBeatSnap(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*4)/(double)4); - LLSIG.game.lanes.get(lane).addNote(n); - } if (lane!=-1) { - if (PLAYING&&!EDITMODE) { + if (PLAYING&&EDITMODE) { + Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()); + n.active=false; + System.out.println(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*4)/(double)4); + n.setBeatSnap(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*4)/(double)4); + LLSIG.game.lanes.get(lane).addNote(n); + } + if (PLAYING&&!EDITMODE&&!EDITOR) { Lane l = lanes.get(lane); if (l.noteExists()) { Note n = l.getNote();