1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 01:07:25 +08:00

Merge pull request #172 from Tom94/better-anchors

Better anchors
This commit is contained in:
Dean Herbert 2016-11-15 14:48:21 +09:00 committed by GitHub
commit ff20053e79
9 changed files with 35 additions and 24 deletions

@ -1 +1 @@
Subproject commit 87a5cd4ce48d6370b8e392378289825f4b4a2039
Subproject commit e5ad12e4aff8b638ee9d7b8a5542a85fab054ffa

View File

@ -20,6 +20,7 @@ using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Desktop.VisualTests.Tests
{
@ -43,7 +44,7 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.TopRight,
TextSize = 40,
Count = 0,
Position = new Vector2(20, 20),
Margin = new MarginPadding(20),
};
Add(score);
@ -51,8 +52,8 @@ namespace osu.Desktop.VisualTests.Tests
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(10, 10),
InnerCountPosition = new Vector2(10, 10),
Margin = new MarginPadding(10),
InnerCountMargin = new MarginPadding(10),
Count = 0,
TextSize = 40,
};
@ -92,7 +93,7 @@ namespace osu.Desktop.VisualTests.Tests
{
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Position = new Vector2(20, 60),
Position = new Vector2(-20, 60),
};
Add(accuracyCombo);
@ -100,7 +101,7 @@ namespace osu.Desktop.VisualTests.Tests
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 160),
Position = new Vector2(20, -160),
Count = 5,
};
Add(stars);
@ -109,7 +110,7 @@ namespace osu.Desktop.VisualTests.Tests
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 190),
Position = new Vector2(20, -190),
Text = stars.Count.ToString("0.00"),
};
Add(starsLabel);

View File

@ -3,6 +3,7 @@
using osu.Game.Modes.UI;
using OpenTK;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Modes.Osu.UI
{
@ -16,15 +17,15 @@ namespace osu.Game.Modes.Osu.UI
protected virtual float PopOutSmallScale => 1.1f;
protected virtual bool CanPopOutWhileRolling => false;
public Vector2 InnerCountPosition
public MarginPadding InnerCountMargin
{
get
{
return DisplayedCountSpriteText.Position;
return DisplayedCountSpriteText.Margin;
}
set
{
DisplayedCountSpriteText.Position = value;
DisplayedCountSpriteText.Margin = value;
}
}

View File

@ -6,6 +6,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Modes.UI;
using OpenTK;
using OpenTK.Input;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Modes.Osu.UI
{
@ -37,7 +38,7 @@ namespace osu.Game.Modes.Osu.UI
FadeTime = 50,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10),
Margin = new MarginPadding(10),
Counters = new KeyCounter[]
{
new KeyCounterKeyboard(@"Z", Key.Z),

View File

@ -7,6 +7,7 @@ using osu.Framework.Input;
using osu.Framework.Threading;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Graphics.UserInterface.Volume
{
@ -40,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
AutoSizeAxes = Axes.Both,
Anchor = 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),
});
}

View File

@ -145,7 +145,7 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
MoveToY(-DrawSize.Y, transition_length, EasingTypes.InQuint);
MoveToY(DrawSize.Y, transition_length, EasingTypes.InQuint);
FadeOut(transition_length, EasingTypes.InQuint);
}
}

View File

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

View File

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

View File

@ -98,8 +98,6 @@ namespace osu.Game.Screens.Menu
}
};
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), wedge_width, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
@ -113,6 +111,14 @@ namespace osu.Game.Screens.Menu
buttonFlow.Add(buttonsTopLevel);
}
protected override void LoadComplete()
{
base.LoadComplete();
// osuLogo.SizeForFlow relies on loading to be complete.
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
switch (args.Key)