Merge branch 'master' into single-osu-logo

This commit is contained in:
Dean Herbert 2017-11-08 14:37:20 +09:00 committed by GitHub
commit 90fec5f370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 16 deletions

View File

@ -80,7 +80,7 @@ public virtual Bindable<T> Bindable
controlWithCurrent?.Current.BindTo(bindable);
if (ShowsDefaultIndicator)
{
restoreDefaultValueButton.Bindable.BindTo(bindable);
restoreDefaultValueButton.Bindable = bindable.GetBoundCopy();
restoreDefaultValueButton.Bindable.TriggerChange();
}
}
@ -134,7 +134,17 @@ private void load(OsuColour colours)
private class RestoreDefaultValueButton<T> : Box, IHasTooltip
{
internal readonly Bindable<T> Bindable = new Bindable<T>();
private Bindable<T> bindable;
internal Bindable<T> Bindable
{
get { return bindable; }
set
{
bindable = value;
bindable.ValueChanged += newValue => UpdateState();
bindable.DisabledChanged += disabled => UpdateState();
}
}
private Color4 buttonColour;
@ -142,9 +152,6 @@ private class RestoreDefaultValueButton<T> : Box, IHasTooltip
public RestoreDefaultValueButton()
{
Bindable.ValueChanged += value => UpdateState();
Bindable.DisabledChanged += disabled => UpdateState();
RelativeSizeAxes = Axes.Y;
Width = SettingsOverlay.CONTENT_MARGINS;
Alpha = 0f;
@ -160,8 +167,8 @@ public RestoreDefaultValueButton()
protected override bool OnClick(InputState state)
{
if (!Bindable.Disabled)
Bindable.SetDefault();
if (bindable != null && !bindable.Disabled)
bindable.SetDefault();
return true;
}
@ -186,8 +193,10 @@ internal void SetButtonColour(Color4 buttonColour)
internal void UpdateState()
{
var colour = Bindable.Disabled ? Color4.Gray : buttonColour;
this.FadeTo(Bindable.IsDefault ? 0f : hovering && !Bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint);
if (bindable == null)
return;
var colour = bindable.Disabled ? Color4.Gray : buttonColour;
this.FadeTo(bindable.IsDefault ? 0f : hovering && !bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint);
this.FadeColour(ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)), 200, Easing.OutQuint);
}
}

View File

@ -76,7 +76,9 @@ private void load(AudioManager audio, OsuConfigManager config, BeatmapManager be
welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya");
beatmaps.Delete(setInfo);
if (setInfo.Protected)
beatmaps.Delete(setInfo);
}
protected override void OnEntering(Screen last)

View File

@ -186,13 +186,18 @@ public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
public Action<BeatmapInfo> HideDifficultyRequested;
private void selectNullBeatmap()
{
selectedGroup = null;
selectedPanel = null;
SelectionChanged?.Invoke(null);
}
public void SelectNext(int direction = 1, bool skipDifficulties = true)
{
if (groups.All(g => g.State == BeatmapGroupState.Hidden))
{
selectedGroup = null;
selectedPanel = null;
SelectionChanged?.Invoke(null);
selectNullBeatmap();
return;
}
@ -383,6 +388,14 @@ private void removeGroup(BeatmapGroup group)
if (group == null)
return;
if (selectedGroup == group)
{
if (getVisibleGroups().Count() == 1)
selectNullBeatmap();
else
SelectNext();
}
groups.Remove(group);
panels.Remove(group.Header);
foreach (var p in group.BeatmapPanels)
@ -391,9 +404,6 @@ private void removeGroup(BeatmapGroup group)
scrollableContent.Remove(group.Header);
scrollableContent.RemoveRange(group.BeatmapPanels);
if (selectedGroup == group)
SelectNext();
computeYPositions();
}