Merge branch 'master' into not-available-to-download

This commit is contained in:
iiSaLMaN
2019-06-19 01:14:32 +03:00
committed by GitHub
144 changed files with 1618 additions and 755 deletions

View File

@ -109,7 +109,7 @@ namespace osu.Game.Overlays
break;
case APIState.Online:
State = Visibility.Hidden;
Hide();
break;
}
}

View File

@ -50,7 +50,7 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDisplay()
{
bpm.Value = BeatmapSet?.OnlineInfo.BPM.ToString(@"0.##") ?? "-";
bpm.Value = BeatmapSet?.OnlineInfo?.BPM.ToString(@"0.##") ?? "-";
if (beatmap == null)
{

View File

@ -16,10 +16,11 @@ namespace osu.Game.Overlays.BeatmapSet
{
public class Details : FillFlowContainer
{
protected readonly UserRatings Ratings;
private readonly PreviewButton preview;
private readonly BasicStats basic;
private readonly AdvancedStats advanced;
private readonly UserRatings ratings;
private BeatmapSetInfo beatmapSet;
@ -33,6 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet
beatmapSet = value;
basic.BeatmapSet = preview.BeatmapSet = BeatmapSet;
updateDisplay();
}
}
@ -46,13 +48,12 @@ namespace osu.Game.Overlays.BeatmapSet
if (value == beatmap) return;
basic.Beatmap = advanced.Beatmap = beatmap = value;
updateDisplay();
}
}
private void updateDisplay()
{
ratings.Metrics = Beatmap?.Metrics;
Ratings.Metrics = BeatmapSet?.Metrics;
}
public Details()
@ -87,7 +88,7 @@ namespace osu.Game.Overlays.BeatmapSet
},
new DetailBox
{
Child = ratings = new UserRatings
Child = Ratings = new UserRatings
{
RelativeSizeAxes = Axes.X,
Height = 95,

View File

@ -14,11 +14,12 @@ namespace osu.Game.Overlays.BeatmapSet
{
public class SuccessRate : Container
{
protected readonly FailRetryGraph Graph;
private readonly FillFlowContainer header;
private readonly OsuSpriteText successRateLabel, successPercent, graphLabel;
private readonly Bar successRate;
private readonly Container percentContainer;
private readonly FailRetryGraph graph;
private BeatmapInfo beatmap;
@ -37,15 +38,15 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDisplay()
{
int passCount = beatmap?.OnlineInfo.PassCount ?? 0;
int playCount = beatmap?.OnlineInfo.PlayCount ?? 0;
int passCount = beatmap?.OnlineInfo?.PassCount ?? 0;
int playCount = beatmap?.OnlineInfo?.PlayCount ?? 0;
var rate = playCount != 0 ? (float)passCount / playCount : 0;
successPercent.Text = rate.ToString("P0");
successRate.Length = rate;
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
graph.Metrics = beatmap?.Metrics;
Graph.Metrics = beatmap?.Metrics;
}
public SuccessRate()
@ -94,7 +95,7 @@ namespace osu.Game.Overlays.BeatmapSet
},
},
},
graph = new FailRetryGraph
Graph = new FailRetryGraph
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
@ -117,7 +118,7 @@ namespace osu.Game.Overlays.BeatmapSet
{
base.UpdateAfterChildren();
graph.Padding = new MarginPadding { Top = header.DrawHeight };
Graph.Padding = new MarginPadding { Top = header.DrawHeight };
}
}
}

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays
private RulesetStore rulesets;
private readonly ScrollContainer scroll;
private readonly OsuScrollContainer scroll;
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
@ -49,7 +49,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
scroll = new ScrollContainer
scroll = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
@ -92,7 +92,7 @@ namespace osu.Game.Overlays
protected override bool OnClick(ClickEvent e)
{
State = Visibility.Hidden;
Hide();
return true;
}

View File

@ -51,7 +51,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = colour.PurpleDarkAlternative,
},
new ScrollContainer
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
@ -92,7 +92,7 @@ namespace osu.Game.Overlays
public void ShowListing()
{
Current.Value = null;
State = Visibility.Visible;
Show();
}
/// <summary>
@ -106,7 +106,7 @@ namespace osu.Game.Overlays
if (build == null) throw new ArgumentNullException(nameof(build));
Current.Value = build;
State = Visibility.Visible;
Show();
}
public void ShowBuild([NotNull] string updateStream, [NotNull] string version)
@ -123,7 +123,7 @@ namespace osu.Game.Overlays
ShowBuild(build);
});
State = Visibility.Visible;
Show();
}
public override bool OnPressed(GlobalAction action)
@ -133,7 +133,7 @@ namespace osu.Game.Overlays
case GlobalAction.Back:
if (Current.Value == null)
{
State = Visibility.Hidden;
Hide();
}
else
{

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Chat
{
public readonly Channel Channel;
protected readonly ChatLineContainer ChatLineFlow;
private readonly ScrollContainer scroll;
private readonly OsuScrollContainer scroll;
public DrawableChannel(Channel channel)
{

View File

@ -56,7 +56,7 @@ namespace osu.Game.Overlays
private readonly Container channelSelectionContainer;
private readonly ChannelSelectionOverlay channelSelectionOverlay;
public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || (channelSelectionOverlay.State == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos));
public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceivePositionalInputAt(screenSpacePos) || (channelSelectionOverlay.State.Value == Visibility.Visible && channelSelectionOverlay.ReceivePositionalInputAt(screenSpacePos));
public ChatOverlay()
{
@ -130,7 +130,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Height = 1,
PlaceholderText = "type your message",
Exit = () => State = Visibility.Hidden,
Exit = Hide,
OnCommit = postMessage,
ReleaseFocusOnCommit = false,
HoldFocus = true,
@ -163,19 +163,19 @@ namespace osu.Game.Overlays
};
channelTabControl.Current.ValueChanged += current => channelManager.CurrentChannel.Value = current.NewValue;
channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State = active.NewValue ? Visibility.Visible : Visibility.Hidden;
channelSelectionOverlay.StateChanged += state =>
channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
channelSelectionOverlay.State.ValueChanged += state =>
{
if (state == Visibility.Hidden && channelManager.CurrentChannel.Value == null)
if (state.NewValue == Visibility.Hidden && channelManager.CurrentChannel.Value == null)
{
channelSelectionOverlay.State = Visibility.Visible;
State = Visibility.Hidden;
channelSelectionOverlay.Show();
Hide();
return;
}
channelTabControl.ChannelSelectorActive.Value = state == Visibility.Visible;
channelTabControl.ChannelSelectorActive.Value = state.NewValue == Visibility.Visible;
if (state == Visibility.Visible)
if (state.NewValue == Visibility.Visible)
{
textbox.HoldFocus = false;
if (1f - ChatHeight.Value < channel_selection_min_height)
@ -195,7 +195,7 @@ namespace osu.Game.Overlays
{
textbox.Current.Disabled = true;
currentChannelContainer.Clear(false);
channelSelectionOverlay.State = Visibility.Visible;
channelSelectionOverlay.Show();
return;
}
@ -253,7 +253,7 @@ namespace osu.Game.Overlays
double targetChatHeight = startDragChatHeight - (e.MousePosition.Y - e.MouseDownPosition.Y) / Parent.DrawSize.Y;
// If the channel selection screen is shown, mind its minimum height
if (channelSelectionOverlay.State == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height)
if (channelSelectionOverlay.State.Value == Visibility.Visible && targetChatHeight > 1f - channel_selection_min_height)
targetChatHeight = 1f - channel_selection_min_height;
ChatHeight.Value = targetChatHeight;
@ -325,7 +325,7 @@ namespace osu.Game.Overlays
this.MoveToY(Height, transition_length, Easing.InSine);
this.FadeOut(transition_length, Easing.InSine);
channelSelectionOverlay.State = Visibility.Hidden;
channelSelectionOverlay.Hide();
textbox.HoldFocus = false;
base.PopOut();

View File

@ -37,8 +37,8 @@ namespace osu.Game.Overlays
dialogContainer.Add(currentDialog);
currentDialog.Show();
currentDialog.StateChanged += state => onDialogOnStateChanged(dialog, state);
State = Visibility.Visible;
currentDialog.State.ValueChanged += state => onDialogOnStateChanged(dialog, state.NewValue);
Show();
}
protected override bool PlaySamplesOnStateChange => false;
@ -53,7 +53,7 @@ namespace osu.Game.Overlays
dialog.Delay(PopupDialog.EXIT_DURATION).Expire();
if (dialog == currentDialog)
State = Visibility.Hidden;
Hide();
}
protected override void PopIn()
@ -66,7 +66,7 @@ namespace osu.Game.Overlays
{
base.PopOut();
if (currentDialog?.State == Visibility.Visible)
if (currentDialog?.State.Value == Visibility.Visible)
{
currentDialog.Hide();
return;

View File

@ -252,7 +252,7 @@ namespace osu.Game.Overlays
if (!IsLoaded)
return;
if (State == Visibility.Hidden)
if (State.Value == Visibility.Hidden)
return;
if (API == null)

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -40,6 +41,19 @@ namespace osu.Game.Overlays
};
}
public override void Show()
{
if (State.Value == Visibility.Visible)
{
// re-trigger the state changed so we can potentially surface to front
State.TriggerChange();
}
else
{
base.Show();
}
}
protected override void PopIn()
{
base.PopIn();

View File

@ -413,12 +413,12 @@ namespace osu.Game.Overlays.Mods
{
if (selectedMod != null)
{
if (State == Visibility.Visible) sampleOn?.Play();
if (State.Value == Visibility.Visible) sampleOn?.Play();
DeselectTypes(selectedMod.IncompatibleMods, true);
}
else
{
if (State == Visibility.Visible) sampleOff?.Play();
if (State.Value == Visibility.Visible) sampleOff?.Play();
}
refreshSelectedMods();

View File

@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Music
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ExitRequested = () => State = Visibility.Hidden,
ExitRequested = Hide,
FilterChanged = search => list.Filter(search),
Padding = new MarginPadding(10),
},

View File

@ -200,7 +200,7 @@ namespace osu.Game.Overlays
beatmaps.ItemAdded += handleBeatmapAdded;
beatmaps.ItemRemoved += handleBeatmapRemoved;
playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint);
playlist.State.ValueChanged += s => playlistButton.FadeColour(s.NewValue == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint);
}
private ScheduledDelegate seekDelegate;
@ -449,7 +449,7 @@ namespace osu.Game.Overlays
// This is here mostly as a performance fix.
// If the playlist is not hidden it will update children even when the music controller is hidden (due to AlwaysPresent).
playlist.State = Visibility.Hidden;
playlist.Hide();
this.FadeOut(transition_length, Easing.OutQuint);
dragContainer.ScaleTo(0.9f, transition_length, Easing.OutQuint);
@ -464,12 +464,26 @@ namespace osu.Game.Overlays
private class MusicIconButton : IconButton
{
public MusicIconButton()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
HoverColour = colours.YellowDark.Opacity(0.6f);
FlashColour = colours.Yellow;
}
protected override void LoadComplete()
{
base.LoadComplete();
// works with AutoSizeAxes above to make buttons autosize with the scale animation.
Content.AutoSizeAxes = Axes.None;
Content.Size = new Vector2(DEFAULT_BUTTON_SIZE);
}
}
private class Background : BufferedContainer

View File

@ -81,13 +81,13 @@ namespace osu.Game.Overlays
private void updateProcessingMode()
{
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State == Visibility.Visible;
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible;
notificationsEnabler?.Cancel();
if (enabled)
// we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed.
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State == Visibility.Visible ? 0 : 1000);
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State.Value == Visibility.Visible ? 0 : 1000);
else
processingPosts = false;
}
@ -96,7 +96,7 @@ namespace osu.Game.Overlays
{
base.LoadComplete();
StateChanged += _ => updateProcessingMode();
State.ValueChanged += _ => updateProcessingMode();
OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true);
}
@ -128,7 +128,7 @@ namespace osu.Game.Overlays
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
if (notification.IsImportant)
State = Visibility.Visible;
Show();
updateCounts();
});

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -36,6 +37,10 @@ namespace osu.Game.Overlays.Notifications
State = state;
}
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
public CancellationToken CancellationToken => cancellationTokenSource.Token;
public virtual ProgressNotificationState State
{
get => state;
@ -62,6 +67,8 @@ namespace osu.Game.Overlays.Notifications
break;
case ProgressNotificationState.Cancelled:
cancellationTokenSource.Cancel();
Light.Colour = colourCancelled;
Light.Pulsate = false;
progressBar.Active = false;

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
new SettingsCheckbox
{
LabelText = "Increase visibility of first object with \"Hidden\" mod",
LabelText = "Increase visibility of first object when visual impairment mods are enabled",
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility)
},
};

View File

@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
{
new LoadingAnimation
{
State = Visibility.Visible,
State = { Value = Visibility.Visible },
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
@ -154,8 +154,9 @@ namespace osu.Game.Overlays.Settings.Sections.General
};
panel.Status.BindTo(api.LocalUser.Value.Status);
panel.Activity.BindTo(api.LocalUser.Value.Activity);
dropdown.Current.ValueChanged += action =>
dropdown.Current.BindValueChanged(action =>
{
switch (action.NewValue)
{
@ -178,9 +179,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
api.Logout();
break;
}
};
dropdown.Current.TriggerChange();
}, true);
break;
}

View File

@ -10,12 +10,14 @@ namespace osu.Game.Overlays.Settings
{
private OsuCheckbox checkbox;
private string labelText;
protected override Drawable CreateControl() => checkbox = new OsuCheckbox();
public override string LabelText
{
get => checkbox.LabelText;
set => checkbox.LabelText = value;
get => labelText;
set => checkbox.LabelText = labelText = value;
}
}
}

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
@ -58,15 +59,49 @@ namespace osu.Game.Overlays.Settings
Text = game.Name,
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold),
},
new OsuSpriteText
new BuildDisplay(game.Version, DebugUtils.IsDebug)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Font = OsuFont.GetFont(size: 14),
Text = game.Version,
Colour = DebugUtils.IsDebug ? colours.Red : Color4.White,
},
}
};
}
private class BuildDisplay : OsuAnimatedButton
{
private readonly string version;
private readonly bool isDebug;
[Resolved]
private OsuColour colours { get; set; }
public BuildDisplay(string version, bool isDebug)
{
this.version = version;
this.isDebug = isDebug;
Content.RelativeSizeAxes = Axes.Y;
Content.AutoSizeAxes = AutoSizeAxes = Axes.X;
Height = 20;
}
[BackgroundDependencyLoader(true)]
private void load(ChangelogOverlay changelog)
{
if (!isDebug)
Action = () => changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version);
Add(new OsuSpriteText
{
Font = OsuFont.GetFont(size: 16),
Text = version,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Padding = new MarginPadding(5),
Colour = isDebug ? colours.Red : Color4.White,
});
}
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Toolbar;
namespace osu.Game.Overlays.Settings
@ -76,7 +77,7 @@ namespace osu.Game.Overlays.Settings
return base.OnMouseMove(e);
}
private class SidebarScrollContainer : ScrollContainer
private class SidebarScrollContainer : OsuScrollContainer
{
public SidebarScrollContainer()
{

View File

@ -9,6 +9,7 @@ using osu.Game.Overlays.Settings.Sections;
using osuTK.Graphics;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
namespace osu.Game.Overlays
{
@ -37,23 +38,23 @@ namespace osu.Game.Overlays
{
}
public override bool AcceptsFocus => subPanels.All(s => s.State != Visibility.Visible);
public override bool AcceptsFocus => subPanels.All(s => s.State.Value != Visibility.Visible);
private T createSubPanel<T>(T subPanel)
where T : SettingsSubPanel
{
subPanel.Depth = 1;
subPanel.Anchor = Anchor.TopRight;
subPanel.StateChanged += subPanelStateChanged;
subPanel.State.ValueChanged += subPanelStateChanged;
subPanels.Add(subPanel);
return subPanel;
}
private void subPanelStateChanged(Visibility visibility)
private void subPanelStateChanged(ValueChangedEvent<Visibility> state)
{
switch (visibility)
switch (state.NewValue)
{
case Visibility.Visible:
Background.FadeTo(0.9f, 300, Easing.OutQuint);
@ -73,7 +74,7 @@ namespace osu.Game.Overlays
}
}
protected override float ExpandedPosition => subPanels.Any(s => s.State == Visibility.Visible) ? -WIDTH : base.ExpandedPosition;
protected override float ExpandedPosition => subPanels.Any(s => s.State.Value == Visibility.Visible) ? -WIDTH : base.ExpandedPosition;
[BackgroundDependencyLoader]
private void load()

View File

@ -119,6 +119,7 @@ namespace osu.Game.Overlays
}
panel.Status.BindTo(u.Status);
panel.Activity.BindTo(u.Activity);
return panel;
})
};

View File

@ -84,10 +84,10 @@ namespace osu.Game.Overlays.Toolbar
}
};
StateChanged += visibility =>
State.ValueChanged += visibility =>
{
if (overlayActivationMode.Value == OverlayActivation.Disabled)
State = Visibility.Hidden;
Hide();
};
if (osuGame != null)

View File

@ -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 osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -15,6 +16,8 @@ namespace osu.Game.Overlays.Toolbar
private OverlayContainer stateContainer;
private readonly Bindable<Visibility> overlayState = new Bindable<Visibility>();
public OverlayContainer StateContainer
{
get => stateContainer;
@ -22,10 +25,12 @@ namespace osu.Game.Overlays.Toolbar
{
stateContainer = value;
overlayState.UnbindBindings();
if (stateContainer != null)
{
Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged;
overlayState.BindTo(stateContainer.State);
}
}
}
@ -40,18 +45,13 @@ namespace osu.Game.Overlays.Toolbar
Depth = 2,
Alpha = 0,
});
overlayState.ValueChanged += stateChanged;
}
protected override void Dispose(bool isDisposing)
private void stateChanged(ValueChangedEvent<Visibility> state)
{
base.Dispose(isDisposing);
if (stateContainer != null)
stateContainer.StateChanged -= stateChanged;
}
private void stateChanged(Visibility state)
{
switch (state)
switch (state.NewValue)
{
case Visibility.Hidden:
stateBackground.FadeOut(200);

View File

@ -100,14 +100,14 @@ namespace osu.Game.Overlays
switch (action)
{
case GlobalAction.DecreaseVolume:
if (State == Visibility.Hidden)
if (State.Value == Visibility.Hidden)
Show();
else
volumeMeterMaster.Decrease(amount, isPrecise);
return true;
case GlobalAction.IncreaseVolume:
if (State == Visibility.Hidden)
if (State.Value == Visibility.Hidden)
Show();
else
volumeMeterMaster.Increase(amount, isPrecise);
@ -126,7 +126,7 @@ namespace osu.Game.Overlays
public override void Show()
{
if (State == Visibility.Visible)
if (State.Value == Visibility.Visible)
schedulePopOut();
base.Show();