Esempio n. 1
0
        public static List<Score> parseOnline(string s, ref Score myScore, Song song, int diff)
        {
            string[] youthem = s.Split('/');
            List<Score> scores = new List<Score>();
            if (youthem[0].Equals("no chart"))
            {
                return null;
            }
            if (!youthem[0].Equals(""))
            {
                Score temp = new Score();
                temp.ArtistTitle = song.Artist + " - " + song.SongName;
                temp.chartName = song.Charts[diff].Name;
                string[] i = youthem[0].Split('|');
                temp.Player = i[0];
                temp.TotalScore = Convert.ToInt32(i[1]);
                temp.Perfects = Convert.ToInt32(i[2]);
                temp.Goods = Convert.ToInt32(i[3]);
                temp.Oks = Convert.ToInt32(i[4]);
                temp.Misses = Convert.ToInt32(i[5]);
                temp.Accuracy = (float)Convert.ToDouble(i[6]);
                temp.MaxCombo = Convert.ToInt32(i[7]);
                temp.UnixTime = Convert.ToInt32(i[8]);
                myScore = temp;
            }
            try
            {
                string[] sc = youthem[1].Split('\\');
                for (int x = 0; x < sc.Length - 1; x++)
                {
                    Score temp = new Score();

                    temp.ArtistTitle = song.Artist + " - " + song.SongName;
                    temp.chartName = song.Charts[diff].Name;
                    string[] i = sc[x].Split('|');
                    temp.Player = i[0];
                    temp.TotalScore = Convert.ToInt32(i[1]);
                    temp.Perfects = Convert.ToInt32(i[2]);
                    temp.Goods = Convert.ToInt32(i[3]);
                    temp.Oks = Convert.ToInt32(i[4]);
                    temp.Misses = Convert.ToInt32(i[5]);
                    temp.Accuracy = (float)Convert.ToDouble(i[6]);
                    temp.MaxCombo = Convert.ToInt32(i[7]);
                    temp.UnixTime = Convert.ToInt32(i[8]);
                    scores.Add(temp);
                }
                Comparison<Score> scoreCompare = new Comparison<Score>(ScoreLibrary.CompareScores);
                scores.Sort(scoreCompare);
            }
            catch
            {
                return null;
            }
            return scores;
        }
Esempio n. 2
0
 public void DownloadReplay(string uri, string local, Song songg, int diffint)
 {
     song = songg;
     diff = diffint;
     t = new Thread(new ParameterizedThreadStart(download));
     t.IsBackground = true;
     List<object> o = new List<object>();
     o.Add(uri);
     o.Add(local);
     o.Add(songg);
     o.Add(diffint);
     t.Start(o);
 }
Esempio n. 3
0
        public ScoreScreen(Game game, string name, Replay replay, Song song, int diff, bool play)
            : base(game, name)
        {
            if (play)
            {
                retryButton = new Button(game, new Rectangle(Config.ResWidth - (int)(Config.ResWidth * 0.3), 230, 100, 50), "Retry", delegate(int data)
                {
                    game.screens["ingameScreen"].Music.stop();
                    IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                    temp.loadSong(temp.CurrentSong, temp.Difficulty, temp.Mods, null, IngameScreen.PlayType.PLAY);
                    Game.setScreen(game.screens["ingameScreen"]);
                });
                UIComponents.Add(retryButton);
            }
            if (replay != null)
            {

                this.replay = replay;
                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"];
                    try
                    {
                        if (temp.Music != null)
                        {
                            temp.Music.stop();
                        }
                        temp.loadSong(song, diff, temp.Mods, this.replay, IngameScreen.PlayType.REPLAY);
                        Game.setScreen(temp);
                        game.Title = "Pulse | Watch replay | " + song.Artist + " - " + song.SongName + " [" + song.Charts[diff].Name + "]";
                    }
                    catch { }
                });
                UIComponents.Add(replayButton);
            }
        }
Esempio n. 4
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;
     }
 }
Esempio n. 5
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);
         }
     }
 }
Esempio n. 6
0
 private void changeSong()
 {
     if (background != null)
     {
         Game.M.setSong(ref songNameList[index].Info);
         currentSong = Game.M.CurrentSong;
         targetVolume = Config.Volume / 100.0f;
         Music.stop();
         string bgString = "";
         if (currentSong.FileVersion == 0)
         {
             bgString = currentSong.BgName;
         }
         else
         {
             bgString = currentSong.Charts[0].BgName;
         }
         background.useTexture("songs\\" + currentSong.Dir + "\\" + bgString);
         updateScoreLabels(0);
         music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
         Music.Volume = 0.0f;
         Music.PositionAsMilli = (long)currentSong.Preview;
         Music.play(false, true);
         changed = true;
         transitioning = true;
         difficultyTexts.Clear();
         updateDiffs();
     }
     for (int x = 0; x < songNameList.Count; x++)
     {
         songNameList[x].select.moveY(new Point(songNameList[x].select.Bounds.X, 246 + ((x - index) * 90)), 0.3);
     }
     if (currentlySelected != null)
     {
         currentlySelected.selected = false;
     }
     songNameList[index].select.selected = true;
     currentlySelected = songNameList[index].select;
 }
Esempio n. 7
0
        public override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            panel.Colour = new OpenTK.Graphics.Color4(0.3f, 0.3f, 0.3f, 0.0f);
            dim.Colour = new OpenTK.Graphics.Color4(0.0f, 0.0f, 0.0f, 0.0f);
            fsw.EnableRaisingEvents = true;
            fsw.IncludeSubdirectories = true;
            fsw.Created += new FileSystemEventHandler(fsw_Created);
            fsw.Changed += new FileSystemEventHandler(fsw_Created);
            fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
            fsw.Error += new ErrorEventHandler(fsw_Error);
            fsw.InternalBufferSize = 61440; //lets handle large changes ;D
            SongLibrary.cacheSongInfo();
            game.KeyPress += new EventHandler<OpenTK.KeyPressEventArgs>(game_KeyPress);
            bgoverlay.Colour = new OpenTK.Graphics.Color4(0.0f, 0.0f, 0.0f, 0.5f);
            searchLabel = new Label(game, new Point(0, 700), "");
            searchLabel.TextTexture.Shadow = true;
            searchInfoL = new Label(game, new Point(0, 700), "type to begin search..");
            //searchInfoL.TextTexture.Shadow = true;
            searchInfoL.TextTexture.Colour = Color.White;

            onlineToggle = new ToggleButton(game, new Rectangle(Utils.getMX(780), 130, 50, 40), "O", delegate(int data)
            {
                Config.LocalScores = !Config.LocalScores;
                updateScoreLabels(0);
            });

            prevPage = new Button(game, new Rectangle(Utils.getMX(835), 130, 50, 40), "<<", delegate(int data)
            {

                if(displayScores != null && scoreDisplayPage > 0) {
                    scoreDisplayPage--;
                    updateScoreLabels(scoreDisplayPage);
                }
            });
            nextPage = new Button(game, new Rectangle(Utils.getMX(890), 130, 50, 40), ">>", delegate(int data)
            {

                if (displayScores != null && displayScores.Count > 0) //if count was 0 maxpage would be -1
                {
                    int maxpage = displayScores.Count / 8;
                    if (displayScores.Count % 8 > 0) //if there's a remainder that means theres some extra scores to display so need new page
                    {
                        maxpage++;
                    }
                    maxpage--; //remember, scoredisplaypage is 0 based!
                    if (scoreDisplayPage < maxpage)
                    {
                        scoreDisplayPage++;
                        updateScoreLabels(scoreDisplayPage);
                        /*if (scoreDisplayPage == maxpage) //finish later, faulty to have in a place like this
                        {
                            nextPage.Visible = false;
                            nextPage.Enabled = false;
                        }*/
                    }
                }
            });
            if (!Config.LocalScores)
            {
                ((ToggleButton)onlineToggle).toggle();
            }
            UIComponents.Add(prevPage);
            UIComponents.Add(nextPage);
            UIComponents.Add(onlineToggle);
            calibrateButton = new Button(game, new Rectangle(70, 768 - 170, 200, 50), "Calibrate offset", delegate(int data)
            {
                int tIndex = 0;
                for (int x = 0; x < currentSong.Charts.Count; x++)
                {
                    if (currentSong.Charts[x].Name.Equals(diffs.BaseText.Line))
                    {
                        tIndex = x;
                    }
                }
                IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                try
                {
                    uint flags = 0;
                    flags = flags | (uint)(nfB.Selected ? 1 : 0);
                    flags = flags | (uint)(autoB.Selected ? 2 : 0);
                    flags = flags | (uint)(mirB.Selected ? 4 : 0);
                    flags = flags | (uint)(hdB.Selected ? 8 : 0);
                    temp.loadSong(SongLibrary.loadSong(songNameList[index].Info), tIndex, new Mods()
                            {
                                Speed = dtB.Selected ? 1.5 : 1.0,
                                Flags = flags,
                                Scroll = Config.PlaySpeed
                            }, null, IngameScreen.PlayType.PLAY);
                    Music.stop();
                    Game.setScreen(game.screens["ingameScreen"]);
                    temp.Calibrate = true;
                    game.Title = "Pulse | " + currentSong.Artist + " - " + currentSong.SongName + " [" + currentSong.Charts[tIndex].Name + "]";
                }
                catch (Exception ex)
                {
                    ErrorLog.log(ex);
                }
            });
            calibrateButton.Visible = false;
            calibrateButton.Enabled = false;
             //   int backpos = Config.ResWidth - 244;//Config.WideScreen? (int)((780d/1024d) * game.Width) : 780;
            backLabel = new Button(game, new Rectangle(Utils.getMX(780), 10, 220, 50), "Back", delegate(int data)
            {
                Game.setScreen(game.screens["menuScreen"]);
            });
            help = new Button(game, new Rectangle(Utils.getMX(780), 130, 220, 50), "Help", delegate(int data)
            {
                new EditorHelp().ShowDialog();
                Game.resetStates();
            });
            UIComponents.Add(help);

            newSongb = new Button(game, new Rectangle(Utils.getMX(780), 70, 220, 50), "New Song", delegate(int data)
            {
                new NewSong().ShowDialog();
                Game.resetStates();
            });
            //   UIComponents.Add(searchLabel);
            UIComponents.Add(backLabel);
            UIComponents.Add(newSongb);
            #region obsolete
            /*difficultyTexts[0] = new Text(Config.ClientSize, new Size(300, 33), new Point(0, 0));
            difficultyTexts[0].Update("3key");
            difficultyTexts[0].Shadow = true;
            difficultyTexts[1] = new Text(Config.ClientSize, new Size(300, 33), new Point(0, 0));
            difficultyTexts[1].Update("4key");
            difficultyTexts[1].Shadow = true;
            difficultyTexts[2] = new Text(Config.ClientSize, new Size(300, 33), new Point(0, 0));
            difficultyTexts[2].Update("6key");
            difficultyTexts[2].Shadow = true;
            difficultyTexts[3] = new Text(Config.ClientSize, new Size(300, 33), new Point(0, 0));
            difficultyTexts[3].Update("7key");
            difficultyTexts[3].Shadow = true;*/
            #endregion
            refresh();
            index = 0;
            for (int x = 0; x < songNameList.Count; x++)
            {
                if (songNameList[x].Info.SongName.Equals(Game.M.CurrentSong.SongName) && songNameList[x].Info.Dir.Equals(Game.M.CurrentSong.Dir))
                {
                    index = x;
                }
            }
            changeSong();
            selectionTexture = new Rect(new Rectangle(2, 250, 548, 28));
            sel2 = new Rect(new Rectangle(0, 249, 552, 30));
            searchBox = new Rect(new Rectangle(0, 700, Config.ResWidth, 30));
            searchBox.Colour = new OpenTK.Graphics.Color4(0.27f, 0.509f, 0.705f, .8f);
            cover = new Rect(new Rectangle(Config.ResWidth - 300, 0, 300, 768));
            cover.Colour = new OpenTK.Graphics.Color4(1f, 1f, 1f, .7f);
            scorebg = new Rect(new Rectangle((int)(Config.ResWidth - 324), 180, 295, 600), Skin.skindict["scoreback"]);
            sel2.Colour = new OpenTK.Graphics.Color4(0.0f, 0.0f, 0.0f, 1.0f);
            selectionTexture.Colour = new OpenTK.Graphics.Color4(0.25f, 0.0f, 1.0f, 1.0f);
            background = new Rect(new Rectangle(0, 0, Config.ResWidth, 768));

            currentSong = SongLibrary.loadSong(songNameList[index].Info);
            string bgString = "";
            if (currentSong.FileVersion == 0)
            {
                bgString = currentSong.BgName;
            }
            else
            {
                bgString = currentSong.Charts[0].BgName;
            }
            background.useTexture("songs\\" + currentSong.Dir + "\\" + bgString);

            music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
            Music.Volume = 0.0f;
            targetVolume = Config.Volume / 100.0f;
            changed = true;
            Music.PositionAsMilli = (long)Game.M.Music.PositionAsMilli;
            Music.play(false, true);
            if (play)
            {
                game.Title = "Pulse | Play Selection";
                newSongb.Enabled = false;
                newSongb.Visible = false;
                help.Enabled = false;
                help.Visible = false;
            }
            else
            {
                game.Title = "Pulse | Edit Selection";
                newSongb.Enabled = true;
                newSongb.Visible = true;
            }
            updateDiffs();
            updateScoreLabels(0);
            //   changeSong();
            //   index = 0;
            for (int x = 0; x < songNameList.Count; x++)
            {
                // if (songNameList[x].textData.Location.Y != 246 + ((x - index) * 33) && !songNameList[x].textData.Moving)
                //  {
                songNameList[x].select.Bounds = new Rectangle(0, 246 + ((x - index) * 90), songNameList[x].select.Bounds.Width, songNameList[x].select.Bounds.Height);
                //  Console.WriteLine(songNameList[x].textData.Position.
                //
            }
            //Console.WriteLine("why");
            List<string> t = new List<String>();
            t.Add(" ");
            diffs = new DropDownBox(game, t, new Rectangle(70, 120, 150, 35));
            diffs.selected += new Action<int>(diffs_selected);
            string tempS = "";
            if (play)
            {
                tempS = "Play";
            }
            else
            {
                tempS = "Edit";
            }
            playButton = new Button(game, new Rectangle(290 + 220, 768 - 170, 200, 50), tempS, delegate(int data)
            {
                if (pickDiff)
                {
                    int tIndex = 0;
                    for (int x = 0; x < currentSong.Charts.Count; x++)
                    {
                        if (currentSong.Charts[x].Name.Equals(diffs.BaseText.Line))
                        {
                            tIndex = x;
                        }
                    }
                    /*if (Config.AutoPlay && play)
                    {
                        ReplayScreen temp = (ReplayScreen)game.screens["replayScreen"];
                        try
                        {
                            temp.loadSong(SongLibrary.loadSong(songNameList[index].Info), tIndex);
                            Game.M.setSong(songNameList[index].Info);
                            Game.M.play();
                            Music.stop();
                            Game.setScreen(game.screens["replayScreen"]);
                            game.Title = "Pulse | Watch replay | " + currentSong.Artist + " - " + currentSong.SongName + " [" + currentSong.Charts[tIndex].Name + "]";
                        }
                        catch { }
                    }
                    else */if (play)
                    {
                        IngameScreen temp = (IngameScreen)game.screens["ingameScreen"];
                        try
                        {
                            IngameScreen.PlayType te = IngameScreen.PlayType.PLAY;
                            if (autoB.Selected)
                                te = IngameScreen.PlayType.AUTO;
                            uint flags = 0;
                            flags = flags | (uint)(nfB.Selected ? 1 : 0);
                            flags = flags | (uint)(autoB.Selected ? 2 : 0);
                            flags = flags | (uint)(mirB.Selected ? 4 : 0);
                            flags = flags | (uint)(hdB.Selected ? 8 : 0);
                            temp.loadSong(SongLibrary.loadSong(songNameList[index].Info), tIndex, new Mods()
                            {
                                Speed = dtB.Selected ? 1.5 : 1.0,
                                Flags = flags,
                                Scroll = Config.PlaySpeed
                            }, null, te);
                            Game.M.setSong(ref songNameList[index].Info);
                            Game.M.play();
                            Music.stop();
                            temp.Calibrate = false;
                            Game.setScreen(game.screens["ingameScreen"]);
                            game.Title = "Pulse | " + currentSong.Artist + " - " + currentSong.SongName + " [" + currentSong.Charts[tIndex].Name + "]";
                            scoreDisplayText.Clear();
                            scoreDisplayPage = 1;
                        }
                        catch (Exception ex)
                        {
                            ErrorLog.log(ex);
                        }
                    }
                    else if (!play)
                    {
                        EditorScreen temp = (EditorScreen)game.screens["editScreen"];
                        try
                        {
                            temp.loadSong(SongLibrary.loadSong(songNameList[index].Info), tIndex);
                            Game.M.setSong(ref songNameList[index].Info);
                            Game.M.play();
                            Music.stop();
                            Game.setScreen(game.screens["editScreen"]);
                        }
                        catch (KeyNotFoundException)
                        {
                        }
                        game.Title = "Pulse|Editor|" + currentSong.Artist + "-" + currentSong.SongName + "[" + currentSong.Charts[tIndex].Name + "]";
                    }
                }
            });
            autoB = new ToggleButton(game, new Rectangle(874 - 480, 120, 100, 40), "Auto", delegate(int data)
            {
                Config.AutoPlay = autoB.Selected;
            });
            dtB = new ToggleButton(game, new Rectangle(874 - 370, 120, 100, 40), "DT", delegate(int data)
            {
                Config.Dt = dtB.Selected;
                if (Config.Dt)
                {
                    Config.Ht = false;
                    if (htB.Selected)
                    {
                        htB.toggle();
                    }
                }
            });
            htB = new ToggleButton(game, new Rectangle(874 - 260, 120, 100, 40), "HT", delegate(int data)
            {
                Config.Ht = htB.Selected;
                if (Config.Ht)
                {
                    Config.Dt = false;
                    if (dtB.Selected)
                    {
                        dtB.toggle();
                    }
                }
            });
            mirB = new ToggleButton(game, new Rectangle(874 - 480, 170, 100, 40), "Mirror", delegate(int data)
            {
                Config.Mirror = mirB.Selected;
            });
            hdB = new ToggleButton(game, new Rectangle(874 - 370, 170, 100, 40), "HD", delegate(int data)
            {
                Config.Hidden = hdB.Selected;
            });
            nfB = new ToggleButton(game, new Rectangle(874 - 260, 170, 100, 40), "No fail", delegate(int data)
            {
                Config.NoFail = nfB.Selected;
            });
            closeSel = new Button(game, new Rectangle(290, 768 - 170, 200, 50), "Close", delegate(int data)
                {
                    notPickDiffs();
                });
            rateLabel = new Label(game, new Point(874 - 460, 370), "Scroll speed: " + Config.PlaySpeed);
            rateDrag = new Dragbar(game, new Point(874-460, 400), 300, false, delegate(int d)
                {
                    double temp = rateDrag.getPercentScrolled();
                    int x = (int)(temp / 10);
                    Config.PlaySpeed = ((float)x / 2) + 0.5f;
                    rateLabel.Text = "Scroll speed: " + Config.PlaySpeed;
                });
            rateDrag.setPos(rateDrag.Bounds.X + (int)(Config.PlaySpeed * 20) + rateDrag.Bounds.Width / 10);
            game.Mouse.Move += new EventHandler<MouseMoveEventArgs>(Mouse_Move);
        }
Esempio n. 8
0
 public void loadSong(Audio.AudioFX fx, Song song)
 {
     times.Clear();
     bpms.Clear();
     initial = Environment.TickCount;
     fx.play(true);
     Music = fx;
     this.song = song;
 }
Esempio n. 9
0
        public void setSong(ref SongInfo s)
        {
            currentSong = SongLibrary.loadSong(s);
            music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
            music.Volume = Config.Volume / 100.0f;
            updateText = true;
            if (currentSong.FileVersion > 0)
            {
                if (currentSong.ID == -1)
                {
                    NameValueCollection nvc = new NameValueCollection();
                    nvc.Add("c", Utils.calcHash(currentSong.Charts[0].Path));
                    int id = Convert.ToInt32(Utils.HttpUploadFile("http://p.ulse.net/idchart", nvc));
                    if (id == -1)
                    {
                        id = -2;
                    }
                    currentSong.ID = id;

                    SongLibrary.Songs[SongLibrary.Songs.IndexOf(s)].ID = id;
                    SongLibrary.songInfos[currentSong.Dir].ID = id;
                }
            }
            else
            {
                Console.WriteLine("Cannot get song id, pncv0");
            }
        }
Esempio n. 10
0
        public void loadSong(Song song, int difficulty, Mods m, Replay replay, PlayType t)
        {
            for (int i = 0; i < 8; i++)
            {
                holding[i] = false;
                canHit[i] = true;
            }
            first = true;
            specFailed = false;
            scoreMod = 1;
            hp = 100;
            notAdded = true;
            mods = m;
            currentReplay = null;
            playType = t;
            currentSong = song;
            this.difficulty = difficulty;
            chart = song.Charts[difficulty];
            hitWindow = 50;
            hitWindow = hitWindow + (chart.Judgement * 20);
            keygroup = chart.Keys - 5;
            switch (t)
            {
                case PlayType.PLAY:
                    recordingReplay = true;
                    this.replay = false;
                    currentReplay = new Replay();
                    this.currentReplay.Mods = m;
                    currentReplay.Mods = mods;
                    if (Config.Spectating)
                    {
                        Config.Spectating = false;
                        try
                        {
                            PacketWriter.sendSpectateCancel(Game.conn.Bw, Config.SpectatedUser);
                        }
                        catch
                        {
                        }
                    }
                    break;
                case PlayType.REPLAY:
                    recordingReplay = false;
                    currentReplay = replay;
                    this.replay = true;
                    this.mods = replay.Mods;
                    foreach (var pair in currentReplay.PressTimings)
                    {
                        pair.value.value = false;
                    }
                    foreach (var pair in currentReplay.ReleaseTimings)
                    {
                        pair.value.value = false;
                    }
                    foreach (ReplayHit h in currentReplay.HitTimings)
                    {
                        h.Used = false;
                    }
                    break;
                case PlayType.TEST:
                    recordingReplay = false;
                    this.replay = false;
                    generateAutoReplay();
                    break;
                case PlayType.AUTO:
                    this.replay = true;
                    this.recordingReplay = false;
                    generateAutoReplay();
                    break;
                case PlayType.SPECTATE:
                    this.replay = true;
                    currentReplay = new Replay();
                    break;
            }

            Game.M.Music.stop();
            try
            {
                PacketWriter.sendSongStart(Game.conn.Bw, Account.currentAccount.AccountName, Utils.calcHash(chart.Path), song.Artist + " - " + song.SongName, (short)playType, mods.Flags, Convert.ToDouble(mods.Scroll, Config.cultureEnglish), mods.Speed);
            }
            catch
            {
            }
            try
            {
                breaksound = File.ReadAllBytes(Skin.skindict["combobreak"]);
                hitsound = File.ReadAllBytes(Skin.skindict["normal-hitnormal"]);
            }
            catch
            {
                Console.WriteLine("Error loading hitsounds, probably missing file");
            }
            if (currentSong.FileVersion == 0)
            {
                music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName);
            }
            else
            {
                music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName); //fix in future to load per chart
            }
            Music.PositionAsMilli = 0;
            Music.Volume = Config.Volume / 100.0f;
            currentOffset = -(chart.LeadInTime * 1000);
            endOffset = 0;
            startOffset = -1;
            foreach (Note n in chart.Notes)
            {
                n.Vertical = -20;
                if (n.Hold)
                {
                    n.HoldVertical = -20;
                }
                n.Enabled = true;
                n.Visible = true;
                n.setAlpha(1.0f);
                n.setColor();
                n.Texture.Fading = false;
                n.Holdbar.Fading = false;
                n.HoldEnd.Fading = false;
                if (startOffset < 0)
                    startOffset = n.Offset;
                if (n.Hold)
                {
                    if (n.HoldOffset > endOffset)
                    {
                        endOffset = n.HoldOffset;
                    }
                }
                else if (n.Offset > endOffset)
                {
                    endOffset = n.Offset;
                }
                if (n.Offset < startOffset)
                {
                    startOffset = n.Offset;
                }
            }
            endOffset += 1500;
            Dictionary<int, int> moves = new Dictionary<int, int>();
            foreach (TimingSection s in currentSong.TimingsList)
            {
                if (s.ChangeSnap)
                {
                    double move = 60 / (s.Snap / 1000);
                    if (move > 400)
                    {
                        move = 400;
                    }
                    double perc = (move / 400) * 100;
                    move = 3000 - (27 * perc);
                    try
                    {
                        moves.Add((int)s.Offset, (int)move);
                    }
                    catch { }
                }
            }
            List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>();
            list.Sort((f, s) =>
            {
                return f.Key.CompareTo(s.Key);
            });
            invert = false;
            if ((mods.Flags & 4) == 4)
            {
                invert = true;
            }
            if ((mods.Flags & 8) == 8)
            {
                scoreMod += 0.05;
            }
            List<int> keys = new List<int>(moves.Keys);
            List<int> offs = new List<int>(moves.Values);
            foreach (Note n in chart.Notes)
            {
                if (n.Offset < keys[0])
                {
                    n.MoveTime = (int)(offs[0] / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll));
                }
            }
            foreach (Note n in chart.Notes)
            {
                foreach (var pair in moves)
                {
                    if (n.Offset >= pair.Key)
                    {
                        n.MoveTime = (int)(pair.Value / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll));
                    }
                }
                if (invert)
                {
                    n.Location = 9 - n.Location;
                }
            }
            time1 = 0;
            time2 = 0;
            time3 = 0;
            finalScore = new Score();
        }
Esempio n. 11
0
 public static Song loadSong(SongInfo song)
 {
     if (song.FileVersion == 0)
     {
         if (File.Exists("songs\\" + song.Dir + "\\" + song.Name + ".pnc"))
         {
             Song temp = new Song(song.Dir + "\\" + song.Name + ".pnc");
             temp.ID = song.ID;
             return temp;
         }
         else
         {
             Game.addToast("press f1, failed to load song " + song.Name);
             Songs.Remove(song);
             songInfos.Remove(song.Name);
             return new Song();
         }
     }
     else if (song.FileVersion == 1)
     {
         Song temp2 = new Song(song.Dir);
         temp2.ID = song.ID;
         return temp2;
     }
     return null;
 }