Beispiel #1
0
        public ChatOverlay()
        {
            RelativeSizeAxes     = Axes.Both;
            RelativePositionAxes = Axes.Both;
            Anchor = Anchor.BottomLeft;
            Origin = Anchor.BottomLeft;

            const float padding = 5;

            Children = new Drawable[]
            {
                channelSelectionContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Height           = 1f - DEFAULT_HEIGHT,
                    Masking          = true,
                    Children         = new[]
                    {
                        channelSelection = new ChannelSelectionOverlay
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                chatContainer = new Container
                {
                    Name             = @"chat container",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Height           = DEFAULT_HEIGHT,
                    Children         = new[]
                    {
                        new Container
                        {
                            Name             = @"chat area",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = TAB_AREA_HEIGHT
                            },
                            Children = new Drawable[]
                            {
                                chatBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                currentChannelContainer = new Container <DrawableChannel>
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding
                                    {
                                        Bottom = textbox_height
                                    },
                                },
                                new Container
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    RelativeSizeAxes = Axes.X,
                                    Height           = textbox_height,
                                    Padding          = new MarginPadding
                                    {
                                        Top    = padding * 2,
                                        Bottom = padding * 2,
                                        Left   = ChatLine.LEFT_PADDING + padding * 2,
                                        Right  = padding * 2,
                                    },
                                    Children = new Drawable[]
                                    {
                                        textbox = new FocusedTextBox
                                        {
                                            RelativeSizeAxes     = Axes.Both,
                                            Height               = 1,
                                            PlaceholderText      = "type your message",
                                            Exit                 = () => State = Visibility.Hidden,
                                            OnCommit             = postMessage,
                                            ReleaseFocusOnCommit = false,
                                            HoldFocus            = true,
                                        }
                                    }
                                },
                                loading = new LoadingAnimation(),
                            }
                        },
                        tabsArea = new Container
                        {
                            Name             = @"tabs area",
                            RelativeSizeAxes = Axes.X,
                            Height           = TAB_AREA_HEIGHT,
                            Children         = new Drawable[]
                            {
                                tabBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                },
                                channelTabs = new ChatTabControl
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    OnRequestLeave   = removeChannel,
                                },
                            }
                        },
                    },
                },
            };

            channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel;
            channelTabs.ChannelSelectorActive.ValueChanged += value => channelSelection.State = value ? Visibility.Visible : Visibility.Hidden;
            channelSelection.StateChanged += state =>
            {
                channelTabs.ChannelSelectorActive.Value = state == Visibility.Visible;

                if (state == Visibility.Visible)
                {
                    textbox.HoldFocus = false;
                    if (1f - ChatHeight.Value < channel_selection_min_height)
                    {
                        transformChatHeightTo(1f - channel_selection_min_height, 800, Easing.OutQuint);
                    }
                }
                else
                {
                    textbox.HoldFocus = true;
                }
            };
        }
Beispiel #2
0
        private void load(OsuConfigManager config, OsuColour colours, TextureStore textures)
        {
            const float padding = 5;

            Children = new Drawable[]
            {
                channelSelectionContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Height           = 1f - DEFAULT_HEIGHT,
                    Masking          = true,
                    Children         = new[]
                    {
                        ChannelSelectionOverlay = new ChannelSelectionOverlay
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                chatContainer = new Container
                {
                    Name             = @"chat container",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Height           = DEFAULT_HEIGHT,
                    Children         = new[]
                    {
                        new Container
                        {
                            Name             = @"chat area",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = TAB_AREA_HEIGHT
                            },
                            Children = new Drawable[]
                            {
                                chatBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                new OnlineViewContainer("Sign in to chat")
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Children         = new Drawable[]
                                    {
                                        currentChannelContainer = new Container <DrawableChannel>
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Padding          = new MarginPadding
                                            {
                                                Bottom = text_box_height
                                            },
                                        },
                                        new Container
                                        {
                                            Anchor           = Anchor.BottomLeft,
                                            Origin           = Anchor.BottomLeft,
                                            RelativeSizeAxes = Axes.X,
                                            Height           = text_box_height,
                                            Padding          = new MarginPadding
                                            {
                                                Top    = padding * 2,
                                                Bottom = padding * 2,
                                                Left   = ChatLine.LEFT_PADDING + padding * 2,
                                                Right  = padding * 2,
                                            },
                                            Children = new Drawable[]
                                            {
                                                textBox = new FocusedTextBox
                                                {
                                                    RelativeSizeAxes     = Axes.Both,
                                                    Height               = 1,
                                                    PlaceholderText      = Resources.Localisation.Web.ChatStrings.InputPlaceholder,
                                                    ReleaseFocusOnCommit = false,
                                                    HoldFocus            = true,
                                                }
                                            }
                                        },
                                        loading = new LoadingSpinner(),
                                    },
                                }
                            }
                        },
                        tabsArea = new TabsArea
                        {
                            Children = new Drawable[]
                            {
                                tabBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                },
                                new Sprite
                                {
                                    Texture = textures.Get(IconTexture),
                                    Anchor  = Anchor.CentreLeft,
                                    Origin  = Anchor.CentreLeft,
                                    Size    = new Vector2(OverlayTitle.ICON_SIZE),
                                    Margin  = new MarginPadding {
                                        Left = 10
                                    },
                                },
                                ChannelTabControl = CreateChannelTabControl().With(d =>
                                {
                                    d.Anchor           = Anchor.BottomLeft;
                                    d.Origin           = Anchor.BottomLeft;
                                    d.RelativeSizeAxes = Axes.Both;
                                    d.OnRequestLeave   = channelManager.LeaveChannel;
                                    d.IsSwitchable     = true;
                                }),
                            }
                        },
                    },
                },
            };

            availableChannels.BindTo(channelManager.AvailableChannels);
            joinedChannels.BindTo(channelManager.JoinedChannels);
            currentChannel.BindTo(channelManager.CurrentChannel);

            textBox.OnCommit += postMessage;

            ChannelTabControl.Current.ValueChanged += current => currentChannel.Value = current.NewValue;
            ChannelTabControl.ChannelSelectorActive.ValueChanged += active => ChannelSelectionOverlay.State.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
            ChannelSelectionOverlay.State.ValueChanged           += state =>
            {
                // Propagate the visibility state to ChannelSelectorActive
                ChannelTabControl.ChannelSelectorActive.Value = state.NewValue == Visibility.Visible;

                if (state.NewValue == Visibility.Visible)
                {
                    textBox.HoldFocus = false;
                    if (1f - ChatHeight.Value < channel_selection_min_height)
                    {
                        this.TransformBindableTo(ChatHeight, 1f - channel_selection_min_height, 800, Easing.OutQuint);
                    }
                }
                else
                {
                    textBox.HoldFocus = true;
                }
            };

            ChannelSelectionOverlay.OnRequestJoin  = channel => channelManager.JoinChannel(channel);
            ChannelSelectionOverlay.OnRequestLeave = channelManager.LeaveChannel;

            ChatHeight = config.GetBindable <float>(OsuSetting.ChatDisplayHeight);
            ChatHeight.BindValueChanged(height =>
            {
                chatContainer.Height             = height.NewValue;
                channelSelectionContainer.Height = 1f - height.NewValue;
                tabBackground.FadeTo(height.NewValue == 1f ? 1f : 0.8f, 200);
            }, true);

            chatBackground.Colour = colours.ChatBlue;

            loading.Show();

            // This is a relatively expensive (and blocking) operation.
            // Scheduling it ensures that it won't be performed unless the user decides to open chat.
            // TODO: Refactor OsuFocusedOverlayContainer / OverlayContainer to support delayed content loading.
            Schedule(() =>
            {
                // TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
                joinedChannels.BindCollectionChanged(joinedChannelsChanged, true);
                availableChannels.BindCollectionChanged(availableChannelsChanged, true);
                currentChannel.BindValueChanged(currentChannelChanged, true);
            });
        }
Beispiel #3
0
        private void load(OsuConfigManager config, OsuColour colours, ChannelManager channelManager)
        {
            const float padding = 5;

            Children = new Drawable[]
            {
                channelSelectionContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Height           = 1f - DEFAULT_HEIGHT,
                    Masking          = true,
                    Children         = new[]
                    {
                        ChannelSelectionOverlay = new ChannelSelectionOverlay
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                chatContainer = new Container
                {
                    Name             = @"chat container",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Height           = DEFAULT_HEIGHT,
                    Children         = new[]
                    {
                        new Container
                        {
                            Name             = @"chat area",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = TAB_AREA_HEIGHT
                            },
                            Children = new Drawable[]
                            {
                                chatBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                currentChannelContainer = new Container <DrawableChannel>
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding
                                    {
                                        Bottom = textbox_height
                                    },
                                },
                                new Container
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    RelativeSizeAxes = Axes.X,
                                    Height           = textbox_height,
                                    Padding          = new MarginPadding
                                    {
                                        Top    = padding * 2,
                                        Bottom = padding * 2,
                                        Left   = ChatLine.LEFT_PADDING + padding * 2,
                                        Right  = padding * 2,
                                    },
                                    Children = new Drawable[]
                                    {
                                        textbox = new FocusedTextBox
                                        {
                                            RelativeSizeAxes     = Axes.Both,
                                            Height               = 1,
                                            PlaceholderText      = "type your message",
                                            Exit                 = Hide,
                                            OnCommit             = postMessage,
                                            ReleaseFocusOnCommit = false,
                                            HoldFocus            = true,
                                        }
                                    }
                                },
                                loading = new LoadingAnimation(),
                            }
                        },
                        tabsArea = new TabsArea
                        {
                            Children = new Drawable[]
                            {
                                tabBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                },
                                ChannelTabControl = CreateChannelTabControl().With(d =>
                                {
                                    d.Anchor           = Anchor.BottomLeft;
                                    d.Origin           = Anchor.BottomLeft;
                                    d.RelativeSizeAxes = Axes.Both;
                                    d.OnRequestLeave   = channelManager.LeaveChannel;
                                }),
                            }
                        },
                    },
                },
            };

            ChannelTabControl.Current.ValueChanged += current => channelManager.CurrentChannel.Value = current.NewValue;
            ChannelTabControl.ChannelSelectorActive.ValueChanged += active => ChannelSelectionOverlay.State.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
            ChannelSelectionOverlay.State.ValueChanged           += state =>
            {
                // Propagate the visibility state to ChannelSelectorActive
                ChannelTabControl.ChannelSelectorActive.Value = state.NewValue == Visibility.Visible;

                if (state.NewValue == Visibility.Visible)
                {
                    textbox.HoldFocus = false;
                    if (1f - ChatHeight.Value < channel_selection_min_height)
                    {
                        this.TransformBindableTo(ChatHeight, 1f - channel_selection_min_height, 800, Easing.OutQuint);
                    }
                }
                else
                {
                    textbox.HoldFocus = true;
                }
            };

            ChannelSelectionOverlay.OnRequestJoin  = channel => channelManager.JoinChannel(channel);
            ChannelSelectionOverlay.OnRequestLeave = channelManager.LeaveChannel;

            ChatHeight = config.GetBindable <float>(OsuSetting.ChatDisplayHeight);
            ChatHeight.BindValueChanged(height =>
            {
                chatContainer.Height             = height.NewValue;
                channelSelectionContainer.Height = 1f - height.NewValue;
                tabBackground.FadeTo(height.NewValue == 1f ? 1f : 0.8f, 200);
            }, true);

            chatBackground.Colour = colours.ChatBlue;

            this.channelManager = channelManager;

            loading.Show();

            // This is a relatively expensive (and blocking) operation.
            // Scheduling it ensures that it won't be performed unless the user decides to open chat.
            // TODO: Refactor OsuFocusedOverlayContainer / OverlayContainer to support delayed content loading.
            Schedule(() =>
            {
                // TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
                channelManager.JoinedChannels.ItemsAdded   += onChannelAddedToJoinedChannels;
                channelManager.JoinedChannels.ItemsRemoved += onChannelRemovedFromJoinedChannels;
                foreach (Channel channel in channelManager.JoinedChannels)
                {
                    ChannelTabControl.AddChannel(channel);
                }

                channelManager.AvailableChannels.ItemsAdded   += availableChannelsChanged;
                channelManager.AvailableChannels.ItemsRemoved += availableChannelsChanged;
                ChannelSelectionOverlay.UpdateAvailableChannels(channelManager.AvailableChannels);

                currentChannel = channelManager.CurrentChannel.GetBoundCopy();
                currentChannel.BindValueChanged(currentChannelChanged, true);
            });
        }
Beispiel #4
0
        public ChatOverlay()
        {
            RelativeSizeAxes     = Axes.Both;
            RelativePositionAxes = Axes.Both;
            Anchor = Anchor.BottomLeft;
            Origin = Anchor.BottomLeft;

            const float padding = 5;

            Children = new Drawable[]
            {
                channelSelectionContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Height           = 1f - DEFAULT_HEIGHT,
                    Masking          = true,
                    Children         = new[]
                    {
                        channelSelectionOverlay = new ChannelSelectionOverlay
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                    },
                },
                chatContainer = new Container
                {
                    Name             = @"chat container",
                    Anchor           = Anchor.BottomLeft,
                    Origin           = Anchor.BottomLeft,
                    RelativeSizeAxes = Axes.Both,
                    Height           = DEFAULT_HEIGHT,
                    Children         = new[]
                    {
                        new Container
                        {
                            Name             = @"chat area",
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = TAB_AREA_HEIGHT
                            },
                            Children = new Drawable[]
                            {
                                chatBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                },
                                currentChannelContainer = new Container <DrawableChannel>
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding
                                    {
                                        Bottom = textbox_height
                                    },
                                },
                                new Container
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    RelativeSizeAxes = Axes.X,
                                    Height           = textbox_height,
                                    Padding          = new MarginPadding
                                    {
                                        Top    = padding * 2,
                                        Bottom = padding * 2,
                                        Left   = ChatLine.LEFT_PADDING + padding * 2,
                                        Right  = padding * 2,
                                    },
                                    Children = new Drawable[]
                                    {
                                        textbox = new FocusedTextBox
                                        {
                                            RelativeSizeAxes     = Axes.Both,
                                            Height               = 1,
                                            PlaceholderText      = "type your message",
                                            Exit                 = Hide,
                                            OnCommit             = postMessage,
                                            ReleaseFocusOnCommit = false,
                                            HoldFocus            = true,
                                        }
                                    }
                                },
                                loading = new LoadingAnimation(),
                            }
                        },
                        tabsArea = new TabsArea
                        {
                            Children = new Drawable[]
                            {
                                tabBackground = new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                },
                                channelTabControl = new ChannelTabControl
                                {
                                    Anchor           = Anchor.BottomLeft,
                                    Origin           = Anchor.BottomLeft,
                                    RelativeSizeAxes = Axes.Both,
                                    OnRequestLeave   = channel => channelManager.LeaveChannel(channel)
                                },
                            }
                        },
                    },
                },
            };

            channelTabControl.Current.ValueChanged += current => channelManager.CurrentChannel.Value = current.NewValue;
            channelTabControl.ChannelSelectorActive.ValueChanged += active => channelSelectionOverlay.State.Value = active.NewValue ? Visibility.Visible : Visibility.Hidden;
            channelSelectionOverlay.State.ValueChanged           += state =>
            {
                if (state.NewValue == Visibility.Hidden && channelManager.CurrentChannel.Value == null)
                {
                    channelSelectionOverlay.Show();
                    Hide();
                    return;
                }

                channelTabControl.ChannelSelectorActive.Value = state.NewValue == Visibility.Visible;

                if (state.NewValue == Visibility.Visible)
                {
                    textbox.HoldFocus = false;
                    if (1f - ChatHeight.Value < channel_selection_min_height)
                    {
                        this.TransformBindableTo(ChatHeight, 1f - channel_selection_min_height, 800, Easing.OutQuint);
                    }
                }
                else
                {
                    textbox.HoldFocus = true;
                }
            };

            channelSelectionOverlay.OnRequestJoin  = channel => channelManager.JoinChannel(channel);
            channelSelectionOverlay.OnRequestLeave = channel => channelManager.LeaveChannel(channel);
        }