예제 #1
0
        static void Main(string[] args)
        {
#if DEBUG
            var vmfPath    = Path.GetFullPath(@".\..\..\Tests\dev_room.vmf");
            var configPath = Path.GetFullPath(@".\..\..\Tests\remotecompile.cfg");
#else
            var vmfPath    = "path.vmf";
            var configPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "remotecompile.cfg");
#endif
            //TODO: Take parameter of map to compile
            //TODO: Take parameter of maps root path for instances
            //      Temporarily use vmf location
            var mapsRoot = Path.GetDirectoryName(vmfPath);

            //TODO: Take optional parameter of config file path
            //TODO: Load local config file, if it doesn't exist, create a default one

            Config config;
            if (File.Exists(configPath))
            {
                //TODO: Load config
            }
            else
            {
                #region Create default config
                config = new Config(new List <IVNode>
                {
                    new VBlock("RemoteCompileConfig", new List <IVNode>
                    {
                        new VBlock("BuildServer", new List <IVNode>
                        {
                            new VProperty("Address", "127.0.0.1")
                            , new VProperty("Port", "9043")
                            , new VProperty("Username", "")
                            , new VProperty("Password", "")
                            , new VBlock("AuthLock", new List <IVNode>
                            {
                                new VProperty("Token", "")
                                , new VProperty("Expires", "")
                            })
                        })
                        , new VProperty("BuildTarget", "Source SDK 2013")

                        //TODO: Add all available VBSP, VVIS, VRAD parameters
                        , new VBlock("VBSP", new List <IVNode>
                        {
                            new VProperty("", "")
                        })
                        , new VBlock("VVIS", new List <IVNode>
                        {
                            new VProperty("", "")
                        })
                        , new VBlock("VRAD", new List <IVNode>
                        {
                            new VProperty("", "")
                        })
                    })
                });

                File.WriteAllLines(configPath, config.ToVMFStrings());
                #endregion
            }

            // Load VMF
            if (!File.Exists(vmfPath))
            {
                // Early exit
                Console.WriteLine("Map does not exist \"{0}\"", vmfPath);
                return;
            }

            var vmfFileContents = File.ReadAllLines(vmfPath);
            var vmf             = new VMF(vmfFileContents);

            // Recursively identify and load dependent instances
            // Track instance dependency tree to recognize instance recursion
            // Only dig 100 levels deep unless otherwise specified in the config
            var instanceTree = new Dictionary <int, Tuple <string, List <int> > >();
            BuildInstanceTree(instanceTree, 100, 0, vmf, vmfPath, BuildInstanceDictionaryKeyIndex++, mapsRoot);

            //TODO: Make sure there is no recursion in the instanceTree

            //TODO: Request hashes of all dependent resources from server.
            //      Compare results to local copies.
            //      Notify user of the comparison


            //TODO: Send compile request with serialized parameters, and list of incoming resources

            //TODO: Send copy of vmf and instances to server

            //TODO: Spin off waiting thread for server to execute OnCompleteBuild commands
            //      This could include: downloading the map, and running the game
        }
예제 #2
0
        static int Main(string[] args)
        {
            #if DEBUG
            //args = new string[] { "-file", "dev_room.vmf" };
            args = new string[] { "-file", "1_instance.vmf" };

            Utils.DirectoryCopy(@"../../instances", "instances", true, true);
            #endif

            #if !DEBUG
            try
            {
            #endif
            #region Get execution parameters
            string filePath = null;
            string gamePath = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-file" && i + 1 < args.Length && !args[i + 1].StartsWith("-"))
                {
                    filePath = args[++i];
                }
                else if (args[i] == "-game" && i + 1 < args.Length && !args[i + 1].StartsWith("-"))
                {
                    gamePath = args[++i]; //does this matter, or should I use the vmfs path to find the instances
                }
                // else if // Add additional parameters here
            }
            if (filePath == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                return 1;
            }
            #endregion

            #region Load VMF
            Console.Write("Loading file contents from \"" + filePath + "\"...");
            string[] fileContents = File.ReadAllLines(filePath);
            Console.WriteLine("Complete.");

            Console.Write("Parsing vmf ");
            VMF vmf = new VMF(fileContents);
            #endregion

            CollapseInstances(vmf);

            #region Save Altered VMF
            string newFilePath = "";
            newFilePath = filePath.EndsWith(".vmf")
                ? filePath.Insert(filePath.LastIndexOf("."), "_new")
                : filePath + "_new";

            File.WriteAllLines(newFilePath, vmf.ToVMFStrings());
            #endregion

            #if !DEBUG
            }
            #region catch - display exception
            catch (Exception ex)
            {
                WriteLine("Exception:", ConsoleColor.Yellow);
                WriteLine(ex.ToString(), ConsoleColor.Red);
                return 1;
            }
            #endregion
            #endif

            return 0;
        }
예제 #3
0
파일: VMFAdapter.cs 프로젝트: 1upD/Nails
        /**
         * Exports the given NailsMap to a VMF file. Uses the file name passed in when this adapter was constructed.
         * <author>1upD</author>
         */
        public void Export(NailsMap map)
        {
            try
            {
                log.Info(string.Format("Exporting Nails map data to VMF file: {0}", this._filename));

                // Make a deep copy of the stored VMF to add instances to
                VMF output_vmf = new VMFParser.VMF(this._vmf.ToVMFStrings());
                int i          = 0;

                foreach (NailsCube cube in map.NailsCubes)
                {
                    int x_pos = cube.X * this._horizontal_scale;
                    int y_pos = cube.Y * this._horizontal_scale;
                    int z_pos = cube.Z * this._vertical_scale;

                    var faces = cube.GetFaces();

                    if (faces.Contains(NailsCubeFace.Floor))
                    {
                        instanceData instance = this.MakeInstance("floor", cube.StyleName, 0, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }

                    if (faces.Contains(NailsCubeFace.Front))
                    {
                        instanceData instance = this.MakeInstance("wall", cube.StyleName, 0, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }

                    if (faces.Contains(NailsCubeFace.Left))
                    {
                        instanceData instance = this.MakeInstance("wall", cube.StyleName, 90, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }

                    if (faces.Contains(NailsCubeFace.Back))
                    {
                        instanceData instance = this.MakeInstance("wall", cube.StyleName, 180, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }

                    if (faces.Contains(NailsCubeFace.Right))
                    {
                        instanceData instance = this.MakeInstance("wall", cube.StyleName, 270, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }

                    if (faces.Contains(NailsCubeFace.Ceiling))
                    {
                        instanceData instance = this.MakeInstance("ceiling", cube.StyleName, 0, i++, x_pos, y_pos, z_pos);
                        insertInstanceIntoVMF(instance, output_vmf);
                    }
                }


                using (StreamWriter sw = new StreamWriter(new FileStream(this._filename, FileMode.Create)))
                {
                    var vmfStrings = output_vmf.ToVMFStrings();
                    foreach (string line in vmfStrings)
                    {
                        sw.WriteLine(line);
                    }
                }

                log.Info(string.Format("Wrote to VMF file: {0}", this._filename));
            } catch (Exception e)
            {
                log.Error("VMFAdapter.Export(): Caught exception: ", e);
                log.Info(string.Format("Failed to write to VMF file: {0}", this._filename));
            }
        }
 static void Main(string[] args)
 {
     #if DEBUG
     args = new string[] { "preview.vmf" }; //REMOVE TEST DATA WHEN DEPLOYING :P
     #endif
     try
     {
         string fileName = args.FirstOrDefault();
         vmf = new VMF(File.ReadAllLines(fileName));
         if (TagModifications())
             File.WriteAllLines(fileName, vmf.ToVMFStrings());
     }
     catch (Exception ex)
     {
         File.WriteAllText("errors.txt", ex.ToString());
     }
 }