1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 01:03:21 +08:00

Fix filter controls having margin when no controls given, add DisplayStyleControl to social, misc cleanups

This commit is contained in:
DrabWeb 2017-05-26 01:32:20 -03:00
parent 63313045d9
commit 2d3995b85c
5 changed files with 58 additions and 28 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Browse
protected abstract Color4 BackgroundColour { get; }
protected abstract T DefaultTab { get; }
protected virtual Drawable CreateControls() => new Container(); //todo: naming
protected virtual Drawable CreateControls() => null; //todo: naming
public BrowseFilterControl()
{
@ -34,6 +34,8 @@ namespace osu.Game.Overlays.Browse
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
var controls = CreateControls();
Container controlsContainer;
Children = new Drawable[]
{
new Box
@ -60,15 +62,11 @@ namespace osu.Game.Overlays.Browse
{
RelativeSizeAxes = Axes.X,
},
new Container
controlsContainer = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = padding }, //todo: margin is still applied without any controls
Children = new[]
{
CreateControls(),
},
Margin = new MarginPadding { Top = controls != null ? padding : 0 },
},
Tabs = new PageTabControl<T>
{
@ -84,6 +82,7 @@ namespace osu.Game.Overlays.Browse
},
};
if (controls != null) controlsContainer.Children = new[] { controls };
Tabs.Current.Value = DefaultTab;
Tabs.Current.TriggerChange();
}

View File

@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Browse
}
//todo: naming
//todo: crash when pressing tab
public abstract class BrowseOverlay<T,U> : BrowseOverlay
{
private readonly Container scrollContainer;

View File

@ -1,6 +1,7 @@
// 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.ComponentModel;
using OpenTK.Graphics;
using osu.Game.Graphics;
using osu.Game.Overlays.Browse;
@ -12,4 +13,15 @@ namespace osu.Game.Overlays.Social
protected override Color4 BackgroundColour => OsuColour.FromHex(@"47253a");
protected override SocialSortCriteria DefaultTab => SocialSortCriteria.Name;
}
public enum SocialSortCriteria
{
Name,
Rank,
Location,
[Description("Time Zone")]
TimeZone,
[Description("World Map")]
WorldMap,
}
}

View File

@ -8,6 +8,7 @@ using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using System.ComponentModel;
namespace osu.Game.Overlays.Social
{
@ -48,4 +49,16 @@ namespace osu.Game.Overlays.Social
browser.Colour = colours.Pink;
}
}
public enum SocialTab
{
[Description("Online Players")]
OnlinePlayers,
[Description("Online Friends")]
OnlineFriends,
[Description("Online Team Members")]
OnlineTeamMembers,
[Description("Chat Channels")]
ChatChannels,
}
}

View File

@ -3,10 +3,13 @@
using System.ComponentModel;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Overlays.Browse;
using osu.Game.Overlays.Social;
using Container = osu.Framework.Graphics.Containers.Container;
namespace osu.Game.Overlays
{
public class SocialOverlay : BrowseOverlay<SocialTab, SocialSortCriteria>
@ -17,28 +20,32 @@ namespace osu.Game.Overlays
protected override BrowseFilterControl<SocialSortCriteria> CreateFilterControl() => new FilterControl();
protected override BrowseHeader<SocialTab> CreateHeader() => new Header();
public SocialOverlay()
{
ScrollFlow.Children = new[]
{
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Vertical = 10 },
Children = new[]
{
new DisplayStyleControl<SortDirection>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
},
},
};
}
}
public enum SocialTab
public enum SortDirection
{
[Description("Online Players")]
OnlinePlayers,
[Description("Online Friends")]
OnlineFriends,
[Description("Online Team Members")]
OnlineTeamMembers,
[Description("Chat Channels")]
ChatChannels,
}
public enum SocialSortCriteria
{
Name,
Rank,
Location,
[Description("Time Zone")]
TimeZone,
[Description("World Map")]
WorldMap,
Ascending,
Descending,
}
}