private void quickLoadToolStripMenuItem_DropDownOpening(object sender, EventArgs e) { this.quickLoadToolStripMenuItem.DropDownItems.Clear(); if (Directory.Exists(MainForm.Path_Replays)) { string[] files = Directory.GetFiles(MainForm.Path_Replays, "*.osr", SearchOption.TopDirectoryOnly); ToolStripMenuItem parentItem = this.quickLoadToolStripMenuItem; int groupBy = 30; int maxItems = files.Length; int counter = 0; foreach (string fullpath in files) { if (maxItems > groupBy && counter % groupBy == 0) { parentItem = new ToolStripMenuItem(String.Format("{0} to {1}", counter + 1, Math.Min(counter + groupBy, maxItems))); this.quickLoadToolStripMenuItem.DropDownItems.Add(parentItem); } string[] split = fullpath.Split('\\'); ToolStripMenuItem item = new ToolStripMenuItem(split[split.Length - 1]); item.Click += item_Click; parentItem.DropDownItems.Add(item); counter++; } } else { MainForm.ErrorMessage("You do not have a replay folder specified. You can change this in the settings file."); } }
private void reloadToolStripMenuItem_Click(object sender, EventArgs e) { try { this.SetSettings(Program.LoadSettings()); } catch { MainForm.ErrorMessage("The settings file was deleted. A new one will be created when you relaunch the program."); } }
public static void OpenSettings() { try { System.Diagnostics.Process.Start(MainForm.Path_Settings); } catch (Exception e) { MainForm.ErrorMessage(e.Message); } }
private Texture2D TextureFromFile(string path) { try { return(new Texture2D(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))); } catch { MainForm.ErrorMessage(String.Format("Could not the load the image found at \"{0}\", please make sure it exists and is a valid .png image.\nRedownloading the .zip file will also restore lost images and update new ones.", path)); return(null); } }
public void Open(string replayPath) { try { if (this.CurrentReplays[this.Canvas.State_ReplaySelected] != null) { this.CurrentReplays[this.Canvas.State_ReplaySelected].Dispose(); } this.CurrentReplays[this.Canvas.State_ReplaySelected] = new ReplayAPI.Replay(replayPath, true); if (this.OsuDbFile == null) { ErrorMessage("Can not read osu!.db."); return; } string beatmapPath = ""; foreach (OsuDbAPI.Beatmap dbBeatmap in this.OsuDbFile.Beatmaps) { if (dbBeatmap.Hash == this.CurrentReplays[this.Canvas.State_ReplaySelected].MapHash) { beatmapPath = MainForm.Path_Songs + dbBeatmap.FolderName + "\\" + dbBeatmap.OsuFile; break; } } if (beatmapPath.Length > 0) { this.Canvas.Beatmap = new BMAPI.v1.Beatmap(beatmapPath); } else { this.Canvas.Beatmap = null; this.SetTimelinePercent(0); MainForm.ErrorMessage("Could not locate .osu file."); } this.UpdateTitle(); this.Canvas.LoadReplay(this.CurrentReplays[this.Canvas.State_ReplaySelected]); if (this.GetReplayRadioBtn(this.Canvas.State_ReplaySelected).Text[0] == ' ') { char[] eax = this.GetReplayRadioBtn(this.Canvas.State_ReplaySelected).Text.ToCharArray(); eax[0] = '*'; this.GetReplayRadioBtn(this.Canvas.State_ReplaySelected).Text = new string(eax); } this.volumeBar_Scroll(null, null); } catch (Exception e) { MainForm.ErrorMessage("Error loading replay: perhaps it is not a replay file ?\nmore info: " + e.Message); } }
public void SetSettings(string[] settings) { MainForm.Path_OsuDb = settings[0]; MainForm.Path_Songs = settings[1]; MainForm.Path_Replays = settings[2]; if (Directory.Exists(MainForm.Path_Songs)) { if (MainForm.Path_Songs[MainForm.Path_Songs.Length - 1] != '\\') { MainForm.Path_Songs += '\\'; } if (File.Exists(MainForm.Path_OsuDb)) { try { this.OsuDbFile = new OsuDbAPI.OsuDbFile(MainForm.Path_OsuDb); } catch { MainForm.ErrorMessage("Could not load osu!.db. Try deleting it and letting osu! rebuild it when you relaunch the game."); } } else { MainForm.ErrorMessage("Path to osu!.db file does not exist. You will not be able to view beatmaps, only the cursor data."); } } else { MainForm.ErrorMessage("Path to songs folder does not exist. You will not be able to view beatmaps, only the cursor data."); } if (Directory.Exists(MainForm.Path_Replays)) { if (MainForm.Path_Replays[MainForm.Path_Replays.Length - 1] != '\\') { MainForm.Path_Replays += '\\'; } } }
private void Tick() { if (Keyboard.GetState().IsKeyDown(Key.H)) { this.ShowHelp = 1; } else if (this.ShowHelp != 2) { this.ShowHelp = 0; } if (Keyboard.GetState().IsKeyDown(Key.D) || Keyboard.GetState().IsKeyDown(Key.Right)) { this.State_PlaybackFlow = 2; } else if (Keyboard.GetState().IsKeyDown(Key.A) || Keyboard.GetState().IsKeyDown(Key.Left)) { this.State_PlaybackFlow = 1; } else if (this.State_PlaybackFlow != 3) { this.State_PlaybackFlow = 0; } MainForm.self.SetPlayPause("Play"); if (this.State_PlaybackFlow == 0) { this.songPlayer.Pause(); } else if (this.State_PlaybackFlow == 1) { this.songPlayer.Pause(); //this.songPlayer.JumpTo((long)(this.songPlayer.SongTime - (gameTime.ElapsedGameTime.Milliseconds * this.State_PlaybackSpeed))); this.songPlayer.JumpTo((long)(this.songPlayer.SongTime - ((1000.0 / 60.0) * this.State_PlaybackSpeed))); } else if (this.State_PlaybackFlow == 2) { this.songPlayer.Play(); } else if (this.State_PlaybackFlow == 3) { MainForm.self.SetPlayPause("Pause"); this.songPlayer.Play(); } if (this.MaxSongTime != 0) { MainForm.self.SetTimelinePercent((float)this.songPlayer.SongTime / (float)this.MaxSongTime); } MainForm.self.SetSongTimeLabel((int)this.songPlayer.SongTime); this.nearbyHitObjects = new List <BMAPI.v1.HitObjects.CircleObject>(); if (this.Beatmap != null) { // we take advantage of the fact that the hitobjects are listed in chronological order and implement a binary search // this will the index of the hitobject closest (rounded down) to the time // we will get all the hitobjects a couple seconds after and before the current time int startIndex = this.BinarySearchHitObjects((float)(this.songPlayer.SongTime - 10000)) - 5; int endIndex = this.BinarySearchHitObjects((float)(this.songPlayer.SongTime + 2000)) + 5; for (int k = startIndex; k < endIndex; k++) { if (k < 0) { continue; } else if (k >= this.Beatmap.HitObjects.Count) { break; } this.nearbyHitObjects.Add(this.Beatmap.HitObjects[k]); } } for (int j = 0; j < 7; j++) { if (this.replayFrames[j] != null) { if (this.replayFrames[j].Count == 0) { MainForm.ErrorMessage("This replay contains no cursor data."); this.replayFrames[j] = null; continue; } // like the hitobjects, the replay frames are also in chronological order // so we use more binary searches to efficiently get the index of the replay frame at a time this.nearbyFrames[j] = new List <ReplayAPI.ReplayFrame>(); if (this.State_PlaybackMode == 0) { int lowIndex = this.BinarySearchReplayFrame(j, (int)(this.songPlayer.SongTime) - this.State_TimeRange); int highIndex = this.BinarySearchReplayFrame(j, (int)this.songPlayer.SongTime) + 1; for (int i = lowIndex; i <= highIndex; i++) { this.nearbyFrames[j].Add(this.replayFrames[j][i]); } } else if (this.State_PlaybackMode == 1) { int nearestIndex = this.BinarySearchReplayFrame(j, (int)this.songPlayer.SongTime); this.nearbyFrames[j].Add(this.replayFrames[j][nearestIndex]); if (nearestIndex + 1 < this.replayFrames[j].Count) { this.nearbyFrames[j].Add(this.replayFrames[j][nearestIndex + 1]); } } } } }