Exemplo n.º 1
0
        /// <summary>
        /// 渡されたgenre.iniのパスから読み込んで設定していく
        /// </summary>
        /// <param name="path">genre.iniの絶対パス</param>
        public CGenreIni(string path)
        {
            StreamReader sr = new StreamReader(path, Encoding.Default);

            string[] strSingleLine = sr.ReadToEnd().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in strSingleLine)
            {
                string str = s.Replace('\t', ' ').TrimStart(new char[] { '\t', ' ' });
                if ((str.Length != 0) && (str[0] != ';'))
                {
                    try
                    {
                        string   strCommand;
                        string   strParam;
                        string[] strArray = str.Split(new char[] { '=' });
                        if (strArray.Length == 2)
                        {
                            strCommand = strArray[0].Trim();
                            strParam   = strArray[1].Trim();

                            #region [ 演奏 ]
                            //-----------------------------
                            if (strCommand == "GenreName")
                            {
                                this.strGenreName = strParam;
                            }
                            else if (strCommand == "GenreColor")
                            {
                                this.cGenreColor = C変換.strColorCodeToColor4(strParam);
                            }
                            else if (strCommand == "FontColor")
                            {
                                this.cFontColor = C変換.strColorCodeToColor4(strParam);
                            }
                            else if (strCommand == "FontOutLineColor")
                            {
                                this.cFontOutLineColor = C変換.strColorCodeToColor4(strParam);
                            }
                            else if (strCommand == "FolderType")
                            {
                                this.nFolderType = C変換.n値を文字列から取得して範囲内に丸めて返す(strParam, 0, 1, 0);
                            }
                            #endregion
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.StackTrace);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void t文字列から読み込み(string strAllSettings)          // 2011.4.13 yyagi; refactored to make initial KeyConfig easier.
        {
            string[] delimiter     = { "\n" };
            string[] strSingleLine = strAllSettings.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in strSingleLine)
            {
                string str = s.Replace('\t', ' ').TrimStart(new char[] { '\t', ' ' });
                if ((str.Length != 0) && (str[0] != ';'))
                {
                    try
                    {
                        string   strCommand;
                        string   strParam;
                        string[] strArray = str.Split(new char[] { '=' });
                        if (strArray.Length == 2)
                        {
                            strCommand = strArray[0].Trim();
                            strParam   = strArray[1].Trim();

                            #region [ 演奏 ]
                            //-----------------------------
                            if (strCommand == "ScrollFieldP1Y")
                            {
                                this.nScrollFieldY[0] = C変換.n値を文字列から取得して返す(strParam, 192);
                            }
                            else if (strCommand == "ScrollFieldP2Y")
                            {
                                this.nScrollFieldY[1] = C変換.n値を文字列から取得して返す(strParam, 192);
                            }
                            else if (strCommand == "SENotesP1Y")
                            {
                                this.nSENotesY[0] = C変換.n値を文字列から取得して返す(strParam, this.nSENotesY[0]);
                            }
                            else if (strCommand == "SENotesP2Y")
                            {
                                this.nSENotesY[1] = C変換.n値を文字列から取得して返す(strParam, this.nSENotesY[1]);
                            }
                            else if (strCommand == "JudgePointP1Y")
                            {
                                this.nJudgePointY[0] = C変換.n値を文字列から取得して返す(strParam, this.nJudgePointY[0]);
                            }
                            else if (strCommand == "JudgePointP2Y")
                            {
                                this.nJudgePointY[1] = C変換.n値を文字列から取得して返す(strParam, this.nJudgePointY[1]);
                            }

                            else if (strCommand == "PlayerCharacterP1X")
                            {
                                this.nPlayerCharacterX[0] = C変換.n値を文字列から取得して返す(strParam, 0);
                            }
                            else if (strCommand == "PlayerCharacterP1Y")
                            {
                                this.nPlayerCharacterY[0] = C変換.n値を文字列から取得して返す(strParam, 0);
                            }
                            else if (strCommand == "CourseSymbolP1X")
                            {
                                this.nCourseSymbolX[0] = C変換.n値を文字列から取得して返す(strParam, this.nCourseSymbolX[0]);
                            }
                            else if (strCommand == "CourseSymbolP1Y")
                            {
                                this.nCourseSymbolY[0] = C変換.n値を文字列から取得して返す(strParam, this.nCourseSymbolY[0]);
                            }

                            else if (strCommand == "DiffDispMode")
                            {
                                this.eDiffDispMode = (E難易度表示タイプ)C変換.n値を文字列から取得して範囲内に丸めて返す(strParam, 0, 2, (int)this.eDiffDispMode);
                            }
                            else if (strCommand == "NowStageDisp")
                            {
                                this.b現在のステージ数を表示しない = C変換.bONorOFF(strParam[0]);
                            }
                            else if (strCommand == "AddScoreColorP1")
                            {
                                string[] arColor = strParam.Split(',');
                                if (arColor.Length == 3)
                                {
                                    this.cScoreColor1P = C変換.n255ToColor4(Convert.ToInt16(arColor[0]), Convert.ToInt16(arColor[1]), Convert.ToInt16(arColor[2]));
                                }
                            }
                            else if (strCommand == "AddScoreColorP2")
                            {
                                string[] arColor = strParam.Split(',');
                                if (arColor.Length == 3)
                                {
                                    this.cScoreColor2P = C変換.n255ToColor4(Convert.ToInt16(arColor[0]), Convert.ToInt16(arColor[1]), Convert.ToInt16(arColor[2]));
                                }
                            }

                            //-----------------------------
                            #endregion
                            #region [ 成績発表 ]
                            //-----------------------------
                            else if (strCommand == "ResultPanelP1X")
                            {
                                this.nResultPanelP1X = C変換.n値を文字列から取得して返す(strParam, 515);
                            }
                            else if (strCommand == "ResultPanelP1Y")
                            {
                                this.nResultPanelP1Y = C変換.n値を文字列から取得して返す(strParam, 75);
                            }
                            else if (strCommand == "ResultPanelP2X")
                            {
                                this.nResultPanelP2X = C変換.n値を文字列から取得して返す(strParam, 515);
                            }
                            else if (strCommand == "ResultPanelP2Y")
                            {
                                this.nResultPanelP2Y = C変換.n値を文字列から取得して返す(strParam, 75);
                            }
                            else if (strCommand == "ResultScoreP1X")
                            {
                                this.nResultScoreP1X = C変換.n値を文字列から取得して返す(strParam, 582);
                            }
                            else if (strCommand == "ResultScoreP1Y")
                            {
                                this.nResultScoreP1Y = C変換.n値を文字列から取得して返す(strParam, 252);
                            }
                            //-----------------------------
                            #endregion
                            #region [ その他 ]
                            #endregion
                        }
                        continue;
                    }
                    catch (Exception exception)
                    {
                        Trace.TraceError(exception.Message);
                        continue;
                    }
                }
            }
        }
        /// <summary>
        /// 指定された .score.ini を読み込む。内容の真偽は判定しない。
        /// </summary>
        /// <param name="iniファイル名">読み込む .score.ini ファイルを指定します(絶対パスが安全)。</param>
        public void t読み込み(string iniファイル名)
        {
            this.iniファイルのあるフォルダ名 = Path.GetDirectoryName(iniファイル名);
            this.iniファイル名        = Path.GetFileName(iniファイル名);

            Eセクション種別 section = Eセクション種別.Unknown;

            if (File.Exists(iniファイル名))
            {
                string       str;
                Encoding     inienc = TJAPlayer3.JudgeTextEncoding.JudgeFileEncoding(iniファイル名);
                StreamReader reader = new StreamReader(iniファイル名, inienc);
                while ((str = reader.ReadLine()) != null)
                {
                    str = str.Replace('\t', ' ').TrimStart(new char[] { '\t', ' ' });
                    if ((str.Length != 0) && (str[0] != ';'))
                    {
                        try
                        {
                            string item;
                            string para;
                            C演奏記録  c演奏記録;
                            #region [ section ]
                            if (str[0] == '[')
                            {
                                StringBuilder builder = new StringBuilder(0x20);
                                int           num     = 1;
                                while ((num < str.Length) && (str[num] != ']'))
                                {
                                    builder.Append(str[num++]);
                                }
                                string str2 = builder.ToString();
                                if (str2.Equals("File"))
                                {
                                    section = Eセクション種別.File;
                                }
                                else if (str2.Equals("HiScore.Drums"))
                                {
                                    section = Eセクション種別.HiScoreDrums;
                                }
                                else if (str2.Equals("HiSkill.Drums"))
                                {
                                    section = Eセクション種別.HiSkillDrums;
                                }
                                // #23595 2011.1.9 ikanick
                                else if (str2.Equals("LastPlay.Drums"))
                                {
                                    section = Eセクション種別.LastPlayDrums;
                                }
                                //----------------------------------------------------
                                else
                                {
                                    section = Eセクション種別.Unknown;
                                }
                            }
                            #endregion
                            else
                            {
                                string[] strArray = str.Split(new char[] { '=' });
                                if (strArray.Length == 2)
                                {
                                    item = strArray[0].Trim();
                                    para = strArray[1].Trim();
                                    switch (section)
                                    {
                                    case Eセクション種別.File:
                                    {
                                        if (!item.Equals("Title"))
                                        {
                                            goto Label_01C7;
                                        }
                                        this.stファイル.Title = para;
                                        continue;
                                    }

                                    case Eセクション種別.HiScoreDrums:
                                    case Eセクション種別.HiSkillDrums:
                                    case Eセクション種別.LastPlayDrums:                                            // #23595 2011.1.9 ikanick
                                    {
                                        c演奏記録 = this.stセクション[(int)section];
                                        if (!item.Equals("Score"))
                                        {
                                            goto Label_03B9;
                                        }
                                        c演奏記録.nスコア = long.Parse(para);


                                        continue;
                                    }
                                    }
                                }
                            }
                            continue;
                            #region [ File section ]
Label_01C7:
                            if (item.Equals("Name"))
                            {
                                this.stファイル.Name = para;
                            }
                            else if (item.Equals("Hash"))
                            {
                                this.stファイル.Hash = para;
                            }
                            else if (item.Equals("PlayCountDrums"))
                            {
                                this.stファイル.PlayCountDrums = C変換.n値を文字列から取得して範囲内に丸めて返す(para, 0, 99999999, 0);
                            }
                            // #23596 10.11.16 add ikanick------------------------------------/
                            else if (item.Equals("ClearCountDrums"))
                            {
                                this.stファイル.ClearCountDrums = C変換.n値を文字列から取得して範囲内に丸めて返す(para, 0, 99999999, 0);
                            }
                            // #24459 2011.2.24 yyagi-----------------------------------------/
                            else if (item.Equals("BestRankDrums"))
                            {
                                this.stファイル.BestRank = C変換.n値を文字列から取得して範囲内に丸めて返す(para, (int)ERANK.SS, (int)ERANK.E, (int)ERANK.UNKNOWN);
                            }
                            //----------------------------------------------------------------/
                            else if (item.Equals("History0"))
                            {
                                this.stファイル.History[0] = para;
                            }
                            else if (item.Equals("History1"))
                            {
                                this.stファイル.History[1] = para;
                            }
                            else if (item.Equals("History2"))
                            {
                                this.stファイル.History[2] = para;
                            }
                            else if (item.Equals("History3"))
                            {
                                this.stファイル.History[3] = para;
                            }
                            else if (item.Equals("History4"))
                            {
                                this.stファイル.History[4] = para;
                            }
                            else if (item.Equals("HistoryCount"))
                            {
                                this.stファイル.HistoryCount = C変換.n値を文字列から取得して範囲内に丸めて返す(para, 0, 99999999, 0);
                            }
                            else if (item.Equals("BGMAdjust"))
                            {
                                this.stファイル.BGMAdjust = C変換.n値を文字列から取得して返す(para, 0);
                            }
                            continue;
                            #endregion
                            #region [ Score section ]
Label_03B9:
                            if (item.Equals("HiScore1"))
                            {
                                c演奏記録.nハイスコア[0] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore2"))
                            {
                                c演奏記録.nハイスコア[1] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore3"))
                            {
                                c演奏記録.nハイスコア[2] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore4"))
                            {
                                c演奏記録.nハイスコア[3] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore5"))
                            {
                                c演奏記録.nハイスコア[4] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore6"))
                            {
                                c演奏記録.nハイスコア[5] = int.Parse(para);
                            }
                            else if (item.Equals("HiScore7"))
                            {
                                c演奏記録.nハイスコア[6] = int.Parse(para);
                            }
                            if (item.Equals("PlaySkill"))
                            {
                                try
                                {
                                    c演奏記録.db演奏型スキル値 = (double)decimal.Parse(para);
                                }
                                catch
                                {
                                    c演奏記録.db演奏型スキル値 = 0.0;
                                }
                            }
                            else if (item.Equals("Skill"))
                            {
                                try
                                {
                                    c演奏記録.dbゲーム型スキル値 = (double)decimal.Parse(para);
                                }
                                catch
                                {
                                    c演奏記録.dbゲーム型スキル値 = 0.0;
                                }
                            }
                            else if (item.Equals("Perfect"))
                            {
                                c演奏記録.nPerfect数 = int.Parse(para);
                            }
                            else if (item.Equals("Great"))
                            {
                                c演奏記録.nGreat数 = int.Parse(para);
                            }
                            else if (item.Equals("Good"))
                            {
                                c演奏記録.nGood数 = int.Parse(para);
                            }
                            else if (item.Equals("Poor"))
                            {
                                c演奏記録.nPoor数 = int.Parse(para);
                            }
                            else if (item.Equals("Miss"))
                            {
                                c演奏記録.nMiss数 = int.Parse(para);
                            }
                            else if (item.Equals("Roll"))
                            {
                                c演奏記録.n連打数 = int.Parse(para);
                            }
                            else if (item.Equals("MaxCombo"))
                            {
                                c演奏記録.n最大コンボ数 = int.Parse(para);
                            }
                            else if (item.Equals("TotalChips"))
                            {
                                c演奏記録.n全チップ数 = int.Parse(para);
                            }
                            else if (item.Equals("Risky"))
                            {
                                c演奏記録.nRisky = int.Parse(para);
                            }
                            else if (item.Equals("TightDrums"))
                            {
                                c演奏記録.bTight = C変換.bONorOFF(para[0]);
                            }
                            #endregion
                            else
                            {
                                #region [ ScrollSpeedDrums ]
                                if (item.Equals("ScrollSpeedDrums"))
                                {
                                    c演奏記録.f譜面スクロール速度 = (float)decimal.Parse(para);
                                }
                                #endregion
                                #region [ PlaySpeed ]
                                else if (item.Equals("PlaySpeed"))
                                {
                                    string[] strArray2 = para.Split(new char[] { '/' });
                                    if (strArray2.Length == 2)
                                    {
                                        c演奏記録.n演奏速度分子 = int.Parse(strArray2[0]);
                                        c演奏記録.n演奏速度分母 = int.Parse(strArray2[1]);
                                    }
                                }
                                #endregion
                                else
                                {
                                    #region [ Drums ]
                                    if (item.Equals("Drums"))
                                    {
                                        c演奏記録.bDrums有効 = C変換.bONorOFF(para[0]);
                                    }
                                    #endregion
                                    #region [ StageFailed ]
                                    else if (item.Equals("StageFailed"))
                                    {
                                        c演奏記録.bSTAGEFAILED有効 = C変換.bONorOFF(para[0]);
                                    }
                                    #endregion
                                    else
                                    {
                                        #region [ DamageLevel ]
                                        if (item.Equals("DamageLevel"))
                                        {
                                            switch (int.Parse(para))
                                            {
                                            case 0:
                                            {
                                                c演奏記録.eダメージレベル = Eダメージレベル.少ない;
                                                continue;
                                            }

                                            case 1:
                                            {
                                                c演奏記録.eダメージレベル = Eダメージレベル.普通;
                                                continue;
                                            }

                                            case 2:
                                            {
                                                c演奏記録.eダメージレベル = Eダメージレベル.大きい;
                                                continue;
                                            }
                                            }
                                            throw new Exception("DamageLevel の値が無効です。");
                                        }
                                        #endregion
                                        if (item.Equals("UseKeyboard"))
                                        {
                                            c演奏記録.b演奏にキーボードを使用した = C変換.bONorOFF(para[0]);
                                        }
                                        else if (item.Equals("UseMIDIIN"))
                                        {
                                            c演奏記録.b演奏にMIDI入力を使用した = C変換.bONorOFF(para[0]);
                                        }
                                        else if (item.Equals("UseJoypad"))
                                        {
                                            c演奏記録.b演奏にジョイパッドを使用した = C変換.bONorOFF(para[0]);
                                        }
                                        else if (item.Equals("UseMouse"))
                                        {
                                            c演奏記録.b演奏にマウスを使用した = C変換.bONorOFF(para[0]);
                                        }
                                        else if (item.Equals("PerfectRange"))
                                        {
                                            c演奏記録.nPerfectになる範囲ms = int.Parse(para);
                                        }
                                        else if (item.Equals("GreatRange"))
                                        {
                                            c演奏記録.nGreatになる範囲ms = int.Parse(para);
                                        }
                                        else if (item.Equals("GoodRange"))
                                        {
                                            c演奏記録.nGoodになる範囲ms = int.Parse(para);
                                        }
                                        else if (item.Equals("PoorRange"))
                                        {
                                            c演奏記録.nPoorになる範囲ms = int.Parse(para);
                                        }
                                        else if (item.Equals("DTXManiaVersion"))
                                        {
                                            c演奏記録.strDTXManiaのバージョン = para;
                                        }
                                        else if (item.Equals("DateTime"))
                                        {
                                            c演奏記録.最終更新日時 = para;
                                        }
                                        else if (item.Equals("Hash"))
                                        {
                                            c演奏記録.Hash = para;
                                        }
                                        else if (item.Equals("9LaneMode"))
                                        {
                                            c演奏記録.レーン9モード = C変換.bONorOFF(para[0]);
                                        }
                                        else if (item.Equals("HiScore1"))
                                        {
                                            c演奏記録.nハイスコア[0] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore2"))
                                        {
                                            c演奏記録.nハイスコア[1] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore3"))
                                        {
                                            c演奏記録.nハイスコア[2] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore4"))
                                        {
                                            c演奏記録.nハイスコア[3] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore5"))
                                        {
                                            c演奏記録.nハイスコア[4] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore6"))
                                        {
                                            c演奏記録.nハイスコア[5] = int.Parse(para);
                                        }
                                        else if (item.Equals("HiScore7"))
                                        {
                                            c演奏記録.nハイスコア[6] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown1"))
                                        {
                                            c演奏記録.n王冠[0] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown2"))
                                        {
                                            c演奏記録.n王冠[1] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown3"))
                                        {
                                            c演奏記録.n王冠[2] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown4"))
                                        {
                                            c演奏記録.n王冠[3] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown5"))
                                        {
                                            c演奏記録.n王冠[4] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown6"))
                                        {
                                            c演奏記録.n王冠[5] = int.Parse(para);
                                        }
                                        else if (item.Equals("Crown7"))
                                        {
                                            c演奏記録.n王冠[6] = int.Parse(para);
                                        }
                                    }
                                }
                            }
                            continue;
                        }
                        catch (Exception exception)
                        {
                            Trace.TraceError(exception.ToString());
                            Trace.TraceError("読み込みを中断します。({0})", iniファイル名);
                            break;
                        }
                    }
                }
                reader.Close();
            }
        }