Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Oops definitely didn't forget something
Browse files Browse the repository at this point in the history
  • Loading branch information
gompoc committed Nov 17, 2021
1 parent 948f913 commit f55829a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### WorldPredownload v1.6.5
- *Actually downloads worlds properly now*

### WorldPredownload v1.6.4
- Fix compatibility with latest update

Expand Down
7 changes: 2 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
### WorldPredownload v1.6.4
- Fix compatibility with latest update

### ActionMenuUtils v2.0.4
- *Actually* fix compatibility with latest update
### WorldPredownload v1.6.5
- *Actually downloads worlds properly now*
38 changes: 15 additions & 23 deletions WorldPredownload/DownloadManager/DownloadComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace WorldPredownload.DownloadManager
[SuppressMessage("ReSharper", "HeuristicUnreachableCode")]
public static partial class WorldDownloadManager
{
private static readonly AsyncCompletedEventHandler OnComplete = async (_, args) =>
private static readonly AsyncCompletedEventHandler OnComplete = Complete;

private static async void Complete(object _, AsyncCompletedEventArgs args)
{
await TaskUtilities.YieldToMainThread();
webClient.Dispose();
Expand All @@ -32,9 +34,7 @@ public static partial class WorldDownloadManager
WorldButton.UpdateTextDownloadStopped();
//WorldDownloadStatus.GameObject.SetText(Constants.STATUS_IDLE_TEXT);
if (!string.IsNullOrEmpty(file)) File.Delete(file);
if (!args.Cancelled)
MelonLogger.Error(
$"World failed to download. Why you might ask?... I don't know! This exception might help: {args.Error}");
if (!args.Cancelled) MelonLogger.Error($"World failed to download. Why you might ask?... I don't know! This exception might help: {args.Error}");
return;
}

Expand All @@ -44,26 +44,18 @@ public static partial class WorldDownloadManager
// level = CompressionLevel.High,
// blockSize = 131072U
// }, 0, ThreadPriority.Normal);

var operation = AssetBundle.RecompressAssetBundleAsync_Internal(file, file, new BuildCompression
{
compression = CompressionType.Lz4,
level = CompressionLevel.High,
blockSize = 131072U
}, 0, ThreadPriority.Normal);

operation.add_completed(DelegateSupport.ConvertDelegate<Action<AsyncOperation>>(
new System.Action<AsyncOperation>(
delegate
{
MelonLogger.Msg($"Finished recompressing world with result: {operation.result}");
var task = new Task(OnRecompress);
// I don't really know how else to ensure that this the recompress operation runs on the main thread, if you know feel free to bonk me for being dumb
task.NoAwait("WorldPredownload OnRecompress");
task.Start();
}))
);
};
var operation = AssetBundle.RecompressAssetBundleAsync_Internal(file, file, new BuildCompression {compression = CompressionType.Lz4, level = CompressionLevel.High, blockSize = 131072U}, 0, ThreadPriority.Normal);

operation.add_completed(DelegateSupport.ConvertDelegate<Action<AsyncOperation>>(new System.Action<AsyncOperation>(delegate
{
MelonLogger.Msg($"Finished recompressing world with result: {operation.result}");
var task = new Task(OnRecompress);
// I don't really know how else to ensure that this the recompress operation runs on the main thread, if you know feel free to bonk me for being dumb
task.NoAwait("WorldPredownload OnRecompress");
task.Start();
})));
}

private static async void OnRecompress()
{
Expand Down
6 changes: 4 additions & 2 deletions WorldPredownload/DownloadManager/DownloadProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ namespace WorldPredownload.DownloadManager
[SuppressMessage("ReSharper", "HeuristicUnreachableCode")]
public static partial class WorldDownloadManager
{
private static readonly DownloadProgressChangedEventHandler OnProgress = async (_, args) =>
private static readonly DownloadProgressChangedEventHandler OnProgress = Progress;

private static async void Progress(object _, DownloadProgressChangedEventArgs args)
{
await TaskUtilities.YieldToMainThread();
if (!Downloading) return;
Expand All @@ -21,6 +23,6 @@ public static partial class WorldDownloadManager
if (FriendButton.CanChangeText) FriendButton.Button.SetText(text);
if (WorldButton.CanChangeText) WorldButton.Button.SetText(text);
if (ModSettings.showStatusOnHud) HudIcon.Update(args.ProgressPercentage / 100f);
};
}
}
}
4 changes: 2 additions & 2 deletions WorldPredownload/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace WorldPredownload.Helpers
[SuppressMessage("ReSharper", "HeuristicUnreachableCode")]
public static class Utilities
{
private static readonly Regex FileIdRegex = new("(/file_[0-9A-Za-z-]+/)", RegexOptions.Compiled);
private static readonly Regex FileIdRegex = new("/(file_[0-9A-Za-z-]+)/", RegexOptions.Compiled);

private static readonly Regex FileVersionRegex = new("(?:\\/file_[0-9A-Za-z-]+\\/)([0-9]+)", RegexOptions.Compiled);

Expand Down Expand Up @@ -73,7 +73,7 @@ public static AssetBundleDownloadManager GetAssetBundleDownloadManager()
{
return AssetBundleDownloadManager.prop_AssetBundleDownloadManager_0;
}

public static void HideCurrentPopup()
{
VRCUiManager.prop_VRCUiManager_0.HideScreen("POPUP");
Expand Down
2 changes: 1 addition & 1 deletion WorldPredownload/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UIExpansionKit.API;
using WorldPredownload.UI;

[assembly: MelonInfo(typeof(WorldPredownload.WorldPredownload), "WorldPredownload", "1.6.4", "gompo", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: MelonInfo(typeof(WorldPredownload.WorldPredownload), "WorldPredownload", "1.6.5", "gompo", "https://github.com/gompoc/VRChatMods/releases/")]
[assembly: MelonGame("VRChat", "VRChat")]
[assembly: ModJsonInfo(
141,
Expand Down
2 changes: 1 addition & 1 deletion WorldPredownload/WorldPredownload.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<VrcReferences>true</VrcReferences>
<Version>1.6.4.0</Version>
<Version>1.6.5.0</Version>
<LangVersion>9</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>annotations</Nullable>
Expand Down

0 comments on commit f55829a

Please sign in to comment.