Move definition of MusicController's position out of itself.

This commit is contained in:
Dean Herbert 2017-01-30 22:00:23 +09:00
parent 578b33dc64
commit cbd6fe3f36
3 changed files with 120 additions and 109 deletions

View File

@ -21,6 +21,7 @@ using osu.Game.Modes;
using osu.Game.Overlays.Toolbar; using osu.Game.Overlays.Toolbar;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using OpenTK;
namespace osu.Game namespace osu.Game
{ {
@ -101,7 +102,11 @@ namespace osu.Game
//overlay elements //overlay elements
(chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add); (chat = new ChatOverlay { Depth = 0 }).Preload(this, overlayContent.Add);
(options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add); (options = new OptionsOverlay { Depth = -1 }).Preload(this, overlayContent.Add);
(musicController = new MusicController() { Depth = -3 }).Preload(this, overlayContent.Add); (musicController = new MusicController()
{
Depth = -3,
Position = new Vector2(0, Toolbar.HEIGHT),
}).Preload(this, overlayContent.Add);
Dependencies.Cache(options); Dependencies.Cache(options);
Dependencies.Cache(musicController); Dependencies.Cache(musicController);

View File

@ -28,8 +28,6 @@ namespace osu.Game.Overlays
{ {
public class MusicController : OverlayContainer public class MusicController : OverlayContainer
{ {
private static readonly Vector2 start_position = new Vector2(0, 50);
private MusicControllerBackground backgroundSprite; private MusicControllerBackground backgroundSprite;
private DragBar progress; private DragBar progress;
private TextAwesome playButton, listButton; private TextAwesome playButton, listButton;
@ -47,22 +45,15 @@ namespace osu.Game.Overlays
private BeatmapDatabase beatmaps; private BeatmapDatabase beatmaps;
private BaseGame game; private BaseGame game;
private Container dragContainer;
public MusicController() public MusicController()
{ {
Width = 400; Width = 400;
Height = 130; Height = 130;
CornerRadius = 5;
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(40),
Radius = 5,
};
Masking = true;
Anchor = Anchor.TopRight;//placeholder Anchor = Anchor.TopRight;//placeholder
Origin = Anchor.TopRight; Origin = Anchor.TopRight;
Position = start_position;
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
} }
@ -75,13 +66,13 @@ namespace osu.Game.Overlays
// Diminish the drag distance as we go further to simulate "rubber band" feeling. // Diminish the drag distance as we go further to simulate "rubber band" feeling.
change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; change *= (float)Math.Pow(change.Length, 0.7f) / change.Length;
MoveTo(start_position + change); dragContainer.MoveTo(change);
return base.OnDrag(state); return base.OnDrag(state);
} }
protected override bool OnDragEnd(InputState state) protected override bool OnDragEnd(InputState state)
{ {
MoveTo(start_position, 800, EasingTypes.OutElastic); dragContainer.MoveTo(Vector2.Zero, 800, EasingTypes.OutElastic);
return base.OnDragEnd(state); return base.OnDragEnd(state);
} }
@ -91,6 +82,19 @@ namespace osu.Game.Overlays
{ {
unicodeString = config.GetUnicodeString; unicodeString = config.GetUnicodeString;
Children = new Drawable[]
{
dragContainer = new Container
{
Masking = true,
CornerRadius = 5,
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(40),
Radius = 5,
},
RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
title = new SpriteText title = new SpriteText
@ -199,6 +203,8 @@ namespace osu.Game.Overlays
Colour = colours.Yellow, Colour = colours.Yellow,
SeekRequested = seek SeekRequested = seek
} }
}
}
}; };
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
@ -210,7 +216,7 @@ namespace osu.Game.Overlays
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>(); playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
backgroundSprite = new MusicControllerBackground(); backgroundSprite = new MusicControllerBackground();
AddInternal(backgroundSprite); dragContainer.Add(backgroundSprite);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -333,7 +339,7 @@ namespace osu.Game.Overlays
(newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
{ {
Add(newBackground); dragContainer.Add(newBackground);
switch (direction) switch (direction)
{ {

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
public class Toolbar : OverlayContainer public class Toolbar : OverlayContainer
{ {
private const float height = 50; public const float HEIGHT = 50;
public Action OnHome; public Action OnHome;
public Action<PlayMode> OnPlayModeChange; public Action<PlayMode> OnPlayModeChange;
@ -120,7 +120,7 @@ namespace osu.Game.Overlays.Toolbar
}; };
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Size = new Vector2(1, height); Size = new Vector2(1, HEIGHT);
} }
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);