Added version checking for offline downloads

This commit is contained in:
kone 2023-04-13 18:17:44 -04:00
parent e457d87f36
commit eb18d1097f
7 changed files with 22545 additions and 22459 deletions

View File

@ -124,12 +124,32 @@ Compile it yourself here: https://gitlab.com/lax1dude/eaglercraftx-1.8/
transform: translate(-50%);
opacity: 0;
}
#newVersion {
position: absolute;
top: 0px;
left: 100vw;
transform: translateX(-100%);
background-color: black;
width: 350px;
height: 250px;
color: white;
border-radius: 5px;
transition: 0.4s opacity;
opacity: 0%;
display: none;
border: solid 1px white;
padding: 10px;
}
a{
color: rgb(45, 155, 228);
}
</style>
<script type="text/javascript">
let versionNum = "";
let hasSiteInteractionHappened = false;
let tooLate = false;
let patchNumber;
if (localStorage.getItem("isTabSettingsModEnabled")){
document.title = localStorage.getItem("tabTitle");
@ -145,6 +165,11 @@ Compile it yourself here: https://gitlab.com/lax1dude/eaglercraftx-1.8/
versionNum = version;
}
function setPatchNum(patchNum){
patchNumber = patchNum;
checkForUpdates();
}
function setBarProg(event, epkSize){
let progress = Math.round(event.loaded/1024/1024);
let size = Math.round(epkSize/1024/1024);
@ -286,6 +311,42 @@ Compile it yourself here: https://gitlab.com/lax1dude/eaglercraftx-1.8/
}
}
function checkForUpdates(){
let xhr = new XMLHttpRequest()
xhr.open("GET", "http://koneseagler.camdvr.org/resent/version.txt");
xhr.send();
xhr.onload = function() {
if (xhr.status == 200) {
let lines = xhr.responseText.split("\r\n");
let differentVersion = false;
if (lines[0] == versionNum){
console.log("same version");
}
else {
console.log("different version");
differentVersion = true;
}
if (lines[1] == patchNumber){
console.log("same patch");
}
else {
console.log("different patch");
differentVersion = true;
}
if (differentVersion){
document.getElementById("newVersion").style.display = "block";
document.getElementById("newVersion").style.opacity = "100%";
document.getElementById("newVersionBody2").innerText = "Resent "+lines[0]+" Patch "+lines[1];
document.getElementById("newVersionLink1").innerText = lines[2];
document.getElementById("newVersionLink1").href = lines[2];
document.getElementById("newVersionLink2").innerText = lines[3];
document.getElementById("newVersionLink2").href = lines[3];
}
}
}
}
</script>
<script type="text/javascript">
"use strict";
@ -312,6 +373,7 @@ window.addEventListener("load", () => {
</head>
<body style="margin:0px;width:100vw;height:100vh;overflow:hidden;" id="game_frame">
<div id = "dividk">
<h1 id="clienttitle">Resent Client</h1>
<!--everything breaks if u remove this and i dont feel like changing the functions in here to fix it-->
<p class="ratio" ></p>
@ -319,6 +381,14 @@ window.addEventListener("load", () => {
<h2 id="clientversion">Resent 3.6</h2>
<p id="progresstext">Loading assets...</p>
<div id="newVersion">
<h2 id="newVersionTitle">New Version Available!</h2>
<p id="newVersionBody1">There is a new version of resent available:</p>
<p id="newVersionBody2">Resent Patch </p>
<p id="newVersionBody3">Links:</p>
<a id="newVersionLink1" href="" target=”_blank” ></a>
<a id="newVersionLink2" href="" target=”_blank” ></a>
</div>
</div>
</body>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -107,6 +107,7 @@
let versionNum = "";
let hasSiteInteractionHappened = false;
let tooLate = false;
let patchNumber;
if (localStorage.getItem("isTabSettingsModEnabled")){
document.title = localStorage.getItem("tabTitle");
@ -138,6 +139,10 @@
// why would you need to set the progress text in a different function???
}
function setPatchNum(patchNum){
patchNumber = patchNum;
}
function die(){
document.getElementById( "meter" ).style.display = "none";
tooLate = true;

4
javascript/version.txt Normal file
View File

@ -0,0 +1,4 @@
3.7
2
https://drive.google.com/file/d/16u4xiiPwi9ziOMnYmqeFZya3RCR-CP6U/view?usp=sharing
https://drive.google.com/file/d/1qeZjdVFdWHBNq6PQaDnMoa38Wu5Y1Rdm/view?usp=sharing

View File

@ -6,6 +6,7 @@ public class ClientInfo {
public static final String name = "Resent";
public static final String version = "3.7";
public static final String patchNum = "2";
public static final String author = "Nitwit";
public static final String release = Release.STABLE.name;

View File

@ -77,6 +77,7 @@ public class PlatformRuntime {
public static void create() {
setClientVersion(ClientInfo.version);
setClientPatchNum(ClientInfo.patchNum);
win = Window.current();
doc = win.getDocument();
@ -192,6 +193,9 @@ public class PlatformRuntime {
@JSBody(params = { "version" }, script = "setVersion(version)")
public static native void setClientVersion(String version);
@JSBody(params = { "patchNum" }, script = "setPatchNum(patchNum)")
public static native void setClientPatchNum(String patchNum);
@JSBody(script = "die()")
public static native void remove();
@ -628,4 +632,6 @@ public class PlatformRuntime {
@JSBody(params = { "isEnabled" }, script = "toggleTabSettingsMod(isEnabled)")
public static native void toggleTabTitleMod(boolean isEnabled);
}