Ejemplo n.º 1
0
Archivo: Map.cs Proyecto: jwse2/SPiApp
        /// <summary>
        /// Call this to start compiling the selected map.
        /// </summary>
        public static void CompileBSP()
        {
            UserData.Instance.Save();

            MapSettings settings = MapSettings.Instance;

            // First and foremost save the settings
            settings.Save();

            // Compose the BSP Options arguments
            string paramBSPOptions = string.Empty;
            {
                string[] parameters =
                {
                    settings.OnlyEnts,
                    settings.BlockSize,
                    settings.SampleScale,
                    settings.DebugLightmaps,
                    settings.BSPOptions
                };

                foreach (string parameter in parameters)
                {
                    if (parameter != null)
                    {
                        paramBSPOptions = string.Format("{0} {1}", paramBSPOptions, parameter);
                    }
                }

                if (paramBSPOptions.Length == 0)
                {
                    paramBSPOptions = "-";
                }
                else
                {
                    paramBSPOptions = paramBSPOptions.TrimStart();
                }
            }

            // Compose the Light Options arguments
            string paramLightOptions = string.Empty;
            {
                string[] parameters =
                {
                    settings.Fast,
                    settings.Extra,
                    settings.Verbose,
                    settings.ModelShadow,
                    settings.NoModelShadow,
                    settings.DumpOptions,
                    settings.Traces,
                    settings.Jitter,
                    settings.LightOptions
                };

                foreach (string parameter in parameters)
                {
                    if (parameter != null)
                    {
                        paramLightOptions = string.Format("{0} {1}", paramLightOptions, parameter);
                    }
                }

                if (paramLightOptions.Length == 0)
                {
                    paramLightOptions = "-";
                }
                else
                {
                    paramLightOptions = paramLightOptions.TrimStart();
                }
            }

            // Compose the batch file argument
            string arguments = string.Format("\"{0}\" {1} \"{2}\" \"{3}\" {4} {5} {6}",
                                             Preferences.InstallPath, UserData.SelectedMap, paramBSPOptions, paramLightOptions,
                                             settings.CompileBSP, settings.CompileLighting, settings.ConnectPaths
                                             );

            // Launch the batch file
            SPiApp2.Components.Application.Launch(
                string.Format("{0}{1}bin{1}map_compile.bat", Environment.CurrentDirectory, System.IO.Path.DirectorySeparatorChar),
                Preferences.InstallPath,
                arguments
                );
        }