Beispiel #1
0
        private void runTask(int queueItemIndex)
        {
            if (process != null && !process.HasExited)
            {
                return;
            }

            if (queueItemIndex > lbxQueue.Items.Count || queueItemIndex == -1)
            {
                TinyFD.tinyfd_messageBox("Selection Error", "Please select a valid task from the queue", "ok", "error", 1);
                return;
            }

            // A reference object to an element in the "list" data structure
            GTask refer = list[queueItemIndex];

            /*
             * Create a new Process object that has properties defined in the StartInfo area
             *
             * We do not want to create a new console window and let the output be redirected towards our new console
             */
            process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = refer.FileName,
                    Arguments              = refer.Arguments,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                }
            };

            // At the moment, I want to make this cross-platform, and in case there are any errors, they are logged to the Errors console window
            try
            {
                process.Start();
                btnRunTask.Enabled = false;
                reader             = TextReader.Synchronized(process.StandardOutput);
                bwrConsoleOutput.RunWorkerAsync();
                queueSelection = queueItemIndex;
            }
            catch (Exception ex)
            {
                tctrlConsole.SelectedIndex = 1;
                rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
                btnRunTask.Enabled         = true;
            }
        }
Beispiel #2
0
        private void btnAdd2Queue_Click(object sender, EventArgs e)
        {
            GTask taskRef = createTask(tctrlTasks.SelectedIndex);

            if (taskRef == null)
            {
                TinyFD.tinyfd_messageBox("Information Incorrect", "Please make sure all fields for the specified task are correct", "ok", "error", 1);
                return;
            }

            lbxQueue.Items.Add(taskRef);
            list.Add(taskRef);
            if (!timerStarted && chkAutoRunTask.Enabled)
            {
                tmrQueueRunner.Start();
                timerStarted = true;
            }
        }
Beispiel #3
0
        private void btnOverwriteTask_Click(object sender, EventArgs e)
        {
            if (lbxQueue.Items.Count <= 0)
            {
                TinyFD.tinyfd_messageBox("No Items in Queue", "Please create some tasks for the program to use before using this program", "ok", "error", 1);
                return;
            }
            else if (lbxQueue.SelectedIndex < 0 || lbxQueue.SelectedIndex > lbxQueue.Items.Count - 1)
            {
                TinyFD.tinyfd_messageBox("Invalid Selection Provided", "Please select a valid task from the queue", "ok", "error", 1);
                return;
            }

            GTask taskRef = createTask(tctrlTasks.SelectedIndex);

            if (taskRef == null)
            {
                TinyFD.tinyfd_messageBox("Information Incorrect", "Please make sure all fields for the specified task are correct", "ok", "error", 1);
                return;
            }

            list[lbxQueue.SelectedIndex] = taskRef;
        }
Beispiel #4
0
        private GTask createTask(int index)
        {
            GTask newTask = new GTask();

            switch (index)
            {
            case 0:
                if (textBoxesAreBlank(txtAFLocation, txtGMadLoc1, txtGMOutput) ||
                    checkLocationsBeingInvalid(txtAFLocation, txtGMadLoc1, txtGMOutput, 0))
                {
                    return(null);
                }

                if (string.IsNullOrWhiteSpace(txtTaskName.Text))
                {
                    newTask.TaskName = "Create .GMA";
                }
                else
                {
                    newTask.TaskName = txtTaskName.Text;
                }

                if (string.IsNullOrWhiteSpace(txtGMFileName.Text))
                {
                    txtGMFileName.Text = "newgma";
                }

                newTask.FileName  = txtGMadLoc1.Text;
                newTask.Arguments = "create -folder \"" + txtAFLocation.Text + "\" -out \"" + txtGMOutput.Text + "\\" + txtGMFileName.Text + ".gma" + "\"";
                newTask.TaskType  = Enums.TaskType.CreateGMA;
                break;

            // This task is for extrafting a .GMA that will be output to a specific location
            case 1:
                if (textBoxesAreBlank(txtCOLoc, txtGMadLoc2, txtGMFileLoc1) ||
                    checkLocationsBeingInvalid(txtCOLoc, txtGMadLoc2, txtGMFileLoc1, 1))
                {
                    return(null);
                }

                if (string.IsNullOrWhiteSpace(txtTaskName.Text))
                {
                    newTask.TaskName = "Extract .GMA";
                }
                else
                {
                    newTask.TaskName = txtTaskName.Text;
                }

                newTask.FileName = txtGMadLoc2.Text;
                string gmaName        = txtGMFileLoc1.Text.Substring(txtGMFileLoc1.Text.LastIndexOf("\\") + 1);
                string folderLocation = Path.Combine(txtCOLoc.Text, gmaName.Substring(0, gmaName.IndexOf(".")));
                newTask.Arguments = "extract -file \"" + txtGMFileLoc1.Text + "\" -out \"" + folderLocation + "\"";
                newTask.TaskType  = Enums.TaskType.ExtractGMA;
                break;

            case 2:
                if (textBoxesAreBlank(txtGMFileLoc2, txtGMPubFileLoc1, txtIconLoc1) ||
                    checkLocationsBeingInvalid(txtGMFileLoc2, txtGMPubFileLoc1, txtIconLoc1, 2))
                {
                    return(null);
                }

                if (string.IsNullOrWhiteSpace(txtTaskName.Text))
                {
                    newTask.TaskName = "Publish Addon";
                }
                else
                {
                    newTask.TaskName = txtTaskName.Text;
                }

                newTask.FileName  = txtGMPubFileLoc1.Text;
                newTask.Arguments = "create -addon \"" + txtGMFileLoc2.Text + "\" -icon \"" + txtIconLoc1.Text + "\"";
                newTask.TaskType  = Enums.TaskType.PublishAddon;
                break;

            case 3:
                if (textBoxesAreBlank(txtGMFileLoc3, txtGMPubFileLoc2, txtAddonID) ||
                    checkLocationsBeingInvalid(txtGMFileLoc3, txtGMPubFileLoc2, txtAddonID, 3))
                {
                    return(null);
                }

                if (string.IsNullOrWhiteSpace(txtTaskName.Text))
                {
                    newTask.TaskName = "Update Addon";
                }
                else
                {
                    newTask.TaskName = txtTaskName.Text;
                }

                newTask.FileName  = txtGMPubFileLoc2.Text;
                newTask.Arguments = "update -addon \"" + txtGMFileLoc3.Text + "\" -id \"" + long.Parse(txtAddonID.Text) + "\" -changes \"" + txtChangeNotes.Text + "\"";
                newTask.TaskType  = Enums.TaskType.UpdateAddon;
                break;

            case 4:
                if (textBoxesAreBlank(txtIconLoc2, txtGMPubFileLoc3, txtAddonID2) ||
                    checkLocationsBeingInvalid(txtIconLoc2, txtGMPubFileLoc3, txtAddonID2, 3))
                {
                    return(null);
                }

                if (string.IsNullOrWhiteSpace(txtTaskName.Text))
                {
                    newTask.TaskName = "Update Icon";
                }
                else
                {
                    newTask.TaskName = txtTaskName.Text;
                }

                newTask.FileName  = txtGMPubFileLoc3.Text;
                newTask.Arguments = "update -icon \"" + txtIconLoc2.Text + "\" -id \"" + long.Parse(txtAddonID2.Text) + "\"";
                newTask.TaskType  = Enums.TaskType.UpdateIcon;
                break;

            default:
                break;
            }

            newTask.TaskNotes = txtTaskNotes.Text;
            return(newTask);
        }