-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathModInfos.xaml.cs
More file actions
77 lines (71 loc) · 2.26 KB
/
ModInfos.xaml.cs
File metadata and controls
77 lines (71 loc) · 2.26 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using ModShardLauncher.Core.Errors;
using ModShardLauncher.Core.UI;
using ModShardLauncher.Mods;
using Serilog;
namespace ModShardLauncher.Controls
{
/// <summary>
/// ModInfos.xaml 的交互逻辑
/// </summary>
public partial class ModInfos : UserControl
{
public static ModInfos Instance;
public List<ModFile> Mods { get; set; } = new();
public ModInfos()
{
InitializeComponent();
Instance = this;
}
private async void Open_Click(object sender, EventArgs e)
{
await DataLoader.DoOpenDialog();
Main.Instance.Refresh();
}
private async void Save_Click(object sender, EventArgs e)
{
if (DataLoader.data.FORM == null)
{
MessageBox.Show(Application.Current.FindResource("LoadDataWarning").ToString());
return;
}
MSLDiagnostic? diag = ModLoader.PatchFile();
if (diag is null)
{
Main.Instance.LogModListStatus();
Log.Information("Successfully patch vanilla");
Task<bool> save = DataLoader.DoSaveDialog();
await save;
if (save.Result)
{
LootUtils.SaveLootTables(Msl.ThrowIfNull(Path.GetDirectoryName(DataLoader.savedDataPath)));
}
else
{
Log.Information("Saved cancelled.");
}
}
else
{
Main.Instance.LogModListStatus();
Log.Information("Failed patching vanilla");
ErrorMessageDialog.Show(diag.Title(), diag.MessageDialog(), Main.Instance.logPath);
}
// reload the data
await DataLoader.LoadFile(DataLoader.dataPath);
Main.Instance.Refresh();
}
private void Server_Click(object sender, EventArgs e)
{
ModInterfaceServer.StartServer(1333);
Main.Instance.Refresh();
}
}
}