mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Merge branch 'master' into profile
This commit is contained in:
@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(0,0,0,0)
|
||||
Colour = new Color4(0, 0, 0, 0)
|
||||
},
|
||||
bar = new Box
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument");
|
||||
|
||||
List<KeyValuePair<string, T>> items = new List<KeyValuePair<string, T>>();
|
||||
foreach(var val in (T[])Enum.GetValues(typeof(T)))
|
||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||
{
|
||||
var field = typeof(T).GetField(Enum.GetName(typeof(T), val));
|
||||
items.Add(
|
||||
|
105
osu.Game/Graphics/UserInterface/PageTabControl.cs
Normal file
105
osu.Game/Graphics/UserInterface/PageTabControl.cs
Normal file
@ -0,0 +1,105 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class PageTabControl<T> : OsuTabControl<T>
|
||||
{
|
||||
protected override TabItem<T> CreateTabItem(T value) => new PageTabItem(value);
|
||||
|
||||
public PageTabControl()
|
||||
{
|
||||
Height = 30;
|
||||
}
|
||||
|
||||
private class PageTabItem : TabItem<T>
|
||||
{
|
||||
private const float transition_duration = 100;
|
||||
|
||||
private readonly Box box;
|
||||
|
||||
public override bool Active
|
||||
{
|
||||
get { return base.Active; }
|
||||
set
|
||||
{
|
||||
if (Active == value) return;
|
||||
|
||||
if (value)
|
||||
slideActive();
|
||||
else
|
||||
slideInactive();
|
||||
base.Active = value;
|
||||
}
|
||||
}
|
||||
|
||||
public PageTabItem(T value) : base(value)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding { Top = 8, Bottom = 8 },
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = (value as Enum).GetDescription() ?? value.ToString(),
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
box = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 5,
|
||||
Scale = new Vector2(1f, 0f),
|
||||
Colour = Color4.White,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
box.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
slideActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
slideInactive();
|
||||
}
|
||||
|
||||
private void slideActive()
|
||||
{
|
||||
box.ScaleTo(new Vector2(1f), transition_duration);
|
||||
}
|
||||
|
||||
private void slideInactive()
|
||||
{
|
||||
box.ScaleTo(new Vector2(1f, 0f), transition_duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -90,7 +90,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Offset = new Vector2(2, 0),
|
||||
Radius = 2,
|
||||
},
|
||||
Children = new [] {
|
||||
Children = new[] {
|
||||
IconLayer = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Offset = new Vector2(2, 0),
|
||||
Radius = 2,
|
||||
},
|
||||
Children = new [] {
|
||||
Children = new[] {
|
||||
TextLayer = new Box
|
||||
{
|
||||
Origin = Anchor.TopLeft,
|
||||
|
Reference in New Issue
Block a user