Prevent double presses when adding notes in editing mode.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 3 years ago
parent 84b6ddaf0d
commit ede61ed878
  1. 27
      LLSIG/src/main/java/LLSIG/LLSIG.java

@ -408,13 +408,24 @@ public class LLSIG implements KeyListener{
} else } else
if (PLAYING&&EDITMODE) { if (PLAYING&&EDITMODE) {
if (!LLSIG.game.lanes.get(lane).keyPressed) { if (!LLSIG.game.lanes.get(lane).keyPressed) {
Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()); Note previousN = LLSIG.game.lanes.get(lane).lastNoteAdded;
n.active=false; double snapBeat = Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*NOTE_RECORD_BEAT_SNAP_MULTIPLE)/(double)NOTE_RECORD_BEAT_SNAP_MULTIPLE;
//System.out.println(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*NOTE_RECORD_BEAT_SNAP_MULTIPLE)/(double)NOTE_RECORD_BEAT_SNAP_MULTIPLE); boolean allowed=true;
n.setBeatSnap(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*NOTE_RECORD_BEAT_SNAP_MULTIPLE)/(double)NOTE_RECORD_BEAT_SNAP_MULTIPLE); if (previousN!=null) {
LLSIG.game.lanes.get(lane).addNote(n); if (previousN.getBeatSnap()==snapBeat) {
LLSIG.game.lanes.get(lane).lastNoteAdded=n; allowed=false;
LLSIG.game.lanes.get(lane).keyPressed=true; }
}
if (allowed) {
Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition());
n.active=false;
//System.out.println(Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*NOTE_RECORD_BEAT_SNAP_MULTIPLE)/(double)NOTE_RECORD_BEAT_SNAP_MULTIPLE);
n.setBeatSnap(snapBeat);
LLSIG.game.lanes.get(lane).addNote(n);
LLSIG.game.lanes.get(lane).lastNoteAdded=n;
LLSIG.game.lanes.get(lane).keyPressed=true;
}
} }
} else } else
if (PLAYING&&!EDITMODE&&!EDITOR) { if (PLAYING&&!EDITMODE&&!EDITOR) {
@ -482,7 +493,7 @@ public class LLSIG implements KeyListener{
lastNote.setNoteType(NoteType.HOLD); lastNote.setNoteType(NoteType.HOLD);
lastNote.setBeatSnapEnd(noteBeat); lastNote.setBeatSnapEnd(noteBeat);
lastNote.active2=false; lastNote.active2=false;
LLSIG.game.lanes.get(lane).lastNoteAdded=null; //LLSIG.game.lanes.get(lane).lastNoteAdded=null;
} }
} }
LLSIG.game.lanes.get(lane).keyPressed=false; LLSIG.game.lanes.get(lane).keyPressed=false;

Loading…
Cancel
Save