public HitsoundElement( string mapFolderName, string[] mapWaveFiles, GameMode gameMode, double offset, int track, TimingSamplesetType lineSample, HitsoundType hitsound, ObjectSamplesetType sample, ObjectSamplesetType addition, string customFile, float volume, float balance) { _mapFolderName = mapFolderName; _mapWaveFiles = mapWaveFiles; GameMode = gameMode; Offset = offset; Track = track; LineSample = lineSample; Hitsound = hitsound; Sample = sample; Addition = addition; CustomFile = customFile; Volume = volume; Balance = balance; SetNamesWithoutTrack(); SetFullPath(); }
public static string ToHitsoundString(this ObjectSamplesetType type, string sample) { switch (type) { case ObjectSamplesetType.Soft: return("soft"); case ObjectSamplesetType.Drum: return("drum"); case ObjectSamplesetType.Normal: return("normal"); case ObjectSamplesetType.Auto: return(sample); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
private IEnumerable <(string, HitsoundType)> AnalyzeHitsoundFiles( HitsoundType itemHitsound, ObjectSamplesetType itemSample, ObjectSamplesetType itemAddition, TimingPoint timingPoint, RawHitObject hitObject, HashSet <string> waves) { if (!string.IsNullOrEmpty(hitObject.FileName)) { return(new[] { ValueTuple.Create( _cache.GetFileUntilFind(_sourceFolder, Path.GetFileNameWithoutExtension(hitObject.FileName)), itemHitsound ) }); } var tuples = new List <(string, HitsoundType)>(); // hitnormal, sliderslide var sampleStr = itemSample != ObjectSamplesetType.Auto ? itemSample.ToHitsoundString(null) : timingPoint.TimingSampleset.ToHitsoundString(); // hitclap, hitfinish, hitwhistle, slidertick, sliderwhistle string additionStr = itemAddition.ToHitsoundString(sampleStr); if (hitObject.ObjectType == HitObjectType.Slider && hitObject.SliderInfo.EdgeHitsounds == null) { var hitsounds = GetHitsounds(itemHitsound, sampleStr, additionStr); tuples.AddRange(hitsounds); } else { var hitsounds = GetHitsounds(itemHitsound, sampleStr, additionStr); tuples.AddRange(_osuFile.General.Mode == GameMode.Mania ? hitsounds.Take(1) : hitsounds); } for (var i = 0; i < tuples.Count; i++) { var fileNameWithoutIndex = tuples[i].Item1; var hitsoundType = tuples[i].Item2; int baseIndex = hitObject.CustomIndex > 0 ? hitObject.CustomIndex : timingPoint.Track; string indexStr = baseIndex > 1 ? baseIndex.ToString() : ""; var fileNameWithoutExt = fileNameWithoutIndex + indexStr; string filePath; if (timingPoint.Track == 0) { filePath = Path.Combine(Domain.DefaultPath, fileNameWithoutExt + Information.WavExtension); } else if (waves.Contains(fileNameWithoutExt)) { filePath = _cache.GetFileUntilFind(_sourceFolder, fileNameWithoutExt); } else { filePath = Path.Combine(Domain.DefaultPath, fileNameWithoutIndex + Information.WavExtension); } tuples[i] = (filePath, hitsoundType); } return(tuples); }
private void ToSlider(RawHitObject hitObject, string others) { var infos = others.SpanSplit(","); // extra string notSureExtra = infos[infos.Length - 1]; bool supportExtra = notSureExtra.IndexOf(":", StringComparison.Ordinal) != -1; hitObject.Extras = supportExtra ? notSureExtra : null; // slider curve var curveInfo = infos[0].SpanSplit("|"); var sliderType = infos[0].Split('|')[0]; var points = new Vector2 <float> [curveInfo.Length - 1]; // curvePoints skip 1 for (var i = 1; i < curveInfo.Length; i++) { var point = curveInfo[i]; var xy = point.SpanSplit(":"); points[i - 1] = new Vector2 <float>(int.Parse(xy[0]), int.Parse(xy[1])); } // repeat int repeat = int.Parse(infos[1]); // length decimal pixelLength = decimal.Parse(infos[2]); // edge hitsounds HitsoundType[] edgeHitsounds; ObjectSamplesetType[] edgeSamples; ObjectSamplesetType[] edgeAdditions; if (infos.Length == 3) { edgeHitsounds = null; edgeSamples = null; edgeAdditions = null; } else if (infos.Length == 4) { edgeHitsounds = infos[3].SpanSplit("|").Select(t => t.ParseToEnum <HitsoundType>()).ToArray(); edgeSamples = null; edgeAdditions = null; } else { edgeHitsounds = infos[3].SpanSplit("|").Select(t => t.ParseToEnum <HitsoundType>()).ToArray(); string[] edgeAdditionsStrArr = infos[4].SpanSplit("|"); edgeSamples = new ObjectSamplesetType[repeat + 1]; edgeAdditions = new ObjectSamplesetType[repeat + 1]; for (int i = 0; i < edgeAdditionsStrArr.Length; i++) { var sampAdd = edgeAdditionsStrArr[i].SpanSplit(":"); edgeSamples[i] = sampAdd[0].ParseToEnum <ObjectSamplesetType>(); edgeAdditions[i] = sampAdd[1].ParseToEnum <ObjectSamplesetType>(); } } TimingPoint[] lastRedLinesIfExsist = _timingPoints.TimingList.Where(t => !t.Inherit) .Where(t => t.Offset <= hitObject.Offset).ToArray(); TimingPoint lastRedLine; // hitobjects before lines is allowed if (lastRedLinesIfExsist.Length == 0) { lastRedLine = _timingPoints.TimingList.First(t => !t.Inherit); } else { double lastRedLineOffset = lastRedLinesIfExsist.Max(t => t.Offset); //duplicate red lines, select the last one lastRedLine = _timingPoints.TimingList.Last(t => t.Offset == lastRedLineOffset && !t.Inherit); } TimingPoint[] lastLinesIfExist = _timingPoints.TimingList.Where(t => t.Offset <= hitObject.Offset).ToArray(); TimingPoint[] lastLines; // 1 red + 1 green is allowed TimingPoint lastLine; // hitobjects before lines is allowed if (lastLinesIfExist.Length == 0) { lastLines = new[] { _timingPoints.TimingList.First(t => !t.Inherit) } } ; //red line multiple default 1.0 else { double lastLineOffset = lastLinesIfExist.Max(t => t.Offset); // 1 red + 1 green is allowed, so maybe here are two results lastLines = _timingPoints.TimingList.Where(t => t.Offset == lastLineOffset).ToArray(); } if (lastLines.Length > 1) { lastLine = lastLines.LastOrDefault(k => k.Inherit) ?? lastLines.Last(k => !k.Inherit); //if (lastLines.Length == 2) //{ // if (lastLines[0].Inherit != lastLines[1].Inherit) // { // lastLine = lastLines.First(t => t.Inherit); // } // else // throw new RepeatTimingSectionException("存在同一时刻两条相同类型的Timing Section。"); //} //else // throw new RepeatTimingSectionException("存在同一时刻多条Timing Section。"); } else { lastLine = lastLines[0]; } hitObject.SliderInfo = new SliderInfo(new Vector2 <float>(hitObject.X, hitObject.Y), hitObject.Offset, lastRedLine.Factor, _difficulty.SliderMultiplier * lastLine.Multiple, _difficulty.SliderTickRate, pixelLength) { CurvePoints = points, EdgeAdditions = edgeAdditions, EdgeHitsounds = edgeHitsounds, EdgeSamples = edgeSamples, Repeat = repeat, SliderType = sliderType.ParseToEnum <SliderType>() }; }