-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
88 changed files
with
1,616 additions
and
1,525 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> | ||
<PackageReference Include="System.Drawing.Common" Version="5.0.3" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" /> | ||
</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,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndrealImageGenerator", "AndrealImageGenerator.csproj", "{505FA106-482E-44D6-92E0-FB2304B3140F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{505FA106-482E-44D6-92E0-FB2304B3140F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{505FA106-482E-44D6-92E0-FB2304B3140F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{505FA106-482E-44D6-92E0-FB2304B3140F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{505FA106-482E-44D6-92E0-FB2304B3140F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ALA/@EntryIndexedValue">ALA</s:String></wpf:ResourceDictionary> |
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,120 @@ | ||
using System.Collections.Concurrent; | ||
using AndrealImageGenerator.Graphics; | ||
using Newtonsoft.Json; | ||
using Path = AndrealImageGenerator.Common.Path; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
namespace AndrealImageGenerator.Beans; | ||
|
||
public class ArcaeaChart | ||
{ | ||
private static readonly ConcurrentDictionary<string, Stream> SongImage = new(); | ||
|
||
[JsonProperty("name_en")] | ||
public string NameEn { get; set; } | ||
|
||
[JsonProperty("name_jp")] | ||
public string NameJp { get; set; } | ||
|
||
[JsonProperty("artist")] | ||
public string Artist { get; set; } | ||
|
||
[JsonProperty("bpm")] | ||
public string Bpm { get; set; } | ||
|
||
[JsonProperty("bpm_base")] | ||
public double BpmBase { get; set; } | ||
|
||
[JsonProperty("set")] | ||
public string Set { get; set; } | ||
|
||
[JsonProperty("set_friendly")] | ||
public string SetFriendly { get; set; } | ||
|
||
[JsonProperty("time")] | ||
public int Time { get; set; } | ||
|
||
[JsonProperty("side")] | ||
public Side Side { get; set; } | ||
|
||
[JsonProperty("world_unlock")] | ||
public bool WorldUnlock { get; set; } | ||
|
||
[JsonProperty("remote_download")] | ||
public bool RemoteDownload { get; set; } | ||
|
||
[JsonProperty("bg")] | ||
public string Bg { get; set; } | ||
|
||
[JsonProperty("date")] | ||
public int Date { get; set; } | ||
|
||
[JsonProperty("version")] | ||
public string Version { get; set; } | ||
|
||
[JsonProperty("difficulty")] | ||
public int Difficulty { get; set; } | ||
|
||
[JsonProperty("rating")] | ||
public int Rating { get; set; } | ||
|
||
[JsonProperty("note")] | ||
public int Note { get; set; } | ||
|
||
[JsonProperty("chart_designer")] | ||
public string ChartDesigner { get; set; } | ||
|
||
[JsonProperty("jacket_designer")] | ||
public string JacketDesigner { get; set; } | ||
|
||
[JsonProperty("jacket_override")] | ||
public bool JacketOverride { get; set; } | ||
|
||
[JsonProperty("audio_override")] | ||
public bool AudioOverride { get; set; } | ||
|
||
internal string SongID { get; set; } | ||
|
||
internal double Const => (double)Rating / 10; | ||
|
||
internal int RatingClass { get; set; } | ||
|
||
internal DifficultyInfo DifficultyInfo => DifficultyInfo.GetByIndex(RatingClass); | ||
|
||
internal string GetSongName(byte length) => NameEn.Length < length + 3 ? NameEn : $"{NameEn[..length]}..."; | ||
|
||
internal async Task<Image> GetSongImage() | ||
{ | ||
var path = await Path.ArcaeaSong(this); | ||
|
||
try | ||
{ | ||
if (!SongImage.TryGetValue(path, out var stream)) | ||
{ | ||
await using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
|
||
using var reader = new BinaryReader(fileStream); | ||
var bytes = reader.ReadBytes((int)fileStream.Length); | ||
stream = new MemoryStream(bytes); | ||
reader.Close(); | ||
fileStream.Close(); | ||
|
||
SongImage.TryAdd(path, stream); | ||
} | ||
|
||
var img = new Image(stream); | ||
if (img.Width == 512) return img; | ||
var newimg = new Image(img, 512, 512); | ||
newimg.SaveAsPng(path); | ||
img.Dispose(); | ||
return newimg; | ||
} | ||
catch (Exception e) | ||
{ | ||
SongImage.TryRemove(path, out var s); | ||
s?.DisposeAsync(); | ||
throw new ArgumentException("GetSongImage Failed.", NameEn, e); | ||
} | ||
} | ||
} |
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,19 @@ | ||
using AndrealImageGenerator.Beans.Json; | ||
|
||
namespace AndrealImageGenerator.Beans; | ||
|
||
internal class Best30Data | ||
{ | ||
internal Best30Data(UserBestsContent b30data) | ||
{ | ||
B30data = b30data; | ||
} | ||
|
||
private UserBestsContent B30data { get; } | ||
|
||
internal string Best30Avg => B30data.Best30Avg.ToString("0.0000"); | ||
|
||
internal string Recent10Avg => B30data.Recent10Avg > 0 ? B30data.Recent10Avg.ToString("0.0000") : "--"; | ||
|
||
internal List<RecordInfo> Best30List => B30data.Best30List.Select(i => new RecordInfo(i)).ToList(); | ||
} |
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,21 @@ | ||
using AndrealImageGenerator.Beans.Json; | ||
|
||
namespace AndrealImageGenerator.Beans; | ||
|
||
internal class Best40Data | ||
{ | ||
internal Best40Data(UserBestsContent b40data) | ||
{ | ||
B40data = b40data; | ||
} | ||
|
||
private UserBestsContent B40data { get; } | ||
|
||
internal string Best30Avg => B40data.Best30Avg.ToString("0.0000"); | ||
|
||
internal string Recent10Avg => B40data.Recent10Avg > 0 ? B40data.Recent10Avg.ToString("0.0000") : "--"; | ||
|
||
internal List<RecordInfo> Best30List => B40data.Best30List.Select(i => new RecordInfo(i)).ToList(); | ||
|
||
internal List<RecordInfo>? OverflowList => B40data.OverflowList?.Select(i => new RecordInfo(i)).ToList(); | ||
} |
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,42 @@ | ||
using System.Collections.Concurrent; | ||
using System.Drawing; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
namespace AndrealImageGenerator.Beans; | ||
|
||
[Serializable] | ||
internal class DifficultyInfo | ||
{ | ||
private static readonly ConcurrentDictionary<int, DifficultyInfo> List = new(); | ||
|
||
static DifficultyInfo() | ||
{ | ||
List.TryAdd(3, new() { LongStr = "Beyond", ShortStr = "BYD", Alias = new[] { "byn", "byd", "beyond" }, Color = Color.FromArgb(165, 20, 49) }); | ||
|
||
List.TryAdd(2, new() { LongStr = "Future", ShortStr = "FTR", Alias = new[] { "ftr", "future" }, Color = Color.FromArgb(115, 35, 100) }); | ||
|
||
List.TryAdd(1, new() { LongStr = "Present", ShortStr = "PRS", Alias = new[] { "prs", "present" }, Color = Color.FromArgb(120, 155, 80) }); | ||
|
||
List.TryAdd(0, new() { LongStr = "Past", ShortStr = "PST", Alias = new[] { "pst", "past" }, Color = Color.FromArgb(20, 165, 215) }); | ||
} | ||
|
||
private string[] Alias { get; set; } | ||
internal string LongStr { get; private set; } | ||
internal string ShortStr { get; private set; } | ||
internal Color Color { get; private set; } | ||
|
||
internal static DifficultyInfo GetByIndex(int index) => List[index]; | ||
|
||
internal static (string, int) DifficultyConverter(string dif) | ||
{ | ||
foreach (var (key, value) in List) | ||
{ | ||
foreach (var alias in value.Alias.Where(dif.EndsWith)) return (dif[..^alias.Length], key); | ||
} | ||
|
||
return (dif, -1); | ||
} | ||
|
||
public static implicit operator string(DifficultyInfo info) => info.ShortStr; | ||
} |
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,9 @@ | ||
namespace AndrealImageGenerator.Beans; | ||
|
||
public enum ImgVersion | ||
{ | ||
ImgV1 = 1, | ||
ImgV2, | ||
ImgV3, | ||
ImgV4 | ||
} |
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,35 @@ | ||
using Newtonsoft.Json; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
namespace AndrealImageGenerator.Beans.Json; | ||
|
||
public class AccountInfo | ||
{ | ||
[JsonProperty("code")] | ||
public int Code { get; set; } | ||
|
||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("user_id")] | ||
public int UserID { get; set; } | ||
|
||
[JsonProperty("is_mutual")] | ||
public bool IsMutual { get; set; } | ||
|
||
[JsonProperty("is_char_uncapped_override")] | ||
public bool IsCharUncappedOverride { get; set; } | ||
|
||
[JsonProperty("is_char_uncapped")] | ||
public bool IsCharUncapped { get; set; } | ||
|
||
[JsonProperty("is_skill_sealed")] | ||
public bool IsSkillSealed { get; set; } | ||
|
||
[JsonProperty("rating")] | ||
public short Rating { get; set; } | ||
|
||
[JsonProperty("character")] | ||
public int Character { get; set; } | ||
} |
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,38 @@ | ||
using Newtonsoft.Json; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
namespace AndrealImageGenerator.Beans.Json; | ||
|
||
public class ArcSongdata | ||
{ | ||
[JsonProperty("song_id")] | ||
public string SongID { get; set; } | ||
|
||
[JsonProperty("difficulty")] | ||
public sbyte Difficulty { get; set; } | ||
|
||
[JsonProperty("score")] | ||
public int Score { get; set; } | ||
|
||
[JsonProperty("shiny_perfect_count")] | ||
public string MaxPure { get; set; } | ||
|
||
[JsonProperty("perfect_count")] | ||
public string Pure { get; set; } | ||
|
||
[JsonProperty("near_count")] | ||
public string Far { get; set; } | ||
|
||
[JsonProperty("miss_count")] | ||
public string Lost { get; set; } | ||
|
||
[JsonProperty("time_played")] | ||
public long TimePlayed { get; set; } | ||
|
||
[JsonProperty("clear_type")] | ||
public sbyte ClearType { get; set; } | ||
|
||
[JsonProperty("rating")] | ||
public double Rating { get; set; } | ||
} |
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,17 @@ | ||
using Newtonsoft.Json; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
namespace AndrealImageGenerator.Beans.Json; | ||
|
||
public class ResponseRoot<T> | ||
{ | ||
[JsonProperty("status")] | ||
public int Status { get; set; } | ||
|
||
[JsonProperty("message")] | ||
public string Message { get; set; } | ||
|
||
[JsonProperty("content")] | ||
public T Content { get; set; } | ||
} |
Oops, something went wrong.