mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Reorder class attributes
This commit is contained in:
parent
a3477c3841
commit
7dd51a9c4a
@ -30,27 +30,7 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
private SearchContainer<ChannelListingItem> flow = null!;
|
private SearchContainer<ChannelListingItem> flow = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider overlayColours { get; set; } = null!;
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
public ChannelListing()
|
|
||||||
{
|
|
||||||
Masking = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn();
|
|
||||||
protected override void PopOut() => this.FadeOut();
|
|
||||||
|
|
||||||
public void UpdateAvailableChannels(IEnumerable<Channel> newChannels)
|
|
||||||
{
|
|
||||||
flow.ChildrenEnumerable = newChannels.Where(c => c.Type == ChannelType.Public)
|
|
||||||
.Select(c => new ChannelListingItem(c));
|
|
||||||
|
|
||||||
foreach (var item in flow.Children)
|
|
||||||
{
|
|
||||||
item.OnRequestJoin += channel => OnRequestJoin?.Invoke(channel);
|
|
||||||
item.OnRequestLeave += channel => OnRequestLeave?.Invoke(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -60,7 +40,7 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = overlayColours.Background4,
|
Colour = colourProvider.Background4,
|
||||||
},
|
},
|
||||||
new OsuScrollContainer
|
new OsuScrollContainer
|
||||||
{
|
{
|
||||||
@ -81,5 +61,21 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateAvailableChannels(IEnumerable<Channel> newChannels)
|
||||||
|
{
|
||||||
|
flow.ChildrenEnumerable = newChannels.Where(c => c.Type == ChannelType.Public)
|
||||||
|
.Select(c => new ChannelListingItem(c));
|
||||||
|
|
||||||
|
foreach (var item in flow.Children)
|
||||||
|
{
|
||||||
|
item.OnRequestJoin += channel => OnRequestJoin?.Invoke(channel);
|
||||||
|
item.OnRequestLeave += channel => OnRequestLeave?.Invoke(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn() => this.FadeIn();
|
||||||
|
|
||||||
|
protected override void PopOut() => this.FadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,13 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
|
|
||||||
public bool FilteringActive { get; set; }
|
public bool FilteringActive { get; set; }
|
||||||
public IEnumerable<string> FilterTerms => new[] { channel.Name, channel.Topic ?? string.Empty };
|
public IEnumerable<string> FilterTerms => new[] { channel.Name, channel.Topic ?? string.Empty };
|
||||||
public bool MatchingFilter
|
public bool MatchingFilter { set => this.FadeTo(value ? 1f : 0f, 100); }
|
||||||
{
|
|
||||||
set => this.FadeTo(value ? 1f : 0f, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly float TEXT_SIZE = 18;
|
|
||||||
private readonly float ICON_SIZE = 14;
|
|
||||||
private readonly Channel channel;
|
private readonly Channel channel;
|
||||||
|
|
||||||
|
private const float TEXT_SIZE = 18;
|
||||||
|
private const float ICON_SIZE = 14;
|
||||||
|
|
||||||
private Colour4 selectedColour;
|
private Colour4 selectedColour;
|
||||||
private Colour4 normalColour;
|
private Colour4 normalColour;
|
||||||
|
|
||||||
@ -45,73 +43,33 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
private IBindable<bool> channelJoined = null!;
|
private IBindable<bool> channelJoined = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider overlayColours { get; set; } = null!;
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
public ChannelListingItem(Channel channel)
|
public ChannelListingItem(Channel channel)
|
||||||
{
|
{
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = 5;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
Height = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
hoverBox.Show();
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
hoverBox.Hide();
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
// Set colours
|
|
||||||
normalColour = overlayColours.Light3;
|
|
||||||
selectedColour = Colour4.White;
|
|
||||||
|
|
||||||
// Set handlers for state display
|
|
||||||
channelJoined = channel.Joined.GetBoundCopy();
|
|
||||||
channelJoined.BindValueChanged(change =>
|
|
||||||
{
|
|
||||||
if (change.NewValue)
|
|
||||||
{
|
|
||||||
checkbox.Show();
|
|
||||||
channelText.Colour = selectedColour;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
checkbox.Hide();
|
|
||||||
channelText.Colour = normalColour;
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
// Set action on click
|
|
||||||
Action = () => (channelJoined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = 5;
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Height = 20;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
hoverBox = new Box
|
hoverBox = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = overlayColours.Background3,
|
Colour = colourProvider.Background3,
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
},
|
},
|
||||||
new GridContainer
|
new GridContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ColumnDimensions = new Dimension[]
|
ColumnDimensions = new[]
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.Absolute, 40),
|
new Dimension(GridSizeMode.Absolute, 40),
|
||||||
new Dimension(GridSizeMode.Absolute, 200),
|
new Dimension(GridSizeMode.Absolute, 200),
|
||||||
@ -155,7 +113,7 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
Icon = FontAwesome.Solid.User,
|
Icon = FontAwesome.Solid.User,
|
||||||
Size = new Vector2(ICON_SIZE),
|
Size = new Vector2(ICON_SIZE),
|
||||||
Margin = new MarginPadding { Right = 5 },
|
Margin = new MarginPadding { Right = 5 },
|
||||||
Colour = overlayColours.Light3,
|
Colour = colourProvider.Light3,
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -164,12 +122,52 @@ namespace osu.Game.Overlays.NewChat
|
|||||||
Text = "0",
|
Text = "0",
|
||||||
Font = OsuFont.Numeric.With(size: TEXT_SIZE, weight: FontWeight.Medium),
|
Font = OsuFont.Numeric.With(size: TEXT_SIZE, weight: FontWeight.Medium),
|
||||||
Margin = new MarginPadding { Bottom = 2 },
|
Margin = new MarginPadding { Bottom = 2 },
|
||||||
Colour = overlayColours.Light3,
|
Colour = colourProvider.Light3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
// Set colours
|
||||||
|
normalColour = colourProvider.Light3;
|
||||||
|
selectedColour = Colour4.White;
|
||||||
|
|
||||||
|
// Set handlers for state display
|
||||||
|
channelJoined = channel.Joined.GetBoundCopy();
|
||||||
|
channelJoined.BindValueChanged(change =>
|
||||||
|
{
|
||||||
|
if (change.NewValue)
|
||||||
|
{
|
||||||
|
checkbox.Show();
|
||||||
|
channelText.Colour = selectedColour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkbox.Hide();
|
||||||
|
channelText.Colour = normalColour;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
// Set action on click
|
||||||
|
Action = () => (channelJoined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
hoverBox.Show();
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
hoverBox.Hide();
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user