mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Fix password icon not disappearing when no password
This commit is contained in:
parent
892d858d5f
commit
57a99886d5
@ -2,8 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
@ -47,5 +51,27 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEnableAndDisablePassword()
|
||||
{
|
||||
DrawableRoom drawableRoom = null;
|
||||
Room room = null;
|
||||
|
||||
AddStep("create room", () => Child = drawableRoom = new DrawableRoom(room = new Room
|
||||
{
|
||||
Name = { Value = "Room with password" },
|
||||
Status = { Value = new RoomStatusOpen() },
|
||||
Category = { Value = RoomCategory.Realtime },
|
||||
}) { MatchingFilter = true });
|
||||
|
||||
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
||||
|
||||
AddStep("set password", () => room.Password.Value = "password");
|
||||
AddAssert("password icon visible", () => Precision.AlmostEquals(1, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
||||
|
||||
AddStep("unset password", () => room.Password.Value = string.Empty);
|
||||
AddAssert("password icon hidden", () => Precision.AlmostEquals(0, drawableRoom.ChildrenOfType<DrawableRoom.PasswordProtectedIcon>().Single().Alpha));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
[Resolved(canBeNull: true)]
|
||||
private LoungeSubScreen lounge { get; set; }
|
||||
|
||||
private Container content;
|
||||
|
||||
public readonly Room Room;
|
||||
|
||||
private SelectionState state;
|
||||
@ -105,6 +103,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
private PasswordProtectedIcon passwordIcon;
|
||||
|
||||
private readonly Bindable<bool> hasPassword = new Bindable<bool>();
|
||||
|
||||
public DrawableRoom(Room room)
|
||||
{
|
||||
Room = room;
|
||||
@ -138,7 +140,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(SELECTION_BORDER_WIDTH),
|
||||
Child = content = new Container
|
||||
Child = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
@ -214,15 +216,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
},
|
||||
},
|
||||
},
|
||||
passwordIcon = new PasswordProtectedIcon { Alpha = 0 }
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (Room.HasPassword.Value)
|
||||
{
|
||||
content.Add(new PasswordProtectedIcon());
|
||||
}
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
@ -241,6 +239,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
this.FadeInFromZero(transition_duration);
|
||||
else
|
||||
Alpha = 0;
|
||||
|
||||
hasPassword.BindTo(Room.HasPassword);
|
||||
hasPassword.BindValueChanged(v => passwordIcon.Alpha = v.NewValue ? 1 : 0, true);
|
||||
}
|
||||
|
||||
public Popover GetPopover() => new PasswordEntryPopover(Room) { JoinRequested = lounge.Join };
|
||||
@ -313,7 +314,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
}
|
||||
}
|
||||
|
||||
private class PasswordProtectedIcon : CompositeDrawable
|
||||
public class PasswordProtectedIcon : CompositeDrawable
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
|
Loading…
Reference in New Issue
Block a user