Migrate to new anchor system without x/y reversal.

This commit is contained in:
Tom94
2016-11-14 17:22:20 +01:00
parent 63f0a01888
commit c860eb25f9
7 changed files with 26 additions and 21 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.GameModes.Play.Taiko;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -37,7 +38,7 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
TextSize = 40, TextSize = 40,
Count = 0, Count = 0,
Position = new Vector2(20, 20), Margin = new MarginPadding(20),
}; };
Add(score); Add(score);
@ -45,8 +46,8 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(10, 10), Margin = new MarginPadding(10),
InnerCountPosition = new Vector2(10, 10), InnerCountMargin = new MarginPadding(10),
Count = 0, Count = 0,
TextSize = 40, TextSize = 40,
}; };
@ -86,7 +87,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Position = new Vector2(20, 60), Position = new Vector2(-20, 60),
}; };
Add(accuracyCombo); Add(accuracyCombo);
@ -94,7 +95,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 160), Position = new Vector2(20, -160),
Count = 5, Count = 5,
}; };
Add(stars); Add(stars);
@ -103,7 +104,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 190), Position = new Vector2(20, -190),
Text = stars.Count.ToString("0.00"), Text = stars.Count.ToString("0.00"),
}; };
Add(starsLabel); Add(starsLabel);

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.GameModes.Play.Osu namespace osu.Game.GameModes.Play.Osu
{ {
@ -22,15 +23,15 @@ namespace osu.Game.GameModes.Play.Osu
protected virtual float PopOutSmallScale => 1.1f; protected virtual float PopOutSmallScale => 1.1f;
protected virtual bool CanPopOutWhileRolling => false; protected virtual bool CanPopOutWhileRolling => false;
public Vector2 InnerCountPosition public MarginPadding InnerCountMargin
{ {
get get
{ {
return DisplayedCountSpriteText.Position; return DisplayedCountSpriteText.Margin;
} }
set set
{ {
DisplayedCountSpriteText.Position = value; DisplayedCountSpriteText.Margin = value;
} }
} }

View File

@ -11,6 +11,7 @@ using osu.Game.Graphics.UserInterface;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
using osu.Game.Beatmaps.Objects; using osu.Game.Beatmaps.Objects;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.GameModes.Play.Osu namespace osu.Game.GameModes.Play.Osu
{ {
@ -42,7 +43,7 @@ namespace osu.Game.GameModes.Play.Osu
FadeTime = 50, FadeTime = 50,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Position = new Vector2(10), Margin = new MarginPadding(10),
Counters = new KeyCounter[] Counters = new KeyCounter[]
{ {
new KeyCounterKeyboard(@"Z", Key.Z), new KeyCounterKeyboard(@"Z", Key.Z),

View File

@ -7,6 +7,7 @@ using osu.Framework.Input;
using osu.Framework.Threading; using osu.Framework.Threading;
using OpenTK; using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Graphics.UserInterface.Volume namespace osu.Game.Graphics.UserInterface.Volume
{ {
@ -40,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Position = new Vector2(10, 30), Margin = new MarginPadding { Left = 10, Right = 10, Top = 30, Bottom = 30 },
Spacing = new Vector2(15, 0), Spacing = new Vector2(15, 0),
}); });
} }

View File

@ -22,12 +22,13 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class MusicController : OverlayContainer public class MusicController : OverlayContainer
{ {
private static readonly Vector2 start_position = new Vector2(10, 60); private static readonly Vector2 start_position = new Vector2(0, 50);
private MusicControllerBackground backgroundSprite; private MusicControllerBackground backgroundSprite;
private DragBar progress; private DragBar progress;
@ -63,6 +64,8 @@ namespace osu.Game.Overlays
Anchor = Anchor.TopRight;//placeholder Anchor = Anchor.TopRight;//placeholder
Origin = Anchor.TopRight; Origin = Anchor.TopRight;
Position = start_position; Position = start_position;
Margin = new MarginPadding(10);
Children = new Drawable[] Children = new Drawable[]
{ {
title = new SpriteText title = new SpriteText
@ -90,7 +93,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(0, 30), Position = new Vector2(0, -30),
Action = () => Action = () =>
{ {
if (current?.Track == null) return; if (current?.Track == null) return;
@ -115,7 +118,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(-30, 30), Position = new Vector2(-30, -30),
Action = prev, Action = prev,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -133,7 +136,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(30, 30), Position = new Vector2(30, -30),
Action = next, Action = next,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -151,7 +154,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Position = new Vector2(20, 30), Position = new Vector2(20, -30),
Children = new Drawable[] Children = new Drawable[]
{ {
listButton = new TextAwesome listButton = new TextAwesome
@ -180,9 +183,7 @@ namespace osu.Game.Overlays
{ {
Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value);
if ((Anchor & Anchor.x2) > 0) // Diminish the drag distance as we go further to simulate "rubber band" feeling.
change.X = -change.X;
change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; change *= (float)Math.Pow(change.Length, 0.7f) / change.Length;
MoveTo(start_position + change); MoveTo(start_position + change);

View File

@ -98,7 +98,7 @@ namespace osu.Game.Overlays
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(5, -5), Position = new Vector2(5, 5),
Alpha = 0, Alpha = 0,
Children = new[] Children = new[]
{ {