-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ae20b3
commit 054dbc2
Showing
33 changed files
with
301 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ target/ | |
*.idea | ||
*.iml | ||
*DotSettings.user | ||
**/TestResult.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
Osu.Patcher.Hook/Patches/LivePerformance/PerformanceCalculator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using Osu.Stubs; | ||
using Osu.Stubs.Framework; | ||
|
||
namespace Osu.Patcher.Hook.Patches.LivePerformance; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Osu.Stubs.Tests</RootNamespace> | ||
<TargetFramework>net462</TargetFramework> | ||
<PlatformTarget>x86</PlatformTarget> <!-- Running in 32bit is necessary for loading in osu! --> | ||
<LangVersion>12</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System.Net.Http"/> | ||
<ProjectReference Include="../Osu.Stubs/Osu.Stubs.csproj"/> | ||
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="all"/> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> | ||
|
||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0"/> | ||
<PackageReference Include="NUnit" Version="4.1.0"/> | ||
<PackageReference Include="NUnitLite" Version="4.1.0"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Newtonsoft.Json; | ||
|
||
namespace Osu.Stubs.Tests; | ||
|
||
[PublicAPI] | ||
public static class OsuApi | ||
{ | ||
[PublicAPI] | ||
public enum ReleaseStream | ||
{ | ||
CuttingEdge, | ||
Stable40, | ||
Beta40, | ||
} | ||
|
||
private static readonly HttpClient Http = new(); | ||
|
||
/// <summary> | ||
/// Gets the latest release files for a specific release stream. | ||
/// </summary> | ||
public static async Task<List<OsuUpdateFile>> GetReleaseFiles(ReleaseStream stream) | ||
{ | ||
Console.WriteLine("Fetching latest osu! update info"); | ||
|
||
var url = $"https://osu.ppy.sh/web/check-updates.php" + | ||
$"?action=check" + | ||
$"&stream={stream.ToString().ToLower()}" + | ||
$"&time={DateTime.Now.Ticks}"; | ||
|
||
using var response = await Http.GetAsync(url); | ||
response.EnsureSuccessStatusCode(); | ||
|
||
var bodyText = await response.Content.ReadAsStringAsync(); | ||
if (bodyText == null) throw new Exception("Response returned no body"); | ||
|
||
var releaseFiles = JsonConvert.DeserializeObject<List<OsuUpdateFile>>(bodyText); | ||
if (releaseFiles == null) throw new Exception("Failed to deserialize update files"); | ||
|
||
return releaseFiles; | ||
} | ||
|
||
/// <summary> | ||
/// Downloads the full osu! update file list to a specific directory. | ||
/// </summary> | ||
/// <param name="dir">An empty directory.</param> | ||
/// <param name="stream">The release stream to download.</param> | ||
public static async Task DownloadOsu(string dir, ReleaseStream stream = ReleaseStream.Stable40) | ||
{ | ||
var updateFiles = await GetReleaseFiles(ReleaseStream.Stable40); | ||
|
||
Parallel.ForEach(updateFiles, updateFile => | ||
{ | ||
Console.WriteLine($"Downloading {updateFile.FileName}"); | ||
DownloadFile(updateFile.DownloadUrl, Path.Combine(dir, updateFile.FileName)).Wait(); | ||
}); | ||
|
||
Console.WriteLine("Finished downloading osu!"); | ||
} | ||
|
||
private static async Task DownloadFile(string url, string path) | ||
{ | ||
using var response = await Http.GetAsync(url); | ||
response.EnsureSuccessStatusCode(); | ||
|
||
var bodyStream = await response.Content.ReadAsStreamAsync(); | ||
if (bodyStream == null) throw new Exception("Response returned no body"); | ||
|
||
using var file = File.Create(path); | ||
await bodyStream.CopyToAsync(file); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Osu.Stubs.Tests; | ||
|
||
public class OsuUpdateFile | ||
{ | ||
[JsonRequired] | ||
[JsonProperty("file_version")] | ||
public int FileVersion { get; set; } | ||
|
||
[JsonRequired] | ||
[JsonProperty("filesize")] | ||
public int FileSize { get; set; } | ||
|
||
[JsonRequired] | ||
[JsonProperty("filename")] | ||
public string FileName { get; set; } = null!; | ||
|
||
[JsonRequired] | ||
[JsonProperty("file_hash")] | ||
public string FileHash { get; set; } = null!; | ||
|
||
[JsonRequired] | ||
[JsonProperty("timestamp")] | ||
public string Timestamp { get; set; } = null!; | ||
|
||
[JsonRequired] | ||
[JsonProperty("url_full")] | ||
public string DownloadUrl { get; set; } = null!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NUnitLite; | ||
|
||
namespace Osu.Stubs.Tests; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) => new AutoRun().Execute(args); | ||
} |
Oops, something went wrong.