private void RecreateLists()
        {
            string[] profiles = Directory.GetFiles(ManagerInfo.Get().GetFullProfileDirectory(), "*.json");

            profileList.Clear();
            profileNameList.Clear();
            modNameList.Clear();

            string selectedName = _currentProfile?.name;

            _currentProfile = null;

            for (int i = 0; i < profiles.Length; i++)
            {
                string file = profiles[i];

                profileNameList.Add(Path.GetFileNameWithoutExtension(file));

                Profile profile = Profile.Load(File.ReadAllText(file), Path.GetFileNameWithoutExtension(file));

                profileList.Add(profile);

                if (selectedName != null && profile.name == selectedName)
                {
                    ProfileCB.SelectedIndex = i;
                    _currentProfile         = profile;
                }
            }
        }
 private void DeleteProfile_Click(object sender, RoutedEventArgs e)
 {
     if (_currentProfile != null)
     {
         string path = Path.Combine(ManagerInfo.Get().GetFullProfileDirectory(), (_currentProfile.name + ".json"));
         File.Delete(path);
         RecreateLists();
     }
 }
Example #3
0
        private void ChangeGameDir_Click(object sender, RoutedEventArgs e)
        {
            ManagerInfo inst   = ManagerInfo.Get();
            string      result = GameInstallFinder.FindInstallDir_Dialog();

            if (result != null)
            {
                InstallDirText.Text = result;
                inst.installDir     = result;
                inst.Save();
            }
        }
Example #4
0
        public static void Uninstall(string name, bool silent = false)
        {
            try
            {
                if (name == "bbepis-BepInExPack")
                {
                    if (!silent)
                    {
                        MessageBoxResult result = MessageBox.Show("Uninstalling BepInEx will also uninstall all of your mods!\nYou sure about this?", "Warning", MessageBoxButton.YesNo);
                        if (result != MessageBoxResult.Yes)
                        {
                            return;
                        }
                    }

                    string installDir = ManagerInfo.Get().installDir;

                    foreach (string dir in Directory.GetDirectories(Path.Combine(installDir, "BepInEx")))
                    {
                        if (new DirectoryInfo(dir).Name != "config")
                        {
                            Directory.Delete(dir, true);
                        }
                    }

                    File.Delete(Path.Combine(installDir, "winhttp.dll"));
                    File.Delete(Path.Combine(installDir, "doorstop_config.ini"));
                }
                else
                {
                    if (Directory.Exists(GetMonoModPath(name)))
                    {
                        Directory.Delete(GetMonoModPath(name), true);
                    }

                    if (Directory.Exists(GetPluginPath(name)))
                    {
                        Directory.Delete(GetPluginPath(name), true);
                    }
                }
            }
            catch (IOException) { }
        }
Example #5
0
        public override void RefreshCollection()
        {
            collection.Clear();

            foreach (string dir in Directory.GetDirectories(ManagerInfo.Get().GetFullDownloadDirectory()))
            {
                string mfPath = Path.Combine(dir, "manifest.json");

                if (File.Exists(mfPath))
                {
                    try
                    {
                        string json = File.ReadAllText(mfPath);

                        LocalManifest manifest = JsonConvert.DeserializeObject <LocalManifest>(json);

                        collection.Add(new Mod(manifest, dir));
                    }
                    catch (IOException ex)
                    {
                        var result = MessageBox.Show($"Exception reading manifest for \"{new DirectoryInfo(dir).Name}\":\n{ex.Message}\nDo you want to re-download this mod?");

                        if (result == MessageBoxResult.Yes)
                        {
                            try
                            {
                                Directory.Delete(dir, true);

                                Mod mod = ModManager.onlineModList.Find(new DirectoryInfo(dir).Name);

                                mod.isInstalled = false;
                                ModManager.EnQueueModDownload(mod, mod.version);
                            }
                            catch (IOException ex2)
                            {
                                MessageBox.Show("Oh no! An exception was thrown when trying to delete the mod, too!\n" + ex2.Message);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        public MainWindow()
        {
            InitializeComponent();

            this.Title = "GCManager V" + App.VERSION;

            ModManager.selectedModInfo.name   = "GCManager";
            ModManager.selectedModInfo.author = "Risk of Rain 2 Mod Manager";
            ModManager.selectedModInfo.image  = new BitmapImage(new System.Uri("pack://application:,,,/commando.png"));
            this.DataContext = ModManager.selectedModInfo;

            InstallDirText.Text = ManagerInfo.Get().installDir;

            ModManager.onlineModList     = onlineModList;
            ModManager.downloadedModList = downloadedModList;

            ModManager.LocalModDeletionImminent += PreModDeletion;

            OnlineMods.SetModList(onlineModList);
            OnlineMods.RefreshList();
            DownloadedMods.SetModList(downloadedModList);
            DownloadedMods.RefreshList();
        }
Example #7
0
 private void OpenDownloads_Click(object sender, RoutedEventArgs e)
 {
     Process.Start("explorer.exe", ManagerInfo.Get().GetFullDownloadDirectory());
 }
Example #8
0
        public void Install()
        {
            if (this.fullName == "bbepis-BepInExPack") //Special case
            {
                Utility.CopyDirectory(Path.Combine(GetDownloadDirectory(), "BepInExPack"), ManagerInfo.Get().installDir);
            }
            else
            {
                List <string> dirs = new List <string>(Directory.GetDirectories(GetDownloadDirectory(), "*", SearchOption.AllDirectories));
                dirs.Add(GetDownloadDirectory());

                foreach (string dir in dirs)
                {
                    string destDir;

                    if (new DirectoryInfo(dir).Name.ToLower() == "monomod")
                    {
                        destDir = GetMonoModPath("");
                    }
                    else
                    {
                        destDir = GetPluginPath("");
                    }

                    string[] dlls = Directory.GetFiles(dir, "*.dll");

                    if (dlls.Length > 0)
                    {
                        destDir = Path.Combine(destDir, this.fullName);
                        Directory.CreateDirectory(destDir);

                        foreach (string filepath in dlls)
                        {
                            string dest = Path.Combine(destDir, Path.GetFileName(filepath));

                            if (!File.Exists(dest))
                            {
                                File.Copy(filepath, dest, true);
                            }
                        }
                    }
                }
            }

            this.isInstalled = true;
        }
Example #9
0
 public static string GetMonoModPath(string fullName)
 {
     return(Path.Combine(ManagerInfo.Get().installDir, "BepInEx", "monomod", fullName));
 }
Example #10
0
 public static string GetPluginPath(string fullName)
 {
     return(Path.Combine(ManagerInfo.Get().installDir, "BepInEx", "plugins", fullName));
 }
Example #11
0
 public string GetDownloadDirectory()
 {
     return(Path.Combine(ManagerInfo.Get().GetFullDownloadDirectory(), this.fullName));
 }
Example #12
0
 public bool CheckIfInstalled()
 {
     return(this.fullName == "bbepis-BepInExPack" ?
            Directory.Exists(Path.Combine(ManagerInfo.Get().installDir, "BepInEx", "core")) :
            (Directory.Exists(GetMonoModPath(this.fullName)) || Directory.Exists(GetPluginPath(this.fullName))));
 }
Example #13
0
 public void Save()
 {
     File.WriteAllText(Path.Combine(ManagerInfo.Get().GetFullProfileDirectory(), (name + ".json")), GetJSON());
 }