コード例 #1
0
 private void NewModNameForm_Load(object sender, EventArgs e)
 {
     if (Program.UseDarkTheme)
     {
         Theme.ApplyDarkThemeToAll(this);
     }
 }
コード例 #2
0
        private void InstallForm_Load(object sender, EventArgs e)
        {
            try
            {
                Steam.Init();
            }
            catch (Exception ex)
            {
                MainForm.AddMessage("Exception thrown while Finding Steam", ex);
            }

            if (Steam.SteamLocation == null)
            {
                MainForm.AddMessageToUser($"Steam is not Setup correctly, " +
                                          $"Please report this issue to {Program.ProgramName}'s GitHub Page with {Program.ProgramName}.log\n" +
                                          $"Please copy all files that came with {Program.ProgramName} into your Game folder. Exiting...");
            }

            var games = FindGames();

            foreach (var game in games)
            {
                var lvi = new ListViewItem();
                lvi.Tag = game;
                lvi.SubItems[0].Text = game.GameName;
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, game.Path));
                listView1.Items.Add(lvi);
            }
            Theme.ApplyDarkThemeToAll(this);
        }
コード例 #3
0
 private void CreateUpdateURLForm_Load(object sender, EventArgs e)
 {
     if (Program.UseDarkTheme)
     {
         Theme.ApplyDarkThemeToAll(this);
     }
 }
コード例 #4
0
 private void AboutForm_Load(object sender, EventArgs e)
 {
     if (Program.UseDarkTheme)
     {
         Theme.ApplyDarkThemeToAll(this);
     }
     // Links
     AddLink("Radfordhound", "https://github.com/Radfordhound");
     AddLink("SuperSonic16", "https://github.com/thesupersonic16");
     AddLink("Skyth", "https://github.com/blueskythlikesclouds");
     AddLink("Korama", "https://forums.sonicretro.org/index.php?showuser=677");
     AddLink("CPKREDIR", "https://forums.sonicretro.org/index.php?showtopic=28795");
     AddLink("Slash", "https://github.com/slashiee");
     AddLink("Sajid", "https://github.com/KTE2399");
     AddLink("MainMemory", "https://github.com/MainMemory");
     AddLink("mod-loader-common", "https://github.com/sonicretro/mania-mod-loader");
 }
コード例 #5
0
        private void SLWSaveForm_Load(object sender, EventArgs e)
        {
            // Sets up this ImageList
            listView1.LargeImageList = new ImageList()
            {
                ImageSize  = new Size(64, 64),
                ColorDepth = ColorDepth.Depth32Bit
            };

            // Applies the Dark Theme, Because why not?
            if (Program.UseDarkTheme)
            {
                Theme.ApplyDarkThemeToAll(this);
            }

            // Checks if the Key and Value exists.
            if (Steam.SteamLocation != null)
            {
                // Checks if "loginusers.vdf" exists.
                if (File.Exists(Path.Combine(Steam.SteamLocation, "config\\loginusers.vdf")))
                {
                    // loginusers.vdf
                    var file = Steam.VDFFile.ReadVDF(Path.Combine(Steam.SteamLocation, "config\\loginusers.vdf"));
                    foreach (var pair in file.Array.Elements.ToList())
                    {
                        // Adds ListViewItem
                        var array = pair.Value as Steam.VDFFile.VDFArray;
                        var lvi   = new ListViewItem(array.Elements["PersonaName"].Value as string)
                        {
                            ImageKey = array.Name
                        };
                        // Adds the SID to the SID list
                        SIDs.Add(array.Name);
                        listView1.Items.Add(lvi);
                    }
                }
                // Gets the icons in another thread
                imageThread = new Thread(new ThreadStart(GetAndApplyImages));
                imageThread.Start();
            }
            else
            {
                Close();
            }
        }
コード例 #6
0
 private void NewModForm_Load(object sender, EventArgs e)
 {
     if (Program.UseDarkTheme)
     {
         if (Theme.ApplyDarkThemeToAll(this))
         {
             foreach (ListViewItem lvi in listView1.Items)
             {
                 if (lvi.ForeColor == Color.Black)
                 {
                     lvi.ForeColor             = Color.FromArgb(200, 200, 180);
                     lvi.SubItems[0].ForeColor = Color.FromArgb(200, 200, 180);
                 }
             }
             // This is here to make it easier to see the groups
             listView1.BackColor = Color.FromArgb(64, 64, 64);
         }
     }
 }
コード例 #7
0
        // GUI Events
        private void UpdateModsForm_Load(object sender, EventArgs e)
        {
            if (Program.UseDarkTheme)
            {
                Theme.ApplyDarkThemeToAll(this);
            }
            // Adds the WebClient_DownloadProgressChanged event to the web client.
            webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(WebClient_DownloadProgressChanged);

            DownloadThread = new Thread(() =>
            {
                // Sets the ProgressBarAll's maximum to the amount of files/lines.
                Invoke(new Action(() => ProgressBarAll.Maximum = ModUpdate.Files.Count));

                var sha = new SHA256Managed();
                byte[] hash;
                for (int i = 0; i < ModUpdate.Files.Count; ++i)
                {
                    string fileName = ModUpdate.Files[i].FileName;
                    string fileUrl  = ModUpdate.Files[i].URL;
                    string fileSha  = ModUpdate.Files[i].SHA256;
                    string fileCom  = ModUpdate.Files[i].Command;
                    if (_Mod != null)
                    {
                        var fileInfo = new FileInfo(Path.Combine(_Mod.RootDirectory, fileName));

                        // Creates the directorys
                        if (!fileInfo.Directory.Exists)
                        {
                            Directory.CreateDirectory(fileInfo.Directory.FullName);
                        }
                    }
                    if (string.IsNullOrEmpty(fileCom) || fileCom == "add")
                    {
                        LogFile.AddMessage($"Downloading: {fileName} from {fileUrl}");
                        // Closes and returns if the user clicked cancel.
                        if (CancelUpdate)
                        {
                            Invoke(new Action(() => Close())); return;
                        }
                        // Sets DownloadLabel's Text to show what file is being downloaded.
                        Invoke(new Action(() => DownloadLabel.Text = "Downloading File: " + Path.GetFileName(fileUrl)));
                        // Centres DownloadLabel's position.
                        Invoke(new Action(() => DownloadLabel.Location =
                                              new Point(Size.Width / 2 - DownloadLabel.Size.Width / 2, DownloadLabel.Location.Y)));
                        // Sets ProgressBarAll's Value to the current file.
                        Invoke(new Action(() => ProgressBarAll.Value = i));
                        // Checks if the mod is installed
                        if (_Mod == null)
                        {
                            webClient.DownloadDataCompleted += DownloadDataCompleted;
                            Invoke(new Action(() => StartFileDownload(fileUrl)));
                        }
                        else
                        {
                            // Downloads the current file to the mod root.
                            Invoke(new Action(() => webClient.DownloadFileAsync(new Uri(fileUrl),
                                                                                Path.Combine(_Mod.RootDirectory, fileName))));
                        }
                        // Waits for the download to finish.
                        while (webClient.IsBusy)
                        {
                            Thread.Sleep(100);
                        }
                        if (_Mod == null)
                        {
                            continue;
                        }

                        using (var stream = File.OpenRead(Path.Combine(_Mod.RootDirectory, fileName)))
                        {
                            if (fileSha != 0.ToString("X64") && fileSha != null)
                            {
                                hash = sha.ComputeHash(stream);
                                if (Encoding.ASCII.GetString(hash) !=
                                    Encoding.ASCII.GetString(Program.StringToByteArray(fileSha)))
                                {
                                    LogFile.AddMessage($"Hash Mismatch on file: {fileName}");
                                    if (MessageBox.Show($"File Hash Mismatch.\n" +
                                                        $"{Program.ByteArrayToString(Program.StringToByteArray(fileSha))}" +
                                                        $" != {Program.ByteArrayToString(hash)}\n" +
                                                        $"Try Redownloading?", "File Hash Mismatch.",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                                    {
                                        i--;
                                    }
                                }
                            }
                        }
                        Thread.Sleep(250);
                    }
                    else if (fileCom == "delete")
                    {
                        File.Delete(Path.Combine(_Mod.RootDirectory, fileName));
                    }
                }
                // Closes the update dialog after all the file has been downloaded.
                Invoke(new Action(() => Close()));
            });
            // Starts the download thread.
            DownloadThread.Start();
        }
コード例 #8
0
 private void ChangeLogForm_Load(object sender, EventArgs e)
 {
     Theme.ApplyDarkThemeToAll(this);
 }