public IMapSearchResult FindBeatmap(IMapSearchArgs searchArgs) { if (!Started) { return(null); } if (searchArgs == null) { throw new ArgumentException(nameof(searchArgs)); } var result = new MapSearchResult(searchArgs); if (!Started || !_settings.Get <bool>(_names.EnableMemoryScanner)) { return(result); } var mods = ReadMods(searchArgs.Status); result.Mods = GetModsEx(mods); Logger?.Log($">Got mods from memory: {result.Mods.ShownMods}({mods})", LogLevel.Debug); Mods eMods = result.Mods?.Mods ?? Mods.Omod; if (Helpers.IsInvalidCombination(eMods)) { Logger?.Log("Sanity check tiggered - invalidating last result", LogLevel.Debug); result.Mods = null; } return(result); }
public Dictionary <string, string> GetMapReplacements(MapSearchResult map) { Dictionary <string, string> dict; if (map.FoundBeatmaps) { dict = map.BeatmapsFound[0].GetDict(); var osuLocation = _settings.Get <string>(_names.MainOsuDirectory); if (string.IsNullOrWhiteSpace(osuLocation)) { dict.Add("!OsuFileLocation!", ""); } else { dict.Add("!OsuFileLocation!", System.IO.Path.Combine(osuLocation, "Songs", map.BeatmapsFound[0].Dir, map.BeatmapsFound[0].OsuFileName)); } } else { dict = ((Beatmap)null).GetDict(true); dict.Add("!OsuFileLocation!", ""); } return(dict); }
public MapSearchResult FindBeatmap(MapSearchArgs searchArgs) { MapSearchResult mapSearchResult = new MapSearchResult(searchArgs); return(mapSearchResult); }
public void CreateTokens(MapSearchResult map) { Dictionary <string, object> dict; var OsuFileLocationToken = _tokenSetter("OsuFileLocation", null); if (map.FoundBeatmaps) { dict = map.BeatmapsFound[0].GetTokens(); var osuLocation = _settings.Get <string>(_names.MainOsuDirectory); var customSongsLocation = _settings.Get <string>(_names.SongsFolderLocation); if (string.IsNullOrWhiteSpace(osuLocation)) { OsuFileLocationToken.Value = null; } else { string baseDirectory = customSongsLocation == _names.SongsFolderLocation.Default <string>() ? Path.Combine(osuLocation, "Songs") : customSongsLocation; OsuFileLocationToken.Value = Path.Combine(baseDirectory, map.BeatmapsFound[0].Dir, map.BeatmapsFound[0].OsuFileName); } } else { dict = ((Beatmap)null).GetTokens(true); OsuFileLocationToken.Value = null; } foreach (var token in dict) { _tokenSetter(token.Key, token.Value); } }
public void SetNewMap(MapSearchResult map) { lock (_lockingObject) { if ((map.Action & OsuStatus.ResultsScreen) != 0) { return; } if (map.FoundBeatmaps && map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation) && (map.Action & (OsuStatus.Playing | OsuStatus.Watching)) != 0) { var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var mods = map.Mods?.WorkingMods ?? ""; _rawData.SetCurrentMap(map.BeatmapsFound[0], mods, mapLocation, (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null)); } else { _rawData.SetCurrentMap(null, "", null, PlayMode.Osu); } } }
private void SetNewMap(MapSearchResult map) { foreach (var dataGetter in _mapDataConsumers) { dataGetter.SetNewMap(map); } }
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 void SetNewMap(MapSearchResult map) { if (map.FoundBeatmaps) { var foundMap = map.BeatmapsFound[0]; var nowPlaying = string.Format("{0} - {1}", foundMap.ArtistRoman, foundMap.TitleRoman); if (map.Action == OsuStatus.Playing || map.Action == OsuStatus.Watching || map.EventSource != "Msn") { nowPlaying += string.Format(" [{0}] {1}", foundMap.DiffName, map.Mods?.ShownMods ?? ""); nowPlaying += string.Format(Environment.NewLine + "NoMod:{0:##.###} ", foundMap.StarsNomod); var mods = map.Mods?.Mods ?? Mods.Omod; var token = Tokens.AllTokens.FirstOrDefault(t => t.Key.ToLower() == "mstars").Value; if (mods != Mods.Omod && token != null) { nowPlaying += $"Modded: {token.Value:##.###}, {map.Action}"; } else { nowPlaying += $"{map.Action}"; } } _mainWindowHandle.NowPlaying = nowPlaying; } else { _mainWindowHandle.NowPlaying = "map data not found: " + map.MapSearchString; } }
public void CreateTokens(MapSearchResult map) { if (map.FoundBeatmaps) { var foundMap = map.BeatmapsFound[0]; var mods = map.Mods?.Mods ?? Mods.Omod; var c = _difficultyCalculator.ApplyMods(foundMap, mods); if ((mods & Mods.Nc) != 0) { mods -= Mods.Nc; mods |= Mods.Dt; } var bpm = Math.Abs(c["MinBpm"] - c["MaxBpm"]) < 0.95 ? c["MinBpm"].ToString("0") : string.Format("{0:0}-{1:0}", c["MinBpm"], c["MaxBpm"]); _tokenSetter("mods", map.Mods?.ShownMods); _tokenSetter("mAR", Math.Round(c["AR"], 2)); _tokenSetter("mCS", Math.Round(c["CS"], 2)); _tokenSetter("mOD", Math.Round(Math.Min(10, c["OD"]), 2)); _tokenSetter("mOD-Real", Math.Round(c["OD"], 2)); _tokenSetter("mHP", c["HP"], format: "{0:0.##}"); _tokenSetter("mStars", Math.Round(foundMap.Stars(PlayMode.Osu, mods), 2)); _tokenSetter("mBpm", bpm); _tokenSetter("mMaxBpm", c["MaxBpm"], format: "{0:0}"); _tokenSetter("mMinBpm", c["MinBpm"], format: "{0:0}"); } else { foreach (var tokenkv in Tokens.AllTokens.Where(t => t.Value.PluginName == Name)) { tokenkv.Value.Reset(); } } }
public void SetNewMap(MapSearchResult map) { lock (_lockingObject) { if ((map.Action & OsuStatus.ResultsScreen) != 0) { return; } if (map.FoundBeatmaps && map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation)) { _sliderBreaks = 0; _lastMisses = 0; _lastCombo = 0; if (map.SearchArgs.EventType == OsuEventType.MapChange) { var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var mods = map.Mods?.WorkingMods ?? ""; _rawData.SetCurrentMap(map.BeatmapsFound[0], mods, mapLocation, (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null)); } _newPlayStarted.Set(); } } }
private void CreateMapReplacements(MapSearchResult mapSearchResult) { foreach (var mapDataReplacementsGetter in _tokenSources) { mapDataReplacementsGetter.CreateTokens(mapSearchResult); } }
public MapSearchResult FindBeatmap(MapSearchArgs searchArgs) { var result = new MapSearchResult(searchArgs); IBeatmap beatmap = null; if (!string.IsNullOrEmpty(searchArgs.MapHash)) { beatmap = _sqliteControler.GetBeatmap(searchArgs.MapHash); } if (!IsValidBeatmap(beatmap) && searchArgs.MapId > 0) { beatmap = _sqliteControler.GetBeatmap(searchArgs.MapId); } if (!IsValidBeatmap(beatmap)) { if (!(string.IsNullOrEmpty(searchArgs.Artist) && string.IsNullOrEmpty(searchArgs.Title)) || !string.IsNullOrEmpty(searchArgs.Raw)) { beatmap = _sqliteControler.GetBeatmap(searchArgs.Artist, searchArgs.Title, searchArgs.Diff, searchArgs.Raw); } } if (IsValidBeatmap(beatmap)) { result.BeatmapsFound.Add(beatmap); } return(result); }
public void SetNewMap(MapSearchResult map) { var ingamePatterns = new List <string>(); foreach (var s in map.FormatedStrings) { //TODO: export ingameOverlay(showInOsu) stuff out of there var name = s.Name; if (s.ShowInOsu) { ingamePatterns.Add(name); } string valueToWrite = (s.SaveEvent & map.Action) != 0 ? s.GetFormatedPattern() : " "; if (s.ShowInOsu) { var configName = "conf-" + name; var valueName = "value-" + name; var config = $"{s.XPosition} {s.YPosition} {s.Color.R} {s.Color.G} {s.Color.B} {s.Color.A} {s.FontName.Replace(' ', '/')} {s.FontSize} {s.Aligment}"; _fileMapManager.Write(configName, config); if (!s.IsMemoryFormat) { _fileMapManager.Write(valueName, valueToWrite.Replace("\r", "")); } } if (!s.IsMemoryFormat) { _fileMapManager.Write(name, valueToWrite); } } _fileMapManager.Write("Sc-ingamePatterns", string.Join(" ", ingamePatterns) + " "); }
public MapSearchResult FindMapData(MapSearchArgs searchArgs) { MapSearchResult mapSearchResult = null; Tuple <Mods, string> foundMods = null; for (int i = 0; i < _mapDataFinders.Count; i++) { if ((_mapDataFinders[i].SearchModes & searchArgs.Status) == 0) { continue; } mapSearchResult = _mapDataFinders[i].FindBeatmap(searchArgs); if (mapSearchResult.FoundBeatmaps) { if (mapSearchResult.Mods == null && foundMods != null) { mapSearchResult.Mods = foundMods; } _logger.Log(string.Format(">Found data using \"{0}\" ID: {1}", _mapDataFinders[i].SearcherName, mapSearchResult.BeatmapsFound[0]?.MapId), LogLevel.Advanced); break; } if (mapSearchResult.Mods != null) { foundMods = mapSearchResult.Mods; } } if (mapSearchResult == null) { mapSearchResult = new MapSearchResult(); } mapSearchResult.Action = searchArgs.Status; return(mapSearchResult); }
private async Task <IMapSearchResult> FindBeatmaps(IMapSearchArgs mapSearchArgs, CancellationToken token) { if (mapSearchArgs.MapId == 0 && string.IsNullOrEmpty(mapSearchArgs.MapHash) && string.IsNullOrEmpty(mapSearchArgs.Raw)) { //TODO: TEST return(null); } if (mapSearchArgs.EventType == OsuEventType.MapChange || _workerState.LastMapSearchResult == null || !_workerState.LastMapSearchResult.BeatmapsFound.Any()) { _logger.SetContextData("SearchingForBeatmaps", "1"); _workerState.LastMapSearchResult = await _mainMapDataGetter.FindMapData(mapSearchArgs, token); _logger.SetContextData("SearchingForBeatmaps", "0"); return(_workerState.LastMapSearchResult); } var searchResult = new MapSearchResult(mapSearchArgs) { Mods = _workerState.LastMapSearchResult.Mods }; searchResult.BeatmapsFound.AddRange(_workerState.LastMapSearchResult.BeatmapsFound); return(searchResult); }
private string GetMapAction(MapSearchResult map) { var act = map.Action; if (act == OsuStatus.Playing) { return("Playing"); } if (act == OsuStatus.Watching) { return("Watching"); } if (act == OsuStatus.Listening) { return("Listening"); } if (act == OsuStatus.Editing) { return("Editing"); } if (act == OsuStatus.Null) { return("NoAction"); } return("NoAction"); }
public MapSearchResult FindBeatmap(MapSearchArgs searchArgs) { MapSearchResult mapSearchResult = new MapSearchResult(); mapSearchResult.MapSearchString = searchArgs.Raw; return(mapSearchResult); }
public void CreateTokens(MapSearchResult map) { for (int i = 0; i < _keyList.Count; i++) { _tokenSetter(getTokenName(_filenames[_keyList[i]]), _keyCount[_keyList[i]], TokenType.Live); } _tokenSetter(getTokenName("m1.txt"), _rightMouseCount, TokenType.Live); _tokenSetter(getTokenName("m2.txt"), _leftMouseCount, TokenType.Live); }
public MapSearchResult FindBeatmap(Dictionary <string, string> mapDictionary) { MapSearchResult mapSearchResult = new MapSearchResult(); mapSearchResult.MapSearchString = mapDictionary["raw"]; return(mapSearchResult); }
public void CreateTokens(MapSearchResult mapSearchResult) { Mods = mapSearchResult.Mods?.Mods ?? Mods.Omod; if (mapSearchResult.FoundBeatmaps && mapSearchResult.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation)) { _strainsToken.Value = GetStrains(mapLocation, mapSearchResult.PlayMode).Strains; } SetSkinTokens(); }
public void CreateTokens(MapSearchResult map) { for (int i = 0; i < _keyList.Count; i++) { _tokenSetter($"{_filenames[_keyList[i]]}", _keyCount[_keyList[i]]); } _tokenSetter("M1", _rightMouseCount); _tokenSetter("M2", _leftMouseCount); }
public void CreateTokens(MapSearchResult map) { for (int i = 0; i < _keyList.Count; i++) { _tokenSetter($"key-{RemoveWhitespace(_filenames[_keyList[i]].ToLowerInvariant())}", _keyCount[_keyList[i]]); } _tokenSetter("m1", _rightMouseCount); _tokenSetter("m2", _leftMouseCount); }
public void SetNewMap(MapSearchResult map) { try { _pauseProcessTracking = (map.Action & (OsuStatus.Playing | OsuStatus.Watching)) != 0; } catch { // ignored } }
public void SetNewMap(MapSearchResult map) { try { _pauseProcessTracking = map.Action == OsuStatus.Playing; } catch { // ignored } }
private string FormatRequest(MapSearchResult map, bool isOnline) { var output = "key=" + _userKey; output += "&isOnline=" + (isOnline ? "true" : "false"); output += "&mapName=" + Uri.EscapeDataString((GetMapName(map))); output += "&mapID=" + GetMapId(map); output += "&mapSetID=" + GetMapSetId(map); output += "&userAction=" + GetMapAction(map); return(output); }
private string GetMapName(MapSearchResult map) { if (!string.IsNullOrWhiteSpace(map.MapSearchString)) { return(map.MapSearchString); } else { return("NoMap"); } }
public async void SetNewMap(MapSearchResult mapSearchResult) { _cts.Cancel(); _cts = new CancellationTokenSource(); var token = _cts.Token; await Task.Run(() => { ProcessNewMap(mapSearchResult, token); }); }
public Dictionary <string, string> GetMapReplacements(MapSearchResult map) { var ret = new Dictionary <string, string>(); for (int i = 0; i < _keyList.Count; i++) { ret[$"!{_filenames[_keyList[i]]}!"] = _keyCount[_keyList[i]].ToString(); } ret["!M1!"] = _rightMouseCount.ToString(); ret["!M2!"] = _leftMouseCount.ToString(); return(ret); }
public MapSearchResult FindBeatmap(Dictionary <string, string> mapDictionary) { var result = new MapSearchResult(); var b = _sqliteControler.GetBeatmap(mapDictionary["artist"], mapDictionary["title"], mapDictionary["diff"], mapDictionary["raw"]); if (b?.MapId > -1 && !(string.IsNullOrWhiteSpace(b.ArtistRoman) || string.IsNullOrWhiteSpace(b.TitleRoman))) { result.BeatmapsFound.Add(b); } result.MapSearchString = mapDictionary["raw"]; return(result); }
public async void SetNewMap(MapSearchResult mapSearchResult) { CancelNewMapProcessing(); try { await Task.Run(() => ProcessNewMap(mapSearchResult, _token), _token); } catch (TaskCanceledException) { } }
private static MapSearchResult CreateMapSearchResult(MapSearchResultVM mapSearchResultVM, int mapRequestId) { MapSearchResult mapSearchResult = new MapSearchResult(); mapSearchResult.City = mapSearchResultVM.City; mapSearchResult.Country = mapSearchResultVM.Country; mapSearchResult.DateCreate = DateTime.Now; mapSearchResult.HouseNumber = mapSearchResultVM.HouseNumber; mapSearchResult.MapRequestId = mapRequestId; mapSearchResult.PostCode = mapSearchResultVM.PostCode; mapSearchResult.ResultCode = mapSearchResultVM.ResultCode; using (MediatelModel context = new MediatelModel()) { context.MapSearchResults.Add(mapSearchResult); context.SaveChanges(); } return mapSearchResult; }
public MapSearchResult GetMapSearchResult(string xml) { XmlDocument aXmlDocument = new XmlDocument(); aXmlDocument.LoadXml(xml); XmlNodeList aDataInfoXmlNodeList = aXmlDocument.GetElementsByTagName(MapSearchResult.DataInfoElementName); MapSearchResult aSearchResult = new MapSearchResult(); if (aDataInfoXmlNodeList == null || aDataInfoXmlNodeList.Count == 0) { return null; } XmlNode aDataNode = aDataInfoXmlNodeList[0]; aSearchResult.AllResultCount = Convert.ToInt32(aDataNode.Attributes[MapSearchResult.DataInfoAttributeName_AllCount].Value); aSearchResult.PageNum = Convert.ToInt32(aDataNode.Attributes[MapSearchResult.DataInfoAttributeName_PageNum].Value); aSearchResult.CurrentResultCount = Convert.ToInt32(aDataNode.Attributes[MapSearchResult.DataInfoAttributeName_CurrentCount ].Value); List<MapSearchResultItem> ltResultItem = new List<MapSearchResultItem>(); string strLatLon = string.Empty; string name = string.Empty; string highName = string.Empty; string address = string.Empty; string phone = string.Empty; string type = string.Empty; foreach (XmlNode anItemNode in aDataNode.ChildNodes) { foreach (XmlNode anChildNode in anItemNode.ChildNodes) { switch (anChildNode.Name) { case MapSearchResultItem.ChildElementName.StrLatLon: strLatLon = anChildNode.InnerText; break; case MapSearchResultItem.ChildElementName.Name: name = anChildNode.InnerText; break; case MapSearchResultItem.ChildElementName.HighName: highName = anChildNode.InnerText; break; case MapSearchResultItem.ChildElementName.Type: type = anChildNode.InnerText; break; case MapSearchResultItem.ChildElementName.Address: address = anChildNode.InnerText; break; case MapSearchResultItem.ChildElementName.Phone: phone = anChildNode.InnerText; break; } } ltResultItem.Add(new MapSearchResultItem(strLatLon, name, highName, address, phone, type)); } if (ltResultItem.Count == 0) { return null; } aSearchResult.Items = ltResultItem; return aSearchResult; }
public IList<LocationInfo> GetGeocodingList(string xml) { XmlDocument aXmlDocument = new XmlDocument(); aXmlDocument.LoadXml(xml); XmlNodeList aDataInfoXmlNodeList = aXmlDocument.GetElementsByTagName(LocationInfo.DataInfoElementName); MapSearchResult aSearchResult = new MapSearchResult(); if (aDataInfoXmlNodeList == null || aDataInfoXmlNodeList.Count == 0) { return null; } IList<LocationInfo> ltLocationInfo = new List<LocationInfo>(); string province = string.Empty; string city = string.Empty; string dist = string.Empty; string area = string.Empty; string road = string.Empty; string point = string.Empty; string roadDirection = string.Empty; string roadLevel = string.Empty; foreach (XmlNode anItemNode in aDataInfoXmlNodeList) { foreach (XmlNode anChildNode in anItemNode.ChildNodes) { switch (anChildNode.Name) { case LocationInfo.ChildElementName.Province: province = anChildNode.InnerText; break; case LocationInfo.ChildElementName.City: city = anChildNode.InnerText; break; case LocationInfo.ChildElementName.Dist: dist = anChildNode.InnerText; break; case LocationInfo.ChildElementName.Area: area = anChildNode.InnerText; break; case LocationInfo.ChildElementName.Road: { road = anChildNode.ChildNodes[0].InnerText; roadDirection = anChildNode.ChildNodes[1].InnerText; roadLevel = anChildNode.ChildNodes[3].InnerText; break; } case LocationInfo.ChildElementName.Poi: point = anChildNode.InnerText; break; } } ltLocationInfo.Add(new LocationInfo(province, city, dist, area, point, road,roadDirection,roadLevel)); } return ltLocationInfo; }