Ejemplo n.º 1
0
        static string[] GetVPKFileList(string VPKPath)
        {
            string arguments = $"l \"{VPKPath}\"";

            var p = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    WorkingDirectory       = Path.GetDirectoryName(vpk),
                    FileName               = vpk,
                    Arguments              = arguments,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true,
                }
            };

            p.Start();

            string output    = p.StandardOutput.ReadToEnd();
            string errOutput = p.StandardError.ReadToEnd();

            if (verbose)
            {
                CompilePalLogger.Log(errOutput);
            }

            p.WaitForExit();

            char[] delims = new[] { '\r', '\n' };
            return(output.Split(delims, StringSplitOptions.RemoveEmptyEntries));
        }
Ejemplo n.º 2
0
        private void AddMapButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            if (GameConfigurationManager.GameConfiguration.SDKMapFolder != null)
            {
                dialog.InitialDirectory = GameConfigurationManager.GameConfiguration.SDKMapFolder;
            }

            dialog.Multiselect = true;
            dialog.Filter      = "Map files (*.vmf;*.vmm)|*.vmf;*.vmm";

            try
            {
                dialog.ShowDialog();
            }
            catch
            {
                CompilePalLogger.LogDebug($"AddMapButton dialog failed to open, falling back to {Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}");
                // if dialog fails to open it's possible its initial directory is in a non existant folder or something
                dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                dialog.ShowDialog();
            }

            foreach (var file in dialog.FileNames)
            {
                CompilingManager.MapFiles.Add(file);
            }
        }
Ejemplo n.º 3
0
        static void PackFileList(CompileContext context, string outputFile)
        {
            if (File.Exists(context.BSPFile))
            {
                if (File.Exists(context.BSPFile + ".unpacked"))
                {
                    CompilePalLogger.LogLineDebug($"Deleting: {context.BSPFile}.unpacked");
                    File.Delete(context.BSPFile + ".unpacked");
                }

                CompilePalLogger.LogLineDebug($"Copying {context.BSPFile} to {context.BSPFile}.unpacked");
                File.Copy(context.BSPFile, context.BSPFile + ".unpacked");
            }

            CompilePalLogger.LogLine("Running bspzip...");
            PackBSP(outputFile);

            // don't copy if vmf directory is also the output directory
            if (bspPath != context.BSPFile)
            {
                if (File.Exists(context.BSPFile))
                {
                    CompilePalLogger.LogLineDebug($"Deleting: {context.BSPFile}");
                    File.Delete(context.BSPFile);
                }

                CompilePalLogger.LogLine("Copying packed bsp to vmf folder...");
                CompilePalLogger.LogLineDebug($"Copying {bspPath} to {context.BSPFile}");
                File.Copy(bspPath, context.BSPFile);
            }
        }
Ejemplo n.º 4
0
 private void ProcessOnOutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (e.Data != null)
     {
         CompilePalLogger.LogLine(e.Data);
     }
 }
Ejemplo n.º 5
0
        public static void CancelCompile()
        {
            try
            {
                compileThread.Abort();
            }
            catch
            {
            }
            IsCompiling = false;

            foreach (var compileProcess in ConfigurationManager.CompileProcesses.Where(cP => cP.Process != null))
            {
                try
                {
                    compileProcess.Cancel();
                    compileProcess.Process.Kill();

                    CompilePalLogger.LogLineColor("Killed {0}.", Brushes.OrangeRed, compileProcess.Metadata.Name);
                }
                catch (InvalidOperationException) { }
                catch (Exception e) { ExceptionHandler.LogException(e); }
            }

            ProgressManager.SetProgress(0);

            CompilePalLogger.LogLineColor("Compile forcefully ended.", Brushes.OrangeRed);

            postCompile(null);
        }
Ejemplo n.º 6
0
        static void UnpackBSP(string unpackDir)
        {
            // unpacks the pak file and extracts it to a temp location

            /* info: vbsp.exe creates files in the pak file that may have
             * dependencies that are not listed anywhere else, as is the
             * case for water materials. We use this method to extract the
             * pak file to a temp folder and read the dependencies of its files. */

            string arguments = "-extractfiles \"$bspold\" \"$dir\"";

            arguments = arguments.Replace("$bspold", bspPath);
            arguments = arguments.Replace("$dir", unpackDir);

            var startInfo = new ProcessStartInfo(bspZip, arguments);

            startInfo.UseShellExecute                  = false;
            startInfo.CreateNoWindow                   = true;
            startInfo.RedirectStandardOutput           = true;
            startInfo.EnvironmentVariables["VPROJECT"] = gameFolder;

            var p = new Process {
                StartInfo = startInfo
            };

            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            if (verbose)
            {
                CompilePalLogger.Log(output);
            }
            p.WaitForExit();
        }
Ejemplo n.º 7
0
 private void ProcessOnErrorDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (e.Data != null)
     {
         CompilePalLogger.LogLineColor(e.Data, Error.GetSeverityBrush(4));
     }
 }
Ejemplo n.º 8
0
        static void ThreadedCheck()
        {
            try
            {
                CompilePalLogger.LogLine("Fetching update information...");

                var    c          = new WebClient();
                string newVersion = c.DownloadString(new Uri(UpdateURL));

                LatestVersion = int.Parse(newVersion);

                if (CurrentVersion < LatestVersion)
                {
                    MainWindow.ActiveDispatcher.Invoke(OnUpdateFound);

                    CompilePalLogger.LogLine("Updater found that Compile Pal is outdated.");
                }
                else
                {
                    CompilePalLogger.LogLine("Updater found that Compile Pal is up to date.");
                }

                ProgressManager.SetProgress(ProgressManager.Progress);
            }
            catch (WebException e)
            {
                CompilePalLogger.LogLine("Failed to find update information as an error was returned:");
                CompilePalLogger.LogLine(e.ToString());
            }
        }
        public static List <GameConfiguration> Parse(string filename)
        {
            var lines     = File.ReadAllLines(filename);
            var gameInfos = new List <GameConfiguration>();

            var data = new KV.FileData(filename);

            foreach (KV.DataBlock gamedb in data.headnode.GetFirstByName(new [] { "\"Configs\"", "\"GameConfig.txt\"" }).GetFirstByName("\"Games\"").subBlocks)
            {
                string       binfolder = Path.GetDirectoryName(filename);
                KV.DataBlock hdb       = gamedb.GetFirstByName("\"Hammer\"");

                CompilePalLogger.LogLine($"Gamedb: {gamedb}");
                GameConfiguration game = new GameConfiguration
                {
                    Name         = gamedb.name.Replace("\"", ""),
                    BinFolder    = binfolder,
                    GameFolder   = GetFullPath(gamedb.TryGetStringValue("GameDir"), binfolder),
                    GameEXE      = GetFullPath(hdb.TryGetStringValue("GameExe"), binfolder),
                    SDKMapFolder = GetFullPath(hdb.TryGetStringValue("MapDir"), binfolder),
                    VBSP         = GetFullPath(hdb.TryGetStringValue("BSP"), binfolder),
                    VVIS         = GetFullPath(hdb.TryGetStringValue("Vis"), binfolder),
                    VRAD         = GetFullPath(hdb.TryGetStringValue("Light"), binfolder),
                    MapFolder    = GetFullPath(hdb.TryGetStringValue("BSPDir"), binfolder)
                };

                gameInfos.Add(game);
            }

            return(gameInfos);
        }
Ejemplo n.º 10
0
        private static void postCompile(List <Error> errors)
        {
            CompilePalLogger.LogLineColor(string.Format("'{0}' compile finished in {1}", ConfigurationManager.CurrentPreset, compileTimeStopwatch.Elapsed.ToString(@"hh\:mm\:ss")), Brushes.ForestGreen);

            if (errors != null && errors.Any())
            {
                int maxSeverity = errors.Max(s => s.Severity);

                var severityBrush = Error.GetSeverityBrush(maxSeverity);

                CompilePalLogger.LogLineColor("{0} errors/warnings logged:", severityBrush, errors.Count);

                int i = 0;
                foreach (var error in errors)
                {
                    i++;

                    string errorText = string.Format("({0}) - ({1})", i, Error.GetSeverityText(error.Severity)) + Environment.NewLine;

                    CompilePalLogger.LogCompileError(errorText, error);

                    if (error.Severity >= 3)
                    {
                        AnalyticsManager.CompileError();
                    }
                }
            }

            OnFinish();

            compileTimeStopwatch.Reset();

            IsCompiling = false;
        }
Ejemplo n.º 11
0
        public void FetchHDRLevels()
        {
            CompilePalLogger.LogLine("Detecting HDR levels...");
            var startInfo = new ProcessStartInfo(vbspInfo, "\"" + bspFile + "\"");

            startInfo.UseShellExecute        = false;
            startInfo.CreateNoWindow         = true;
            startInfo.RedirectStandardOutput = true;

            var p = new Process {
                StartInfo = startInfo
            };

            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            if (p.ExitCode != 0)
            {
                CompilePalLogger.LogLine("Could not read HDR levels, defaulting to one.");
            }
            else
            {
                Regex  re       = new Regex(@"^LDR\sworldlights\s+.*", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                string LDRStats = re.Match(output).Value.Trim();
                re = new Regex(@"^HDR\sworldlights\s+.*", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                string HDRStats = re.Match(output).Value.Trim();
                LDR = !LDRStats.Contains(" 0/");
                HDR = !HDRStats.Contains(" 0/");
            }
        }
Ejemplo n.º 12
0
        static void PackBSP()
        {
            string arguments = "-addlist \"$bspnew\"  \"$list\" \"$bspold\"";

            arguments = arguments.Replace("$bspnew", bspPath);
            arguments = arguments.Replace("$bspold", bspPath);
            arguments = arguments.Replace("$list", "files.txt");

            var startInfo = new ProcessStartInfo(bspZip, arguments);

            startInfo.UseShellExecute                  = false;
            startInfo.RedirectStandardOutput           = true;
            startInfo.CreateNoWindow                   = true;
            startInfo.EnvironmentVariables["VPROJECT"] = gameFolder;

            var p = new Process {
                StartInfo = startInfo
            };

            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            if (verbose)
            {
                CompilePalLogger.Log(output);
            }
            p.WaitForExit();
        }
Ejemplo n.º 13
0
        public static void Init()
        {
            if (File.Exists(mapFiles))
            {
                var list    = JsonConvert.DeserializeObject <List <object> >(File.ReadAllText(mapFiles));
                var mapList = new List <Map>();

                // make this backwards compatible by allowing plain string values in maplist array (old format)
                foreach (var item in list)
                {
                    if (item is string mapFile)
                    {
                        mapList.Add(new Map(mapFile));
                    }
                    else if (item is JObject obj)
                    {
                        mapList.Add(obj.ToObject <Map>());
                    }
                    else
                    {
                        CompilePalLogger.LogDebug($"Failed to load item from mapfiles: {item}");
                    }
                }

                CompilingManager.MapFiles = new TrulyObservableCollection <Map>(mapList);
            }

            CompilingManager.MapFiles.CollectionChanged +=
                delegate
            {
                File.WriteAllText(mapFiles, JsonConvert.SerializeObject(CompilingManager.MapFiles, Formatting.Indented));
            };
        }
Ejemplo n.º 14
0
        private void readOutput()
        {
            char[]     buffer = new char[256];
            Task <int> read   = null;

            while (true)
            {
                if (read == null)
                {
                    read = Process.StandardOutput.ReadAsync(buffer, 0, buffer.Length);
                }

                read.Wait(100); // an arbitray timeout

                if (read.IsCompleted)
                {
                    if (read.Result > 0)
                    {
                        string text = new string(buffer, 0, read.Result);

                        CompilePalLogger.ProgressiveLog(text);

                        read = null; // ok, this task completed so we need to create a new one
                        continue;
                    }

                    // got -1, process ended
                    break;
                }
            }
            Process.WaitForExit();
        }
Ejemplo n.º 15
0
        static void ThreadedCheck()
        {
            try
            {
                CompilePalLogger.LogLine("Fetching update information...");

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                var    c          = new WebClient();
                string newVersion = GetValidVersionString(c.DownloadString(new Uri(isPrerelease ? LatestPrereleaseVersionURL : LatestVersionURL)));

                latestVersion = Version.Parse(newVersion);

                if (currentVersion < latestVersion)
                {
                    MainWindow.ActiveDispatcher.Invoke(OnUpdateFound);

                    CompilePalLogger.LogLine("Updater found that Compile Pal Multi is outdated.");
                }
                else
                {
                    CompilePalLogger.LogLine("Updater found that Compile Pal Multi is up to date.");
                }

                ProgressManager.SetProgress(ProgressManager.Progress);
            }
            catch (WebException e)
            {
                CompilePalLogger.LogLine("Failed to find update information as an error was returned:");
                CompilePalLogger.LogLine(e.ToString());
            }
        }
Ejemplo n.º 16
0
        public CompileProcess(string name)
        {
            string jsonMetadata = Path.Combine(ParameterFolder, name, "meta.json");

            if (File.Exists(jsonMetadata))
            {
                Metadata = JsonConvert.DeserializeObject <CompileMetadata>(File.ReadAllText(jsonMetadata));

                CompilePalLogger.LogLine("Loaded JSON metadata {0} from {1} at order {2}", Metadata.Name, jsonMetadata, Metadata.Order);
            }
            else
            {
                string legacyMetadata = Path.Combine(ParameterFolder, name + ".meta");

                if (File.Exists(legacyMetadata))
                {
                    Metadata = LoadLegacyData(legacyMetadata);

                    Directory.CreateDirectory(Path.Combine(ParameterFolder, name));

                    File.WriteAllText(jsonMetadata, JsonConvert.SerializeObject(Metadata, Formatting.Indented));

                    CompilePalLogger.LogLine("Loaded CSV metadata {0} from {1} at order {2}, converted to JSON successfully.", Metadata.Name, legacyMetadata, Metadata.Order);
                }
                else
                {
                    throw new FileNotFoundException("The metadata file for " + name + " could not be found.");
                }
            }



            ParameterList = ConfigurationManager.GetParameters(Metadata.Name, Metadata.DoRun);
        }
Ejemplo n.º 17
0
        static void PackVPK(string targetVPK, string responseFile, string searchPath)
        {
            string arguments = $"a \"{targetVPK}\" \"@{responseFile}\"";

            var p = new Process
            {
                StartInfo = new ProcessStartInfo

                {
                    WorkingDirectory       = searchPath,
                    FileName               = vpk,
                    Arguments              = arguments,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true,
                }
            };

            //p.StartInfo.EnvironmentVariables["VPROJECT"] = gameFolder;
            p.Start();

            string output    = p.StandardOutput.ReadToEnd();
            string errOutput = p.StandardError.ReadToEnd();

            if (verbose)
            {
                CompilePalLogger.Log(output);
                CompilePalLogger.Log(errOutput);
            }


            p.WaitForExit();
        }
Ejemplo n.º 18
0
        private static void CompileThreaded()
        {
            try
            {
                ProgressManager.SetProgress(0);

                var compileErrors = new List <Error>();

                foreach (string mapFile in MapFiles)
                {
                    CompilePalLogger.LogLine(string.Format("Starting compilation of {0}", mapFile));

                    foreach (var compileProcess in ConfigurationManager.CompileProcesses.Where(c => c.DoRun))
                    {
                        compileProcess.Run(GameConfigurationManager.BuildContext(mapFile));

                        if (compileProcess is CompileExecutable)
                        {
                            var executable = compileProcess as CompileExecutable;

                            compileErrors.AddRange(executable.CompileErrors);
                        }

                        ProgressManager.Progress += (1d / ConfigurationManager.CompileProcesses.Count(c => c.DoRun)) / MapFiles.Count;
                    }
                }

                MainWindow.ActiveDispatcher.Invoke(() => postCompile(compileErrors));
            }
            catch (ThreadAbortException) { ProgressManager.ErrorProgress(); }
        }
Ejemplo n.º 19
0
        public static void LogException(Exception e, bool crash = true)
        {
            if (!Directory.Exists(CompilePalPath.Directory + "CrashLogs"))
            {
                Directory.CreateDirectory(CompilePalPath.Directory + "CrashLogs");
            }


            CompilePalLogger.LogLine("An exception was caught by the ExceptionHandler:");
            CompilePalLogger.LogLine(e.ToString());
            if (e.InnerException != null)
            {
                CompilePalLogger.LogLine(e.InnerException.ToString());
            }

            try {
                AnalyticsManager.Error();//risky, but /interesting/
            } catch (Exception) {}

            if (crash)
            {
                string crashLogName = DateTime.Now.ToString("s").Replace(":", "-");

                File.WriteAllText(Path.Combine("CrashLogs", crashLogName + ".txt"), e.ToString() + e.InnerException ?? "");

                Thread.Sleep(2000);
                Environment.Exit(0);
            }
        }
Ejemplo n.º 20
0
        private static void AssemblePresets()
        {
            if (!Directory.Exists(PresetsFolder))
            {
                Directory.CreateDirectory(PresetsFolder);
            }

            //get a list of presets from the directories in the preset folder
            var presets = Directory.GetDirectories(PresetsFolder);

            //clear old lists
            KnownPresets.Clear();

            foreach (var process in CompileProcesses)
            {
                process.PresetDictionary.Clear();
            }

            foreach (string presetPath in presets)
            {
                string preset = Path.GetFileName(presetPath);
                foreach (var process in CompileProcesses)
                {
                    string file = Path.Combine(presetPath, process.PresetFile);
                    if (File.Exists(file))
                    {
                        process.PresetDictionary.Add(preset, new ObservableCollection <ConfigItem>());
                        //read the list of preset parameters
                        var lines = File.ReadAllLines(file);

                        foreach (var line in lines)
                        {
                            var item = ParsePresetLine(line);

                            if (process.ParameterList.Any(c => c.Parameter == item.Parameter))
                            {
                                //remove .clone if you are a m*******t and wish to enter the object oriented version of hell
                                var equivalentItem = (ConfigItem)process.ParameterList.FirstOrDefault(c => c.Parameter == item.Parameter).Clone();

                                equivalentItem.Value = item.Value;

                                //Copy extra information stored for custom programs
                                if (item.Parameter == "program")
                                {
                                    equivalentItem.Value2  = item.Value2;
                                    equivalentItem.Warning = item.Warning;
                                }


                                process.PresetDictionary[preset].Add(equivalentItem);
                            }
                        }
                    }
                }
                CompilePalLogger.LogLine("Added preset {0} for processes {1}", preset, string.Join(", ", CompileProcesses));
                CurrentPreset = preset;
                KnownPresets.Add(preset);
            }
        }
Ejemplo n.º 21
0
        public override void Run(CompileContext context)
        {
            CompilePalLogger.LogLine("\nCompilePal - Nav Generator");
            mapname      = System.IO.Path.GetFileName(context.BSPFile).Replace(".bsp", "");
            mapnav       = context.CopyLocation.Replace(".bsp", ".nav");
            mapcfg       = context.Configuration.GameFolder + "/cfg/" + mapname + ".cfg";
            mapCFGBackup = context.Configuration.GameFolder + "/cfg/" + mapname + "_cpalbackup.cfg";

            hidden = GetParameterString().Contains("-hidden");

            string args = "-game \"" + context.Configuration.GameFolder + "\" -windowed -novid -nosound +sv_cheats 1 +map " + mapname;

            if (hidden)
            {
                args += " -noborder -x 4000 -y 2000";
            }

            var startInfo = new ProcessStartInfo(context.Configuration.GameEXE, args);

            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow  = false;

            CompilePalLogger.LogLine("Generating...");
            if (File.Exists(mapcfg))
            {
                if (File.Exists(mapCFGBackup))
                {
                    System.IO.File.Delete(mapCFGBackup);
                }
                System.IO.File.Move(mapcfg, mapCFGBackup);
            }

            System.IO.File.Create(mapcfg).Dispose();
            TextWriter tw = new StreamWriter(mapcfg);

            tw.WriteLine("nav_generate");
            tw.Close();

            Process = new Process {
                StartInfo = startInfo
            };
            Process.Start();

            FileSystemWatcher fw = new FileSystemWatcher();

            fw.Path                = System.IO.Path.GetDirectoryName(mapnav);
            fw.Filter              = "*.nav";
            fw.NotifyFilter        = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
            fw.Changed            += new FileSystemEventHandler(fileSystemWatcher_NavCreated);
            fw.Created            += new FileSystemEventHandler(fileSystemWatcher_NavCreated);
            fw.EnableRaisingEvents = true;

            Process.WaitForExit();
            fw.Dispose();

            cleanUp();
            CompilePalLogger.LogLine("nav file complete!");
        }
Ejemplo n.º 22
0
        private static void CompileThreaded()
        {
            try
            {
                ProgressManager.SetProgress(0);

                var mapErrors = new List <MapErrors>();


                foreach (string mapFile in MapFiles)
                {
                    string cleanMapName = Path.GetFileNameWithoutExtension(mapFile);

                    var compileErrors = new List <Error>();
                    CompilePalLogger.LogLine($"Starting compilation of {cleanMapName}");

                    //Update the grid so we have the most up to date order
                    OrderManager.UpdateOrder();

                    GameConfigurationManager.BackupCurrentContext();
                    foreach (var compileProcess in OrderManager.CurrentOrder)
                    {
                        currentCompileProcess = compileProcess;
                        compileProcess.Run(GameConfigurationManager.BuildContext(mapFile));

                        if (compileProcess is CompileExecutable executable)
                        {
                            compileErrors.AddRange(executable.CompileErrors);

                            //Portal 2 cannot work with leaks, stop compiling if we do get a leak.
                            if (GameConfigurationManager.GameConfiguration.Name == "Portal 2")
                            {
                                if (executable.Name == "VBSP" && executable.CompileErrors.Count > 0)
                                {
                                    //we have a VBSP error, aka a leak -> stop compiling;
                                    break;
                                }
                            }
                        }

                        ProgressManager.Progress += (1d / ConfigurationManager.CompileProcesses.Count(c => c.Metadata.DoRun &&
                                                                                                      c.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset))) / MapFiles.Count;
                    }

                    mapErrors.Add(new MapErrors {
                        MapName = cleanMapName, Errors = compileErrors
                    });

                    GameConfigurationManager.RestoreCurrentContext();
                }

                MainWindow.ActiveDispatcher.Invoke(() => postCompile(mapErrors));
            }
            catch (ThreadAbortException) { ProgressManager.ErrorProgress(); }
        }
Ejemplo n.º 23
0
        public override void Run(CompileContext context)
        {
            vbspInfo      = context.Configuration.VBSPInfo;
            bspFile       = context.CopyLocation;
            CompileErrors = new List <Error>();

            try
            {
                CompilePalLogger.LogLine("\nCompilePalMulti - Cubemap Generator");

                if (!File.Exists(context.CopyLocation))
                {
                    throw new FileNotFoundException();
                }

                hidden = GetParameterString().Contains("-hidden");
                FetchHDRLevels();

                string mapname = System.IO.Path.GetFileName(context.CopyLocation).Replace(".bsp", "");

                string args = "-steam -game \"" + context.Configuration.GameFolder + "\" -windowed -novid -nosound +mat_specular 0 %HDRevel% +map " + mapname + " -buildcubemaps";

                if (hidden)
                {
                    args += " -noborder -x 4000 -y 2000";
                }

                if (HDR && LDR)
                {
                    CompilePalLogger.LogLine("Map requires two sets of cubemaps");

                    CompilePalLogger.LogLine("Compiling LDR cubemaps...");
                    RunCubemaps(context.Configuration.GameEXE, args.Replace("%HDRevel%", "+mat_hdr_level 0"));

                    CompilePalLogger.LogLine("Compiling HDR cubemaps...");
                    RunCubemaps(context.Configuration.GameEXE, args.Replace("%HDRevel%", "+mat_hdr_level 2"));
                }
                else
                {
                    CompilePalLogger.LogLine("Map requires one set of cubemaps");
                    CompilePalLogger.LogLine("Compiling cubemaps...");
                    RunCubemaps(context.Configuration.GameEXE, args.Replace("%HDRevel%", ""));
                }
                CompilePalLogger.LogLine("Cubemaps compiled");
            }
            catch (FileNotFoundException)
            {
                CompilePalLogger.LogCompileError($"Could not find file: {context.CopyLocation}", new Error($"Could not find file: {context.CopyLocation}", ErrorSeverity.Error));
            }
            catch (Exception exception)
            {
                CompilePalLogger.LogLine("Something broke:");
                CompilePalLogger.LogCompileError($"{exception}\n", new Error(exception.ToString(), "CompilePalMulti Internal Error", ErrorSeverity.FatalError));
            }
        }
Ejemplo n.º 24
0
        public override void Run(CompileContext context)
        {
            try
            {
                bspZip     = context.Configuration.BSPZip;
                gameFolder = context.Configuration.GameFolder;
                bspPath    = context.BSPFile;

                Keys.vmtTextureKeyWords  = File.ReadAllLines(System.IO.Path.Combine(keysFolder, "texturekeys.txt")).ToList();
                Keys.vmtMaterialKeyWords = File.ReadAllLines(System.IO.Path.Combine(keysFolder, "materialkeys.txt")).ToList();
                Keys.vmfSoundKeys        = File.ReadAllLines(System.IO.Path.Combine(keysFolder, "vmfsoundkeys.txt")).ToList();
                Keys.vmfMaterialKeys     = File.ReadAllLines(System.IO.Path.Combine(keysFolder, "vmfmaterialkeys.txt")).ToList();
                Keys.vmfModelKeys        = File.ReadAllLines(System.IO.Path.Combine(keysFolder, "vmfmodelkeys.txt")).ToList();

                CompilePalLogger.LogLine("Finding sources of game content...");
                GetSourceDirectories(gameFolder);

                CompilePalLogger.LogLine("Reading BSP...");
                BSP map = new BSP(new FileInfo(bspPath));
                AssetUtils.findBspUtilityFiles(map, sourceDirectories);

                string unpackDir = System.IO.Path.GetTempPath() + Guid.NewGuid();
                UnpackBSP(unpackDir);
                AssetUtils.findBspPakDependencies(map, unpackDir);

                CompilePalLogger.LogLine("Initializing pak file...");
                PakFile pakfile = new PakFile(map, sourceDirectories);

                CompilePalLogger.LogLine("Writing file list...");
                pakfile.OutputToFile();

                CompilePalLogger.LogLine("Running bspzip...");
                PackBSP();

                CompilePalLogger.LogLine("Finished packing!");

                CompilePalLogger.LogLine("---------------------");
                CompilePalLogger.LogLine(pakfile.vmtcount + " materials added");
                CompilePalLogger.LogLine(pakfile.mdlcount + " models added");
                CompilePalLogger.LogLine(pakfile.pcfcount + " particle files added");
                CompilePalLogger.LogLine(pakfile.sndcount + " sounds added");
                CompilePalLogger.LogLine("Nav file: " + (map.nav.Key != default(string) ? "yes" : "no"));
                CompilePalLogger.LogLine("Soundscape: " + (map.soundscape.Key != default(string) ? "yes" : "no"));
                CompilePalLogger.LogLine("Soundscript: " + (map.soundscript.Key != default(string) ? "yes" : "no"));
                CompilePalLogger.LogLine("Detail File: " + (map.detail.Key != default(string) ? "yes" : "no"));
                CompilePalLogger.LogLine("Particle Manifest: " + (map.particleManifest.Key != default(string) ? "yes" : "no"));
                CompilePalLogger.LogLine("---------------------");
            }
            catch (Exception exception)
            {
                CompilePalLogger.LogLine("Something broke:");
                CompilePalLogger.LogLine(exception.ToString());
            }
        }
Ejemplo n.º 25
0
        private static void postCompile(List <MapErrors> errors)
        {
            CompilePalLogger.LogLineColor(
                $"\n'{ConfigurationManager.CurrentPreset}' compile finished in {compileTimeStopwatch.Elapsed.ToString(@"hh\:mm\:ss")}", Brushes.ForestGreen);

            if (errors != null && errors.Any())
            {
                int numErrors   = errors.Sum(e => e.Errors.Count);
                int maxSeverity = errors.Max(e => e.Errors.Any() ? e.Errors.Max(e2 => e2.Severity) : 0);
                CompilePalLogger.LogLineColor("{0} errors/warnings logged:", Error.GetSeverityBrush(maxSeverity), numErrors);

                foreach (var map in errors)
                {
                    CompilePalLogger.Log("  ");

                    if (!map.Errors.Any())
                    {
                        CompilePalLogger.LogLineColor("No errors/warnings logged for {0}", Error.GetSeverityBrush(0), map.MapName);
                        continue;
                    }

                    int mapMaxSeverity = map.Errors.Max(e => e.Severity);
                    CompilePalLogger.LogLineColor("{0} errors/warnings logged for {1}:", Error.GetSeverityBrush(mapMaxSeverity), map.Errors.Count, map.MapName);

                    var distinctErrors = map.Errors.GroupBy(e => e.ID);
                    foreach (var errorList in distinctErrors)
                    {
                        var error = errorList.First();

                        string errorText = $"{errorList.Count()}x: {error.SeverityText}: {error.ShortDescription}";

                        CompilePalLogger.Log("    ● ");
                        CompilePalLogger.LogCompileError(errorText, error);
                        CompilePalLogger.LogLine();

                        if (error.Severity >= 3)
                        {
                            AnalyticsManager.CompileError();
                        }
                    }
                }
            }

            OnFinish();

            compileTimeStopwatch.Reset();

            IsCompiling = false;

            // Tells windows it's now okay to enter sleep
            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS);
        }
Ejemplo n.º 26
0
        private void readOutput()
        {
            char[]     buffer = new char[256];
            Task <int> read   = null;

            while (true)
            {
                if (read == null)
                {
                    read = Process.StandardOutput.ReadAsync(buffer, 0, buffer.Length);
                }

                read.Wait(100); // an arbitray timeout

                if (read.IsCompleted)
                {
                    if (read.Result > 0)
                    {
                        string text = new string(buffer, 0, read.Result);

                        var error = GetError(text);

                        if (error != null)
                        {
                            if (error.Severity == 5)
                            {
                                CompilePalLogger.LogLineColor("An error cancelled the compile.", Brushes.Red);
                                ProgressManager.ErrorProgress();
                                return;
                            }

                            CompilePalLogger.LogCompileError(text, error);

                            CompileErrors.Add(error);
                        }
                        else
                        {
                            CompilePalLogger.Log(text);
                        }

                        read = null; // ok, this task completed so we need to create a new one
                        continue;
                    }

                    // got -1, process ended
                    break;
                }
            }
            Process.WaitForExit();
        }
Ejemplo n.º 27
0
 private void ProcessOnOutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (e.Data != null)
     {
         if (e.Data.StartsWith("COMPILE_PAL_SET"))
         {
             GameConfigurationManager.ModifyCurrentContext(e.Data);
         }
         else
         {
             CompilePalLogger.LogLine(e.Data);
         }
     }
 }
Ejemplo n.º 28
0
        private static void DeleteNav(string mapname, string gamefolder)
        {
            List <string> navdirs = BSPPack.BSPPack.GetSourceDirectories(gamefolder, false);

            foreach (string source in navdirs)
            {
                string externalPath = source + "/maps/" + mapname + ".nav";

                if (File.Exists(externalPath))
                {
                    CompilePalLogger.LogLine("Deleting existing nav file.");
                    File.Delete(externalPath);
                }
            }
        }
Ejemplo n.º 29
0
        public static void StartCompile()
        {
            AnalyticsManager.Compile();

            IsCompiling = true;

            compileTimeStopwatch.Start();

            OnClear();

            CompilePalLogger.LogLine(string.Format("Starting a '{0}' compile.", ConfigurationManager.CurrentPreset));

            compileThread = new Thread(CompileThreaded);
            compileThread.Start();
        }
Ejemplo n.º 30
0
        public override void Run(CompileContext context)
        {
            string copyDestination = context.CopyLocation;
            string copySource      = context.BSPFile;

            try
            {
                File.Copy(copySource, copyDestination, true);
                CompilePalLogger.LogLine("File {0} copied to {1}", System.IO.Path.GetFileName(copySource), System.IO.Path.GetDirectoryName(copyDestination));
            }
            catch
            {
                CompilePalLogger.LogLine("File {0} failed to be copied to {1}", copySource, copyDestination);
            }
        }