Exemple #1
0
        public List <MaterialParameter> GetEnabledMaterialParameters()
        {
            List <MaterialParameter> materialParameters = new List <MaterialParameter>();

            for (var i = 0; i < materialParameterList.Items.Count; i++)
            {
                if (materialParameterList.GetItemChecked(i))
                {
                    MaterialParameter param = (materialParameterList.Items[i] as MaterialParameterDisplayListEntry).Param;
                    int result = VMTInteraction.VerifyParameter(param);
                    if (result != -1)
                    {
                        if (result == 0)
                        {
                            progressBox.AppendText("WARNING: Parameter " + param.ParamName + " is missing required settings. Please check the parameter settings for more info and try again.\r\n");
                        }
                        if (result == 1)
                        {
                            progressBox.AppendText("WARNING: Parameter " + param.ParamName + " is of type " + param.ParamType + "but the value is " + param.ParamValue + ". Please check the parameter settings and try again.\r\n");
                        }
                        WriteMessage("Parameter " + param.ParamName + " has been deselected.\r\n");
                        materialParameterList.SetItemChecked(i, false);
                    }
                    else
                    {
                        materialParameters.Add(param);
                    }
                }
            }
            return(materialParameters);
        }
Exemple #2
0
        private async void StartPackagingButton_Click(object sender, EventArgs e)
        {
            progressBox.Clear();
            if (!ConfirmValidGame())
            {
                toolStripStatusLabel1.Text = "ERROR: Cannot export. gameinfo.txt not present in specified directory. Please confirm the location to the \"tf\" folder in the Export tab.";
                return;
            }
            try
            {
                if (!Directory.Exists(Path.GetDirectoryName(saveFileDialog1.FileName)))
                {
                    WriteMessage("ERROR: Tne export directory is not accessible.", ExportState.ErrorFatal);
                    return;
                }
            }
            catch (ArgumentException)
            {
                WriteMessage("ERROR: Tne export directory is not accessible.", ExportState.ErrorFatal);
                return;
            }
            for (var i = 0; i < materialParameterList.Items.Count; i++)
            // Considering using this as a way to preset the parameters so that I don't need to
            // run constant cases later on when the process begins.
            {
                if (materialParameterList.GetItemChecked(i))
                {
                    MaterialParameter param = (materialParameterList.Items[i] as MaterialParameterDisplayListEntry).Param;
                    int result = VMTInteraction.VerifyParameter(param);
                    if (result != -1)
                    {
                        if (result == 0)
                        {
                            progressBox.AppendText("WARNING: Parameter " + param.ParamName + " is missing required settings. Please check the parameter settings for more info and try again.\r\n");
                        }
                        if (result == 1)
                        {
                            progressBox.AppendText("WARNING: Parameter " + param.ParamName + " is of type " + param.ParamType + "but the value is " + param.ParamValue + ". Please check the parameter settings and try again.\r\n");
                        }
                        WriteMessage("Parameter " + param.ParamName + " has been deselected.\r\n");
                        materialParameterList.SetItemChecked(i, false);
                    }
                }
            }
            if (materialParameterList.CheckedItems.Count == 0)
            {
                WriteMessage("ERROR: No parameters have been selected.", ExportState.ErrorFatal);
                return;
            }

            if (exportingState)
            {
                progressBox.AppendText("I've started, so I'll finish.\r\n");
                //cancellationTokenSource.Cancel(); //Cancel immediately.
            }
            else
            {
                startPackagingButton.Text = "Abort Packaging";
            }


            ////
            ////
            ////BEGIN
            ////
            ////
            ////

            DirectoryInfo           exportPath              = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "TF2AssetManager", Path.GetFileNameWithoutExtension(Properties.Settings.Default.VpkLocation)));
            string                  tempFileLocation        = Path.Combine(Path.GetTempPath(), "TF2AssetManager", Path.GetFileName(saveFileDialog1.FileName));
            CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
            CancellationToken       token = cancellationTokenSource.Token;

            exportingState = true;


            List <string> includedCustomFiles = new List <string>();

            foreach (string itemChecked in customFileCheckList.CheckedItems)
            {
                includedCustomFiles.Add(itemChecked);
            }

            WriteMessage("Searching for files in the TF2 assets...", ExportState.Begin);
            ExportProcess.Export(pathToExecutableDirectory, customFilesCheckBox.Checked, includedCustomFiles, this);
            try
            {
                File.Delete(saveFileDialog1.FileName);
                File.Move(tempFileLocation, saveFileDialog1.FileName);
                WriteMessage("Operation complete.", ExportState.Success, "Export complete.");
            }
            catch (IOException)
            {
                WriteMessage("ERROR: The file is already in use by another process. Please close the process that is using this file.", ExportState.ErrorFatal, "An error has occurred during exporting. The target export file already exists, and cannot be written over.");
            }
            ClearAllTempFiles(exportPath, tempFileLocation);
            exportingState            = false;
            startPackagingButton.Text = "Begin Packaging";
        }