protected override void playRebound(int lastJudgedEndpoint) { if (lastJudgedEndpoint == RepeatCount) { base.playRebound(lastJudgedEndpoint); } else { SampleSetInfo ss = SampleSets != null ? SampleSets[lastJudgedEndpoint] : SampleSet; PlaySound(SoundTypeList != null ? SoundTypeList[lastJudgedEndpoint] : SoundType, ss); } }
protected override void playRebound() { if (lastJudgedEndpoint == RepeatCount) { base.playRebound(); } else { SampleSetInfo ss = SampleSets?[lastJudgedEndpoint] ?? SampleSet; PlaySound(SoundTypeList?[lastJudgedEndpoint] ?? SoundType, ss); } }
internal override void PlaySound(HitObjectSoundType type, SampleSetInfo ssi) { float volume = ssi.Volume * (0.5f + 0.5f * circularProgress.Progress); if ((type & HitObjectSoundType.Finish) > 0) { AudioEngine.PlaySample(OsuSamples.HitFinish, ssi.AdditionSampleSet, volume); } if ((type & HitObjectSoundType.Whistle) > 0) { AudioEngine.PlaySample(OsuSamples.HitWhistle, ssi.AdditionSampleSet, volume); } if ((type & HitObjectSoundType.Clap) > 0) { AudioEngine.PlaySample(OsuSamples.HitClap, ssi.AdditionSampleSet, volume); } AudioEngine.PlaySample(OsuSamples.HitNormal, ssi.SampleSet, volume); }
public void LoadFile() { spriteManager.ForwardPlayOptimisedAdd = true; beatmap.ControlPoints.Clear(); FileSection currentSection = FileSection.Unknown; //Check file just before load -- ensures no modifications have occurred. //BeatmapManager.Current.UpdateChecksum(); List <string> readableFiles = new List <string>(); readableFiles.Add(beatmap.BeatmapFilename); string storyBoardFile = beatmap.StoryboardFilename; //if (beatmap.CheckFileExists(storyBoardFile)) // readableFiles.Add(storyBoardFile); //bool hasCustomColours = false; //bool firstColour = true; bool hitObjectPreInit = false; bool lastAddedSpinner = false; //bool verticalFlip = (GameBase.Mode == OsuModes.Play && Player.currentScore != null && // ModManager.CheckActive(Player.currentScore.enabledMods, Mods.HardRock)); int linenumber; //The first file will be the actual .osu file. //The second file is the .osb for now. for (int fn = 0; fn < readableFiles.Count; fn++) { if (fn > 0) { break; //don't handle storyboarding yet. //baseReader = new StreamReader(BeatmapManager.Current.GetFileStream(readableFiles[fn])); //LocatedTextReaderWrapper ltr = new LocatedTextReaderWrapper(baseReader); //osqEngine = new osq.Encoder(ltr); } //using (TextReader reader = (fn == 0 ? (TextReader)new StreamReader(BeatmapManager.Current.GetFileStream(readableFiles[fn])) : new StringReader(osqEngine.Encode()))) TextReader reader = new StreamReader(beatmap.GetFileStream(readableFiles[fn])); { linenumber = 0; string line = null; bool readNew = true; int objnumber = 0; bool headerReadFinished = false; while (true) { if (readNew) { line = reader.ReadLine(); if (line == null) { break; } linenumber++; } readNew = true; if (line.Length == 0 || line.StartsWith(" ") || line.StartsWith("_") || line.StartsWith("//")) { continue; } //if (currentSection == FileSection.Events) ParseVariables(ref line); string key = string.Empty; string val = string.Empty; if (!headerReadFinished) { string[] var = line.Split(':'); if (var.Length > 1) { key = var[0].Trim(); val = var[1].Trim(); } } if (line[0] == '[') { try { currentSection = (FileSection)Enum.Parse(typeof(FileSection), line.Trim('[', ']')); if (currentSection == FileSection.HitObjects) { headerReadFinished = true; } } catch (Exception) { } continue; } switch (currentSection) { case FileSection.ScoringMultipliers: if (key == "HP") { beatmap.HpStreamAdjustmentMultiplier = double.Parse(val, GameBase.nfi); } else { Difficulty diff = (Difficulty)int.Parse(key); beatmap.DifficultyInfo[diff] = new BeatmapDifficultyInfo(diff) { ComboMultiplier = double.Parse(val, GameBase.nfi) }; } break; case FileSection.General: switch (key) { case "CountdownOffset": if (val.Length > 0) { beatmap.CountdownOffset = int.Parse(val); } break; } break; case FileSection.TimingPoints: { string[] split = line.Split(','); if (split.Length > 2) { beatmap.ControlPoints.Add( new ControlPoint(double.Parse(split[0], GameBase.nfi), double.Parse(split[1], GameBase.nfi), split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]), (SampleSet)int.Parse(split[3]), split.Length > 4 ? (CustomSampleSet)int.Parse(split[4]) : CustomSampleSet.Default, int.Parse(split[5]), split.Length > 6 ? split[6][0] == '1' : true, split.Length > 7 ? split[7][0] == '1' : false)); } break; } case FileSection.Editor: switch (key) { case "Bookmarks": if (val.Length > 0) { beatmap.StreamSwitchPoints = new List <int>(); string[] points = val.Split(','); foreach (string point in points) { beatmap.StreamSwitchPoints.Add(int.Parse(point.Trim())); } } break; } //not relevant continue; case FileSection.Difficulty: switch (key) { case "HPDrainRate": beatmap.DifficultyHpDrainRate = Math.Min((byte)10, Math.Max((byte)0, byte.Parse(val))); break; case "CircleSize": beatmap.DifficultyCircleSize = Math.Min((byte)10, Math.Max((byte)0, byte.Parse(val))); break; case "OverallDifficulty": beatmap.DifficultyOverall = Math.Min((byte)10, Math.Max((byte)0, byte.Parse(val))); //if (!hasApproachRate) DifficultyApproachRate = DifficultyOverall; break; case "SliderMultiplier": beatmap.DifficultySliderMultiplier = Math.Max(0.4, Math.Min(3.6, double.Parse(val, GameBase.nfi))); break; case "SliderTickRate": beatmap.DifficultySliderTickRate = Math.Max(0.5, Math.Min(8, double.Parse(val, GameBase.nfi))); break; /*case "ApproachRate": * beatmap.DifficultyApproachRate = Math.Min((byte)10, Math.Max((byte)0, byte.Parse(val))); * hasApproachRate = true; * break;*/ } break; case FileSection.HitObjects: { if (fn > 0) { continue; } if (!hitObjectPreInit) { //ComboColoursReset(); hitObjectPreInit = true; } string[] split = line.Split(','); int offset = 0; Difficulty difficulty = (Difficulty)int.Parse(split[offset++]); SampleSetInfo ssi = parseSampleSet(split[offset++]); int x = (int)Math.Max(0, Math.Min(512, decimal.Parse(split[offset++], GameBase.nfi))); int y = (int)Math.Max(0, Math.Min(512, decimal.Parse(split[offset++], GameBase.nfi))); int time = (int)decimal.Parse(split[offset++], GameBase.nfi); if (objnumber == 0) { CountdownTime = time; } else { CountdownTime = Math.Min(CountdownTime, time); } objnumber++; if (!shouldLoadDifficulty(difficulty)) { continue; } HitObjectType type = (HitObjectType)int.Parse(split[offset], GameBase.nfi) & ~HitObjectType.ColourHax; int comboOffset = (Convert.ToInt32(split[offset++], GameBase.nfi) >> 4) & 7; // mask out bits 5-7 for combo offset. HitObjectSoundType soundType = (HitObjectSoundType)int.Parse(split[offset++], GameBase.nfi); Vector2 pos = new Vector2(x, y); bool newCombo = (type & HitObjectType.NewCombo) > 0 || lastAddedSpinner || StreamHitObjects[(int)difficulty] == null || StreamHitObjects[(int)difficulty].Count == 0; HitObject h = null; //used for new combo forcing after a spinner. lastAddedSpinner = h is Spinner; if ((type & HitObjectType.Circle) > 0) { h = hitFactory.CreateHitCircle(pos, time, newCombo, soundType, newCombo ? comboOffset : 0); } else if ((type & (HitObjectType.Slider | HitObjectType.Hold)) > 0) { CurveTypes curveType = CurveTypes.Bezier; int repeatCount = 0; double length = 0; List <Vector2> points = new List <Vector2>(); List <HitObjectSoundType> sounds = null; string[] pointsplit = split[offset++].Split('|'); for (int i = 0; i < pointsplit.Length; i++) { if (pointsplit[i].Length == 1) { switch (pointsplit[i]) { case "C": curveType = CurveTypes.Catmull; break; case "B": curveType = CurveTypes.Bezier; break; case "L": curveType = CurveTypes.Linear; break; case "P": curveType = CurveTypes.PerfectCurve; break; } continue; } string[] temp = pointsplit[i].Split(':'); Vector2 v = new Vector2((float)Convert.ToDouble(temp[0], GameBase.nfi), (float)Convert.ToDouble(temp[1], GameBase.nfi)); points.Add(v); } repeatCount = Convert.ToInt32(split[offset++], GameBase.nfi); length = Convert.ToDouble(split[offset++], GameBase.nfi); List <SampleSetInfo> listSampleSets = null; //Per-endpoint Sample Additions if (split[offset].Length > 0) { string[] adds = split[offset++].Split('|'); if (adds.Length > 0) { sounds = new List <HitObjectSoundType>(adds.Length); for (int i = 0; i < adds.Length; i++) { int sound; int.TryParse(adds[i], out sound); sounds.Add((HitObjectSoundType)sound); } } } else { offset += 1; } if (split.Length > 13) { string[] samplesets = split[13].Split(':'); listSampleSets = new List <SampleSetInfo>(samplesets.Length); for (int i = 0; i < samplesets.Length; i++) { SampleSetInfo node_ssi = parseSampleSet(samplesets[i]); listSampleSets.Add(node_ssi); } } if ((repeatCount > 1 && length < 50) || (repeatCount > 4 && length < 100) || (type & HitObjectType.Hold) > 0) { h = hitFactory.CreateHoldCircle(pos, time, newCombo, soundType, repeatCount, length, sounds, newCombo ? comboOffset : 0, Convert.ToDouble(split[offset++], GameBase.nfi), Convert.ToDouble(split[offset++], GameBase.nfi), listSampleSets); } else { h = hitFactory.CreateSlider(pos, time, newCombo, soundType, curveType, repeatCount, length, points, sounds, newCombo ? comboOffset : 0, Convert.ToDouble(split[offset++], GameBase.nfi), Convert.ToDouble(split[offset++], GameBase.nfi), listSampleSets); } } else if ((type & HitObjectType.Spinner) > 0) { h = hitFactory.CreateSpinner(time, Convert.ToInt32(split[offset++], GameBase.nfi), soundType); } //Make sure we have a valid hitObject and actually add it to this manager. if (h != null) { h.SampleSet = ssi; Add(h, difficulty); } } break; case FileSection.Unknown: continue; //todo: readd this? not sure if we need it anymore. } } } } PostProcessing(); }