private void button2_Click(object sender, EventArgs e) { List <Item_Str> ItemList = ItemCtrl.GetItemList(); string file = textBox4.Text + "级物品.txt"; //写文件 FileStream rtfs = new FileStream(file, FileMode.Create, FileAccess.Write); //StreamWriter rt = new StreamWriter(rtfs, Encoding.GetEncoding(950)); StreamWriter rt = new StreamWriter(rtfs, Encoding.Default); rt.BaseStream.Seek(0, SeekOrigin.Begin); rt.BaseStream.Position = 0; //遍历DropList foreach (var it in ItemList) { if (it.limit_level == textBox4.Text) { rt.WriteLine(ItemCtrl.GetIdByCode(it.code) + "\t" + CFormat.ToSimplified(it.code)); } } rt.Close(); rtfs.Close(); MessageBox.Show("输出掉宝资料【" + file + "】成功!"); }
public static string GameStrToSimpleCN(string src) { byte[] utf8bytes = System.Text.Encoding.Default.GetBytes(src); string temp = System.Text.Encoding.GetEncoding(950).GetString(utf8bytes); temp = CFormat.ToSimplified(temp); return(temp); }
public static bool MdfyItemAttr(string id, Item_Str item) { for (int i = 0; i < m_ItemList.Count; i++) { if (CFormat.ToSimplified(m_ItemList[i].code) == id) { m_ItemList[i] = item; return(true); } } return(false); }
public static string GetItemHelp(string id) { string name = ""; foreach (var item in m_ItemHelpList) { if (CFormat.ToTraditional(CFormat.PureString(id)) == CFormat.ToTraditional(CFormat.PureString(item.id))) { return(item.name); } } return(name); }
public static string GetIdByCode(string code) { string id = ""; foreach (var item in m_ItemDefList) { if (CFormat.ToTraditional(CFormat.PureString(code)) == CFormat.ToTraditional(CFormat.PureString("item_" + item.name))) { return(item.id); } } return(id); }
//item_XX ID 此处把 item_XX称作id public static bool GetAttrById(string id, out Item_Str item) { foreach (var it in m_ItemList) { if (CFormat.ToSimplified(it.code) == id) { item = it; return(true); } } item = new Item_Str(); item.more = new List <string>(); return(false); }
private void FillItemLstV() { List <Item_Str> itemList = ItemCtrl.GetItemList(); lstv_ItemList.Items.Clear(); foreach (var item in itemList) { string code = item.code; string id = ItemCtrl.GetIdByCode(code); ListViewItem lvi = new ListViewItem(); lvi.Text = CFormat.PureString(id); lvi.SubItems.Add(CFormat.PureString(code)); lstv_ItemList.Items.Add(lvi); } lstv_ItemList.EndUpdate(); }
public static bool LoadItemDefList() { //文件存在 if (!File.Exists("profile\\ITEM.H")) { return(false); } //读取 m_ItemDefList.Clear(); FileStream fs = new FileStream("profile\\ITEM.H", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("#define")) { ItemDef_Str playerDef; string tmp = strLine.Split(new string[] { "item_" }, StringSplitOptions.RemoveEmptyEntries)[1]; string name = tmp.Split(' ')[0].Split('\t')[0]; string id = tmp.Replace(" ", "").Replace("\\t", "").Replace(name, ""); playerDef.id = CFormat.PureString(id); playerDef.name = CFormat.PureString(name); m_ItemDefList.Add(playerDef); } strLine = null; strLine = reader.ReadLine(); } reader.Close(); fs.Close(); return(true); }
public static bool LoadItemHelpList() { //文件存在 if (!File.Exists("profile\\ITEM_HELP_STRING.TXT")) { return(false); } //读取 m_ItemHelpList.Clear(); FileStream fs = new FileStream("profile\\ITEM_HELP_STRING.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("item = ") && strLine.Substring(0, CFormat.StringLength("item = ")) == "item = ") { ItemHelp_Str item_help; string tmp = strLine.Split(new string[] { "item = " }, StringSplitOptions.RemoveEmptyEntries)[0]; string id = tmp.Split(',')[0]; string name = tmp.Split(',')[1]; item_help.id = id; item_help.name = name; m_ItemHelpList.Add(item_help); } strLine = null; strLine = reader.ReadLine(); } reader.Close(); fs.Close(); return(true); }
public static bool LoadItemList() { //文件存在 if (!File.Exists("profile\\ITEM.TXT")) { return(false); } //读取 m_ItemList.Clear(); FileStream fs = new FileStream("profile\\ITEM.TXT", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs, Encoding.GetEncoding(950)); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; Item_Str item; item.code = ""; item.name = ""; item.cost = ""; item.sell = ""; item.help_string = ""; item.limit_level = ""; item.more = new List <string>(); bool get = false; string strLine = ""; strLine = reader.ReadLine(); while (strLine != null) { strLine = strLine.Split('/')[0]; if (strLine.Contains("[item]") && strLine.Contains("[item]")) { if (get) { //add army m_ItemList.Add(item); } get = true; item.code = ""; item.name = ""; item.cost = ""; item.sell = ""; item.help_string = ""; item.limit_level = ""; item.more = new List <string>(); } else if (strLine.Contains("code = ") && strLine.Substring(0, CFormat.StringLength("code =")) == "code =") { item.code = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("name = ") && strLine.Substring(0, CFormat.StringLength("name =")) == "name =") { item.name = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("cost = ") && strLine.Substring(0, CFormat.StringLength("cost =")) == "cost =") { item.cost = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("sell = ") && strLine.Substring(0, CFormat.StringLength("sell =")) == "sell =") { item.sell = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("help_string = ") && strLine.Substring(0, CFormat.StringLength("help_string =")) == "help_string =") { item.help_string = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("limit_level = ") && strLine.Substring(0, CFormat.StringLength("limit_level =")) == "limit_level =") { item.limit_level = CFormat.PureString(strLine.Split('=')[1]); } else if (strLine.Contains("=")) { item.more.Add(strLine); } strLine = null; strLine = reader.ReadLine(); } //末了 写一次 m_ItemList.Add(item); reader.Close(); fs.Close(); return(true); }