Adjust styling of disabled settings

This commit is contained in:
smoogipoo 2018-12-22 15:00:35 +09:00
parent 34fc740e1f
commit 6afd2f7263
3 changed files with 18 additions and 13 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 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.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
@ -10,6 +12,11 @@ namespace osu.Game.Tests.Visual
{ {
public class TestCaseMatchSettingsOverlay : OsuTestCase public class TestCaseMatchSettingsOverlay : OsuTestCase
{ {
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RoomSettingsOverlay)
};
public TestCaseMatchSettingsOverlay() public TestCaseMatchSettingsOverlay()
{ {
Child = new RoomSettingsOverlay(new Room()) Child = new RoomSettingsOverlay(new Room())

View File

@ -4,39 +4,32 @@
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osuTK.Graphics;
namespace osu.Game.Screens.Multi.Components namespace osu.Game.Screens.Multi.Components
{ {
public abstract class DisableableTabControl<T> : TabControl<T> public abstract class DisableableTabControl<T> : TabControl<T>
{ {
public readonly BindableBool ReadOnly = new BindableBool(); public readonly BindableBool Enabled = new BindableBool();
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true) protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
{ {
if (tab is DisableableTabItem<T> disableable) if (tab is DisableableTabItem<T> disableable)
disableable.ReadOnly.BindTo(ReadOnly); disableable.Enabled.BindTo(Enabled);
base.AddTabItem(tab, addToDropdown); base.AddTabItem(tab, addToDropdown);
} }
protected abstract class DisableableTabItem<T> : TabItem<T> protected abstract class DisableableTabItem<T> : TabItem<T>
{ {
public readonly BindableBool ReadOnly = new BindableBool(); public readonly BindableBool Enabled = new BindableBool();
protected DisableableTabItem(T value) protected DisableableTabItem(T value)
: base(value) : base(value)
{ {
ReadOnly.BindValueChanged(updateReadOnly);
}
private void updateReadOnly(bool readOnly)
{
Colour = readOnly ? Color4.Gray : Color4.White;
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
if (ReadOnly) if (!Enabled)
return true; return true;
return base.OnClick(e); return base.OnClick(e);
} }

View File

@ -22,6 +22,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
private const float transition_duration = 350; private const float transition_duration = 350;
private const float field_padding = 45; private const float field_padding = 45;
private const float disabled_alpha = 0.2f;
private readonly RoomBindings bindings = new RoomBindings(); private readonly RoomBindings bindings = new RoomBindings();
@ -82,10 +83,12 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
new Section("ROOM VISIBILITY") new Section("ROOM VISIBILITY")
{ {
Alpha = disabled_alpha,
Child = AvailabilityPicker = new RoomAvailabilityPicker(), Child = AvailabilityPicker = new RoomAvailabilityPicker(),
}, },
new Section("GAME TYPE") new Section("GAME TYPE")
{ {
Alpha = disabled_alpha,
Child = new FillFlowContainer Child = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -116,6 +119,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{ {
new Section("MAX PARTICIPANTS") new Section("MAX PARTICIPANTS")
{ {
Alpha = disabled_alpha,
Child = MaxParticipantsField = new SettingsNumberTextBox Child = MaxParticipantsField = new SettingsNumberTextBox
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -146,6 +150,7 @@ namespace osu.Game.Screens.Multi.Match.Components
}, },
new Section("PASSWORD (OPTIONAL)") new Section("PASSWORD (OPTIONAL)")
{ {
Alpha = disabled_alpha,
Child = PasswordField = new SettingsPasswordTextBox Child = PasswordField = new SettingsPasswordTextBox
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -199,8 +204,8 @@ namespace osu.Game.Screens.Multi.Match.Components
MaxParticipantsField.ReadOnly = true; MaxParticipantsField.ReadOnly = true;
PasswordField.ReadOnly = true; PasswordField.ReadOnly = true;
AvailabilityPicker.ReadOnly.Value = true; AvailabilityPicker.Enabled.Value = false;
TypePicker.ReadOnly.Value = true; TypePicker.Enabled.Value = false;
ApplyButton.Enabled.Value = false; ApplyButton.Enabled.Value = false;
} }