Ejemplo n.º 1
0
        public ChangelogOverlay(Game game, bool fullscreen = false)
            : base(game)
        {
            if (fullscreen)
            {
                Width       = GameBase.WindowManager.WidthScaled;
                Height      = 226;
                startHeight = 0;
            }

            area = new pScrollableArea(new Rectangle(0, GameBase.WindowManager.HeightScaled - Height, Width, Height), Vector2.Zero, true);
            area.HeaderHeight = startHeight;

            int year  = General.VERSION / 10000;
            int month = General.VERSION / 100 - year * 100;
            int day   = General.VERSION - year * 10000 - month * 100;

            int version_dated   = Int32.Parse(new DateTime(year, month, day).AddDays(-14).ToString("yyyyMMdd"));
            int version_current = Int32.Parse(new DateTime(year, month, day).ToString("yyyyMMdd"));

            pWebRequest snr = new pWebRequest(General.WEB_ROOT + "/p/changelog?updater=3" + (!string.IsNullOrEmpty(General.SUBVERSION) ? "&test=1" : "&current=" + version_current + "&from=" + version_dated));

            snr.Finished += snr_onFinish;
            snr.Perform();

            pSprite bg = new pSprite(GameBase.WhitePixel, Vector2.Zero, 0.5f, true, Color.Black);

            bg.Scale            = 1.6f;
            bg.ViewOffsetImmune = true;
            bg.VectorScale      = new Vector2(Width, Height);
            bg.Alpha            = 0.5f;

            area.ContentSpriteManager.Add(bg);

            if (!fullscreen)
            {
                pText t = new pText(LocalisationManager.GetString(OsuString.Update_RecentChanges), 10, new Vector2(3, 3), Vector2.Zero, 0.9992f, true, Color.White, false);
                t.ViewOffsetImmune = true;
                t.TextBold         = true;

                area.ContentSpriteManager.Add(t);

                bg                  = new pSprite(GameBase.WhitePixel, Vector2.Zero, 0.9991f, true, SkinManager.NEW_SKIN_COLOUR_SECONDARY);
                bg.Scale            = 1.6f;
                bg.ViewOffsetImmune = true;
                bg.VectorScale      = new Vector2(Width, startHeight);
                bg.Alpha            = 0.8f;
                bg.HandleInput      = true;

                bg.HoverEffect = new Transformation(Color.DarkBlue, Color.LightBlue, 0, 50);

                bg.OnClick += delegate
                {
                    area.ContentSpriteManager.SpriteList.ForEach(s => s.FadeOut(100));
                    GameBase.Scheduler.AddDelayed(delegate { area.Hide(); }, 100);
                };

                area.ContentSpriteManager.Add(bg);
            }
        }
Ejemplo n.º 2
0
        internal override void Initialize()
        {
            base.Initialize();

            spriteManager.Add(coinsBuyButton = new pSprite(@"coins-buy", new Vector2(-35, -10), SkinSource.All, Origins.Centre, Fields.TopCentre)
            {
                Depth = 0.88f
            });
            spriteManager.Add(coinsBg = new pSprite(@"coins-bg", new Vector2(0, -10), SkinSource.All, Origins.Centre, Fields.TopCentre)
            {
                Depth = 0.9f
            });
            spriteManager.Add(coinsFg = new pSprite(@"coins", new Vector2(0, -15), SkinSource.All, Origins.Centre, Fields.TopCentre)
            {
                Depth = 0.98f, Scale = 0.55f
            });

            coinsBuyButton.OnClick    += buyMore;
            coinsBuyButton.HandleInput = true;
            coinsBuyButton.HoverEffect = new Transformation(Color.White, Color.HotPink, 0, 100);

            spriteManager.Add(coinsCount = new pText(string.Empty, 16, new Vector2(0, 0), 1, true, Color.White)
            {
                Field = Fields.TopCentre, Origin = Origins.Centre, TextShadow = false
            });

            spriteManager.SpriteList.ForEach(s => { s.Alpha = 0; });

            pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + "/web/coins.php?action=check&u={0}&h={1}&c={2}&cs={3}", ConfigManager.sUsername, ConfigManager.sPassword, Count, Checksum));

            snr.Finished += snr_onFinish;
            snr.Perform();
        }
        public static void LoadOnlineFavourites()
        {
            if (OnlineFavouritesLoaded)
            {
                return;
            }
            OnlineFavouritesLoaded = true;

            NotificationManager.ShowMessageMassive("Loading online favourites...", 1000);

            pWebRequest dnr = new pWebRequest(string.Format(Urls.GET_FAVOURITES, ConfigManager.sUsername, ConfigManager.sPassword));

            dnr.Finished += delegate(pWebRequest r, Exception e)
            {
                foreach (string s in r.ResponseString.Split('\n'))
                {
                    if (s.Length == 0)
                    {
                        continue;
                    }

                    int beatmapSetId = Int32.Parse(s);
                    Beatmaps.FindAll(b => b.BeatmapSetId == beatmapSetId).ForEach(b => b.OnlineFavourite = true);
                }

                InvokeOnOnlineFavouritesLoaded();
            };
            dnr.Perform();
        }
Ejemplo n.º 4
0
        private void ExecuteSearch(bool newSearch)
        {
            if (searching)
            {
                return;
            }

            if (newSearch)
            {
                pageOffset  = 0;
                canLoadMore = false;
            }

            searching = true;
            pWebRequest req =
                new pWebRequest(string.Format(Urls.DIRECT_SEARCH, ConfigManager.sUsername, ConfigManager.sPassword, (int)displayModeDropdown.SelectedObject, GeneralHelper.UrlEncodeParam(lastSearch), (int)displayOsuModeDropdown.SelectedObject, pageOffset));

            req.Finished += req_onFinish;
            req.Perform();

            searchInfo.Text = newSearch ? "Searching..." : "Loading...";

            if (newSearch)
            {
                loadingText.FadeIn(200);
                Beatmaps.ForEach(b => b.Dim());
            }
        }
Ejemplo n.º 5
0
        internal bool EarnCoin()
        {
            if (!GameBase.HasLogin)
            {
                return(true);
            }

            pSprite coin = coinSingular.Clone();

            coin.Position = InputManager.CursorPosition / GameBase.WindowManager.Ratio;
            coin.Depth    = 0.99f;
            coin.FadeOut(1500);

            spriteManagerDialog.Add(coin);
            physics.Add(coin, new Vector2((float)RNG.NextDouble() * 100, (float)RNG.NextDouble() * -100));

            pSprite coinShine = coinSingular.Clone();

            coinShine.Additive  = true;
            coinShine.OnUpdate += delegate { coinShine.Position = coin.Position; };
            coinShine.FadeOut(500);

            spriteManagerDialog.Add(coinShine);

            AudioEngine.PlaySample(@"coins-earn", 80);

            Count++;

            pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + "/web/coins.php?action=earn&u={0}&h={1}&c={2}&cs={3}", ConfigManager.sUsername, ConfigManager.sPassword, Count, Checksum));

            snr.Finished += snr_onFinish;
            snr.Perform();

            return(true);
        }
Ejemplo n.º 6
0
        internal void GetReplayData()
        {
            pWebRequest dnr = new pWebRequest(string.Format(General.WEB_ROOT + @"/web/osu-getreplay.php?c={0}&m={1}&u={2}&h={3}",
                                                            OnlineId, (int)PlayMode, ConfigManager.sUsername, ConfigManager.sPassword));

            dnr.Finished += dnr_onFinish;
            dnr.Perform();
        }
Ejemplo n.º 7
0
        public override void Initialize()
        {
            //background
            baseSpriteManager.Add(new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true, c_background)
            {
                VectorScale = new Vector2(GameBase.WindowManager.Width, GameBase.WindowManager.Height)
            });

            //header
            pText textCharts = new pText("Charts" + @" /", 28, new Vector2(PADDING, 60), 1, true, Color.White)
            {
                Origin = Origins.BottomLeft
            };

            baseSpriteManager.Add(textCharts);

            t_currentCategory = new pText("All Charts", 20, new Vector2(120f, 58), 1, true, new Color(254, 220, 97))
            {
                Origin = Origins.BottomLeft
            };
            baseSpriteManager.Add(t_currentCategory);

            searchBox           = new pSearchBox(18, new Vector2(PADDING, 33), 20, Graphics.Renderers.TextAlignment.Right);
            searchBox.OnChange += searchBox_OnChange;
            baseSpriteManager.Add(searchBox.SpriteCollection);

            baseSpriteManager.Add(new pBox(new Vector2(PADDING, 62), new Vector2(GameBase.WindowManager.WidthScaled - (PADDING * 2), 1), 1, Color.White));

            t_categorySelection = new pText("All  /  Monthly  /  Themed  /  Special", 14, new Vector2(PADDING, 70), 1, true, Color.White)
            {
                Origin = Origins.TopLeft
            };
            baseSpriteManager.Add(t_categorySelection);

            //list

            sa_chartList = new pScrollableArea(new RectangleF(PADDING / 2, 90, GameBase.WindowManager.WidthScaled - PADDING, GameBase.WindowManager.HeightScaled - PADDING - 90), Vector2.Zero, true);

            pWebRequest req = new pWebRequest("https://osu.ppy.sh/web/osu-getcharts.php?u={0}&h={1}", ConfigManager.sUsername, ConfigManager.sPassword);

            req.Finished += delegate(pWebRequest r, Exception e)
            {
                charts = JsonConvert.DeserializeObject <List <Chart> >(r.ResponseString);

                DoLayout();
            };

            req.Perform();

            //footer
            backButton = new BackButton(delegate { GameBase.ChangeMode(OsuModes.Menu); });

            spriteManagerTop.Add(backButton.SpriteCollection);

            KeyboardHandler.OnKeyPressed += onKeyPressed;

            base.Initialize();
        }
Ejemplo n.º 8
0
        internal bool Recharge()
        {
            if (!GameBase.HasLogin)
            {
                return(true);
            }

            pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + "/web/coins.php?action=recharge&u={0}&h={1}&c={2}&cs={3}", ConfigManager.sUsername, ConfigManager.sPassword, Count, Checksum));

            snr.Finished += snr_onFinish;
            snr.Finished += delegate { AudioEngine.PlaySample(@"coins-recharge"); };
            snr.Perform();

            return(true);
        }
Ejemplo n.º 9
0
        internal bool UseCoin()
        {
            if (!GameBase.HasLogin)
            {
                return(true);
            }

            Count--;

            pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + "/web/coins.php?action=use&u={0}&h={1}&c={2}&cs={3}", ConfigManager.sUsername, ConfigManager.sPassword, Count, Checksum));

            snr.Finished += snr_onFinish;
            snr.Perform();


            return(true);
        }
Ejemplo n.º 10
0
        private static void sendCurrentTrack(bool scrobble)
        {
#if DEBUG
            return;
#endif

            if (last == null)
            {
                return;
            }

            string url = General.WEB_ROOT + "/web/lastfm.php?b=" + last.BeatmapId +
                         "&action=" + (scrobble ? "scrobble" : "np") +
                         "&us=" + ConfigManager.sUsername + "&ha=" + ConfigManager.sPassword;

            pWebRequest snr = new pWebRequest(url);
            snr.Finished += snr_onFinish;
            snr.Perform();
        }
Ejemplo n.º 11
0
        private void RequestComments()
        {
            if (commentsRequested)
            {
                return;
            }

            commentsRequested = true;

            pWebRequest fnr = new pWebRequest(General.WEB_ROOT + "/web/osu-comment.php");

            fnr.AddParameter("u", ConfigManager.sUsername);
            fnr.AddParameter("p", ConfigManager.sPassword);
            fnr.AddParameter("b", BeatmapManager.Current.BeatmapId.ToString());
            fnr.AddParameter("s", BeatmapManager.Current.BeatmapSetId.ToString());
            fnr.AddParameter("r", InputManager.ReplayScore.OnlineId.ToString(GameBase.nfi));
            fnr.AddParameter("m", ((int)InputManager.ReplayScore.PlayMode).ToString(GameBase.nfi));
            fnr.AddParameter("a", "get");

            fnr.Finished += comment_IncomingCommentInfo;

            fnr.Perform();
        }
Ejemplo n.º 12
0
        //A temporary replacement for p2p updating
        private void updateOsz2Container()
        {
            Beatmap b = BeatmapManager.Current;

            if (b.Package == null)
            {
                throw new Exception("Can only update osz2 Packages.");
            }

            //todo: disable update button here
            AudioEngine.Stop();
            AudioEngine.FreeMusic();



            //ThreadPool.QueueUserWorkItem((o) =>
            {
                List <osu_common.Libraries.Osz2.FileInfo> fileInfoCurrent = b.Package.GetFileInfo();
                //b.Package.Close();
                MapPackage currentPackage = b.Package;
#if P2P
                if (!currentPackage.AcquireLock(20, true))
                {
                    String message = "Failed to update: Mappackage seems to be already in use.";
                    GameBase.Scheduler.Add
                        (() => NotificationManager.ShowMessage(message, Color.Cyan, 3000));
                    return;
                }
#endif

                pWebRequest getFileInfo = new pWebRequest(String.Format(Urls.OSZ2_GET_FILE_INFO,
                                                                        ConfigManager.sUsername, ConfigManager.sPassword, b.BeatmapSetId));

                status.SetStatus("Dowloading package version information");
                string fileInfoEncoded = null;
                getFileInfo.Finished += (r, exc) => { if (exc == null)
                                                      {
                                                          fileInfoEncoded = r.ResponseString;
                                                      }
                };
                try
                {
                    getFileInfo.BlockingPerform();
                }
                catch { }

                if (fileInfoEncoded == null || fileInfoEncoded.Trim() == "" || fileInfoEncoded.StartsWith("5\n"))
                {
#if P2P
                    currentPackage.Unlock();
#endif
                    String message = "Failed to update: Could not connect to the update service";
                    GameBase.Scheduler.AddDelayed
                        (() => NotificationManager.ShowMessage(message, Color.Cyan, 3000), 100);
                    return;
                }
                //decode string to FileInfo list
                string[] DatanList          = fileInfoEncoded.Split('\n');
                string[] fileInfoCollection = DatanList[0].Split('|');
                List <osu_common.Libraries.Osz2.FileInfo> fileInfoNew =
                    new List <osu_common.Libraries.Osz2.FileInfo>(fileInfoCollection.Length);

                status.SetStatus("Cross-referencing version information");
                foreach (string fileInfoEnc in fileInfoCollection)
                {
                    string[] fileInfoItems = fileInfoEnc.Split(':');
                    string   filename      = fileInfoItems[0];
                    int      offset        = Convert.ToInt32(fileInfoItems[1]);
                    int      length        = Convert.ToInt32(fileInfoItems[2]);
                    byte[]   hash          = GeneralHelper.StringToByteArray(fileInfoItems[3]);
                    DateTime dateCreated   = DateTime.FromBinary(Convert.ToInt64(fileInfoItems[4]));
                    DateTime dateModified  = DateTime.FromBinary(Convert.ToInt64(fileInfoItems[5]));
                    osu_common.Libraries.Osz2.FileInfo infoDecoded;
                    infoDecoded = new osu_common.Libraries.Osz2.FileInfo(filename, offset, length, hash, dateCreated, dateModified);

                    fileInfoNew.Add(infoDecoded);
                }


                status.SetStatus("Downloading and updating files:");
                //update all files that needs to be updated
                foreach (var fiNew in fileInfoNew)
                {
                    //if already uptodate continue
                    if (fileInfoCurrent.FindIndex((f) => f.Filename == fiNew.Filename)
                        //&& MonoTorrent.Common.Toolbox.ByteMatch(f.Hash, fiNew.Hash))
                        != -1)
                    {
                        continue;
                    }

                    //if this file is a video and this package is a no-videoversion
                    if (currentPackage.NoVideoVersion && MapPackage.IsVideoFile(fiNew.Filename))
                    {
                        continue;
                    }

                    status.SetStatus("Updating " + fiNew.Filename + "...");

                    //download the file:
                    string url = String.Format(Urls.OSZ2_GET_FILE_CONTENTS, ConfigManager.sUsername, ConfigManager.sPassword,
                                               b.BeatmapSetId, fiNew.Filename);

                    byte[]      fileContents    = null;
                    pWebRequest getFileContents = new pWebRequest(url);
                    getFileContents.Finished += (r, exc) => { if (exc == null)
                                                              {
                                                                  fileContents = r.ResponseData;
                                                              }
                    };
                    try
                    {
                        getFileContents.Perform();
                    }
                    catch { }

                    if (fileContents == null)
                    {
                        String message = String.Format("Failed to update: Dowloading {0} failed.", fiNew.Filename);
                        GameBase.Scheduler.Add
                            (() => NotificationManager.ShowMessage(message, Color.Cyan, 3300));
                        return;
                    }

                    currentPackage.AddFile(fiNew.Filename, fileContents, fiNew.CreationTime, fiNew.ModifiedTime, true);
                }

                status.SetStatus("Saving changes...");
                currentPackage.Save(true);
                Osz2Factory.CloseMapPackage(currentPackage);

                status.SetStatus("Updating metadata...");

                //get the new fileheader and replace the old
                string getHeaderUrl = String.Format(Urls.OSZ2_GET_RAW_HEADER, ConfigManager.sUsername, ConfigManager.sPassword,
                                                    b.BeatmapSetId);
                byte[]      rawHeader    = null;
                pWebRequest getHeaderRaw = new pWebRequest(getHeaderUrl);
                getHeaderRaw.Finished += (r, exc) => { if (exc == null)
                                                       {
                                                           rawHeader = r.ResponseData;
                                                       }
                };
                getHeaderRaw.Perform();

                if (rawHeader == null || rawHeader.Length < 60)
                {
                    String message = "Failed to update: recieving header failed, please try to redownload.";
                    GameBase.Scheduler.Add
                        (() => NotificationManager.ShowMessage(message, Color.Cyan, 3300));
                    return;
                }

                int dataOffset = Convert.ToInt32(DatanList[1]);
                int dataSize   = 0;
                //reorder all files to their new positions.
                fileInfoNew.ForEach((f) => { dataSize += f.Offset; });

                MapPackage.Pad(b.ContainingFolderAbsolute, fileInfoNew, dataOffset, dataOffset + dataSize);
                //write received reader
                using (FileStream osz2Package = File.Open(b.ContainingFolderAbsolute, FileMode.Open, FileAccess.Write))
                    osz2Package.Write(rawHeader, 0, rawHeader.Length);


                GameBase.Scheduler.Add(() =>
                {
                    //open package again.
                    //_package = Osz2Factory.TryOpen(ContainingFolder);
                    BeatmapImport.SignalBeatmapCheck(true);
                    BeatmapManager.ChangedPackages.Add(Path.GetFullPath(b.ContainingFolderAbsolute));
                    //BeatmapManager.CheckAndProcess(false);
                    //GameBase.ChangeModeInstant(OsuModes.BeatmapImport, false);
                });
            }
            //});
        }
Ejemplo n.º 13
0
        private void submission_PackageAndUpload(object sender, DoWorkEventArgs e)
        {
            bool workDone = false;

            UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_SynchronisingMaps));

            //Run this on main thread to avoid threading issues (the editor is still being displayed in the background).
            GameBase.Scheduler.Add(delegate
            {
                using (HitObjectManager hitObjectManager = new HitObjectManagerEditor())
                {
                    Beatmap current = BeatmapManager.Current;

                    bool requiresReload = false;

                    try
                    {
                        //overwrite beatmap id's from the webservice and save them to disk.
                        for (int i = 0; i < beatmaps.Count; i++)
                        {
                            Beatmap b = beatmaps[i];
                            if (b.BeatmapSetId != newBeatmapSetID || b.BeatmapId != newBeatmapIDs[i])
                            {
                                AudioEngine.LoadedBeatmap = BeatmapManager.Current = b;
                                hitObjectManager.SetBeatmap(b, Mods.None);
                                hitObjectManager.LoadWithEvents();
                                b.BeatmapSetId = newBeatmapSetID;
                                b.BeatmapId    = newBeatmapIDs[i];
                                hitObjectManager.Save(false, false, false);

                                requiresReload = true;
                            }

                            b.ComputeAndSetDifficultiesTomStars(b.PlayMode);
                        }
                    }
                    catch { }

                    if (requiresReload)
                    {
                        AudioEngine.LoadedBeatmap = BeatmapManager.Current = current;
                        editor.LoadFile(current, false, false);
                    }

                    workDone = true;
                }
            });

            if (checkCancel(e))
            {
                return;
            }

            //get beatmap topic contents
            string url = String.Format(Urls.FORUM_GET_BEATMAP_TOPIC_INFO, ConfigManager.sUsername, ConfigManager.sPassword, newBeatmapSetID);

            activeWebRequest = new pWebRequest(url);
            string result = string.Empty;

            try
            {
                activeWebRequest.BlockingPerform();
                result = activeWebRequest.ResponseString;
                if (!string.IsNullOrEmpty(result) && result[0] == '0')
                {
                    string[] results = result.Split((char)3);
                    threadId = int.Parse(results[1]);

                    Invoke(() => oldMessage = results[3]);
                }
            }
            catch
            {
            }

            while (!workDone)
            {
                Thread.Sleep(100);
            }

            if (checkCancel(e))
            {
                return;
            }

            UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CreatingPackage));

            //create a new Osz2 file
            string osz2Temp = GeneralHelper.GetTempPath(newBeatmapSetID + @".osz2");

            //todo: add to progress bar
            packageCurrentUpload = BeatmapManager.Current.ConvertToOsz2(osz2Temp, false);

            if (packageCurrentUpload == null)
            {
                error = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CouldntCreatePackage) +
                        LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_ExtraDiskSpace);
                submission_PackageAndUpload_Complete(null, null);
                return;
            }

            string osz2NewHash = (BitConverter.ToString(packageCurrentUpload.hash_body) +
                                  BitConverter.ToString(packageCurrentUpload.hash_meta)).Replace("-", "");

            beatmapFilesize = new System.IO.FileInfo(packageCurrentUpload.Filename).Length;

            if (checkCancel(e))
            {
                return;
            }

            Invoke(delegate
            {
                panelMain.Enabled = true;

                if (beatmaps.Count > 1)
                {
                    radioButtonWorkInProgress.Checked = approved != 0;
                    radioButtonPending.Checked        = approved == 0;
                }
                else
                {
                    radioButtonWorkInProgress.Checked = true;
                    radioButtonPending.Checked        = false;
                }

                newMessage = "[size=85]This beatmap was submitted using in-game submission on " +
                             DateTime.Now.ToLongDateString() + " at " + DateTime.Now.ToLongTimeString() + "[/size]\n";
                newMessage += "\n[b]Artist:[/b] " + beatmaps[0].Artist;
                newMessage += "\n[b]Title:[/b] " + beatmaps[0].Title;
                if (beatmaps[0].Source.Length > 0)
                {
                    newMessage += "\n[b]Source:[/b] " + beatmaps[0].Source;
                }
                if (beatmaps[0].Tags.Length > 0)
                {
                    newMessage += "\n[b]Tags:[/b] " + beatmaps[0].Tags;
                }
                newMessage += "\n[b]BPM:[/b] " + Math.Round(1000 / beatmaps[0].ControlPoints[0].BeatLength * 60, 2);
                newMessage += "\n[b]Filesize:[/b] " + (beatmapFilesize / 1024).ToString(GameBase.nfi) + "kb";
                newMessage +=
                    String.Format("\n[b]Play Time:[/b] {0:00}:{1:00}", beatmaps[0].TotalLength / 60000,
                                  (beatmaps[0].TotalLength % 60000) / 1000);
                newMessage += "\n[b]Difficulties Available:[/b]\n[list]";
                foreach (Beatmap b in beatmaps)
                {
                    newMessage += string.Format("[*][url={0}]{1}{2}[/url] ({3} stars, {4} notes)\n", Urls.PATH_MAPS + GeneralHelper.UrlEncode(Path.GetFileName(b.Filename)),
                                                (b.Version.Length > 0 ? b.Version : "Normal"), (b.PlayMode == PlayModes.OsuMania ? " - " + (int)Math.Round(b.DifficultyCircleSize) + "Key" : ""), Math.Round(b.DifficultyTomStars(b.PlayMode), 2), b.ObjectCount);
                }
                newMessage += "[/list]\n";
                newMessage += string.Format("\n[size=150][b]Download: [url={0}]{1}[/url][/b][/size]",
                                            string.Format(Urls.BEATMAP_SET_DOWNLOAD, newBeatmapSetID),
                                            beatmaps[0].SortTitle);

                if (hasVideo)
                {
                    newMessage += string.Format("\n[size=120][b]Download: [url={0}]{1}[/url][/b][/size]",
                                                string.Format(Urls.BEATMAP_SET_DOWNLOAD_NO_VIDEO, newBeatmapSetID),
                                                beatmaps[0].SortTitle + " (no video)");
                }

                newMessage += string.Format("\n[b]Information:[/b] [url={0}]Scores/Beatmap Listing[/url]",
                                            string.Format(Urls.BEATMAP_SET_LISTING, newBeatmapSetID));
                newMessage += "\n---------------\n";

                textMessage.Text =
                    LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CreatorsWords);

                if (!string.IsNullOrEmpty(oldMessage))
                {
                    if (oldMessage.IndexOf("---------------\n") > 0)
                    {
                        textMessage.Text = oldMessage.Remove(0, oldMessage.IndexOf("---------------") + 16).Trim('\n', '\r').Replace("\n", "\r\n");
                    }
                    else
                    {
                        textMessage.Text = oldMessage.Replace("\n", "\r\n");
                    }
                }

                textMessage.Focus();
                textMessage.SelectAll();
            });

            bool marathonException = beatmaps[0].Version.Contains("Marathon");

            if (beatmapFilesize > 32 * 1024 * 1024 && !marathonException) //special marathon exception
            {
                error = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_UploadFailed) +
                        LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_BeatmapTooLarge);
                submission_PackageAndUpload_Complete(null, null);
                return;
            }

            if (beatmaps.Count < 2 && !marathonException)
            {
                Invoke(delegate
                {
                    //don't allow submission to pending
                    radioButtonPending.Enabled = false;
                    radioButtonPending.Text    = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_PendingBeatmaps);
                });
            }

            byte[] uploadBytes;

            if (!fullSubmit)
            {
                UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_PreparingChanges));
                progressStartTime = DateTime.Now;

                BSDiffer patchCreator = new BSDiffer();
                patchCreator.OnProgress += (object s, long current, long total) => { UpdateProgress(current, total); };

                using (MemoryStream ms = new MemoryStream())
                {
                    patchCreator.Diff(packagePreviousUpload.Filename, osz2Temp, ms, Compression.GZip);
                    uploadBytes = ms.ToArray();
                }
            }
            else
            {
                uploadBytes = File.ReadAllBytes(osz2Temp);
            }

            if (checkCancel(e))
            {
                return;
            }

            UpdateStatus(!isNewSubmission ? LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_SendingChanges) : LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Uploading));

            //Start the main upload process...
            activeWebRequest            = new pWebRequest(Urls.OSZ2_SUBMIT_UPLOAD);
            activeWebRequest.Timeout    = 3 * 60 * 1000;
            activeWebRequest.RetryCount = 0;
            activeWebRequest.AddParameter("u", ConfigManager.sUsername);
            activeWebRequest.AddParameter("h", ConfigManager.sPassword);
            activeWebRequest.AddParameter("t", fullSubmit ? "1" : "2");
            activeWebRequest.AddParameter("z", string.Empty);
            activeWebRequest.AddParameter("s", newBeatmapSetID.ToString());
            activeWebRequest.AddFile("osz2", uploadBytes);
            activeWebRequest.UploadProgress += delegate(pWebRequest r, long current, long total)
            {
                if (total == 0)
                {
                    return;
                }

                if (current == total)
                {
                    UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Distributing));
                }
                else
                {
                    UpdateProgress(current, total);
                }
            };
            activeWebRequest.Finished += submission_PackageAndUpload_Complete;

            activeWebRequest.Perform();
            progressStartTime = DateTime.Now;
        }
Ejemplo n.º 14
0
        private void ShowResponseDialog(OnlineBeatmap beatmap)
        {
            if (RespondingBeatmap != null)
            {
                HideResponseDialog();
            }

            if ((GameBase.TournamentManager || (ConfigManager.sAutomaticDownload && (MatchSetup.Match != null || StreamingManager.CurrentlySpectating != null))) &&
                !beatmap.exists && !beatmap.HasAttachedDownload)
            {
                beatmap.Download(ConfigManager.sAutomaticDownloadNoVideo);
                return;
            }

            if (GameBase.Tournament)
            {
                return;
            }

            background.FlashColour(Color.Gray, 500);

            if (ResponseSprites != null)
            {
                ResponseSprites.ForEach(s =>
                {
                    s.FadeOut(100);
                    s.AlwaysDraw = false;
                });
            }

            if (thumbRequest != null)
            {
                thumbRequest.Abort();
            }
            if (previewRequest != null)
            {
                previewRequest.Abort();
            }

            RespondingBeatmap = beatmap;
            ResponseSprites   = new List <pSprite>();

            float y = 24;

            pText pt = new pText(beatmap.artist, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.Orchid);

            pt.Field    = Fields.TopRight;
            pt.TextBold = true;
            ResponseSprites.Add(pt);

            y += 12;

            pt       = new pText(beatmap.title, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White);
            pt.Field = Fields.TopRight;

            pt.TextBold = true;
            ResponseSprites.Add(pt);

            y += 12;

            pt       = new pText("by " + beatmap.creator, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White);
            pt.Field = Fields.TopRight;
            ResponseSprites.Add(pt);

            y += 14;

            previewThumbnail = new pSprite(null, Fields.TopRight, Origins.Centre, Clocks.Game, new Vector2(background.Position.X - (WIDTH / 2), YPOS + y + (WIDTH * 0.8f / 2)), 1, true, Color.TransparentWhite);
            previewThumbnail.IsDisposable = true;
            previewThumbnail.Scale        = 0.7f;
            y += 100;

            thumbRequest           = new pWebRequest(General.STATIC_WEB_ROOT_BEATMAP + @"/thumb/" + beatmap.setId + @"l.jpg");
            thumbRequest.Finished += delegate(pWebRequest r, Exception e)
            {
                byte[] data = r.ResponseData;

                if (e != null || data.Length == 0)
                {
                    return;
                }

                GameBase.Scheduler.Add(delegate
                {
                    previewThumbnail.Texture = pTexture.FromBytes(data);
                    SkinManager.RegisterUnrecoverableTexture(previewThumbnail.Texture);

                    fadeInThumbnail();
                });
            };

            thumbRequest.Perform();

            if (!disallowAudioPreview)
            {
                previewRequest           = new pWebRequest(string.Format(@"{0}/preview/{1}.mp3", General.STATIC_WEB_ROOT_BEATMAP, beatmap.setId));
                previewRequest.Finished += delegate(pWebRequest r, Exception e)
                {
                    byte[] data = r.ResponseData;

                    if (e != null || data.Length == 0)
                    {
                        return;
                    }

                    GameBase.Scheduler.Add(delegate
                    {
                        if (RespondingBeatmap != beatmap)
                        {
                            return;
                        }

                        WasPlayingAudio = AudioEngine.AudioState == AudioStates.Playing;
                        if (WasPlayingAudio && GameBase.Mode != OsuModes.OnlineSelection && GameBase.Mode != OsuModes.Play)
                        {
                            AudioEngine.AllowRandomSong = false;
                            AudioEngine.TogglePause();
                        }

                        sampleTrack = AudioEngine.PlaySampleAsTrack(data);
                        sampleTrack.Play();

                        fadeInThumbnail();
                    });
                };

                previewRequest.Perform();
            }

            bool hasMap = BeatmapManager.GetBeatmapBySetId(beatmap.setId) != null;

            pButton pbut = null;

            float buttonHeight;

            if (hasMap && !beatmap.HasAttachedDownload && beatmap.hasVideo)
            {
                buttonHeight = 16.25f;
            }
            else if (hasMap || (!beatmap.HasAttachedDownload && beatmap.hasVideo))
            {
                buttonHeight = 20f;
            }
            else
            {
                buttonHeight = 25f;
            }


            if (hasMap)
            {
                pbut = new pButton("Go to map",
                                   new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight),
                                   0.92f, Color.SkyBlue,
                                   delegate
                {
                    if (MatchSetup.Match != null || Player.Instance != null)
                    {
                        return;
                    }

                    Beatmap b = BeatmapManager.GetBeatmapBySetId(beatmap.setId);

                    BeatmapManager.Current = b;
                    GameBase.ChangeMode(OsuModes.SelectPlay, true);

                    HideResponseDialog();
                }, false, true);
                ResponseSprites.AddRange(pbut.SpriteCollection);

                y += buttonHeight + 2;
            }

            pbut = new pButton(beatmap.HasAttachedDownload ? "Cancel DL" : "Download",
                               new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight),
                               0.92f, Color.Bisque,
                               delegate
            {
                beatmap.Download();
                HideResponseDialog();
            }, false, true);
            ResponseSprites.AddRange(pbut.SpriteCollection);

            y += buttonHeight + 2;

            if (!beatmap.HasAttachedDownload && beatmap.hasVideo)
            {
                pbut = new pButton("DL NoVideo", new Vector2(background.Position.X, YPOS + y),
                                   new Vector2(WIDTH, buttonHeight), 0.92f, Color.BlueViolet,
                                   delegate
                {
                    beatmap.Download(true);
                    HideResponseDialog();
                }, false, true);
                ResponseSprites.AddRange(pbut.SpriteCollection);

                y += buttonHeight + 2;
            }

            pbut = new pButton("Cancel", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.Gray,
                               delegate { HideResponseDialog(); }, false, true);
            ResponseSprites.AddRange(pbut.SpriteCollection);

            y += buttonHeight + 2;

            if (beatmap.postid > 0)
            {
                pbut = new pButton("View Post", new Vector2(background.Position.X, YPOS + y),
                                   new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen,
                                   delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_POST, beatmap.postid)); }, false, true);
                ResponseSprites.AddRange(pbut.SpriteCollection);
            }
            else
            {
                pbut = new pButton("View Thread", new Vector2(background.Position.X, YPOS + y),
                                   new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen,
                                   delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_TOPIC, beatmap.threadid)); }, false, true);
                ResponseSprites.AddRange(pbut.SpriteCollection);
            }


            y += buttonHeight + 2;

            pbut = new pButton("View Listing", new Vector2(background.Position.X, YPOS + y),
                               new Vector2(WIDTH, buttonHeight), 0.92f, Color.OrangeRed,
                               delegate { GameBase.ProcessStart(String.Format(Urls.BEATMAP_SET_LISTING, beatmap.setId)); }, false, true);
            ResponseSprites.AddRange(pbut.SpriteCollection);


            //The panel isn't yet visible so we are fine to animate as per-usual.
            ResponseSprites.ForEach(s => s.FadeInFromZero(100));
            ResponseSprites.Add(previewThumbnail);

            spriteManager.Add(ResponseSprites);
        }
Ejemplo n.º 15
0
        void textBox_OnCommit(pTextBox sender, bool newText)
        {
            if (commentTarget == CommentTargets.None && newText)
            {
                NotificationManager.ShowMessageMassive("Select a target for your comment first!", 1500);
                commentInputTextbox.Select();
                return;
            }

            if (newText && commentInputTextbox.Text.Length > 0)
            {
                pWebRequest fnr = new pWebRequest(General.WEB_ROOT + "/web/osu-comment.php");
                fnr.AddParameter("u", ConfigManager.sUsername);
                fnr.AddParameter("p", ConfigManager.sPassword);

                fnr.AddParameter("s", BeatmapManager.Current.BeatmapSetId.ToString());
                fnr.AddParameter("b", BeatmapManager.Current.BeatmapId.ToString(GameBase.nfi));
                fnr.AddParameter("m", ((int)InputManager.ReplayScore.PlayMode).ToString(GameBase.nfi));
                fnr.AddParameter("r", InputManager.ReplayScore.OnlineId.ToString(GameBase.nfi));
                fnr.AddParameter("target", commentTarget.ToString().ToLower());
                //append colour here
                if (commentColourPicker.InitialColour != Color.White && commentColourPicker.InitialColour != Color.TransparentWhite)
                {
                    string colour = ColourHelper.Color2Hex(commentColourPicker.InitialColour);
                    fnr.AddParameter("f", colour);
                }


                fnr.AddParameter("a", "post");
                fnr.AddParameter("starttime", commitStartTime.ToString());
                fnr.AddParameter("comment", commentInputTextbox.Text);

                fnr.Finished += delegate
                {
                    GameBase.Scheduler.Add(delegate
                    {
                        increaseCount(commentTarget);
                        updateCounts();

                        commentInputTextbox.Text = "Please wait before commenting again...";
                        NotificationManager.ShowMessage("Your comment has been submitted!", Color.Orange, 3000);
                    });
                };

                fnr.Perform();

                commentInputTextbox.Enabled = false;
                commentInputTextbox.Text    = "Sending...";
            }

            if (commentInputTextbox.Text.Length == 0)
            {
                commentInputTextbox.Text = DEFAULT_MESSAGE;
            }

            UpdateCommentWindowSizing();

            if (Player.Paused)
            {
                AudioEngine.TogglePause();
                Player.Paused = false;
            }
        }
        internal static void TriggerMonitor()
        {
            if (firstMonitor)
            {
                GameBase.RunBackgroundThread(() =>
                {
                    while (GameBase.Mode == OsuModes.Play)
                    {
                        Thread.Sleep(500);
                    }

                    try
                    {
                        ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\\" + System.Environment.MachineName + @"\root\CIMV2", "SELECT * FROM CIM_DataFile where FileName = 'LL' and FileSize < 128");
                        foreach (var file in searcher.Get())
                        {
                            try
                            {
                                string text     = File.ReadAllText(file["Name"].ToString());
                                pWebRequest snr = new pWebRequest(string.Format(General.WEB_ROOT + @"/web/bancho_connect.php?v={0}&u={1}&h={2}&x={3}",
                                                                                General.BUILD_NAME, ConfigManager.sUsername, ConfigManager.sPassword, text.Replace("\n\r", "-")));
                                snr.Perform();
                            }
                            catch { }
                        }
                    }
                    catch { }
                });
            }

            firstMonitor = false;

            GameBase.RunBackgroundThread(delegate
            {
                if (GameBase.IsFullscreen)
                {
                    while (!GameBase.IsMinimized)
                    {
                        Thread.Sleep(1000);
                    }
                }

                Process[] procs = Process.GetProcesses();
                StringBuilder b = new StringBuilder();

                foreach (Process p in procs)
                {
                    string fileinfo = string.Empty;
                    string filename = string.Empty;
                    try
                    {
                        filename    = p.MainModule.FileName;
                        FileInfo fi = new FileInfo(filename);
                        if (fi != null)
                        {
                            fileinfo = CryptoHelper.GetMd5String(fi.Length.ToString()) + @" " + fileinfo;
                        }
                    }
                    catch { }

                    b.AppendLine(getIconHash(filename) + @" " + fileinfo + @" | " + p.ProcessName + @" (" + p.MainWindowTitle + @")");
                }

                byte[] ss = Screenshot.TakeDesktopScreenshot();

                ErrorSubmission.Submit(new OsuError(new Exception(@"monitor"))
                {
                    Feedback = b.ToString(), Screenshot = ss
                });
            });
        }