-
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.
Merge pull request #233 from Founntain/logging
Implementation of console logging & Project Restructure
- Loading branch information
Showing
169 changed files
with
1,614 additions
and
1,071 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
6 changes: 3 additions & 3 deletions
6
...ayer.IO/DbReader/DataModels/DbMapEntry.cs → OsuPlayer.Data/DataModels/DbMapEntry.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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using System.Text; | ||
using Nein.Extensions; | ||
using OsuPlayer.Data.DataModels.Interfaces; | ||
|
||
namespace OsuPlayer.Data.DataModels; | ||
|
||
/// <summary> | ||
/// a minimal beatmap entry with only frequently used data | ||
/// </summary> | ||
public class DbMapEntryBase : IMapEntryBase | ||
{ | ||
public required IDbReaderFactory DbReaderFactory { get; init; } | ||
|
||
public long DbOffset { get; init; } | ||
public string? OsuPath { get; init; } | ||
public string Artist { get; init; } = string.Empty; | ||
public string Title { get; init; } = string.Empty; | ||
public string Hash { get; init; } = string.Empty; | ||
public int BeatmapSetId { get; init; } | ||
public int TotalTime { get; init; } | ||
public string TotalTimeString => TimeSpan.FromMilliseconds(TotalTime).FormatTime(); | ||
public string SongName => GetSongName(); | ||
public string ArtistString => GetArtist(); | ||
public string TitleString => GetTitle(); | ||
|
||
/// <summary> | ||
/// Gets the artist | ||
/// <remarks>may be overridden for usage with <see cref="DbMapEntry.UseUnicode" /></remarks> | ||
/// </summary> | ||
/// <returns>the artist</returns> | ||
public virtual string GetArtist() | ||
{ | ||
return Artist; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the title | ||
/// <remarks>may be overridden for usage with <see cref="DbMapEntry.UseUnicode" /></remarks> | ||
/// </summary> | ||
/// <returns>the title</returns> | ||
public virtual string GetTitle() | ||
{ | ||
return Title; | ||
} | ||
|
||
public string GetSongName() | ||
{ | ||
return $"{GetArtist()} - {GetTitle()}"; | ||
} | ||
|
||
/// <summary> | ||
/// Reads a osu!.db map entry and fills a full <see cref="DbMapEntry" /> with data | ||
/// </summary> | ||
/// <returns>a new <see cref="DbMapEntry" /> generated from osu!.db data</returns> | ||
public IMapEntry? ReadFullEntry() | ||
{ | ||
if (OsuPath == null) return null; | ||
|
||
var reader = GetReader(); | ||
|
||
if (reader == default) | ||
return null; | ||
|
||
return reader.ReadFullEntry(OsuPath, this, dbOffset: DbOffset); | ||
} | ||
|
||
public IDatabaseReader? GetReader() | ||
{ | ||
if (OsuPath == null) | ||
return null; | ||
|
||
return DbReaderFactory.CreateDatabaseReader(OsuPath); | ||
} | ||
|
||
public bool Equals(IMapEntryBase? other) | ||
{ | ||
return Hash == other?.Hash; | ||
} | ||
|
||
public int CompareTo(IMapEntryBase? other) | ||
{ | ||
return string.Compare(Hash, other?.Hash, StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return GetSongName(); | ||
} | ||
|
||
public static bool operator ==(DbMapEntryBase? left, IMapEntryBase? right) | ||
{ | ||
return left?.Hash == right?.Hash; | ||
} | ||
|
||
public static bool operator !=(DbMapEntryBase? left, IMapEntryBase? right) | ||
{ | ||
return left?.Hash != right?.Hash; | ||
} | ||
|
||
public override bool Equals(object? other) | ||
{ | ||
if (other is IMapEntryBase map) | ||
return Hash == map.Hash; | ||
|
||
return false; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return BitConverter.ToInt32(Encoding.UTF8.GetBytes(Hash)); | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
.../Extensions/HistoricalMapEntryComparer.cs → .../Extensions/HistoricalMapEntryComparer.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using OsuPlayer.Data.DataModels.Interfaces; | ||
using OsuPlayer.Data.Enums; | ||
|
||
namespace OsuPlayer.Data.DataModels; | ||
|
||
public interface IDbReaderFactory | ||
{ | ||
public DbCreationType Type { get; set; } | ||
|
||
public IDatabaseReader CreateDatabaseReader(string path); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...layer.IO/DbReader/Interfaces/IMapEntry.cs → ...r.Data/DataModels/Interfaces/IMapEntry.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
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,23 @@ | ||
using Avalonia.Media; | ||
|
||
namespace OsuPlayer.Data.DataModels.Interfaces; | ||
|
||
public interface IUser | ||
{ | ||
public Guid UniqueId { get; } | ||
|
||
public string SongsPlayedString { get; } | ||
public string LevelAndTotalXpString { get; } | ||
public string LevelProgressString { get; } | ||
public Brush RoleColor { get; } | ||
public string RoleString { get; } | ||
public string DescriptionTitleString { get; } | ||
public string LevelString { get; } | ||
public string JoinDateString { get; } | ||
public string TotalXpString { get; } | ||
|
||
public int GetXpNeededForNextLevel(); | ||
public static abstract int GetXpNeededForNextLevel(int level); | ||
public Brush GetRoleColorBrush(); | ||
public string GetRoleString(); | ||
} |
11 changes: 3 additions & 8 deletions
11
...ayer/Modules/Services/ObservableSorter.cs → ...layer.Data/DataModels/ObservableSorter.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
2 changes: 1 addition & 1 deletion
2
OsuPlayer.Network/Online/Article.cs → OsuPlayer.Data/DataModels/Online/Article.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
2 changes: 1 addition & 1 deletion
2
OsuPlayer.Network/Online/News.cs → OsuPlayer.Data/DataModels/Online/News.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
2 changes: 1 addition & 1 deletion
2
...k/Online/OnlineUserStatusModelExtended.cs → ...s/Online/OnlineUserStatusModelExtended.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
2 changes: 1 addition & 1 deletion
2
OsuPlayer.Network/Online/UserColors.cs → ...ayer.Data/DataModels/Online/UserColors.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
8 changes: 4 additions & 4 deletions
8
OsuPlayer.IO/DbReader/Collection.cs → OsuPlayer.Data/DataModels/OsuCollection.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
6 changes: 3 additions & 3 deletions
6
...r.IO/DbReader/DataModels/RealmMapEntry.cs → OsuPlayer.Data/DataModels/RealmMapEntry.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
Oops, something went wrong.