示例#1
0
        bool GetSection(string strLine, ref EOSU_SECTION Section)
        {
            if (strLine.Length >= 2 && strLine[0] == '[' && strLine[strLine.Length - 1] == ']')
            {
                Section = EOSU_SECTION.EOSU_SECTION_NON;
                string v = strLine.Replace("[", "");
                v = v.Replace("]", "");

                if (v == "HitObjects")
                {
                    Section = EOSU_SECTION.EOSU_SECTION_HITOBJECTS;
                }
                else if (v == "Metadata")
                {
                    Section = EOSU_SECTION.EOSU_SECTION_METADATA;
                }
                else if (v == "TimingPoints")
                {
                    Section = EOSU_SECTION.EOSU_SECTION_TIMEPOINT;
                }
                else if (v == "Difficulty")
                {
                    Section = EOSU_SECTION.EOSU_SECTION_DIFFICULTY;
                }
                return(true);
            }
            return(false);
        }
示例#2
0
        public override void LoadStageInfo(string stagePath, EStageLevel stageLevel)
        {
            using (StreamReader sr = new StreamReader(stagePath, Encoding.GetEncoding("gb18030")))
            {
                char[]       invalidFlag = { ',' };
                char[]       trimStart   = { ' ', '\t' };
                char[]       trimEnd     = { ' ', '\r', '\n', '\t' };
                string       stringLine  = null;
                EOSU_SECTION curSection  = EOSU_SECTION.EOSU_SECTION_NON;
                EOSU_SECTION Section     = EOSU_SECTION.EOSU_SECTION_NON;
                while ((stringLine = sr.ReadLine()) != null)
                {
                    if (!m_bInvalidFlag && ContainsFlag(stringLine, invalidFlag))
                    {
                        m_bInvalidFlag = true;
                    }

                    stringLine = stringLine.TrimEnd(trimEnd);
                    stringLine = stringLine.TrimStart(trimStart);
                    if (IsComment(stringLine))
                    {
                        continue;
                    }
                    if (GetSection(stringLine, ref Section))
                    {
                        curSection = Section;
                    }
                    else
                    {
                        if (BeginWithNum(stringLine))
                        {
                            if (Section == EOSU_SECTION.EOSU_SECTION_HITOBJECTS)
                            {
                                AddNewOperator(stringLine);
                            }

                            if (Section == EOSU_SECTION.EOSU_SECTION_TIMEPOINT)
                            {
                                string[] splitResult = stringLine.Split(',');
                                if (splitResult.Length >= 3)
                                {
                                    float offset = 0;
                                    float.TryParse(splitResult[0], out offset);
                                    mOffset = offset / 1000;

                                    float bpm = 0;
                                    float.TryParse(splitResult[1], out bpm);
                                    mBPM = 60000 / bpm;

                                    int nbeat = 0;
                                    int.TryParse(splitResult[2], out nbeat);
                                    if (nbeat == 3)
                                    {
                                        mBeatN = 3;
                                    }
                                }
                            }
                        }
                        else
                        {
                            string strkey   = null;
                            string strvalue = null;
                            if (Section == EOSU_SECTION.EOSU_SECTION_METADATA)
                            {
                                SeparateString(stringLine, ':', ref strkey, ref strvalue);
                                if (strkey == "Tags")
                                {
                                    float fv = 0;
                                    float.TryParse(strvalue, out fv);
                                    mMatchTime = fv;
                                }
                                else if (strkey == "Source")
                                {
                                    //for show time;
                                    string[] ShowTomes = strvalue.Split(',');
                                    mShowtimeRound = new int[ShowTomes.Length];
                                    for (int i = 0; i < ShowTomes.Length; i++)
                                    {
                                        int nv = 0;
                                        int.TryParse(ShowTomes[i], out nv);
                                        mShowtimeRound[i] = nv;
                                    }
                                }
                            }
                            else if (Section == EOSU_SECTION.EOSU_SECTION_DIFFICULTY)
                            {
                                SeparateString(stringLine, ':', ref strkey, ref strvalue);
                            }
                        }
                    }
                }

                sr.Close();
            }
        }