Esempio n. 1
0
        protected override async void OnClick(EventArgs e)
        {
            // start by clearing all of the controls in the ociform and stopping the audio
            OCIForm.instance.Controls.Clear();
            Audio.Stop();

            // then initialize the loading bar, show the extracting message and play the loading bgm
            LoadingBar loadingBar = new LoadingBar(OCIForm.instance);

            loadingBar.SetLoadingStatus(string.Format("Extracting {0}, please wait...", OCIForm.instance.modPath.Name));
            Audio.PlaySound(loadingBar.GetLoadingBGM(), false);

            // extract the zip archive
            try
            {
                string zipDestination = Static.modsPath + OCIForm.instance.modPath.Name;

                if (!Directory.Exists(zipDestination))
                {
                    await Task.Run(() =>
                    {
                        ZipFile.ExtractToDirectory(OCIForm.instance.modPath.FullName, zipDestination);
                    });
                }
            }
            catch (Exception ex)
            {
                string message = "An exception was encountered:\n---------------\n"
                                 + ex.Message + "\n---------------\n" + ex.ToString();

                MessageBox.Show(message);
            }

            // then if we've been told by the checkboxes to directly apply the zip archive to oneshot, install the mod
            if (OCIDirectApply.instance.Checked)
            {
                ChangesManage.MultithreadStuff(true, loadingBar, new DirectoryInfo(Static.modsPath + OCIForm.instance.modPath.Name), OCIDeleteExisting.instance.Checked);
            }
        }
Esempio n. 2
0
        protected override async void OnClick(EventArgs e)
        {
            MainForm.instance.Controls.Clear();

            // initialize loading box
            PictureBox pb = new PictureBox();

            pb.Image    = Image.FromFile(Static.spritesPath + "loading.png");
            pb.Size     = pb.Image.Size;
            pb.Location = new Point(20, 20);
            MainForm.instance.Controls.Add(pb);

            await Task.Delay(1);

            try // why is this in a try catch i can't remember
            {
                ChangesManage.MultithreadStuff(false, new LoadingBar(MainForm.instance));
            }
            catch { }

            //Form1.instance.Controls.Clear();
            //Form1.instance.InitStartMenu();
        }
Esempio n. 3
0
        public void RefreshMods()
        {
            StringBuilder sb = new StringBuilder("samuel"); // i can't remember why i made this but i'm scared to remove it in case it'll break everything beyond repair

            Nodes.Clear();

            // create the mods directory if it doesn't exist
            if (!Directory.Exists(Static.modsPath))
            {
                Directory.CreateDirectory(Static.modsPath);
            }
            if (!Program.doneSetup)
            {
                MessageBox.Show("A base oneshot could not be found. Please open the setup page and follow the instructions.");
                MainForm.instance.Controls.Clear();
                MainForm.instance.InitStartMenu();
                return;
            }

            Static.baseOneShotPath = File.ReadAllText(Static.appDataPath + "path.molly");
            Logger.WriteLine("oneshot path is " + Static.baseOneShotPath);

            LoadingBar loadingBar = new LoadingBar(MainForm.instance, showProgressBar: false);

            // now we extract any existing zip files
            foreach (FileInfo zip in new DirectoryInfo(Static.modsPath).GetFiles())
            {
                loadingBar.SetLoadingStatus(string.Format("attempting to extract {0},\nplease wait a moment", zip.Name));
                Logger.WriteLine($"attempting to extract {zip.FullName}");
                try
                {
                    if (zip.Extension == ".zip")
                    {
                        ZipFile.ExtractToDirectory(zip.FullName, Static.modsPath + "/" + zip.Name.Replace(".zip", ""));
                    }
                }
                catch (Exception ex)
                {
                    string message = zip.Name + " was detected as a possible zip file,\nbut an exception was encountered while trying to extract it:\n---------------\n"
                                     + ex.Message + "\n---------------\n" + ex.ToString() +
                                     "\nThis exception will be ignored but trying to use this mod may cause issues.";

                    MessageBox.Show(message);
                }

                // delete the corresponding zip file
                File.Delete(zip.FullName);
            }

            // add the mods to the treeview
            string[] mods = Directory.GetDirectories(Static.modsPath);
            foreach (string s in mods)
            {
                string modName = s.Substring(s.LastIndexOf("Mods") + 5); // create the name of the mod to add to the treeview

                // check if the mod is valid. if not, warn the player
                if (!ChangesManage.ConfirmValid(s))
                {
                    Audio.PlaySound("sfx_denied", false);
                    MessageBox.Show($"Could not confirm that {modName} is a valid OneShot mod or add-on." +
                                    "\nThis could be because the contents of the mod are not in the root of the directory." +
                                    "\nPlease double check that this is the case, and if so, move them." +
                                    "\n\nOneShot ModLoader will ignore this just in case and continue as if it were valid, but there are no guarantees it will install correctly.");
                }

                if (!ActiveMods.instance.Nodes.ContainsKey(modName) && modName != "base oneshot")
                {
                    Nodes.Add(modName, modName);
                }
            }

            ActiveMods.instance.RefreshMods();

            loadingBar.text.Dispose();
        }