Skip to content

Commit

Permalink
Add Skins
Browse files Browse the repository at this point in the history
  • Loading branch information
Exsper committed Feb 3, 2024
1 parent 6b38e80 commit 293d567
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 3 deletions.
32 changes: 29 additions & 3 deletions LazerFilesViewer/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.VisualBasic.FileIO;
using osu.Game.Beatmaps;
using osu.Game.Skinning;
using Realms;
using System.Collections;
using System.Diagnostics;
Expand All @@ -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;

Expand All @@ -43,8 +45,8 @@ private RealmConfiguration GetConfiguration()
private void BuildDirectories()
{
Realm r = Realm.GetInstance(GetConfiguration());
var allItems = r.All<BeatmapSetInfo>();
foreach (var item in allItems)
var allBeatmaps = r.All<BeatmapSetInfo>();
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);
Expand All @@ -53,6 +55,16 @@ private void BuildDirectories()
d.AddFile(file.Filename, file.File.Hash);
}
}
var allSkins = r.All<SkinInfo>();
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();
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
65 changes: 65 additions & 0 deletions LazerFilesViewer/Osu.Game/SkinInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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<SkinInfo>
{
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<RealmNamedFileUsage> 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();
}

}
}

0 comments on commit 293d567

Please sign in to comment.