コード例 #1
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;
            }
        }