Skip to content

Commit 4e2cb43

Browse files
ComputerEliteComputerElite
authored andcommitted
a lot of stuff. Mostly UX
1 parent aa1e10e commit 4e2cb43

File tree

13 files changed

+218
-48
lines changed

13 files changed

+218
-48
lines changed

QuestAppVersionSwitcher/Assets/html/index.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ <h2>Cosmetics type</h2>
124124
<div class="contentItem hidden" id="getMods">
125125
<h2>You can download mods and cosmetics from the following sites. Only QMods are supported by QuestAppVersionSwitcher + any cosmetics formats of the currently selected game</h2>
126126
<div style="display: flex; flex-direction: column;" class="buttonsContainer">
127-
<div class="button labelMargin" onclick="OpenSite(`https://computerelite.github.io/tools/Beat_Saber/questmods.html?version=${currentGameVersion}&isqavs=true`)">Open Beat Saber Mods page</div>
128-
<div class="button labelMargin" onclick="OpenSite(`https://computerelite.github.io/tools/Oculus/QAVSHome.html?version=${currentGameVersion}&isqavs=true`)">Open website hub</div>
127+
<div class="button labelMargin" onclick="OpenSite(`https://computerelite.github.io/tools/Beat_Saber/questmods.html?version=${currentGameVersion}&isqavs=true&port=${GetPort()}&ismodded=${isGamePatched}`)">Open Beat Saber Mods page</div>
128+
<div class="button labelMargin" onclick="OpenSite(`https://computerelite.github.io/tools/Oculus/QAVSHome.html?version=${currentGameVersion}&isqavs=true&port=${GetPort()}&ismodded=${isGamePatched}`)">Open website hub</div>
129129
<div class="button labelMargin" onclick="OpenSite(`https://www.google.com/search?q=computerelite`)">Open Google</div>
130130
</div>
131131
</div>
@@ -296,9 +296,10 @@ <h2>Downloads</h2>
296296
<div class="contentHeader headerMargin">
297297
Password needed
298298
</div>
299-
Please enter the password you set when you logged in. If you didn't set one or forgot your password abort the download and head to the <code>Tools & Options</code> section to log in again.
299+
Please enter the password you set when you logged in.
300300
<br>
301-
Check the <code>download progress</code> section to see if the download was successful.
301+
<br>
302+
<i>If you didn't set one or forgot your password abort the download and head to the <code>Tools & Options</code> section to log in again.</i>
302303
<input type="password" id="passwordConfirm" placeholder="password">
303304
<div id="step7box" class="textBox"></div>
304305
<div class="buttonSelectionContainer">
@@ -373,6 +374,24 @@ <h2>Downloads</h2>
373374
</div>
374375
</div>
375376
</div>
377+
378+
<div id="step13" class="restoreStep hidden">
379+
<div class="contentHeader headerMargin">
380+
Login
381+
</div>
382+
To downgrade your game you need to log into QuestAppVersionSwitcher with your Meta account. This is needed so you can download the old version of the game.
383+
<br>
384+
To downgrade press the login button below and login with your Meta account.
385+
<div id="step13box" class="textBox"></div>
386+
<div class="buttonSelectionContainer">
387+
<div class="buttonContainer">
388+
<div class="button" id="login2">Login</div>
389+
</div>
390+
<div class="buttonContainer buttonMargin">
391+
<div class="button" id="cancellogin2">Abort downgrade</div>
392+
</div>
393+
</div>
394+
</div>
376395
</div>
377396

378397
<div class="listContainer darken hidden" id="deleteContainer">
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
var qavsInjectionDiv = document.createElement("div");
2+
document.body.appendChild(qavsInjectionDiv);
3+
const qavsPort = "{0}"
4+
5+
// Create nav bar
6+
var qavsNavbar = document.createElement("div");
7+
qavsNavbar.style = "color: #EEEEEE; position: fixed; top: 10px; right: 10px; background-color: #414141; border-radius: 5px; padding: 5px; display: flex; z-index: 50000;";
8+
qavsNavbar.innerHTML += `
9+
<div style="border-radius: 5px; font-size: 100%; background-color: #5B5B5B; width: fit-content; height: fit-content; padding: 5px; cursor: pointer; flex-shrink: 0; user-select: none; margin-right: 5px;" onclick="history.go(-1)">Back</div>
10+
<div style="border-radius: 5px; font-size: 100%; background-color: #5B5B5B; width: fit-content; height: fit-content; padding: 5px; cursor: pointer; flex-shrink: 0; user-select: none; margin-right: 5px;" onclick="history.go(1)">Forward</div>
11+
<div style="border-radius: 5px; font-size: 100%; background-color: #5B5B5B; width: fit-content; height: fit-content; padding: 5px; cursor: pointer; flex-shrink: 0; user-select: none; margin-right: 5px;" onclick="location = 'http://localhost:${qavsPort}'">QuestAppVersionSwitcher</div>
12+
<div style="border-radius: 5px; font-size: 100%; background-color: #5B5B5B; width: fit-content; height: fit-content; padding: 5px; cursor: pointer; flex-shrink: 0; user-select: none;" onclick="location = 'https://oculus.com/experiences/quest'">Oculus (Login)</div>`;
13+
qavsInjectionDiv.appendChild(qavsNavbar)
14+
15+
// Handle popups
16+
var qavsPopupContainer = document.createElement("div");
17+
qavsPopupContainer.style = "font-size: 24px; border: 1px solid #4aaf8b; position: fixed; bottom: 10px; right: 10px; z-index: 50000; padding: 10px; border-radius: 5px; background-color: #414141; color: #EEEEEE; display: none;"
18+
qavsInjectionDiv.appendChild(qavsPopupContainer);
19+
20+
const ModInstall = 0
21+
const DependencyDownload = 4
22+
const ModDownload = 7
23+
const QueuedModInstall = 8
24+
const Error = 6
25+
26+
var somethingWasRunning = false;
27+
function UpdatePopUps() {
28+
fetch("http://localhost:" + qavsPort + "/api/mods/operations").then(res => {
29+
res.json().then(operations => {
30+
operations = operations.filter(x => !x.isDone);
31+
var queuedMods = operations.filter(x => x.type == QueuedModInstall);
32+
var installingMods = operations.filter(x => x.type == ModInstall);
33+
var downloadingMods = operations.filter(x => x.type == ModDownload);
34+
var downloadingDependencies = operations.filter(x => x.type == DependencyDownload);
35+
var errors = operations.filter(x => x.type == Error);
36+
37+
var html = `
38+
${queuedMods.length > 0 ? `${queuedMods.length} mods queued<br>` : ``}
39+
${installingMods.length > 0 ? `${installingMods.length} mods installing<br>` : ``}
40+
${downloadingMods.length > 0 ? `${downloadingMods.length} mods downloading<br>` : ``}
41+
${downloadingDependencies.length > 0 ? `${downloadingDependencies.length} dependencies downloading<br>` : ``}
42+
${errors.length > 0 ? `${errors.length} errors, more info in installed mods tab<br>` : ``}
43+
`;
44+
if(!html) {
45+
html = "All done!"
46+
} else {
47+
somethingWasRunning = true
48+
}
49+
qavsPopupContainer.innerHTML = html;
50+
qavsPopupContainer.style.display = somethingWasRunning ? "block" : "none";
51+
})
52+
})
53+
}
54+
setInterval(UpdatePopUps, 300);

QuestAppVersionSwitcher/Assets/html/script.js

Lines changed: 91 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function IsOnQuest() {
2121
return location.host.startsWith("127.0.0.1") ||location.host.startsWith("localhost")
2222
}
2323

24+
function GetPort() {
25+
return location.port
26+
}
27+
28+
document.getElementById("cancellogin2").onclick = () => {
29+
CloseGetPasswordPopup()
30+
}
31+
2432
fetch("/api/android/device").then(res => res.json().then(res => {
2533
if(res.sdkVersion <= 29) {
2634
// Android 10 and below don't need new storage perms
@@ -174,7 +182,7 @@ function UpdateVersion(version) {
174182

175183
var isGamePatched = false
176184
const patchingOptions = document.getElementById("patchingOptions")
177-
185+
var patchingStatus = {}
178186
function UpdatePatchingStatus() {
179187
if(patchInProgress) {
180188
return;
@@ -183,6 +191,7 @@ function UpdatePatchingStatus() {
183191
fetch("/api/patching/getmodstatus").then(res => {
184192
res.json().then(res => {
185193
UpdateVersion(res.version)
194+
patchingStatus = res
186195
isGamePatched = res.isPatched
187196
if (res.isPatched) {
188197
document.getElementById("modsButton").style.display = "block"
@@ -448,6 +457,38 @@ UpdateUI()
448457
TokenUIUpdate()
449458
const oculusLink = "https://auth.meta.com/"
450459
const params = new URLSearchParams(window.location.search)
460+
461+
function CheckStartParams() {
462+
var download = params.get("download")
463+
var game = params.get("game")
464+
var version = params.get("version")
465+
var package = params.get("package")
466+
var modnow = params.get("modnow")
467+
if(download) {
468+
fetch("/api/questappversionswitcher/loggedinstatus").then(res => {
469+
res.json().then(res => {
470+
if(res.msg == "2") {
471+
// Logged in
472+
// Open downgrade tab
473+
OpenTab("downgrade")
474+
// Open OculusDB on correct page
475+
document.getElementById("downgradeframe").src = `https://oculusdb.rui2015.me/id/${game}?downloadversion=${version}`
476+
} else {
477+
// Not logged in
478+
OpenGetPasswordPopup()
479+
GotoStep(13)
480+
}
481+
})
482+
})
483+
}
484+
485+
if(modnow) {
486+
ChangeApp(package)
487+
OpenTab("patching")
488+
PatchGame()
489+
}
490+
}
491+
451492
var config = {}
452493
var selectedBackup = ""
453494

@@ -480,6 +521,7 @@ function UpdateUI(closeLists = false) {
480521
if(firstConfigFetch) {
481522
firstConfigFetch = false;
482523
CheckFolderPermission();
524+
CheckStartParams()
483525
}
484526
Array.prototype.forEach.call(document.getElementsByClassName("packageName"), e => {
485527
if(config.currentApp) e.innerHTML = config.currentApp
@@ -561,7 +603,7 @@ function FormatDownload(d) {
561603
</div>
562604
${d.isCancelable ? `<input type="button" class="DownloadText" value="Cancel" onclick="StopDownload('${d.backupName}')">` : ``}
563605
<div class="DownloadText" style="color: ${d.textColor};">
564-
${d.text} ${d.percentageString} ${d.doneString} / ${d.totalString} ${d.speedString} ETA ${d.eTAString}
606+
<b>${d.text}</b> ${d.percentageString} ${d.doneString} / ${d.totalString} ${d.speedString} ETA ${d.eTAString}
565607
</div>
566608
</div>`
567609
}
@@ -580,7 +622,7 @@ setInterval(() => {
580622
downloads += FormatDownload(download)
581623
}
582624
gdms += `<div style="display: flex; flex-direction: column; background-color: #1F1F1F; padding: 10px;"><div class="downloadContainer">
583-
${!d.done ? `<input type="button" class="DownloadText" style="width: 0px; background-color: #333333" value="Cancel" onclick="StopGameDownload('${d.id}')">` : ``}
625+
${!d.done ? (d.canceled || d.error ? `` : `<input type="button" class="DownloadText" style="width: 200px; background-color: #333333; font-size: 1.2em;" value="Cancel" onclick="StopGameDownload('${d.id}')">`) : `<input type="button" class="DownloadText" style="width: 200px; background-color: #333333; color: #00FF00; font-size: 1.2em;" value="Install Version" onclick="RestoreBackup('${d.backupName}', '${d.packageName}')">`}
584626
<div class="DownloadText" style="color: ${d.textColor};">
585627
<b>${d.canceled ? "Cancelled " : ""}${d.status}</b><br>${d.filesDownloaded} / ${d.filesToDownload} files downloaded
586628
</div>
@@ -682,13 +724,15 @@ setInterval(() => {
682724
})
683725
}, 500)
684726

727+
if(localStorage.lastOpened) OpenTab(localStorage.lastOpened)
685728
function OpenTab(section) {
686729
Array.prototype.forEach.call(document.getElementsByClassName("menuItem"), e => {
687730
e.className = "menuItem" + (e.getAttribute("section") == section ? " selected" : "")
688731
})
689732
Array.prototype.forEach.call(document.getElementsByClassName("contentItem"), e => {
690733
e.className = "contentItem" + (e.id == section ? "" : " hidden")
691734
})
735+
localStorage.lastOpened = section
692736
}
693737

694738

@@ -775,7 +819,7 @@ document.getElementById("uninstall2").onclick = () => {
775819
fetch(`/api/backupinfo?package=${config.currentApp}&backupname=${selectedBackup}`).then(res => {
776820
res.json().then(j => {
777821
if(!j.containsApk) {
778-
GotoStep("4.1")
822+
AfterAPKInstall()
779823
} else {
780824
fetch(`/api/android/uninstallpackage?package=${config.currentApp}`, {method: "POST"}).then(res => {
781825
if (res.status == 230) GotoStep(3)
@@ -805,29 +849,33 @@ document.getElementById("install").onclick = () => {
805849
}).then(res => {
806850
res.json().then(j => {
807851
if (res.status == 200) {
808-
fetch("/api/gotaccess?package=" + config.currentApp).then(res => {
852+
AfterAPKInstall()
853+
}
854+
else TextBoxError("step4.1box", j.msg)
855+
})
856+
})
857+
}
858+
859+
function AfterAPKInstall() {
860+
fetch("/api/gotaccess?package=" + config.currentApp).then(res => {
861+
res.json().then(j => {
862+
if (j.gotAccess) {
863+
fetch("/api/backupinfo?package=" + config.currentApp + "&backupname=" + selectedBackup).then(res => {
809864
res.json().then(j => {
810-
if (j.gotAccess) {
811-
fetch("/api/backupinfo?package=" + config.currentApp + "&backupname=" + selectedBackup).then(res => {
812-
res.json().then(j => {
813-
if(j.isPatchedApk) {
814-
GotoStep("4.2")
815-
} else {
816-
if (j.containsAppData || j.containsObbs) {
817-
GotoStep(4)
818-
} else {
819-
GotoStep(5)
820-
}
821-
}
822-
})
823-
})
865+
if(j.isPatchedApk) {
866+
GotoStep("4.2")
824867
} else {
825-
GotoStep("4.1")
868+
if (j.containsAppData || j.containsObbs) {
869+
GotoStep(4)
870+
} else {
871+
GotoStep(5)
872+
}
826873
}
827874
})
828875
})
876+
} else {
877+
GotoStep("4.1")
829878
}
830-
else TextBoxError("step4.1box", j.msg)
831879
})
832880
})
833881
}
@@ -1070,6 +1118,20 @@ document.getElementById("abortPassword").onclick = () => {
10701118
document.getElementById("confirmPassword").style.display = "block"
10711119
CloseGetPasswordPopup()
10721120
}
1121+
1122+
function RestoreBackup(backupName, game) {
1123+
if(game && config.currentApp != game) {
1124+
ChangeApp(game)
1125+
setTimeout(() => RestoreBackupFromSelectedGame(backupName), 200)
1126+
return;
1127+
}
1128+
RestoreBackupFromSelectedGame(backupName)
1129+
}
1130+
1131+
function RestoreBackupFromSelectedGame(backupName) {
1132+
selectedBackup = backupName;
1133+
OpenRestorePopup();
1134+
}
10731135
function PasswordInput() {
10741136
TextBoxText("step7box", "Waiting for response and requesting obbs to download from Oculus. This may take 30 seconds...")
10751137
options.password = encodeURIComponent(document.getElementById("passwordConfirm").value)
@@ -1085,6 +1147,7 @@ function PasswordInput() {
10851147
TextBoxGood("step7box", j.msg)
10861148
document.getElementById("abortPassword").innerHTML = "Close Popup"
10871149
document.getElementById("confirmPassword").style.display = "none"
1150+
OpenTab("download")
10881151
}
10891152
})
10901153
})
@@ -1118,6 +1181,13 @@ document.getElementById("confirmLogin").onclick = () => {
11181181
TextBoxGood("step9box", "One sec...")
11191182
location = oculusLink
11201183
}
1184+
document.getElementById("login2").onclick = () => {
1185+
TextBoxGood("step13box", "One sec...")
1186+
location = oculusLink
1187+
}
1188+
document.getElementById("abortLogin").onclick = () => {
1189+
CloseGetPasswordPopup()
1190+
}
11211191

11221192
document.getElementById("tokenPassword").onclick = () => {
11231193
options.password = encodeURIComponent(document.getElementById("passwordConfirm").value)

QuestAppVersionSwitcher/Assets/html/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@
247247

248248
/* Loader end */
249249

250+
.browser {
251+
width: 100vw;
252+
height: 100vh;
253+
position: fixed;
254+
left: 0;
255+
top: 0;
256+
}
250257

251258
body {
252259
margin: 0px;

QuestAppVersionSwitcher/ClientModels.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class About
4848
public enum BackupInfoVersion
4949
{
5050
V1,
51-
V2
51+
V2,
52+
V3
5253
}
5354

5455
public class BackupList

QuestAppVersionSwitcher/DownloadListener.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class DownloadListener : Java.Lang.Object, IDownloadListener
1616
public void OnDownloadStart(string url, string userAgent, string contentDisposition, string mimetype, long contentLength)
1717
{
1818
Logger.Log("Downloading mod from " + url);
19-
CoreService.browser.EvaluateJavascript("ShowToast('Downloading', '#FFFFFF', '#222222')", null);
2019
QAVSModManager.InstallModFromUrl(url);
2120
}
2221
}

QuestAppVersionSwitcher/DownloadManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class DownloadManager : DownloadProgress
1717
{
1818
public delegate void DownloadFinished(DownloadManager manager);
1919
public event DownloadFinished DownloadFinishedEvent;
20+
public event DownloadFinished DownloadErrorEvent;
2021
public event DownloadFinished DownloadCanceled;
2122
public string tmpPath = "";
2223
public bool isObb = false;
@@ -98,6 +99,7 @@ public void StartDownload(string binaryid, string password, string version, stri
9899
SetEmpty();
99100
this.backupName = "Unknown Error: Have you entered your token in the Tools & Options section? Doing this is needed. Otherwise you don't own the game you are trying to download.";
100101
this.textColor = "#EE0000";
102+
if(DownloadErrorEvent != null) DownloadErrorEvent(this);
101103
}
102104
else
103105
{

0 commit comments

Comments
 (0)