bool IsFalsePlay(string msnString, OsuStatus msnStatus, string lastMapString) { lock (_lastListened) { // if we're listening to a song AND it's not already in the first place of our Queue if (msnStatus == OsuStatus.Listening && msnString != _lastListened[0]) { //first process our last listened song "Queue" _lastListened[1] = _lastListened[0]; _lastListened[0] = msnString; } //we have to be playing for bug to occour... if (msnStatus != OsuStatus.Playing) return false; //if same string is sent 2 times in a row if (msnString == lastMapString) { //this is where it gets checked for actual bug- Map gets duplicated only when we just switched from another song //so check if we switched by checking if last listened song has changed if (_lastListened[0] != _lastListened[1]) { //to avoid marking another plays(Retrys) as False- we "break" our Queue until we change song. _lastListened[1] = _lastListened[0]; return true; } } return false; } }
public Dictionary<string, string> GetFormatedMapStrings(Dictionary<string, string> replacements, OsuStatus status) { if (_commandsPreviewSettings != null && !_commandsPreviewSettings.IsDisposed) _commandsPreviewSettings.Add(replacements); return new Dictionary<string, string>(); }
private Dictionary<string, string> GetMapFormatedStrings(Dictionary<string,string> replacements,OsuStatus status) { var ret = new Dictionary<string, string>(); foreach (var dataGetter in _mapDataParsers) { var temp = dataGetter.GetFormatedMapStrings(replacements,status); if (temp?.Count > 0) { foreach (var t in temp) { if(ret.ContainsKey(t.Key)) continue; ret.Add(t.Key,t.Value); } } } return ret; }
public Dictionary<string, string> GetFormatedMapStrings(Dictionary<string, string> replacements, OsuStatus status) { var replacementDict = replacements; var res = new Dictionary<string, string>(); if (replacementDict != null) { lock (_patternDictionary) { foreach (var pattern in _patternDictionary) { if ((pattern.SaveEvent & (int)status) == 0) res.Add(pattern.Filename, ""); else res.Add(pattern.Filename, FormatMapString(pattern.Pattern, replacementDict)); } } _mapDataParserSettings?.SetPreviewDict(replacementDict); } //res.Add("np", FormatMapString("!ArtistRoman! - !TitleRoman! [!DiffName!] !Mods!", replacementDict)); return res; }
public void FindMapData(Dictionary<string,string> mapDict, OsuStatus status) { for (int i = 0; i < _mapDataFinders.Count; i++) { if ((_mapDataFinders[i].SearchModes & status) == 0) continue; _mapSearchResult = _mapDataFinders[i].FindBeatmap(mapDict); if (_mapSearchResult.FoundBeatmaps) { _logger.Log(string.Format(">Found data using \"{0}\" ID: {1}", _mapDataFinders[i].SearcherName,_mapSearchResult.BeatmapsFound[0]?.MapId),LogLevel.Advanced); break; } } if(_mapSearchResult==null) _mapSearchResult = new MapSearchResult(); _mapSearchResult.Action = status; var mapReplacements = GetMapReplacements(_mapSearchResult); _mapSearchResult.FormatedStrings = GetMapFormatedStrings(mapReplacements,_mapSearchResult.Action); SaveMapStrings(_mapSearchResult.FormatedStrings); SetNewMap(_mapSearchResult); }
public Dictionary <string, string> GetFormatedMapStrings(Dictionary <string, string> replacements, OsuStatus status) { var replacementDict = replacements; var res = new Dictionary <string, string>(); if (replacementDict != null) { lock (_patternDictionary) { foreach (var pattern in _patternDictionary) { if ((pattern.SaveEvent & (int)status) == 0) { res.Add(pattern.Filename, ""); } else { res.Add(pattern.Filename, FormatMapString(pattern.Pattern, replacementDict)); } } } _mapDataParserSettings?.SetPreviewDict(replacementDict); } //res.Add("np", FormatMapString("!ArtistRoman! - !TitleRoman! [!DiffName!] !Mods!", replacementDict)); return(res); }
public virtual bool CanSave(OsuStatus status) => (StatusWhitelist & status) != 0;
private List <OutputPattern> GetMapPatterns(Dictionary <string, string> replacements, OsuStatus status) { var ret = new List <OutputPattern>(); foreach (var dataGetter in _mapDataParsers) { var temp = dataGetter.GetFormatedPatterns(replacements, status); if (temp?.Count > 0) { ret.AddRange(temp); } } return(ret); }
public abstract List <IOutputPattern> GetOutputPatterns(Tokens replacements, OsuStatus status);
public PPControl(OsuListenerManager mamger, int?id) { m_listener_manager = mamger; m_listener_manager.OnModsChanged += (mods) => { m_cur_mods = mods; m_pp_calculator.ClearCache(); }; m_listener_manager.OnCount300Changed += c => m_n300 = c; m_listener_manager.OnCountGekiChanged += c => m_ngeki = c; m_listener_manager.OnCountKatuChanged += c => m_nkatu = c; m_listener_manager.OnCount100Changed += c => m_n100 = c; m_listener_manager.OnCount50Changed += c => m_n50 = c; m_listener_manager.OnCountMissChanged += c => m_nmiss = c; m_listener_manager.OnScoreChanged += s => m_score = s; m_listener_manager.OnPlayModeChanged += (last, mode) => { switch (mode) { case OsuPlayMode.Osu: m_pp_calculator = new StdPPCalculator(); break; case OsuPlayMode.Taiko: m_pp_calculator = new TaikoPerformanceCalculator(); break; case OsuPlayMode.Mania: m_pp_calculator = new ManiaPerformanceCalculator(); break; default: Sync.Tools.IO.CurrentIO.WriteColor("[RealTimePPDisplayer]Unsupported Mode", ConsoleColor.Red); m_pp_calculator = null; break; } m_mode = mode; }; m_listener_manager.OnStatusChanged += (last, cur) => { m_status = cur; if (cur == OsuStatus.Listening || cur == OsuStatus.Editing)//Clear Output { m_combo = 0; m_max_combo = 0; m_n100 = 0; m_n50 = 0; m_nmiss = 0; foreach (var p in m_displayers) { p.Value.Clear(); } } }; m_listener_manager.OnComboChanged += (combo) => { if (m_status != OsuStatus.Playing) { return; } if (combo <= ((m_pp_calculator as OppaiPerformanceCalculator)?.Oppai.FullCombo ?? 20000)) { m_combo = combo; m_max_combo = Math.Max(m_max_combo, m_combo); } }; m_listener_manager.OnBeatmapChanged += RTPPOnBeatmapChanged; m_listener_manager.OnPlayingTimeChanged += RTPPOnPlayingTimeChanged; }
/* * protected BeatmapEntry GetCurrentBeatmap() * { * return new BeatmapEntry() * { * BeatmapId = beatmapID, * BeatmapSetId = beatmapSetID, * OsuFilePath = OsuFilePath * }; * } */ public abstract void OnStatusChange(OsuStatus last_status, OsuStatus status);
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { OsuStatus newOsuStatus = (OsuStatus)value; switch (newOsuStatus) { case OsuStatus.EditingMap: return("Editing Map"); case OsuStatus.GameShutdownAnimation: return("Shutting Down"); case OsuStatus.GameStartupAnimation: return("Starting Up"); case OsuStatus.MainMenu: return("Main Menu"); case OsuStatus.MultiplayerResultsscreen: return("MP Results"); case OsuStatus.MultiplayerRoom: return("MP Room"); case OsuStatus.MultiplayerRooms: return("MP Rooms"); case OsuStatus.MultiplayerSongSelect: return("MP Song Select"); case OsuStatus.NotRunning: return("Not Running"); case OsuStatus.OsuDirect: return("osu! Direct"); case OsuStatus.Playing: return("Playing a Map"); case OsuStatus.ProcessingBeatmaps: return("Processing Maps"); case OsuStatus.RankingTagCoop: return("Ranking Tag Co-op"); case OsuStatus.RankingTeam: return("Ranking Team"); case OsuStatus.ResultsScreen: return("Results Screen"); case OsuStatus.SongSelect: return("Song Select"); case OsuStatus.SongSelectEdit: return("Song Select Edit"); case OsuStatus.Tourney: return("Tourney"); case OsuStatus.Unknown: return("Unknown"); case OsuStatus.SongPaused: return("Paused"); case OsuStatus.InMapBreak: return("Map Break"); case OsuStatus.MapStart: return("Map Start"); default: System.Diagnostics.Debug.WriteLine($"No converter string defined for osu status {newOsuStatus.ToString()}"); return("Unknown"); } }
public void Tick(List <StructuredOsuMemoryReader> clientReaders, bool sendEvents) { var reader = clientReaders[0]; var osuData = reader.OsuMemoryAddresses; reader.Read(osuData.GeneralData); _currentStatus = osuData.GeneralData.OsuStatus; if (_lastStatusLog != _currentStatus) { _lastStatusLog = _currentStatus; //Console.WriteLine("status: {0} {1}", _currentStatus, _currentStatus == OsuMemoryStatus.Unknown ? num.ToString() : ""); } if (_currentStatus == OsuMemoryStatus.NotRunning) { return; } reader.Read(osuData.Beatmap); _currentMapId = osuData.Beatmap.Id; var isReplay = (bool?)reader.ReadProperty(osuData.Player, nameof(Player.IsReplay)); if (isReplay == null) { return; } OsuStatus status = _currentStatus.Convert(); status = status == OsuStatus.Playing && isReplay.Value ? OsuStatus.Watching : status; var gameMode = osuData.GeneralData.GameMode; var mapHash = osuData.Beatmap.Md5; var mapSelectionMods = osuData.GeneralData.Mods; var playingMods = -1; if (status == OsuStatus.Playing || status == OsuStatus.Watching) { var mods = ((Mods)reader.ReadProperty(osuData.Player, nameof(Player.Mods)))?.Value; if (mods == null) { return; } playingMods = mods.Value; } var retries = osuData.GeneralData.Retries; var currentTime = osuData.GeneralData.AudioTime; var mapHashDiffers = mapHash != null && _lastMapHash != null && _lastMapHash != mapHash; var mapIdDiffers = _lastMapId != _currentMapId; var memoryStatusDiffers = _lastStatus != _currentStatus; var gameModeDiffers = gameMode != _lastGameMode; var mapSelectionModsDiffer = mapSelectionMods != _lastMapSelectionMods; var playingModsDiffer = (status == OsuStatus.Watching || status == OsuStatus.Playing) && playingMods != _lastPlayingMods; OsuEventType?osuEventType = null; //"good enough" replay retry detection. if (isReplay.Value && _currentStatus == OsuMemoryStatus.Playing && _lastTime > currentTime && DateTime.UtcNow > _nextReplayRetryAllowedAt) { osuEventType = OsuEventType.PlayChange; _nextReplayRetryAllowedAt = DateTime.UtcNow.AddMilliseconds(500); } _lastTime = currentTime; var playInitialized = (status != OsuStatus.Watching && status != OsuStatus.Playing) || playingMods != -1; if (sendEvents && playInitialized && ( osuEventType.HasValue || mapIdDiffers || memoryStatusDiffers || mapHashDiffers || gameModeDiffers || mapSelectionModsDiffer || playingModsDiffer || retries != _lastRetries ) ) { if (!osuEventType.HasValue || playingModsDiffer) { osuEventType = mapIdDiffers || mapHashDiffers || gameModeDiffers || mapSelectionModsDiffer || playingModsDiffer ? OsuEventType.MapChange //different mapId/hash/mode/mods(changed stats) = different map : memoryStatusDiffers ? OsuEventType.SceneChange //memory scene(status) change = Scene change : _currentStatus == OsuMemoryStatus.Playing ? OsuEventType.PlayChange // map retry : OsuEventType.MapChange; //bail } _lastMapId = _currentMapId; _lastStatus = _currentStatus; _lastRetries = retries; _lastGameMode = gameMode; _lastMapSelectionMods = mapSelectionMods; _lastMapHash = mapHash; _lastPlayingMods = playingMods; var rawString = Retry.RetryMe(() => (string)reader.ReadProperty(osuData.Beatmap, nameof(CurrentBeatmap.Md5)), s => (System.Text.Encoding.UTF8.GetByteCount(s ?? string.Empty) == s?.Length), 5) ?? string.Empty; NewOsuEvent?.Invoke(this, new MemoryMapSearchArgs(osuEventType.Value) { MapId = _currentMapId, Status = status, Raw = rawString, MapHash = mapHash, PlayMode = (PlayMode)gameMode, Mods = playingMods != -1 ? playingMods : mapSelectionMods }); } for (int i = 0; i < clientReaders.Count; i++) { _memoryDataProcessors[i].Tick(status, _currentStatus, clientReaders[i]); } }
public List <OutputPattern> GetFormatedPatterns(Dictionary <string, string> replacements, OsuStatus status) { List <OutputPattern> ret = null; if (replacements != null) { ret = new List <OutputPattern>(); foreach (var p in _patterns) { var newPattern = (OutputPattern)p.Clone(); newPattern.Replacements = replacements; ret.Add(newPattern); } if (_parserSettings != null && !_parserSettings.IsDisposed) { _parserSettings.SetPreview(replacements); } } return(ret); }
public static bool IsListening(OsuStatus status) { const OsuStatus listen = OsuStatus.SelectSong | OsuStatus.MatchSetup | OsuStatus.Lobby | OsuStatus.Idle; return((listen & status) == status); }
/// <summary> /// Returns existing token instance with updated value or creates new instance if it doesn't exist /// </summary> internal static IToken SetToken(string pluginName, string tokenName, object value, TokenType type = TokenType.Normal, string format = null, object defaultValue = null, OsuStatus whitelist = OsuStatus.All) { IToken token; if (AllTokens.ContainsKey(tokenName)) { token = AllTokens[tokenName]; token.Value = value; } else { if (tokenName.Length == 0 || !char.IsLetter(tokenName[0])) { throw new Exception($"Token name must start with a letter (got: \"{tokenName}\")"); } if (tokenName.Any(char.IsWhiteSpace)) { throw new Exception($"Token name can not contain whitespace characters (got: \"{tokenName}\")"); } if (!char.IsLower(tokenName[0])) { throw new Exception($"First token letter must be lowercase (token name ideally should be camelCase) (got: \"{tokenName}\")"); } bool isLazy = false; if (value != null) { var valueType = value.GetType(); isLazy = valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Lazy <>); } token = isLazy ? new LazyToken <object>((Lazy <object>)value, type, format, defaultValue, whitelist) : new Token(value, type, format, defaultValue, whitelist); token.PluginName = pluginName; _AllTokens[tokenName] = token; if ((type & TokenType.Live) != 0) { OutputPattern.AddLiveToken(tokenName); } AllTokensChanged?.Invoke(null, tokenName); } return(token); }
public abstract List <OutputPattern> GetFormatedPatterns(Tokens replacements, OsuStatus status);
public void SetPreview(Tokens replacements, OsuStatus status) { this.patternEdit.SetPreview(replacements, status); }
public void Tick(IOsuMemoryReader reader, bool sendEvents) { _currentStatus = reader.GetCurrentStatus(out _); if (_lastStatusLog != _currentStatus) { _lastStatusLog = _currentStatus; //Console.WriteLine("status: {0} {1}", _currentStatus, _currentStatus == OsuMemoryStatus.Unknown ? num.ToString() : ""); } if (_currentStatus != OsuMemoryStatus.NotRunning) { _currentMapId = reader.GetMapId(); var isReplay = reader.IsReplay(); OsuStatus status = _currentStatus.Convert(); status = status == OsuStatus.Playing && isReplay ? OsuStatus.Watching : status; var gameMode = reader.ReadSongSelectGameMode(); var mapHash = reader.GetMapMd5Safe(); var mapSelectionMods = reader.GetMods(); var playingMods = status == OsuStatus.Playing || status == OsuStatus.Watching ? reader.GetPlayingMods() : -1; var retries = reader.GetRetrys(); var currentTime = reader.ReadPlayTime(); var mapHashDiffers = mapHash != null && _lastMapHash != null && _lastMapHash != mapHash; var mapIdDiffers = _lastMapId != _currentMapId; var memoryStatusDiffers = _lastStatus != _currentStatus; var gameModeDiffers = gameMode != _lastGameMode; var mapSelectionModsDiffer = mapSelectionMods != _lastMapSelectionMods; var playingModsDiffer = (status == OsuStatus.Watching || status == OsuStatus.Playing) && playingMods != _lastPlayingMods; OsuEventType?osuEventType = null; //"good enough" replay retry detection. if (isReplay && _currentStatus == OsuMemoryStatus.Playing && _lastTime > currentTime && DateTime.UtcNow > _nextReplayRetryAllowedAt) { osuEventType = OsuEventType.PlayChange; _nextReplayRetryAllowedAt = DateTime.UtcNow.AddMilliseconds(500); } _lastTime = currentTime; var playInitialized = (status != OsuStatus.Watching && status != OsuStatus.Playing) || playingMods != -1; if (sendEvents && playInitialized && ( osuEventType.HasValue || mapIdDiffers || memoryStatusDiffers || mapHashDiffers || gameModeDiffers || mapSelectionModsDiffer || retries != _lastRetries ) ) { if (!osuEventType.HasValue || playingModsDiffer) { osuEventType = mapIdDiffers || mapHashDiffers || gameModeDiffers || mapSelectionModsDiffer || playingModsDiffer ? OsuEventType.MapChange //different mapId/hash/mode/mods(changed stats) = different map : memoryStatusDiffers ? OsuEventType.SceneChange //memory scene(status) change = Scene change : _currentStatus == OsuMemoryStatus.Playing ? OsuEventType.PlayChange // map retry : OsuEventType.MapChange; //bail } _lastMapId = _currentMapId; _lastStatus = _currentStatus; _lastRetries = retries; _lastGameMode = gameMode; _lastMapSelectionMods = mapSelectionMods; _lastMapHash = mapHash; _lastPlayingMods = playingMods; NewOsuEvent?.Invoke(this, new MapSearchArgs("OsuMemory", osuEventType.Value) { MapId = _currentMapId, Status = status, Raw = reader.GetSongString(), MapHash = mapHash, PlayMode = (PlayMode)gameMode, }); } _memoryDataProcessor.Tick(status, reader); } }
public void Tick(OsuStatus status, OsuMemoryStatus rawStatus, StructuredOsuMemoryReader reader) { _notUpdatingTokens.WaitOne(); _notUpdatingMemoryValues.Reset(); lock (_lockingObject) { if (!ReferenceEquals(OsuMemoryData, reader.OsuMemoryAddresses)) { OsuMemoryData = reader.OsuMemoryAddresses; } if ((OsuStatus)_statusToken.Value != status) { _statusToken.Value = status; } _rawStatusToken.Value = rawStatus; int playTime = OsuMemoryData.GeneralData.AudioTime; switch (status) { case OsuStatus.Playing: case OsuStatus.Watching: if (_lastStatus != OsuStatus.Playing && _lastStatus != OsuStatus.Watching) { _newPlayStarted.Set(); Thread.Sleep(500); //Initial play delay } reader.TryRead(OsuMemoryData.KeyOverlay); reader.TryRead(OsuMemoryData.Player); if (!ReferenceEquals(_rawData.Play, OsuMemoryData.Player)) { _rawData.Play = OsuMemoryData.Player; } //TODO: support for live multiplayer leaderboard if (!ReadLeaderboard) { //Read whole leaderboard once if (reader.TryRead(OsuMemoryData.LeaderBoard)) { ReadLeaderboard = true; if (!ReferenceEquals(_rawData.LeaderBoard, OsuMemoryData.LeaderBoard)) { _rawData.LeaderBoard = OsuMemoryData.LeaderBoard; } } } else { //Throttle whole leaderboard reads - Temporary solution until multiplayer detection is implemented, this should be only done in multiplayer if (_nextLeaderBoardUpdate < DateTime.UtcNow) { reader.TryRead(OsuMemoryData.LeaderBoard); _nextLeaderBoardUpdate = DateTime.UtcNow.AddMilliseconds(_settings.Get <int>(MultiplayerLeaderBoardUpdateRate)); } else { //...then update main player data if (OsuMemoryData.LeaderBoard.HasLeaderBoard) { reader.TryRead(OsuMemoryData.LeaderBoard.MainPlayer); } } } break; case OsuStatus.ResultsScreen: ReadLeaderboard = false; reader.TryRead(OsuMemoryData.ResultsScreen); if (!ReferenceEquals(_rawData.Play, OsuMemoryData.ResultsScreen)) { _rawData.Play = OsuMemoryData.ResultsScreen; } playTime = Convert.ToInt32(_rawData.PpCalculator?.BeatmapLength ?? 0); break; default: ReadLeaderboard = false; _rawData.LeaderBoard = new LeaderBoard(); reader.TryRead(OsuMemoryData.Skin); if (_nextSongSelectionScoresUpdate < DateTime.UtcNow) { reader.TryRead(OsuMemoryData.SongSelectionScores); _nextSongSelectionScoresUpdate = DateTime.UtcNow.AddMilliseconds(_settings.Get <int>(SongSelectionScoresUpdateRate)); } _lastStatus = status; break; } _rawData.PlayTime = playTime; _liveTokens["time"].Update(); _lastStatus = status; } _notUpdatingMemoryValues.Set(); }
private Dictionary <string, string> GetMapFormatedStrings(Dictionary <string, string> replacements, OsuStatus status) { var ret = new Dictionary <string, string>(); foreach (var dataGetter in _mapDataParsers) { var temp = dataGetter.GetFormatedMapStrings(replacements, status); if (temp?.Count > 0) { foreach (var t in temp) { if (ret.ContainsKey(t.Key)) { continue; } ret.Add(t.Key, t.Value); } } } return(ret); }
public Dictionary <string, string> GetFormatedMapStrings(Dictionary <string, string> replacements, OsuStatus status) { if (_commandsPreviewSettings != null && !_commandsPreviewSettings.IsDisposed) { _commandsPreviewSettings.Add(replacements); } return(new Dictionary <string, string>()); }
private void CreateToken(string name, object value, TokenType tokenType, string format, object defaultValue, OsuStatus statusWhitelist, Func <object> updater) { _liveTokens[name] = new LiveToken(_tokenSetter(name, value, tokenType, format, defaultValue, statusWhitelist), updater); }