Skip to content

Commit 05fde3a

Browse files
committed
[Major] If crashed while patching, the log now displays which mods were patched, which one failed and the other on hold
1 parent b5af1a4 commit 05fde3a

6 files changed

Lines changed: 33 additions & 2 deletions

File tree

Controls/ModInfos.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private async void Save_Click(object sender, EventArgs e)
4242
}
4343
catch(Exception ex)
4444
{
45+
Main.Instance.LogModList();
4546
Log.Error(ex, "Something went wrong");
4647
Log.Information("Failed patching vanilla");
4748
MessageBox.Show(Application.Current.FindResource("SaveDataWarning").ToString());

Controls/ModSourceInfos.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private async void Save_Click(object sender, EventArgs e)
4141
}
4242
catch(Exception ex)
4343
{
44+
Main.Instance.LogModList();
4445
Log.Error(ex, "Something went wrong");
4546
Log.Information("Failed patching vanilla");
4647
MessageBox.Show(Application.Current.FindResource("SaveDataWarning").ToString());

FileReader.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public override string ToString()
3030
return Name;
3131
}
3232
}
33+
public enum PatchStatus
34+
{
35+
None,
36+
Patching,
37+
Success,
38+
}
3339
public class ModFile
3440
{
3541
public string Name;
@@ -41,6 +47,7 @@ public class ModFile
4147
public string Path;
4248
public Mod instance { get; set; }
4349
public bool isEnabled { get; set; }
50+
public PatchStatus PatchStatus { get; set; } = PatchStatus.None;
4451
public bool isExisted => File.Exists(Path);
4552
public byte[] Icon { get; set; } = Array.Empty<byte>();
4653
public override string ToString()

Main.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using ModShardLauncher.Controls;
2-
using ModShardLauncher.Controls;
32
using Newtonsoft.Json;
43
using System;
54
using System.Collections.Generic;
@@ -12,6 +11,7 @@
1211
using Serilog.Core;
1312
using Serilog.Events;
1413
using System.Runtime.InteropServices;
14+
using ModShardLauncher.Mods;
1515

1616
namespace ModShardLauncher
1717
{
@@ -75,7 +75,28 @@ public Main()
7575

7676
Viewer.Content = MainPage;
7777
}
78+
public void LogModList()
79+
{
80+
foreach (ModFile modFile in ModPage.Mods.Where(x => x.isEnabled))
81+
{
82+
string statusMessage = "";
83+
switch(modFile.PatchStatus)
84+
{
85+
case PatchStatus.Patching:
86+
statusMessage = "Patching failed";
87+
break;
88+
89+
case PatchStatus.Success:
90+
statusMessage = "Patching successed";
91+
break;
7892

93+
case PatchStatus.None:
94+
statusMessage = "Waiting to be patched";
95+
break;
96+
}
97+
Log.Warning("Patching {{{2}}} for {{{0}}} {{{1}}}", modFile.Name, modFile.Version, statusMessage);
98+
}
99+
}
79100
private void MyToggleButton_Checked(object sender, EventArgs e)
80101
{
81102
foreach(var i in stackPanel.Children)

ModLoader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public static void PatchMods()
173173
continue;
174174
}
175175
Main.Settings.EnableMods.Add(mod.Name);
176+
mod.PatchStatus = PatchStatus.Patching;
176177

177178
// work around to find the FileVersion of ModShardLauncher.dll for single file publishing
178179
// see: https://github.com/dotnet/runtime/issues/13051
@@ -196,6 +197,7 @@ public static void PatchMods()
196197
if (type.IsSubclassOf(typeof(Weapon)))
197198
LoadWeapon(type);
198199
}
200+
mod.PatchStatus = PatchStatus.Success;
199201
}
200202
}
201203
public static void LoadWeapon(Type type)

ModUtils/AsmUtils.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ public static void CheckRefVariableOrCreate(string name, UndertaleInstruction.In
182182
{
183183
Log.Information(string.Format("Found variable: {0}", variable.ToString()));
184184
}
185-
186185
}
187186
catch
188187
{

0 commit comments

Comments
 (0)