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; }
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); } } }
public static List<Score> reconstruct(string name) { XmlDocument doc = new XmlDocument(); using (FileStream fs = new FileStream(name, FileMode.Open)) { doc.Load(fs); } List<Score> scores = new List<Score>(); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { Score s = new Score(); #region nodeparse foreach (XmlNode node1 in node.ChildNodes) { switch (node1.Name) { case "oks": s.Oks = Convert.ToInt32(node1.InnerText); break; case "perfects": s.Perfects = Convert.ToInt32(node1.InnerText); break; case "goods": s.Goods = Convert.ToInt32(node1.InnerText); break; case "misses": s.Misses = Convert.ToInt32(node1.InnerText); break; case "maxc": s.MaxCombo = Convert.ToInt32(node1.InnerText); break; case "totalscore": s.TotalScore = Convert.ToInt32(node1.InnerText); break; case "acc": s.Accuracy = (float)Convert.ToDouble(node1.InnerText, Config.cultureEnglish); break; case "date": s.dateString = node1.InnerText; break; case "at": s.ArtistTitle = node1.InnerText; break; case "cname": s.chartName = node1.InnerText; break; case "flags": s.Flags = Convert.ToInt32(node1.InnerText); break; case "replay": s.ReplayName = node1.InnerText; break; } } #endregion scores.Add(s); } return scores; }
public static int CompareScores(Score a, Score b) { return -(a.TotalScore).CompareTo(b.TotalScore); }
public override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); if (currentOffset > updateTime && updateTime != -1234) { score.TotalScore = scoreUpdate; score.Combo = comboUpdate; hp = hpUpdate; score.Accuracy = accUpdate; updateTime = -1234; } if (skip.Visible == true && keyPress(Config.SkipKey)) { running = true; unpause(); music.PositionAsMilli = (long)startOffset - 2000; currentOffset = music.PositionAsMilli; skip.Visible = false; skip.Enabled = false; } if (!Config.Specs.Equals(oldSpecs) && Config.Spectating) { userList.Update(Config.Specs); oldSpecs = Config.Specs; } else if (!Config.SpecsOnMe.Equals(oldSpecs) && Config.Spectated) { userList.Update(Config.SpecsOnMe); oldSpecs = Config.SpecsOnMe; } if (startOffset - currentOffset < 2000) { skip.Visible = false; skip.Enabled = false; } if (!paused) { heartbeatTime += e.Time; time1 += e.Time; time2 += e.Time; time3 += e.Time; if (time3 > 0.5) { time3 = 0; double min = Math.Floor((endOffset - music.PositionAsMilli) / 60000); double sec = Math.Floor((endOffset - music.PositionAsMilli) % 60000); sec = Math.Floor(sec / 1000); countDown.Text = min.ToString("0#") + ":" + sec.ToString("0#"); } } if (time2 > 0.05 && !comboText.moving && comboMove) { comboMove = false; comboText.scale(new Size((int)(frame.LaneWidth[0] * 1.5), (int)(frame.LaneWidth[0] * 1.5)), 0.12); comboText.move(new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, (int)(frame.LaneWidth[0] * 1.5))) / 2, frame.Location.Y + 200), 0.12); } if (!running && !paused && !scores) { currentOffset += e.Time * 1000 * mods.Speed; if (time1 > chart.LeadInTime / mods.Speed) { running = true; unpause(); time1 = 0; } } if (failed) { pause(); try { if (running == true) { if (Config.Spectated) { PacketWriter.sendSpectateFail(Game.conn.Bw); } PacketWriter.sendSongStart(Game.conn.Bw, Account.currentAccount.AccountName, "", "", (short)2, 0, 0, 0); } } catch { } running = false; scores = false; pauseScreen.Failed = true; } if (scores) { if (invert) { invert = false; foreach (Note n in chart.Notes) { if (Config.Mirror) { n.Location = 9 - n.Location; } } } music.Speed = 0.0f; scoreScreen.OnUpdateFrame(e); if (scoreScreen.Score == null) { scoreScreen.Score = score; } scoreFadeTime += e.Time; if (scoreFadeTime > 0.025 && overlay.Colour.A < 1.0f) { float newAlpha = overlay.Colour.A + 0.2f; overlay.Colour = new Color4(overlay.Colour.R, overlay.Colour.G, overlay.Colour.B, newAlpha); scoreFadeTime = 0; } } if (keyPress(Key.Escape)) { if (buffering || specFailed) { Game.setScreen(game.screens["selectScreen"]); game.Title = "Pulse"; try { PacketWriter.sendSpectateCancel(Game.conn.Bw, Config.SpectatedUser); Config.Spectating = false; Config.SpectatedUser = ""; buffering = false; } catch { } } else if (!running && paused && !scores && !failed) { unpause(); //time = 0; //running = true; } else if (!running && !scores && !failed) { pause(); } else if (!scores && !failed) { if (currentOffset > endOffset - 1510) { forceScores = true; } else { togglePause(); } } else if (playType == PlayType.PLAY && !scores && failed) { foreach (Note n in Chart.Notes) { if (Config.Mirror) { n.Location = 9 - n.Location; } } loadSong(CurrentSong, Difficulty, mods, null, playType); onSwitched(); } } for (int i = 0; i < 8; i++) { if (!holding[i]) { canHit[i] = true; } } if (!paused && running) { currentOffset = music.PositionAsMilli + Config.Offset + (-7 * (music.Speed / 10)); } if (replay) { #region replay if (!paused) { if (playType == PlayType.SPECTATE) { if (bufferOffset - currentOffset < bufferGap) { pause(); buffering = true; bufferAmount += 250; } } pulse = true; foreach (TimingSection t in currentSong.TimingsList) { if (currentOffset > t.Offset) { if (sectionSnap != t.Snap) { sectionSnap = t.Snap; glow.Bounds = new Rectangle(new Point((int)frame.Location.X, (int)frame.HitHeight - 43), new Size((int)frame.Width, 40)); } } } foreach (var pair in currentReplay.PressTimings) { if (currentOffset > pair.key && !pair.value.value) { pair.value.value = true; keys[pair.value.key] = true; int temp = 0; for (int x = 0; x < pair.value.key; x++) { temp += frame.LaneWidth[x]; } lights[pair.value.key].fade(0.65f, 0.075); lights[pair.value.key].move(new Point((int)frame.Location.X + (frame.LaneLoc[pair.value.key]) + (1 * pair.value.key) + 5, 96), 0.1); lights[pair.value.key].scale(new Size(frame.LaneWidth[pair.value.key], (int)frame.HitHeight - 99), 0.1); glows[pair.value.key].fade(0.65f, 0.075); presses[pair.value.key].fade(1.0f, 0.05); } } foreach (var pair in currentReplay.ReleaseTimings) { if (currentOffset > pair.key && !pair.value.value) { pair.value.value = true; keys[pair.value.key] = false; int temp = 0; for (int x = 0; x < pair.value.key; x++) { temp += frame.LaneWidth[x]; } lights[pair.value.key].fade(0.0f, 0.075); lights[pair.value.key].move(new Point((int)frame.Location.X + (frame.LaneLoc[pair.value.key] + (1 * pair.value.key)) + 5 + 25, 596), 0.075); lights[pair.value.key].scale(new Size(0, (int)frame.HitHeight - 599), 0.05); glows[pair.value.key].fade(0.0f, 0.075); presses[pair.value.key].fade(0.0f, 0.05); } } } else { pulse = false; } if (playType != PlayType.TEST && (currentOffset > endOffset && !scores) || (music.PositionAsMilli == music.Length && !scores)) { scores = true; if (playType == PlayType.SPECTATE) { this.score = finalScore; } try { PacketWriter.sendSongStart(Game.conn.Bw, Account.currentAccount.AccountName, "", "", (short)2, 0, 0, 0); } catch { } scoreScreen = new ScoreScreen(game, "scores", currentReplay, currentSong, difficulty, false); scoreScreen.OnLoad(null); paused = false; running = false; SongInfo curr = SongLibrary.songInfos[CurrentSong.PncName]; String cstring = chart.Name; score.chartName = chart.Name; score.ArtistTitle = currentSong.Artist + " - " + currentSong.SongName; score.dateString = DateTime.Now.ToString(); scoreScreen.Score = score; } if (!scores) { foreach (ReplayHit r in currentReplay.HitTimings) { if (r.Used == false && currentOffset > r.NoteOffset - r.OffsetDifference) { Note temp = null; bool hold = false; foreach (Note n in chart.Notes) { if (n.Hold && n.HoldOffset + hitWindow < currentOffset) { n.Enabled = false; n.setAlpha(0.0f); foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * r.Lane)) + 5 - frame.LaneWidth[n.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } } else if (!n.Hold && n.Offset + hitWindow < currentOffset) { n.Enabled = false; n.setAlpha(0.0f); } if (n.Offset == r.NoteOffset && n.Location == r.Lane + 1) { temp = n; break; } else if (n.HoldOffset == r.NoteOffset && n.Location == r.Lane + 1) { temp = n; hold = true; break; } } r.Used = true; if (r.Hit != Replay.HitType.MISS && r.Hit != Replay.HitType.HOLDMISS && temp != null) { score.Combo++; //comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, 50)) / 2, frame.Location.Y + 200); comboText.move(new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0] * 2)) / 2, frame.Location.Y + 185), 0.02); comboText.scale(new Size(frame.LaneWidth[0] * 2, frame.LaneWidth[0] * 2), 0.02); if (score.Combo > 2) { comboText.Visible = true; } comboMove = true; time2 = 0; if (Config.HitVolume > 0) { sfx = AudioManager.loadFromMemory(hitsound);//.loadFromFile(Skin.skindict["normal-hitnormal"],true); sfx.Volume = Config.HitVolume / 100f; //add separate hitsound config setting later? sfx.play(false); } temp.Texture.fade(0.0f, 0.05); if (!temp.Hold) { temp.Enabled = false; } else if (temp.Hold && hold) { temp.Enabled = false; temp.Texture.fade(0.0f, 0.05); temp.Holdbar.fade(0.0f, 0.05); temp.HoldStart.fade(0.0f, 0.05); temp.HoldEnd.fade(0.0f, 0.05); foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[temp.Location - 1]) + (1 * r.Lane)) + 5 - frame.LaneWidth[temp.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } } else if (temp.Hold) { holdBursts.Add(new Animation(new Rectangle(((int)frame.Location.X + (frame.LaneLoc[temp.Location - 1]) + (1 * r.Lane)) + 5 - frame.LaneWidth[temp.Location - 1] * 2, (int)frame.HitHeight - 25 - frame.LaneWidth[temp.Location - 1] * 2, frame.LaneWidth[temp.Location - 1] + frame.LaneWidth[temp.Location - 1] * 4, frame.LaneWidth[temp.Location - 1] + frame.LaneWidth[temp.Location - 1] * 4), Skin.HoldFrameRate, "holdBurst", 3, true, Skin.MaskHolds)); } if (r.Hit == Replay.HitType.PERFECT) { adjustHp(2); burstAcc(3); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 3); score.AccuracyTotal.Add(3); } else if (r.Hit == Replay.HitType.GREAT) { adjustHp(1); burstAcc(2); score.TotalScore += (score.Combo * 45) / 6; score.AccuracyTotal.Add(3.5f); } else if (r.Hit == Replay.HitType.GOOD) { adjustHp(1); burstAcc(2); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 2); score.AccuracyTotal.Add(2); } else if (r.Hit == Replay.HitType.OK) { adjustHp(-3); burstAcc(1); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 1); score.AccuracyTotal.Add(1); } if (!hold) { burst = new Animation(new Rectangle(((int)frame.Location.X + (frame.LaneLoc[temp.Location - 1]) + (1 * r.Lane)) + 5 - frame.LaneWidth[temp.Location - 1] * 2, (int)frame.HitHeight - 25 - frame.LaneWidth[temp.Location - 1] * 2, frame.LaneWidth[temp.Location - 1] + frame.LaneWidth[temp.Location - 1] * 4, frame.LaneWidth[temp.Location - 1] + frame.LaneWidth[temp.Location - 1] * 4), Skin.BurstFrameRate, "burst", Skin.BurstFrameCount, false, Skin.MaskBursts); bursts.Add(burst); } } else if (temp != null) { temp.Enabled = false; temp.Texture.fade(0.0f, 0.1); if (temp.Hold) { temp.Holdbar.fade(0.0f, 0.1); temp.HoldEnd.fade(0.0f, 0.1); temp.HoldStart.fade(0.0f, 0.1); foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[temp.Location - 1]) + (1 * r.Lane)) + 5 - frame.LaneWidth[temp.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } } burstAcc(0); if (r.Hit == Replay.HitType.HOLDMISS) { adjustHp(-24); } else { adjustHp(-12); } miss(); } //comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, comboText.CharWidth)) / 2, frame.Location.Y + 200); } } foreach (Note n in chart.Notes) { if (n.Offset - currentOffset > 20000) break; if (n.Texture.Colour.A <= 0 && running && n.Holdbar.Colour.A <= 0) { n.Visible = false; } if (n.Offset - currentOffset < n.MoveTime && n.Visible) { moveRate = (double)(int)frame.HitHeight / n.MoveTime; double temp = n.Offset - currentOffset; double moved = (n.MoveTime - temp) * moveRate; n.Vertical = moved; if (n.Hold) { temp = n.HoldOffset - currentOffset; moved = (n.MoveTime - temp) * moveRate; n.HoldVertical = moved; } if (((Mods.Flags & 8) == 8) && n.Offset - currentOffset < n.MoveTime - (n.MoveTime / 3)) { if (!n.Texture.Fading) { n.Texture.fade(0.0f, 0.2 / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll)); } if (n.Hold && n.HoldOffset - currentOffset < n.MoveTime - (n.MoveTime / 3) && !n.Holdbar.Fading) { n.Holdbar.fade(0.0f, 0.2); n.HoldEnd.fade(0.0f, 0.2); n.HoldStart.fade(0.0f, 0.2); foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * n.Location - 1)) + 5 - frame.LaneWidth[n.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } } } } } } else { } #endregion } else if (!replay) { if (Config.Spectated && heartbeatTime > 1 && !paused && !scores) { try { PacketWriter.sendSpectateHeartbeat(Game.conn.Bw, (int)currentOffset, score.TotalScore, score.Combo, hp, score.Accuracy); heartbeatTime = 0; } catch { } } #region play if (!paused) { pulse = true; foreach (TimingSection t in currentSong.TimingsList) { if (currentOffset > t.Offset) { if (sectionSnap != t.Snap) { sectionSnap = t.Snap; glow.Bounds = new Rectangle(new Point((int)frame.Location.X + 5, (int)frame.HitHeight - 43), new Size((int)frame.Width - 3, 40)); } } } if (recordingReplay) { for (int x = 0; x < chart.Keys; x++) { if (newKeyState.Contains(Config.keys[keygroup][x]) && !oldKeyState.Contains(Config.keys[keygroup][x])) { currentReplay.PressTimings.Add(new Pair<int, Pair<int, bool>>((int)currentOffset - 8, new Pair<int, bool>(x, false))); if (Config.Spectated) { PacketWriter.sendSpectatePress(Game.conn.Bw, (int)currentOffset, x); } } else if (!newKeyState.Contains(Config.keys[keygroup][x]) && oldKeyState.Contains(Config.keys[keygroup][x])) { currentReplay.ReleaseTimings.Add(new Pair<int, Pair<int, bool>>((int)currentOffset - 8, new Pair<int, bool>(x, false))); if (Config.Spectated) { PacketWriter.sendSpectateRelease(Game.conn.Bw, (int)currentOffset, x); } } if (newKeyState.Contains(Config.keys[keygroup][x])) { keys[x] = true; if (lights[x].Colour.A == 0.0f && !lights[x].Fading) { lights[x].fade(0.65f, 0.075); lights[x].move(new Point(((frame.Location.X) + frame.LaneLoc[x]) + (1 * x) + 5, 96), 0.1); lights[x].scale(new Size(frame.LaneWidth[x], (int)frame.HitHeight - 99), 0.1); glows[x].fade(0.65f, 0.075); } if (!presses[x].Fading && presses[x].Colour.A == 0.0f) { presses[x].fade(1.0f, 0.05); } } else { keys[x] = false; if (!lights[x].Fading && lights[x].Colour.A > 0.0f) { lights[x].fade(0.0f, 0.075); lights[x].move(new Point(((frame.Location.X) + frame.LaneLoc[x]) + (1 * x) + 5 + 25, 596), 0.075); lights[x].scale(new Size(0, (int)frame.HitHeight - 599), 0.05); glows[x].fade(0.0f, 0.075); } if (!presses[x].Fading && presses[x].Colour.A > 0.0f) { presses[x].fade(0.0f, 0.05); } } } } } else { pulse = false; } if ((playType == PlayType.PLAY && !scores && (currentOffset > endOffset || music.PositionAsMilli == music.Length)) || forceScores) { scores = true; try { PacketWriter.sendSongStart(Game.conn.Bw, Account.currentAccount.AccountName, "", "", (short)2, 0, 0, 0); } catch { } paused = false; running = false; if (notAdded) { try { if (Config.Spectated) { PacketWriter.sendSpectateFinish(Game.conn.Bw, score.TotalScore, score.MaxCombo, score.Perfects, score.Goods, score.Oks, score.Misses, (int)mods.Flags, (double)score.Accuracy); } } catch { } if (!calibrate) { SongInfo curr = SongLibrary.songInfos[CurrentSong.PncName]; String cstring = chart.Name; score.chartName = chart.Name; score.ArtistTitle = currentSong.Artist + " - " + currentSong.SongName; score.dateString = DateTime.Now.ToString(); try { if (CurrentSong.FileVersion == 1) { string fileName = ScoreLibrary.getFileFromDiff(curr, cstring); string hash = Utils.calcHash(fileName); string sName = "replay\\" + hash + ".psf"; string rName; XmlDocument rep = new XmlDocument(); XmlDeclaration d = rep.CreateXmlDeclaration("1.0", null, "yes"); rep.AppendChild(d); XmlElement r = rep.CreateElement("replay"); r.SetAttribute("Version", "1"); XmlElement m = rep.CreateElement("m"); XmlElement scr = rep.CreateElement("c"); scr.InnerText = "" + Convert.ToDouble(mods.Scroll, Config.cultureEnglish); m.AppendChild(scr); XmlElement speed = rep.CreateElement("s"); speed.InnerText = "" + mods.Speed; m.AppendChild(speed); XmlElement flags = rep.CreateElement("f"); flags.InnerText = "" + mods.Flags; m.AppendChild(flags); r.AppendChild(m); foreach (ReplayHit h in currentReplay.HitTimings) { XmlElement t = rep.CreateElement("h"); XmlElement hit = rep.CreateElement("t"); hit.InnerText = "" + (int)h.Hit; t.AppendChild(hit); XmlElement lane = rep.CreateElement("l"); lane.InnerText = "" + h.Lane; t.AppendChild(lane); XmlElement o = rep.CreateElement("o"); o.InnerText = "" + h.NoteOffset; t.AppendChild(o); XmlElement di = rep.CreateElement("d"); di.InnerText = "" + h.OffsetDifference; t.AppendChild(di); r.AppendChild(t); } foreach (Pair<int, Pair<int, bool>> h in currentReplay.PressTimings) { XmlElement p = rep.CreateElement("p"); XmlElement o = rep.CreateElement("o"); o.InnerText = "" + h.key; p.AppendChild(o); XmlElement l = rep.CreateElement("l"); l.InnerText = "" + h.value.key; p.AppendChild(l); r.AppendChild(p); } foreach (Pair<int, Pair<int, bool>> h in currentReplay.ReleaseTimings) { XmlElement p = rep.CreateElement("r"); XmlElement o = rep.CreateElement("o"); o.InnerText = "" + h.key; p.AppendChild(o); XmlElement l = rep.CreateElement("l"); l.InnerText = "" + h.value.key; p.AppendChild(l); r.AppendChild(p); } rep.AppendChild(r); if (File.Exists(sName)) { Console.WriteLine("1237"); rName = "replay\\r\\" + Config.UnixTime() + " " + hash + ".pcr"; if (!Directory.Exists("replay\\r")) { Directory.CreateDirectory("replay\\r"); } rep.Save(rName); score.ReplayName = Config.UnixTime() + " " + hash; List<Score> reconstructed = ScoreLibrary.reconstruct(sName); if (reconstructed.Count < 8) { reconstructed.Add(score); ScoreLibrary.serializeScores(reconstructed, sName); } else { Comparison<Score> scoreCompare = new Comparison<Score>(ScoreLibrary.CompareScores); reconstructed.Sort(scoreCompare); if (reconstructed[reconstructed.Count - 1].TotalScore < score.TotalScore) { File.Delete("replay\\r\\" + reconstructed[reconstructed.Count - 1].ReplayName); reconstructed.RemoveAt(reconstructed.Count - 1); reconstructed.Add(score); ScoreLibrary.serializeScores(reconstructed, sName); } } } else { List<Score> newL = new List<Score>(); newL.Add(score); ScoreLibrary.serializeScores(newL, sName); rName = "replay\\r\\" + Config.UnixTime() + " " + hash + ".pcr"; Directory.CreateDirectory("replay\\r"); rep.Save(rName); score.ReplayName = Config.UnixTime() + " " + hash; newL = new List<Score>(); newL.Add(score); ScoreLibrary.serializeScores(newL, sName); } if (Account.currentAccount != null) { NameValueCollection nvc = new NameValueCollection(); nvc.Add("u", Account.currentAccount.AccountName); nvc.Add("p", Account.currentAccount.passHash); nvc.Add("c", hash); XmlDocument doc = new XmlDocument(); XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, "yes"); doc.AppendChild(dec); XmlElement root = doc.CreateElement("score"); root.SetAttribute("Version", "1"); XmlElement oks = doc.CreateElement("oks"); oks.InnerText = score.Oks.ToString(); root.AppendChild(oks); XmlElement perfects = doc.CreateElement("perfects"); perfects.InnerText = score.Perfects.ToString(); root.AppendChild(perfects); XmlElement goods = doc.CreateElement("goods"); goods.InnerText = score.Goods.ToString(); root.AppendChild(goods); XmlElement misses = doc.CreateElement("misses"); misses.InnerText = score.Misses.ToString(); root.AppendChild(misses); XmlElement maxC = doc.CreateElement("maxc"); maxC.InnerText = score.MaxCombo.ToString(); root.AppendChild(maxC); XmlElement totalScore = doc.CreateElement("totalscore"); totalScore.InnerText = score.TotalScore.ToString(); root.AppendChild(totalScore); XmlElement acc = doc.CreateElement("acc"); acc.InnerText = score.Accuracy.ToString(Config.cultureEnglish); root.AppendChild(acc); XmlElement flag = doc.CreateElement("flags"); flag.InnerText = "" + score.Flags; root.AppendChild(flag); doc.AppendChild(root); doc.Save("tmp.xml"); UploadClass uc = new UploadClass(); uc.uploadDone += new Action<string, int>(uc_uploadDone); try { uc.HttpUploadFileAsync("http://p.ulse.net/scoresubmit", nvc, rName, "replay", "text/xml", "tmp.xml", "score", "text/xml"); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } catch (Exception ex) { Console.WriteLine("Score submit failed: " + ex.Message); } } notAdded = false; scoreScreen = new ScoreScreen(game, "scores", currentReplay, currentSong, difficulty, true); scoreScreen.OnLoad(null); } } if (!scores) { foreach (Note n in chart.Notes) { if (n.Offset - currentOffset > 20000) break; if (n.Texture.Colour.A <= 0 && running && n.Offset - currentOffset > -hitWindow && n.Holdbar.Colour.A <= 0 && !holding[n.Location - 1]) { n.Visible = false; } if (n.Offset - currentOffset < n.MoveTime && n.Visible && n.Enabled) { moveRate = (double)(int)frame.HitHeight / n.MoveTime; double temp = n.Offset - currentOffset; double moved = (n.MoveTime - temp) * moveRate; n.Vertical = moved; if (n.Hold) { temp = n.HoldOffset - currentOffset; moved = (n.MoveTime - temp) * moveRate; n.HoldVertical = moved; } if (((Mods.Flags & 8) == 8) && n.Offset - currentOffset < n.MoveTime - (n.MoveTime / 3)) { if (!n.Texture.Fading) { n.Texture.fade(0.0f, 0.2 / (mods.Scroll > 5 ? mods.Scroll / 10 : mods.Scroll)); } if (n.Hold && n.HoldOffset - currentOffset < n.MoveTime - (n.MoveTime / 3) && !n.Holdbar.Fading) { n.Holdbar.fade(0.0f, 0.2); n.HoldEnd.fade(0.0f, 0.2); n.HoldStart.fade(0.0f, 0.2); } } } if (n.Enabled) { bool added = false; if ((n.Offset - currentOffset < n.MoveTime && n.Offset - currentOffset > -hitWindow) || holding[n.Location - 1]) { if (!Music.Paused) { if (canHit[n.Location - 1]) { if (keys[n.Location - 1] && !prevKey[n.Location - 1]) { if (n.Offset - currentOffset < hitWindow && n.Offset - currentOffset > -hitWindow) { if (calibrate) { offsets.Add((int)currentOffset - (int)n.Offset); offsetLabel.Text = "Average mistime: " + Math.Round(offsets.Average(), 3); } comboText.move(new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0] * 2)) / 2, frame.Location.Y + 185), 0.02); comboText.scale(new Size(frame.LaneWidth[0] * 2, frame.LaneWidth[0] * 2), 0.02); comboMove = true; canHit[n.Location - 1] = false; if (Config.HitVolume > 0 && hitsound != null) { sfx = AudioManager.loadFromMemory(hitsound);//.loadFromFile(Skin.skindict["normal-hitnormal"],true); sfx.Volume = Config.HitVolume / 100f; //add separate hitsound config setting later? sfx.play(false); } if (!added) { Replay.HitType hit = Replay.HitType.MISS; added = true; score.Combo++; if (n.Offset - currentOffset < (hitWindow - ((hitWindow / 100) * 70)) && n.Offset - currentOffset > -(hitWindow - ((hitWindow / 100) * 70))) { adjustHp(2); burstAcc(3); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 3); score.AccuracyTotal.Add(3); hit = Replay.HitType.PERFECT; } else if (n.Offset - currentOffset < (hitWindow - ((hitWindow / 100) * 40)) && n.Offset - currentOffset > -(hitWindow - ((hitWindow / 100) * 40))) { adjustHp(1); burstAcc(2); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 2); score.AccuracyTotal.Add(2); hit = Replay.HitType.GOOD; } else if (n.Offset - currentOffset < (hitWindow - ((hitWindow / 100) * 10)) && n.Offset - currentOffset > -(hitWindow - ((hitWindow / 100) * 10))) { adjustHp(-3); burstAcc(1); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 1); score.AccuracyTotal.Add(1f); hit = Replay.HitType.OK; } if (hit != Replay.HitType.MISS) { currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, hit)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)hit); } burst = new Animation(new Rectangle(((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * n.Location - 1)) + 5 - frame.LaneWidth[n.Location - 1] * 2, (int)frame.HitHeight - 25 - frame.LaneWidth[n.Location - 1] * 2, frame.LaneWidth[n.Location - 1] + frame.LaneWidth[n.Location - 1] * 4, frame.LaneWidth[n.Location - 1] + frame.LaneWidth[n.Location - 1] * 4), Skin.BurstFrameRate, "burst", Skin.BurstFrameCount, false, Skin.MaskBursts); bursts.Add(burst); } } if (!n.Hold) { n.Enabled = false; n.Texture.fade(0.0f, 0.05); } else { holding[n.Location - 1] = true; n.Texture.fade(0.0f, 0.05); holdBursts.Add(new Animation(new Rectangle(((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * n.Location)) + 5 - frame.LaneWidth[n.Location - 1] * 2, (int)frame.HitHeight - 25 - frame.LaneWidth[n.Location - 1] * 2, frame.LaneWidth[n.Location - 1] + frame.LaneWidth[n.Location - 1] * 4, frame.LaneWidth[n.Location - 1] + frame.LaneWidth[n.Location - 1] * 4), Skin.HoldFrameRate, "holdBurst", 3, true, Skin.MaskHolds)); } } else if (n.Offset - currentOffset < ((double)hitWindow * 1.1) && n.Offset - currentOffset > (double)(hitWindow * 0.9)) { n.Enabled = false; n.Texture.fade(0.0f, 0.1); if (n.Hold) { n.Holdbar.fade(0.0f, 0.1); n.HoldEnd.fade(0.0f, 0.1); n.HoldStart.fade(0.0f, 0.1); } burstAcc(0); if (!added) { if (!n.Hold) { currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, Replay.HitType.MISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)Replay.HitType.MISS); } adjustHp(-12); } else { currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, Replay.HitType.HOLDMISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)Replay.HitType.HOLDMISS); } adjustHp(-24); } miss(); added = true; } } //Console.WriteLine("Current: " + currentOffset + ", Note: " + n.Offset + ", Diff: " + (currentOffset - n.Offset)); comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0])) / 2, frame.Location.Y + 200); if (score.Combo > 2) { comboText.Visible = true; } } } else if (!canHit[n.Location - 1] && n.Hold && holding[n.Location - 1]) { //display hold success texture/effect when implemented if (!keys[n.Location - 1] && prevKey[n.Location - 1]) { foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * n.Location)) + 5 - frame.LaneWidth[n.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } if (n.HoldOffset - currentOffset < hitWindow * 2 && n.HoldOffset - currentOffset > -hitWindow * 2) { comboText.move(new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0] * 2)) / 2, frame.Location.Y + 185), 0.03); comboText.scale(new Size(frame.LaneWidth[0] * 2, frame.LaneWidth[0] * 2), 0.03); comboMove = true; if (Config.HoldHitsounds && Config.HitVolume > 0 && hitsound != null) { sfx = AudioManager.loadFromMemory(hitsound);//.loadFromFile(Skin.skindict["normal-hitnormal"],true); sfx.Volume = Config.HitVolume / 100f; //add separate hitsound config setting later? sfx.play(false); } if (!added) { Replay.HitType hit = Replay.HitType.MISS; if (n.HoldOffset - currentOffset < (hitWindow - ((hitWindow / 100) * 70)) * 2 && n.HoldOffset - currentOffset > -(hitWindow - ((hitWindow / 100) * 70)) * 2) { adjustHp(2); burstAcc(3); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 3); score.AccuracyTotal.Add(3); hit = Replay.HitType.PERFECT; } else if (n.HoldOffset - currentOffset < (hitWindow - ((hitWindow / 100) * 40)) * 2 && n.HoldOffset - currentOffset > -(hitWindow - ((hitWindow / 100) * 40)) * 2) { adjustHp(1); burstAcc(2); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 2); score.AccuracyTotal.Add(2); hit = Replay.HitType.GOOD; } else if (n.HoldOffset - currentOffset < (hitWindow - ((hitWindow / 100) * 10)) * 2 && n.HoldOffset - currentOffset > -(hitWindow - ((hitWindow / 100) * 10)) * 2) { adjustHp(-3); burstAcc(1); score.TotalScore += (int)(scoreMod * ((score.Combo * 9) / 6.5) * 3); score.AccuracyTotal.Add(1); hit = Replay.HitType.OK; } if (hit != Replay.HitType.MISS) { currentReplay.HitTimings.Add(new ReplayHit((int)n.HoldOffset, (int)n.HoldOffset - (int)currentOffset, n.Location - 1, hit)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.HoldOffset, (int)(n.HoldOffset - currentOffset), n.Location - 1, (int)hit); } score.Combo++; added = true; if (score.Combo > 2) { comboText.Visible = true; } } } n.Enabled = false; n.Texture.fade(0.0f, 0.05); n.Holdbar.fade(0.0f, 0.05); n.HoldStart.fade(0.0f, 0.05); n.HoldEnd.fade(0.0f, 0.05); holding[n.Location - 1] = false; } else if (n.Offset - currentOffset < 0) { burstAcc(0); adjustHp(-12); currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, Replay.HitType.MISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)Replay.HitType.MISS); } if (!added) { miss(); } n.Enabled = false; n.Texture.fade(0.0f, 0.1); n.Holdbar.fade(0.0f, 0.1); n.HoldEnd.fade(0.0f, 0.1); n.HoldStart.fade(0.0f, 0.1); holding[n.Location - 1] = false; } comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0])) / 2, frame.Location.Y + 200); } else if (n.HoldOffset - currentOffset < -hitWindow * 2) { foreach (Animation a in holdBursts) { if (a.Bounds.X == ((int)frame.Location.X + (frame.LaneLoc[n.Location - 1]) + (1 * n.Location)) + 5 - frame.LaneWidth[n.Location - 1] * 2) { a.Active = false; holdRem.Add(a); } } burstAcc(0); adjustHp(-12); currentReplay.HitTimings.Add(new ReplayHit((int)n.HoldOffset, (int)n.HoldOffset - (int)currentOffset, n.Location - 1, Replay.HitType.MISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.HoldOffset, (int)(n.HoldOffset - currentOffset), n.Location - 1, (int)Replay.HitType.MISS); } if (!added) { added = true; miss(); } n.Enabled = false; n.Texture.fade(0.0f, 0.1); n.Holdbar.fade(0.0f, 0.1); n.HoldEnd.fade(0.0f, 0.1); n.HoldStart.fade(0.0f, 0.1); holding[n.Location - 1] = false; comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0])) / 2, frame.Location.Y + 200); } } if (n.Enabled && n.Offset - currentOffset < -hitWindow && !holding[n.Location - 1]) { burstAcc(0); adjustHp(-12); currentReplay.HitTimings.Add(new ReplayHit((int)n.HoldOffset, (int)n.HoldOffset - (int)currentOffset, n.Location - 1, Replay.HitType.MISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.HoldOffset, (int)(n.HoldOffset - currentOffset), n.Location - 1, (int)Replay.HitType.MISS); } if (!added) { added = true; miss(); } n.Enabled = false; n.Texture.fade(0.0f, 0.1); if (n.Hold) { n.Holdbar.fade(0.0f, 0.1); n.HoldEnd.fade(0.0f, 0.1); n.HoldStart.fade(0.0f, 0.1); } comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0])) / 2, frame.Location.Y + 200); } } } else if ((n.Offset - currentOffset) < -hitWindow) { n.Enabled = false; n.Texture.fade(0.0f, 0.1); if (n.Hold) { n.Holdbar.fade(0.0f, 0.1); n.HoldEnd.fade(0.0f, 0.1); n.HoldStart.fade(0.0f, 0.1); adjustHp(-24); currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, Replay.HitType.HOLDMISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)Replay.HitType.HOLDMISS); } } else { adjustHp(-12); currentReplay.HitTimings.Add(new ReplayHit((int)n.Offset, (int)n.Offset - (int)currentOffset, n.Location - 1, Replay.HitType.MISS)); if (Config.Spectated) { PacketWriter.sendSpectateHit(Game.conn.Bw, (int)n.Offset, (int)(n.Offset - currentOffset), n.Location - 1, (int)Replay.HitType.MISS); } } burstAcc(0); if (!added) { added = true; miss(); } comboText.Location = new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString(comboText.Text, frame.LaneWidth[0])) / 2, frame.Location.Y + 200); } } } } else { } #endregion } for (int x = 0; x < keys.Length; x++) { prevKey[x] = keys[x]; } if (paused) { if (!buffering && !specFailed) { pauseScreen.OnUpdateFrame(e); } } if (scoreLabel.Text != score.TotalScore.ToString("D9")) { scoreLabel.Text = score.TotalScore.ToString("D9"); } if (comboText.Text != score.Combo + "x") { comboText.Text = score.Combo + "x"; } if (score.Accuracy > 0) { if (accuracyLabel.Text != "" + String.Format("{0:0.00}%", score.Accuracy)) { accuracyLabel.Text = "" + String.Format("{0:0.00}%", score.Accuracy); } } else { accuracyLabel.Text = ""; } for (int z = accRem.Count - 1; z > -1; z--) { bursts.Remove(accRem[z]); accRem.Remove(accRem[z]); } for (int z = holdRem.Count - 1; z > -1; z--) { holdBursts.Remove(holdRem[z]); holdRem.Remove(holdRem[z]); } for (int z = hitTimingsToAdd.Count - 1; z > -1; z--) { currentReplay.HitTimings.Add(hitTimingsToAdd[z]); hitTimingsToAdd.RemoveAt(z); } for (int z = pressTimingsToAdd.Count - 1; z > -1; z--) { currentReplay.PressTimings.Add(pressTimingsToAdd[z]); pressTimingsToAdd.RemoveAt(z); } for (int z = releaseTimingsToAdd.Count - 1; z > -1; z--) { currentReplay.ReleaseTimings.Add(releaseTimingsToAdd[z]); releaseTimingsToAdd.RemoveAt(z); } }
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(); }
private void initUI() { if (skip != null) { UIComponents.Remove(skip); } skip = new Button(game, new Rectangle(400, 350, 200, 50), "Skip", delegate(int data) { running = true; unpause(); music.PositionAsMilli = (long)startOffset - 2000; currentOffset = music.PositionAsMilli; skip.Visible = false; skip.Enabled = false; }); UIComponents.Add(skip); if (startOffset < 2000) { skip.Visible = false; skip.Enabled = false; } else { skip.Visible = true; skip.Enabled = true; } bg = new Rect(new Rectangle(0, 0, Config.ResWidth, 768)); if (currentSong.FileVersion == 0) { bg.useTexture("songs\\" + currentSong.Dir + "\\" + currentSong.BgName); music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName); } else { bg.useTexture("songs\\" + currentSong.Dir + "\\" + chart.BgName); music = AudioManager.loadFromFile("songs\\" + currentSong.Dir + "\\" + currentSong.FileName); //fix in future to load per chart } forceScores = false; failed = false; scores = false; running = false; paused = false; UIComponents.Clear(); score = new Score(); score.Flags = (int)mods.Flags; scoreFadeTime = 0; pulse = false; Config.Editing = false; Skin.PlayFrame = new Frame(Skin.FrameLoc, chart.Keys); frame = Skin.PlayFrame; setNoteOffsets(Skin.FrameLoc); tlContainer = new Rect(new Rectangle(Config.ResWidth - 605, 0, 605, 150), Skin.skindict["tlContainer"]); hpBar = new Rect(new Rectangle((int)frame.Location.X + (int)frame.Width, 0, 10, (int)frame.HitHeight)); adjustHp(0); overlay = new Rect(new Rectangle(0, 0, Config.ResWidth, 768)); overlay.Colour = new Color4(0.0f, 0.0f, 0.0f, 0.0f); glow = new Rect(new Rectangle((int)frame.Location.X, (int)frame.HitHeight - 43, (int)frame.Width, 40), Skin.skindict["keyLight"]); glow.Colour = Skin.PulseColour; for (int x = 0; x < lights.Length; x++) { presses[x] = new Rect(new Rectangle(frame.Location.X + frame.LaneLoc[x] + 5 + (1 * x), frame.Location.Y + 600, frame.LaneWidth[x] + 1, 50), Skin.skindict["press" + (x + 1)]); presses[x].fade(0.0f, 0.075); lights[x] = new Rect(new Rectangle(((frame.Location.X) + frame.LaneLoc[x]) + (1 * x) + 5 + 25, (int)frame.HitHeight - 53, 0, frame.LaneWidth[x]), Skin.skindict["keyLight"]); glows[x] = new Rect(new Rectangle(((frame.Location.X) + frame.LaneLoc[x]) + (1 * x) + 5, (int)frame.HitHeight - 203, frame.LaneWidth[x], 200), Skin.skindict["keyLight"]); glows[x].Colour = new Color4(1.0f, 1.0f, 1.0f, 0.5f); lights[x].Colour = Skin.LightColours[x]; lights[x].fade(0.0f, 0.075); glows[x].fade(0.0f, 0.075); } songtitle = new Label(game, new Point(Config.ResWidth - 490, 10), currentSong.SongName + " - " + chart.Name); songartist = new Label(game, new Point(Config.ResWidth - 485, 60), currentSong.Artist); songtitle.TextTexture.TextFont = new Font("Myriad Pro", 35); songtitle.TextTexture.Shadow = false; songartist.TextTexture.Shadow = false; UIComponents.Add(songartist); UIComponents.Add(songtitle); if (calibrate) { offsetLabel = new Label(game, new Point(450, 85), "Average mistime: "); UIComponents.Add(offsetLabel); offsetLabel.Visible = true; offsetLabel.Enabled = true; offsets.Clear(); } scoreLabel = new GraphicalText(score.TotalScore.ToString("D9"), Skin.ScoreLocation); scoreLabel.scale(new Size(30, 30), 0.1); comboText = new GraphicalText("0x", (new Point(frame.Location.X + (int)frame.Width / 2 - (int)(GraphicalText.measureString("0x", frame.LaneWidth[0])) / 2, frame.Location.Y + 200))); comboText.Visible = false; accuracyLabel = new GraphicalText("00.00%", Skin.AccLocation); pauseScreen = new PauseScreen(game, "pause", this); pauseScreen.OnLoad(null); countDown = new Label(game, new Point((int)frame.Location.X + (int)frame.Width + 20, (int)frame.HitHeight - 20), "00:00"); countDown.TextTexture.TextFont = new Font("Myriad pro", 30); UIComponents.Add(countDown); scoreLabel.scale(new Size(Skin.ScoreSize.Width, Skin.ScoreSize.Height), 0.0); accuracyLabel.scale(new Size(Skin.AccSize.Width, Skin.AccSize.Height), 0.0); if (skip != null) { UIComponents.Add(skip); } bufferOverlay = new Rect(new Rectangle(0, 0, Config.ResWidth, 768)); bufferOverlay.Colour = new Color4(0, 0, 0, 0.5f); bufferingLabel = new Label(game, new Point(Config.ResWidth / 2 - 100, 768 / 2 - 20), "Buffering..."); specFailedLabel = new Label(game, new Point(Config.ResWidth / 2 - 100, 768 / 2 - 20), "User failed"); userList = new Text(new Size(700, 100), new Point((int)frame.Width + 50, 70)); oldSpecs = ""; }