Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrollable beatmap list #252

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
using System;
using maisim.Game.Beatmaps;
using osu.Framework.Bindables;

namespace maisim.Game.Graphics.UserInterface.Overlays
{
/// <summary>
/// A class that provide the bindable for the current <see cref="BeatmapSet"/> and <see cref="DifficultyLevel"/> of the game.
/// </summary>
public class CurrentWorkingBeatmap
{
/// <summary>
/// The bindable for the current <see cref="BeatmapSet"/>.
/// </summary>
private Bindable<BeatmapSet> currentBeatmapSet = new Bindable<BeatmapSet>();

/// <summary>
/// The bindable for the current <see cref="DifficultyLevel"/>.
/// </summary>
private Bindable<DifficultyLevel> currentDifficultyLevel = new Bindable<DifficultyLevel>();

/// <summary>
/// Get the current <see cref="BeatmapSet"/> of the game.
/// </summary>
public BeatmapSet BeatmapSet => currentBeatmapSet.Value;

/// <summary>
/// Get the current <see cref="DifficultyLevel"/> of the game.
/// </summary>
public DifficultyLevel DifficultyLevel => currentDifficultyLevel.Value;

/// <summary>
/// Bind <see cref="ValueChangedEvent{T}"/> of the <see cref="BeatmapSet"/> to the <see cref="BeatmapSet"/> bindable.
/// </summary>
/// <param name="onChange">The action to perform when <see cref="BeatmapSet"/> changes.</param>
/// <param name="runOnceImmediately">Whether the action provided in <paramref name="onChange"/> should be run once immediately.</param>
public void BindBeatmapSetChanged(Action<ValueChangedEvent<BeatmapSet>> onChange, bool runOnceImmediately = false) => currentBeatmapSet.BindValueChanged(onChange, runOnceImmediately);

/// <summary>
/// Bind <see cref="ValueChangedEvent{T}"/> of the <see cref="DifficultyLevel"/> to the <see cref="DifficultyLevel"/> bindable.
/// </summary>
/// <param name="onChange">The action to perform when <see cref="DifficultyLevel"/> changes.</param>
/// <param name="runOnceImmediately">Whether the action provided in <paramref name="onChange"/> should be run once immediately.</param>
public void BindDifficultyLevelChanged(Action<ValueChangedEvent<DifficultyLevel>> onChange, bool runOnceImmediately = false) => currentDifficultyLevel.BindValueChanged(onChange, runOnceImmediately);

/// <summary>
/// Set the value of the <see cref="BeatmapSet"/> bindable.
/// </summary>
/// <param name="beatmapSet">The new value of the <see cref="BeatmapSet"/> bindable.</param>
public void SetCurrentBeatmapSet(BeatmapSet beatmapSet)
{
currentBeatmapSet.Value = beatmapSet;
}

/// <summary>
/// Set the value of the <see cref="DifficultyLevel"/> bindable.
/// </summary>
/// <param name="difficultyLevel">The new value of the <see cref="DifficultyLevel"/> bindable.</param>
public void SetCurrentDifficultyLevel(DifficultyLevel difficultyLevel)
{
currentDifficultyLevel.Value = difficultyLevel;
}
}
}
using System;
using maisim.Game.Beatmaps;
using osu.Framework.Bindables;
namespace maisim.Game.Graphics.UserInterface.Overlays
{
/// <summary>
/// A class that provide the bindable for the current <see cref="BeatmapSet"/> and <see cref="DifficultyLevel"/> of the game.
/// </summary>
public class CurrentWorkingBeatmap
{
/// <summary>
/// The bindable for the current <see cref="BeatmapSet"/>.
/// </summary>
private Bindable<BeatmapSet> currentBeatmapSet = new Bindable<BeatmapSet>();
/// <summary>
/// The bindable for the current <see cref="DifficultyLevel"/>.
/// </summary>
private Bindable<DifficultyLevel> currentDifficultyLevel = new Bindable<DifficultyLevel>();
/// <summary>
/// Get the current <see cref="BeatmapSet"/> of the game.
/// </summary>
public BeatmapSet BeatmapSet => currentBeatmapSet.Value;
/// <summary>
/// Get the current <see cref="DifficultyLevel"/> of the game.
/// </summary>
public DifficultyLevel DifficultyLevel => currentDifficultyLevel.Value;
/// <summary>
/// Bind <see cref="ValueChangedEvent{T}"/> of the <see cref="BeatmapSet"/> to the <see cref="BeatmapSet"/> bindable.
/// </summary>
/// <param name="onChange">The action to perform when <see cref="BeatmapSet"/> changes.</param>
/// <param name="runOnceImmediately">Whether the action provided in <paramref name="onChange"/> should be run once immediately.</param>
public void BindBeatmapSetChanged(Action<ValueChangedEvent<BeatmapSet>> onChange, bool runOnceImmediately = false) => currentBeatmapSet.BindValueChanged(onChange, runOnceImmediately);
/// <summary>
/// Bind <see cref="ValueChangedEvent{T}"/> of the <see cref="DifficultyLevel"/> to the <see cref="DifficultyLevel"/> bindable.
/// </summary>
/// <param name="onChange">The action to perform when <see cref="DifficultyLevel"/> changes.</param>
/// <param name="runOnceImmediately">Whether the action provided in <paramref name="onChange"/> should be run once immediately.</param>
public void BindDifficultyLevelChanged(Action<ValueChangedEvent<DifficultyLevel>> onChange, bool runOnceImmediately = false) => currentDifficultyLevel.BindValueChanged(onChange, runOnceImmediately);
/// <summary>
/// Set the value of the <see cref="BeatmapSet"/> bindable.
/// </summary>
/// <param name="beatmapSet">The new value of the <see cref="BeatmapSet"/> bindable.</param>
public void SetCurrentBeatmapSet(BeatmapSet beatmapSet)
{
currentBeatmapSet.Value = beatmapSet;
}
/// <summary>
/// Set the value of the <see cref="DifficultyLevel"/> bindable.
/// </summary>
/// <param name="difficultyLevel">The new value of the <see cref="DifficultyLevel"/> bindable.</param>
public void SetCurrentDifficultyLevel(DifficultyLevel difficultyLevel)
{
currentDifficultyLevel.Value = difficultyLevel;
}
}
}
16 changes: 8 additions & 8 deletions maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class BeatmapSetCard : CompositeDrawable
[Resolved]
private MaisimConfigManager gameConfig { get; set; }

private readonly BeatmapSet beatmapSet;
protected internal readonly BeatmapSet BeatmapSet;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the internal accessor here.

private MaisimSpriteText title;
private MaisimSpriteText artist;

Expand All @@ -33,7 +33,7 @@ public partial class BeatmapSetCard : CompositeDrawable

public BeatmapSetCard(BeatmapSet beatmapSet)
{
this.beatmapSet = beatmapSet;
BeatmapSet = beatmapSet;
}

[BackgroundDependencyLoader]
Expand Down Expand Up @@ -86,7 +86,7 @@ private void load(TextureStore textureStore)
Origin = Anchor.Centre,
Size = new Vector2(98, 98),
FillMode = FillMode.Fill,
Texture = textureStore.Get(beatmapSet.TrackMetadata.CoverPath)
Texture = textureStore.Get(BeatmapSet.TrackMetadata.CoverPath)
}
}
},
Expand Down Expand Up @@ -126,7 +126,7 @@ private void load(TextureStore textureStore)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.TitleUnicode : beatmapSet.TrackMetadata.Title,
Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.TitleUnicode : BeatmapSet.TrackMetadata.Title,
Colour = Color4.White
}
},
Expand All @@ -141,7 +141,7 @@ private void load(TextureStore textureStore)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.ArtistUnicode : beatmapSet.TrackMetadata.Artist,
Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.ArtistUnicode : BeatmapSet.TrackMetadata.Artist,
Colour = Color4Extensions.FromHex("#b8b8b8")
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@ private void load(TextureStore textureStore)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = BeatmapUtils.GetDifficultyRatingRange(beatmapSet).Item1.ToString(CultureInfo.CurrentCulture) + " - " + BeatmapUtils.GetDifficultyRatingRange(beatmapSet).Item2.ToString(CultureInfo.CurrentCulture),
Text = BeatmapUtils.GetDifficultyRatingRange(BeatmapSet).Item1.ToString(CultureInfo.CurrentCulture) + " - " + BeatmapUtils.GetDifficultyRatingRange(BeatmapSet).Item2.ToString(CultureInfo.CurrentCulture),
Colour = Color4.Black,
}
}
Expand Down Expand Up @@ -263,8 +263,8 @@ private void load(TextureStore textureStore)
protected override void Update()
{
base.Update();
title.Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.TitleUnicode : beatmapSet.TrackMetadata.Title;
artist.Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.ArtistUnicode : beatmapSet.TrackMetadata.Artist;
title.Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.TitleUnicode : BeatmapSet.TrackMetadata.Title;
artist.Text = gameConfig.Get<bool>(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.ArtistUnicode : BeatmapSet.TrackMetadata.Artist;
}

/// <summary>
Expand Down
Loading