1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 16:19:35 +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 osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Taiko.UI;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
public class ElongatedCirclePiece : CirclePiece
{
/// <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>
public Func<float> PlayfieldLengthReference;
@ -38,4 +37,4 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
Width = (PlayfieldLengthReference?.Invoke() ?? 0) * Length + DrawHeight;
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -147,8 +147,16 @@ namespace osu.Game
{
Children = new Drawable[]
{
Cursor = new MenuCursor { Depth = float.MinValue },
new TooltipContainer(Cursor) { Depth = float.MinValue }
new Container
{
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;
dropdown.Current.BindTo(bindable);
if (value?.Disabled ?? true)
Alpha = 0.3f;
}
}
@ -75,6 +73,11 @@ namespace osu.Game.Overlays.Options
Items = Items,
}
};
dropdown.Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
}
}
}

View File

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

View File

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

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Caching;
@ -12,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Toolbar
{
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Toolbar
private readonly Drawable modeButtonLine;
private ToolbarModeButton activeButton;
public Action<RulesetInfo> OnRulesetChange;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public ToolbarModeSelector()
{
@ -66,30 +66,36 @@ namespace osu.Game.Overlays.Toolbar
}
[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
{
Ruleset = ruleset,
Ruleset = r,
Action = delegate
{
SetRuleset(ruleset);
OnRulesetChange?.Invoke(ruleset);
ruleset.Value = r;
}
});
}
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()
{
base.Update();
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>())
{

View File

@ -1,22 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
/// <summary>
/// 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>
public interface IPartialJudgement
{
/// <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>
/// This is set to false once the judgement has been re-processed.
/// </para>

View File

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

View File

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

View File

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

View File

@ -31,6 +31,8 @@ namespace osu.Game.Screens.Ranking
private ResultModeTabControl modeChangeButtons;
internal override bool AllowRulesetChange => false;
private Container currentPage;
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.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Backgrounds;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Screens
{
@ -24,8 +27,8 @@ namespace osu.Game.Screens
protected virtual IEnumerable<Type> PossibleChildren => null;
private readonly Container textContainer;
private readonly Box box;
private readonly FillFlowContainer textContainer;
private readonly Container boxContainer;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
@ -40,13 +43,13 @@ namespace osu.Game.Screens
Content.Alpha = 0;
textContainer.Position = new Vector2(DrawSize.X / 16, 0);
box.ScaleTo(0.2f);
box.RotateTo(-20);
boxContainer.ScaleTo(0.2f);
boxContainer.RotateTo(-20);
Content.Delay(300, true);
box.ScaleTo(1, transition_time, EasingTypes.OutElastic);
box.RotateTo(0, transition_time / 2, EasingTypes.OutQuint);
boxContainer.ScaleTo(1, transition_time, EasingTypes.OutElastic);
boxContainer.RotateTo(0, transition_time / 2, EasingTypes.OutQuint);
textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo);
Content.FadeIn(transition_time, EasingTypes.OutExpo);
@ -82,36 +85,62 @@ namespace osu.Game.Screens
Children = new Drawable[]
{
box = new Box
boxContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.3f),
RelativeSizeAxes = Axes.Both,
CornerRadius = 20,
Masking = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = getColourFor(GetType()),
Alpha = 1,
BlendingMode = BlendingMode.Additive,
},
textContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
Children = new Drawable[]
{
new OsuSpriteText
new Box
{
Text = GetType().Name,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 50,
RelativeSizeAxes = Axes.Both,
Colour = getColourFor(GetType()),
Alpha = 0.2f,
BlendingMode = BlendingMode.Additive,
},
new OsuSpriteText
textContainer = new FillFlowContainer
{
Text = GetType().Namespace,
AutoSizeAxes = Axes.Both,
Anchor = 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,
Origin = Anchor.BottomLeft,
Alpha = 0,
Action = delegate {
Exit();
}
Action = Exit
},
childModeButtons = new FillFlowContainer
{
Direction = FillDirection.Vertical,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.1f, 1)
RelativeSizeAxes = Axes.Y,
Size = new Vector2(TwoLayerButton.SIZE_RETRACTED.X, 1)
}
};
@ -138,14 +165,11 @@ namespace osu.Game.Screens
{
foreach (Type t in PossibleChildren)
{
childModeButtons.Add(new Button
childModeButtons.Add(new ChildModeButton
{
Text = $@"{t.Name}",
RelativeSizeAxes = Axes.X,
Size = new Vector2(1, 40),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BackgroundColour = getColourFor(t),
HoverColour = getColourFor(t).Lighten(0.2f),
Action = delegate
{
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);
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");
}
}
}
}