Exemplo n.º 1
0
        public void Read(GenericStructure gs)
        {
            ID                       = gs.PropertyInteger("ID");
            Name                     = gs["Name"];
            Specification            = gs["Specification"];
            Engine                   = (Engine)Enum.Parse(typeof(Engine), gs["EngineID"]);
            DontRedirectOutput       = gs.PropertyBoolean("DontRedirectOutput");
            Path                     = gs["Path"];
            Bsp                      = gs["Bsp"];
            Csg                      = gs["Csg"];
            Vis                      = gs["Vis"];
            Rad                      = gs["Rad"];
            IncludePathInEnvironment = gs.PropertyBoolean("IncludePathInEnvironment", true);

            WorkingDirectory  = gs.PropertyEnum("WorkingDirectory", CompileWorkingDirectory.TemporaryDirectory);
            AfterCopyBsp      = gs.PropertyBoolean("AfterCopyBsp");
            AfterRunGame      = gs.PropertyBoolean("AfterRunGame");
            AfterAskBeforeRun = gs.PropertyBoolean("AfterAskBeforeRun");

            CopyBsp = gs.PropertyBoolean("CopyBsp");
            CopyRes = gs.PropertyBoolean("CopyRes");
            CopyLin = gs.PropertyBoolean("CopyLin");
            CopyMap = gs.PropertyBoolean("CopyMap");
            CopyPts = gs.PropertyBoolean("CopyPts");
            CopyLog = gs.PropertyBoolean("CopyLog");
            CopyErr = gs.PropertyBoolean("CopyErr");

            foreach (var prof in gs.GetChildren("Profile"))
            {
                var bp = new BuildProfile();
                bp.Read(prof);
                Profiles.Add(bp);
            }
        }
Exemplo n.º 2
0
        public Batch(Document document, Build build, BuildProfile profile)
        {
            Document = document;
            Game = document.Game;
            Build = build;
            Profile = profile;

            var workingDir = Path.GetDirectoryName(document.MapFile);
            if (build.WorkingDirectory == CompileWorkingDirectory.SubDirectory && workingDir != null)
            {
                workingDir = Path.Combine(workingDir,  Path.GetFileNameWithoutExtension(document.MapFileName));
            }
            else if (build.WorkingDirectory == CompileWorkingDirectory.TemporaryDirectory || workingDir == null)
            {
                workingDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            }

            if (!Directory.Exists(workingDir)) Directory.CreateDirectory(workingDir);
            TargetFile = SaveCordonMap(document, workingDir);
            OriginalFile = document.MapFile;

            var fileFlag = '"' + TargetFile + '"';

            Steps = new List<BatchCompileStep>();
            if (profile.RunCsg)
            {
                Steps.Add(new BatchCompileStep
                {
                    Operation = Path.Combine(build.Path, build.Csg),
                    Flags = (profile.FullCsgParameters + ' ' + fileFlag).Trim()
                });
            }
            if (profile.RunBsp)
            {
                Steps.Add(new BatchCompileStep
                {
                    Operation = Path.Combine(build.Path, build.Bsp),
                    Flags = (profile.FullBspParameters + ' ' + fileFlag).Trim()
                });
            }
            if (profile.RunVis)
            {
                Steps.Add(new BatchCompileStep
                {
                    Operation = Path.Combine(build.Path, build.Vis),
                    Flags = (profile.FullVisParameters + ' ' + fileFlag).Trim()
                });
            }
            if (profile.RunRad)
            {
                Steps.Add(new BatchCompileStep
                {
                    Operation = Path.Combine(build.Path, build.Rad),
                    Flags = (profile.FullRadParameters + ' ' + fileFlag).Trim()
                });
            }
        }
Exemplo n.º 3
0
        public void Read(GenericStructure gs)
        {
            ID = gs.PropertyInteger("ID");
            Name = gs["Name"];
            Specification = gs["Specification"];
            Engine = (Engine)Enum.Parse(typeof(Engine), gs["EngineID"]);
            DontRedirectOutput = gs.PropertyBoolean("DontRedirectOutput");
            Path = gs["Path"];
            Bsp = gs["Bsp"];
            Csg = gs["Csg"];
            Vis = gs["Vis"];
            Rad = gs["Rad"];
            IncludePathInEnvironment = gs.PropertyBoolean("IncludePathInEnvironment", true);

            WorkingDirectory = gs.PropertyEnum("WorkingDirectory", CompileWorkingDirectory.TemporaryDirectory);
            AfterCopyBsp = gs.PropertyBoolean("AfterCopyBsp");
            AfterRunGame = gs.PropertyBoolean("AfterRunGame");
            AfterAskBeforeRun = gs.PropertyBoolean("AfterAskBeforeRun");

            CopyBsp = gs.PropertyBoolean("CopyBsp");
            CopyRes = gs.PropertyBoolean("CopyRes");
            CopyLin = gs.PropertyBoolean("CopyLin");
            CopyMap = gs.PropertyBoolean("CopyMap");
            CopyPts = gs.PropertyBoolean("CopyPts");
            CopyLog = gs.PropertyBoolean("CopyLog");
            CopyErr = gs.PropertyBoolean("CopyErr");

            foreach (var prof in gs.GetChildren("Profile"))
            {
                var bp = new BuildProfile();
                bp.Read(prof);
                Profiles.Add(bp);
            }
        }
Exemplo n.º 4
0
 private void UseProfile(BuildProfile pro)
 {
     _profile = pro;
     UpdateParameters(pro);
     DialogResult = DialogResult.OK;
     Close();
 }
Exemplo n.º 5
0
        private void UpdateProfiles()
        {
            if (!_build.Profiles.Any())
            {
                _profile = CreateProfile("Default");
            }
            var profs = _build.Profiles;
            var idx = profs.IndexOf(_profile);
            if (idx < 0) idx = ProfileSelect.SelectedIndex;

            ProfileSelect.Items.Clear();
            PresetTable.Controls.Clear();
            PresetTable.RowStyles.Clear();

            if (_specification.Presets.Any())
            {
                PresetTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                PresetTable.Controls.Add(new Label
                {
                    Text = "Choose a preset to use for the compile:",
                    Dock = DockStyle.Top
                });

                foreach (var preset in _specification.Presets)
                {
                    PresetTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                    var btn = new HeadingButton
                    {
                        HeadingText = preset.Name,
                        Text = preset.Description,
                        Dock = DockStyle.Top
                    };
                    var pre = preset;
                    btn.Click += (s, e) => UsePreset(pre);
                    PresetTable.Controls.Add(btn);
                }

                PresetTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                PresetTable.Controls.Add(new Label {Text = "Or select from a custom profile:", Dock = DockStyle.Top});
            }
            else
            {
                PresetTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                PresetTable.Controls.Add(new Label { Text = "Select a profile to use for the compile:", Dock = DockStyle.Top });
            }

            foreach (var profile in profs)
            {
                ProfileSelect.Items.Add(profile);
                PresetTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                var btn = new Button
                {
                    Text = profile.Name,
                    Height = 30,
                    Dock = DockStyle.Top
                };
                var pro = profile;
                btn.Click += (s, e) => UseProfile(pro);
                PresetTable.Controls.Add(btn);
            }
            if (idx < 0 || idx >= profs.Count) idx = 0;
            if (ProfileSelect.SelectedIndex != idx) ProfileSelect.SelectedIndex = idx;
        }
Exemplo n.º 6
0
 private void UpdateParameters(BuildProfile prof)
 {
     RunCsgCheckbox.Checked = prof.RunCsg;
     RunBspCheckbox.Checked = prof.RunBsp;
     RunVisCheckbox.Checked = prof.RunVis;
     RunRadCheckbox.Checked = prof.RunRad;
     CsgParameters.SetCommands(prof.GeneratedCsgParameters ?? "", prof.AdditionalCsgParameters ?? "");
     BspParameters.SetCommands(prof.GeneratedBspParameters ?? "", prof.AdditionalBspParameters ?? "");
     VisParameters.SetCommands(prof.GeneratedVisParameters ?? "", prof.AdditionalVisParameters ?? "");
     RadParameters.SetCommands(prof.GeneratedRadParameters ?? "", prof.AdditionalRadParameters ?? "");
     SharedParameters.SetCommands(prof.GeneratedSharedParameters ?? "", prof.AdditionalSharedParameters ?? "");
 }
Exemplo n.º 7
0
 private void SaveProfileAsButtonClicked(object sender, EventArgs e)
 {
     using (var qf = new QuickForm("Save Build Profile As...").TextBox("Name").OkCancel())
     {
         if (qf.ShowDialog() == DialogResult.OK)
         {
             var name = qf.String("Name");
             if (_build.Profiles.Any(x => String.Equals(name, x.Name, StringComparison.InvariantCultureIgnoreCase)))
             {
                 MessageBox.Show("There is already a profile with that name, please type a unique name.", "Cannot create profile");
                 name = null;
             }
             if (!String.IsNullOrWhiteSpace(name))
             {
                 _profile = SaveAsProfile(name);
                 UpdateProfiles();
             }
         }
     }
 }
Exemplo n.º 8
0
 private BuildProfile SaveAsProfile(string name)
 {
     var prof = new BuildProfile
     {
         ID = _build.Profiles.Any() ? _build.Profiles.Max(x => x.ID) + 1 : 1,
         BuildID = _build.ID,
         Name = name,
         RunCsg = RunCsgCheckbox.Checked,
         RunBsp = RunBspCheckbox.Checked,
         RunVis = RunVisCheckbox.Checked,
         RunRad = RunRadCheckbox.Checked,
         GeneratedCsgParameters = CsgParameters.GeneratedCommands,
         GeneratedBspParameters = BspParameters.GeneratedCommands,
         GeneratedVisParameters = VisParameters.GeneratedCommands,
         GeneratedRadParameters = RadParameters.GeneratedCommands,
         GeneratedSharedParameters = SharedParameters.GeneratedCommands,
         AdditionalCsgParameters = CsgParameters.AdditionalCommands,
         AdditionalBspParameters = BspParameters.AdditionalCommands,
         AdditionalVisParameters = VisParameters.AdditionalCommands,
         AdditionalRadParameters = RadParameters.AdditionalCommands,
         AdditionalSharedParameters = SharedParameters.AdditionalCommands
     };
     _build.Profiles.Add(prof);
     SettingsManager.Write();
     return prof;
 }
Exemplo n.º 9
0
 private void ProfileSelected(object sender, EventArgs e)
 {
     _profile = ProfileSelect.SelectedItem as BuildProfile;
     if (_profile == null) return;
     UpdateParameters(_profile);
 }
Exemplo n.º 10
0
 private BuildProfile CreateProfile(string name)
 {
     var prof = new BuildProfile
     {
         ID = _build.Profiles.Any() ? _build.Profiles.Max(x => x.ID) + 1 : 1,
         BuildID = _build.ID,
         Name = name,
         RunCsg = _specification.GetDefaultRun("csg"),
         RunBsp = _specification.GetDefaultRun("bsp"),
         RunVis = _specification.GetDefaultRun("vis"),
         RunRad = _specification.GetDefaultRun("rad"),
         GeneratedCsgParameters = _specification.GetDefaultParameters("csg"),
         GeneratedBspParameters = _specification.GetDefaultParameters("bsp"),
         GeneratedVisParameters = _specification.GetDefaultParameters("vis"),
         GeneratedRadParameters = _specification.GetDefaultParameters("rad"),
         GeneratedSharedParameters = _specification.GetDefaultParameters("shared"),
         AdditionalCsgParameters = "",
         AdditionalBspParameters = "",
         AdditionalVisParameters = "",
         AdditionalRadParameters = "",
         AdditionalSharedParameters = ""
     };
     _build.Profiles.Add(prof);
     SettingsManager.Write();
     return prof;
 }
Exemplo n.º 11
0
 private void UpdateParameters(BuildProfile prof)
 {
     CsgParameters.SetCommands(prof.GeneratedCsgParameters ?? "", prof.AdditionalCsgParameters ?? "");
     BspParameters.SetCommands(prof.GeneratedBspParameters ?? "", prof.AdditionalBspParameters ?? "");
     VisParameters.SetCommands(prof.GeneratedVisParameters ?? "", prof.AdditionalVisParameters ?? "");
     RadParameters.SetCommands(prof.GeneratedRadParameters ?? "", prof.AdditionalRadParameters ?? "");
     SharedParameters.SetCommands(prof.GeneratedSharedParameters ?? "", prof.AdditionalSharedParameters ?? "");
 }