Ejemplo n.º 1
0
        //TODO: Throw error if somethings messed up with the timing section
        //Calculates the slider velocity at a specified time using the default
        //velocity and the relevant timing section
        //Timing points inside sliders don't affect the slider itself
        protected double GetSliderVelocity()
        {
            int ms = Int32.Parse(HitObjectParser.GetProperty(id, "time"));
            //Get the default slider velocity of the beatmap
            double slidervelocity = Double.Parse(map.GetTag("Difficulty", "SliderMultiplier"), CultureInfo.InvariantCulture);

            //Get all the timing sections of the beatmap
            string[] timings = this.map.GetSection("TimingPoints");
            //Will hold the relevant timing point
            string timingpoint = null;

            //Find the section that applies to the given time
            for (int i = 0; i < timings.Length; i++)
            {
                //Split the string by commas to get all the relevant times
                string[] attributes = timings[i].Split(',');
                //Trim each string just in case
                attributes = Dewlib.TrimStringArray(attributes);
                //If the timing point is a higher time, then we want the previous timing section
                if (Int32.Parse(attributes[0]) > ms)
                {
                    //avoid accessing a negative timing point
                    if (i == 0)
                    {
                        timingpoint = timings[0];
                    }
                    else
                    {
                        timingpoint = timings[i - 1];
                    }
                    break;
                }
            }

            //If the timing point needed is the very last one
            if (timingpoint == null)
            {
                timingpoint = timings[timings.Length - 1];
            }

            string[] properties = timingpoint.Split(',');
            //If the offset is positive, then there is no slider multiplication
            if (Double.Parse(properties[1], CultureInfo.InvariantCulture) > 0)
            {
                return(slidervelocity);
            }
            //Otherwise the slider multiplier is 100 / abs(offset)
            else
            {
                double offset = Double.Parse(properties[1], CultureInfo.InvariantCulture);
                return(slidervelocity * (100 / Math.Abs(offset)));
            }
        }
Ejemplo n.º 2
0
 public DebugController()
 {
     //Checks if the file exists, then loads it if it does
     if (File.Exists("debugcommands.txt"))
     {
         using (StreamReader sr = new StreamReader("debugcommands.txt"))
         {
             string filecontents = sr.ReadToEnd();
             commandlist = filecontents.Split('\n');
             commandlist = Dewlib.TrimStringArray(commandlist);
         }
         this.FindCommands();
     }
     else
     {
         commandlist = new string[0];
     }
 }
Ejemplo n.º 3
0
        // Searches for a tag in a given section.
        // This method does not search for info in events, timingpoints, colours, or hitobjects.
        // If the tag is not found, the method returns null.
        public string GetTag(string sectionname, string tag)
        {
            sectionname = sectionname.ToUpper();

            //Get the correct line number for the given section
            int sectionline = section.GetTaggableSectionLine(sectionname);

            //If the section doesn't exist, or is not a taggable section, return null
            if (sectionline == -1)
            {
                return(null);
            }

            //Searches through each line for the requested tag
            for (int i = sectionline + 1; i < filelines.Length; i++)
            {
                //Section ends on empty line, so stop searching once you get to one
                if (filelines[i].Length == 0)
                {
                    break;
                }

                //Get a pair of strings, one side is the tag, other side is the value of the tag
                string[] pair = Dewlib.SplitFirst(filelines[i], ':');

                //Skip if the pair is invalid
                if (pair.Length != 2)
                {
                    continue;
                }

                //Trim the pair, since the tag value will have a space (e.g. Mode: 0)
                pair = Dewlib.TrimStringArray(pair);

                //Essentially if the tag is a match
                if (pair[0].ToUpper() == tag.ToUpper())
                {
                    //Return its value
                    return(pair[1]);
                }
            }
            //If nothing was found, return null
            return(null);
        }
Ejemplo n.º 4
0
        //Calculates the Milliseconds per Beat at a specified time by searching
        //through the entire timing points section
        //Timing points inside sliders don't affect the slider itself
        protected double GetMpB()
        {
            int ms = Int32.Parse(HitObjectParser.GetProperty(id, "time"));

            //Get all the timing sections of the beatmap
            string[] timings = this.map.GetSection("TimingPoints");
            //Just in case there is only one timing point
            string timingpoint = timings[0];

            //Find the section that applies to the given time
            for (int i = 0; i < timings.Length; i++)
            {
                //Split the string by commas to get all the relevant times
                string[] attributes = timings[i].Split(',');
                //Trim each string just in case
                attributes = Dewlib.TrimStringArray(attributes);

                if (Int32.Parse(attributes[0]) > ms)
                {
                    break;
                }

                else if (Double.Parse(attributes[1], CultureInfo.InvariantCulture) > 0)
                {
                    timingpoint = timings[i];
                }
                else
                {
                    continue;
                }
            }

            if (timingpoint == null)
            {
                throw new Exception("Error, no relevant timing point\nms=" + ms);
            }

            string[] properties = timingpoint.Split(',');
            return(Double.Parse(properties[1], CultureInfo.InvariantCulture));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Format the file's contents into an array (each entry is one line), loads it into this.filelines, and trims each entry of whitespace.
 /// Empty lines are preserved (to determine when a section ends)
 /// </summary>
 /// <param name="filecontents">The contents of the file in a string</param>
 private void FormatFileString(string filecontents)
 {
     filelines = filecontents.Split('\n');
     filelines = Dewlib.TrimStringArray(filelines);
 }