Exemplo n.º 1
0
        void dr_downloadFinish(Song song, int diff)
        {
            Replay replay = null;

            if (System.IO.File.Exists("replay\\" + Utils.calcHash(song.Charts[diff].Path) + ".pcr"))
            {
                replay = ScoreLibrary.reconReplay("replay\\" + Utils.calcHash(song.Charts[diff].Path) + ".pcr");
                System.IO.File.Delete("replay\\" + Utils.calcHash(song.Charts[diff].Path) + ".pcr");
            }
            IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];

            if (replay != null)
            {
                temp.loadSong(song, diff, replay.Mods, replay, IngameScreen.PlayType.REPLAY);
                temp.Music.stop();
                Game.setScreen(game.screens["ingameScreen"]);
                game.Title         = "Pulse | Watch replay | " + song.Artist + " - " + song.SongName + " [" + song.Charts[diff].Name + "]";
                exitButton.Visible = true;
                exitButton.Enabled = true;
            }
            else
            {
                Console.WriteLine("no replay");
                Game.addToast("No replay available for this score");
                exitButton.Visible = true;
                exitButton.Enabled = true;
            }
        }
Exemplo n.º 2
0
        public void setScore(Score score, Song song, int diff, int rank)
        {
            this.score         = score;
            scoreLabel.Text    = score.TotalScore.ToString("D8");
            accuracyLabel.Text = String.Format("{0:0.00}%", score.Accuracy);
            maxComboLabel.Text = "" + score.MaxCombo + "x";
            dateLabel.Text     = score.dateString;
            statsLabel.Text    = "Perfect: " + "\nGood: " + "\nOK: " + "\nMiss: ";
            statsNoLabel.Text  = "" + score.Perfects + "\n" + score.Goods + "\n" + score.Oks + "\n" + score.Misses;
            string songinf = score.ArtistTitle;

            if (songinf.Length < 26)
            {
                songInfoLabel.Text = songinf.Substring(0, songinf.Length) + " [" + score.chartName + "]";
            }
            else
            {
                songInfoLabel.Text = songinf.Substring(0, 25) + "... [" + score.chartName + "]";
            }
            if (score.ReplayName != "")
            {
                replayButton = new Button(game, new Rectangle(Config.ResWidth - (int)(Config.ResWidth * 0.3), 330, 100, 50), "Replay", delegate(int data)
                {
                    IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                    if (Config.LocalScores)
                    {
                        Replay replay = ScoreLibrary.reconReplay("replay\\r\\" + score.ReplayName + ".pcr");
                        try
                        {
                            temp.loadSong(song, diff, replay.Mods, replay, IngameScreen.PlayType.REPLAY);
                            temp.Music.stop();
                            Game.setScreen(game.screens["ingameScreen"]);
                            game.Title = "Pulse | Watch replay | " + song.Artist + " - " + song.SongName + " [" + song.Charts[diff].Name + "]";
                        }
                        catch { }
                    }
                    else
                    {
                        string hash = Utils.calcHash(song.Charts[diff].Path);
                        string dl   = "http://p.ulse.net/getreplay?r=" + rank + "&c=" + hash;
                        Console.WriteLine("{0} rank {1} hash", rank, hash);
                        downloadReplay dr  = new downloadReplay();
                        dr.downloadFinish += new Action <Song, int>(dr_downloadFinish);
                        dr.DownloadReplay(dl, "replay\\" + hash + ".pcr", song, diff);
                        // wc.DownloadFileAsync(new Uri(dl), "replay\\temp.pcr");
                        //wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
                        replayButton.Enabled = false;
                        replayButton.Visible = false;
                        exitButton.Enabled   = false;
                        exitButton.Visible   = false;
                        Game.addToast("Downloading replay...");
                    }
                });
                if (!UIComponents.Contains(replayButton))
                {
                    UIComponents.Add(replayButton);
                }
            }
        }
Exemplo n.º 3
0
        //gl context problems... again!
        void uc_uploadDone(string obj, int tIndex)
        {
            //  Game.game.MakeCurrent();
            updateScore = true;
            Score me = null;

            displayScores = ScoreLibrary.parseOnline(obj, ref me, currentSong, tIndex);
            currtIndex    = tIndex;
            gotScore      = false;
            Console.WriteLine("found");
        }
Exemplo n.º 4
0
        private void updateScoreLabels(int e)
        {
            scoreDisplayText.Clear();
            //gotScore = false;
            if (!pickDiff)
            {
                displayScores = null;
                return;
            }
            SongInfo ss = songNameList[index].Info;

            scoreDisplayPage = e;
            //Console.WriteLine("updating score labels");
            int tIndex = 0;

            for (int x = 0; x < currentSong.Charts.Count; x++)
            {
                if (currentSong.Charts[x].Name.Equals(diffs.BaseText.Line))
                {
                    tIndex = x;
                }
            }
            String diffName = currentSong.Charts[tIndex].Name;

            if (currentSong.FileVersion == 1)
            {
                if (Config.LocalScores)
                {
                    string tempFileName = ScoreLibrary.getFileFromDiff(ss, diffName);
                    string hash         = Utils.calcHash(tempFileName);
                    //  List<Score> tempList = null;
                    if (File.Exists("replay\\" + hash + ".psf"))
                    {
                        if (currentUpload != null)
                        {
                            currentUpload.abort();
                        }
                        displayScores = ScoreLibrary.reconstruct("replay\\" + hash + ".psf");
                        displayScores.Sort(scoreCompare);
                        scoreDisplayText.Clear();
                        //if calculated upper bound exceeds displayscores.count, use count as upper bound instead
                        int upperlimit = displayScores.Count > scoreDisplayPage * 8 + 8 ? scoreDisplayPage * 8 + 8 : displayScores.Count;

                        for (int i = scoreDisplayPage * 8; i < upperlimit; i++)
                        {
                            int    toset = i;
                            int    loc   = (i == 0 ? 0 : (i % 8));
                            Button toAdd = new Button(game, new Rectangle(Config.ResWidth, 200 + (loc * 60) + (loc * 1) /*1 px padding*/, 230, 60), "#" + (toset + 1) + " " + displayScores[toset].Player + " " + displayScores[toset].TotalScore.ToString("D8"), delegate(int data)
                            {
                                ScoreSelectScreen temp = (ScoreSelectScreen)game.screens["sSScreen"];
                                Game.setScreen(temp);
                                temp.Music = this.Music;
                                temp.setScore(displayScores[toset], currentSong, tIndex, data);
                            }, Skin.skindict["scoreentry"]);
                            toAdd.OtherData = i + 1;
                            scoreDisplayText.Add(toAdd);
                        }
                        return;
                    }
                    else
                    {
                        displayScores = null;
                        return;
                    }
                }
                else
                {
                    if (Account.currentAccount != null)
                    {
                        //online scores TODO
                        if (!gotScore)
                        {
                            gotScore = true;
                            string hash           = Utils.calcHash(currentSong.Charts[tIndex].Path);
                            NameValueCollection n = new NameValueCollection();
                            n.Add("n", Account.currentAccount.AccountName);
                            n.Add("c", hash);

                            scoreDisplayText.Clear();
                            if (currentUpload != null)
                            {
                                //currentUpload.abort();
                            }
                            UploadClass uc = new UploadClass();
                            currentUpload    = uc;
                            uc.additionalArg = tIndex; //hacky
                            uc.uploadDone   += new Action <string, int>(uc_uploadDone);
                            uc.HttpUploadFileAsync("http://p.ulse.net/getscores", n);
                        }
                        //Game.game.Context.MakeCurrent(null); not gonna fly ;x

                        /*  I feel like I am flying so free across the sky
                         *  Like i'm diving in the air
                         *  I fly high the way you want it
                         *
                         *  Just gotta the way you want it.
                         *
                         *  Don't trip on the people
                         *  And things around you now
                         *  Keep lookin' ahead cousin
                         *  So glide on until you find it
                         *
                         *  Just gotta until you find it
                         *  In this limitless sky
                         *
                         *  Full speed ahead and I get high
                         *  Open the window (Look up the sky)
                         *  (That's the floating island in the legendary world)
                         *  Future is eternal, (Light, early-morning sunlight)
                         *  (The greatest, open up, look now with your left eye)
                         *
                         *  It's all a weird-ass place i'm in so weird a place
                         *  I'm tripping-out passing time
                         *  It's a wonderful way to free my mind
                         *  Up in the sky
                         *  I'm content to keep on flying.*/
                    }
                    else
                    {
                        Config.LocalScores = true;
                        ((ToggleButton)onlineToggle).toggle();
                    }
                }
            }
        }