Exemple #1
0
        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            var newMod = new NewModDialog()
            {
                Owner = this
            };
            var result = newMod.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            // Get unique directory
            string modPath = Path.Combine(ModDatabase.ModDirectory, SelectedGame.ToString(), newMod.ModTitle);

            if (Directory.Exists(modPath))
            {
                var newModPath = modPath;
                int i          = 0;

                while (Directory.Exists(newModPath))
                {
                    newModPath = modPath + "_" + i++;
                }

                modPath = newModPath;
            }

            // Build mod
            var mod = new ModBuilder()
                      .SetGame(SelectedGame)
                      .SetTitle(newMod.ModTitle)
                      .SetDescription(newMod.Description)
                      .SetVersion(newMod.Version)
                      .SetDate(DateTime.UtcNow.ToShortDateString())
                      .SetAuthor(newMod.Author)
                      .SetUrl(newMod.Url)
                      .SetUpdateUrl(newMod.UpdateUrl)
                      .SetBaseDirectoryPath(modPath)
                      .Build();

            // Do actual saving
            var modLoader = new XmlModLoader();

            modLoader.Save(mod);

            // Reload
            RefreshModDatabase();
        }
Exemple #2
0
        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            var newMod = new NewModDialog()
            {
                Owner = this
            };
            var result = newMod.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            // Get unique directory
            string folderPath = Path.Combine(ModDatabase.ModDirectory, SelectedGame.ToString());

            string[] gamePath = Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories);
            if (FolderComboBox.SelectedItem.ToString() != "All Folders")
            {
                foreach (string folder in gamePath)
                {
                    if (Path.GetFileName(folder) == FolderComboBox.SelectedItem.ToString())
                    {
                        folderPath = folder;
                    }
                }
            }
            string modPath = Path.Combine(folderPath, newMod.ModTitle);

            if (Directory.Exists(modPath))
            {
                var newModPath = modPath;
                int i          = 0;

                while (Directory.Exists(newModPath))
                {
                    newModPath = modPath + "_" + i++;
                }

                modPath = newModPath;
            }

            // Build mod
            var mod = new ModBuilder()
                      .SetGame(SelectedGame)
                      .SetTitle(newMod.ModTitle)
                      .SetDescription(newMod.Description)
                      .SetVersion(newMod.Version)
                      .SetDate(DateTime.UtcNow.ToShortDateString())
                      .SetAuthor(newMod.Author)
                      .SetUrl(newMod.Url)
                      .SetUpdateUrl(newMod.UpdateUrl)
                      .SetBaseDirectoryPath(modPath)
                      .Build();

            // Do actual saving
            var modLoader = new XmlModLoader();

            modLoader.Save(mod);

            // Reload
            RefreshModDatabase();
            RefreshMods();
        }