1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Initial refactoring.

This commit is contained in:
Dean Herbert 2017-05-01 13:01:08 +09:00
parent 9bdf462dd1
commit 37944bb04e
3 changed files with 32 additions and 44 deletions

View File

@ -3,8 +3,6 @@
using System;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -17,26 +15,24 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Select;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Overlays
namespace osu.Game.Overlays.Music
{
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 FilterControl filter;
private readonly Playlist list;
public BeatmapSetInfo[] List
{
get
{
return list.Sets;
}
}
public BeatmapSetInfo[] List => list.Sets;
public Action<BeatmapSetInfo,int> OnSelect
public Action<BeatmapSetInfo, int> OnSelect
{
get { return list.OnSelect; }
set { list.OnSelect = value; }
@ -100,8 +96,9 @@ namespace osu.Game.Overlays
filter.Search.HoldFocus = true;
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()
@ -109,8 +106,8 @@ namespace osu.Game.Overlays
filter.Search.HoldFocus = false;
filter.Search.TriggerFocusLost();
list.ScrollContainer.ScrollDraggerVisible = false;
ResizeTo(new Vector2(1f, 0f), transition_duration, EasingTypes.OutQuint);
ResizeTo(new Vector2(1, 0), transition_duration, EasingTypes.OutQuint);
FadeOut(transition_duration);
}
private class FilterControl : Container
@ -236,7 +233,7 @@ namespace osu.Game.Overlays
{
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
// because the scroller can be seen when scrolled to the bottom and PlaylistController is closed
public readonly ScrollContainer ScrollContainer;
private void itemSelected(BeatmapSetInfo arg1, int arg2) => OnSelect?.Invoke(arg1, arg2);
private Action<BeatmapSetInfo,int> onSelect;
public Action<BeatmapSetInfo,int> OnSelect
{
get { return onSelect; }
set
{
onSelect = value;
foreach (PlaylistItem s in items.Children)
s.OnSelect = value;
}
}
public Action<BeatmapSetInfo, int> OnSelect;
private BeatmapSetInfo current;
public BeatmapSetInfo Current
@ -279,7 +263,7 @@ namespace osu.Game.Overlays
{
Children = new Drawable[]
{
ScrollContainer = new ScrollContainer
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
@ -304,7 +288,7 @@ namespace osu.Game.Overlays
public readonly int Index;
public readonly BeatmapSetInfo RepresentedSet;
public Action<BeatmapSetInfo,int> OnSelect;
public Action<BeatmapSetInfo, int> OnSelect;
private bool current;
public bool Current

View File

@ -24,13 +24,14 @@ using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using System.Linq;
using osu.Game.Overlays.Music;
namespace osu.Game.Overlays
{
public class MusicController : FocusedOverlayContainer
{
private const float player_height = 130;
private const float playlist_height = 510;
private Drawable currentBackground;
private DragBar progress;
private Button playButton;
@ -58,13 +59,9 @@ namespace osu.Game.Overlays
public MusicController()
{
Width = 400;
Height = player_height + playlist_height;
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 OnDrag(InputState state)
@ -97,13 +94,14 @@ namespace osu.Game.Overlays
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
playlist = new PlaylistController
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = player_height + 10 },
RelativeSizeAxes = Axes.X,
Y = player_height + 10,
//todo: this is the logic I expect, but maybe not others
OnSelect = (set, index) =>
{
@ -230,7 +228,7 @@ namespace osu.Game.Overlays
currentBackground = new MusicControllerBackground();
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()
@ -242,6 +240,12 @@ namespace osu.Game.Overlays
base.LoadComplete();
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
Height = dragContainer.Height;
}
protected override void Update()
{
base.Update();

View File

@ -421,7 +421,7 @@
<Compile Include="Screens\Select\BeatmapDetailArea.cs" />
<Compile Include="Graphics\UserInterface\OsuTabControlCheckbox.cs" />
<Compile Include="Screens\Select\BeatmapDetailAreaTabControl.cs" />
<Compile Include="Overlays\PlaylistController.cs" />
<Compile Include="Overlays\Music\PlaylistController.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">