mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Refactor into some kind of sanity
This commit is contained in:
parent
b80c421a29
commit
e8567414c6
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ProfileHeader),
|
||||
typeof(RankGraph),
|
||||
typeof(LineGraph),
|
||||
typeof(OverlayHeaderTabControl),
|
||||
typeof(TabControlOverlayHeader.OverlayHeaderTabControl),
|
||||
typeof(CentreHeaderContainer),
|
||||
typeof(BottomHeaderContainer),
|
||||
typeof(DetailHeaderContainer),
|
||||
|
@ -1,14 +1,39 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public abstract class BreadcrumbControlOverlayHeader : OverlayHeader
|
||||
{
|
||||
protected OverlayHeaderBreadcrumbControl TabControl;
|
||||
protected OverlayHeaderBreadcrumbControl BreadcrumbControl;
|
||||
|
||||
protected override TabControl<string> CreateControl() => TabControl = new OverlayHeaderBreadcrumbControl();
|
||||
protected override TabControl<string> CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl();
|
||||
|
||||
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
|
||||
{
|
||||
public OverlayHeaderBreadcrumbControl()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value);
|
||||
|
||||
private class ControlTabItem : BreadcrumbTabItem
|
||||
{
|
||||
protected override float ChevronSize => 8;
|
||||
|
||||
public ControlTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Font = Text.Font.With(size: 14);
|
||||
Chevron.Y = 3;
|
||||
Bar.Height = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ namespace osu.Game.Overlays.Changelog
|
||||
|
||||
public ChangelogHeader()
|
||||
{
|
||||
TabControl.AddItem(listing_string);
|
||||
TabControl.Current.ValueChanged += e =>
|
||||
BreadcrumbControl.AddItem(listing_string);
|
||||
BreadcrumbControl.Current.ValueChanged += e =>
|
||||
{
|
||||
if (e.NewValue == listing_string)
|
||||
ListingSelected?.Invoke();
|
||||
@ -46,7 +46,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
TabControl.AccentColour = colours.Violet;
|
||||
BreadcrumbControl.AccentColour = colours.Violet;
|
||||
TitleBackgroundColour = colours.GreyVioletDarker;
|
||||
ControlBackgroundColour = colours.GreyVioletDark;
|
||||
}
|
||||
@ -56,12 +56,12 @@ namespace osu.Game.Overlays.Changelog
|
||||
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
|
||||
{
|
||||
if (e.OldValue != null)
|
||||
TabControl.RemoveItem(e.OldValue.ToString());
|
||||
BreadcrumbControl.RemoveItem(e.OldValue.ToString());
|
||||
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
TabControl.AddItem(e.NewValue.ToString());
|
||||
TabControl.Current.Value = e.NewValue.ToString();
|
||||
BreadcrumbControl.AddItem(e.NewValue.ToString());
|
||||
BreadcrumbControl.Current.Value = e.NewValue.ToString();
|
||||
|
||||
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name);
|
||||
|
||||
@ -69,7 +69,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
}
|
||||
else
|
||||
{
|
||||
TabControl.Current.Value = listing_string;
|
||||
BreadcrumbControl.Current.Value = listing_string;
|
||||
Streams.Current.Value = null;
|
||||
title.Version = null;
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ namespace osu.Game.Overlays.News
|
||||
|
||||
public NewsHeader()
|
||||
{
|
||||
TabControl.AddItem(front_page_string);
|
||||
BreadcrumbControl.AddItem(front_page_string);
|
||||
|
||||
TabControl.Current.ValueChanged += e =>
|
||||
BreadcrumbControl.Current.ValueChanged += e =>
|
||||
{
|
||||
if (e.NewValue == front_page_string)
|
||||
ShowFrontPage?.Invoke();
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Overlays.News
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
TabControl.AccentColour = colours.Violet;
|
||||
BreadcrumbControl.AccentColour = colours.Violet;
|
||||
TitleBackgroundColour = colours.GreyVioletDarker;
|
||||
ControlBackgroundColour = colours.GreyVioletDark;
|
||||
}
|
||||
@ -46,18 +46,18 @@ namespace osu.Game.Overlays.News
|
||||
private void showPost(ValueChangedEvent<string> e)
|
||||
{
|
||||
if (e.OldValue != null)
|
||||
TabControl.RemoveItem(e.OldValue);
|
||||
BreadcrumbControl.RemoveItem(e.OldValue);
|
||||
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
TabControl.AddItem(e.NewValue);
|
||||
TabControl.Current.Value = e.NewValue;
|
||||
BreadcrumbControl.AddItem(e.NewValue);
|
||||
BreadcrumbControl.Current.Value = e.NewValue;
|
||||
|
||||
title.IsReadingPost = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TabControl.Current.Value = front_page_string;
|
||||
BreadcrumbControl.Current.Value = front_page_string;
|
||||
title.IsReadingPost = false;
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
CreateControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN })
|
||||
CreateTabControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN })
|
||||
}
|
||||
},
|
||||
CreateContent()
|
||||
@ -99,6 +99,6 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected abstract ScreenTitle CreateTitle();
|
||||
|
||||
protected abstract TabControl<string> CreateControl();
|
||||
protected abstract TabControl<string> CreateTabControl();
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
|
||||
{
|
||||
public OverlayHeaderBreadcrumbControl()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value);
|
||||
|
||||
private class ControlTabItem : BreadcrumbTabItem
|
||||
{
|
||||
protected override float ChevronSize => 8;
|
||||
|
||||
public ControlTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Font = Text.Font.With(size: 14);
|
||||
Chevron.Y = 3;
|
||||
Bar.Height = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class OverlayHeaderTabControl : OverlayTabControl<string>
|
||||
{
|
||||
public OverlayHeaderTabControl()
|
||||
{
|
||||
BarHeight = 1;
|
||||
RelativeSizeAxes = Axes.None;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
Height = 35;
|
||||
}
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new OverlayHeaderTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour,
|
||||
};
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
};
|
||||
|
||||
private class OverlayHeaderTabItem : OverlayTabItem
|
||||
{
|
||||
public OverlayHeaderTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Text = value;
|
||||
Text.Font = OsuFont.GetFont(size: 14);
|
||||
Bar.ExpandedSize = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -9,6 +13,43 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
protected OverlayHeaderTabControl TabControl;
|
||||
|
||||
protected override TabControl<string> CreateControl() => TabControl = new OverlayHeaderTabControl();
|
||||
protected override TabControl<string> CreateTabControl() => TabControl = new OverlayHeaderTabControl();
|
||||
|
||||
public class OverlayHeaderTabControl : OverlayTabControl<string>
|
||||
{
|
||||
public OverlayHeaderTabControl()
|
||||
{
|
||||
BarHeight = 1;
|
||||
RelativeSizeAxes = Axes.None;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
Height = 35;
|
||||
}
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new OverlayHeaderTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour,
|
||||
};
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
};
|
||||
|
||||
private class OverlayHeaderTabItem : OverlayTabItem
|
||||
{
|
||||
public OverlayHeaderTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Text = value;
|
||||
Text.Font = OsuFont.GetFont(size: 14);
|
||||
Bar.ExpandedSize = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user