private void MaterialParameterList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (materialParameterList.SelectedIndex == -1 || materialParameterList.SelectedIndex >= materialParameterList.Items.Count)
            {
                materialParameterList.SelectedIndex = 0;
            }
            toolStripStatusLabel1.Text = "";
            MaterialParameter selectedParameter = XMLInteraction.MaterialParametersArrayList[materialParameterList.SelectedIndex];

            materialParameterName.Text = selectedParameter.ParamName;
            materialParameter.Text     = selectedParameter.Parameter;
            if (!selectedParameter.ParamType.UsesArrays)
            {
                materialParameterValue.Text = selectedParameter.ParamValue;
            }
            if (selectedParameter.ParamType.Delimiter)
            {
                materialParameterValue.Text = string.Join(",", selectedParameter.ParamValue);
            }

            if (comboBoxDataSource[selectedParameter.ParamType.ParameterInternalName] == null)
            {
                toolStripStatusLabel1.Text = materialParameterName.Text + " uses an invalid parameter type. This will cause an error when exporting.";
            }
            else
            {
                materialTypeComboBox.SelectedValue = selectedParameter.ParamType.ParameterInternalName;
            }

            if (selectedParameter.ParamType.ParameterInternalName == "proxy")
            {
                RefreshProxyGroupBoxes(selectedParameter.ParamValue);
            }
        }
Ejemplo n.º 2
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);
        }
        private void SetInitialParameterValue(MaterialParameter materialParameter)
        {
            materialParameter.ParamType = MaterialParameterType.GetMaterialParameterType(materialTypeComboBox.SelectedValue.ToString());
            Type paramType = materialParameter.ParamType.ParameterType;

            if (materialParameter.ParamType.UsesArrays)
            {
                if (materialParameter.ParamType.UsesAttributes)
                {
                    materialParameter.ParamValue = new List <string[]>();
                }
                else
                {
                    materialParameter.ParamValue = new List <string>();
                }
            }
            else
            {
                if (materialParameter.ParamType.ParameterType.Name == "String")
                {
                    materialParameter.ParamValue = string.Empty;
                }
                else
                {
                    materialParameter.ParamValue = Activator.CreateInstance(paramType).ToString();
                }

                materialParameterValue.Text = materialParameter.ParamValue.ToString();
            }
        }
        private void MaterialParameterValue_TextChanged(object sender, EventArgs e)
        {
            MaterialParameter selectedParameter = XMLInteraction.MaterialParametersArrayList[materialParameterList.SelectedIndex];

            if (!selectedParameter.ParamType.UsesArrays)
            {
                selectedParameter.ParamValue = materialParameterValue.Text;
            }
            if (selectedParameter.ParamType.Delimiter)
            {
                selectedParameter.ParamValue = new List <string>();
                selectedParameter.ParamValue.AddRange(materialParameterValue.Text.Split(','));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Checks the validity of a MaterialParameter to make sure that none of the fields are invalid.
 /// </summary>
 /// <param name="parameter">Parameter to verify.</param>
 /// <returns>Returns true if the parameter is valid, or false if the check fails.</returns>
 static public int VerifyParameter(MaterialParameter parameter)
 {
     //if (parameter.ParamValue.Length == 0
     //    || (parameter.Parameter.Length == 0 && parameter.ParamType.ToString() != "proxy"))
     //{
     //    return 0;
     //}
     //if (parameter.ParamType.ToString() == "integer" && !Int32.TryParse(parameter.ParamValue, out int num))
     //{
     //    return 1;
     //}
     //else if (parameter.ParamType.ToString().Contains("vector3") && parameter.ParamValue.Split(',').Length != 3) //Check that it contains 3 values only.
     //{
     //    return 1;
     //}
     return(-1); //Consider implementing a more verbose system.
 }
Ejemplo n.º 6
0
        private async void MaterialParameterList_MouseClick(object sender, MouseEventArgs e)
        {
            //HACK: https://stackoverflow.com/a/4579701
            if ((e.Button == MouseButtons.Left) & (e.X > 13))
            {
                MaterialParameter selectedParameter = materialParameterDisplayList[materialParameterList.SelectedIndex].Param;
                materialParameterList.SetItemChecked(this.materialParameterList.SelectedIndex, !this.materialParameterList.GetItemChecked(this.materialParameterList.SelectedIndex));
                await XMLInteraction.WriteXmlParameters(completeUserDataPath);

                overwriteModeComboBox.SelectedIndex   = selectedParameter.ParamForce;
                randomizerOffsetNumeric.DecimalPlaces = 7;
                deviationSettingsParam1Label.Text     = "Parameter Random Deviation";
                deviationSettingsParam2Label.Hide();
                deviationSettingsParam3Label.Hide();
                randomizerOffsetNumeric2.Hide();
                randomizerOffsetNumeric3.Hide();
                if (selectedParameter.ParamType.ToString() == "integer") //Consider case.
                {
                    randomizerOffsetNumeric.DecimalPlaces = 0;
                    deviationSettingsGroupBox.Show();
                }
                else if (selectedParameter.ParamType.ToString() == "bool" ||
                         selectedParameter.ParamType.ToString() == "proxy")
                {
                    deviationSettingsGroupBox.Hide();
                }
                else if (selectedParameter.ParamType.ToString().Contains("vector3"))
                {
                    deviationSettingsGroupBox.Show();
                    toolStripStatusLabel1.Text        = "Vector3 randomization is currently unimplemented. These settings will not be saved.";
                    deviationSettingsParam1Label.Text = "Parameter 1 Random Deviation";
                    deviationSettingsParam1Label.Show();
                    deviationSettingsParam2Label.Show();
                    deviationSettingsParam3Label.Show();
                    randomizerOffsetNumeric.Show();
                    randomizerOffsetNumeric2.Show();
                    randomizerOffsetNumeric3.Show();
                }
                randomizerChanceLabel.Text     = selectedParameter.RandomizerChance.ToString();
                randomizerChanceTrackBar.Value = selectedParameter.RandomizerChance;
                randomizerOffsetNumeric.Value  = (decimal)selectedParameter.RandomizerOffset;
                parameterSettingsGroupBox.Show();
            }
        }
        private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (materialParameterList.SelectedIndex == -1)
            {
                return;
            }
            MaterialParameter selectedParameter = XMLInteraction.MaterialParametersArrayList[materialParameterList.SelectedIndex];

            label3.Text = "Parameter";
            label4.Show();
            materialParameterValue.Show();
            colorCheckBox.Hide();
            multipleChoiceFormButton.Hide();
            proxyPropertiesGroup.Hide();
            if (materialTypeComboBox.SelectedValue.ToString() == "vector3")
            {
                colorCheckBox.Show();
                int[] parameterColorValue;
                try
                {
                    parameterColorValue = Array.ConvertAll(materialParameterValue.Text.Split(','), int.Parse);
                    if (parameterColorValue.Length != 3)
                    {
                        parameterColorValue = new int[] { 0, 0, 0 };
                    }
                }
                catch (FormatException)
                {
                    parameterColorValue = new int[] { 0, 0, 0 };
                }
                redLabel.Text   = parameterColorValue[0].ToString();
                greenLabel.Text = parameterColorValue[1].ToString();
                blueLabel.Text  = parameterColorValue[2].ToString();

                redTrackBar.Value   = parameterColorValue[0];
                greenTrackBar.Value = parameterColorValue[1];
                blueTrackBar.Value  = parameterColorValue[2];

                colorPreview.BackColor = Color.FromArgb(parameterColorValue[0], parameterColorValue[1], parameterColorValue[2]);
            }
            else if (materialTypeComboBox.SelectedValue.ToString() == "proxy")
            {
                label3.Text = "Proxy";
                label4.Hide();
                materialParameterValue.Hide();
                proxyPropertiesGroup.Show();
                if (selectedParameter.ParamValue.GetType() != typeof(List <string[]>)) //Are you sure? this causes conflict with MaterialTypeComboBox_SelectedChangeCommitted
                {
                    SetInitialParameterValue(selectedParameter);
                }
                RefreshProxyGroupBoxes(selectedParameter.ParamValue);
            }
            else if (materialTypeComboBox.SelectedValue.ToString() == "choices")
            {
                materialParameterValue.Hide();
                multipleChoiceFormButton.Show();
                toolStripStatusLabel1.Text = "The parameter type \"" + materialTypeComboBox.SelectedItem.ToString() + "\" is currently unimplemented. This parameter will not be packaged.";
            }
            else
            {
                proxyPropertiesGroup.Hide();
            }
            //XMLInteraction.MaterialParametersArrayList[materialParameterList.SelectedIndex].ParamType = MaterialParameterType.GetMaterialParameterType(materialTypeComboBox.SelectedItem.ToString());
            //Caused errors.
        }
Ejemplo n.º 8
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";
        }