Disable RulesetToggleButton whenever the ruleset can't be changed

This commit is contained in:
TocoToucan 2018-04-29 18:36:19 +03:00
parent 306f05b7bd
commit ca574f2345
2 changed files with 9 additions and 5 deletions

View File

@ -49,14 +49,14 @@ namespace osu.Game.Overlays.Direct
{ {
private Drawable icon private Drawable icon
{ {
get { return iconContainer.Icon; } get => iconContainer.Icon;
set { iconContainer.Icon = value; } set => iconContainer.Icon = value;
} }
private RulesetInfo ruleset; private RulesetInfo ruleset;
public RulesetInfo Ruleset public RulesetInfo Ruleset
{ {
get { return ruleset; } get => ruleset;
set set
{ {
ruleset = value; ruleset = value;
@ -73,6 +73,9 @@ namespace osu.Game.Overlays.Direct
iconContainer.FadeTo(Ruleset.ID == obj?.ID ? 1f : 0.5f, 100); iconContainer.FadeTo(Ruleset.ID == obj?.ID ? 1f : 0.5f, 100);
} }
public override bool HandleKeyboardInput => !bindable.Disabled && base.HandleKeyboardInput;
public override bool HandleMouseInput => !bindable.Disabled && base.HandleMouseInput;
public RulesetToggleButton(Bindable<RulesetInfo> bindable, RulesetInfo ruleset) public RulesetToggleButton(Bindable<RulesetInfo> bindable, RulesetInfo ruleset)
{ {
this.bindable = bindable; this.bindable = bindable;
@ -90,6 +93,7 @@ namespace osu.Game.Overlays.Direct
Ruleset = ruleset; Ruleset = ruleset;
bindable.ValueChanged += Bindable_ValueChanged; bindable.ValueChanged += Bindable_ValueChanged;
bindable.DisabledChanged += isDisabled => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300);
Bindable_ValueChanged(bindable.Value); Bindable_ValueChanged(bindable.Value);
Action = () => bindable.Value = Ruleset; Action = () => bindable.Value = Ruleset;
} }

View File

@ -87,8 +87,8 @@ namespace osu.Game.Overlays.Toolbar
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(); ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
} }
public override bool HandleKeyboardInput => !ruleset.Disabled; public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput;
public override bool HandleMouseInput => !ruleset.Disabled; public override bool HandleMouseInput => !ruleset.Disabled && base.HandleMouseInput;
private void disabledChanged(bool isDisabled) => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300); private void disabledChanged(bool isDisabled) => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300);