From 293d567ef2095c42ecd6a8896d015106493f91e8 Mon Sep 17 00:00:00 2001 From: Exsper Date: Sat, 3 Feb 2024 13:33:09 +0800 Subject: [PATCH] Add Skins --- LazerFilesViewer/MainForm.cs | 32 +++++++++++-- LazerFilesViewer/Osu.Game/SkinInfo.cs | 65 +++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 LazerFilesViewer/Osu.Game/SkinInfo.cs diff --git a/LazerFilesViewer/MainForm.cs b/LazerFilesViewer/MainForm.cs index ba23626..375dc27 100644 --- a/LazerFilesViewer/MainForm.cs +++ b/LazerFilesViewer/MainForm.cs @@ -1,5 +1,6 @@ using Microsoft.VisualBasic.FileIO; using osu.Game.Beatmaps; +using osu.Game.Skinning; using Realms; using System.Collections; using System.Diagnostics; @@ -22,6 +23,7 @@ public partial class MainForm : Form private string DataBasePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\osu\client.realm"; private FakeDirectory Songs = new FakeDirectory("Songs", "\\"); + private FakeDirectory Skins = new FakeDirectory("Skins", "\\"); SelectedItemsList SelectedItemsList; @@ -43,8 +45,8 @@ private RealmConfiguration GetConfiguration() private void BuildDirectories() { Realm r = Realm.GetInstance(GetConfiguration()); - var allItems = r.All(); - foreach (var item in allItems) + var allBeatmaps = r.All(); + foreach (var item in allBeatmaps) { string title = (item.Beatmaps.Count > 0) ? item.OnlineID + " " + item.Beatmaps.First().Metadata.ArtistUnicode + " - " + item.Beatmaps.First().Metadata.TitleUnicode : item.Hash; FakeDirectory d = Songs.AddDirectory(title); @@ -53,6 +55,16 @@ private void BuildDirectories() d.AddFile(file.Filename, file.File.Hash); } } + var allSkins = r.All(); + foreach (var item in allSkins) + { + string title = item.ToString(); + FakeDirectory d = Skins.AddDirectory(title); + foreach (var file in item.Files) + { + d.AddFile(file.Filename, file.File.Hash); + } + } r.Dispose(); } @@ -115,6 +127,11 @@ private void ShowRootDirectory(bool isHistory = false) item.Tag = Songs; item.SubItems.Add("�ļ���"); item.SubItems.Add(""); + + item = FileListView.Items.Add("Skins", (int)FileListIcons.Folder); + item.Tag = Skins; + item.SubItems.Add("�ļ���"); + item.SubItems.Add(""); AddressToolStripComboBox.Text = "\\"; if (!isHistory) historyControl.AddHistory(CurrentPage.Directory, "\\"); CheckButtonEnable(); @@ -145,11 +162,20 @@ private bool OpenPath(string path, bool isHistory = false) ShowCurrentDirectory(Songs, isHistory); return true; } - FakeDirectory d = Songs; + if (path == "Skins") + { + ShowCurrentDirectory(Skins, isHistory); + return true; + } + FakeDirectory d = null; if (path.StartsWith("Songs\\")) { d = Songs.GetDirectory(path.Substring(6)); } + if (path.StartsWith("Skins\\")) + { + d = Skins.GetDirectory(path.Substring(6)); + } if (d != null) { ShowCurrentDirectory(d, isHistory); diff --git a/LazerFilesViewer/Osu.Game/SkinInfo.cs b/LazerFilesViewer/Osu.Game/SkinInfo.cs new file mode 100644 index 0000000..8026855 --- /dev/null +++ b/LazerFilesViewer/Osu.Game/SkinInfo.cs @@ -0,0 +1,65 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using osu.Game.Models; +using Realms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace osu.Game.Skinning +{ + [MapTo("Skin")] + public class SkinInfo : RealmObject, IEquatable + { + internal static readonly Guid TRIANGLES_SKIN = new Guid("2991CFD8-2140-469A-BCB9-2EC23FBCE4AD"); + internal static readonly Guid ARGON_SKIN = new Guid("CFFA69DE-B3E3-4DEE-8563-3C4F425C05D0"); + internal static readonly Guid ARGON_PRO_SKIN = new Guid("9FC9CF5D-0F16-4C71-8256-98868321AC43"); + internal static readonly Guid CLASSIC_SKIN = new Guid("81F02CD3-EEC6-4865-AC23-FAE26A386187"); + internal static readonly Guid RANDOM_SKIN = new Guid("D39DFEFB-477C-4372-B1EA-2BCEA5FB8908"); + + [PrimaryKey] + public Guid ID { get; set; } + + public string Name { get; set; } = null!; + + public string Creator { get; set; } = null!; + + public string InstantiationInfo { get; set; } = null!; + + public string Hash { get; set; } = string.Empty; + public bool Protected { get; set; } + + public IList Files { get; } = null!; + + public bool DeletePending { get; set; } + + public SkinInfo(string? name = null, string? creator = null, string? instantiationInfo = null) + { + Name = name ?? string.Empty; + Creator = creator ?? string.Empty; + InstantiationInfo = instantiationInfo ?? string.Empty; + ID = Guid.NewGuid(); + } + + private SkinInfo() + { + } + + public bool Equals(SkinInfo? other) + { + if (ReferenceEquals(this, other)) return true; + if (other == null) return false; + + return ID == other.ID; + } + + public override string ToString() + { + string author = string.IsNullOrEmpty(Creator) ? string.Empty : $"({Creator})"; + return $"{Name} {author}".Trim(); + } + + } +}