public ArrayList LoadFileByCharSetForPRO(string FileName, string CharSet) { try { Clear(); StreamReader sr = new StreamReader(FileName, System.Text.Encoding.GetEncoding(CharSet)); int lastNumber = 0; int currentDeck = 0; ArrayList lastList = new ArrayList(); while (!sr.EndOfStream) { string s = sr.ReadLine().Trim(); if (s.StartsWith("!side")) { currentDeck = 2; continue; } else if (s.StartsWith("#wait list")) { currentDeck = 3; continue; } else if (s.Length == 0 || s.StartsWith("#") || s.StartsWith("!")) { continue; } CardDescription card = null; string lastname = s; if (currentDeck == 3) { lastname = s.Substring(1); } card = CardLibrary.GetInstance().GetCardByCheatCode(lastname); string text = null; if (card != null) { string err = null; switch (currentDeck) { case 0: if (CardDescription.isExtraCard(card)) { err = ExtraDeck.AddCard(card.ID, -1, text); } else { err = MainDeck.AddCard(card.ID, -1, text); } break; case 1: err = ExtraDeck.AddCard(card.ID, -1, text); break; case 2: err = SideDeck.AddCard(card.ID, -1, text); break; case 3: err = TempDeck.AddCard(card.ID, -1, text); break; } if (err != null) { lastNumber++; lastList.Add(card.name); } } else { lastNumber++; lastList.Add(lastname); } } sr.Close(); deckname = Regex.Replace(FileName, @".[^.]*$", ""); deckname = Regex.Replace(deckname, @"^.*\\", ""); MainDeck.isChanged = false; SideDeck.isChanged = false; ExtraDeck.isChanged = false; TempDeck.isChanged = false; return(lastList); } catch { Clear(); return(null); } }
public ArrayList LoadFileByCharSet(string FileName, string CharSet) { try { Clear(); StreamReader sr = new StreamReader(FileName, System.Text.Encoding.GetEncoding(CharSet)); int lastNumber = 0; int currentDeck = 0; ArrayList lastList = new ArrayList(); while (!sr.EndOfStream) { string s = sr.ReadLine().Trim(); if (s.StartsWith("====")) { currentDeck = 1; continue; } else if (s.StartsWith("####")) { currentDeck = 2; continue; } else if (s.StartsWith("$$$$")) { currentDeck = 3; continue; } else if (s.Length == 0) { continue; } CardDescription card = null; string text = ""; string lastname = null; if (s[0] == '[') { Match match = regex1.Match(s); string name = match.Groups["name"].Value; text = match.Groups["text"].Value; //string name = s.Substring(s.LastIndexOf('[') + 1, s.LastIndexOf(']') - s.LastIndexOf('[') - 1); lastname = name; card = CardLibrary.GetInstance().GetCardByName(name); if (card == null) { card = CardLibrary.GetInstance().GetCardByOldName(name); } } else { string japname = CharacterSet.JPSBCToDBC(s); lastname = japname; card = CardLibrary.GetInstance().GetCardByJapName(japname); } if (card != null) { string err = null; switch (currentDeck) { case 0: if (CardDescription.isExtraCard(card)) { err = ExtraDeck.AddCard(card.ID, -1, text); } else { err = MainDeck.AddCard(card.ID, -1, text); } break; case 1: err = ExtraDeck.AddCard(card.ID, -1, text); break; case 2: err = SideDeck.AddCard(card.ID, -1, text); break; case 3: err = TempDeck.AddCard(card.ID, -1, text); break; } if (err != null) { lastNumber++; lastList.Add(card.name); } } else { lastNumber++; lastList.Add(lastname); } } sr.Close(); deckname = Regex.Replace(FileName, @".[^.]*$", ""); deckname = Regex.Replace(deckname, @"^.*\\", ""); MainDeck.isChanged = false; SideDeck.isChanged = false; ExtraDeck.isChanged = false; TempDeck.isChanged = false; return(lastList); } catch { Clear(); return(null); } }