public bool SaveDebugConfig() { StreamWriter writer = null; try { writer = new StreamWriter(configdebugPath, false, Config.Encode); for (int i = 0; i < debugArray.Length; i++) { AConfigItem item = debugArray[i]; if (item == null) { continue; } writer.WriteLine(item.ToString()); } } catch (Exception) { return(false); } finally { if (writer != null) { writer.Close(); } } return(true); }
public T GetConfigValue <T>(ConfigCode code) { AConfigItem item = GetItem(code); //if ((item != null) && (item is ConfigItem<T>)) return(((ConfigItem <T>)item).Value); //throw new ExeEE("GetConfigValueのCodeまたは型が不適切"); }
public override void CopyTo(AConfigItem other) { ConfigItem <T> item = ((ConfigItem <T>)other); item.Fixed = false; item.Value = this.Value; item.Fixed = this.Fixed; }
public bool LoadDebugConfig() { if (!File.Exists(configdebugPath)) { goto err; } EraStreamReader eReader = new EraStreamReader(false); if (!eReader.Open(configdebugPath)) { goto err; } ScriptPosition pos = null; try { string line = null; while ((line = eReader.ReadLine()) != null) { if ((line.Length == 0) || (line[0] == ';')) { continue; } pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line); string[] tokens = line.Split(new char[] { ':' }); if (tokens.Length < 2) { continue; } AConfigItem item = GetDebugItem(tokens[0].Trim()); if (item != null) { item.TryParse(tokens[1]); } #if UEMUERA_DEBUG //else // throw new Exception("コンフィグファイルが変"); #endif } } catch (EmueraException ee) { ParserMediator.ConfigWarn(ee.Message, pos, 1, null); goto err; } catch (Exception exc) { ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace); goto err; } finally { eReader.Dispose(); } Config.SetDebugConfig(this); return(true); err: Config.SetDebugConfig(this); return(false); }
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); }
public AConfigItem GetItem(string key) { AConfigItem item = GetConfigItem(key); if (item == null) { item = GetReplaceItem(key); if (item == null) { item = GetDebugItem(key); } } return(item); }
public AConfigItem GetItem(ConfigCode code) { AConfigItem item = GetConfigItem(code); if (item == null) { item = GetReplaceItem(code); if (item == null) { item = GetDebugItem(code); } } return(item); }
// 1.52a改変部分 (単位の差し替えおよび前置、後置のためのコンフィグ処理) public void LoadReplaceFile(string filename) { EraStreamReader eReader = new EraStreamReader(false); if (!eReader.Open(filename)) { return; } ScriptPosition pos = null; try { string line = null; while ((line = eReader.ReadLine()) != null) { if ((line.Length == 0) || (line[0] == ';')) { continue; } pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line); string[] tokens = line.Split(new char[] { ',', ':' }); if (tokens.Length < 2) { continue; } string itemName = tokens[0].Trim(); tokens[1] = line.Substring(tokens[0].Length + 1); if (string.IsNullOrEmpty(tokens[1].Trim())) { continue; } AConfigItem item = GetReplaceItem(itemName); if (item != null) { item.TryParse(tokens[1]); } } } catch (EmueraException ee) { ParserMediator.Warn(ee.Message, pos, 1); } catch (Exception exc) { ParserMediator.Warn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace); } finally { eReader.Dispose(); } }
private bool loadConfig(string confPath, bool fix) { if (!File.Exists(confPath)) { return(false); } EraStreamReader eReader = new EraStreamReader(false); if (!eReader.Open(confPath)) { return(false); } //加载二进制数据 var bytes = File.ReadAllBytes(confPath); var md5s = GenericUtils.CalcMd5ListForConfig(bytes); ScriptPosition pos = null; int md5i = 0; try { string line = null; //bool defineIgnoreWarningFiles = false; while ((line = eReader.ReadLine()) != null) { var md5 = md5s[md5i++]; if ((line.Length == 0) || (line[0] == ';')) { continue; } pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line); string[] tokens = line.Split(new char[] { ':' }); if (tokens.Length < 2) { continue; } var token_0 = tokens[0].Trim(); AConfigItem item = GetConfigItem(token_0); if (item == null) { token_0 = uEmuera.Utils.SHIFTJIS_to_UTF8(token_0, md5); if (!string.IsNullOrEmpty(token_0)) { item = GetConfigItem(token_0); } } if (item != null) { //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行 if (item.Code == ConfigCode.CompatiDRAWLINE) { item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739); } //if ((item.Code == ConfigCode.IgnoreWarningFiles)) //{ // if (!defineIgnoreWarningFiles) // (item.GetValue<List<string>>()).Clear(); // defineIgnoreWarningFiles = true; // if ((item.Fixed) && (fix)) // item.Fixed = false; //} if (item.Code == ConfigCode.TextEditor) { //パスの関係上tokens[2]は使わないといけない if (tokens.Length > 2) { if (tokens[2].StartsWith("\\")) { tokens[1] += ":" + tokens[2]; } if (tokens.Length > 3) { for (int i = 3; i < tokens.Length; i++) { tokens[1] += ":" + tokens[i]; } } } } if (item.Code == ConfigCode.EditorArgument) { //半角スペースを要求する引数が必要なエディタがあるので別処理で ((ConfigItem <string>)item).Value = tokens[1]; continue; } if (item.Code == ConfigCode.MaxLog && Program.AnalysisMode) { //解析モード時はここを上書きして十分な長さを確保する tokens[1] = "10000"; } if ((item.TryParse(tokens[1])) && (fix)) { item.Fixed = true; } } #if UEMUERA_DEBUG //else // throw new Exception("コンフィグファイルが変"); #endif } } catch (EmueraException ee) { ParserMediator.ConfigWarn(ee.Message, pos, 1, null); } catch (Exception exc) { ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace); } finally { eReader.Dispose(); } return(true); }
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); }
public abstract void CopyTo(AConfigItem other);
private bool loadConfig(string confPath, bool fix) { if (!File.Exists(confPath)) { return(false); } EraStreamReader eReader = new EraStreamReader(false); if (!eReader.Open(confPath)) { return(false); } ScriptPosition pos = null; try { string line = null; //bool defineIgnoreWarningFiles = false; while ((line = eReader.ReadLine()) != null) { if ((line.Length == 0) || (line[0] == ';')) { continue; } pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line); string[] tokens = line.Split(new char[] { ':' }); if (tokens.Length < 2) { continue; } AConfigItem item = GetConfigItem(tokens[0].Trim()); if (item != null) { //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行 if (item.Code == ConfigCode.CompatiDRAWLINE) { item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739); } //if ((item.Code == ConfigCode.IgnoreWarningFiles)) //{ // if (!defineIgnoreWarningFiles) // (item.GetValue<List<string>>()).Clear(); // defineIgnoreWarningFiles = true; // if ((item.Fixed) && (fix)) // item.Fixed = false; //} if (item.Code == ConfigCode.TextEditor) { //パスの関係上tokens[2]は使わないといけない if (tokens.Length > 2) { if (tokens[2].StartsWith("\\")) { tokens[1] += ":" + tokens[2]; } if (tokens.Length > 3) { for (int i = 3; i < tokens.Length; i++) { tokens[1] += ":" + tokens[i]; } } } } if (item.Code == ConfigCode.EditorArgument) { //半角スペースを要求する引数が必要なエディタがあるので別処理で ((ConfigItem <string>)item).Value = tokens[1]; continue; } if ((item.TryParse(tokens[1])) && (fix)) { item.Fixed = true; } } #if DEBUG //else // throw new Exception("コンフィグファイルが変"); #endif } } catch (EmueraException ee) { ParserMediator.ConfigWarn(ee.Message, pos, 1, null); } catch (Exception exc) { ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace); } finally { eReader.Dispose(); } return(true); }