mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #37 - Touch support without userscript, many other feats
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.update;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class GuiUpdateDownloadSuccess extends GuiScreen {
|
||||
|
||||
protected final GuiScreen parent;
|
||||
protected final UpdateDataObj updateData;
|
||||
|
||||
public GuiUpdateDownloadSuccess(GuiScreen parent, UpdateDataObj updateData) {
|
||||
this.parent = parent;
|
||||
this.updateData = updateData;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 56, I18n.format("updateSuccess.downloadOffline")));
|
||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 6 + 86, I18n.format("updateSuccess.installToBootMenu")));
|
||||
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 6 + 130, I18n.format("gui.cancel")));
|
||||
}
|
||||
|
||||
public void actionPerformed(GuiButton btn) {
|
||||
if(btn.id == 0) {
|
||||
this.mc.loadingScreen.eaglerShow(I18n.format("updateSuccess.downloading"), null);
|
||||
UpdateService.quine(updateData.clientSignature, updateData.clientBundle);
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}else if(btn.id == 1) {
|
||||
this.mc.displayGuiScreen(new GuiUpdateInstallOptions(this, parent, updateData));
|
||||
}else if(btn.id == 2) {
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("updateSuccess.title"), this.width / 2, 50, 11184810);
|
||||
this.drawCenteredString(fontRendererObj,
|
||||
updateData.clientSignature.bundleDisplayName + " " + updateData.clientSignature.bundleDisplayVersion,
|
||||
this.width / 2, 70, 0xFFFFAA);
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.update;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.GuiScreenGenericErrorMessage;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class GuiUpdateInstallOptions extends GuiScreen {
|
||||
|
||||
protected final GuiScreen parent;
|
||||
protected final GuiScreen onDone;
|
||||
protected final UpdateDataObj updateData;
|
||||
protected boolean makeDefault;
|
||||
protected boolean enableCountdown;
|
||||
protected GuiButton makeDefaultBtn;
|
||||
protected GuiButton enableCountdownBtn;
|
||||
|
||||
public GuiUpdateInstallOptions(GuiScreen parent, GuiScreen onDone, UpdateDataObj updateData) {
|
||||
this.parent = parent;
|
||||
this.onDone = onDone;
|
||||
this.updateData = updateData;
|
||||
makeDefault = updateData.clientSignature.bundleVersionInteger > EaglercraftVersion.updateBundlePackageVersionInt;
|
||||
enableCountdown = makeDefault;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(makeDefaultBtn = new GuiButton(0, this.width / 2 - 100, this.height / 6 + 46,
|
||||
I18n.format("updateInstall.setDefault") + ": " + I18n.format(makeDefault ? "gui.yes" : "gui.no")));
|
||||
this.buttonList.add(enableCountdownBtn = new GuiButton(1, this.width / 2 - 100, this.height / 6 + 76,
|
||||
I18n.format("updateInstall.setCountdown") + ": "
|
||||
+ I18n.format(enableCountdown ? "gui.yes" : "gui.no")));
|
||||
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 6 + 110, I18n.format("updateInstall.install")));
|
||||
this.buttonList.add(new GuiButton(3, this.width / 2 - 100, this.height / 6 + 140, I18n.format("gui.cancel")));
|
||||
|
||||
}
|
||||
|
||||
public void actionPerformed(GuiButton btn) {
|
||||
if(btn.id == 0) {
|
||||
makeDefault = !makeDefault;
|
||||
makeDefaultBtn.displayString = I18n.format("updateInstall.setDefault") + ": " + I18n.format(makeDefault ? "gui.yes" : "gui.no");
|
||||
}else if(btn.id == 1) {
|
||||
enableCountdown = !enableCountdown;
|
||||
enableCountdownBtn.displayString = I18n.format("updateInstall.setCountdown") + ": " + I18n.format(enableCountdown ? "gui.yes" : "gui.no");
|
||||
}else if(btn.id == 2) {
|
||||
mc.loadingScreen.eaglerShow(I18n.format("updateSuccess.installing"), null);
|
||||
try {
|
||||
UpdateService.installSignedClient(updateData.clientSignature, updateData.clientBundle, makeDefault, enableCountdown);
|
||||
}catch(Throwable t) {
|
||||
mc.displayGuiScreen(new GuiScreenGenericErrorMessage("installFailed.title", t.toString(), onDone));
|
||||
return;
|
||||
}
|
||||
mc.displayGuiScreen(onDone);
|
||||
}else if(btn.id == 3) {
|
||||
mc.displayGuiScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int mx, int my, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("updateInstall.title"), this.width / 2, 40, 11184810);
|
||||
this.drawCenteredString(fontRendererObj,
|
||||
updateData.clientSignature.bundleDisplayName + " " + updateData.clientSignature.bundleDisplayVersion,
|
||||
this.width / 2, 60, 0xFFFFAA);
|
||||
super.drawScreen(mx, my, partialTicks);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.update;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@ -60,12 +62,13 @@ public class GuiUpdateVersionList extends GuiScreen {
|
||||
UpdateService.startClientUpdateFrom(slots.certList.get(selected));
|
||||
}
|
||||
case 0:
|
||||
default:
|
||||
mc.displayGuiScreen(back);
|
||||
break;
|
||||
case 2:
|
||||
this.initGui();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +82,7 @@ public class GuiUpdateVersionList extends GuiScreen {
|
||||
super.drawScreen(par1, par2, par3);
|
||||
if(tooltip != null) {
|
||||
drawHoveringText(mc.fontRendererObj.listFormattedStringToWidth(tooltip, 180), par1, par2);
|
||||
GlStateManager.disableLighting();
|
||||
tooltip = null;
|
||||
}
|
||||
}
|
||||
@ -88,4 +92,11 @@ public class GuiUpdateVersionList extends GuiScreen {
|
||||
super.handleMouseInput();
|
||||
slots.handleMouseInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTouchInput() throws IOException {
|
||||
super.handleTouchInput();
|
||||
slots.handleTouchInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
@ -35,7 +34,7 @@ public class GuiUpdateVersionSlot extends GuiSlot {
|
||||
|
||||
private static final ResourceLocation eaglerGuiTex = new ResourceLocation("eagler:gui/eagler_gui.png");
|
||||
|
||||
final List<UpdateCertificate> certList = new ArrayList();
|
||||
final List<UpdateCertificate> certList = new ArrayList<>();
|
||||
|
||||
final GuiUpdateVersionList screen;
|
||||
|
||||
@ -86,7 +85,7 @@ public class GuiUpdateVersionSlot extends GuiSlot {
|
||||
screen.drawBackground(0);
|
||||
}
|
||||
|
||||
public static final SimpleDateFormat dateFmt = EagRuntime.fixDateFormat(new SimpleDateFormat("M/dd/yyyy"));
|
||||
public static final SimpleDateFormat dateFmt = new SimpleDateFormat("M/dd/yyyy");
|
||||
private static final char[] hexChars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.PlatformApplication;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformWebRTC;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayServerSocket;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.pkt.IPacket00Handshake;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.pkt.RelayPacket00Handshake;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ public class RelayUpdateChecker {
|
||||
|
||||
}
|
||||
|
||||
private static final List<RelayEntry> relaysList = new ArrayList();
|
||||
private static final List<RelayEntry> relaysList = new ArrayList<>();
|
||||
|
||||
private static long lastUpdateCheck = -1l;
|
||||
private static boolean hasInit = false;
|
||||
@ -74,7 +74,8 @@ public class RelayUpdateChecker {
|
||||
}
|
||||
long millis = System.currentTimeMillis();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if((mc.theWorld == null || mc.isSingleplayer()) && millis - lastUpdateCheck > updateCheckRate) {
|
||||
if ((mc.theWorld == null || mc.isSingleplayer())
|
||||
&& (millis - lastUpdateCheck > updateCheckRate || millis + 60000l < lastUpdateCheck)) {
|
||||
lastUpdateCheck = millis;
|
||||
try {
|
||||
EaglerOutputStream bao = new EaglerOutputStream(8);
|
||||
@ -120,12 +121,13 @@ public class RelayUpdateChecker {
|
||||
|
||||
private static void updateRelay(RelayEntry socket) {
|
||||
try {
|
||||
socket.currentSocket.update();
|
||||
if(socket.currentSocket.isClosed()) {
|
||||
socket.currentSocket = null;
|
||||
}else if(socket.currentSocket.isOpen()) {
|
||||
if(!socket.handshake) {
|
||||
socket.handshake = true;
|
||||
socket.currentSocket.writePacket(new IPacket00Handshake(0x02, RelayManager.preferredRelayVersion, magic));
|
||||
socket.currentSocket.writePacket(new RelayPacket00Handshake(0x02, RelayManager.preferredRelayVersion, magic));
|
||||
}else {
|
||||
// close immediately
|
||||
if(socket.currentSocket.nextPacket() != null) {
|
||||
|
@ -0,0 +1,28 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.update;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class UpdateDataObj {
|
||||
|
||||
public final UpdateCertificate clientSignature;
|
||||
public final byte[] clientBundle;
|
||||
|
||||
public UpdateDataObj(UpdateCertificate clientSignature, byte[] clientBundle) {
|
||||
this.clientSignature = clientSignature;
|
||||
this.clientBundle = clientBundle;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.update;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
public class UpdateResultObj {
|
||||
|
||||
private final boolean success;
|
||||
private final Object dataObj;
|
||||
|
||||
private UpdateResultObj(boolean success, Object dataObj) {
|
||||
this.success = success;
|
||||
this.dataObj = dataObj;
|
||||
}
|
||||
|
||||
public static UpdateResultObj createSuccess(UpdateDataObj dataObj) {
|
||||
return new UpdateResultObj(true, dataObj);
|
||||
}
|
||||
|
||||
public static UpdateResultObj createFailure(String dataObj) {
|
||||
return new UpdateResultObj(false, dataObj);
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public UpdateDataObj getSuccess() {
|
||||
return (UpdateDataObj)dataObj;
|
||||
}
|
||||
|
||||
public String getFailure() {
|
||||
return (String)dataObj;
|
||||
}
|
||||
|
||||
}
|
@ -37,9 +37,9 @@ public class UpdateService {
|
||||
private static boolean isBundleDataValid = false;
|
||||
|
||||
private static UpdateCertificate latestUpdateFound = null;
|
||||
private static final Set<UpdateCertificate> availableUpdates = new HashSet();
|
||||
private static final Set<RawKnownCertHolder> fastUpdateKnownCheckSet = new HashSet();
|
||||
private static final Set<UpdateCertificate> dismissedUpdates = new HashSet();
|
||||
private static final Set<UpdateCertificate> availableUpdates = new HashSet<>();
|
||||
private static final Set<RawKnownCertHolder> fastUpdateKnownCheckSet = new HashSet<>();
|
||||
private static final Set<UpdateCertificate> dismissedUpdates = new HashSet<>();
|
||||
|
||||
private static class RawKnownCertHolder {
|
||||
|
||||
@ -50,7 +50,7 @@ public class UpdateService {
|
||||
public RawKnownCertHolder(byte[] data) {
|
||||
this.data = data;
|
||||
this.hashcode = Arrays.hashCode(data);
|
||||
this.age = System.currentTimeMillis();
|
||||
this.age = EagRuntime.steadyTimeMillis();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
@ -176,7 +176,7 @@ public class UpdateService {
|
||||
|
||||
private static void freeMemory() {
|
||||
if(fastUpdateKnownCheckSet.size() > 127) {
|
||||
List<RawKnownCertHolder> lst = new ArrayList(fastUpdateKnownCheckSet);
|
||||
List<RawKnownCertHolder> lst = new ArrayList<>(fastUpdateKnownCheckSet);
|
||||
fastUpdateKnownCheckSet.clear();
|
||||
lst.sort((c1, c2) -> { return (int)(c2.age - c1.age); });
|
||||
for(int i = 0; i < 64; ++i) {
|
||||
@ -193,6 +193,15 @@ public class UpdateService {
|
||||
return PlatformUpdateSvc.getUpdatingStatus();
|
||||
}
|
||||
|
||||
public static UpdateResultObj getUpdateResult() {
|
||||
return PlatformUpdateSvc.getUpdateResult();
|
||||
}
|
||||
|
||||
public static void installSignedClient(UpdateCertificate clientCert, byte[] clientPayload, boolean setDefault,
|
||||
boolean setTimeout) {
|
||||
PlatformUpdateSvc.installSignedClient(clientCert, clientPayload, setDefault, setTimeout);
|
||||
}
|
||||
|
||||
public static UpdateCertificate getLatestUpdateFound() {
|
||||
return latestUpdateFound;
|
||||
}
|
||||
@ -221,6 +230,10 @@ public class UpdateService {
|
||||
}
|
||||
}
|
||||
|
||||
public static void quine(UpdateCertificate cert, byte[] payload) {
|
||||
PlatformUpdateSvc.quine(cert, payload);
|
||||
}
|
||||
|
||||
public static boolean shouldDisableDownloadButton() {
|
||||
return EagRuntime.getConfiguration().getDownloadOfflineButtonLink() == null && (myUpdateCert == null
|
||||
|| (getClientBundleData() == null && PlatformUpdateSvc.getUpdatingStatus().isBusy));
|
||||
|
Reference in New Issue
Block a user