Пример #1
0
        private void btnLoadAddons_Click(object sender, EventArgs e)
        {
            if (addonList != null && !addonList.HasExited)
            {
                return;
            }

            lbxAddonList.Items.Clear();
            if (string.IsNullOrWhiteSpace(txtDefGMPFile.Text))
            {
                TinyFD.tinyfd_messageBox("No Location Provided", "You need to enter in the GMPublish.exe file in the Settings area of this program", "ok", "error", 1);
                return;
            }

            try
            {
                Process[] steam = Process.GetProcessesByName("steam");
                if (steam.Length == 0)
                {
                    TinyFD.tinyfd_messageBox("Steam.exe Not Running", "You need to load up Steam to use this part of the program", "ok", "error", 1);
                    return;
                }
            }
            catch (Exception ex)
            {
                tctrlConsole.SelectedIndex = 1;
                rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
            }

            addonList = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = txtDefGMPFile.Text,
                    Arguments              = "list",
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                }
            };

            try
            {
                addonList.Start();
                content.Clear();
                reader2 = TextReader.Synchronized(addonList.StandardOutput);
                bwrAddonList.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                btnLoadAddons.Enabled      = true;
                tctrlConsole.SelectedIndex = 1;
                rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
            }
        }
Пример #2
0
 /**
  * A helper method which checks if text boxes for each task are blank (Task Notes and Name are optional)
  */
 private bool textBoxesAreBlank(TextBox T1, TextBox T2, TextBox T3)
 {
     // Checking if each text boxes contents are not empty, null, or just spaces prevents bad input
     if (string.IsNullOrWhiteSpace(T1.Text) || string.IsNullOrWhiteSpace(T2.Text) || string.IsNullOrWhiteSpace(T3.Text))
     {
         TinyFD.tinyfd_messageBox("Input Error", "Please fill in all required fields before adding it to the task queue", "ok", "error", 1);
         return(true);
     }
     return(false);
 }
Пример #3
0
        private void btnDeleteTask_Click(object sender, EventArgs e)
        {
            if (lbxQueue.SelectedIndex > lbxQueue.Items.Count || lbxQueue.SelectedIndex == -1)
            {
                TinyFD.tinyfd_messageBox("Selection Error", "Please select a valid task from the queue", "ok", "error", 1);
                return;
            }

            list.RemoveAt(lbxQueue.SelectedIndex);
            lbxQueue.Items.RemoveAt(lbxQueue.SelectedIndex);
        }
Пример #4
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;
            }
        }
Пример #5
0
        static void Main()
        {
            // This code here detects if the program is already running, prevents another instance from loading
            const string appName = "GMWU";

            mu = new Mutex(true, appName, out bool createdNew);

            if (!createdNew)
            {
                TinyFD.tinyfd_messageBox($"{appName} is already running", "You cannot have more than one instance of this program running", "ok", "error", 1);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new GMWU());
        }
Пример #6
0
 private void btnApplyChanges_Click(object sender, EventArgs e)
 {
     if (!int.TryParse(txtChangeTime.Text, out int time))
     {
         TinyFD.tinyfd_messageBox("Time information Incorrect", "Please enter in a valid time for the tasks to run at", "ok", "error", 1);
         return;
     }
     if (time > 0)
     {
         tmrQueueRunner.Interval  = Math.Abs(time * 1000);
         lblCurrentQueueTime.Text = $"Current Time Interval: {tmrQueueRunner.Interval / 1000} Seconds";
     }
     else
     {
         chkAutoRunTask.Checked = false;
     }
 }
Пример #7
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;
            }
        }
Пример #8
0
        private void btnUseID_Click(object sender, EventArgs e)
        {
            if (!addonsLoaded)
            {
                TinyFD.tinyfd_messageBox("Addons Not Loaded", "Please load your addons before using this function", "ok", "error", 1);
                return;
            }

            try
            {
                Clipboard.SetText(lbxAddonList.SelectedItem.ToString().Substring(0, lbxAddonList.SelectedItem.ToString().IndexOf('\t')));
                TinyFD.tinyfd_messageBox("Addon ID Copied", "Addon ID has been copied to your clipboard", "ok", "info", 1);
            }
            catch (Exception ex)
            {
                tctrlConsole.SelectedIndex = 1;
                rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
            }
        }
Пример #9
0
        /**
         * A helper method that loads file dialogs for .jpg icons that are 512x512
         */
        private void loadIconDialog(string title, string defaultPath, int numFilters, string[] filterPatterns, string filterDescription, int allowMultipleSelects, TextBox T1)
        {
            dialog       = TinyFD.tinyfd_openFileDialog(title, defaultPath, numFilters, filterPatterns, filterDescription, allowMultipleSelects);
            dialogResult = stringFromAnsi(dialog);
            if (!string.IsNullOrWhiteSpace(dialogResult))
            {
                if (!dialogResult.Contains(".jpg"))
                {
                    TinyFD.tinyfd_messageBox("Image Load Error", "This image is not a .jpg", "ok", "error", 1);
                    return;
                }

                if (CheckIfFileIsImage(dialogResult))
                {
                    pbxIcon.Image = newImg;
                    T1.Text       = dialogResult;
                }
            }
        }
Пример #10
0
 private bool CheckIfFileIsImage(string path)
 {
     try
     {
         newImg = Image.FromFile(path);
         if (newImg.Width != 512 || newImg.Height != 512)
         {
             if (pbxIcon.Image != null)
             {
                 pbxIcon.Image.Dispose();
             }
             TinyFD.tinyfd_messageBox("Image Load Error", "The specified image is not 512x512", "ok", "error", 1);
             return(false);
         }
     }
     catch (Exception ex)
     {
         tctrlConsole.SelectedIndex = 1;
         rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
         return(false);
     }
     return(true);
 }
Пример #11
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;
        }
Пример #12
0
        private void btnCreateJS_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtJSOutput.Text))
            {
                TinyFD.tinyfd_messageBox("No Location Provided", "You need to enter in a location for the addon.json file that is created", "ok", "error", 1);
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtAddonTitle.Text))
            {
                TinyFD.tinyfd_messageBox("No Addon Title Provided", "You need to enter in a title for your addon", "ok", "error", 1);
                return;
            }
            else if (cbxTag1.SelectedItem.ToString().Equals(cbxTag2.SelectedItem.ToString()))
            {
                TinyFD.tinyfd_messageBox("Duplicate Tags Entered", "You cannot add the same addon tag twice", "ok", "error", 1);
                return;
            }

            string[] tags;
            if (cbxTag2.SelectedIndex > 0)
            {
                tags = new string[] { cbxTag1.SelectedItem.ToString().ToLowerInvariant(), cbxTag2.SelectedItem.ToString().ToLowerInvariant() }
            }
            ;
            else
            {
                tags = new string[] { cbxTag1.SelectedItem.ToString().ToLowerInvariant() }
            };

            string[] wildcards;
            if (string.IsNullOrWhiteSpace(txtWildcards.Text))
            {
                wildcards = new string[0];
            }
            else
            {
                try
                {
                    wildcards = Regex.Replace(txtWildcards.Text, @"\s+", string.Empty).Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
                }
                catch (Exception ex)
                {
                    wildcards = new string[0];
                    tctrlConsole.SelectedIndex = 1;
                    rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
                }
            }

            try
            {
                AddonJson js   = new AddonJson(txtAddonTitle.Text, cbxAddonType.SelectedItem.ToString().ToLowerInvariant(), tags, wildcards);
                string    json = JsonConvert.SerializeObject(js, Formatting.Indented);
                File.WriteAllText(Path.Combine(txtJSOutput.Text, "addon.json"), json);
                TinyFD.tinyfd_messageBox("Addon.json Created", $"The addon.json file has been created at: {txtJSOutput.Text}", "ok", "info", 1);
            }
            catch (Exception ex)
            {
                tctrlConsole.SelectedIndex = 1;
                rtbErrors.Text            += $"[{DateTime.Now.ToString("HH:mm:ss tt")}] {ex}{Environment.NewLine}{Environment.NewLine}";
            }
        }
Пример #13
0
        /**
         * A helper method which checks locations of all the information inside text boxes for each task
         *
         * A switch statement was used since each task has a unique identifier (0 to 4) to tell the program what to check
         */
        private bool checkLocationsBeingInvalid(TextBox T1, TextBox T2, TextBox T3, int Identifier)
        {
            switch (Identifier)
            {
            case 0:
                // Create .GMA
                if (!Directory.Exists(T1.Text) || !File.Exists(T2.Text) || !Directory.Exists(T3.Text))
                {
                    TinyFD.tinyfd_messageBox("Input Error", "Make sure all locations provided are valid", "ok", "error", 1);
                    return(true);
                }
                break;

            case 1:
                // Extract .GMA
                if (!Directory.Exists(T1.Text) || !File.Exists(T2.Text) || !File.Exists(T3.Text))
                {
                    TinyFD.tinyfd_messageBox("Input Error", "Make sure all locations provided are valid", "ok", "error", 1);
                    return(true);
                }
                break;

            case 2:
                // Publish Addon
                if (!File.Exists(T1.Text) || !File.Exists(T2.Text) || !File.Exists(T3.Text))
                {
                    TinyFD.tinyfd_messageBox("Input Error", "Make sure all locations provided are valid", "ok", "error", 1);
                    return(true);
                }
                if (!CheckIfFileIsImage(T3.Text))
                {
                    return(true);
                }
                break;

            case 3:
                // Update Addon
                if (!File.Exists(T1.Text) || !File.Exists(T2.Text))
                {
                    TinyFD.tinyfd_messageBox("Input Error", "Make sure all locations provided are valid", "ok", "error", 1);
                    return(true);
                }
                else if (!long.TryParse(T3.Text, out long _))
                {
                    TinyFD.tinyfd_messageBox("Addon ID Input Error", "Enter in a valid addon ID (you can use the addon list as well)", "ok", "error", 1);
                    return(true);
                }
                break;

            case 4:
                // Update Icon
                if (!File.Exists(T1.Text) || !File.Exists(T2.Text))
                {
                    TinyFD.tinyfd_messageBox("Input Error", "Make sure all locations provided are valid", "ok", "error", 1);
                    return(true);
                }
                if (!CheckIfFileIsImage(T1.Text))
                {
                    return(true);
                }
                else if (!long.TryParse(T3.Text, out long _))
                {
                    TinyFD.tinyfd_messageBox("Addon ID Input Error", "Enter in a valid addon ID (you can use the addon list as well)", "ok", "error", 1);
                    return(true);
                }
                break;

            default:
                break;
            }
            return(false);
        }