protected void star_OnClick(object sender, EventArgs e)
        {
            int    rating = ((pSprite)sender).TagNumeric;
            string url    = "http://osu.ppy.sh/rating/ingame-rate.php?u=" + ConfigManager.sUsername + "&p=" +
                            ConfigManager.sPassword + "&c=" + BeatmapManager.Current.BeatmapChecksum + "&v=" +
                            rating;
            StringNetRequest request = new StringNetRequest(url);

            request.onFinish += submitSuccess;

            acceptRating = false;
            foreach (pSprite s in star)
            {
                s.IsClickable = false;

                if (s.TagNumeric > rating)
                {
                    s.FadeOut(500);
                }
                else
                {
                    s.FadeColour(Color.YellowGreen, 500);
                }
                if (s.CurrentScale > 1)
                {
                    s.Transformations.Add(
                        new Transformation(TransformationType.Scale, s.CurrentScale, 1, GameBase.Time,
                                           GameBase.Time + 500));
                }
            }
            ratingText.Text = "Submitting rating...";

            NetManager.AddRequest(request);
        }
Exemple #2
0
        public NewsButton()
        {
            newsButton          = new pSprite(TextureManager.Load(OsuTexture.news_button), FieldTypes.StandardSnapBottomLeft, OriginTypes.BottomLeft, ClockTypes.Mode, Vector2.Zero, 0.8f, true, Color4.White);
            newsButton.OnClick += newsButton_OnClick;
            Add(newsButton);

            newsLight          = new pSprite(TextureManager.Load(OsuTexture.news_light), FieldTypes.StandardSnapBottomLeft, OriginTypes.BottomLeft, ClockTypes.Mode, new Vector2(3, 13f), 0.81f, true, Color4.White);
            newsLight.Additive = true;

            newsLight.Transform(new TransformationF(TransformationType.Fade, 0, 1, 0, 300, EasingTypes.Out)
            {
                Looping = true, LoopDelay = 1500
            });
            newsLight.Transform(new TransformationF(TransformationType.Fade, 1, 0, 300, 1500, EasingTypes.Out)
            {
                Looping = true, LoopDelay = 600
            });
            Add(newsLight);

            newsLight.Bypass = true;

            string lastRead      = GameBase.Config.GetValue("NewsLastRead", string.Empty);
            string lastRetrieved = GameBase.Config.GetValue("NewsLastRetrieved", string.Empty);

            if (lastRead == string.Empty || lastRetrieved != lastRead)
            {
                HasNews = true;
            }

            StringNetRequest nr = new StringNetRequest(@"https://osustream.com/misc/news.php?v=2");

            nr.onFinish += newsCheck_onFinish;
            NetManager.AddRequest(nr);
        }
Exemple #3
0
        public static void Report(string contents)
        {
#if iOS
            contents += "&device=" + (int)osum.Support.iPhone.HardwareDetection.Version;
            contents += "&version=" + Foundation.NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();
#endif
            StringNetRequest nr = new StringNetRequest("https://www.osustream.com/admin/crash.php", "POST", "exception=" + contents);
            NetManager.AddRequest(nr);
        }
Exemple #4
0
        internal void GetOnlineScores(bool getScores)
        {
            if (RetrievingOnlineScores)
            {
                return;
            }
            RetrievingOnlineScores = true;
            string url = "http://osu.ppy.sh/web/osu-getscores3.php?s=" + (getScores ? "0" : "1") + "&c=" + BeatmapChecksum + "&f=" +
                         GeneralHelper.UrlEncode(Path.GetFileName(Filename));
            StringNetRequest request = new StringNetRequest(url);

            request.onFinish += doGetOnlineScores;
            NetManager.AddRequest(request);
        }
        private void Ranking_Hide()
        {
            if (rankingNetRequest != null)
            {
                rankingNetRequest.Abort();
                rankingNetRequest = null;
            }

            spriteManagerDifficultySelect.FadeIn(200);
            rankingSpriteManager.FadeOut(200);

            GameBase.ShowLoadingOverlay = false;

            showDifficultySelection2();

            rankingScores = null;
        }
        private void Ranking_Show()
        {
            State = SelectState.RankingDisplay;

            if (spriteManagerDifficultySelect != null)
            {
                spriteManagerDifficultySelect.FadeOut(200);
            }

            if (rankingSpriteManager != null)
            {
                rankingSpriteManager.Clear();
                rankingSpriteManager.FadeIn(0);
                rankingSpriteManager.ScrollTo(0);
            }
            else
            {
                rankingSpriteManager = new SpriteManagerDraggable {
                    StartBufferZone = BeatmapPanel.PANEL_HEIGHT + 5
                };
            }

            footerHide();

            GameBase.ShowLoadingOverlay = true;

            if (s_SongInfo != null)
            {
                s_SongInfo.FadeOut(100);
            }

            int period = 0;

            rankingNetRequest = new StringNetRequest(@"https://osustream.com/score/retrieve.php", "POST",
                                                     "udid=" + GameBase.Instance.DeviceIdentifier +
                                                     "&filename=" + NetRequest.UrlEncode(Path.GetFileName(Player.Beatmap.ContainerFilename)) +
                                                     "&period=" + period +
                                                     "&difficulty=" + (int)Player.Difficulty);

            rankingNetRequest.onFinish += rankingReceived;

            NetManager.AddRequest(rankingNetRequest);
        }
        public RankingDialog(Ranking ranking)
            : base("", true)
        {
            score = ranking.score;

            int recordingStartTime = GameBase.Time;

            highScorePosition = ScoreManager.InsertScore(score, true, true);

            if (ConfigManager.sUsername.Length > 0)
            {
                string url = "http://osu.ppy.sh/rating/ingame-rate.php?u=" + ConfigManager.sUsername + "&p=" +
                             ConfigManager.sPassword + "&c=" + BeatmapManager.Current.BeatmapChecksum;
                StringNetRequest request = new StringNetRequest(url);
                request.onFinish += checkRatingAvailable;
                NetManager.AddRequest(request);
            }

            vspacing = 20;
            if (highScorePosition > -1)
            {
                pSprite p =
                    new pText("You achieved the #" + highScorePosition + " local score!", 22, new Vector2(320, vspacing),
                              1F,
                              true, Color.YellowGreen);
                p.OriginType = OriginTypes.Centre;
                Transformation t =
                    new Transformation(TransformationType.Fade, 0, 1, recordingStartTime + 300, recordingStartTime + 400);
                p.Transformations.Add(t);
                SpriteCollection.Add(p);

                vspacing += 25;

                p =
                    new pText("Please enter your name:", 18, new Vector2(320, vspacing), 1F, true,
                              Color.TransparentWhite);
                p.OriginType = OriginTypes.Centre;
                t            =
                    new Transformation(TransformationType.Fade, 0, 1, recordingStartTime + 300, recordingStartTime + 400);
                p.Transformations.Add(t);
                SpriteCollection.Add(p);

                vspacing += 18;

                p =
                    new pSprite(GameBase.WhitePixel, FieldTypes.Window, OriginTypes.TopLeft, ClockTypes.Game,
                                new Vector2(120, vspacing), 0.94F, true, new Color(80, 80, 80, 150));
                p.UseVectorScale = true;
                p.VectorScale    = new Vector2(640, 40);
                SpriteCollection.Add(p);

                recordingEntry =
                    new pText(ConfigManager.sUsername, 22, new Vector2(120, vspacing), new Vector2(400, 40), 0.95f, true,
                              Color.TransparentWhite, false);
                recordingEntry.TextAlignment = Alignment.Centre;
                SpriteCollection.Add(recordingEntry);

                vspacing += 30;

                saveReplay =
                    new pCheckbox(null, "Save local replay", new Vector2(140, vspacing), 0.95f,
                                  ConfigManager.sSaveReplay);
                SpriteCollection.AddRange(saveReplay.SpriteCollection);

                exportReplay = new pCheckbox(null, "Export replay as .osr", new Vector2(400, vspacing), 0.95f, false);
                SpriteCollection.AddRange(exportReplay.SpriteCollection);

                vspacing += 30;
            }
            else
            {
                pSprite p =
                    new pText("You failed to rank on the local charts!  Better luck next time.", 22,
                              new Vector2(320, vspacing),
                              1F,
                              true, Color.OrangeRed);
                p.OriginType = OriginTypes.Centre;
                SpriteCollection.Add(p);

                vspacing += 80;
            }

            OnlineRetrival = BeatmapManager.Current.submissionStatus == SubmissionStatus.Ranked &&
                             ConfigManager.sUsername.Length > 0;
            if (OnlineRetrival)
            {
                onlineRanking =
                    new pText("Retrieving online ranking statistics...", 22, new Vector2(0, vspacing),
                              new Vector2(640, 80), 1, true, Color.TransparentWhite,
                              false);
                onlineRanking.TextAlignment = Alignment.Centre;
                SpriteCollection.Add(onlineRanking);

                vspacing += 40;

                onlineRanking2 =
                    new pText("", 22, new Vector2(0, vspacing),
                              new Vector2(640, 80), 1, true, Color.TransparentWhite,
                              false);
                onlineRanking2.TextAlignment = Alignment.Centre;
                SpriteCollection.Add(onlineRanking2);

                if (score.submitting)
                {
                    score.SubmissionComplete += score_SubmissionComplete;
                }
                else
                {
                    score_SubmissionComplete(score);
                }

                vspacing += 40;
                GameBase.User.DrawAt(new Vector2(240, vspacing), false, 0);
                GameBase.User.Sprites[0].IsClickable = false;
                SpriteCollection.AddRange(GameBase.User.Sprites);
                vspacing += 65;
            }

            ratingText =
                new pText("Checking rating status...", 22, new Vector2(0, 340), new Vector2(640, 80), 0.98F, true,
                          Color.TransparentWhite, false);
            ratingText.TextAlignment = Alignment.Centre;
            SpriteCollection.Add(ratingText);

            pText pt =
                new pText("Close", 20, new Vector2(320, 440), Vector2.Zero, 0.96F, true, Color.Black, false);

            pt.OriginType = OriginTypes.Centre;
            SpriteCollection.Add(pt);

            pSprite pb =
                new pSprite(SkinManager.Load("menu-button-background"), FieldTypes.Window,
                            OriginTypes.Centre,
                            ClockTypes.Game,
                            new Vector2(320, 440), 0.95F, true, Color.White);

            pb.OnClick      += closeWindow;
            pb.CurrentScale  = 0.7F;
            pb.CurrentColour = new Color(0, 0, 0, 178);
            pb.IsClickable   = true;
            pb.HoverEffect   = new Transformation(Color.White, Color.PeachPuff, 0, 50);
            SpriteCollection.Add(pb);

            int offset = 55;

            for (int i = 0; i < 10; i++)
            {
                star[i] =
                    new pSprite(ranking.content.Load <Texture2D>("star"), FieldTypes.Window, OriginTypes.Centre,
                                ClockTypes.Game, new Vector2(160 + 32 * i, ratingText.CurrentPosition.Y + offset),
                                0.97F, true, Color.Black);
                star[i].TagNumeric = i + 1;

                SpriteCollection.Add(star[i]);
            }
        }
        private void rankingReceived(string _result, Exception e)
        {
            rankingNetRequest = null;

            if (e != null || _result == null)
            {
                //error occurred
                GameBase.Notify(LocalisationManager.GetString(OsuString.InternetFailed), delegate { Ranking_Hide(); });
                return;
            }

            try
            {
                rankingScores = new List <Score>();

                foreach (string s in _result.Split('\n'))
                {
                    if (s.Length == 0)
                    {
                        continue;
                    }

                    string[] split = s.Split('|');

                    int i = 0;

                    Score score = new Score
                    {
                        Id                = int.Parse(split[i++], GameBase.nfi),
                        OnlineRank        = int.Parse(split[i++], GameBase.nfi),
                        Username          = split[i++],
                        hitScore          = int.Parse(split[i++], GameBase.nfi),
                        comboBonusScore   = int.Parse(split[i++], GameBase.nfi),
                        spinnerBonusScore = int.Parse(split[i++], GameBase.nfi),
                        count300          = ushort.Parse(split[i++], GameBase.nfi),
                        count100          = ushort.Parse(split[i++], GameBase.nfi),
                        count50           = ushort.Parse(split[i++], GameBase.nfi),
                        countMiss         = ushort.Parse(split[i++], GameBase.nfi),
                        maxCombo          = ushort.Parse(split[i++], GameBase.nfi),
                        date              = UnixTimestamp.Parse(int.Parse(split[i++], GameBase.nfi)),
                        guest             = split[i++] == "1"
                    };

                    rankingScores.Add(score);
                }

                var text = new pText("Leaderboards have been frozen. Thanks for participating!", 14, new Vector2(0, 25), Vector2.Zero, 1, true, Color4.White, true);
                text.Origin = OriginTypes.Centre;
                text.Field  = FieldTypes.StandardSnapTopCentre;

                rankingSpriteManager.Add(text);

                int index = 0;
                foreach (Score score in rankingScores)
                {
                    ScorePanel sp = new ScorePanel(score, onScoreClicked);
                    sp.Sprites.ForEach(s => s.Position = new Vector2(0, 50 + (ScorePanel.PANEL_HEIGHT + 3) * index));

                    rankingSpriteManager.Add(sp);

                    index++;
                }

                GameBase.ShowLoadingOverlay = false;

                rankingSpriteManager.FadeInFromZero(300);
            }
            catch
            {
                GameBase.Notify(LocalisationManager.GetString(OsuString.InternetFailed), delegate { Ranking_Hide(); });
            }
        }
Exemple #9
0
        private void doSubmission()
        {
            int deviceType = 0;

#if iOS
            if (!GameBase.Mapper)
            {
                deviceType = (int)osum.Support.iPhone.HardwareDetection.Version;

                //todo: for iOS5 twitter authentication, we need to double-check we actually have auth.
                string hash = GameBase.Config.GetValue <string>("hash", null);
                if (hash == null)
                {
                    //todo: no twitter auth. are we not submitting anymore?
                    return;
                }
                else if (hash.StartsWith("ios-"))
                {
                    hash = hash.Substring(4);
                    using (ACAccountStore store = new ACAccountStore())
                    {
                        ACAccount account = store.FindAccount(hash);
                        if (account != null)
                        {
                            //yay, i think.
                            //todo: test that this actually checks grants (it should in theory).
                        }
                        else
                        {
                            GameBase.Notify("Twitter authentication failed. Please visit the options screen to login again.");
                            GameBase.Config.SetValue <string>("username", null);
                            GameBase.Config.SetValue <string>("hash", null);
                            GameBase.Config.SetValue <string>("twitterId", null);
                            GameBase.Config.SaveConfig();
                            return;
                        }
                    }
                }

                string check = CryptoHelper.GetMd5String("moocow" +
                                                         GameBase.Instance.DeviceIdentifier +
                                                         RankableScore.count100 +
                                                         RankableScore.count300 +
                                                         RankableScore.count50 +
                                                         RankableScore.countMiss +
                                                         RankableScore.maxCombo +
                                                         RankableScore.spinnerBonusScore +
                                                         RankableScore.comboBonusScore +
                                                         RankableScore.accuracyBonusScore +
                                                         RankableScore.Ranking +
                                                         Path.GetFileName(Player.Beatmap.ContainerFilename) +
                                                         deviceType +
                                                         RankableScore.hitScore +
                                                         (int)Player.Difficulty);

                string postString =
                    "udid=" + GameBase.Instance.DeviceIdentifier +
                    "&count300=" + RankableScore.count300 +
                    "&count100=" + RankableScore.count100 +
                    "&count50=" + RankableScore.count50 +
                    "&countMiss=" + RankableScore.countMiss +
                    "&maxCombo=" + RankableScore.maxCombo +
                    "&spinnerBonus=" + RankableScore.spinnerBonusScore +
                    "&comboBonus=" + RankableScore.comboBonusScore +
                    "&accuracyBonus=" + RankableScore.accuracyBonusScore +
                    "&hitScore=" + RankableScore.hitScore +
                    "&rank=" + RankableScore.Ranking +
                    "&filename=" + NetRequest.UrlEncode(Path.GetFileName(Player.Beatmap.ContainerFilename)) +
                    "&cc=" + GameBase.Config.GetValue <string>("hash", string.Empty) +
                    "&c=" + check +
                    "&difficulty=" + (int)Player.Difficulty +
                    "&username="******"username", string.Empty) +
                    "&twitterid=" + GameBase.Config.GetValue <string>("twitterId", string.Empty) +
                    "&dt=" + deviceType +
                    "&offset=" + avg;

                spriteSubmitting = new pSprite(TextureManager.Load(OsuTexture.songselect_audio_preview), FieldTypes.StandardSnapRight, OriginTypes.Centre, ClockTypes.Game, new Vector2(20, 20), 0.999f, true, Color4.White)
                {
                    ExactCoordinates = false,
                    DimImmune        = true,
                    ScaleScalar      = 0.7f
                };

                spriteSubmitting.Transform(new TransformationF(TransformationType.Rotation, 0, MathHelper.Pi * 2, Clock.Time, Clock.Time + 1500)
                {
                    Looping = true
                });
                GameBase.MainSpriteManager.Add(spriteSubmitting);
                spriteSubmitting.FadeInFromZero(300);

                StringNetRequest nr = new StringNetRequest("https://www.osustream.com/score/submit.php", "POST", postString);
                nr.onFinish += delegate(string result, Exception e)
                {
                    spriteSubmitting.AlwaysDraw = false;
                    if (e == null)
                    {
                        spriteSubmitting.FadeOut(200);
                        spriteSubmitting.ScaleTo(3, 200);
                        spriteSubmitting.Colour = Color4.YellowGreen;
                    }
                    else
                    {
                        spriteSubmitting.FadeOut(1000);
                        spriteSubmitting.ScaleTo(1.2f, 200, EasingTypes.In);
                        spriteSubmitting.Colour = Color4.Red;
                    }

                    if (e == null && result != null && result.StartsWith("message:"))
                    {
                        rankingNotification = new Notification("Ranking", result.Replace("message:", string.Empty), NotificationStyle.Okay);
                        if (finishedDisplaying)
                        {
                            GameBase.Notify(rankingNotification);
                        }
                    }
                };
                NetManager.AddRequest(nr);
            }
#endif
        }