Skip to content

Commit 8ae7d85

Browse files
Merge pull request #9 from ComputerElite/modding-support
Modding support
2 parents 781bdd6 + 87bf102 commit 8ae7d85

47 files changed

Lines changed: 3635 additions & 1637 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

APKSigner.cs

Lines changed: 456 additions & 0 deletions
Large diffs are not rendered by default.

Assets/html/index.html

Lines changed: 39 additions & 532 deletions
Large diffs are not rendered by default.

Assets/html/script.js

Lines changed: 722 additions & 0 deletions
Large diffs are not rendered by default.

Assets/html/style.css

Lines changed: 379 additions & 1 deletion
Large diffs are not rendered by default.

ClientModels.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22

33
namespace QuestAppVersionSwitcher.ClientModels
44
{
5+
public class PatchingStatus
6+
{
7+
public bool isPatched { get; set; } = false;
8+
public bool isInstalled { get; set; } = true;
9+
public bool canBePatched { get; set; } = true; // Not implemented yet.
10+
public string version { get; set; } = "";
11+
public string versionCode { get; set; } = "";
12+
public ModdedJson moddedJson { get; set; } = null;
13+
}
14+
15+
public class MessageAndValue<T>
16+
{
17+
public string msg { get; set; } = "";
18+
public T value { get; set; } = default(T);
19+
20+
public MessageAndValue(string msg, T value)
21+
{
22+
this.msg = msg;
23+
this.value = value;
24+
}
25+
}
26+
27+
public class ModdedJson
28+
{
29+
public string patcherName { get; set; } = "";
30+
public string patcherVersion { get; set; } = "0.0.0";
31+
public string modloaderName { get; set; } = "";
32+
public string modloaderVersion { get; set; } = "";
33+
public List<string> modifiedFiles { get; set; } = new List<string>();
34+
}
35+
536
public class About
637
{
738
public string version { get; set; } = "";

CoreService.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using AndroidX.Core.App;
77
using ComputerUtils.Android.FileManaging;
88
using ComputerUtils.Android.Logging;
9+
using QuestAppVersionSwitcher.Mods;
910
using System;
1011
using System.IO;
1112
using System.Reflection;
@@ -33,7 +34,7 @@ public async void Start()
3334
{
3435
if (await Permissions.RequestAsync<Permissions.StorageRead>() != PermissionStatus.Granted) return;
3536
}
36-
37+
3738
//Set webbrowser settings
3839
browser.SetWebChromeClient(new WebChromeClient());
3940
browser.Settings.JavaScriptEnabled = true;
@@ -52,9 +53,17 @@ public async void Start()
5253
// Create all directories and files
5354
FileManager.CreateDirectoryIfNotExisting(coreVars.QAVSDir);
5455
FileManager.CreateDirectoryIfNotExisting(coreVars.QAVSBackupDir);
55-
FileManager.RecreateDirectoryIfExisting(coreVars.QAVDTmpDowngradeDir);
56+
FileManager.RecreateDirectoryIfExisting(coreVars.QAVSTmpDowngradeDir);
57+
FileManager.RecreateDirectoryIfExisting(coreVars.QAVSTmpPatchingDir);
58+
FileManager.CreateDirectoryIfNotExisting(coreVars.QAVSPatchingFilesDir);
59+
FileManager.CreateDirectoryIfNotExisting(coreVars.QAVSModAssetsDir);
60+
FileManager.RecreateDirectoryIfExisting(coreVars.QAVSTmpModsDir);
61+
62+
// Download file copies file
63+
ExternalFilesDownloader.DownloadUrl("https://raw.githubusercontent.com/Lauriethefish/QuestPatcher/main/QuestPatcher.Core/Resources/file-copy-paths.json", coreVars.QAVSFileCopiesFile);
5664
if (!File.Exists(coreVars.QAVSConfigLocation)) File.WriteAllText(coreVars.QAVSConfigLocation, JsonSerializer.Serialize(coreVars));
5765
coreVars = JsonSerializer.Deserialize<CoreVars>(File.ReadAllText(coreVars.QAVSConfigLocation));
66+
QAVSModManager.Init();
5867
qAVSWebserver.Start();
5968
}
6069
}

CoreVars.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using System.Collections.Generic;
2+
using System.IO;
23
using System.Text.Json;
34

45
namespace QuestAppVersionSwitcher.Core
@@ -10,8 +11,15 @@ public class CoreVars // aka config
1011
public string token { get; set; } = "";
1112
public int loginStep { get; set; } = 0;
1213
public string password { get; set; } = "";
14+
public PatchingPermissions patchingPermissions = new PatchingPermissions();
1315
public readonly string QAVSDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/";
14-
public readonly string QAVDTmpDowngradeDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpDowngrade/";
16+
public readonly string QAVSTmpDowngradeDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpDowngrade/";
17+
public readonly string QAVSTmpPatchingDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpPatching/";
18+
public readonly string QAVSTmpModsDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/tmpMods/";
19+
public readonly string QAVSModsDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/Mods/";
20+
public readonly string QAVSModAssetsDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/ModAssets/";
21+
public readonly string QAVSFileCopiesFile = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/ModAssets/file-copies.json";
22+
public readonly string QAVSPatchingFilesDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/patchingFiles/";
1523
public readonly string QAVSBackupDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/Backups/";
1624
public readonly string QAVSConfigLocation = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/QuestAppVersionSwitcher/config.json";
1725
public readonly string AndroidAppLocation = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/Android/data/";
@@ -22,4 +30,21 @@ public void Save()
2230
File.WriteAllText(QAVSConfigLocation, JsonSerializer.Serialize(this));
2331
}
2432
}
33+
34+
public class PatchingPermissions
35+
{
36+
public bool externalStorage { get; set; } = true;
37+
public bool handTracking { get; set; } = true;
38+
public bool debug { get; set; } = true;
39+
public List<string> otherPermissions { get; set; } = new List<string>();
40+
public HandTrackingVersion handTrackingVersion { get; set; }
41+
}
42+
43+
public enum HandTrackingVersion
44+
{
45+
None,
46+
V1,
47+
V1HighFrequency,
48+
V2
49+
}
2550
}

DownloadManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void StartDownload(string binaryid, string password, string version, stri
2525
this.isObb = isObb;
2626
string decodedToken = PasswordEncryption.Decrypt(CoreService.coreVars.token, password);
2727
WebClient downloader = new WebClient();
28-
tmpPath = CoreService.coreVars.QAVDTmpDowngradeDir + DateTime.Now.Ticks + (isObb ? ".obb" : ".apk");
28+
tmpPath = CoreService.coreVars.QAVSTmpDowngradeDir + DateTime.Now.Ticks + (isObb ? ".obb" : ".apk");
2929
List<long> lastBytesPerSec = new List<long>();
3030
DateTime lastUpdate = DateTime.Now;
3131
bool locked = false;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2021 Laurie ?
1+
Copyright(c) 2021 Laurie?
22

33
This software is provided 'as-is', without any express or implied
44
warranty. In no event will the authors be held liable for any damages
@@ -8,7 +8,7 @@ Permission is granted to anyone to use this software for any purpose,
88
including commercial applications, and to alter it and redistribute it
99
freely, subject to the following restrictions:
1010

11-
1. The origin of this software must not be misrepresented; you must not
11+
1.The origin of this software must not be misrepresented; you must not
1212
claim that you wrote the original software. If you use this software
1313
in a product, an acknowledgment in the product documentation would be
1414
appreciated but is not required.

Mods/ConfigModProvider.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Text.Json.Serialization;
2+
using System.Threading.Tasks;
3+
4+
namespace QuestAppVersionSwitcher.Mods
5+
{
6+
public abstract class ConfigModProvider : JsonConverter<IMod>, IModProvider
7+
{
8+
/// <summary>
9+
/// ID of this provider, used for distinguishing which mods are from which provider in the config.
10+
/// </summary>
11+
public abstract string ConfigSaveId { get; }
12+
13+
public abstract string FileExtension { get; }
14+
public abstract Task<IMod> LoadFromFile(string modPath);
15+
public abstract Task DeleteMod(IMod mod);
16+
public abstract Task LoadMods();
17+
public abstract void ClearMods();
18+
public abstract Task LoadLegacyMods();
19+
}
20+
}

0 commit comments

Comments
 (0)