Ejemplo n.º 1
0
        /***** DELETE *****/
        public static void delete(AddonInfo addon_info)
        {
            UserConfig info = Configuration.getConfigAsYAML();

            if (info.installed.ContainsKey(addon_info.folder_name) && info.installed[addon_info.folder_name] != null)
            {
                if (info.disabled.ContainsKey(addon_info.folder_name) && info.disabled[addon_info.folder_name])
                {
                    Directory.Delete(Path.Combine("Disabled Plugins", addon_info.folder_name), true);
                    info.disabled.Remove(addon_info.folder_name);
                    info.installed.Remove(addon_info.folder_name);
                    info.version.Remove(addon_info.folder_name);
                    Configuration.setConfigAsYAML(info);
                }
                else
                {
                    if (addon_info.install_mode != "arc")
                    {
                        Directory.Delete(Path.Combine(Path.Combine(info.game_path, "addons"), addon_info.folder_name), true);
                        if (info.disabled.ContainsKey(addon_info.folder_name))
                        {
                            info.disabled.Remove(addon_info.folder_name);
                        }
                        info.installed.Remove(addon_info.folder_name);
                        info.version.Remove(addon_info.folder_name);

                        //deleting arcdps will delete other addons as well
                        if (addon_info.folder_name == "arcdps")
                        {
                            foreach (AddonInfo adj_info in ApprovedList.GenerateAddonList())
                            {
                                if (adj_info.install_mode == "arc")
                                {
                                    //if arc-dependent plugin is disabled, it won't get deleted since it's not in the /addons/arcdps folder
                                    if (info.disabled.ContainsKey(adj_info.folder_name) && !info.disabled[adj_info.folder_name])
                                    {
                                        info.disabled.Remove(adj_info.folder_name);
                                        info.installed.Remove(adj_info.folder_name);
                                        info.version.Remove(adj_info.folder_name);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        File.Delete(Path.Combine(Path.Combine(Path.Combine(info.game_path, "addons"), "arcdps"), addon_info.plugin_name));
                        if (info.disabled.ContainsKey(addon_info.folder_name))
                        {
                            info.disabled.Remove(addon_info.folder_name);
                        }
                        info.installed.Remove(addon_info.folder_name);
                        info.version.Remove(addon_info.folder_name);
                    }

                    Configuration.setConfigAsYAML(info);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This constructor initializes various default properties across the class and then
        /// applies any updated values to them using <c>ApplyDefaultConfig</c>.
        /// </summary>
        public OpeningViewModel()
        {
            AddonList = ApprovedList.GenerateAddonList();

            DescriptionText     = "Select an add-on to see more information about it.";
            DeveloperVisibility = Visibility.Hidden;

            UpdateLinkVisibility     = Visibility.Hidden;
            UpdateProgressVisibility = Visibility.Hidden;

            GamePath = Configuration.getConfigAsYAML().game_path;
        }
        /***** DELETE *****/
        public static void delete(AddonInfoFromYaml addon_info)
        {
            UserConfig info = Configuration.getConfigAsYAML();

            if (info.installed.ContainsKey(addon_info.folder_name) && info.installed[addon_info.folder_name] != null)
            {
                if (info.disabled.ContainsKey(addon_info.folder_name) && info.disabled[addon_info.folder_name])
                {
                    FileSystem.DeleteDirectory(Path.Combine("Disabled Plugins", addon_info.folder_name), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                    info.disabled.Remove(addon_info.folder_name);
                    info.installed.Remove(addon_info.folder_name);
                    info.version.Remove(addon_info.folder_name);
                    Configuration.setConfigAsYAML(info);
                }
                else
                {
                    if (addon_info.install_mode != "arc")
                    {
                        FileSystem.DeleteDirectory(Path.Combine(Path.Combine(info.game_path, "addons"), addon_info.folder_name), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                        if (info.disabled.ContainsKey(addon_info.folder_name))
                        {
                            info.disabled.Remove(addon_info.folder_name);
                        }
                        info.installed.Remove(addon_info.folder_name);
                        info.version.Remove(addon_info.folder_name);

                        //deleting arcdps will delete other addons as well
                        if (addon_info.folder_name == "arcdps")
                        {
                            foreach (AddonInfoFromYaml adj_info in ApprovedList.GenerateAddonList())
                            {
                                if (adj_info.install_mode == "arc")
                                {
                                    //if arc-dependent plugin is disabled, it won't get deleted since it's not in the /addons/arcdps folder
                                    if (info.disabled.ContainsKey(adj_info.folder_name) && !info.disabled[adj_info.folder_name])
                                    {
                                        info.disabled.Remove(adj_info.folder_name);
                                        info.installed.Remove(adj_info.folder_name);
                                        info.version.Remove(adj_info.folder_name);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //buildpad check
                        if (!addon_info.addon_name.Contains("BuildPad"))
                        {
                            FileSystem.DeleteFile(Path.Combine(Path.Combine(Path.Combine(info.game_path, "addons"), "arcdps"), addon_info.plugin_name), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                        }
                        else
                        {
                            string   buildPadFileName = "";
                            string[] arcFiles         = Directory.GetFiles(Path.Combine(Path.Combine(info.game_path, "addons"), "arcdps"));

                            //search for plugin name in arc folder
                            //TODO: Should break out of operation and give message if the plugin is not found.
                            foreach (string arcFileName in arcFiles)
                            {
                                if (arcFileName.Contains("buildpad"))
                                {
                                    buildPadFileName = Path.GetFileName(arcFileName);
                                }
                            }

                            FileSystem.DeleteFile(Path.Combine(Path.Combine(Path.Combine(info.game_path, "addons"), "arcdps"), buildPadFileName), UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                        }


                        if (info.disabled.ContainsKey(addon_info.folder_name))
                        {
                            info.disabled.Remove(addon_info.folder_name);
                        }
                        info.installed.Remove(addon_info.folder_name);
                        info.version.Remove(addon_info.folder_name);
                    }

                    Configuration.setConfigAsYAML(info);
                }
            }
        }