enable cursor
This commit is contained in:
@@ -25,7 +25,9 @@ import itdelatrisu.opsu.beatmap.Beatmap;
|
||||
import itdelatrisu.opsu.downloads.DownloadList;
|
||||
import itdelatrisu.opsu.downloads.Updater;
|
||||
import itdelatrisu.opsu.render.CurveRenderState;
|
||||
import itdelatrisu.opsu.ui.Cursor;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import itdelatrisu.opsu.ui.UI;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.opengl.Display;
|
||||
@@ -107,9 +109,14 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||
|
||||
private long exitconfirmation;
|
||||
|
||||
public final Cursor cursor;
|
||||
public boolean drawCursor;
|
||||
|
||||
public DisplayContainer(InstanceContainer instanceContainer, EventBus eventBus) {
|
||||
this.instanceContainer = instanceContainer;
|
||||
this.eventBus = eventBus;
|
||||
this.cursor = new Cursor();
|
||||
drawCursor = true;
|
||||
|
||||
outTransitionListener = new TransitionFinishedListener() {
|
||||
@Override
|
||||
@@ -169,7 +176,11 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||
Music.poll(delta);
|
||||
mouseX = input.getMouseX();
|
||||
mouseY = input.getMouseY();
|
||||
|
||||
state.update();
|
||||
if (drawCursor) {
|
||||
cursor.setCursorPosition(delta, mouseX, mouseY);
|
||||
}
|
||||
|
||||
int maxRenderInterval;
|
||||
if (Display.isVisible() && Display.isActive()) {
|
||||
@@ -196,6 +207,12 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||
bubNotifState.render(graphics);
|
||||
barNotifState.render(graphics);
|
||||
|
||||
cursor.updateAngle(renderDelta);
|
||||
if (drawCursor) {
|
||||
cursor.draw(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) || input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON));
|
||||
}
|
||||
UI.drawTooltip(graphics);
|
||||
|
||||
timeSinceLastRender = 0;
|
||||
|
||||
Display.update(false);
|
||||
@@ -216,6 +233,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||
initGL();
|
||||
glVersion = GL11.glGetString(GL11.GL_VERSION);
|
||||
glVendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
GLHelper.hideNativeCursor();
|
||||
}
|
||||
|
||||
public void teardown() {
|
||||
@@ -318,6 +336,10 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
||||
eventBus.post(new ResolutionChangedEvent(this.width, this.height));
|
||||
}
|
||||
|
||||
public void resetCursor() {
|
||||
cursor.reset(mouseX, mouseY);
|
||||
}
|
||||
|
||||
private int getDelta() {
|
||||
long time = getTime();
|
||||
int delta = (int) (time - lastFrame);
|
||||
|
||||
@@ -57,8 +57,8 @@ public class OpsuDanceInjector extends Injector {
|
||||
bind(ButtonMenu.class).asEagerSingleton();
|
||||
bind(SongMenu.class).asEagerSingleton();
|
||||
bind(DownloadsMenu.class).asEagerSingleton();
|
||||
bind(GameRanking.class).asEagerSingleton();
|
||||
bind(Game.class).asEagerSingleton();
|
||||
bind(GameRanking.class).asEagerSingleton();
|
||||
bind(GamePauseMenu.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
*/
|
||||
package yugecin.opsudance.utils;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Cursor;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.newdawn.slick.opengl.ImageIOImageData;
|
||||
@@ -25,8 +28,10 @@ import org.newdawn.slick.opengl.LoadableImageData;
|
||||
import org.newdawn.slick.opengl.TGAImageData;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class GLHelper {
|
||||
|
||||
@@ -85,4 +90,22 @@ public class GLHelper {
|
||||
Display.setIcon(bufs);
|
||||
}
|
||||
|
||||
public static void hideNativeCursor() {
|
||||
try {
|
||||
int min = Cursor.getMinCursorSize();
|
||||
IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
|
||||
Mouse.setNativeCursor(new Cursor(min, min, min / 2, min / 2, 1, tmp, null));
|
||||
} catch (LWJGLException e) {
|
||||
ErrorHandler.error("Cannot hide native cursor", e).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showNativeCursor() {
|
||||
try {
|
||||
Mouse.setNativeCursor(null);
|
||||
} catch (LWJGLException e) {
|
||||
ErrorHandler.error("Cannot show native cursor", e).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user