mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 18:27:26 +08:00
Initial refactoring.
This commit is contained in:
parent
9bdf462dd1
commit
37944bb04e
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -17,26 +15,24 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays.Music
|
||||||
{
|
{
|
||||||
public class PlaylistController : OverlayContainer
|
public class PlaylistController : OverlayContainer
|
||||||
{
|
{
|
||||||
private const float transition_duration = 800;
|
private const float transition_duration = 600;
|
||||||
|
|
||||||
|
private const float playlist_height = 510;
|
||||||
|
|
||||||
private readonly Box bg;
|
private readonly Box bg;
|
||||||
private readonly FilterControl filter;
|
private readonly FilterControl filter;
|
||||||
private readonly Playlist list;
|
private readonly Playlist list;
|
||||||
|
|
||||||
public BeatmapSetInfo[] List
|
public BeatmapSetInfo[] List => list.Sets;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return list.Sets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action<BeatmapSetInfo,int> OnSelect
|
public Action<BeatmapSetInfo, int> OnSelect
|
||||||
{
|
{
|
||||||
get { return list.OnSelect; }
|
get { return list.OnSelect; }
|
||||||
set { list.OnSelect = value; }
|
set { list.OnSelect = value; }
|
||||||
@ -100,8 +96,9 @@ namespace osu.Game.Overlays
|
|||||||
filter.Search.HoldFocus = true;
|
filter.Search.HoldFocus = true;
|
||||||
filter.Search.TriggerFocus();
|
filter.Search.TriggerFocus();
|
||||||
|
|
||||||
list.ScrollContainer.ScrollDraggerVisible = true;
|
|
||||||
ResizeTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint);
|
ResizeTo(new Vector2(1, playlist_height), transition_duration, EasingTypes.OutQuint);
|
||||||
|
FadeIn(transition_duration, EasingTypes.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
@ -109,8 +106,8 @@ namespace osu.Game.Overlays
|
|||||||
filter.Search.HoldFocus = false;
|
filter.Search.HoldFocus = false;
|
||||||
filter.Search.TriggerFocusLost();
|
filter.Search.TriggerFocusLost();
|
||||||
|
|
||||||
list.ScrollContainer.ScrollDraggerVisible = false;
|
ResizeTo(new Vector2(1, 0), transition_duration, EasingTypes.OutQuint);
|
||||||
ResizeTo(new Vector2(1f, 0f), transition_duration, EasingTypes.OutQuint);
|
FadeOut(transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FilterControl : Container
|
private class FilterControl : Container
|
||||||
@ -236,7 +233,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
newItems.Add(new PlaylistItem(value[i], i)
|
newItems.Add(new PlaylistItem(value[i], i)
|
||||||
{
|
{
|
||||||
OnSelect = OnSelect,
|
OnSelect = itemSelected,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,22 +241,9 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exposed so PlaylistController can hide the scroll dragger when hidden
|
private void itemSelected(BeatmapSetInfo arg1, int arg2) => OnSelect?.Invoke(arg1, arg2);
|
||||||
// because the scroller can be seen when scrolled to the bottom and PlaylistController is closed
|
|
||||||
public readonly ScrollContainer ScrollContainer;
|
|
||||||
|
|
||||||
private Action<BeatmapSetInfo,int> onSelect;
|
public Action<BeatmapSetInfo, int> OnSelect;
|
||||||
public Action<BeatmapSetInfo,int> OnSelect
|
|
||||||
{
|
|
||||||
get { return onSelect; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
onSelect = value;
|
|
||||||
|
|
||||||
foreach (PlaylistItem s in items.Children)
|
|
||||||
s.OnSelect = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BeatmapSetInfo current;
|
private BeatmapSetInfo current;
|
||||||
public BeatmapSetInfo Current
|
public BeatmapSetInfo Current
|
||||||
@ -279,7 +263,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
ScrollContainer = new ScrollContainer
|
new ScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -304,7 +288,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public readonly int Index;
|
public readonly int Index;
|
||||||
public readonly BeatmapSetInfo RepresentedSet;
|
public readonly BeatmapSetInfo RepresentedSet;
|
||||||
public Action<BeatmapSetInfo,int> OnSelect;
|
public Action<BeatmapSetInfo, int> OnSelect;
|
||||||
|
|
||||||
private bool current;
|
private bool current;
|
||||||
public bool Current
|
public bool Current
|
@ -24,13 +24,14 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Overlays.Music;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class MusicController : FocusedOverlayContainer
|
public class MusicController : FocusedOverlayContainer
|
||||||
{
|
{
|
||||||
private const float player_height = 130;
|
private const float player_height = 130;
|
||||||
private const float playlist_height = 510;
|
|
||||||
private Drawable currentBackground;
|
private Drawable currentBackground;
|
||||||
private DragBar progress;
|
private DragBar progress;
|
||||||
private Button playButton;
|
private Button playButton;
|
||||||
@ -58,13 +59,9 @@ namespace osu.Game.Overlays
|
|||||||
public MusicController()
|
public MusicController()
|
||||||
{
|
{
|
||||||
Width = 400;
|
Width = 400;
|
||||||
Height = player_height + playlist_height;
|
|
||||||
|
|
||||||
Margin = new MarginPadding(10);
|
Margin = new MarginPadding(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool InternalContains(Vector2 screenSpacePos) => playlist.State == Visibility.Visible ? dragContainer.Contains(screenSpacePos) : playerContainer.Contains(screenSpacePos);
|
|
||||||
|
|
||||||
protected override bool OnDragStart(InputState state) => true;
|
protected override bool OnDragStart(InputState state) => true;
|
||||||
|
|
||||||
protected override bool OnDrag(InputState state)
|
protected override bool OnDrag(InputState state)
|
||||||
@ -97,13 +94,14 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
playlist = new PlaylistController
|
playlist = new PlaylistController
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.X,
|
||||||
Padding = new MarginPadding { Top = player_height + 10 },
|
Y = player_height + 10,
|
||||||
//todo: this is the logic I expect, but maybe not others
|
//todo: this is the logic I expect, but maybe not others
|
||||||
OnSelect = (set, index) =>
|
OnSelect = (set, index) =>
|
||||||
{
|
{
|
||||||
@ -230,7 +228,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
currentBackground = new MusicControllerBackground();
|
currentBackground = new MusicControllerBackground();
|
||||||
playerContainer.Add(currentBackground);
|
playerContainer.Add(currentBackground);
|
||||||
playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible? activeColour : Color4.White, transition_length, EasingTypes.OutQuint);
|
playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible? activeColour : Color4.White, 200, EasingTypes.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -242,6 +240,12 @@ namespace osu.Game.Overlays
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
Height = dragContainer.Height;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
@ -421,7 +421,7 @@
|
|||||||
<Compile Include="Screens\Select\BeatmapDetailArea.cs" />
|
<Compile Include="Screens\Select\BeatmapDetailArea.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\OsuTabControlCheckbox.cs" />
|
<Compile Include="Graphics\UserInterface\OsuTabControlCheckbox.cs" />
|
||||||
<Compile Include="Screens\Select\BeatmapDetailAreaTabControl.cs" />
|
<Compile Include="Screens\Select\BeatmapDetailAreaTabControl.cs" />
|
||||||
<Compile Include="Overlays\PlaylistController.cs" />
|
<Compile Include="Overlays\Music\PlaylistController.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user