mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 00:37:18 +08:00
Revert DI usage of ChannelSelectorState
in favour of directly binding BindableBool
SelectorActive
This commit is contained in:
parent
e596c9d171
commit
5319bce772
@ -25,9 +25,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Cached]
|
||||
private readonly Bindable<Channel> selected = new Bindable<Channel>();
|
||||
|
||||
[Cached]
|
||||
private readonly Bindable<ChannelSelectorState> selector = new Bindable<ChannelSelectorState>();
|
||||
|
||||
private OsuSpriteText selectorText;
|
||||
private OsuSpriteText selectedText;
|
||||
private OsuSpriteText leaveText;
|
||||
@ -92,7 +89,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
channelList.OnRequestSelect += channel =>
|
||||
{
|
||||
selector.Value = ChannelSelectorState.Hidden;
|
||||
channelList.SelectorActive.Value = false;
|
||||
selected.Value = channel;
|
||||
};
|
||||
|
||||
@ -104,9 +101,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
channelList.RemoveChannel(channel);
|
||||
};
|
||||
|
||||
selector.BindValueChanged(change =>
|
||||
channelList.SelectorActive.BindValueChanged(change =>
|
||||
{
|
||||
selectorText.Text = $"Channel Selector State: {change.NewValue}";
|
||||
selectorText.Text = $"Channel Selector Active: {change.NewValue}";
|
||||
}, true);
|
||||
|
||||
selected.BindValueChanged(change =>
|
||||
|
@ -56,6 +56,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
new ChannelListSelector
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
SelectorActive = { BindTarget = SelectorActive },
|
||||
},
|
||||
privateChannelFlow = new ChannelListItemFlow("DIRECT MESSAGES"),
|
||||
},
|
||||
@ -72,6 +73,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
ChannelListItem item = new ChannelListItem(channel);
|
||||
item.OnRequestSelect += chan => OnRequestSelect?.Invoke(chan);
|
||||
item.OnRequestLeave += chan => OnRequestLeave?.Invoke(chan);
|
||||
item.SelectorActive.BindTarget = SelectorActive;
|
||||
|
||||
ChannelListItemFlow flow = getFlowForChannel(channel);
|
||||
channelMap.Add(channel, item);
|
||||
@ -130,10 +132,4 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ChannelSelectorState
|
||||
{
|
||||
Visibile,
|
||||
Hidden,
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
public readonly BindableBool Unread = new BindableBool();
|
||||
|
||||
public readonly BindableBool SelectorActive = new BindableBool();
|
||||
|
||||
private readonly Channel channel;
|
||||
|
||||
private Box hoverBox = null!;
|
||||
@ -39,9 +41,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
[Resolved]
|
||||
private Bindable<Channel> selectedChannel { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<ChannelSelectorState> selectorState { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
@ -128,7 +127,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
base.LoadComplete();
|
||||
|
||||
selectedChannel.BindValueChanged(_ => updateSelectState(), true);
|
||||
selectorState.BindValueChanged(_ => updateSelectState(), true);
|
||||
SelectorActive.BindValueChanged(_ => updateSelectState(), true);
|
||||
|
||||
Unread.BindValueChanged(change =>
|
||||
{
|
||||
@ -168,7 +167,7 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
|
||||
private void updateSelectState()
|
||||
{
|
||||
if (selectedChannel.Value == channel && selectorState.Value == ChannelSelectorState.Hidden)
|
||||
if (selectedChannel.Value == channel && !SelectorActive.Value)
|
||||
selectBox.FadeIn(300, Easing.OutQuint);
|
||||
else
|
||||
selectBox.FadeOut(200, Easing.OutQuint);
|
||||
|
@ -22,9 +22,6 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
private Box hoverBox = null!;
|
||||
private Box selectBox = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<ChannelSelectorState> selectorState { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
@ -68,15 +65,15 @@ namespace osu.Game.Overlays.Chat.ChannelList
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
selectorState.BindValueChanged(selector =>
|
||||
SelectorActive.BindValueChanged(selector =>
|
||||
{
|
||||
if (selector.NewValue == ChannelSelectorState.Visibile)
|
||||
if (selector.NewValue)
|
||||
selectBox.FadeIn(300, Easing.OutQuint);
|
||||
else
|
||||
selectBox.FadeOut(200, Easing.OutQuint);
|
||||
}, true);
|
||||
|
||||
Action = () => selectorState.Value = ChannelSelectorState.Visibile;
|
||||
Action = () => SelectorActive.Value = true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user