Пример #1
0
        public virtual void APIStateChanged(IAPIProvider api, APIState state)
        {
            switch (state)
            {
            case APIState.Offline:
                PopContentOut(Content);
                placeholder.ScaleTo(0.8f).Then().ScaleTo(1, 3 * transform_duration, Easing.OutQuint);
                placeholder.FadeInFromZero(2 * transform_duration, Easing.OutQuint);
                LoadingAnimation.Hide();
                break;

            case APIState.Online:
                PopContentIn(Content);
                placeholder.FadeOut(transform_duration / 2, Easing.OutQuint);
                LoadingAnimation.Hide();
                break;

            case APIState.Failing:
            case APIState.Connecting:
                PopContentOut(Content);
                LoadingAnimation.Show();
                placeholder.FadeOut(transform_duration / 2, Easing.OutQuint);
                break;
            }
        }
Пример #2
0
        private void updateScores()
        {
            if (!IsLoaded)
            {
                return;
            }

            Scores = null;
            getScoresRequest?.Cancel();

            if (api == null || Beatmap == null)
            {
                return;
            }

            loading.Show();

            getScoresRequest          = new GetScoresRequest(Beatmap);
            getScoresRequest.Success += r =>
            {
                Scores = r.Scores;
                loading.Hide();
            };
            api.Queue(getScoresRequest);
        }
Пример #3
0
        private void initializeChannels()
        {
            loading.Show();

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                AvailableChannels = channels;

                Scheduler.Add(delegate
                {
                    addChannel(channels.Find(c => c.Name == @"#lazer"));
                    addChannel(channels.Find(c => c.Name == @"#osu"));
                    addChannel(channels.Find(c => c.Name == @"#lobby"));

                    channelSelection.OnRequestJoin  = addChannel;
                    channelSelection.OnRequestLeave = removeChannel;
                    channelSelection.Sections       = new[]
                    {
                        new ChannelSection
                        {
                            Header   = "All Channels",
                            Channels = channels,
                        },
                    };
                });

                messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
            };

            api.Queue(req);
        }
Пример #4
0
        private void updateSearch()
        {
            queryChangedDebounce?.Cancel();

            if (!IsLoaded)
            {
                return;
            }

            Users = null;
            clearPanels();
            loading.Hide();
            getUsersRequest?.Cancel();

            if (api?.IsLoggedIn != true)
            {
                return;
            }

            switch (Header.Tabs.Current.Value)
            {
            case SocialTab.Friends:
                var friendRequest = new GetFriendsRequest();     // TODO filter arguments?
                friendRequest.Success    += updateUsers;
                api.Queue(getUsersRequest = friendRequest);
                break;

            default:
                var userRequest = new GetUsersRequest();     // TODO filter arguments!
                userRequest.Success      += response => updateUsers(response.Select(r => r.User));
                api.Queue(getUsersRequest = userRequest);
                break;
            }
            loading.Show();
        }
Пример #5
0
        private void initializeChannels()
        {
            loading.Show();

            messageRequest?.Cancel();

            ListChannelsRequest req = new ListChannelsRequest();

            req.Success += delegate(List <Channel> channels)
            {
                AvailableChannels = channels;

                Scheduler.Add(delegate
                {
                    //todo: decide how to handle default channels for a user now that they are saved server-side.
                    addChannel(channels.Find(c => c.Name == @"#lazer"));
                    addChannel(channels.Find(c => c.Name == @"#osu"));

                    channelSelection.OnRequestJoin  = addChannel;
                    channelSelection.OnRequestLeave = removeChannel;
                    channelSelection.Sections       = new[]
                    {
                        new ChannelSection
                        {
                            Header   = "All Channels",
                            Channels = channels,
                        },
                    };
                });

                messageRequest = Scheduler.AddDelayed(fetchUpdates, 1000, true);
            };

            api.Queue(req);
        }
Пример #6
0
            private void showMore()
            {
                var req = new GetUserScoresRequest(user.Id, type, visiblePages++ *5);

                showMoreLoading.Show();
                showMoreButton.Hide();

                req.Success += scores =>
                {
                    foreach (var s in scores)
                    {
                        s.ApplyRuleset(rulesets.GetRuleset(s.OnlineRulesetID));
                    }

                    showMoreButton.FadeTo(scores.Count == 5 ? 1 : 0);
                    showMoreLoading.Hide();

                    if (scores.Any())
                    {
                        missing.Hide();
                        foreach (OnlineScore score in scores)
                        {
                            scoreContainer.Add(new DrawableScore(score, includeWeigth ? Math.Pow(0.95, scoreContainer.Count) : -1)
                            {
                                RelativeSizeAxes = Axes.X,
                                Height           = 60,
                            });
                        }
                    }
                };

                Schedule(() => { api.Queue(req); });
            }
Пример #7
0
        private void updateScores()
        {
            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (Scope == LeaderboardScope.Local)
                {
                    // TODO: get local scores from wherever here.
                    PlaceholderState = PlaceholderState.NoScores;
                    return;
                }

                if (Beatmap?.OnlineBeatmapID == null)
                {
                    PlaceholderState = PlaceholderState.Unavailable;
                    return;
                }

                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
                {
                    PlaceholderState = PlaceholderState.NotSupporter;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest          = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope);
                getScoresRequest.Success += r => Schedule(() =>
                {
                    Scores           = r.Scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                });

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Пример #8
0
        public TestCaseLoadingAnimation()
            : base(2, 2)
        {
            LoadingAnimation loading;

            Cell(0).AddRange(new Drawable[]
            {
                new Box
                {
                    Colour           = Color4.Black,
                    RelativeSizeAxes = Axes.Both
                },
                loading = new LoadingAnimation()
            });

            loading.Show();

            Cell(1).AddRange(new Drawable[]
            {
                new Box
                {
                    Colour           = Color4.White,
                    RelativeSizeAxes = Axes.Both
                },
                loading = new LoadingAnimation()
            });

            loading.Show();

            Cell(2).AddRange(new Drawable[]
            {
                new Box
                {
                    Colour           = Color4.Gray,
                    RelativeSizeAxes = Axes.Both
                },
                loading = new LoadingAnimation()
            });

            loading.Show();

            Cell(3).AddRange(new Drawable[]
            {
                loading = new LoadingAnimation()
            });

            Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true);
        }
Пример #9
0
        private void showMore()
        {
            var req = new GetUserScoresRequest(user.Value.Id, type, visiblePages++ *5);

            showMoreLoading.Show();
            showMoreButton.Hide();

            req.Success += scores =>
            {
                foreach (var s in scores)
                {
                    s.ApplyRuleset(rulesets.GetRuleset(s.OnlineRulesetID));
                }

                showMoreButton.FadeTo(scores.Count == 5 ? 1 : 0);
                showMoreLoading.Hide();

                if (!scores.Any())
                {
                    return;
                }

                missing.Hide();

                foreach (OnlineScore score in scores)
                {
                    DrawableScore drawableScore;

                    switch (type)
                    {
                    default:
                        drawableScore = new DrawablePerformanceScore(score, includeWeight ? Math.Pow(0.95, scoreContainer.Count) : (double?)null);
                        break;

                    case ScoreType.Recent:
                        drawableScore = new DrawableTotalScore(score);
                        break;
                    }

                    drawableScore.RelativeSizeAxes = Axes.X;
                    drawableScore.Height           = 60;

                    scoreContainer.Add(drawableScore);
                }
            };

            api.Queue(req);
        }
Пример #10
0
        protected void UpdateScores()
        {
            // don't display any scores or placeholder until the first Scores_Set has been called.
            // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished.
            if (!scoresLoadedOnce)
            {
                return;
            }

            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest = FetchScores(scores => Schedule(() =>
                {
                    Scores           = scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                }));

                if (getScoresRequest == null)
                {
                    return;
                }

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Пример #11
0
        private void reloadUsers(APIAccess api)
        {
            Users = null;

            // no this is not the correct data source, but it's something.
            var request = new GetUsersRequest();

            request.Success += res =>
            {
                Users = res.Select(e => e.User);
                loading.Hide();
            };

            api.Queue(request);
            loading.Show();
        }
Пример #12
0
        private void updateScores()
        {
            getScoresRequest?.Cancel();
            getScoresRequest = null;
            Scores           = null;

            if (Scope == LeaderboardScope.Local)
            {
                // TODO: get local scores from wherever here.
                PlaceholderState = PlaceholderState.NoScores;
                return;
            }

            if (Beatmap?.OnlineBeatmapID == null)
            {
                PlaceholderState = PlaceholderState.Unavailable;
                return;
            }

            if (api?.IsLoggedIn != true)
            {
                PlaceholderState = PlaceholderState.NotLoggedIn;
                return;
            }

            PlaceholderState = PlaceholderState.Retrieving;
            loading.Show();

            if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
            {
                loading.Hide();
                PlaceholderState = PlaceholderState.NotSupporter;
                return;
            }

            getScoresRequest          = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope);
            getScoresRequest.Success += r =>
            {
                Scores           = r.Scores;
                PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
            };
            getScoresRequest.Failure += onUpdateFailed;

            api.Queue(getScoresRequest);
        }
Пример #13
0
        private void load(OverlayColourProvider colourProvider)
        {
            coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f));
            onlineStatusPill.BackgroundColour = colourProvider.Background6;

            State.BindValueChanged(_ => updateDownloadButtons());

            BeatmapSet.BindValueChanged(setInfo =>
            {
                Picker.BeatmapSet = RulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
                cover.BeatmapSet  = setInfo.NewValue;

                if (setInfo.NewValue == null)
                {
                    onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint);
                    fadeContent.Hide();

                    loading.Show();

                    downloadButtonsContainer.FadeOut(transition_duration);
                    favouriteButton.FadeOut(transition_duration);
                }
                else
                {
                    fadeContent.FadeIn(500, Easing.OutQuint);

                    loading.Hide();

                    title.Text  = setInfo.NewValue.Metadata.Title ?? string.Empty;
                    artist.Text = setInfo.NewValue.Metadata.Artist ?? string.Empty;

                    onlineStatusPill.FadeIn(500, Easing.OutQuint);
                    onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status;

                    downloadButtonsContainer.FadeIn(transition_duration);
                    favouriteButton.FadeIn(transition_duration);

                    updateDownloadButtons();
                }
            }, true);
        }
Пример #14
0
        private void load(OsuColour colours)
        {
            tabsBg.Colour = colours.Gray3;

            State.BindValueChanged(_ => updateDownloadButtons());

            BeatmapSet.BindValueChanged(setInfo =>
            {
                Picker.BeatmapSet = RulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
                cover.BeatmapSet  = setInfo.NewValue;

                if (setInfo.NewValue == null)
                {
                    onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint);
                    fadeContent.Hide();

                    loading.Show();

                    downloadButtonsContainer.FadeOut(transition_duration);
                    favouriteButton.FadeOut(transition_duration);
                }
                else
                {
                    fadeContent.FadeIn(500, Easing.OutQuint);

                    loading.Hide();

                    title.Text  = setInfo.NewValue.Metadata.Title ?? string.Empty;
                    artist.Text = setInfo.NewValue.Metadata.Artist ?? string.Empty;

                    onlineStatusPill.FadeIn(500, Easing.OutQuint);
                    onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status;

                    downloadButtonsContainer.FadeIn(transition_duration);
                    favouriteButton.FadeIn(transition_duration);

                    updateDownloadButtons();
                }
            }, true);
        }
Пример #15
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);
            });
        }
Пример #16
0
        private void updateScores()
        {
            // don't display any scores or placeholder until the first Scores_Set has been called.
            // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished.
            if (!scoresLoadedOnce)
            {
                return;
            }

            getScoresRequest?.Cancel();
            getScoresRequest = null;

            pendingUpdateScores?.Cancel();
            pendingUpdateScores = Schedule(() =>
            {
                if (Scope == LeaderboardScope.Local)
                {
                    // TODO: get local scores from wherever here.
                    PlaceholderState = PlaceholderState.NoScores;
                    return;
                }

                if (Beatmap?.OnlineBeatmapID == null)
                {
                    PlaceholderState = PlaceholderState.Unavailable;
                    return;
                }

                if (api?.IsLoggedIn != true)
                {
                    PlaceholderState = PlaceholderState.NotLoggedIn;
                    return;
                }

                if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter)
                {
                    PlaceholderState = PlaceholderState.NotSupporter;
                    return;
                }

                PlaceholderState = PlaceholderState.Retrieving;
                loading.Show();

                getScoresRequest          = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope);
                getScoresRequest.Success += r => Schedule(() =>
                {
                    Scores           = r.Scores;
                    PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
                });

                getScoresRequest.Failure += e => Schedule(() =>
                {
                    if (e is OperationCanceledException)
                    {
                        return;
                    }

                    PlaceholderState = PlaceholderState.NetworkFailure;
                });

                api.Queue(getScoresRequest);
            });
        }
Пример #17
0
 protected virtual void ShowMore()
 {
     ShowMoreLoading.Show();
     ShowMoreButton.Hide();
 }