コード例 #1
0
 /// <summary>
 ///     Returns true if the two maps are equal by value.
 /// </summary>
 /// <param name="other">the Qua to compare to</param>
 /// <returns></returns>
 public bool EqualByValue(Qua other)
 {
     return(AudioFile == other.AudioFile &&
            SongPreviewTime == other.SongPreviewTime &&
            BackgroundFile == other.BackgroundFile &&
            BannerFile == other.BannerFile &&
            MapId == other.MapId &&
            MapSetId == other.MapSetId &&
            Mode == other.Mode &&
            Title == other.Title &&
            Artist == other.Artist &&
            Source == other.Source &&
            Tags == other.Tags &&
            Creator == other.Creator &&
            DifficultyName == other.DifficultyName &&
            Description == other.Description &&
            Genre == other.Genre &&
            TimingPoints.SequenceEqual(other.TimingPoints, TimingPointInfo.ByValueComparer) &&
            SliderVelocities.SequenceEqual(other.SliderVelocities, SliderVelocityInfo.ByValueComparer)
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            && InitialScrollVelocity == other.InitialScrollVelocity &&
            BPMDoesNotAffectScrollVelocity == other.BPMDoesNotAffectScrollVelocity &&
            HasScratchKey == other.HasScratchKey &&
            HitObjects.SequenceEqual(other.HitObjects, HitObjectInfo.ByValueComparer) &&
            CustomAudioSamples.SequenceEqual(other.CustomAudioSamples, CustomAudioSampleInfo.ByValueComparer) &&
            SoundEffects.SequenceEqual(other.SoundEffects, SoundEffectInfo.ByValueComparer) &&
            EditorLayers.SequenceEqual(other.EditorLayers, EditorLayerInfo.ByValueComparer) &&
            RandomizeModifierSeed == other.RandomizeModifierSeed);
 }
コード例 #2
0
 /// <summary>
 ///     Returns true if the two maps are equal by value.
 /// </summary>
 /// <param name="other">the Qua to compare to</param>
 /// <returns></returns>
 public bool EqualByValue(Qua other)
 {
     return(AudioFile == other.AudioFile &&
            SongPreviewTime == other.SongPreviewTime &&
            BackgroundFile == other.BackgroundFile &&
            BannerFile == other.BannerFile &&
            MapId == other.MapId &&
            MapSetId == other.MapSetId &&
            Mode == other.Mode &&
            Title == other.Title &&
            Artist == other.Artist &&
            Source == other.Source &&
            Tags == other.Tags &&
            Creator == other.Creator &&
            DifficultyName == other.DifficultyName &&
            Description == other.Description &&
            Genre == other.Genre &&
            TimingPoints.SequenceEqual(other.TimingPoints, TimingPointInfo.ByValueComparer) &&
            SliderVelocities.SequenceEqual(other.SliderVelocities, SliderVelocityInfo.ByValueComparer) &&
            HitObjects.SequenceEqual(other.HitObjects, HitObjectInfo.ByValueComparer) &&
            CustomAudioSamples.SequenceEqual(other.CustomAudioSamples, CustomAudioSampleInfo.ByValueComparer) &&
            SoundEffects.SequenceEqual(other.SoundEffects, SoundEffectInfo.ByValueComparer) &&
            EditorLayers.SequenceEqual(other.EditorLayers, EditorLayerInfo.ByValueComparer) &&
            RandomizeModifierSeed == other.RandomizeModifierSeed);
 }
コード例 #3
0
        public static Qua Parse(string filePath)
        {
            var parsedMap = new Qua();

            string[] lines = File.ReadAllLines(filePath);

            bool isHitobjects = false;

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                string[] lineSplit = line.Split(new char[] { ':' }, 2);
                string   variable  = lineSplit[0].Trim().TrimStart(new char[] { '-' }).Trim();
                string   value     = lineSplit[1].Trim();

                if (variable == "HitObjects")
                {
                    isHitobjects = true;
                }

                switch (variable)
                {
                case "Mode":
                    parsedMap.Mode = (GameMode)Enum.Parse(typeof(GameMode), value);
                    break;

                case "Title":
                    parsedMap.Title = value;
                    break;

                case "Artist":
                    parsedMap.Artist = value;
                    break;

                case "Creator":
                    parsedMap.Creator = value;
                    break;

                case "DifficultyName":
                    parsedMap.DifficultyName = value;
                    break;

                case "StartTime" when isHitobjects:
                    var ho = new HitObject();
                    ho.StartTime = int.Parse(value);
                    ho.Lane      = int.Parse(lines[++i].Split(new char[] { ':' }, 2)[1].Trim());
                    if (i + 1 < lines.Length && lines[i + 1].Contains("EndTime"))
                    {
                        ho.EndTime = int.Parse(lines[++i].Split(new char[] { ':' }, 2)[1].Trim());
                    }

                    parsedMap.HitObjects.Add(ho);
                    break;
                }
            }

            return(parsedMap);
        }
コード例 #4
0
ファイル: Qua.cs プロジェクト: Discookie/Quaver.API
        /// <summary>
        /// </summary>
        /// <param name="qua"></param>
        /// <param name="checkValidity"></param>
        /// <exception cref="ArgumentException"></exception>
        private static void AfterLoad(Qua qua, bool checkValidity)
        {
            if (checkValidity && !qua.IsValid())
            {
                throw new ArgumentException("The .qua file is invalid. It does not have HitObjects, TimingPoints, its Mode is invalid or some hit objects are invalid.");
            }

            // Try to sort the Qua before returning.
            qua.Sort();
        }
コード例 #5
0
ファイル: Qua.cs プロジェクト: Discookie/Quaver.API
        /// <summary>
        /// </summary>
        /// <param name="qua"></param>
        private static void RestoreDefaultValues(Qua qua)
        {
            // Restore default values.
            for (var i = 0; i < qua.TimingPoints.Count; i++)
            {
                var tp = qua.TimingPoints[i];
                if (tp.Signature == 0)
                {
                    tp.Signature = TimeSignature.Quadruple;
                }
                qua.TimingPoints[i] = tp;
            }

            for (var i = 0; i < qua.HitObjects.Count; i++)
            {
                var obj = qua.HitObjects[i];

                if (obj.HitSound == 0)
                {
                    obj.HitSound = HitSounds.Normal;
                }

                foreach (var keySound in obj.KeySounds)
                {
                    if (keySound.Volume == 0)
                    {
                        keySound.Volume = 100;
                    }
                }

                qua.HitObjects[i] = obj;
            }

            for (var i = 0; i < qua.SoundEffects.Count; i++)
            {
                var info = qua.SoundEffects[i];
                if (info.Volume == 0)
                {
                    info.Volume = 100;
                }
                qua.SoundEffects[i] = info;
            }
        }