-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreateMod.xaml.cs
More file actions
56 lines (49 loc) · 1.85 KB
/
Copy pathCreateMod.xaml.cs
File metadata and controls
56 lines (49 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Windows;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
namespace Concursus
{
/// <summary>
/// Interaction logic for CreateMod.xaml
/// </summary>
public partial class CreateMod : Window
{
List<string> current_mod_names = MainWindow.current_mods.Select(e => e.folder_name).ToList();
public CreateMod()
{
InitializeComponent();
Themes.UpdateForm(Themes.CURRENT_THEME, this);
this.Title = $"Create Mod for {MainWindow.selected_game.GameName}";
}
private void button_Click(object sender, RoutedEventArgs e)
{
string new_mod_name = txtName.Text.Trim();
if (new_mod_name == String.Empty)
{
MessageBox.Show("Mod Name cannot be empty!", "Can't create mod", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (new_mod_name.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
{
MessageBox.Show($"Mod Name contains illegal characters!\n\n{String.Join(',', Path.GetInvalidPathChars())}", "Can't create mod", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (current_mod_names.Contains(new_mod_name))
{
MessageBox.Show("A mod folder with that name already exists!", "Can't create mod", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
MainWindow.selected_game.CreateNewMod(new_mod_name, new ModConfig()
{
name = new_mod_name,
author = txtAuthor.Text.Trim(),
version = txtVersion.Text.Trim(),
description = txtDescription.Text.Trim()
});
this.Close();
}
}
}