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

Merge pull request #659 from peppy/general-fixes

Update UI controls to understand DisabledChanged
This commit is contained in:
Dean Herbert 2017-04-21 20:54:51 +09:00 committed by GitHub
commit 612c1b99de
18 changed files with 153 additions and 89 deletions

@ -1 +1 @@
Subproject commit e24091cf7f5bf25602306c11146326079f2a98b0 Subproject commit dc31d5bf4f10dd2a65a36a5461a0f422f41529d0

View File

@ -3,14 +3,13 @@
using System; using System;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Taiko.UI;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{ {
public class ElongatedCirclePiece : CirclePiece public class ElongatedCirclePiece : CirclePiece
{ {
/// <summary> /// <summary>
/// As we are being used to define the absolute size of hits, we need to be given a relative reference of our containing <see cref="TaikoPlayfield"/>. /// As we are being used to define the absolute size of hits, we need to be given a relative reference of our containing playfield container.
/// </summary> /// </summary>
public Func<float> PlayfieldLengthReference; public Func<float> PlayfieldLengthReference;
@ -38,4 +37,4 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
Width = (PlayfieldLengthReference?.Invoke() ?? 0) * Length + DrawHeight; Width = (PlayfieldLengthReference?.Invoke() ?? 0) * Length + DrawHeight;
} }
} }
} }

View File

@ -25,8 +25,6 @@ namespace osu.Game.Graphics.UserInterface
{ {
bindable = value; bindable = value;
Current.BindTo(bindable); Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
} }
} }
@ -84,6 +82,11 @@ namespace osu.Game.Graphics.UserInterface
else else
sampleUnchecked?.Play(); sampleUnchecked?.Play();
}; };
Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)

View File

@ -74,6 +74,11 @@ namespace osu.Game.Graphics.UserInterface
Expanded = true, Expanded = true,
} }
}; };
Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -33,6 +33,11 @@ namespace osu.Game.Graphics.UserInterface
Height = 40; Height = 40;
TextContainer.Height = 0.5f; TextContainer.Height = 0.5f;
CornerRadius = 5; CornerRadius = 5;
Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -203,13 +203,7 @@ namespace osu.Game
{ {
Depth = -3, Depth = -3,
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
OnRulesetChange = r => Ruleset.Value = r, }, overlayContent.Add);
}, t =>
{
Ruleset.ValueChanged += delegate { Toolbar.SetRuleset(Ruleset.Value); };
Ruleset.TriggerChange();
overlayContent.Add(Toolbar);
});
options.StateChanged += delegate options.StateChanged += delegate
{ {

View File

@ -147,8 +147,16 @@ namespace osu.Game
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
Cursor = new MenuCursor { Depth = float.MinValue }, new Container
new TooltipContainer(Cursor) { Depth = float.MinValue } {
RelativeSizeAxes = Axes.Both,
Depth = float.MinValue,
Children = new Drawable[]
{
Cursor = new MenuCursor(),
new TooltipContainer(Cursor) { Depth = -1 },
}
},
} }
}); });
} }

View File

@ -34,8 +34,6 @@ namespace osu.Game.Overlays.Options
{ {
bindable = value; bindable = value;
dropdown.Current.BindTo(bindable); dropdown.Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
} }
} }
@ -75,6 +73,11 @@ namespace osu.Game.Overlays.Options
Items = Items, Items = Items,
} }
}; };
dropdown.Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
} }
} }
} }

View File

@ -35,8 +35,6 @@ namespace osu.Game.Overlays.Options
{ {
bindable = value; bindable = value;
slider.Current.BindTo(bindable); slider.Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
} }
} }

View File

@ -16,9 +16,7 @@ namespace osu.Game.Overlays.Options
{ {
bindable = value; bindable = value;
Current.BindTo(bindable); Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
} }
} }
} }
} }

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using OpenTK; using OpenTK;
@ -20,9 +19,7 @@ namespace osu.Game.Overlays.Toolbar
public const float TOOLTIP_HEIGHT = 30; public const float TOOLTIP_HEIGHT = 30;
public Action OnHome; public Action OnHome;
public Action<RulesetInfo> OnRulesetChange;
private readonly ToolbarModeSelector modeSelector;
private readonly ToolbarUserArea userArea; private readonly ToolbarUserArea userArea;
protected override bool HideOnEscape => false; protected override bool HideOnEscape => false;
@ -53,13 +50,7 @@ namespace osu.Game.Overlays.Toolbar
{ {
Action = () => OnHome?.Invoke() Action = () => OnHome?.Invoke()
}, },
modeSelector = new ToolbarModeSelector new ToolbarModeSelector()
{
OnRulesetChange = mode =>
{
OnRulesetChange?.Invoke(mode);
}
}
} }
}, },
new FillFlowContainer new FillFlowContainer
@ -130,8 +121,6 @@ namespace osu.Game.Overlays.Toolbar
} }
} }
public void SetRuleset(RulesetInfo ruleset) => modeSelector.SetRuleset(ruleset);
protected override void PopIn() protected override void PopIn()
{ {
MoveToY(0, transition_time, EasingTypes.OutQuint); MoveToY(0, transition_time, EasingTypes.OutQuint);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Caching; using osu.Framework.Caching;
@ -12,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Database; using osu.Game.Database;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Toolbar
private readonly Drawable modeButtonLine; private readonly Drawable modeButtonLine;
private ToolbarModeButton activeButton; private ToolbarModeButton activeButton;
public Action<RulesetInfo> OnRulesetChange; private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public ToolbarModeSelector() public ToolbarModeSelector()
{ {
@ -66,30 +66,36 @@ namespace osu.Game.Overlays.Toolbar
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RulesetDatabase rulesets) private void load(RulesetDatabase rulesets, OsuGame game)
{ {
foreach (var ruleset in rulesets.AllRulesets) foreach (var r in rulesets.AllRulesets)
{ {
modeButtons.Add(new ToolbarModeButton modeButtons.Add(new ToolbarModeButton
{ {
Ruleset = ruleset, Ruleset = r,
Action = delegate Action = delegate
{ {
SetRuleset(ruleset); ruleset.Value = r;
OnRulesetChange?.Invoke(ruleset);
} }
}); });
} }
ruleset.ValueChanged += rulesetChanged;
ruleset.DisabledChanged += disabledChanged;
ruleset.BindTo(game.Ruleset);
} }
public override bool HandleInput => !ruleset.Disabled;
private void disabledChanged(bool isDisabled) => FadeColour(isDisabled ? Color4.Gray : Color4.White, 300);
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
Size = new Vector2(modeButtons.DrawSize.X, 1); Size = new Vector2(modeButtons.DrawSize.X, 1);
} }
public void SetRuleset(RulesetInfo ruleset) private void rulesetChanged(RulesetInfo ruleset)
{ {
foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>()) foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>())
{ {

View File

@ -1,22 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Judgements namespace osu.Game.Rulesets.Judgements
{ {
/// <summary> /// <summary>
/// Inidicates that the judgement this is attached to is a partial judgement and the scoring value may change. /// Inidicates that the judgement this is attached to is a partial judgement and the scoring value may change.
/// <para>
/// This judgement will be continually processed by <see cref="DrawableHitObject{TObject, TJudgement}.CheckJudgement(bool)"/>
/// unless the result is a miss and will trigger a full re-process of the <see cref="ScoreProcessor"/> when changed.
/// </para>
/// </summary> /// </summary>
public interface IPartialJudgement public interface IPartialJudgement
{ {
/// <summary> /// <summary>
/// Indicates that this partial judgement has changed and requires a full re-process of the <see cref="ScoreProcessor"/>. /// Indicates that this partial judgement has changed and requires reprocessing.
/// <para> /// <para>
/// This is set to false once the judgement has been re-processed. /// This is set to false once the judgement has been re-processed.
/// </para> /// </para>

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
namespace osu.Game.Screens namespace osu.Game.Screens
@ -25,8 +26,12 @@ namespace osu.Game.Screens
internal virtual bool HasLocalCursorDisplayed => false; internal virtual bool HasLocalCursorDisplayed => false;
internal virtual bool AllowRulesetChange => true;
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>(); private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public WorkingBeatmap Beatmap public WorkingBeatmap Beatmap
{ {
get get
@ -40,7 +45,7 @@ namespace osu.Game.Screens
} }
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGameBase game) private void load(OsuGameBase game, OsuGame osuGame)
{ {
if (game != null) if (game != null)
{ {
@ -52,11 +57,23 @@ namespace osu.Game.Screens
} }
beatmap.ValueChanged += OnBeatmapChanged; beatmap.ValueChanged += OnBeatmapChanged;
if (osuGame != null)
ruleset.BindTo(osuGame.Ruleset);
} }
/// <summary>
/// The global Beatmap was changed.
/// </summary>
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap) protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)
{ {
}
protected override void Update()
{
if (!IsCurrentScreen) return;
ruleset.Disabled = !AllowRulesetChange;
} }
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)

View File

@ -39,6 +39,8 @@ namespace osu.Game.Screens.Play
public bool IsPaused => !interpolatedSourceClock.IsRunning; public bool IsPaused => !interpolatedSourceClock.IsRunning;
internal override bool AllowRulesetChange => false;
public bool HasFailed { get; private set; } public bool HasFailed { get; private set; }
public int RestartCount; public int RestartCount;

View File

@ -27,6 +27,8 @@ namespace osu.Game.Screens.Play
private bool showOverlays = true; private bool showOverlays = true;
internal override bool ShowOverlays => showOverlays; internal override bool ShowOverlays => showOverlays;
internal override bool AllowRulesetChange => false;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
public PlayerLoader(Player player) public PlayerLoader(Player player)

View File

@ -31,6 +31,8 @@ namespace osu.Game.Screens.Ranking
private ResultModeTabControl modeChangeButtons; private ResultModeTabControl modeChangeButtons;
internal override bool AllowRulesetChange => false;
private Container currentPage; private Container currentPage;
private static readonly Vector2 background_blur = new Vector2(20); private static readonly Vector2 background_blur = new Vector2(20);

View File

@ -7,12 +7,15 @@ using osu.Framework.Screens;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Screens namespace osu.Game.Screens
{ {
@ -24,8 +27,8 @@ namespace osu.Game.Screens
protected virtual IEnumerable<Type> PossibleChildren => null; protected virtual IEnumerable<Type> PossibleChildren => null;
private readonly Container textContainer; private readonly FillFlowContainer textContainer;
private readonly Box box; private readonly Container boxContainer;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2"); protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
@ -40,13 +43,13 @@ namespace osu.Game.Screens
Content.Alpha = 0; Content.Alpha = 0;
textContainer.Position = new Vector2(DrawSize.X / 16, 0); textContainer.Position = new Vector2(DrawSize.X / 16, 0);
box.ScaleTo(0.2f); boxContainer.ScaleTo(0.2f);
box.RotateTo(-20); boxContainer.RotateTo(-20);
Content.Delay(300, true); Content.Delay(300, true);
box.ScaleTo(1, transition_time, EasingTypes.OutElastic); boxContainer.ScaleTo(1, transition_time, EasingTypes.OutElastic);
box.RotateTo(0, transition_time / 2, EasingTypes.OutQuint); boxContainer.RotateTo(0, transition_time / 2, EasingTypes.OutQuint);
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo); textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
Content.FadeIn(transition_time, EasingTypes.OutExpo); Content.FadeIn(transition_time, EasingTypes.OutExpo);
@ -82,36 +85,62 @@ namespace osu.Game.Screens
Children = new Drawable[] Children = new Drawable[]
{ {
box = new Box boxContainer = new Container
{ {
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.3f), Size = new Vector2(0.3f),
RelativeSizeAxes = Axes.Both,
CornerRadius = 20,
Masking = true,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Colour = getColourFor(GetType()), Children = new Drawable[]
Alpha = 1,
BlendingMode = BlendingMode.Additive,
},
textContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
{ {
new OsuSpriteText new Box
{ {
Text = GetType().Name, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre, Colour = getColourFor(GetType()),
TextSize = 50, Alpha = 0.2f,
BlendingMode = BlendingMode.Additive,
}, },
new OsuSpriteText textContainer = new FillFlowContainer
{ {
Text = GetType().Namespace, AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Position = new Vector2(0, 30) Direction = FillDirection.Vertical,
Children = new[]
{
new TextAwesome
{
Icon = FontAwesome.fa_universal_access,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 50,
},
new OsuSpriteText
{
Text = GetType().Name,
Colour = getColourFor(GetType()).Lighten(0.8f),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 50,
},
new OsuSpriteText
{
Text = "is not yet ready for use!",
TextSize = 20,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new OsuSpriteText
{
Text = "please check back a bit later.",
TextSize = 14,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
}
}, },
} }
}, },
@ -120,17 +149,15 @@ namespace osu.Game.Screens
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Alpha = 0, Alpha = 0,
Action = delegate { Action = Exit
Exit();
}
}, },
childModeButtons = new FillFlowContainer childModeButtons = new FillFlowContainer
{ {
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Y,
Size = new Vector2(0.1f, 1) Size = new Vector2(TwoLayerButton.SIZE_RETRACTED.X, 1)
} }
}; };
@ -138,14 +165,11 @@ namespace osu.Game.Screens
{ {
foreach (Type t in PossibleChildren) foreach (Type t in PossibleChildren)
{ {
childModeButtons.Add(new Button childModeButtons.Add(new ChildModeButton
{ {
Text = $@"{t.Name}", Text = $@"{t.Name}",
RelativeSizeAxes = Axes.X,
Size = new Vector2(1, 40),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BackgroundColour = getColourFor(t), BackgroundColour = getColourFor(t),
HoverColour = getColourFor(t).Lighten(0.2f),
Action = delegate Action = delegate
{ {
Push(Activator.CreateInstance(t) as Screen); Push(Activator.CreateInstance(t) as Screen);
@ -163,5 +187,21 @@ namespace osu.Game.Screens
byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255); byte b = (byte)MathHelper.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
return new Color4(r, g, b, 255); return new Color4(r, g, b, 255);
} }
public class ChildModeButton : TwoLayerButton
{
public ChildModeButton()
{
Icon = FontAwesome.fa_osu_right_o;
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
ActivationSound = audio.Sample.Get(@"Menu/menuhit");
}
}
} }
} }