mirror of
https://github.com/ppy/osu
synced 2024-12-29 02:12:43 +00:00
Merge branch 'master' into fix-spectator-playing-state-5
This commit is contained in:
commit
20f890cfd0
@ -243,7 +243,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
int totalCount = Pieces.Count(p => p.IsSelected.Value);
|
||||
int countOfState = Pieces.Where(p => p.IsSelected.Value).Count(p => p.ControlPoint.Type.Value == type);
|
||||
|
||||
var item = new PathTypeMenuItem(type, () =>
|
||||
var item = new TernaryStateRadioMenuItem(type == null ? "Inherit" : type.ToString().Humanize(), MenuItemType.Standard, _ =>
|
||||
{
|
||||
foreach (var p in Pieces.Where(p => p.IsSelected.Value))
|
||||
updatePathType(p, type);
|
||||
@ -258,15 +258,5 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private class PathTypeMenuItem : TernaryStateMenuItem
|
||||
{
|
||||
public PathTypeMenuItem(PathType? type, Action action)
|
||||
: base(type == null ? "Inherit" : type.ToString().Humanize(), changeState, MenuItemType.Standard, _ => action?.Invoke())
|
||||
{
|
||||
}
|
||||
|
||||
private static TernaryState changeState(TernaryState state) => TernaryState.True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ namespace osu.Game.Rulesets.Taiko.Edit
|
||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
|
||||
{
|
||||
if (selection.All(s => s.Item is Hit))
|
||||
yield return new TernaryStateMenuItem("Rim") { State = { BindTarget = selectionRimState } };
|
||||
yield return new TernaryStateToggleMenuItem("Rim") { State = { BindTarget = selectionRimState } };
|
||||
|
||||
if (selection.All(s => s.Item is TaikoHitObject))
|
||||
yield return new TernaryStateMenuItem("Strong") { State = { BindTarget = selectionStrongState } };
|
||||
yield return new TernaryStateToggleMenuItem("Strong") { State = { BindTarget = selectionStrongState } };
|
||||
|
||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||
yield return item;
|
||||
|
@ -0,0 +1,86 @@
|
||||
// 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 System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneBreadcrumbControlHeader : OsuTestScene
|
||||
{
|
||||
private static readonly string[] items = { "first", "second", "third", "fourth", "fifth" };
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red);
|
||||
|
||||
private TestHeader header;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = header = new TestHeader
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestAddAndRemoveItem()
|
||||
{
|
||||
foreach (var item in items.Skip(1))
|
||||
AddStep($"Add {item} item", () => header.AddItem(item));
|
||||
|
||||
foreach (var item in items.Reverse().SkipLast(3))
|
||||
AddStep($"Remove {item} item", () => header.RemoveItem(item));
|
||||
|
||||
AddStep("Clear items", () => header.ClearItems());
|
||||
|
||||
foreach (var item in items)
|
||||
AddStep($"Add {item} item", () => header.AddItem(item));
|
||||
|
||||
foreach (var item in items)
|
||||
AddStep($"Remove {item} item", () => header.RemoveItem(item));
|
||||
}
|
||||
|
||||
private class TestHeader : BreadcrumbControlOverlayHeader
|
||||
{
|
||||
public TestHeader()
|
||||
{
|
||||
TabControl.AddItem(items[0]);
|
||||
Current.Value = items[0];
|
||||
}
|
||||
|
||||
public void AddItem(string value)
|
||||
{
|
||||
TabControl.AddItem(value);
|
||||
Current.Value = TabControl.Items.LastOrDefault();
|
||||
}
|
||||
|
||||
public void RemoveItem(string value)
|
||||
{
|
||||
TabControl.RemoveItem(value);
|
||||
Current.Value = TabControl.Items.LastOrDefault();
|
||||
}
|
||||
|
||||
public void ClearItems()
|
||||
{
|
||||
TabControl.Clear();
|
||||
Current.Value = null;
|
||||
}
|
||||
|
||||
protected override OverlayTitle CreateTitle() => new TestTitle();
|
||||
}
|
||||
|
||||
private class TestTitle : OverlayTitle
|
||||
{
|
||||
public TestTitle()
|
||||
{
|
||||
Title = "Test Title";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public class TestSceneStatefulMenuItem : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestTernaryMenuItem()
|
||||
public void TestTernaryRadioMenuItem()
|
||||
{
|
||||
OsuMenu menu = null;
|
||||
|
||||
@ -30,9 +30,57 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Origin = Anchor.Centre,
|
||||
Items = new[]
|
||||
{
|
||||
new TernaryStateMenuItem("First"),
|
||||
new TernaryStateMenuItem("Second") { State = { BindTarget = state } },
|
||||
new TernaryStateMenuItem("Third") { State = { Value = TernaryState.True } },
|
||||
new TernaryStateRadioMenuItem("First"),
|
||||
new TernaryStateRadioMenuItem("Second") { State = { BindTarget = state } },
|
||||
new TernaryStateRadioMenuItem("Third") { State = { Value = TernaryState.True } },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
checkState(TernaryState.Indeterminate);
|
||||
|
||||
click();
|
||||
checkState(TernaryState.True);
|
||||
|
||||
click();
|
||||
checkState(TernaryState.True);
|
||||
|
||||
click();
|
||||
checkState(TernaryState.True);
|
||||
|
||||
AddStep("change state via bindable", () => state.Value = TernaryState.True);
|
||||
|
||||
void click() =>
|
||||
AddStep("click", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(menu.ScreenSpaceDrawQuad.Centre);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
void checkState(TernaryState expected)
|
||||
=> AddAssert($"state is {expected}", () => state.Value == expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTernaryToggleMenuItem()
|
||||
{
|
||||
OsuMenu menu = null;
|
||||
|
||||
Bindable<TernaryState> state = new Bindable<TernaryState>(TernaryState.Indeterminate);
|
||||
|
||||
AddStep("create menu", () =>
|
||||
{
|
||||
state.Value = TernaryState.Indeterminate;
|
||||
|
||||
Child = menu = new OsuMenu(Direction.Vertical, true)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Items = new[]
|
||||
{
|
||||
new TernaryStateToggleMenuItem("First"),
|
||||
new TernaryStateToggleMenuItem("Second") { State = { BindTarget = state } },
|
||||
new TernaryStateToggleMenuItem("Third") { State = { Value = TernaryState.True } },
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -9,28 +9,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// <summary>
|
||||
/// An <see cref="OsuMenuItem"/> with three possible states.
|
||||
/// </summary>
|
||||
public class TernaryStateMenuItem : StatefulMenuItem<TernaryState>
|
||||
public abstract class TernaryStateMenuItem : StatefulMenuItem<TernaryState>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TernaryStateMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to display.</param>
|
||||
/// <param name="nextStateFunction">A function to inform what the next state should be when this item is clicked.</param>
|
||||
/// <param name="type">The type of action which this <see cref="TernaryStateMenuItem"/> performs.</param>
|
||||
/// <param name="action">A delegate to be invoked when this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
||||
public TernaryStateMenuItem(string text, MenuItemType type = MenuItemType.Standard, Action<TernaryState> action = null)
|
||||
: this(text, getNextState, type, action)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TernaryStateMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to display.</param>
|
||||
/// <param name="changeStateFunc">A function that mutates a state to another state after this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
||||
/// <param name="type">The type of action which this <see cref="TernaryStateMenuItem"/> performs.</param>
|
||||
/// <param name="action">A delegate to be invoked when this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
||||
protected TernaryStateMenuItem(string text, Func<TernaryState, TernaryState> changeStateFunc, MenuItemType type, Action<TernaryState> action)
|
||||
: base(text, changeStateFunc, type, action)
|
||||
protected TernaryStateMenuItem(string text, Func<TernaryState, TernaryState> nextStateFunction, MenuItemType type = MenuItemType.Standard, Action<TernaryState> action = null)
|
||||
: base(text, nextStateFunction, type, action)
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,23 +36,5 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TernaryState getNextState(TernaryState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case TernaryState.False:
|
||||
return TernaryState.True;
|
||||
|
||||
case TernaryState.Indeterminate:
|
||||
return TernaryState.True;
|
||||
|
||||
case TernaryState.True:
|
||||
return TernaryState.False;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
osu.Game/Graphics/UserInterface/TernaryStateRadioMenuItem.cs
Normal file
26
osu.Game/Graphics/UserInterface/TernaryStateRadioMenuItem.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// 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 System;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// A ternary state menu item which will always set the item to <c>true</c> on click, even if already <c>true</c>.
|
||||
/// </summary>
|
||||
public class TernaryStateRadioMenuItem : TernaryStateMenuItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TernaryStateMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to display.</param>
|
||||
/// <param name="type">The type of action which this <see cref="TernaryStateMenuItem"/> performs.</param>
|
||||
/// <param name="action">A delegate to be invoked when this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
||||
public TernaryStateRadioMenuItem(string text, MenuItemType type = MenuItemType.Standard, Action<TernaryState> action = null)
|
||||
: base(text, getNextState, type, action)
|
||||
{
|
||||
}
|
||||
|
||||
private static TernaryState getNextState(TernaryState state) => TernaryState.True;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
// 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 System;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// A ternary state menu item which toggles the state of this item <c>false</c> if clicked when <c>true</c>.
|
||||
/// </summary>
|
||||
public class TernaryStateToggleMenuItem : TernaryStateMenuItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="TernaryStateToggleMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to display.</param>
|
||||
/// <param name="type">The type of action which this <see cref="TernaryStateMenuItem"/> performs.</param>
|
||||
/// <param name="action">A delegate to be invoked when this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
||||
public TernaryStateToggleMenuItem(string text, MenuItemType type = MenuItemType.Standard, Action<TernaryState> action = null)
|
||||
: base(text, getNextState, type, action)
|
||||
{
|
||||
}
|
||||
|
||||
private static TernaryState getNextState(TernaryState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case TernaryState.False:
|
||||
return TernaryState.True;
|
||||
|
||||
case TernaryState.Indeterminate:
|
||||
return TernaryState.True;
|
||||
|
||||
case TernaryState.True:
|
||||
return TernaryState.False;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,12 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetNewsRequest : APIRequest<GetNewsResponse>
|
||||
{
|
||||
private readonly int? year;
|
||||
private readonly Cursor cursor;
|
||||
|
||||
public GetNewsRequest(Cursor cursor = null)
|
||||
public GetNewsRequest(int? year = null, Cursor cursor = null)
|
||||
{
|
||||
this.year = year;
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
@ -19,6 +21,10 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
req.AddCursor(cursor);
|
||||
|
||||
if (year.HasValue)
|
||||
req.AddParameter("year", year.Value.ToString());
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
@ -144,6 +145,8 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
public void BeginPlaying(GameplayBeatmap beatmap, Score score)
|
||||
{
|
||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||
|
||||
if (IsPlaying)
|
||||
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
|
||||
|
||||
@ -164,14 +167,24 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
public void EndPlaying()
|
||||
{
|
||||
IsPlaying = false;
|
||||
currentBeatmap = null;
|
||||
// This method is most commonly called via Dispose(), which is asynchronous.
|
||||
// Todo: This should not be a thing, but requires framework changes.
|
||||
Schedule(() =>
|
||||
{
|
||||
if (!IsPlaying)
|
||||
return;
|
||||
|
||||
EndPlayingInternal(currentState);
|
||||
IsPlaying = false;
|
||||
currentBeatmap = null;
|
||||
|
||||
EndPlayingInternal(currentState);
|
||||
});
|
||||
}
|
||||
|
||||
public void WatchUser(int userId)
|
||||
{
|
||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||
|
||||
if (watchingUsers.Contains(userId))
|
||||
return;
|
||||
|
||||
@ -220,6 +233,8 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
public void HandleFrame(ReplayFrame frame)
|
||||
{
|
||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||
|
||||
if (frame is IConvertibleReplayFrame convertible)
|
||||
pendingFrames.Enqueue(convertible.ToLegacy(currentBeatmap));
|
||||
|
||||
|
@ -26,7 +26,10 @@ namespace osu.Game.Overlays
|
||||
AccentColour = colourProvider.Light2;
|
||||
}
|
||||
|
||||
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value);
|
||||
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour,
|
||||
};
|
||||
|
||||
private class ControlTabItem : BreadcrumbTabItem
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
@ -9,12 +10,18 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
public class FrontPageDisplay : CompositeDrawable
|
||||
/// <summary>
|
||||
/// Lists articles in a vertical flow for a specified year.
|
||||
/// </summary>
|
||||
public class ArticleListing : CompositeDrawable
|
||||
{
|
||||
public Action<APINewsSidebar> SidebarMetadataUpdated;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
@ -24,6 +31,17 @@ namespace osu.Game.Overlays.News.Displays
|
||||
private GetNewsRequest request;
|
||||
private Cursor lastCursor;
|
||||
|
||||
private readonly int? year;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a listing for the specified year.
|
||||
/// </summary>
|
||||
/// <param name="year">The year to load articles from. If null, will show the most recent articles.</param>
|
||||
public ArticleListing(int? year = null)
|
||||
{
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -74,7 +92,7 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
request = new GetNewsRequest(lastCursor);
|
||||
request = new GetNewsRequest(year, lastCursor);
|
||||
request.Success += response => Schedule(() => onSuccess(response));
|
||||
api.PerformAsync(request);
|
||||
}
|
||||
@ -85,22 +103,19 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
|
||||
// only needs to be updated on the initial load, as the content won't change during pagination.
|
||||
if (lastCursor == null)
|
||||
SidebarMetadataUpdated?.Invoke(response.SidebarMetadata);
|
||||
|
||||
// store cursor for next pagination request.
|
||||
lastCursor = response.Cursor;
|
||||
|
||||
var flow = new FillFlowContainer<NewsCard>
|
||||
LoadComponentsAsync(response.NewsPosts.Select(p => new NewsCard(p)).ToList(), loaded =>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
Children = response.NewsPosts.Select(p => new NewsCard(p)).ToList()
|
||||
};
|
||||
content.AddRange(loaded);
|
||||
|
||||
LoadComponentAsync(flow, loaded =>
|
||||
{
|
||||
content.Add(loaded);
|
||||
showMore.IsLoading = false;
|
||||
showMore.Alpha = lastCursor == null ? 0 : 1;
|
||||
showMore.Alpha = response.Cursor != null ? 1 : 0;
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
@ -19,13 +19,18 @@ namespace osu.Game.Overlays.News
|
||||
{
|
||||
TabControl.AddItem(front_page_string);
|
||||
|
||||
article.BindValueChanged(onArticleChanged, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(e =>
|
||||
{
|
||||
if (e.NewValue == front_page_string)
|
||||
ShowFrontPage?.Invoke();
|
||||
});
|
||||
|
||||
article.BindValueChanged(onArticleChanged, true);
|
||||
}
|
||||
|
||||
public void SetFrontPage() => article.Value = null;
|
||||
|
@ -9,6 +9,7 @@ using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.News.Sidebar
|
||||
{
|
||||
@ -31,30 +32,55 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background4
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = OsuScrollContainer.SCROLL_BAR_HEIGHT,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Colour = colourProvider.Background3,
|
||||
Alpha = 0.5f
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding
|
||||
Padding = new MarginPadding { Right = -3 }, // Compensate for scrollbar margin
|
||||
Child = new OsuScrollContainer
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 50,
|
||||
Right = 30
|
||||
},
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Children = new Drawable[]
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Container
|
||||
{
|
||||
new YearsPanel(),
|
||||
monthsFlow = new FillFlowContainer<MonthSection>
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Right = 3 }, // Addeded 3px back
|
||||
Child = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10)
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 50,
|
||||
Right = 30
|
||||
},
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new YearsPanel(),
|
||||
monthsFlow = new FillFlowContainer<MonthSection>
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,9 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
{
|
||||
public int Year { get; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private NewsOverlay overlay { get; set; }
|
||||
|
||||
private readonly bool isCurrent;
|
||||
|
||||
public YearButton(int year, bool isCurrent)
|
||||
@ -106,7 +109,11 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
{
|
||||
IdleColour = isCurrent ? Color4.White : colourProvider.Light2;
|
||||
HoverColour = isCurrent ? Color4.White : colourProvider.Light1;
|
||||
Action = () => { }; // Avoid button being disabled since there's no proper action assigned.
|
||||
Action = () =>
|
||||
{
|
||||
if (!isCurrent)
|
||||
overlay?.ShowYear(Year);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
// 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 System;
|
||||
using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.News;
|
||||
using osu.Game.Overlays.News.Displays;
|
||||
using osu.Game.Overlays.News.Sidebar;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -13,9 +16,48 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
private readonly Bindable<string> article = new Bindable<string>(null);
|
||||
|
||||
private readonly Container sidebarContainer;
|
||||
private readonly NewsSidebar sidebar;
|
||||
|
||||
private readonly Container content;
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private bool displayUpdateRequired = true;
|
||||
|
||||
public NewsOverlay()
|
||||
: base(OverlayColourScheme.Purple, false)
|
||||
{
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
},
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension()
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
sidebarContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Child = sidebar = new NewsSidebar()
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -26,12 +68,7 @@ namespace osu.Game.Overlays
|
||||
article.BindValueChanged(onArticleChanged);
|
||||
}
|
||||
|
||||
protected override NewsHeader CreateHeader() => new NewsHeader
|
||||
{
|
||||
ShowFrontPage = ShowFrontPage
|
||||
};
|
||||
|
||||
private bool displayUpdateRequired = true;
|
||||
protected override NewsHeader CreateHeader() => new NewsHeader { ShowFrontPage = ShowFrontPage };
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
@ -56,38 +93,69 @@ namespace osu.Game.Overlays
|
||||
Show();
|
||||
}
|
||||
|
||||
public void ShowYear(int year)
|
||||
{
|
||||
loadFrontPage(year);
|
||||
Show();
|
||||
}
|
||||
|
||||
public void ShowArticle(string slug)
|
||||
{
|
||||
article.Value = slug;
|
||||
Show();
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> e)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
|
||||
if (e.NewValue == null)
|
||||
{
|
||||
Header.SetFrontPage();
|
||||
LoadDisplay(new FrontPageDisplay());
|
||||
return;
|
||||
}
|
||||
|
||||
Header.SetArticle(e.NewValue);
|
||||
LoadDisplay(Empty());
|
||||
}
|
||||
|
||||
protected void LoadDisplay(Drawable display)
|
||||
{
|
||||
ScrollFlow.ScrollToStart();
|
||||
LoadComponentAsync(display, loaded =>
|
||||
LoadComponentAsync(display, loaded => content.Child = loaded, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
sidebarContainer.Height = DrawHeight;
|
||||
sidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
}
|
||||
|
||||
private void onArticleChanged(ValueChangedEvent<string> article)
|
||||
{
|
||||
if (article.NewValue == null)
|
||||
loadFrontPage();
|
||||
else
|
||||
loadArticle(article.NewValue);
|
||||
}
|
||||
|
||||
private void loadFrontPage(int? year = null)
|
||||
{
|
||||
beginLoading();
|
||||
|
||||
Header.SetFrontPage();
|
||||
|
||||
var page = new ArticleListing(year);
|
||||
page.SidebarMetadataUpdated += metadata => Schedule(() =>
|
||||
{
|
||||
Child = loaded;
|
||||
sidebar.Metadata.Value = metadata;
|
||||
Loading.Hide();
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
});
|
||||
LoadDisplay(page);
|
||||
}
|
||||
|
||||
private void loadArticle(string article)
|
||||
{
|
||||
beginLoading();
|
||||
|
||||
Header.SetArticle(article);
|
||||
|
||||
// Temporary, should be handled by ArticleDisplay later
|
||||
LoadDisplay(Empty());
|
||||
Loading.Hide();
|
||||
}
|
||||
|
||||
private void beginLoading()
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
Loading.Show();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -168,13 +168,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
if (SelectedBlueprints.All(b => b.Item is IHasComboInformation))
|
||||
{
|
||||
yield return new TernaryStateMenuItem("New combo") { State = { BindTarget = SelectionNewComboState } };
|
||||
yield return new TernaryStateToggleMenuItem("New combo") { State = { BindTarget = SelectionNewComboState } };
|
||||
}
|
||||
|
||||
yield return new OsuMenuItem("Sound")
|
||||
{
|
||||
Items = SelectionSampleStates.Select(kvp =>
|
||||
new TernaryStateMenuItem(kvp.Value.Description) { State = { BindTarget = kvp.Value } }).ToArray()
|
||||
new TernaryStateToggleMenuItem(kvp.Value.Description) { State = { BindTarget = kvp.Value } }).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
@ -93,6 +94,9 @@ namespace osu.Game.Screens.Play
|
||||
[Resolved]
|
||||
private MusicController musicController { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private SpectatorClient spectatorClient { get; set; }
|
||||
|
||||
private Sample sampleRestart;
|
||||
|
||||
public BreakOverlay BreakOverlay;
|
||||
@ -882,6 +886,11 @@ namespace osu.Game.Screens.Play
|
||||
return true;
|
||||
}
|
||||
|
||||
// EndPlaying() is typically called from ReplayRecorder.Dispose(). Disposal is currently asynchronous.
|
||||
// To resolve test failures, forcefully end playing synchronously when this screen exits.
|
||||
// Todo: Replace this with a more permanent solution once osu-framework has a synchronous cleanup method.
|
||||
spectatorClient.EndPlaying();
|
||||
|
||||
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
||||
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
||||
(GameplayClockContainer as MasterGameplayClockContainer)?.StopUsingBeatmapClock();
|
||||
|
@ -250,7 +250,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
else
|
||||
state = TernaryState.False;
|
||||
|
||||
return new TernaryStateMenuItem(collection.Name.Value, MenuItemType.Standard, s =>
|
||||
return new TernaryStateToggleMenuItem(collection.Name.Value, MenuItemType.Standard, s =>
|
||||
{
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ using osuTK;
|
||||
namespace osu.Game.Skinning.Editor
|
||||
{
|
||||
[Cached(typeof(SkinEditor))]
|
||||
public class SkinEditor : FocusedOverlayContainer
|
||||
public class SkinEditor : VisibilityContainer
|
||||
{
|
||||
public const double TRANSITION_DURATION = 500;
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace osu.Game.Skinning.Editor
|
||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||
yield return item;
|
||||
|
||||
IEnumerable<AnchorMenuItem> createAnchorItems(Func<Drawable, Anchor> checkFunction, Action<Anchor> applyFunction)
|
||||
IEnumerable<TernaryStateMenuItem> createAnchorItems(Func<Drawable, Anchor> checkFunction, Action<Anchor> applyFunction)
|
||||
{
|
||||
var displayableAnchors = new[]
|
||||
{
|
||||
@ -117,7 +117,7 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
return displayableAnchors.Select(a =>
|
||||
{
|
||||
return new AnchorMenuItem(a, selection, _ => applyFunction(a))
|
||||
return new TernaryStateRadioMenuItem(a.ToString(), MenuItemType.Standard, _ => applyFunction(a))
|
||||
{
|
||||
State = { Value = GetStateFromSelection(selection, c => checkFunction((Drawable)c.Item) == a) }
|
||||
};
|
||||
@ -166,15 +166,5 @@ namespace osu.Game.Skinning.Editor
|
||||
scale.Y = scale.X;
|
||||
}
|
||||
}
|
||||
|
||||
public class AnchorMenuItem : TernaryStateMenuItem
|
||||
{
|
||||
public AnchorMenuItem(Anchor anchor, IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection, Action<TernaryState> action)
|
||||
: base(anchor.ToString(), getNextState, MenuItemType.Standard, action)
|
||||
{
|
||||
}
|
||||
|
||||
private static TernaryState getNextState(TernaryState state) => TernaryState.True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user