Пример #1
0
        public static void GetMods()
        {
            try
            {
                logStream.Log("Updating modlist...");
                // This list contain the ModInfos and the folder name of each mod
                Mods       = new List <ModInfo>();
                Categories = new HashSet <string>();

                if (!Directory.Exists(ModsPath))
                {
                    Directory.CreateDirectory(ModsPath);
                }

                var modFolder = new DirectoryInfo(ModsPath);

                foreach (var mod in modFolder.GetDirectories())
                {
                    var info = new ModInfo();

                    info.GenInfo(mod.Name);
                    Mods.Add(info);
                    Categories.Add(info.category);
                }
                Mods.Sort((left, right) => left.order.CompareTo(right.order));
                logStream.Log("Modlist updated !");
            }
            catch (Exception e) { logStream.Error(e.ToString()); }
        }
Пример #2
0
        public static void GetMods()
        {
            // This list contain the ModInfos and the folder name of each mod
            Mods = new List <ModInfo>();

            if (!Directory.Exists(ModsPath))
            {
                Directory.CreateDirectory(ModsPath);
            }

            var modFolder = new DirectoryInfo(ModsPath);

            int i = 0;

            foreach (var mod in modFolder.GetDirectories())
            {
                var info = new ModInfo();
                info.GenInfo(mod.FullName);
                // If the order change the generation of the list
                if (info.order >= Mods.Count)
                {
                    Mods.Add(info);
                }
                else
                {
                    if (i > 0)
                    {
                        if (info.order == Mods[i - 1].order)
                        {
                            info.order++;
                            info.SaveSettingsJSON(mod.FullName);
                        }
                    }
                    Mods.Insert(info.order, info);
                }
                i++;
            }
        }
Пример #3
0
        public static bool InstallMod(string path, string name, bool lookForNativePC)
        {
            if (Directory.Exists(Path.Combine(ModsPath, name)))
            // If the mod is installed
            {
                MessageBox.Show("This mod is already installed", "Simple MHW Mod Manager", MessageBoxButton.OK, MessageBoxImage.Information);
                return(true);
            }

            var nativePCs = new List <string>();

            if (lookForNativePC)
            {
                foreach (var dir in GetRecursiveDirectories(path))
                {
                    if (Path.GetFileName(dir).Equals("nativePC", StringComparison.OrdinalIgnoreCase))
                    {
                        nativePCs.Add(dir);
                        logStream.Log(Path.Combine(name, dir.Substring(path.Length + 1)) + " found.");
                    }
                }
            }
            else
            {
                Directory.CreateDirectory(Path.Combine(ModsPath, name));
                MoveDirectory(path, Path.Combine(ModsPath, name, "install"));
                Directory.CreateDirectory(Path.Combine(ModsPath, name, "uninstall"));
                foreach (var file in GetRecursiveFiles(Path.Combine(ModsPath, name, "install")))
                {
                    var relative = file.Substring(Path.Combine(ModsPath, name, "install").Length + 1);
                    if (File.Exists(Path.Combine(Settings.settings.mhw_path, relative)))
                    {
                        File.Copy(Path.Combine(Settings.settings.mhw_path, relative), Path.Combine(ModsPath, name, "uninstall", relative));
                    }
                }
                var info = new ModInfo();

                info.GenInfo(name, null, true);
                return(true);
            }
            if (nativePCs.Count == 1)
            {
                MoveDirectory(nativePCs.First(), Path.Combine(ModsPath, name));
                return(true);
            }
            else if (nativePCs.Count == 0)
            {
                logStream.Warning("No nativePC found.");
                if (MessageBox.Show("No nativePC found, add the entire file as the nativePC folder ?", "Simple MHW Mod Manager", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    MoveDirectory(path, Path.Combine(ModsPath, name));
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                var dialog = new nativePcPicker(nativePCs.Select(str => str.Substring(path.Length + 1)));
                if (dialog.ShowDialog() == true)
                {
                    MoveDirectory(Path.Combine(path, dialog.Value), Path.Combine(ModsPath, name));
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }