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. 15
      LLSIG/src/main/java/LLSIG/LLSIG.java

@ -408,14 +408,25 @@ 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 previousN = LLSIG.game.lanes.get(lane).lastNoteAdded;
double snapBeat = Math.round(((musicPlayer.getPlayPosition()-offset)/beatDelay)*NOTE_RECORD_BEAT_SNAP_MULTIPLE)/(double)NOTE_RECORD_BEAT_SNAP_MULTIPLE;
boolean allowed=true;
if (previousN!=null) {
if (previousN.getBeatSnap()==snapBeat) {
allowed=false;
}
}
if (allowed) {
Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition()); Note n = new Note(NoteType.NORMAL,musicPlayer.getPlayPosition());
n.active=false; n.active=false;
//System.out.println(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);
n.setBeatSnap(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).addNote(n);
LLSIG.game.lanes.get(lane).lastNoteAdded=n; LLSIG.game.lanes.get(lane).lastNoteAdded=n;
LLSIG.game.lanes.get(lane).keyPressed=true; LLSIG.game.lanes.get(lane).keyPressed=true;
} }
}
} else } else
if (PLAYING&&!EDITMODE&&!EDITOR) { if (PLAYING&&!EDITMODE&&!EDITOR) {
Lane l = lanes.get(lane); Lane l = lanes.get(lane);
@ -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