Ejemplo n.º 1
0
 static void ListGames()
 {
     if (Directory.Exists("games"))
     {
         string[] files = Directory.GetFileSystemEntries("games");
         foreach (string s in files)
         {
             GameFile file = new GameFile();
             if (file.ReadFile(s + "/game.sgm")) {
                 string name, author, desc;
                 file.TryGetData("name", out name);
                 file.TryGetData("author", out author);
                 file.TryGetData("description", out desc);
                 Console.WriteLine(string.Format("{0} by {1}, \"{2}\"", name, author, desc));
             }
         }
     }
 }
Ejemplo n.º 2
0
        static ArrayInstance GetGameList()
        {
            string directory = GlobalProps.EnginePath + "/games";
            ArrayInstance array = _engine.Array.New();
            if (!Directory.Exists(directory)) return array;

            string[] files = Directory.GetDirectories(directory);
            for (uint i = 0; i < files.Length; ++i) {
                GameFile file = new GameFile();
                if (!file.ReadFile(files[i] + "/game.sgm")) continue;
                string name;

                ObjectInstance obj = CreateObject();
                obj["name"] = (file.TryGetData("name", out name)) ? name : "";
                obj["description"] = (file.TryGetData("description", out name)) ? name : "";
                obj["author"] = (file.TryGetData("author", out name)) ? name : "";
                obj["directory"] = Path.GetFileName(files[i]);

                ArrayInstance.Push(array, obj);
            }

            return array;
        }