Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(kModsDirectoryPath) || checkModsFolder(ref kModsDirectoryPath) != ModFolderCheckResult.VALID)
            {
                if (!chooseModDirectory())
                {
                    Application.Exit();
                }
            }

            var splash = new LoadingSplash();

            splash.Show();
            Application.DoEvents();  // Hacky, but whatever.
            LoadModFiles();
            splash.Dispose();
            splash.Hide();
            int initialTab = (int)Properties.Settings.Default["InitialTab"];

            tabControl.SelectedIndex = initialTab;

            if (Properties.Settings.Default.MainFormSize != null)
            {
                this.Size = Properties.Settings.Default.MainFormSize;
            }
        }
Пример #2
0
 private bool UnzipMods(string modsPath)
 {
     if (MessageBox.Show("The chosen directory (" + modsPath + ") \nappears to have compressed mods. To use it, the mods must be uncompressed. Would you like to do that?", "Compressed mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
     {
         var splash = new LoadingSplash();
         splash.Show();
         Application.DoEvents();  // Hacky, but whatever.
         foreach (var path in Directory.EnumerateFiles(modsPath))
         {
             if (path.EndsWith(".smod") && !Directory.Exists(path.Substring(0, path.Length - 5)))
             {
                 System.IO.Compression.ZipFile.ExtractToDirectory(path, modsPath);
             }
         }
         splash.Hide();
         splash.Dispose();
         return(true);
     }
     return(false);
 }
Пример #3
0
        public void Reload()
        {
            // Show the splash on reload too since it takes a while
            var splash = new LoadingSplash();

            splash.Show();
            Application.DoEvents();  // Hacky, but whatever.

            manifestView.Reload();
            entityBrowserView.Reload();
            encounterDesignerView.Reload();
            effectsEditorView.Reload();
            recipesView.Reload();

            if (mNetWorthVisualizer != null && !mNetWorthVisualizer.IsDisposed)
            {
                mNetWorthVisualizer.UpdateNetWorthData();
            }

            splash.Dispose();
            splash.Hide();
        }
Пример #4
0
        private bool chooseModDirectory()
        {
            var dialog = new FolderSelectDialog()
            {
                DirectoryPath = kModsDirectoryPath ?? Environment.CurrentDirectory,
                Title         = "Stonehearth Mods Root Directory"
            };

            DialogResult result = DialogResult.Abort;

            do
            {
                result = dialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string newPath = dialog.DirectoryPath;
                    var    check   = this.checkModsFolder(ref newPath);

                    if (check == ModFolderCheckResult.ZIPPED)
                    {
                        if (MessageBox.Show("The chosen directory appears to have compressed mods. To use it, the mods must be uncompressed. Would you like to do that?", "Compressed mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                        {
                            var splash = new LoadingSplash();
                            splash.Show();
                            Application.DoEvents();  // Hacky, but whatever.
                            foreach (var path in Directory.EnumerateFiles(newPath))
                            {
                                if (path.EndsWith(".smod") && !Directory.Exists(path.Substring(0, path.Length - 5)))
                                {
                                    System.IO.Compression.ZipFile.ExtractToDirectory(path, newPath);
                                }
                            }
                            splash.Hide();
                            splash.Dispose();
                            check = ModFolderCheckResult.VALID;
                        }
                    }

                    if (check == ModFolderCheckResult.VALID)
                    {
                        kModsDirectoryPath = JsonHelper.NormalizeSystemPath(newPath);
                        Properties.Settings.Default["ModsDirectory"] = kModsDirectoryPath;
                        Properties.Settings.Default.Save();
                        return(true);
                    }
                    else if (Directory.Exists(newPath))
                    {
                        // If the directory does exist, but doesn't seem to be valid, make it a user choice
                        if (MessageBox.Show("The chosen directory does not appear to be a valid mods directory. Choose it anyway?", "Possibly invalid mods directory", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                        {
                            kModsDirectoryPath = JsonHelper.NormalizeSystemPath(newPath);
                            Properties.Settings.Default["ModsDirectory"] = kModsDirectoryPath;
                            return(true);
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Invalid mods directory chosen. Try again?", "Invalid directory", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    if (MessageBox.Show("No mods directory selected. Try again?", "No directory selected.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }while (true); // repeat until we've got a proper directory or the user aborts
        }