Control key implemented in the editor.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
sigonasr2, Sig, Sigo 2021-10-15 00:22:37 +00:00
parent d20ffe3c1e
commit 48b74c92a1

View File

@ -3,6 +3,8 @@ import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,7 +25,7 @@ import main.java.sig.utils.FileUtils;
import javafx.application.Platform; import javafx.application.Platform;
public class LLSIG implements KeyListener{ public class LLSIG implements KeyListener,MouseWheelListener{
Player musicPlayer; Player musicPlayer;
JFrame window; JFrame window;
Thread gameLoop; Thread gameLoop;
@ -51,6 +53,7 @@ public class LLSIG implements KeyListener{
public boolean BPM_MEASURE = false; public boolean BPM_MEASURE = false;
public boolean PLAYING = true; //Whether or not a song is loaded and playing. public boolean PLAYING = true; //Whether or not a song is loaded and playing.
public boolean EDITOR = false; //Whether or not we are in beatmap editing mode. public boolean EDITOR = false; //Whether or not we are in beatmap editing mode.
public boolean HOLDING_CTRL_KEY = false;
public static double EDITOR_CURSOR_BEAT = 0; public static double EDITOR_CURSOR_BEAT = 0;
public static double PREVIOUS_CURSOR_BEAT = 0; public static double PREVIOUS_CURSOR_BEAT = 0;
@ -355,6 +358,7 @@ public class LLSIG implements KeyListener{
}); });
}); });
}break; }break;
case KeyEvent.VK_CONTROL:{HOLDING_CTRL_KEY=true;}break;
} }
} else { } else {
switch (e.getKeyCode()) { switch (e.getKeyCode()) {
@ -486,6 +490,7 @@ public class LLSIG implements KeyListener{
case KeyEvent.VK_K:{lane=6;}break; case KeyEvent.VK_K:{lane=6;}break;
case KeyEvent.VK_L:{lane=7;}break; case KeyEvent.VK_L:{lane=7;}break;
case KeyEvent.VK_SEMICOLON:{lane=8;}break; case KeyEvent.VK_SEMICOLON:{lane=8;}break;
case KeyEvent.VK_CONTROL:{HOLDING_CTRL_KEY=false;}break;
} }
if (lane!=-1) { if (lane!=-1) {
if (EDITOR) { if (EDITOR) {
@ -532,4 +537,19 @@ public class LLSIG implements KeyListener{
} }
} }
} }
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (EDITOR) {
if (e.getWheelRotation()!=0) {
if (Math.abs(e.getWheelRotation())<0) {
//Rotated up.
EDITOR_CURSOR_BEAT=Math.max(EDITOR_CURSOR_BEAT-(1d/EDITOR_BEAT_DIVISIONS),0);
} else {
//Rotated down.
EDITOR_CURSOR_BEAT+=1d/EDITOR_BEAT_DIVISIONS;
}
}
}
}
} }