Skip to content

Commit

Permalink
Merge pull request #77 from emulamer/bs_130
Browse files Browse the repository at this point in the history
Bs 130
  • Loading branch information
emulamer authored Aug 31, 2019
2 parents 12e68b2 + 418d0ab commit 6485efd
Show file tree
Hide file tree
Showing 16 changed files with 1,930 additions and 1,793 deletions.
1,773 changes: 900 additions & 873 deletions BeatOn/Assets/www/main-es2015.js

Large diffs are not rendered by default.

1,831 changes: 929 additions & 902 deletions BeatOn/Assets/www/main-es5.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions BeatOn/BeatOn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@
<None Include="Assets\AboutAssets.txt" />
<AndroidResource Include="Resources\raw\libmodloader.so" />
<AndroidResource Include="Resources\raw\libbeatonmod.so" />
<AndroidResource Include="Resources\raw\libmodloader64.so" />
<AndroidResource Include="Resources\raw\libbeatonmod64.so" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\activity_main.axml">
Expand Down
68 changes: 61 additions & 7 deletions BeatOn/BeatSaberModder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class BeatSaberModder
{
public const string APK_ASSETS_PATH = "assets/bin/Data/";
public const string LIBMODLOADER_TARGET_FILE = "lib/armeabi-v7a/libmodloader.so";
public const string LIBMODLOADER64_TARGET_FILE = "lib/arm64-v8a/libmodloader.so";
public const string MOD_TAG_FILE = "beaton.modded";
public const string BS_PLAYER_DATA_FILE = "/sdcard/Android/data/com.beatgames.beatsaber/files/PlayerData.dat";

Expand Down Expand Up @@ -392,8 +393,10 @@ public void ApplyModToTempApk()
"Managed",
"boot.config" });

bool is64bit = IsApk64Bit(TempApk);

//// copy libassetredirect.so to the mods folder
InstallAssetRedirectMod();
InstallAssetRedirectMod(is64bit);

//from this point on, the APK has been modified and isn't definitively recoverable if something goes wrong
tempApkModified = true;
Expand Down Expand Up @@ -957,6 +960,35 @@ private void AddManifestModToApk(string apkFilename)
}
}

private bool IsApk64Bit(string apkFilename)
{
UpdateStatus("Checking if APK is 64-bit...");
try
{
using (var apk = new ZipFileProvider(apkFilename, FileCacheMode.None, true, QuestomAssets.Utils.FileUtils.GetTempDirectory()))
{
if (apk.DirectoryExists(LIBMODLOADER64_TARGET_FILE.GetDirectoryFwdSlash()))
{
UpdateStatus("APK is 64 bit");
return true;
}
if (apk.DirectoryExists(LIBMODLOADER_TARGET_FILE.GetDirectoryFwdSlash()))
{
UpdateStatus("APK is 32 bit");
return false;
}
UpdateStatus("Can't find a libs folder for either 32 or 64 bit...");
throw new ModException("Unable to find library folder to determine 32 or 64 bit.");
}
}
catch (Exception ex)
{
Log.LogErr("Error determining if APK is 64 bit!", ex);
UpdateStatus("Unable to determine if APK is 32 or 64 bit!");
throw new ModException("Error determining if APK is 64 bit!", ex);
}
}

private void AddModLoaderToApk(string apkFilename)
{
UpdateStatus("Adding the libmodloader.so file to the APK...");
Expand All @@ -966,8 +998,18 @@ private void AddModLoaderToApk(string apkFilename)
{
using (var resStream = _context.Resources.OpenRawResource(Resource.Raw.libmodloader))
{
apk.QueueWriteStream(LIBMODLOADER_TARGET_FILE, resStream, true, true);
apk.Save();
using (var resStream64 = _context.Resources.OpenRawResource(Resource.Raw.libmodloader64))
{
if (apk.DirectoryExists(LIBMODLOADER_TARGET_FILE.GetDirectoryFwdSlash()))
{
apk.QueueWriteStream(LIBMODLOADER_TARGET_FILE, resStream, true, true);
}
if (apk.DirectoryExists(LIBMODLOADER64_TARGET_FILE.GetDirectoryFwdSlash()))
{
apk.QueueWriteStream(LIBMODLOADER64_TARGET_FILE, resStream64, true, true);
}
apk.Save();
}
}
}
}
Expand All @@ -979,7 +1021,7 @@ private void AddModLoaderToApk(string apkFilename)
}
}

private void InstallAssetRedirectMod()
private void InstallAssetRedirectMod(bool is64Bit)
{
UpdateStatus("Installing asset redirection mod ...");
try
Expand All @@ -999,11 +1041,23 @@ private void InstallAssetRedirectMod()
UpdateStatus("Failed to create mods directory in external storage!");
throw new ModException($"Unable to create directory {dirName}!", ex);
}
using (var resStream = _context.Resources.OpenRawResource(Resource.Raw.libbeatonmod))
if (is64Bit)
{
using (var fs = File.Open(Path.Combine(Constants.MODLOADER_MODS_PATH, "libbeatonmod.so"), FileMode.Create, FileAccess.Write))
using (var resStream = _context.Resources.OpenRawResource(Resource.Raw.libbeatonmod64))
{
resStream.CopyTo(fs);
using (var fs = File.Open(Path.Combine(Constants.MODLOADER_MODS_PATH, "libbeatonmod.so"), FileMode.Create, FileAccess.Write))
{
resStream.CopyTo(fs);
}
}
} else
{
using (var resStream = _context.Resources.OpenRawResource(Resource.Raw.libbeatonmod))
{
using (var fs = File.Open(Path.Combine(Constants.MODLOADER_MODS_PATH, "libbeatonmod.so"), FileMode.Create, FileAccess.Write))
{
resStream.CopyTo(fs);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions BeatOn/Core/RequestHandlers/PostConfigRestore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public void HandleRequest(HttpListenerContext context)
try
{
cfg = JsonConvert.DeserializeObject<QuestomAssets.Models.BeatSaberQuestomConfig>(_getQaeConfig().RootFileProvider.ReadToString(configFile));
cfg.Mods.Clear();
foreach (var pl in cfg.Playlists)
{
foreach (var s in pl.SongList)
Expand Down
2 changes: 1 addition & 1 deletion BeatOn/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.1.1.2" package="com.emulamer.beaton" android:installLocation="preferExternal" android:versionCode="112">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.1.3.3" package="com.emulamer.beaton" android:installLocation="preferExternal" android:versionCode="133">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down
6 changes: 3 additions & 3 deletions BeatOn/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("emulamer")]
[assembly: AssemblyProduct("BeatOn")]
[assembly: AssemblyCopyright("Copyright ©emulamer 2018")]
[assembly: AssemblyCopyright("Copyright ©emulamer 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
Expand All @@ -26,5 +26,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.2")]
[assembly: AssemblyFileVersion("0.1.1.2")]
[assembly: AssemblyVersion("0.1.3.3")]
[assembly: AssemblyFileVersion("0.1.3.3")]
10 changes: 8 additions & 2 deletions BeatOn/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added BeatOn/Resources/raw/libbeatonmod64.so
Binary file not shown.
Binary file added BeatOn/Resources/raw/libmodloader64.so
Binary file not shown.
2 changes: 1 addition & 1 deletion beatsaber-hook
Submodule beatsaber-hook updated 123 files
1 change: 1 addition & 0 deletions frontend/src/app/credits/credits.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h2>Credits to BSMG crew in general, and in particular:</h2>
<li><b>elliotttate</b>: inspiration, support and the awesome logos</li>
<li><b>karldeux</b>: code contributor, project wrangler</li>
<li><b>Zingabopp</b>: Sync Saber Service</li>
<li><b>RedBrumbler</b>: trail blazing asset modding</li>
<li><b>lolpants</b>: everything lolpants does.</li>
<li><b>emulamer</b>: did some stuff</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/main-mods/main-mods.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<mat-icon aria-hidden="false" class="setup-icon">cloud_upload</mat-icon>
</div>
<mat-card-title>Mod Management</mat-card-title>
<mat-card-subtitle>Manage all mods available for the quest here. Install, uninstall, and configure mods..</mat-card-subtitle>
<div class="builtinMods">
<mat-card-subtitle>Manage all mods available for the quest here. Install, uninstall, and configure mods.</mat-card-subtitle>
<div *ngIf="showColorMods" class="builtinMods">
<button mat-raised-button [ngStyle]="{'background-color': leftColor}" cpPosition="left" [cpPositionOffset]="-30" [cpCmykEnabled]="false"
[(colorPicker)]="leftColor"
[cpAlphaChannel]="true" cpCloseClickOutside="true" cpOutputFormat="rgba"
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/app/main-mods/main-mods.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ClientChangeColor, ColorType } from '../models/ClientChangeColor';
})
export class MainModsComponent implements OnInit, AfterViewInit {
config: QuestomConfig = <QuestomConfig>{ Mods: [] };
showColorMods: boolean = false;
beatSaberVersion: string = '';
modSwitchInProgress: boolean = false;
modIDBeingSwitched: string = null;
Expand All @@ -36,10 +37,27 @@ export class MainModsComponent implements OnInit, AfterViewInit {
) {
this.configSvc.configUpdated.subscribe((cfg: BeatOnConfig) => {
this.config = cfg.Config;
this.checkColorMod(cfg);
this.beatSaberVersion = cfg.BeatSaberVersion;
});
}
isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}

checkColorMod(cfg: BeatOnConfig) {
if (cfg.BeatSaberVersion) {
var split = cfg.BeatSaberVersion.split('.');
if (split.length >= 2) {
if (this.isNumeric(split[0]) && this.isNumeric(split[1])) {
if (parseInt(split[0]) >= 1 && parseInt(split[1]) <= 2) {
this.showColorMods = true;
console.log('color mods enabled for older version than 1.3');
}
}
}
}
}
get leftColor() {
if (this.config && this.config.LeftColor) {
return (
Expand Down Expand Up @@ -106,6 +124,7 @@ export class MainModsComponent implements OnInit, AfterViewInit {
let isInit = false;
this.configSvc.getConfig().subscribe((cfg: BeatOnConfig) => {
this.config = cfg.Config;
this.checkColorMod(cfg);
this.beatSaberVersion = cfg.BeatSaberVersion;
});
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/setup/setup.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h4>Welcome to Beat On!</h4>
<p>Beat On will modify and reinstall your copy of Beat Saber so that it can support custom songs and some additional modifications.
After the modifications to Beat Saber during the setup process, Beat On will allow you to download songs on the Quest from this app, upload songs from your computer, manage custom playlists from the Quest or your computer's browser and install some types of other modifications.</p>

<h4>This version of Beat On is intended for Beat Saber version 1.1.0 and 1.2.0!</h4>
<h4>This version of Beat On is intended for Beat Saber version 1.3.0!</h4>
<p>It is remotely possible that it may work with future versions of Beat Saber without modification, however it is highly likely that if a new version of Beat Saber has been released, this will result in a Beat Saber that doesn't work and you will need to wait for an update to Beat On.</p>
<br />
<p style="color: orangered">If at any point you have problems with Beat Saber or Beat On, uninstalling Beat Saber (either through Beat On or another tool like adb) and reinstalling Beat Saber from the Oculus Store will revert Beat Saber back to normal.</p>
Expand Down

0 comments on commit 6485efd

Please sign in to comment.