Skip to content

Commit a67b406

Browse files
committed
Hotfix: More errors checks
1 parent 1638e23 commit a67b406

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed

ERPLoader/Logger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ERPLoader
55
{
6-
static class Logger
6+
public static class Logger
77
{
88
private static readonly System.Threading.ReaderWriterLockSlim fileWriteLock = new();
99
private static DateTime Now => DateTime.Now;

ERPLoader/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ static void Main(string[] args)
6161
else
6262
{
6363
Logger.Warning("Found errors in your settings.json file. Please fix it and restart the app");
64-
Console.WriteLine("\nPress any key to exit...");
64+
Logger.NewLine();
65+
Logger.Log("Press any key to exit...");
6566
Console.ReadKey();
6667
}
6768

ERPLoader/Settings.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Text.Json;
3+
using System.Text.RegularExpressions;
34

45
namespace ERPLoader
56
{
@@ -53,14 +54,31 @@ public void SaveSettings()
5354

5455
public bool Verify()
5556
{
57+
Regex F1GameNameRegex = new(@"^f1_.+\.exe$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
58+
5659
if (string.IsNullOrWhiteSpace(F1GameDirectory)
5760
|| string.IsNullOrWhiteSpace(ModsFolderName)
5861
|| string.IsNullOrWhiteSpace(BackupFileExtension)
5962
|| string.IsNullOrWhiteSpace(DisabledModsEndsWith)
6063
|| string.IsNullOrWhiteSpace(FindReplaceFileName))
6164
return false;
6265

63-
return true;
66+
bool foundF1Exe = false;
67+
foreach (var file in Directory.EnumerateFiles(F1GameDirectory))
68+
{
69+
if (F1GameNameRegex.IsMatch(file))
70+
{
71+
foundF1Exe = true;
72+
break;
73+
}
74+
}
75+
76+
if (!foundF1Exe)
77+
{
78+
Logger.Error("F1 game path is incorrect! Please check your settings.json file and make sure the path is correctly pointing to F1 game folder");
79+
}
80+
81+
return foundF1Exe;
6482
}
6583
}
6684
}

EasyERPExplorer/Program.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using EasyERPExplorer.Renderer;
22
using EasyERPExplorer.Windows;
33
using ERPLoader;
4+
using System;
45

56
namespace EasyERPExplorer
67
{
@@ -9,16 +10,30 @@ class Program
910
[System.STAThread]
1011
static void Main()
1112
{
13+
Logger.FileWrite("===========EasyERPExplorer START===========");
14+
1215
Settings.InitSettings();
1316

14-
GameFolderExplorer gameFolderExplorer = new();
15-
ModsExplorer modsExplorer = new();
17+
if (Settings.Instance.Verify())
18+
{
19+
GameFolderExplorer gameFolderExplorer = new();
20+
ModsExplorer modsExplorer = new();
21+
22+
Window.DrawWindows.Add(gameFolderExplorer);
23+
Window.DrawWindows.Add(modsExplorer);
1624

17-
Window.DrawWindows.Add(gameFolderExplorer);
18-
Window.DrawWindows.Add(modsExplorer);
25+
Window wnd = new Window();
26+
wnd.Run();
27+
}
28+
else
29+
{
30+
Logger.Error("Cannot verify settings.json file. Please make sure the file contain valid info.");
31+
Logger.NewLine();
32+
Logger.Log("Press any to exit...");
33+
Console.ReadKey();
34+
}
1935

20-
Window wnd = new Window();
21-
wnd.Run();
36+
Logger.FileWrite("===========EasyERPExplorer EXIT===========");
2237
}
2338
}
2439
}

EasyERPExplorer/Renderer/ImGuiController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ private void RenderImDrawData(ImDrawDataPtr draw_data)
286286
int newSize = (int)Math.Max(_vertexBufferSize * 1.5f, vertexSize);
287287
GL.NamedBufferData(_vertexBuffer, newSize, IntPtr.Zero, BufferUsageHint.DynamicDraw);
288288
_vertexBufferSize = newSize;
289-
289+
#if DEBUG
290290
Console.WriteLine($"Resized dear imgui vertex buffer to new size {_vertexBufferSize}");
291+
#endif
291292
}
292293

293294
int indexSize = cmd_list.IdxBuffer.Size * sizeof(ushort);
@@ -296,8 +297,9 @@ private void RenderImDrawData(ImDrawDataPtr draw_data)
296297
int newSize = (int)Math.Max(_indexBufferSize * 1.5f, indexSize);
297298
GL.NamedBufferData(_indexBuffer, newSize, IntPtr.Zero, BufferUsageHint.DynamicDraw);
298299
_indexBufferSize = newSize;
299-
300+
#if DEBUG
300301
Console.WriteLine($"Resized dear imgui index buffer to new size {_indexBufferSize}");
302+
#endif
301303
}
302304
}
303305

0 commit comments

Comments
 (0)