Compare commits

..

No commits in common. "2bb51035c2aaf1b7b83e38e9bb2fd7bd3bf4c04a" and "f20012c33f037bba14358c16afcdfab9b13b461e" have entirely different histories.

7 changed files with 13 additions and 55 deletions

View File

@ -16,7 +16,7 @@ public class EaglercraftVersion {
//Client name (Shadow) //Client name (Shadow)
public static final String projectForkName = new String(new byte[] {83, 104, 97, 100, 111, 119 }); public static final String projectForkName = new String(new byte[] {83, 104, 97, 100, 111, 119 });
//Build version (number + snapshot/official) //Build version (number + snapshot/official)
public static final String projectForkVersion = new String(new byte[] {52, 46, 53, 32, 115, 110, 97, 112, 115, 104, 111, 116, 45, 50, 52, 119, 50, 56, 97 }); public static final String projectForkVersion = new String(new byte[] {52, 46, 53, 32, 115, 110, 97, 112, 115, 104, 111, 116, 45, 50, 52, 119, 50, 55, 97 });
//Author name (PeytonPlayz585) //Author name (PeytonPlayz585)
public static final String projectForkVendor = new String(new byte[] {80, 101, 121, 116, 111, 110, 80, 108, 97, 121, 122, 53, 56, 53 }); public static final String projectForkVendor = new String(new byte[] {80, 101, 121, 116, 111, 110, 80, 108, 97, 121, 122, 53, 56, 53 });

View File

@ -202,9 +202,8 @@ public class WorldRenderer {
* SLOW AND STUPID COMPANION FUNCTION TO 'func_181672_a' * SLOW AND STUPID COMPANION FUNCTION TO 'func_181672_a'
*/ */
public void setVertexState(WorldRenderer.State state) { public void setVertexState(WorldRenderer.State state) {
int[] rawBuffer = state.getRawBuffer(); this.grow(state.getRawBuffer().length);
this.grow(rawBuffer.length); PlatformBufferFunctions.put(this.intBuffer, 0, state.getRawBuffer());
PlatformBufferFunctions.put(this.intBuffer, 0, rawBuffer);
this.vertexCount = state.getVertexCount(); this.vertexCount = state.getVertexCount();
this.vertexFormat = state.getVertexFormat(); this.vertexFormat = state.getVertexFormat();
} }

View File

@ -40,7 +40,7 @@ public class GuiButton extends Gui {
public int id; public int id;
public boolean enabled; public boolean enabled;
public boolean visible; public boolean visible;
public boolean hovered; protected boolean hovered;
public float fontScale = 1.0f; public float fontScale = 1.0f;
public GuiButton(int buttonId, int x, int y, String buttonText) { public GuiButton(int buttonId, int x, int y, String buttonText) {

View File

@ -11,9 +11,7 @@ import org.teavm.jso.dom.html.HTMLImageElement;
import org.teavm.jso.gamepad.GamepadEvent; import org.teavm.jso.gamepad.GamepadEvent;
import net.lax1dude.eaglercraft.v1_8.Display; import net.lax1dude.eaglercraft.v1_8.Display;
import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.minecraft.client.Minecraft;
import org.teavm.jso.gamepad.Gamepad; import org.teavm.jso.gamepad.Gamepad;
@ -29,8 +27,8 @@ public class Controller {
private static boolean left = false; private static boolean left = false;
private static boolean right = false; private static boolean right = false;
//Fixes 'slight' issues of stick drift people have been complaining about
private static double threshold = 0.3; private static double threshold = 0.3;
//Fixes 'slight' issues of stick drift people have been complaining about
private static double cameraThreshold = 4.0; private static double cameraThreshold = 4.0;
private static double cursorThreshold = 0.4; private static double cursorThreshold = 0.4;
@ -38,7 +36,6 @@ public class Controller {
private static ButtonState[] button = new ButtonState[30]; private static ButtonState[] button = new ButtonState[30];
public static HTMLImageElement cursor; public static HTMLImageElement cursor;
public static boolean isActive = false;
public static final int getDX() { public static final int getDX() {
if(dx < 0.0) { if(dx < 0.0) {
@ -159,10 +156,6 @@ public class Controller {
} }
} }
if(getDX() > 0 || getDY() > 0 || getDX() < 0 || getDY() < 0) {
isActive = true;
}
forward = axes[1] < -threshold; forward = axes[1] < -threshold;
backwards = axes[1] > threshold; backwards = axes[1] > threshold;
left = axes[0] < -threshold; left = axes[0] < -threshold;
@ -179,11 +172,9 @@ public class Controller {
if(button[i] == ButtonState.PRESSED) { if(button[i] == ButtonState.PRESSED) {
button[i] = ButtonState.HELD; button[i] = ButtonState.HELD;
isActive = true;
} else { } else {
if(!(button[i] == ButtonState.HELD)) { if(!(button[i] == ButtonState.HELD)) {
button[i] = ButtonState.PRESSED; button[i] = ButtonState.PRESSED;
isActive = true;
} }
} }
} else if(!gamePad.getButtons()[i].isPressed() && index == activeController) { } else if(!gamePad.getButtons()[i].isPressed() && index == activeController) {
@ -198,10 +189,6 @@ public class Controller {
updateAxes(gamePad); updateAxes(gamePad);
updateButtons(gamePad, index); 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) { public static void addCursor(int x, int y) {
@ -259,7 +246,6 @@ public class Controller {
@Override @Override
public void handleEvent(GamepadEvent arg0) { public void handleEvent(GamepadEvent arg0) {
connectedControllers.add(arg0.getGamepad().getIndex()); connectedControllers.add(arg0.getGamepad().getIndex());
isActive = true;
System.out.println("Controller connected!"); System.out.println("Controller connected!");
} }
}); });
@ -271,7 +257,6 @@ public class Controller {
if(connectedControllers.contains(index)) { if(connectedControllers.contains(index)) {
connectedControllers.remove(index); connectedControllers.remove(index);
resetButtonStates(); resetButtonStates();
isActive = false;
System.out.println("Controller disconnected!"); System.out.println("Controller disconnected!");
} }
} }

View File

@ -21,7 +21,6 @@ import org.teavm.jso.dom.html.HTMLElement;
import org.teavm.jso.webgl.WebGLFramebuffer; import org.teavm.jso.webgl.WebGLFramebuffer;
import org.teavm.jso.webgl.WebGLRenderbuffer; 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.EagUtils;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.EarlyLoadScreen; import net.lax1dude.eaglercraft.v1_8.internal.teavm.EarlyLoadScreen;
import net.lax1dude.eaglercraft.v1_8.internal.teavm.WebGL2RenderingContext; import net.lax1dude.eaglercraft.v1_8.internal.teavm.WebGL2RenderingContext;
@ -129,7 +128,6 @@ public class PlatformInput {
int b = evt.getButton(); int b = evt.getButton();
buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true; buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true;
mouseEvents.add(evt); mouseEvents.add(evt);
Controller.isActive = false;
} }
}); });
canvas.addEventListener("mouseup", mouseup = new EventListener<MouseEvent>() { canvas.addEventListener("mouseup", mouseup = new EventListener<MouseEvent>() {
@ -140,7 +138,6 @@ public class PlatformInput {
int b = evt.getButton(); int b = evt.getButton();
buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false; buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false;
mouseEvents.add(evt); mouseEvents.add(evt);
Controller.isActive = false;
} }
}); });
canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() { canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() {
@ -155,21 +152,18 @@ public class PlatformInput {
if(hasBeenActive()) { if(hasBeenActive()) {
mouseEvents.add(evt); mouseEvents.add(evt);
} }
Controller.isActive = false;
} }
}); });
canvas.addEventListener("mouseenter", mouseenter = new EventListener<MouseEvent>() { canvas.addEventListener("mouseenter", mouseenter = new EventListener<MouseEvent>() {
@Override @Override
public void handleEvent(MouseEvent evt) { public void handleEvent(MouseEvent evt) {
isMouseOverWindow = true; isMouseOverWindow = true;
Controller.isActive = false;
} }
}); });
canvas.addEventListener("mouseleave", mouseleave = new EventListener<MouseEvent>() { canvas.addEventListener("mouseleave", mouseleave = new EventListener<MouseEvent>() {
@Override @Override
public void handleEvent(MouseEvent evt) { public void handleEvent(MouseEvent evt) {
isMouseOverWindow = false; isMouseOverWindow = false;
Controller.isActive = false;
} }
}); });
win.addEventListener("keydown", keydown = new EventListener<KeyboardEvent>() { win.addEventListener("keydown", keydown = new EventListener<KeyboardEvent>() {
@ -185,7 +179,6 @@ public class PlatformInput {
int ww = processFunctionKeys(w); int ww = processFunctionKeys(w);
keyStates[KeyboardConstants.getEaglerKeyFromBrowser(ww, ww == w ? evt.getLocation() : 0)] = true; keyStates[KeyboardConstants.getEaglerKeyFromBrowser(ww, ww == w ? evt.getLocation() : 0)] = true;
keyEvents.add(evt); keyEvents.add(evt);
Controller.isActive = false;
} }
}); });
win.addEventListener("keyup", keyup = new EventListener<KeyboardEvent>() { win.addEventListener("keyup", keyup = new EventListener<KeyboardEvent>() {
@ -204,7 +197,6 @@ public class PlatformInput {
} }
} }
keyEvents.add(evt); keyEvents.add(evt);
Controller.isActive = false;
} }
}); });
win.addEventListener("keypress", keypress = new EventListener<KeyboardEvent>() { win.addEventListener("keypress", keypress = new EventListener<KeyboardEvent>() {
@ -212,7 +204,6 @@ public class PlatformInput {
public void handleEvent(KeyboardEvent evt) { public void handleEvent(KeyboardEvent evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
Controller.isActive = false;
if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt); if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt);
} }
}); });
@ -223,7 +214,6 @@ public class PlatformInput {
evt.stopPropagation(); evt.stopPropagation();
mouseEvents.add(evt); mouseEvents.add(evt);
mouseDWheel += evt.getDeltaY(); mouseDWheel += evt.getDeltaY();
Controller.isActive = false;
} }
}); });
win.addEventListener("blur", new EventListener<WheelEvent>() { win.addEventListener("blur", new EventListener<WheelEvent>() {
@ -236,14 +226,12 @@ public class PlatformInput {
for(int i = 0; i < keyStates.length; ++i) { for(int i = 0; i < keyStates.length; ++i) {
keyStates[i] = false; keyStates[i] = false;
} }
Controller.isActive = false;
} }
}); });
win.addEventListener("focus", new EventListener<WheelEvent>() { win.addEventListener("focus", new EventListener<WheelEvent>() {
@Override @Override
public void handleEvent(WheelEvent evt) { public void handleEvent(WheelEvent evt) {
isWindowFocused = true; isWindowFocused = true;
Controller.isActive = false;
} }
}); });
win.getDocument().addEventListener("pointerlockchange", pointerlock = new EventListener<WheelEvent>() { win.getDocument().addEventListener("pointerlockchange", pointerlock = new EventListener<WheelEvent>() {
@ -263,7 +251,6 @@ public class PlatformInput {
}, 60); }, 60);
mouseDX = 0.0D; mouseDX = 0.0D;
mouseDY = 0.0D; mouseDY = 0.0D;
Controller.isActive = false;
} }
}); });
@ -516,16 +503,10 @@ public class PlatformInput {
} }
public static int mouseGetX() { public static int mouseGetX() {
if(Controller.cursor != null) {
return Controller.cursor.getOffsetLeft();
}
return mouseX; return mouseX;
} }
public static int mouseGetY() { public static int mouseGetY() {
if(Controller.cursor != null) {
return canvas.getClientHeight() - Controller.cursor.getOffsetTop();
}
return mouseY; return mouseY;
} }

View File

@ -1300,10 +1300,14 @@ public class Minecraft extends ModData implements IThreadListener {
Controller.tick(); Controller.tick();
if(this.currentScreen != null && Controller.isActive && Controller.cursor == null) { if(this.currentScreen != null) {
Controller.addCursor(0, 0); if(Controller.cursor == null) {
} else if(Controller.cursor != null) { Controller.addCursor(0, 0);
Controller.removeCursor(); }
} else {
if(Controller.cursor != null) {
Controller.removeCursor();
}
} }
if (this.rightClickDelayTimer > 0) { if (this.rightClickDelayTimer > 0) {

View File

@ -425,17 +425,6 @@ public abstract class GuiScreen extends Gui implements GuiYesNoCallback {
this.mc.thePlayer.sendChatMessage(msg); 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, * Called when the mouse is clicked. Args : mouseX, mouseY,