diff --git a/maisim/maisim.Game/Graphics/UserInterface/Overlays/CurrentWorkingBeatmap.cs b/maisim/maisim.Game/Graphics/UserInterface/Overlays/CurrentWorkingBeatmap.cs index 89ce04f7..065d4a06 100644 --- a/maisim/maisim.Game/Graphics/UserInterface/Overlays/CurrentWorkingBeatmap.cs +++ b/maisim/maisim.Game/Graphics/UserInterface/Overlays/CurrentWorkingBeatmap.cs @@ -1,64 +1,64 @@ -using System; -using maisim.Game.Beatmaps; -using osu.Framework.Bindables; - -namespace maisim.Game.Graphics.UserInterface.Overlays -{ - /// - /// A class that provide the bindable for the current and of the game. - /// - public class CurrentWorkingBeatmap - { - /// - /// The bindable for the current . - /// - private Bindable currentBeatmapSet = new Bindable(); - - /// - /// The bindable for the current . - /// - private Bindable currentDifficultyLevel = new Bindable(); - - /// - /// Get the current of the game. - /// - public BeatmapSet BeatmapSet => currentBeatmapSet.Value; - - /// - /// Get the current of the game. - /// - public DifficultyLevel DifficultyLevel => currentDifficultyLevel.Value; - - /// - /// Bind of the to the bindable. - /// - /// The action to perform when changes. - /// Whether the action provided in should be run once immediately. - public void BindBeatmapSetChanged(Action> onChange, bool runOnceImmediately = false) => currentBeatmapSet.BindValueChanged(onChange, runOnceImmediately); - - /// - /// Bind of the to the bindable. - /// - /// The action to perform when changes. - /// Whether the action provided in should be run once immediately. - public void BindDifficultyLevelChanged(Action> onChange, bool runOnceImmediately = false) => currentDifficultyLevel.BindValueChanged(onChange, runOnceImmediately); - - /// - /// Set the value of the bindable. - /// - /// The new value of the bindable. - public void SetCurrentBeatmapSet(BeatmapSet beatmapSet) - { - currentBeatmapSet.Value = beatmapSet; - } - - /// - /// Set the value of the bindable. - /// - /// The new value of the bindable. - public void SetCurrentDifficultyLevel(DifficultyLevel difficultyLevel) - { - currentDifficultyLevel.Value = difficultyLevel; - } - } -} +using System; +using maisim.Game.Beatmaps; +using osu.Framework.Bindables; + +namespace maisim.Game.Graphics.UserInterface.Overlays +{ + /// + /// A class that provide the bindable for the current and of the game. + /// + public class CurrentWorkingBeatmap + { + /// + /// The bindable for the current . + /// + private Bindable currentBeatmapSet = new Bindable(); + + /// + /// The bindable for the current . + /// + private Bindable currentDifficultyLevel = new Bindable(); + + /// + /// Get the current of the game. + /// + public BeatmapSet BeatmapSet => currentBeatmapSet.Value; + + /// + /// Get the current of the game. + /// + public DifficultyLevel DifficultyLevel => currentDifficultyLevel.Value; + + /// + /// Bind of the to the bindable. + /// + /// The action to perform when changes. + /// Whether the action provided in should be run once immediately. + public void BindBeatmapSetChanged(Action> onChange, bool runOnceImmediately = false) => currentBeatmapSet.BindValueChanged(onChange, runOnceImmediately); + + /// + /// Bind of the to the bindable. + /// + /// The action to perform when changes. + /// Whether the action provided in should be run once immediately. + public void BindDifficultyLevelChanged(Action> onChange, bool runOnceImmediately = false) => currentDifficultyLevel.BindValueChanged(onChange, runOnceImmediately); + + /// + /// Set the value of the bindable. + /// + /// The new value of the bindable. + public void SetCurrentBeatmapSet(BeatmapSet beatmapSet) + { + currentBeatmapSet.Value = beatmapSet; + } + + /// + /// Set the value of the bindable. + /// + /// The new value of the bindable. + public void SetCurrentDifficultyLevel(DifficultyLevel difficultyLevel) + { + currentDifficultyLevel.Value = difficultyLevel; + } + } +} diff --git a/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetCard.cs b/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetCard.cs index f0240491..d0e44384 100644 --- a/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetCard.cs +++ b/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetCard.cs @@ -24,7 +24,7 @@ public partial class BeatmapSetCard : CompositeDrawable [Resolved] private MaisimConfigManager gameConfig { get; set; } - private readonly BeatmapSet beatmapSet; + protected internal readonly BeatmapSet BeatmapSet; private MaisimSpriteText title; private MaisimSpriteText artist; @@ -33,7 +33,7 @@ public partial class BeatmapSetCard : CompositeDrawable public BeatmapSetCard(BeatmapSet beatmapSet) { - this.beatmapSet = beatmapSet; + BeatmapSet = beatmapSet; } [BackgroundDependencyLoader] @@ -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) } } }, @@ -126,7 +126,7 @@ private void load(TextureStore textureStore) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.TitleUnicode : beatmapSet.TrackMetadata.Title, + Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.TitleUnicode : BeatmapSet.TrackMetadata.Title, Colour = Color4.White } }, @@ -141,7 +141,7 @@ private void load(TextureStore textureStore) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.ArtistUnicode : beatmapSet.TrackMetadata.Artist, + Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.ArtistUnicode : BeatmapSet.TrackMetadata.Artist, Colour = Color4Extensions.FromHex("#b8b8b8") } } @@ -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, } } @@ -263,8 +263,8 @@ private void load(TextureStore textureStore) protected override void Update() { base.Update(); - title.Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.TitleUnicode : beatmapSet.TrackMetadata.Title; - artist.Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? beatmapSet.TrackMetadata.ArtistUnicode : beatmapSet.TrackMetadata.Artist; + title.Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.TitleUnicode : BeatmapSet.TrackMetadata.Title; + artist.Text = gameConfig.Get(MaisimSetting.UseUnicodeInfo) ? BeatmapSet.TrackMetadata.ArtistUnicode : BeatmapSet.TrackMetadata.Artist; } /// diff --git a/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetSelection.cs b/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetSelection.cs index 7ea15bf7..ad3d0d76 100644 --- a/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetSelection.cs +++ b/maisim/maisim.Game/Graphics/UserInterfaceV2/BeatmapSetSelection.cs @@ -1,59 +1,173 @@ -using maisim.Game.Graphics.UserInterface.Overlays; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osuTK; - -namespace maisim.Game.Graphics.UserInterfaceV2 -{ - public partial class BeatmapSetSelection : CompositeDrawable - { - [Resolved] - private CurrentWorkingBeatmap currentWorkingBeatmap { get; set; } - - [BackgroundDependencyLoader] - private void load() - { - // This container need to be wide equal to the screen width to prevent the scroll bar from being cut off. - Anchor = Anchor.TopLeft; - Origin = Anchor.TopLeft; - RelativeSizeAxes = Axes.Y; - Size = new Vector2(400, 1); - InternalChildren = new Drawable[] - { - new Box - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = MaisimColour.SongSelectionContainerColor, - Alpha = 0.5f - }, - new Container() - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - Size = new Vector2(1, 90), - CornerRadius = 10, - Masking = true, - BorderColour = MaisimColour.SongSelectionContainerBorderColor, - BorderThickness = 3, - Child = new Box() - { - RelativeSizeAxes = Axes.Both, - Colour = MaisimColour.SongSelectionContainerBorderColor, - Alpha = 0.5f, - } - }, - new BeatmapSetCard(currentWorkingBeatmap.BeatmapSet) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Scale = new Vector2(0.6f, 0.6f), - } - }; - } - } -} +using System.Collections.Generic; +using maisim.Game.Beatmaps; +using maisim.Game.Graphics.UserInterface.Overlays; +using maisim.Game.Utils; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osuTK; + +namespace maisim.Game.Graphics.UserInterfaceV2 +{ + public partial class BeatmapSetSelection : CompositeDrawable + { + [Resolved] + private CurrentWorkingBeatmap currentWorkingBeatmap { get; set; } + + [Resolved] + private MusicPlayer musicPlayer { get; set; } + + private List beatmapSetDrawables; + private Box topBox; + private Box bottomBox; + private Container dummyBox; + private Box backgroundBox; + private BasicScrollContainer scrollContainer; + + private void workingBeatmapChange(ValueChangedEvent beatmapSetEvent) + { + if (scrollContainer.IsDragged || scrollContainer.IsHovered) + musicPlayer.SeekTo(beatmapSetEvent.NewValue.PreviewTime); + } + + [BackgroundDependencyLoader] + private void load() + { + beatmapSetDrawables = new List(); + + // Add BeatmapSetCard to the container + foreach (TestUtil.AvailableTrackMetadata availableTrackMetadata in TestUtil.AVAILABLE_BEATMAP_SET_TRACK) + { + if (availableTrackMetadata != TestUtil.AvailableTrackMetadata.None) + { + BeatmapSet beatmapSet = new BeatmapSetTestFixture(availableTrackMetadata).BeatmapSet; + beatmapSetDrawables.Add(new BeatmapSetCard(beatmapSet) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(0.6f, 0.6f), + // Add a margin between each BeatmapSetCard + Margin = new MarginPadding() + { + Top = 10 + } + }); + } + } + + // This container need to be wide equal to the screen width to prevent the scroll bar from being cut off. + Anchor = Anchor.TopLeft; + Origin = Anchor.TopLeft; + RelativeSizeAxes = Axes.Y; + Position = new Vector2(120, 0); + Size = new Vector2(400, 1); + InternalChildren = new Drawable[] + { + backgroundBox = new Box + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = MaisimColour.SongSelectionContainerColor, + Alpha = 0.5f + }, + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + dummyBox = new Container() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Size = new Vector2(1, 90), + CornerRadius = 10, + Masking = true, + BorderColour = MaisimColour.SongSelectionContainerBorderColor, + BorderThickness = 3, + Child = new Box() + { + RelativeSizeAxes = Axes.Both, + Colour = MaisimColour.SongSelectionContainerBorderColor, + Alpha = 0.5f, + } + }, + scrollContainer = new BasicScrollContainer() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = true, + Child = new FillFlowContainer() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + topBox = new Box() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Size = new Vector2(1, 310), + Alpha = 0, + AlwaysPresent = true + }, + new FillFlowContainer() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = beatmapSetDrawables.ToArray() + }, + bottomBox = new Box() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Size = new Vector2(1, 320), + Alpha = 0, + AlwaysPresent = true + } + } + } + } + } + } + }; + + currentWorkingBeatmap.BindBeatmapSetChanged(workingBeatmapChange); + } + + protected override void LoadComplete() + { + topBox.Size = new Vector2(1,backgroundBox.ScreenSpaceDrawQuad.Size.Y / 2 - dummyBox.ScreenSpaceDrawQuad.Size.Y / 2 - 20); + bottomBox.Size = new Vector2(1,backgroundBox.ScreenSpaceDrawQuad.Size.Y / 2 - dummyBox.ScreenSpaceDrawQuad.Size.Y / 2 - 10); + + base.LoadComplete(); + } + + protected override void Update() + { + // If beatmapSetCard's position is in the middle of the screen, set the bindableBeatmapSet to the beatmapSetCard's beatmapSet + foreach (Drawable drawable in beatmapSetDrawables) + { + // Check that what beatmapSetCard is inside the dummyBox by using ScreenSpaceDrawQuad + if (drawable.ScreenSpaceDrawQuad.TopLeft.Y >= dummyBox.ScreenSpaceDrawQuad.TopLeft.Y && drawable.ScreenSpaceDrawQuad.BottomRight.Y <= dummyBox.ScreenSpaceDrawQuad.BottomRight.Y) + { + currentWorkingBeatmap.SetCurrentBeatmapSet(((BeatmapSetCard) drawable).BeatmapSet); + } + } + } + } +} diff --git a/maisim/maisim.Game/Screen/Gameplay/Playfield.cs b/maisim/maisim.Game/Screen/Gameplay/Playfield.cs index 0bc32d31..0d357832 100644 --- a/maisim/maisim.Game/Screen/Gameplay/Playfield.cs +++ b/maisim/maisim.Game/Screen/Gameplay/Playfield.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using maisim.Game.Gameplay.Notes; using maisim.Game.Graphics.Gameplay.Notes; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osuTK; namespace maisim.Game.Screen.Gameplay { diff --git a/maisim/maisim.Game/Screen/MaisimScreenStack.cs b/maisim/maisim.Game/Screen/MaisimScreenStack.cs index 723b7bb6..9569e19b 100644 --- a/maisim/maisim.Game/Screen/MaisimScreenStack.cs +++ b/maisim/maisim.Game/Screen/MaisimScreenStack.cs @@ -1,7 +1,6 @@ using maisim.Game.Graphics.Containers; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Screens; namespace maisim.Game.Screen diff --git a/maisim/maisim.Game/Screen/SongSelectionScreen.cs b/maisim/maisim.Game/Screen/SongSelectionScreen.cs index 815f3b4d..3868ff9b 100644 --- a/maisim/maisim.Game/Screen/SongSelectionScreen.cs +++ b/maisim/maisim.Game/Screen/SongSelectionScreen.cs @@ -67,7 +67,7 @@ private void load() Anchor = Anchor.BottomRight, Origin = Anchor.Centre, Size = new Vector2(100), - Position = new Vector2(-5,-5), + Position = new Vector2(-10,-10), Scale = new Vector2(0), Depth = 10, Child = new MaisimLogo diff --git a/maisim/maisim.Game/Utils/TestUtil.cs b/maisim/maisim.Game/Utils/TestUtil.cs index 35edee06..0621a49c 100644 --- a/maisim/maisim.Game/Utils/TestUtil.cs +++ b/maisim/maisim.Game/Utils/TestUtil.cs @@ -134,6 +134,7 @@ public enum AvailableTrackMetadata Source = "継母の連れ子が元カノだった" } }; + /// /// List of random name that can be use for testing. ///