Controller mouse click
This commit is contained in:
parent
f20012c33f
commit
48f8a49dd3
|
@ -40,7 +40,7 @@ public class GuiButton extends Gui {
|
|||
public int id;
|
||||
public boolean enabled;
|
||||
public boolean visible;
|
||||
protected boolean hovered;
|
||||
public boolean hovered;
|
||||
public float fontScale = 1.0f;
|
||||
|
||||
public GuiButton(int buttonId, int x, int y, String buttonText) {
|
||||
|
|
|
@ -11,7 +11,9 @@ import org.teavm.jso.dom.html.HTMLImageElement;
|
|||
import org.teavm.jso.gamepad.GamepadEvent;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Display;
|
||||
import net.lax1dude.eaglercraft.v1_8.Mouse;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import org.teavm.jso.gamepad.Gamepad;
|
||||
|
||||
|
@ -27,8 +29,8 @@ public class Controller {
|
|||
private static boolean left = false;
|
||||
private static boolean right = false;
|
||||
|
||||
private static double threshold = 0.3;
|
||||
//Fixes 'slight' issues of stick drift people have been complaining about
|
||||
private static double threshold = 0.3;
|
||||
private static double cameraThreshold = 4.0;
|
||||
private static double cursorThreshold = 0.4;
|
||||
|
||||
|
@ -189,6 +191,10 @@ public class Controller {
|
|||
updateAxes(gamePad);
|
||||
updateButtons(gamePad, index);
|
||||
}
|
||||
|
||||
if(cursor != null && isButtonPressed(0) || isButtonDown(0)) {
|
||||
Minecraft.getMinecraft().currentScreen.controllerClicked(Mouse.getX(), Mouse.getY());
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCursor(int x, int y) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.teavm.jso.dom.html.HTMLElement;
|
|||
import org.teavm.jso.webgl.WebGLFramebuffer;
|
||||
import org.teavm.jso.webgl.WebGLRenderbuffer;
|
||||
|
||||
import net.PeytonPlayz585.shadow.input.Controller;
|
||||
import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.EarlyLoadScreen;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.teavm.WebGL2RenderingContext;
|
||||
|
@ -503,10 +504,16 @@ public class PlatformInput {
|
|||
}
|
||||
|
||||
public static int mouseGetX() {
|
||||
if(Controller.cursor != null) {
|
||||
return Controller.cursor.getOffsetLeft();
|
||||
}
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
public static int mouseGetY() {
|
||||
if(Controller.cursor != null) {
|
||||
return canvas.getClientHeight() - Controller.cursor.getOffsetTop();
|
||||
}
|
||||
return mouseY;
|
||||
}
|
||||
|
||||
|
|
|
@ -426,6 +426,17 @@ public abstract class GuiScreen extends Gui implements GuiYesNoCallback {
|
|||
this.mc.thePlayer.sendChatMessage(msg);
|
||||
}
|
||||
|
||||
public void controllerClicked(int x, int y) {
|
||||
for (int i = 0; i < this.buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton) this.buttonList.get(i);
|
||||
if (guibutton.enabled && guibutton.visible && guibutton.hovered) {
|
||||
this.selectedButton = guibutton;
|
||||
guibutton.playPressSound(this.mc.getSoundHandler());
|
||||
this.actionPerformed(guibutton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**+
|
||||
* Called when the mouse is clicked. Args : mouseX, mouseY,
|
||||
* clickedButton
|
||||
|
|
Loading…
Reference in New Issue
Block a user