Esempio n. 1
0
        static public List <string> LoadFile(string filename)
        {
            List <string> gameNames = new List <string>();

            using (StreamReader iStream = new StreamReader(filename, true)) {
                try {
                    string       iLine;
                    GameLineType regular = GameLineType.comment;
                    while ((iLine = iStream.ReadLine()) != null)
                    {
                        if (iLine[0] == '*')
                        {
                            GameList.AddLine(GameLineType.end, iLine);
                            regular = GameLineType.comment;
                            continue;
                        }
                        if (iLine[0] == '[')
                        {
                            regular = GameLineType.game;
                            const string pattern = @"^\[([^[]*)\].*$";
                            Match        m       = Regex.Match(iLine, pattern, RegexOptions.IgnoreCase);
                            //if(!m.Success)
                            //	return -1;
                            gameNames.Add(m.Groups[1].Value);                                           //	Extract "[...]" from string
                        }
                        GameList.AddLine(regular, iLine);
                    }
                    GameList.EndItem();
                } catch (Exception ex) {
                    string msg = "Error: Could not read file from disk. Original error: " + ex.Message;
                    //MessageBox.Show(msg);
                }
            }
            return(gameNames);
        }
Esempio n. 2
0
        static public List <string> LoadFile(string filename)
        {
            List <string> gameNames = new List <string>();

            using (StreamReader iStream = new StreamReader(filename, true)) {
                try {
                    string       iLine;
                    GameLineType regular = GameLineType.comment;
                    while ((iLine = iStream.ReadLine()) != null)
                    {
                        if (iLine.Length > 0)
                        {
                            if (iLine[0] == '*')
                            {
                                GameFile.AddLine(GameLineType.end, iLine);
                                regular = GameLineType.comment;
                                continue;
                            }
                            if (iLine[0] == '[')
                            {
                                regular = GameLineType.game;
                                gameNames.Add(iLine.Replace("\t", "  "));
                            }
                        }
                        GameFile.AddLine(regular, iLine);
                    }
                    GameFile.EndItem();
                } catch (Exception ex) {
                    string msg = "Error: Could not read file from disk. Original error: " + ex.Message;
                }
            }
            return(gameNames);
        }
Esempio n. 3
0
 static void AddLine(GameLineType type, string line)
 {
     if (type != gameItemType)
     {
         if (type != GameLineType.end)
         {
             EndItem();
         }
         gameItemType = type;
     }
     if (listItem == null)
     {
         listItem = new List <string>();
     }
     listItem.Add(line);
 }
Esempio n. 4
0
 static public void InitList()
 {
     listGames    = new List <List <string> >();
     gameItemType = GameLineType.none;
 }