mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 13:27:20 +08:00
Move DisplayStyleControl to all FilterControls
This commit is contained in:
parent
5785715ad5
commit
12f6276e05
@ -13,12 +13,10 @@ using osu.Game.Overlays.SearchableList;
|
||||
|
||||
namespace osu.Game.Overlays.Direct
|
||||
{
|
||||
public class FilterControl : SearchableListFilterControl<DirectSortCritera>
|
||||
public class FilterControl : SearchableListFilterControl<DirectSortCritera,RankStatus>
|
||||
{
|
||||
private FillFlowContainer<RulesetToggleButton> modeButtons;
|
||||
|
||||
public readonly DisplayStyleControl<RankStatus> DisplayStyleControl;
|
||||
|
||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552");
|
||||
protected override DirectSortCritera DefaultTab => DirectSortCritera.Title;
|
||||
protected override Drawable CreateSupplementaryControls()
|
||||
@ -32,16 +30,6 @@ namespace osu.Game.Overlays.Direct
|
||||
return modeButtons;
|
||||
}
|
||||
|
||||
public FilterControl()
|
||||
{
|
||||
Add(DisplayStyleControl = new DisplayStyleControl<RankStatus>
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding { Bottom = 5, Right = SearchableListOverlay.WIDTH_PADDING },
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ using System;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class DirectOverlay : SearchableListOverlay<DirectTab,DirectSortCritera>
|
||||
public class DirectOverlay : SearchableListOverlay<DirectTab,DirectSortCritera,RankStatus>
|
||||
{
|
||||
private const float panel_padding = 10f;
|
||||
|
||||
@ -30,7 +30,7 @@ namespace osu.Game.Overlays
|
||||
protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265");
|
||||
|
||||
protected override SearchableListHeader<DirectTab> CreateHeader() => new Header();
|
||||
protected override SearchableListFilterControl<DirectSortCritera> CreateFilterControl() => new FilterControl();
|
||||
protected override SearchableListFilterControl<DirectSortCritera,RankStatus> CreateFilterControl() => new FilterControl();
|
||||
|
||||
private IEnumerable<BeatmapSetInfo> beatmapSets;
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
@ -41,9 +41,7 @@ namespace osu.Game.Overlays
|
||||
if (beatmapSets?.Equals(value) ?? false) return;
|
||||
beatmapSets = value;
|
||||
|
||||
var s = PanelDisplayStyle.Grid;
|
||||
withDisplayStyleControl(c => s = c.DisplayStyle.Value);
|
||||
recreatePanels(s);
|
||||
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +101,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; };
|
||||
Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; };
|
||||
withDisplayStyleControl(c => c.DisplayStyle.ValueChanged += recreatePanels);
|
||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels;
|
||||
|
||||
updateResultCounts();
|
||||
}
|
||||
@ -135,12 +133,6 @@ namespace osu.Game.Overlays
|
||||
panels.Children = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b));
|
||||
}
|
||||
|
||||
private void withDisplayStyleControl(Action<DisplayStyleControl<RankStatus>> action)
|
||||
{
|
||||
var f = Filter as FilterControl;
|
||||
if (f != null) action.Invoke(f.DisplayStyleControl);
|
||||
}
|
||||
|
||||
public class ResultCounts
|
||||
{
|
||||
public readonly int Artists;
|
||||
|
@ -13,7 +13,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.SearchableList
|
||||
{
|
||||
public abstract class SearchableListFilterControl<T> : Container
|
||||
public abstract class SearchableListFilterControl<T,U> : Container
|
||||
{
|
||||
private const float padding = 10;
|
||||
|
||||
@ -21,6 +21,7 @@ namespace osu.Game.Overlays.SearchableList
|
||||
|
||||
public readonly SearchTextBox Search;
|
||||
public readonly PageTabControl<T> Tabs;
|
||||
public readonly DisplayStyleControl<U> DisplayStyleControl;
|
||||
|
||||
protected abstract Color4 BackgroundColour { get; }
|
||||
protected abstract T DefaultTab { get; }
|
||||
@ -80,6 +81,12 @@ namespace osu.Game.Overlays.SearchableList
|
||||
},
|
||||
},
|
||||
},
|
||||
DisplayStyleControl = new DisplayStyleControl<U>
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding { Bottom = 5, Right = SearchableListOverlay.WIDTH_PADDING },
|
||||
},
|
||||
};
|
||||
|
||||
if (controls != null) controlsContainer.Children = new[] { controls };
|
||||
|
@ -15,20 +15,19 @@ namespace osu.Game.Overlays.SearchableList
|
||||
public static readonly float WIDTH_PADDING = 80;
|
||||
}
|
||||
|
||||
//todo: naming
|
||||
public abstract class SearchableListOverlay<T,U> : SearchableListOverlay
|
||||
public abstract class SearchableListOverlay<T,U,S> : SearchableListOverlay
|
||||
{
|
||||
private readonly Container scrollContainer;
|
||||
|
||||
protected readonly SearchableListHeader<T> Header;
|
||||
protected readonly SearchableListFilterControl<U> Filter;
|
||||
protected readonly SearchableListFilterControl<U,S> Filter;
|
||||
protected readonly FillFlowContainer ScrollFlow;
|
||||
|
||||
protected abstract Color4 BackgroundColour { get; }
|
||||
protected abstract Color4 TrianglesColourLight { get; }
|
||||
protected abstract Color4 TrianglesColourDark { get; }
|
||||
protected abstract SearchableListHeader<T> CreateHeader();
|
||||
protected abstract SearchableListFilterControl<U> CreateFilterControl();
|
||||
protected abstract SearchableListFilterControl<U,S> CreateFilterControl();
|
||||
|
||||
protected SearchableListOverlay()
|
||||
{
|
||||
|
@ -3,15 +3,22 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
|
||||
namespace osu.Game.Overlays.Social
|
||||
{
|
||||
public class FilterControl : SearchableListFilterControl<SocialSortCriteria>
|
||||
public class FilterControl : SearchableListFilterControl<SocialSortCriteria,SortDirection>
|
||||
{
|
||||
protected override Color4 BackgroundColour => OsuColour.FromHex(@"47253a");
|
||||
protected override SocialSortCriteria DefaultTab => SocialSortCriteria.Name;
|
||||
|
||||
public FilterControl()
|
||||
{
|
||||
Tabs.Margin = new MarginPadding { Top = 10 };
|
||||
}
|
||||
}
|
||||
|
||||
public enum SocialSortCriteria
|
||||
|
@ -14,7 +14,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class SocialOverlay : SearchableListOverlay<SocialTab, SocialSortCriteria>
|
||||
public class SocialOverlay : SearchableListOverlay<SocialTab,SocialSortCriteria,SortDirection>
|
||||
{
|
||||
private readonly FillFlowContainer<UserPanel> panelFlow;
|
||||
|
||||
@ -23,7 +23,7 @@ namespace osu.Game.Overlays
|
||||
protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"5c2648");
|
||||
|
||||
protected override SearchableListHeader<SocialTab> CreateHeader() => new Header();
|
||||
protected override SearchableListFilterControl<SocialSortCriteria> CreateFilterControl() => new FilterControl();
|
||||
protected override SearchableListFilterControl<SocialSortCriteria,SortDirection> CreateFilterControl() => new FilterControl();
|
||||
|
||||
private IEnumerable<User> users;
|
||||
public IEnumerable<User> Users
|
||||
@ -50,26 +50,13 @@ namespace osu.Game.Overlays
|
||||
ThirdWaveColour = OsuColour.FromHex(@"9B2B6E");
|
||||
FourthWaveColour = OsuColour.FromHex(@"6D214D");
|
||||
|
||||
ScrollFlow.Children = new Drawable[]
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
panelFlow = new FillFlowContainer<UserPanel>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 20 },
|
||||
Spacing = new Vector2(10f),
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user