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++;
            }
        }
Beispiel #2
0
        private void saveBTN_Click(object sender, RoutedEventArgs e)
        {
            int     order = Int32.Parse(orderTB.Text);
            ModInfo mod   = App.Mods[originalOrder];

            mod.name = nameTB.Text;
            //TODO
            //App.Mods[order].replacedArmors = selectedItems.Items;
            if (order != originalOrder)
            {
                mod.order = order;
                //Number already exists, swap them
                if (App.Mods[order] != null)
                {
                    ModInfo swappedWith = App.Mods[order];
                    swappedWith.order       = originalOrder;
                    App.Mods[order]         = mod;
                    App.Mods[originalOrder] = swappedWith;
                }
            }
            mod.SaveSettingsJSON(System.IO.Path.Combine(App.ModsPath, mod.path));
            Close();
        }
Beispiel #3
0
        public EditWindow(ModInfo info)
        {
            InitializeComponent();
            originalName  = info.name;
            originalOrder = info.order;
            nameTB.Text   = info.name;
            orderTB.Text  = info.order.ToString();

            this.DataContext = this;

            #region Adding items
            info.replacedArmors.Where(a => a.type == Armor.ARMOR_SLOT.HEAD).ToList().ForEach(a => { addedHeads.Add(a); displayedAddedHeads.Add(a); });
            info.replacedArmors.Where(a => a.type == Armor.ARMOR_SLOT.CHEST).ToList().ForEach(a => { addedChests.Add(a); displayedAddedChests.Add(a); });
            info.replacedArmors.Where(a => a.type == Armor.ARMOR_SLOT.ARMS).ToList().ForEach(a => { addedArms.Add(a); displayedAddedArms.Add(a); });
            info.replacedArmors.Where(a => a.type == Armor.ARMOR_SLOT.WAIST).ToList().ForEach(a => { addedWaists.Add(a); displayedAddedWaists.Add(a); });
            info.replacedArmors.Where(a => a.type == Armor.ARMOR_SLOT.LEGS).ToList().ForEach(a => { addedLegs.Add(a); displayedAddedLegs.Add(a); });
            info.replacedWeapons.Where(w => !String.IsNullOrWhiteSpace(w.main_model)).ToList().ForEach(w => { addedMain.Add(w); displayedAddedMain.Add(w); });
            info.replacedWeapons.Where(w => !String.IsNullOrWhiteSpace(w.part_model)).ToList().ForEach(w => { addedPart.Add(w); displayedAddedPart.Add(w); });

            App.armors[Armor.ARMOR_SLOT.HEAD].Where(a => !addedHeads.Contains(a)).ToList().ForEach(a => { allHeads.Add(a); displayedAllHeads.Add(a); });
            App.armors[Armor.ARMOR_SLOT.CHEST].Where(a => !addedHeads.Contains(a)).ToList().ForEach(a => { allChests.Add(a); displayedAllChests.Add(a); });
            App.armors[Armor.ARMOR_SLOT.ARMS].Where(a => !addedHeads.Contains(a)).ToList().ForEach(a => { allArms.Add(a); displayedAllArms.Add(a); });
            App.armors[Armor.ARMOR_SLOT.WAIST].Where(a => !addedHeads.Contains(a)).ToList().ForEach(a => { allWaists.Add(a); displayedAllWaists.Add(a); });
            App.armors[Armor.ARMOR_SLOT.LEGS].Where(a => !addedHeads.Contains(a)).ToList().ForEach(a => { allLegs.Add(a); displayedAllLegs.Add(a); });
            App.weapons.Where(w => !String.IsNullOrWhiteSpace(w.main_model) && !addedMain.Select(x => x.ID).Contains(w.ID)).ToList().ForEach(w => { allMain.Add(w); displayedAllMain.Add(w); });
            App.weapons.Where(w => !String.IsNullOrWhiteSpace(w.part_model) && !addedPart.Select(x => x.ID).Contains(w.ID)).ToList().ForEach(w => { allPart.Add(w); displayedAllPart.Add(w); });
            #endregion

            #region Tab visibility
            if (addedHeads.Count < 1 && addedChests.Count < 1 && addedArms.Count < 1 && addedWaists.Count < 1 && addedLegs.Count < 1)
            {
                PossibleArmorTab.Visibility = Visibility.Collapsed;
                AddedArmorTab.Visibility    = Visibility.Collapsed;
            }
            else
            {
                if (addedHeads.Count < 1)
                {
                    AddedHeadTab.Visibility = Visibility.Collapsed;
                    AddedHeadTab.Visibility = Visibility.Collapsed;
                }
                if (addedChests.Count < 1)
                {
                    PossibleChestTab.Visibility = Visibility.Collapsed;
                    AddedChestTab.Visibility    = Visibility.Collapsed;
                }
                if (addedArms.Count < 1)
                {
                    PossibleArmTab.Visibility = Visibility.Collapsed;
                    AddedArmTab.Visibility    = Visibility.Collapsed;
                }
                if (addedWaists.Count < 1)
                {
                    PossibleWaistTab.Visibility = Visibility.Collapsed;
                    AddedWaistTab.Visibility    = Visibility.Collapsed;
                }
                if (addedLegs.Count < 1)
                {
                    PossibleLegTab.Visibility = Visibility.Collapsed;
                    AddedLegTab.Visibility    = Visibility.Collapsed;
                }
            }

            if (addedMain.Count < 1 && addedPart.Count < 1)
            {
                PossibleWeaponTab.Visibility = Visibility.Collapsed;
                AddedWeaponTab.Visibility    = Visibility.Collapsed;
            }
            else
            {
                if (addedMain.Count < 1)
                {
                    PossibleMainTab.Visibility = Visibility.Collapsed;
                    AddedMainTab.Visibility    = Visibility.Collapsed;
                }
                if (addedPart.Count < 1)
                {
                    PossiblePartialTab.Visibility = Visibility.Collapsed;
                    AddedPartialTab.Visibility    = Visibility.Collapsed;
                }
            }
            #endregion
        }
Beispiel #4
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);
                }
            }
        }