Esempio n. 1
0
        internal void UpdateSelected(bool userForced = false, bool firstUpdate = false)
        {
            if (BeatmapManager.Current != SelectedMap || userForced || firstUpdate)
            {
                //Keeps selected map in sync with current map. Sanity checks for null values.
                if ((!userForced && BeatmapManager.Current != null) || (userForced && SelectedMap == null))
                {
                    SelectedMap = BeatmapManager.Current;
                }
                else
                {
                    BeatmapManager.Current = SelectedMap;
                }

                Debug.Assert(SelectedMap != null);

                foreach (JumpToItem m in items)
                {
                    if (SelectedMap?.ContainingFolder == m.map.ContainingFolder)
                    {
                        m.colourBackground.FadeTo(0.6f, 100);
                        m.colourBackground.FadeColour(Color.CornflowerBlue, 100);

                        if (!userForced)
                        {
                            if (items.Count <= 12)
                            {
                                scrollableView.SetContentDimensions(new Vector2(0, 0));
                                continue;
                            }

                            int itemIndex     = items.IndexOf(m);
                            int itemPositionY = itemIndex * JumpToItem.ITEM_HEIGHT;

                            scrollableView.SetScrollPosition(new Vector2(0, Math.Min(scrollableView.ContentDimensions.Y - ITEM_WINDOW_HEIGHT, itemPositionY)));
                        }
                    }
                    else
                    {
                        if (m.colourBackground.Alpha > 0.001f)
                        {
                            m.colourBackground.FadeTo(0.001f, 20);
                            m.colourBackground.FadeColour(Color.White, 20);
                        }
                    }
                }
            }

            if (userForced && !SongConfirmed)
            {
                MusicControl.ChooseRandomSong(false);
                MusicControl.PushHistory(BeatmapManager.Current);
            }
        }
Esempio n. 2
0
        private void req_onFinish(pWebRequest r, Exception e)
        {
            lock (Beatmaps)
            {
                if (pageOffset == 0)
                {
                    Beatmaps.ForEach(b => b.Dispose());
                    Beatmaps.Clear();
                    resultsPane.SetScrollPosition(Vector2.Zero);
                }

                try
                {
                    string[] lines = r.ResponseString.Split('\n');

                    int status = Int32.Parse(lines[0]);

                    tempIncoming = string.Empty;

                    if (status < 0)
                    {
                        searchInfo.Text = "Error: " + lines[1];
                    }
                    else
                    {
                        for (int i = 1; i < lines.Length; i++)
                        {
                            if (lines[i].Length == 0)
                            {
                                continue;
                            }
                            OnlineBeatmap ob = new OnlineBeatmap(lines[i]);
                            ob.OnDownloadFinished += delegate
                            {
                                lock (Beatmaps)
                                    Beatmaps.Remove(ob);
                                newResults = true;
                                ob.Dispose();
                            };
                            if (displayExisting.Checked || !ob.exists)
                            {
                                Beatmaps.Add(ob);
                            }
                        }

                        canLoadMore = status > 100 && pageOffset != 39;

                        status = Math.Min(100, status);

                        int totalCount = (pageOffset * 100 + status);

                        if (canLoadMore)
                        {
                            searchInfo.Text = "Over " + totalCount + " results found.";
                        }
                        else
                        {
                            searchInfo.Text = totalCount + " result" + (totalCount != 1 ? "s" : "") + " found.";
                        }
                    }
                }
                catch
                {
                }
            }

            newResults = true;
        }