public void SetConfig(string config, string path) { if (!File.Exists(config)) { return; } regx_monster = "(\\s\\S*?)"; regx_pendulum = "(\\s\\S*?)"; //设置文件名 configName = MyPath.getFullFileName(MSEConfig.TAG, config); replaces = new SortedList <string, string>(); typeDic = new SortedList <long, string>(); raceDic = new SortedList <long, string>(); string[] lines = File.ReadAllLines(config, Encoding.UTF8); foreach (string line in lines) { if (string.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.StartsWith(TAG_CN2TW)) { Iscn2tw = ConfHelper.getBooleanValue(line); } else if (line.StartsWith(TAG_SPELL)) { str_spell = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_HEAD)) { head = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_END)) { end = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_TEXT)) { temp_text = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_TRAP)) { str_trap = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_REG_PENDULUM)) { regx_pendulum = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_REG_MONSTER)) { regx_monster = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_MAXCOUNT)) { maxcount = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_WIDTH)) { width = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_HEIGHT)) { height = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_PEND_WIDTH)) { pwidth = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_PEND_HEIGHT)) { pheight = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_NO_TEN)) { no10 = ConfHelper.getBooleanValue(line); } else if (line.StartsWith(TAG_NO_START_CARDS)) { string val = ConfHelper.getValue(line); string[] cs = val.Split(','); noStartCards = new long[cs.Length]; int i = 0; foreach (string str in cs) { long l = 0; long.TryParse(str, out l); noStartCards[i++] = l; } } else if (line.StartsWith(TAG_IMAGE)) { //如果路径不合法,则为后面的路径 imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE)); //图片缓存目录 imagecache = MyPath.Combine(imagepath, "cache"); MyPath.CreateDir(imagecache); } else if (line.StartsWith(TAG_REPALCE)) { //特数字替换 string word = ConfHelper.getValue(line); string p = ConfHelper.getRegex(ConfHelper.getValue1(word)); string r = ConfHelper.getRegex(ConfHelper.getValue2(word)); if (!string.IsNullOrEmpty(p)) { replaces.Add(p, r); } } else if (line.StartsWith(TAG_RACE)) { //种族 ConfHelper.DicAdd(raceDic, line); } else if (line.StartsWith(TAG_TYPE)) { //类型 ConfHelper.DicAdd(typeDic, line); } else if (line.StartsWith(TAG_REIMAGE)) { reimage = ConfHelper.getBooleanValue(line); } } }