Added copy/paste and screenshot

This commit is contained in:
LAX1DUDE 2022-03-30 17:05:47 -07:00
parent 7a2a314928
commit 050bf47771
10 changed files with 198 additions and 114 deletions

View File

@ -19,7 +19,11 @@ public class MinecraftMain {
EaglerAdapter.initializeContext(); EaglerAdapter.initializeContext();
LocalStorageManager.loadStorage(); LocalStorageManager.loadStorage();
ServerList.loadDefaultServers(Base64.encodeBase64String(EaglerAdapter.loadLocalStorage("forced")));
byte[] b = EaglerAdapter.loadLocalStorage("forced");
if(b != null) {
ServerList.loadDefaultServers(Base64.encodeBase64String(b));
}
Minecraft mc = new Minecraft(); Minecraft mc = new Minecraft();
mc.run(); mc.run();

View File

@ -38,6 +38,7 @@ import org.lwjgl.LWJGLException;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.openal.AL;
import org.lwjgl.opengl.ARBDebugOutput; import org.lwjgl.opengl.ARBDebugOutput;
import org.lwjgl.opengl.ARBDebugOutputCallback; import org.lwjgl.opengl.ARBDebugOutputCallback;
import org.lwjgl.opengl.ARBOcclusionQuery2; import org.lwjgl.opengl.ARBOcclusionQuery2;
@ -726,10 +727,16 @@ public class EaglerAdapterImpl2 {
Display.destroy(); Display.destroy();
Keyboard.destroy(); Keyboard.destroy();
Mouse.destroy(); Mouse.destroy();
eagler.dispose(); EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
eagler.dispose();
}
});
if(ss != null) { if(ss != null) {
ss.cleanup(); ss.cleanup();
} }
AL.destroy();
} }
public static final boolean isWindows() { public static final boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows"); return System.getProperty("os.name").toLowerCase().contains("windows");
@ -1035,6 +1042,9 @@ public class EaglerAdapterImpl2 {
ss.setListenerOrientation(var13, var14, var15, var16, var17, var18); ss.setListenerOrientation(var13, var14, var15, var16, var17, var18);
ss.setListenerVelocity(vx, vy, vz); ss.setListenerVelocity(vx, vy, vz);
} }
public static final void setPlaybackOffsetDelay(float f) {
// nah
}
private static int playbackId = 0; private static int playbackId = 0;
public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) { public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) {
int id = ++playbackId; int id = ++playbackId;
@ -1154,7 +1164,7 @@ public class EaglerAdapterImpl2 {
return Runtime.getRuntime().freeMemory(); return Runtime.getRuntime().freeMemory();
} }
public static final void exit() { public static final void exit() {
System.exit(0); Runtime.getRuntime().halt(0);
} }
public static final int _wArrayByteLength(Object obj) { public static final int _wArrayByteLength(Object obj) {
return ((IntBuffer)obj).remaining() * 4; return ((IntBuffer)obj).remaining() * 4;
@ -1177,6 +1187,23 @@ public class EaglerAdapterImpl2 {
appendbuffer.flip(); appendbuffer.flip();
return appendbuffer; return appendbuffer;
} }
public static final String getUserAgent() {
return System.getProperty("os.name");
}
public static final String getClipboard() {
return "<err>";
}
public static final void setClipboard(String str) {
// todo
}
public static final void saveScreenshot() {
}
private static class ServerQueryImpl extends WebSocketClient implements ServerQuery { private static class ServerQueryImpl extends WebSocketClient implements ServerQuery {
private final LinkedList<QueryResponse> queryResponses = new LinkedList(); private final LinkedList<QueryResponse> queryResponses = new LinkedList();

View File

@ -9,11 +9,9 @@ import java.util.HashMap;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2;
import net.lax1dude.eaglercraft.glemu.vector.Matrix3f;
import net.lax1dude.eaglercraft.glemu.vector.Matrix4f; import net.lax1dude.eaglercraft.glemu.vector.Matrix4f;
import net.lax1dude.eaglercraft.glemu.vector.Vector3f; import net.lax1dude.eaglercraft.glemu.vector.Vector3f;
import net.lax1dude.eaglercraft.glemu.vector.Vector4f; import net.lax1dude.eaglercraft.glemu.vector.Vector4f;
import net.minecraft.src.RenderItem;
public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
@ -606,6 +604,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
case GL_DST_COLOR: pp1 = _wGL_DST_COLOR; break; case GL_DST_COLOR: pp1 = _wGL_DST_COLOR; break;
case GL_SRC_COLOR: pp1 = _wGL_SRC_COLOR; break; case GL_SRC_COLOR: pp1 = _wGL_SRC_COLOR; break;
case GL_ONE_MINUS_SRC_COLOR: pp1 = _wGL_ONE_MINUS_SRC_COLOR; break; case GL_ONE_MINUS_SRC_COLOR: pp1 = _wGL_ONE_MINUS_SRC_COLOR; break;
case GL_ONE_MINUS_DST_COLOR: pp1 = _wGL_ONE_MINUS_DST_COLOR; break;
case GL_ONE: pp1 = _wGL_ONE; break; case GL_ONE: pp1 = _wGL_ONE; break;
case GL_ZERO: pp1 = _wGL_ZERO; break; case GL_ZERO: pp1 = _wGL_ZERO; break;
} }
@ -617,6 +616,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
case GL_DST_COLOR: pp2 = _wGL_DST_COLOR; break; case GL_DST_COLOR: pp2 = _wGL_DST_COLOR; break;
case GL_SRC_COLOR: pp2 = _wGL_SRC_COLOR; break; case GL_SRC_COLOR: pp2 = _wGL_SRC_COLOR; break;
case GL_ONE_MINUS_SRC_COLOR: pp2 = _wGL_ONE_MINUS_SRC_COLOR; break; case GL_ONE_MINUS_SRC_COLOR: pp2 = _wGL_ONE_MINUS_SRC_COLOR; break;
case GL_ONE_MINUS_DST_COLOR: pp1 = _wGL_ONE_MINUS_DST_COLOR; break;
case GL_ONE: pp2 = _wGL_ONE; break; case GL_ONE: pp2 = _wGL_ONE; break;
case GL_ZERO: pp2 = _wGL_ZERO; break; case GL_ZERO: pp2 = _wGL_ZERO; break;
} }

View File

@ -26,6 +26,7 @@ public class Minecraft implements Runnable {
public PlayerControllerMP playerController; public PlayerControllerMP playerController;
private boolean fullscreen = false; private boolean fullscreen = false;
private boolean hasCrashed = false; private boolean hasCrashed = false;
private boolean isGonnaTakeDatScreenShot = false;
public int displayWidth; public int displayWidth;
public int displayHeight; public int displayHeight;
@ -485,7 +486,7 @@ public class Minecraft implements Runnable {
} }
public static EnumOS getOs() { public static EnumOS getOs() {
String var0 = System.getProperty("os.name").toLowerCase(); String var0 = EaglerAdapter.getUserAgent().toLowerCase();
return var0.contains("win") ? EnumOS.WINDOWS return var0.contains("win") ? EnumOS.WINDOWS
: (var0.contains("mac") ? EnumOS.MACOS : (var0.contains("mac") ? EnumOS.MACOS
: (var0.contains("solaris") ? EnumOS.SOLARIS : (var0.contains("sunos") ? EnumOS.SOLARIS : (var0.contains("linux") ? EnumOS.LINUX : (var0.contains("unix") ? EnumOS.LINUX : EnumOS.UNKNOWN))))); : (var0.contains("solaris") ? EnumOS.SOLARIS : (var0.contains("sunos") ? EnumOS.SOLARIS : (var0.contains("linux") ? EnumOS.LINUX : (var0.contains("unix") ? EnumOS.LINUX : EnumOS.UNKNOWN)))));
@ -523,6 +524,14 @@ public class Minecraft implements Runnable {
if(!this.inGameHasFocus) this.setIngameFocus(); if(!this.inGameHasFocus) this.setIngameFocus();
} }
} }
public boolean isChatOpen() {
return this.currentScreen != null && (this.currentScreen instanceof GuiChat);
}
public String getServerURI() {
return this.getNetHandler() != null ? this.getNetHandler().getNetManager().getServerURI() : "[not connected]";
}
/** /**
* Checks for an OpenGL error. If there is one, prints the error ID and error * Checks for an OpenGL error. If there is one, prints the error ID and error
@ -575,36 +584,10 @@ public class Minecraft implements Runnable {
public void run() { public void run() {
this.running = true; this.running = true;
this.startGame();
//try { while (this.running) {
this.startGame(); this.runGameLoop();
//} catch (Exception var11) { }
// var11.printStackTrace();
// return;
//}
//try {
while (this.running) {
if (this.refreshTexturePacksScheduled) {
this.refreshTexturePacksScheduled = false;
this.renderEngine.refreshTextures();
}
try {
this.runGameLoop();
} catch (OutOfMemoryError var10) {
this.freeMemory();
this.displayGuiScreen(new GuiMemoryErrorScreen());
System.gc();
}
}
//} catch (MinecraftError var12) {
// ;
//} catch (Throwable var14) {
// var14.printStackTrace();
//}
EaglerAdapter.destroyContext(); EaglerAdapter.destroyContext();
EaglerAdapter.exit(); EaglerAdapter.exit();
} }
@ -613,6 +596,11 @@ public class Minecraft implements Runnable {
* Called repeatedly from run() * Called repeatedly from run()
*/ */
private void runGameLoop() { private void runGameLoop() {
if (this.refreshTexturePacksScheduled) {
this.refreshTexturePacksScheduled = false;
this.renderEngine.refreshTextures();
}
AxisAlignedBB.getAABBPool().cleanPool(); AxisAlignedBB.getAABBPool().cleanPool();
if (this.theWorld != null) { if (this.theWorld != null) {
@ -696,8 +684,6 @@ public class Minecraft implements Runnable {
this.guiAchievement.updateAchievementWindow(); this.guiAchievement.updateAchievementWindow();
this.mcProfiler.startSection("root"); this.mcProfiler.startSection("root");
this.screenshotListener();
if (!this.fullscreen && (EaglerAdapter.getCanvasWidth() != this.displayWidth || EaglerAdapter.getCanvasHeight() != this.displayHeight)) { if (!this.fullscreen && (EaglerAdapter.getCanvasWidth() != this.displayWidth || EaglerAdapter.getCanvasHeight() != this.displayHeight)) {
this.displayWidth = EaglerAdapter.getCanvasWidth(); this.displayWidth = EaglerAdapter.getCanvasWidth();
this.displayHeight = EaglerAdapter.getCanvasHeight(); this.displayHeight = EaglerAdapter.getCanvasHeight();
@ -731,6 +717,11 @@ public class Minecraft implements Runnable {
EaglerAdapter.syncDisplay(EntityRenderer.performanceToFps(this.func_90020_K())); EaglerAdapter.syncDisplay(EntityRenderer.performanceToFps(this.func_90020_K()));
} }
if(isGonnaTakeDatScreenShot) {
isGonnaTakeDatScreenShot = false;
EaglerAdapter.saveScreenshot();
}
EaglerAdapter.doJavascriptCoroutines(); EaglerAdapter.doJavascriptCoroutines();
this.mcProfiler.endSection(); this.mcProfiler.endSection();
@ -741,47 +732,6 @@ public class Minecraft implements Runnable {
return this.currentScreen != null && this.currentScreen instanceof GuiMainMenu ? 2 : this.gameSettings.limitFramerate; return this.currentScreen != null && this.currentScreen instanceof GuiMainMenu ? 2 : this.gameSettings.limitFramerate;
} }
public void freeMemory() {
try {
this.renderGlobal.deleteAllDisplayLists();
} catch (Throwable var4) {
;
}
try {
System.gc();
AxisAlignedBB.getAABBPool().clearPool();
this.theWorld.getWorldVec3Pool().clearAndFreeCache();
} catch (Throwable var3) {
;
}
try {
System.gc();
this.loadWorld((WorldClient) null);
} catch (Throwable var2) {
;
}
System.gc();
}
/**
* checks if keys are down
*/
private void screenshotListener() {
/*
if (EaglerAdapter.isKeyDown(60)) {
if (!this.isTakingScreenshot) {
this.isTakingScreenshot = true;
this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, this.displayWidth, this.displayHeight));
}
} else {
this.isTakingScreenshot = false;
}
*/
}
/** /**
* Update debugProfilerName in response to number keys in debug screen * Update debugProfilerName in response to number keys in debug screen
*/ */
@ -1190,7 +1140,7 @@ public class Minecraft implements Runnable {
if (EaglerAdapter.getEventKeyState()) { if (EaglerAdapter.getEventKeyState()) {
KeyBinding.onTick(EaglerAdapter.getEventKey()); KeyBinding.onTick(EaglerAdapter.getEventKey());
} }
boolean F3down = (this.gameSettings.keyBindFunction.pressed && EaglerAdapter.isKeyDown(4)); boolean F3down = (this.gameSettings.keyBindFunction.pressed && EaglerAdapter.isKeyDown(4));
if (this.field_83002_am > 0L) { if (this.field_83002_am > 0L) {
@ -1206,6 +1156,7 @@ public class Minecraft implements Runnable {
} }
if (EaglerAdapter.getEventKeyState()) { if (EaglerAdapter.getEventKeyState()) {
isGonnaTakeDatScreenShot |= (this.gameSettings.keyBindFunction.pressed && EaglerAdapter.getEventKey() == 3);
if (EaglerAdapter.getEventKey() == 87) { if (EaglerAdapter.getEventKey() == 87) {
this.toggleFullscreen(); this.toggleFullscreen();
} else { } else {

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglercraftRandom; import net.lax1dude.eaglercraft.EaglercraftRandom;
import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.TextureLocation;
@ -407,14 +408,16 @@ public class GuiIngame extends Gui {
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 2, 14737632); this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 2, 14737632);
var45 = "Allocated memory: " + var37 * 100L / var39 + "% (" + var37 / 1024L / 1024L + "MB)"; var45 = "Allocated memory: " + var37 * 100L / var39 + "% (" + var37 / 1024L / 1024L + "MB)";
this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 12, 14737632); this.drawString(var8, var45, var6 - var8.getStringWidth(var45) - 2, 12, 14737632);
this.drawString(var8, "Player is not using an xbox live account", 2, 64, 0xFFBBBB);
this.drawString(var8, "Using cracked server @ " + mc.getServerURI(), 2, 73, 0xFFBBBB);
var47 = MathHelper.floor_double(this.mc.thePlayer.posX); var47 = MathHelper.floor_double(this.mc.thePlayer.posX);
var22 = MathHelper.floor_double(this.mc.thePlayer.posY); var22 = MathHelper.floor_double(this.mc.thePlayer.posY);
var23 = MathHelper.floor_double(this.mc.thePlayer.posZ); var23 = MathHelper.floor_double(this.mc.thePlayer.posZ);
this.drawString(var8, "x: "+doubleToShorterString(this.mc.thePlayer.posX)+" ("+var47+") // c: "+(var47 >> 4)+" ("+(var47 & 15)+")", 2, 64, 14737632); this.drawString(var8, "x: "+doubleToShorterString(this.mc.thePlayer.posX)+" ("+var47+") // c: "+(var47 >> 4)+" ("+(var47 & 15)+")", 2, 92, 14737632);
this.drawString(var8, "y: "+doubleToShorterString(this.mc.thePlayer.posY)+" ("+var22+") (feet pos)", 2, 72, 14737632); this.drawString(var8, "y: "+doubleToShorterString(this.mc.thePlayer.posY)+" ("+var22+") (feet pos)", 2, 100, 14737632);
this.drawString(var8, "z: "+doubleToShorterString(this.mc.thePlayer.posZ)+" ("+var23+") // c: "+(var23 >> 4)+" ("+(var23 & 15)+")", 2, 80, 14737632); this.drawString(var8, "z: "+doubleToShorterString(this.mc.thePlayer.posZ)+" ("+var23+") // c: "+(var23 >> 4)+" ("+(var23 & 15)+")", 2, 108, 14737632);
var24 = MathHelper.floor_double((double) (this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; var24 = MathHelper.floor_double((double) (this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
this.drawString(var8, "f: " + var24 + " (" + Direction.directions[var24] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632); this.drawString(var8, "f: " + var24 + " (" + Direction.directions[var24] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 116, 14737632);
//this.drawString(var8, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] { Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()), //this.drawString(var8, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] { Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()),
// Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(var47, var23)) }), 2, 104, 14737632); // Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(var47, var23)) }), 2, 104, 14737632);
@ -445,6 +448,12 @@ public class GuiIngame extends Gui {
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f); EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
var8.drawStringWithShadow(this.mc.renderGlobal.getDebugInfoShort(), 2, 2, 16777215); var8.drawStringWithShadow(this.mc.renderGlobal.getDebugInfoShort(), 2, 2, 16777215);
var8.drawStringWithShadow("x: "+MathHelper.floor_double(this.mc.thePlayer.posX)+", y: "+MathHelper.floor_double(this.mc.thePlayer.posY)+", z: "+MathHelper.floor_double(this.mc.thePlayer.posZ), 2, 12, 16777215); var8.drawStringWithShadow("x: "+MathHelper.floor_double(this.mc.thePlayer.posX)+", y: "+MathHelper.floor_double(this.mc.thePlayer.posY)+", z: "+MathHelper.floor_double(this.mc.thePlayer.posZ), 2, 12, 16777215);
int offset = this.mc.isChatOpen() ? 135 : 0;
int offset2 = this.mc.isChatOpen() ? 4 : 0;
String str = "not using an xbox live account";
var8.drawStringWithShadow(str, (var6 * 4 / 3) - 2 - var8.getStringWidth(str) - offset, 2 + offset2, 0xFFDDDD);
str = "eaglercraft: " + ConfigConstants.version;
var8.drawStringWithShadow(str, (var6 * 4 / 3) - 2 - var8.getStringWidth(str) - offset, 12 + offset2, 14737632);
EaglerAdapter.glPopMatrix(); EaglerAdapter.glPopMatrix();
} }

View File

@ -199,10 +199,12 @@ public class GuiMainMenu extends GuiScreen {
if(par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) { if(par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) {
showAck = true; showAck = true;
} }
/*
w = this.fontRenderer.getStringWidth("debug console") * 3 / 4; w = this.fontRenderer.getStringWidth("debug console") * 3 / 4;
if(par1 >= 0 && par1 <= (w + 4) && par2 >= 0 && par2 <= 9) { if(par1 >= 0 && par1 <= (w + 4) && par2 >= 0 && par2 <= 9) {
EaglerAdapter.openConsole(); EaglerAdapter.openConsole();
} }
*/
} }
}else { }else {
if(par3 == 0) { if(par3 == 0) {
@ -432,12 +434,13 @@ public class GuiMainMenu extends GuiScreen {
*/ */
this.drawString(this.fontRenderer, "minecraft 1.5.2", 2, this.height - 20, 16777215); this.drawString(this.fontRenderer, "minecraft 1.5.2", 2, this.height - 20, 16777215);
this.drawString(this.fontRenderer, ConfigConstants.mainMenuString, 2, this.height - 10, 16777215); this.drawString(this.fontRenderer, ConfigConstants.mainMenuString + EnumChatFormatting.GRAY + " (cracked)", 2, this.height - 10, 16777215);
String var10 = "copyright " + Calendar.getInstance().get(Calendar.YEAR) + " calder young"; //String var10 = "Copyright " + Calendar.getInstance().get(Calendar.YEAR) + " Mojang AB.";
String var10 = "copyright 2013 Mojang AB";
this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 10, 16777215); this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 10, 16777215);
var10 = "all rights reserved"; var10 = "site resources are";
this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 20, 16777215); this.drawString(this.fontRenderer, var10, this.width - this.fontRenderer.getStringWidth(var10) - 2, this.height - 20, 16777215);
if (this.field_92025_p != null && this.field_92025_p.length() > 0) { if (this.field_92025_p != null && this.field_92025_p.length() > 0) {
@ -447,7 +450,19 @@ public class GuiMainMenu extends GuiScreen {
// this.field_92024_r) / 2, ((GuiButton)this.buttonList.get(0)).yPosition - 12, // this.field_92024_r) / 2, ((GuiButton)this.buttonList.get(0)).yPosition - 12,
// 16777215); // 16777215);
} }
/*
String lid = "(login is disabled, this copy violates Mojang's terms of service)";
int sl = this.fontRenderer.getStringWidth(lid);
EaglerAdapter.glPushMatrix();
float k = ((this.width - sl) * 3 / 4) < 80 ? 0.5f : 0.75f;
EaglerAdapter.glScalef(k, k, k);
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
this.drawString(fontRenderer, lid, (int)(this.width / k - sl) / 2, (int)((this.height - 19) / k), 0x88999999);
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
EaglerAdapter.glPopMatrix();
*/
var10 = "eaglercraft readme.txt"; var10 = "eaglercraft readme.txt";
int w = this.fontRenderer.getStringWidth(var10) * 3 / 4; int w = this.fontRenderer.getStringWidth(var10) * 3 / 4;
if(!showAck && par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) { if(!showAck && par1 >= (this.width - w - 4) && par1 <= this.width && par2 >= 0 && par2 <= 9) {
@ -460,7 +475,7 @@ public class GuiMainMenu extends GuiScreen {
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f); EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
this.drawString(this.fontRenderer, var10, 0, 0, 16777215); this.drawString(this.fontRenderer, var10, 0, 0, 16777215);
EaglerAdapter.glPopMatrix(); EaglerAdapter.glPopMatrix();
/*
var10 = "debug console"; var10 = "debug console";
w = this.fontRenderer.getStringWidth(var10) * 3 / 4; w = this.fontRenderer.getStringWidth(var10) * 3 / 4;
if(!showAck && par1 >= 0 && par1 <= (w + 4) && par2 >= 0 && par2 <= 9) { if(!showAck && par1 >= 0 && par1 <= (w + 4) && par2 >= 0 && par2 <= 9) {
@ -473,7 +488,7 @@ public class GuiMainMenu extends GuiScreen {
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f); EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
this.drawString(this.fontRenderer, var10, 0, 0, 16777215); this.drawString(this.fontRenderer, var10, 0, 0, 16777215);
EaglerAdapter.glPopMatrix(); EaglerAdapter.glPopMatrix();
*/
if(showAck) { if(showAck) {
super.drawScreen(0, 0, par3); super.drawScreen(0, 0, par3);
this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680); this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680);

View File

@ -250,8 +250,7 @@ public class GuiScreen extends Gui {
} }
public static boolean isCtrlKeyDown() { public static boolean isCtrlKeyDown() {
boolean var0 = EaglerAdapter.isKeyDown(28) && EaglerAdapter.getEventChar() == 0; return EaglerAdapter.isKeyDown(29) || EaglerAdapter.isKeyDown(157) || (isMacOs && EaglerAdapter.isKeyDown(28) || EaglerAdapter.isKeyDown(219) || EaglerAdapter.isKeyDown(220));
return EaglerAdapter.isKeyDown(29) || EaglerAdapter.isKeyDown(157) || isMacOs && (var0 || EaglerAdapter.isKeyDown(219) || EaglerAdapter.isKeyDown(220));
} }
public static boolean isShiftKeyDown() { public static boolean isShiftKeyDown() {

View File

@ -72,6 +72,9 @@ public class GuiTextField extends Gui {
* Sets the text of the textbox. * Sets the text of the textbox.
*/ */
public void setText(String par1Str) { public void setText(String par1Str) {
if(text.equals(par1Str)) {
return;
}
if (par1Str.length() > this.maxStringLength) { if (par1Str.length() > this.maxStringLength) {
this.text = par1Str.substring(0, this.maxStringLength); this.text = par1Str.substring(0, this.maxStringLength);
} else { } else {
@ -273,15 +276,24 @@ public class GuiTextField extends Gui {
return true; return true;
case 3: case 3:
GuiScreen.setClipboardString(this.getSelectedtext()); String s = this.getSelectedtext();
if(s != null && s.length() > 0) {
GuiScreen.setClipboardString(s);
}
return true; return true;
case 22: case 22:
this.writeText(GuiScreen.getClipboardString()); String s3 = GuiScreen.getClipboardString();
if(s3 != null && s3.length() > 0) {
this.writeText(s3);
}
return true; return true;
case 24: case 24:
GuiScreen.setClipboardString(this.getSelectedtext()); String s2 = this.getSelectedtext();
if(s2 != null && s2.length() > 0) {
GuiScreen.setClipboardString(s2);
}
this.writeText(""); this.writeText("");
return true; return true;
@ -296,7 +308,7 @@ public class GuiTextField extends Gui {
return true; return true;
case 199: case 200:
if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isShiftKeyDown()) {
this.setSelectionPos(0); this.setSelectionPos(0);
} else { } else {
@ -335,7 +347,7 @@ public class GuiTextField extends Gui {
return true; return true;
case 207: case 208:
if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isShiftKeyDown()) {
this.setSelectionPos(this.text.length()); this.setSelectionPos(this.text.length());
} else { } else {
@ -354,7 +366,27 @@ public class GuiTextField extends Gui {
return true; return true;
default: default:
if (ChatAllowedCharacters.isAllowedCharacter(par1)) { boolean ctrl = GuiScreen.isCtrlKeyDown();
if(ctrl && (par1 == 'c' || par1 == 'C')) {
String s5 = this.getSelectedtext();
if(s5.length() > 0) {
GuiScreen.setClipboardString(s5);
}
return true;
}else if(ctrl && (par1 == 'x' || par1 == 'X')) {
String s6 = this.getSelectedtext();
if(s6.length() > 0) {
GuiScreen.setClipboardString(s6);
this.writeText("");
}
return true;
}else if(ctrl && (par1 == 'v' || par1 == 'V')) {
String s4 = GuiScreen.getClipboardString();
if(s4 != null && s4.length() > 0) {
this.writeText(s4);
}
return true;
}else if (ChatAllowedCharacters.isAllowedCharacter(par1)) {
this.writeText(Character.toString(par1)); this.writeText(Character.toString(par1));
return true; return true;
} else { } else {
@ -434,7 +466,7 @@ public class GuiTextField extends Gui {
if (var6) { if (var6) {
if (var13) { if (var13) {
Gui.drawRect(var11, var8 - 1, var11 + 1, var8 + 1 + this.fontRenderer.FONT_HEIGHT, -3092272); Gui.drawRect(var11, var8 - 1, var11 + 1, var8 + 1 + this.fontRenderer.FONT_HEIGHT, var1 | 0xFF000000);
} else { } else {
this.fontRenderer.drawStringWithShadow("_", var11, var8, var1); this.fontRenderer.drawStringWithShadow("_", var11, var8, var1);
} }
@ -466,18 +498,18 @@ public class GuiTextField extends Gui {
} }
Tessellator var6 = Tessellator.instance; Tessellator var6 = Tessellator.instance;
EaglerAdapter.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); EaglerAdapter.glColor4f(0.2F, 0.2F, 1.0F, 1.0F);
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_ONE_MINUS_DST_COLOR, EaglerAdapter.GL_SRC_ALPHA);
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D); EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
EaglerAdapter.glEnable(EaglerAdapter.GL_COLOR_LOGIC_OP);
EaglerAdapter.glLogicOp(EaglerAdapter.GL_OR_REVERSE);
var6.startDrawingQuads(); var6.startDrawingQuads();
var6.addVertex((double) par1, (double) par4, 0.0D); var6.addVertex((double) par1, (double) par4, 0.0D);
var6.addVertex((double) par3, (double) par4, 0.0D); var6.addVertex((double) par3, (double) par4, 0.0D);
var6.addVertex((double) par3, (double) par2, 0.0D); var6.addVertex((double) par3, (double) par2, 0.0D);
var6.addVertex((double) par1, (double) par2, 0.0D); var6.addVertex((double) par1, (double) par2, 0.0D);
var6.draw(); var6.draw();
EaglerAdapter.glDisable(EaglerAdapter.GL_COLOR_LOGIC_OP);
EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D); EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
} }
public void setMaxStringLength(int par1) { public void setMaxStringLength(int par1) {
@ -579,7 +611,7 @@ public class GuiTextField extends Gui {
if (par1 < 0) { if (par1 < 0) {
par1 = 0; par1 = 0;
} }
this.selectionEnd = par1; this.selectionEnd = par1;
if (this.fontRenderer != null) { if (this.fontRenderer != null) {

View File

@ -60,6 +60,7 @@ public class SoundManager {
this.sounddefinitions = new HashMap(); this.sounddefinitions = new HashMap();
try { try {
NBTTagCompound file = CompressedStreamTools.readUncompressed(EaglerAdapter.loadResourceBytes("/sounds/sounds.dat")); NBTTagCompound file = CompressedStreamTools.readUncompressed(EaglerAdapter.loadResourceBytes("/sounds/sounds.dat"));
EaglerAdapter.setPlaybackOffsetDelay(file.hasKey("playbackOffset") ? file.getFloat("playbackOffset") : 0.03f);
NBTTagList l = file.getTagList("sounds"); NBTTagList l = file.getTagList("sounds");
int c = l.tagCount(); int c = l.tagCount();
for(int i = 0; i < c; i++) { for(int i = 0; i < c; i++) {

View File

@ -6,6 +6,9 @@ import java.io.InputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -13,6 +16,7 @@ import org.json.JSONObject;
import org.teavm.interop.Async; import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback; import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.ajax.ReadyStateChangeHandler; import org.teavm.jso.ajax.ReadyStateChangeHandler;
import org.teavm.jso.ajax.XMLHttpRequest; import org.teavm.jso.ajax.XMLHttpRequest;
@ -173,6 +177,12 @@ public class EaglerAdapterImpl2 {
LocalStorageManager.saveStorageG(); LocalStorageManager.saveStorageG();
LocalStorageManager.saveStorageP(); LocalStorageManager.saveStorageP();
} }
@JSBody(params = { "m" }, script = "return m.offsetX;")
private static native int getOffsetX(MouseEvent m);
@JSBody(params = { "m" }, script = "return m.offsetY;")
private static native int getOffsetY(MouseEvent m);
public static final void initializeContext(HTMLElement rootElement, String assetPackageURI) { public static final void initializeContext(HTMLElement rootElement, String assetPackageURI) {
parent = rootElement; parent = rootElement;
@ -224,8 +234,8 @@ public class EaglerAdapterImpl2 {
canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() { canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() {
@Override @Override
public void handleEvent(MouseEvent evt) { public void handleEvent(MouseEvent evt) {
mouseX = evt.getClientX(); mouseX = getOffsetX(evt);
mouseY = canvas.getClientHeight() - evt.getClientY(); mouseY = canvas.getClientHeight() - getOffsetY(evt);
mouseDX += evt.getMovementX(); mouseDX += evt.getMovementX();
mouseDY += -evt.getMovementY(); mouseDY += -evt.getMovementY();
evt.preventDefault(); evt.preventDefault();
@ -832,6 +842,10 @@ public class EaglerAdapterImpl2 {
public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) { public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) {
webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
} }
public static final int _wglGetAttribLocation(ProgramGL p1, String p2) {
return webgl.getAttribLocation(p1.obj, p2);
}
@JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;") @JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;")
private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p); private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p);
public static final int _wglGetTexParameteri(int p1) { public static final int _wglGetTexParameteri(int p1) {
@ -997,6 +1011,14 @@ public class EaglerAdapterImpl2 {
public static final void syncDisplay(int performanceToFps) { public static final void syncDisplay(int performanceToFps) {
} }
private static final DateFormat dateFormatSS = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
public static final void saveScreenshot() {
saveScreenshot("screenshot_" + dateFormatSS.format(new Date()).toString() + ".png", canvas);
}
@JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=cvs.toDataURL(\"image/png\");a.download=name;a.click();")
private static native void saveScreenshot(String name, HTMLCanvasElement cvs);
private static WebSocket sock = null; private static WebSocket sock = null;
private static boolean sockIsConnecting = false; private static boolean sockIsConnecting = false;
@ -1131,11 +1153,14 @@ public class EaglerAdapterImpl2 {
//l.setVelocity(vx, vy, vz); //l.setVelocity(vx, vy, vz);
} }
private static int playbackId = 0; private static int playbackId = 0;
private static final HashMap<String,AudioBufferX> loadedSoundFiles = new HashMap(); private static final HashMap<String,AudioBufferX> loadedSoundFiles = new HashMap();
private static AudioContext audioctx = null; private static AudioContext audioctx = null;
private static float playbackOffsetDelay = 0.03f;
public static final void setPlaybackOffsetDelay(float f) {
playbackOffsetDelay = f;
}
@Async @Async
public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer); public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer);
@ -1208,7 +1233,7 @@ public class EaglerAdapterImpl2 {
s.connect(g); s.connect(g);
g.connect(p); g.connect(p);
p.connect(audioctx.getDestination()); p.connect(audioctx.getDestination());
s.start(0.0d, 0.03d); s.start(0.0d, playbackOffsetDelay);
final int theId = ++playbackId; final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g)); activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
s.setOnEnded(new EventListener<MediaEvent>() { s.setOnEnded(new EventListener<MediaEvent>() {
@ -1231,7 +1256,7 @@ public class EaglerAdapterImpl2 {
g.getGain().setValue(volume > 1.0f ? 1.0f : volume); g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
s.connect(g); s.connect(g);
g.connect(audioctx.getDestination()); g.connect(audioctx.getDestination());
s.start(0.0d, 0.03d); s.start(0.0d, playbackOffsetDelay);
final int theId = ++playbackId; final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g)); activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g));
s.setOnEnded(new EventListener<MediaEvent>() { s.setOnEnded(new EventListener<MediaEvent>() {
@ -1316,6 +1341,9 @@ public class EaglerAdapterImpl2 {
} }
@JSBody(params = { }, script = "return window.navigator.userAgent;")
public static native String getUserAgent();
private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"}; private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"};
private static int[] LWJGLKeyCodes = new int[] { private static int[] LWJGLKeyCodes = new int[] {
@ -1574,11 +1602,29 @@ public class EaglerAdapterImpl2 {
return (k > LWJGLKeyCodes.length || k < 0) ? -1 : LWJGLKeyCodes[k]; return (k > LWJGLKeyCodes.length || k < 0) ? -1 : LWJGLKeyCodes[k];
} }
public static final String getClipboard() { @JSFunctor
return ""; //TODO: html5 clipboard private static interface StupidFunctionResolveString extends JSObject {
void resolveStr(String s);
} }
public static final void setClipboard(String str) { @Async
public static native String getClipboard();
private static void getClipboard(final AsyncCallback<String> cb) {
getClipboard0(new StupidFunctionResolveString() {
@Override
public void resolveStr(String s) {
cb.complete(s);
}
});
}
@JSBody(params = { "cb" }, script = "window.navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(null); });")
private static native void getClipboard0(StupidFunctionResolveString cb);
@JSBody(params = { "str" }, script = "window.navigator.clipboard.writeText(str);")
public static native void setClipboard(String str);
@JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";")
private static native boolean isString(JSObject obj); private static native boolean isString(JSObject obj);