mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Refactor hands for legibility (visual and code)
This commit is contained in:
parent
0d8a7246dd
commit
e8f5a8e3d6
@ -6,6 +6,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -14,6 +15,8 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
{
|
{
|
||||||
public class ToolbarClock : CompositeDrawable
|
public class ToolbarClock : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
private const float hand_thickness = 2.2f;
|
||||||
|
|
||||||
public ToolbarClock()
|
public ToolbarClock()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
@ -72,7 +75,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
private Drawable second;
|
private Drawable second;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Size = new Vector2(30);
|
Size = new Vector2(30);
|
||||||
|
|
||||||
@ -82,38 +85,94 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
hour = new Hand
|
hour = new LargeHand(0.3f),
|
||||||
{
|
minute = new LargeHand(0.45f),
|
||||||
Colour = Color4.Orange,
|
second = new SecondHand(),
|
||||||
Size = new Vector2(0.3f, 1.2f),
|
new CentreCircle
|
||||||
},
|
|
||||||
minute = new Hand
|
|
||||||
{
|
|
||||||
Colour = Color4.Green,
|
|
||||||
Size = new Vector2(0.45f, 1),
|
|
||||||
},
|
|
||||||
second = new Hand
|
|
||||||
{
|
|
||||||
Colour = Color4.Blue,
|
|
||||||
Size = new Vector2(0.48f, 0.5f),
|
|
||||||
},
|
|
||||||
new Circle
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = new Vector2(1.5f),
|
}
|
||||||
Colour = Color4.Black,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Hand : Circle
|
private class CentreCircle : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Hand()
|
public CentreCircle()
|
||||||
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(hand_thickness),
|
||||||
|
Colour = Color4.Black,
|
||||||
|
},
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(hand_thickness * 0.7f),
|
||||||
|
Colour = Color4.White,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SecondHand : CompositeDrawable
|
||||||
|
{
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Width = 0.54f;
|
||||||
|
|
||||||
|
Height = hand_thickness / 2;
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Custom;
|
||||||
|
|
||||||
|
OriginPosition = new Vector2(Height * 2, Height / 2);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Colour = colours.YellowDark,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LargeHand : CompositeDrawable
|
||||||
|
{
|
||||||
|
public LargeHand(float length)
|
||||||
|
{
|
||||||
|
Width = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.CentreLeft;
|
Origin = Anchor.CentreLeft;
|
||||||
|
|
||||||
|
Origin = Anchor.Custom;
|
||||||
|
OriginPosition = new Vector2(hand_thickness / 2); // offset x also, to ensure the centre of the line is centered on the face.
|
||||||
|
Height = hand_thickness;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Colour = colours.PurpleLight,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
BorderThickness = 0.5f,
|
||||||
|
BorderColour = colours.Purple,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +203,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
private abstract class ClockDisplay : CompositeDrawable
|
private abstract class ClockDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
private int lastSecond;
|
private int? lastSecond;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user