示例#1
0
        public bool SaveConfig()
        {
            StreamWriter writer = null;

            try
            {
                writer = new StreamWriter(configPath, false, Config.Encode);
                for (int i = 0; i < configArray.Length; i++)
                {
                    AConfigItem item = configArray[i];
                    if (item == null)
                    {
                        continue;
                    }

                    //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行
                    if (item.Code == ConfigCode.CompatiDRAWLINE)
                    {
                        continue;
                    }
                    if ((item.Code == ConfigCode.ChangeMasterNameIfDebug) && (item.GetValue <bool>()))
                    {
                        continue;
                    }
                    if ((item.Code == ConfigCode.LastKey) && (item.GetValue <long>() == 0))
                    {
                        continue;
                    }
                    //if (item.Code == ConfigCode.IgnoreWarningFiles)
                    //{
                    //    List<string> files = item.GetValue<List<string>>();
                    //    foreach (string filename in files)
                    //        writer.WriteLine(item.Text + ":" + filename.ToString());
                    //    continue;
                    //}
                    writer.WriteLine(item.ToString());
                }
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
            return(true);
        }
示例#2
0
        public SingleTerm GetConfigValueInERB(string text, ref string errMes)
        {
            AConfigItem item = ConfigData.Instance.GetItem(text);

            if (item == null)
            {
                errMes = "文字列\"" + text + "\"は適切なコンフィグ名ではありません";
                return(null);
            }
            SingleTerm term;

            switch (item.Code)
            {
            //<bool>
            case ConfigCode.AutoSave:                    //"オートセーブを行なう"
            case ConfigCode.MoneyFirst:                  //"単位の位置"
                if (item.GetValue <bool>())
                {
                    term = new SingleTerm(1);
                }
                else
                {
                    term = new SingleTerm(0);
                }
                break;

            //<int>
            case ConfigCode.WindowX:                    // "ウィンドウ幅"
            case ConfigCode.PrintCPerLine:              // "PRINTCを並べる数"
            case ConfigCode.PrintCLength:               // "PRINTCの文字数"
            case ConfigCode.FontSize:                   // "フォントサイズ"
            case ConfigCode.LineHeight:                 // "一行の高さ"
            case ConfigCode.SaveDataNos:                // "表示するセーブデータ数"
            case ConfigCode.MaxShopItem:                // "販売アイテム数"
            case ConfigCode.ComAbleDefault:             // "COM_ABLE初期値"
                term = new SingleTerm(item.GetValue <int>());
                break;

            //<Color>
            case ConfigCode.ForeColor:                   //"文字色"
            case ConfigCode.BackColor:                   //"背景色"
            case ConfigCode.FocusColor:                  //"選択中文字色"
            case ConfigCode.LogColor:                    //"履歴文字色"
            {
                Color color = item.GetValue <Color>();
                term = new SingleTerm(((color.R * 256) + color.G) * 256 + color.B);
            }
            break;

            //<Int64>
            case ConfigCode.pbandDef:                    // "PBANDの初期値"
            case ConfigCode.RelationDef:                 // "RELATIONの初期値"
                term = new SingleTerm(item.GetValue <Int64>());
                break;

            //<string>
            case ConfigCode.FontName:                    // "フォント名"
            case ConfigCode.MoneyLabel:                  // "お金の単位"
            case ConfigCode.LoadLabel:                   // "起動時簡略表示"
            case ConfigCode.DrawLineString:              // "DRAWLINE文字"
            case ConfigCode.TitleMenuString0:            // "システムメニュー0"
            case ConfigCode.TitleMenuString1:            // "システムメニュー1"
            case ConfigCode.TimeupLabel:                 // "時間切れ表示"
                term = new SingleTerm(item.GetValue <string>());
                break;

            //<char>
            case ConfigCode.BarChar1:                    // "BAR文字1"
            case ConfigCode.BarChar2:                    // "BAR文字2"
                term = new SingleTerm(item.GetValue <char>().ToString());
                break;

            //<TextDrawingMode>
            case ConfigCode.TextDrawingMode:                    // "描画インターフェース"
                term = new SingleTerm(item.GetValue <TextDrawingMode>().ToString());
                break;

            default:
            {
                errMes = "コンフィグ文字列\"" + text + "\"の値の取得は許可されていません";
                return(null);
            }
            }
            return(term);
        }