Save() 공개 메소드

public Save ( String path ) : void
path String
리턴 void
예제 #1
0
파일: VMMFile.cs 프로젝트: maxdup/VMMC
        public void VMMCollapse(string output)
        {
            Console.WriteLine("collapsing VMM");
            // find the topLevel vmf
            List <Dictionary <string, string> > topLevels = vmfs.FindAll(dic => dic.Keys.Contains("TopLevel"));

            if (topLevels.Count == 0)
            {
                TopLevelVmf = vmfs.First();
            }
            else
            {
                TopLevelVmf = topLevels.Aggregate((curMin, x) => (curMin == null || int.Parse(x["TopLevel"]) < int.Parse(curMin["topLevel"]) ? x : curMin));
            }
            vmfs.Remove(TopLevelVmf);

            //start file
            VMFFile topmap = new VMFFile(vmfdir + "/" + TopLevelVmf["File"]);

            VMFVector3Value originVal = new VMFVector3Value {
                X = 0, Y = 0, Z = 0
            };
            VMFVector3Value anglesVal = new VMFVector3Value {
                Pitch = 0, Roll = 0, Yaw = 0
            };
            VMFNumberValue fixup_styleVal = new VMFNumberValue {
                Value = 0
            };

            foreach (Dictionary <string, string> vmf in vmfs)
            {
                Console.WriteLine("Inserting submap of {0}", vmfdir + "/" + vmf["File"]);

                VMFFile submap = new VMFFile(vmfdir + "/" + vmf["File"]);

                foreach (VMFStructure worldStruct in submap.World)
                {
                    if (worldStruct.Type == VMFStructureType.Group || worldStruct.Type == VMFStructureType.Solid)
                    {
                        VMFStructure clone = worldStruct.Clone(topmap.LastID, topmap.LastNodeID);
                        clone.Transform(originVal, anglesVal);
                        topmap.World.Structures.Add(clone);
                    }
                }

                foreach (VMFStructure rootStruct in submap.Root)
                {
                    if (rootStruct.Type == VMFStructureType.Entity)
                    {
                        VMFStructure clone = rootStruct.Clone(topmap.LastID, topmap.LastNodeID);
                        clone.Transform(originVal, anglesVal);
                        topmap.Root.Structures.Add(clone);
                    }
                }
                topmap.updateIds();
            }
            topmap.ResolveInstances();
            topmap.Save(vmfdir + ".vmf");
        }
예제 #2
0
        static void Main(string[] args)
        {
#if !DEBUG
            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
#endif

            List <String> paths   = new List <string>();
            bool          cleanup = false;

            string[] fgdpaths = new string[0];

            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];
                if (!arg.StartsWith("-"))
                {
                    paths.Add(arg);
                }
                else
                {
                    switch (arg.Substring(1).ToLower())
                    {
                    case "c":
                    case "-cleanup":
                        cleanup = true;
                        break;

                    case "d":
                    case "-fgd":
                        fgdpaths = args[++i].Split(',').Select(x => x.Trim()).ToArray();
                        break;
                    }
                }
            }

            if (paths.Count < 1)
            {
                Console.WriteLine("Unexpected arguments. Aborting...");
                return;
            }

            String vmf      = paths[0];
            String rootName = Path.GetDirectoryName(vmf) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(vmf);
            String dest     = (paths.Count >= 2 ? paths[1] : rootName + ".temp.vmf");
            String del      = "Deleting ";
            String renaming = "Renaming {0} to {1}";

            if (cleanup)
            {
                if (File.Exists(dest))
                {
                    Console.WriteLine(del + dest);
                    File.Delete(dest);
                }

                String prt     = rootName + ".prt";
                String tempPrt = rootName + ".temp.prt";

                if (File.Exists(tempPrt))
                {
                    if (File.Exists(prt))
                    {
                        Console.WriteLine(del + prt);
                        File.Delete(prt);
                    }

                    Console.WriteLine(renaming, tempPrt, prt);
                    File.Move(tempPrt, prt);
                }

                String lin     = rootName + ".lin";
                String tempLin = rootName + ".temp.lin";

                if (File.Exists(lin))
                {
                    Console.WriteLine(del + lin);
                    File.Delete(lin);
                }

                if (File.Exists(tempLin))
                {
                    Console.WriteLine(renaming, tempLin, lin);
                    File.Move(tempLin, lin);
                }
            }
            else
            {
                foreach (String path in fgdpaths)
                {
                    VMFStructure.ParseFGD(path);
                }

                VMFFile file = new VMFFile(vmf);
                file.ResolveInstances();
                file.Save(dest);
            }

#if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
#endif
        }
예제 #3
0
        static void Main(string[] args)
        {
            #if !DEBUG
            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
            #endif

            List<String> paths = new List<string>();
            bool cleanup = false;

            string[] fgdpaths = new string[0];

            for (int i = 0; i < args.Length; ++i) {
                string arg = args[i];
                if (!arg.StartsWith("-"))
                    paths.Add(arg);
                else {
                    switch (arg.Substring(1).ToLower()) {
                        case "c":
                        case "-cleanup":
                            cleanup = true;
                            break;
                        case "d":
                        case "-fgd":
                            fgdpaths = args[++i].Split(',').Select(x => x.Trim()).ToArray();
                            break;
                    }
                }
            }

            if (paths.Count < 1) {
                Console.WriteLine("Unexpected arguments. Aborting...");
                return;
            }

            String vmf = paths[0];
            String rootName = Path.GetDirectoryName(vmf) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(vmf);
            String dest = (paths.Count >= 2 ? paths[1] : rootName + ".temp.vmf");
            String del = "Deleting ";
            String renaming = "Renaming {0} to {1}";

            if (cleanup) {
                if (File.Exists(dest)) {
                    Console.WriteLine(del + dest);
                    File.Delete(dest);
                }

                String prt = rootName + ".prt";
                String tempPrt = rootName + ".temp.prt";

                if (File.Exists(tempPrt)) {
                    if (File.Exists(prt)) {
                        Console.WriteLine(del + prt);
                        File.Delete(prt);
                    }

                    Console.WriteLine(renaming, tempPrt, prt);
                    File.Move(tempPrt, prt);
                }

                String lin = rootName + ".lin";
                String tempLin = rootName + ".temp.lin";

                if (File.Exists(lin))
                {
                    Console.WriteLine(del + lin);
                    File.Delete(lin);
                }

                if (File.Exists(tempLin))
                {
                    Console.WriteLine(renaming, tempLin, lin);
                    File.Move(tempLin, lin);
                }
            } else {
                foreach (String path in fgdpaths) {
                    VMFStructure.ParseFGD(path);
                }

                VMFFile file = new VMFFile(vmf);
                file.ResolveInstances();
                file.Save(dest);
            }

            #if DEBUG
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
            #endif
        }