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(); } } } }
public override void OnUpdateFrame(OpenTK.FrameEventArgs e) { scroll(); float mwdif = 0; if (!Game.MouseState.LeftButton) { doIt = true; } float currentmw = game.Mouse.WheelPrecise; base.OnUpdateFrame(e); if (searchCountdown > 0 && !resetSearch) { searchCountdown -= (int)(e.Time * 1000); } if (searchCountdown <= 0 && !resetSearch) { // if(!searchLabel.Text.Equals("")) { search(searchLabel.Text); //} resetSearch = true; searchCountdown = 500; } if (updateScore) { if (displayScores != null && displayScores.Count > 0) { int upperlimit = displayScores.Count > scoreDisplayPage * 8 + 8 ? scoreDisplayPage * 8 + 8 : displayScores.Count; if (upperlimit > displayScores.Count) { upperlimit = 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, currtIndex, data); }, Skin.skindict["scoreentry"]); toAdd.OtherData = i + 1; scoreDisplayText.Add(toAdd); } } updateScore = false; } for (int i = 0; i < scoreDisplayText.Count; i++) { //orig 770 int recalc = Config.ResWidth - 254; Button b = scoreDisplayText[i]; if (b.Bounds.X == (int)(Config.ResWidth - 254)) { continue; //nothing to do here } if (i != 0) { if (scoreDisplayText[i - 1].Bounds.X > (int)(Config.ResWidth - 104)) { //stagger it continue; } } //770 //total of 254 pixels to travel double percentage = (b.Bounds.X - recalc) / 254d; // double percentage = (b.Bounds.X - 1034) / 254d; double squared = Math.Pow(percentage, 0.7); /// Console.WriteLine("{0} {1}", percentage, squared); if (b.Bounds.X > recalc) { // Console.WriteLine(b.Bounds.X); int tomove = b.Bounds.X - ((int)Math.Round((20 * squared)) + 1);// ((int)(1600 * e.Time)); //with *time wasnt being staggered correctly because if the update took too long in the first update it would step over 920 if (tomove < recalc) { tomove = recalc; } b.Bounds = new Rectangle(tomove, b.Bounds.Y, b.Bounds.Width, b.Bounds.Height); } else { b.Bounds = new Rectangle(recalc, b.Bounds.Y, b.Bounds.Width, b.Bounds.Height); } } if (transitioning) { if (transIn) { bgoverlay.Alpha += 0.15f; if (bgoverlay.Alpha >= 1f) { transIn = false; } } else { bgoverlay.Alpha -= 0.15f; if (bgoverlay.Alpha <= 0f) { transitioning = false; transIn = true; } } } if (changed) { time += e.Time; if (time > 0.1) { Music.Volume += targetVolume / 10.0f; if (Music.Volume >= targetVolume) { Music.Volume = targetVolume; changed = false; } time = 0.0; } } if (accept && !Game.pbox.expanded) { // searchLabel.Text += toadd; if (keyPress(Key.Down)) { if (pickSong) { if (index + 1 != songNameList.Count) { index++; changeSong(); } } } else if (keyPress(Key.Up)) { if (pickSong) { if (index - 1 > -1) { index--; changeSong(); } } } else if (keyPress(Key.Enter)) { if (pickSong) { pickDiffs(); updateScoreLabels(0); if (play) { calibrateButton.Visible = true; calibrateButton.Enabled = true; } } else if (pickDiff) { playButton.del.Invoke(0); } } else if (keyPress(Key.Escape)) { if (pickDiff) { notPickDiffs(); updateScoreLabels(0); diffIndex = 0; if (play) { calibrateButton.Visible = false; calibrateButton.Enabled = false; } } else if (searchLabel.Text.Length > 0) { resetSearch = false; searchCountdown = 0; searchLabel.Text = ""; } else { //Music.stop(); Game.setScreen(game.screens["menuScreen"]); } } else if (keyPress(Key.F1)) { refresh(); changeSong(); } else if ((mwdif = currentmw - prevMouse) != 0) { prevMouse = currentmw; totalscroll += mwdif; // Console.WriteLine("{0},{1},{2}", mwdif, prevMouse, "lol"); if (totalscroll < -5f) { if (pickSong) { if (index + 1 != songNameList.Count) { index++; changeSong(); } } totalscroll = 0; // Console.WriteLine("total scroll reset"); } else if (totalscroll > 5f) { if (pickSong) { if (index - 1 > -1) { index--; changeSong(); } } totalscroll = 0; //Console.WriteLine("total scroll reset"); } } else { } } else { count++; if (count == 10) { accept = true; } } for (int x = 0; x < songNameList.Count; x++) { songNameList[x].select.OnUpdateFrame(e); } if (dim.Colour.A > 0 || pickDiff) { dim.draw(e); panel.draw(e); playButton.OnUpdateFrame(e); hdB.OnUpdateFrame(e); dtB.OnUpdateFrame(e); nfB.OnUpdateFrame(e); mirB.OnUpdateFrame(e); autoB.OnUpdateFrame(e); htB.OnUpdateFrame(e); closeSel.OnUpdateFrame(e); calibrateButton.OnUpdateFrame(e); rateDrag.OnUpdateFrame(e); } if (displayScores != null) { if (scoreDisplayText.Count > 0) { foreach (Button t in scoreDisplayText) { t.OnUpdateFrame(null); } } } }