Пример #1
0
        public static string GetCurrentBeatmap()
        {
            string path;

            try {
                string songs = SettingsManager.GetSongsPath();

                if (string.IsNullOrEmpty(songs))
                {
                    throw new Exception(
                              @"Can't fetch current in-game beatmap, because there is no Songs path specified in Preferences.");
                }

                string folder   = PioReader.GetMapFolderName();
                string filename = PioReader.GetOsuFileName();

                if (string.IsNullOrEmpty(folder))
                {
                    throw new Exception(@"Can't fetch the folder name of the current in-game beatmap.");
                }

                if (string.IsNullOrEmpty(filename))
                {
                    throw new Exception(@"Can't fetch the file name of the current in-game beatmap.");
                }

                path = Path.Combine(songs, folder, filename);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                try {
                    var reader = EditorReaderStuff.GetEditorReader();
                    reader.FetchEditor();
                    reader.SetHOM();
                    reader.ReadHOM();
                    reader.FetchBeatmap();
                    path = EditorReaderStuff.GetCurrentBeatmap(reader);
                }
                catch (Exception ex2) {
                    Console.WriteLine(ex2.Message);
                    Console.WriteLine(ex2.StackTrace);
                    throw ex;
                }
            }

            return(path);
        }
Пример #2
0
        public static string GetCurrentBeatmap()
        {
            try {
                string songs = SettingsManager.GetSongsPath();

                string folder   = PioReader.GetMapFolderName();
                string filename = PioReader.GetOsuFileName();
                string path     = Path.Combine(songs, folder, filename);

                if (songs == "" || folder == "" || filename == "")
                {
                    return("");
                }
                return(path);
            }
            catch (Exception) {
                return("");
            }
        }
Пример #3
0
        private void BeatmapUpdateTimer_Tick(object sender, EventArgs e)
        {
            if (gameLoaded == false || gameLoaded == null || !mapSelectScreen || editor.State == EditorState.GENERATING_BEATMAP)
            {
                return;
            }

            // this can be cleaned up...
            // Read memory for current map
            string beatmapFolder   = osuReader.GetMapFolderName();
            string beatmapFilename = osuReader.GetOsuFileName();

            var invalidChars = Path.GetInvalidFileNameChars();

            // Read unsuccessful
            if (string.IsNullOrWhiteSpace(beatmapFilename) || beatmapFilename.Any(c => invalidChars.Contains(c)))
            {
                return;
            }

            // Beatmap name hasn't changed since last read
            if (previousBeatmapRead != null && previousBeatmapRead == beatmapFilename)
            {
                return;
            }
            previousBeatmapRead = beatmapFilename;

            // Try to locate the beatmap
            string absoluteFilename = Path.Combine(userSongsFolder, beatmapFolder, beatmapFilename);

            if (!File.Exists(absoluteFilename))
            {
                return;
            }

            // signal the editor class to load this beatmap sometime in the future
            editor.RequestBeatmapLoad(absoluteFilename);
        }
Пример #4
0
        private void OnShown(object sender, EventArgs eventArgs)
        {
            if (!string.IsNullOrEmpty(_osuWindowTitleHint))
            {
                Text += $": {_osuWindowTitleHint}";
            }
            _ = Task.Run(async() =>
            {
                try
                {
                    var playContainer = new PlayContainerEx();
                    var playReseted   = false;
                    while (true)
                    {
                        if (cts.IsCancellationRequested)
                        {
                            return;
                        }

                        var patternsToRead = GetPatternsToRead();

                        var stopwatch = Stopwatch.StartNew();

                        #region OsuBase

                        var mapId         = -1;
                        var songString    = string.Empty;
                        var mapMd5        = string.Empty;
                        var mapFolderName = string.Empty;
                        var osuFileName   = string.Empty;
                        var retrys        = -1;
                        var gameMode      = -1;
                        var mapData       = string.Empty;
                        var status        = OsuMemoryStatus.Unknown;
                        var statusNum     = -1;
                        var playTime      = -1;
                        if (patternsToRead.OsuBase)
                        {
                            mapId         = _reader.GetMapId();
                            songString    = _reader.GetSongString();
                            mapMd5        = _reader.GetMapMd5();
                            mapFolderName = _reader.GetMapFolderName();
                            osuFileName   = _reader.GetOsuFileName();
                            retrys        = _reader.GetRetrys();
                            gameMode      = _reader.ReadSongSelectGameMode();
                            mapData       =
                                $"HP:{_reader.GetMapHp()} OD:{_reader.GetMapOd()}, CS:{_reader.GetMapCs()}, AR:{_reader.GetMapAr()}, setId:{_reader.GetMapSetId()}";
                            status   = _reader.GetCurrentStatus(out statusNum);
                            playTime = _reader.ReadPlayTime();
                        }

                        #endregion

                        #region Mods

                        var mods = -1;
                        if (patternsToRead.Mods)
                        {
                            mods = _reader.GetMods();
                        }

                        #endregion

                        #region CurrentSkinData

                        var skinFolderName = string.Empty;
                        if (patternsToRead.CurrentSkinData)
                        {
                            skinFolderName = _reader.GetSkinFolderName();
                        }

                        #endregion

                        #region PlayContainer

                        double hp                = 0;
                        var playerName           = string.Empty;
                        var hitErrorCount        = -1;
                        var playingMods          = -1;
                        double displayedPlayerHp = 0;

                        if (status == OsuMemoryStatus.Playing && patternsToRead.PlayContainer)
                        {
                            playReseted = false;
                            _reader.GetPlayData(playContainer);
                            hp                = _reader.ReadPlayerHp();
                            playerName        = _reader.PlayerName();
                            hitErrorCount     = _reader.HitErrors()?.Count ?? -2;
                            playingMods       = _reader.GetPlayingMods();
                            displayedPlayerHp = _reader.ReadDisplayedPlayerHp();
                        }
                        else if (!playReseted)
                        {
                            playReseted = true;
                            playContainer.Reset();
                        }

                        #endregion

                        #region TourneyBase

                        // TourneyBase
                        var tourneyIpcState       = TourneyIpcState.Unknown;
                        var tourneyIpcStateNumber = -1;
                        var tourneyLeftStars      = -1;
                        var tourneyRightStars     = -1;
                        var tourneyBO             = -1;
                        var tourneyStarsVisible   = false;
                        var tourneyScoreVisible   = false;
                        if (status == OsuMemoryStatus.Tourney && patternsToRead.TourneyBase)
                        {
                            tourneyIpcState     = _reader.GetTourneyIpcState(out tourneyIpcStateNumber);
                            tourneyLeftStars    = _reader.ReadTourneyLeftStars();
                            tourneyRightStars   = _reader.ReadTourneyRightStars();
                            tourneyBO           = _reader.ReadTourneyBO();
                            tourneyStarsVisible = _reader.ReadTourneyStarsVisible();
                            tourneyScoreVisible = _reader.ReadTourneyScoreVisible();
                        }

                        #endregion

                        stopwatch.Stop();

                        var readTimeMs = stopwatch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond;
                        double readTimeMsMin;
                        double readTimeMsMax;
                        lock (_minMaxLock)
                        {
                            if (readTimeMs < _memoryReadTimeMin)
                            {
                                _memoryReadTimeMin = readTimeMs;
                            }
                            if (readTimeMs > _memoryReadTimeMax)
                            {
                                _memoryReadTimeMax = readTimeMs;
                            }
                            // copy value since we're inside lock
                            readTimeMsMin = _memoryReadTimeMin;
                            readTimeMsMax = _memoryReadTimeMax;
                        }

                        Invoke((MethodInvoker)(() =>
                        {
                            textBox_readTime.Text = $"         ReadTimeMS: {readTimeMs}{Environment.NewLine}" +
                                                    $" Min ReadTimeMS: {readTimeMsMin}{Environment.NewLine}" +
                                                    $"Max ReadTimeMS: {readTimeMsMax}{Environment.NewLine}";

                            textBox_mapId.Text = mapId.ToString();
                            textBox_strings.Text = $"songString: \"{songString}\" {Environment.NewLine}" +
                                                   $"md5: \"{mapMd5}\" {Environment.NewLine}" +
                                                   $"mapFolder: \"{mapFolderName}\" {Environment.NewLine}" +
                                                   $"fileName: \"{osuFileName}\" {Environment.NewLine}" +
                                                   $"Retrys:{retrys} {Environment.NewLine}" +
                                                   $"mods:{(Mods)mods}({mods}) {Environment.NewLine}" +
                                                   $"SkinName: \"{skinFolderName}\"";
                            textBox_time.Text = playTime.ToString();
                            textBox_mapData.Text = mapData;
                            textBox_Status.Text = status + " " + statusNum + " " + gameMode;

                            textBox_CurrentPlayData.Text =
                                playContainer + Environment.NewLine +
                                $"hp________: {hp:00.##} {Environment.NewLine}" +
                                $"displayedHp: {displayedPlayerHp:00.##} {Environment.NewLine}" +
                                $"playingMods:{(Mods)playingMods} ({playingMods}) " +
                                $"PlayerName: {playerName}{Environment.NewLine}" +
                                $"HitErrorCount: {hitErrorCount} ";

                            if (status == OsuMemoryStatus.Tourney)
                            {
                                textBox_TourneyStuff.Text =
                                    $"IPC-State: {tourneyIpcState} ({tourneyIpcStateNumber}) | BO {tourneyBO}{Environment.NewLine}" +
                                    $"Stars: {tourneyLeftStars} | {tourneyRightStars}{Environment.NewLine}" +
                                    $"Warmup/Stars State: {(tourneyStarsVisible ? "stars visible, warmup disabled" : "stars hidden, warmup enabled")}{Environment.NewLine}" +
                                    $"Score/Chat state: {(tourneyScoreVisible ? "chat hidden, score visible or no lobby joined" : "chat visible, score hidden")}{Environment.NewLine}";
                            }
                            else
                            {
                                textBox_TourneyStuff.Text = "no data since not in tourney mode";
                            }
                        }));
                        await Task.Delay(_readDelay);
                    }
                }
                catch (ThreadAbortException)
                {
                }
            });
        }
Пример #5
0
        private void BeatmapUpdateTimer_Tick(object sender, EventArgs e)
        {
            if (gameLoaded == false || gameLoaded == null)
            {
                return;
            }


            // this can be cleaned up...
            // Read memory for current map
            string beatmapFolder   = osuReader.GetMapFolderName();
            string beatmapFilename = osuReader.GetOsuFileName();

            // Read unsuccessful
            if (beatmapFilename == "")
            {
                return;
            }

            // Beatmap name hasn't changed since last read
            if (previousBeatmapRead != null && previousBeatmapRead == beatmapFilename)
            {
                return;
            }
            previousBeatmapRead = beatmapFilename;

            // Try to locate the beatmap
            string absoluteFilename = userSongsFolder + "\\" + beatmapFolder + "\\" + beatmapFilename;

            if (!File.Exists(absoluteFilename))
            {
                if (++beatmapFindFailCounter == 10)
                {
                    string msg = "Automatic beatmap detection failed 10 times in a row. ";
                    msg += "Your songs folder is probably somewhere else. ";
                    msg += "Please manually select your Songs folder in the next window.";
                    MessageBox.Show(msg, "Having trouble finding your beatmaps...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    using (var folderDialog = new OpenFileDialog())
                    {
                        folderDialog.Title           = "Select your osu! installation folder";
                        folderDialog.ValidateNames   = false;
                        folderDialog.CheckFileExists = false;
                        folderDialog.CheckPathExists = true;
                        folderDialog.FileName        = "Select Folder";
                        if (folderDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        userSongsFolder = Path.GetDirectoryName(folderDialog.FileName);
                        Properties.Settings.Default.SongsFolder = userSongsFolder;
                        Properties.Settings.Default.Save();
                        // try again
                        absoluteFilename = userSongsFolder + "\\" + beatmapFolder + "\\" + beatmapFilename;
                        if (!File.Exists(absoluteFilename))
                        {
                            return;
                        }
                    }
                }
                return;
            }
            beatmapFindFailCounter = 0;

            // signal the editor class to load this beatmap sometime in the future
            editor.RequestBeatmapLoad(absoluteFilename);
        }
Пример #6
0
        private void BeatmapUpdateTimer_Tick(object sender, EventArgs e)
        {
            if (gameLoaded == false || gameLoaded == null || !mapSelectScreen || editor.State == EditorState.GENERATING_BEATMAP)
            {
                return;
            }

            // this can be cleaned up...
            // Read memory for current map
            string beatmapFolder   = osuReader.GetMapFolderName();
            string beatmapFilename = osuReader.GetOsuFileName();

            var invalidChars = Path.GetInvalidFileNameChars();

            // Read unsuccessful
            if (string.IsNullOrWhiteSpace(beatmapFilename) || beatmapFilename.Any(c => invalidChars.Contains(c)))
            {
                return;
            }

            // Beatmap name hasn't changed since last read
            if (previousBeatmapRead != null && previousBeatmapRead == beatmapFilename)
            {
                return;
            }
            previousBeatmapRead = beatmapFilename;

            // Try to locate the beatmap
            string absoluteFilename = Path.Combine(userSongsFolder, beatmapFolder, beatmapFilename);

            if (!File.Exists(absoluteFilename))
            {
                if (++beatmapFindFailCounter == 7)
                {
                    string msg = "Automatic beatmap detection failed 7 times in a row. ";
                    msg += "Your songs folder is probably not in your osu! install folder. ";
                    msg += "Please manually locate your Songs folder in the following window.";
                    MessageBox.Show(msg, "Having trouble finding your beatmaps...", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    using (var folderDialog = new OpenFileDialog())
                    {
                        folderDialog.Title           = "Select your osu! installation folder";
                        folderDialog.ValidateNames   = false;
                        folderDialog.CheckFileExists = false;
                        folderDialog.CheckPathExists = true;
                        folderDialog.FileName        = "Select Folder";
                        if (folderDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        userSongsFolder = Path.GetDirectoryName(folderDialog.FileName);
                        Properties.Settings.Default.SongsFolder = userSongsFolder;
                        Properties.Settings.Default.Save();
                        // try again
                        absoluteFilename = Path.Combine(userSongsFolder, beatmapFolder, beatmapFilename);
                        if (!File.Exists(absoluteFilename))
                        {
                            return;
                        }
                    }
                }
                return;
            }
            beatmapFindFailCounter = 0;

            // signal the editor class to load this beatmap sometime in the future
            editor.RequestBeatmapLoad(absoluteFilename);
        }