Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel selection overlay #861

Merged
merged 52 commits into from Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
31890a1
Initial layout, channels items
DrabWeb May 20, 2017
6a8d745
Use Channels in ChannelListItems, ChannelSection, fix ChannelListItem…
DrabWeb May 20, 2017
3cc5100
Add settings button, background triangles, proper displaying of Channels
DrabWeb May 20, 2017
7eba619
Move Joined to Channel
DrabWeb May 20, 2017
47dfc0d
Added transition
DrabWeb May 20, 2017
2e1d01a
Added searching
DrabWeb May 20, 2017
4a166c1
Make ChannelSelectionOverlay a FocusedOverlayContainer
DrabWeb May 20, 2017
a60d1ef
Basic channel joining (ignore layout in ChatOverlay, temporary)
DrabWeb May 21, 2017
51bc3df
Padding below channel list, remove text shadows, fix search box focusing
DrabWeb May 21, 2017
62897d3
Remove SettingsButton(old and outdated design), fix channel list scro…
DrabWeb May 23, 2017
64016f9
Merge https://github.com/ppy/osu into channel-selection
DrabWeb May 26, 2017
fb0b54e
Remove merge error
DrabWeb May 26, 2017
d29ebb1
Cleanup
DrabWeb May 26, 2017
21e900d
Transition code cleanup
DrabWeb May 26, 2017
d632435
Make ChannelListItems scale better
DrabWeb May 26, 2017
4c55127
Add OnRequestLeave
DrabWeb May 26, 2017
ae96ef0
Tab character
DrabWeb May 26, 2017
38d0138
CI fixes
DrabWeb May 26, 2017
b632e7f
Accept Channel in ctor and remove Channel property
DrabWeb May 27, 2017
754fe95
Make ChannelSection headers uppercase in the setter
DrabWeb May 27, 2017
b88c07f
Make channel readonly
DrabWeb May 27, 2017
21a8071
Merge https://github.com/ppy/osu into channel-selection
DrabWeb May 29, 2017
50e50ce
Update with framework changes
DrabWeb May 29, 2017
745e2e5
Make the channel selection overlay hide/resize with chat
DrabWeb May 30, 2017
d29bf58
Show scroll dragger
DrabWeb May 30, 2017
d8e86da
Better scroll dragger position
DrabWeb May 30, 2017
2ba86cf
Channel list item hover effect
DrabWeb May 30, 2017
b9292b6
Merge https://github.com/ppy/osu into channel-selection
DrabWeb May 30, 2017
96efa5a
Hook up to channel selector tab item
DrabWeb May 30, 2017
2edbf64
Redundant parentheses
DrabWeb May 30, 2017
d970430
Fix the channel selector not appearing if the chat is scaled up too t…
DrabWeb Jun 1, 2017
6176f1d
Make the transition when chat is too tall and opening the channel sel…
DrabWeb Jun 1, 2017
e7bf1e0
Merge https://github.com/ppy/osu into channel-selection
DrabWeb Jun 1, 2017
52d524a
Update with framework changes
DrabWeb Jun 1, 2017
32f98ca
Don't autohide the channel list if the chat is too tall
DrabWeb Jun 1, 2017
c2d1a44
Fix channel selection not getting focus
DrabWeb Jun 1, 2017
d728c87
Fix janky opening transition when resizing the chat and reopening the…
DrabWeb Jun 1, 2017
a707d63
Fix visual errors if spamming close/open on channel list
DrabWeb Jun 1, 2017
fad5b4c
Speed up animations
DrabWeb Jun 1, 2017
ecb0c2f
Cleanup ChannelListItem Joined binding
DrabWeb Jun 1, 2017
24b3ec7
Fix tab background not fading
DrabWeb Jun 1, 2017
697fab9
Reselect the chosen tab when closing the channel list
DrabWeb Jun 1, 2017
62ada0a
Make the add tab item unselectable and toggle the channel list
DrabWeb Jun 1, 2017
90dabe0
Fix the channel list appearing behind the tab bar
DrabWeb Jun 2, 2017
1fa7016
Fix channel list occasioanlly taking clicks when not open
DrabWeb Jun 2, 2017
d81ff9c
Add visual states for ChannelSelectorTabItem
DrabWeb Jun 2, 2017
c13e807
Redundant parenthesis
DrabWeb Jun 2, 2017
778865b
Merge remote-tracking branch 'upstream/master' into channel-selection
peppy Jun 5, 2017
16fcfc4
Fix toggle not toggling on pressing escape
peppy Jun 5, 2017
57aad13
Merge branch 'master' into channel-selection
peppy Jun 5, 2017
d9106c4
Temporarily disable inspection
peppy Jun 5, 2017
6b7e18a
Fix not being able to change channels when channel select dialog is up
peppy Jun 5, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion osu.Game/Online/Chat/Channel.cs
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Configuration;
using osu.Framework.Lists;

namespace osu.Game.Online.Chat
Expand All @@ -25,7 +26,7 @@ public class Channel

public readonly SortedList<Message> Messages = new SortedList<Message>(Comparer<Message>.Default);

//internal bool Joined;
public Bindable<bool> Joined = new Bindable<bool>();

public bool ReadOnly => Name != "#lazer";

Expand Down
174 changes: 174 additions & 0 deletions osu.Game/Overlays/Chat/ChannelListItem.cs
@@ -0,0 +1,174 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;

namespace osu.Game.Overlays.Chat
{
public class ChannelListItem : ClickableContainer, IFilterable
{
private const float width_padding = 5;
private const float channel_width = 150;
private const float text_size = 15;
private const float transition_duration = 100;

private readonly Channel channel;

private readonly OsuSpriteText topic;
private readonly TextAwesome joinedCheckmark;

private Color4? joinedColour;

This comment was marked as off-topic.

private Color4? topicColour;

public string[] FilterTerms => new[] { channel.Name };
public bool MatchingCurrentFilter
{
set
{
FadeTo(value ? 1f : 0f, 100);
}
}

public Action<Channel> OnRequestJoin;
public Action<Channel> OnRequestLeave;

public ChannelListItem(Channel channel)
{
this.channel = channel;

RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

Action = () => { (channel.Joined ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); };

Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new Container
{
Children = new[]
{
joinedCheckmark = new TextAwesome
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Icon = FontAwesome.fa_check_circle,
TextSize = text_size,
Shadow = false,
Margin = new MarginPadding { Right = 10f },
Alpha = 0f,
},
},
},
new Container
{
Width = channel_width,
AutoSizeAxes = Axes.Y,
Children = new[]
{
new OsuSpriteText
{
Text = channel.ToString(),
TextSize = text_size,
Font = @"Exo2.0-Bold",
Shadow = false,
},
},
},
new Container
{
RelativeSizeAxes = Axes.X,
Width = 0.7f,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Left = width_padding },
Children = new[]
{
topic = new OsuSpriteText
{
Text = channel.Topic,
TextSize = text_size,
Font = @"Exo2.0-SemiBold",
Shadow = false,
Alpha = 0.8f,
},
},
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Left = width_padding },
Spacing = new Vector2(3f, 0f),
Children = new Drawable[]
{
new TextAwesome
{
Icon = FontAwesome.fa_user,
TextSize = text_size - 2,
Shadow = false,
Margin = new MarginPadding { Top = 1 },
},
new OsuSpriteText
{
Text = @"0",
TextSize = text_size,
Font = @"Exo2.0-SemiBold",
Shadow = false,
},
},
},
},
},
};

channel.Joined.ValueChanged += updateColour;
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
topicColour = colours.Gray9;
joinedColour = colours.Blue;

updateColour(channel.Joined);
}

protected override void Dispose(bool isDisposing)
{
if(channel != null) channel.Joined.ValueChanged -= updateColour;

This comment was marked as off-topic.

base.Dispose(isDisposing);
}

private void updateColour(bool joined)
{
if (joined)
{
joinedCheckmark.FadeTo(1f, transition_duration);
topic.FadeTo(0.8f, transition_duration);
topic.FadeColour(Color4.White, transition_duration);
FadeColour(joinedColour ?? Color4.White, transition_duration);
}
else
{
joinedCheckmark.FadeTo(0f, transition_duration);
topic.FadeTo(1f, transition_duration);
topic.FadeColour(topicColour ?? Color4.White, transition_duration);
FadeColour(Color4.White, transition_duration);
}
}
}
}
63 changes: 63 additions & 0 deletions osu.Game/Overlays/Chat/ChannelSection.cs
@@ -0,0 +1,63 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System.Collections.Generic;
using System.Linq;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;

namespace osu.Game.Overlays.Chat
{
public class ChannelSection : Container, IHasFilterableChildren
{
private readonly OsuSpriteText header;

public readonly FillFlowContainer<ChannelListItem> ChannelFlow;

public IEnumerable<IFilterable> FilterableChildren => ChannelFlow.Children;
public string[] FilterTerms => new[] { Header };
public bool MatchingCurrentFilter
{
set
{
FadeTo(value ? 1f : 0f, 100);
}
}

public string Header
{
get { return header.Text; }
set { header.Text = value.ToUpper(); }
}

public IEnumerable<Channel> Channels
{
set { ChannelFlow.Children = value.Select(c => new ChannelListItem(c)); }
}

public ChannelSection()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

Children = new Drawable[]
{
header = new OsuSpriteText
{
TextSize = 15,
Font = @"Exo2.0-Bold",
},
ChannelFlow = new FillFlowContainer<ChannelListItem>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 25 },
Spacing = new Vector2(0f, 5f),
},
};
}
}
}