Skip to content

Commit 054987c

Browse files
committed
v1.0.2
Fixed cleanup before initsettings Other small changes
1 parent 2aaccef commit 054987c

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

ERPLoader/ERPLoader.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net5.0</TargetFramework>
6+
<StartupObject>ERPLoader.Program</StartupObject>
7+
<AssemblyVersion>1.0.2.0</AssemblyVersion>
8+
<Authors>Maxhyt</Authors>
9+
<RepositoryUrl>https://github.com/ducng99/EasyERPMod</RepositoryUrl>
10+
<FileVersion>1.0.2.0</FileVersion>
611
</PropertyGroup>
712

813
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -13,6 +18,8 @@
1318
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1419
<PlatformTarget>x64</PlatformTarget>
1520
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
21+
<DebugType>none</DebugType>
22+
<DebugSymbols>false</DebugSymbols>
1623
</PropertyGroup>
1724

1825
<ItemGroup>

ERPLoader/Program.cs

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,51 @@ namespace ERPLoader
1111
{
1212
class Program
1313
{
14-
public static Settings EasyModSettings { get; private set; } = new();
14+
public static Settings EasyModSettings { get; private set; }
1515
public static string ModsFolderPath { get; private set; }
1616

1717
private static readonly List<ModModel> ModsList = new();
1818

1919
static void Main(string[] args)
2020
{
21-
Cleanup();
22-
PrintIntro();
2321
InitSettings();
22+
23+
PrintIntro();
24+
Cleanup();
2425
LoadMods();
2526
StartMods();
2627

27-
var gameProcess = StartGame();
28-
29-
if (gameProcess != null)
28+
if (EasyModSettings.LaunchGame)
3029
{
31-
Logger.Log("Waiting for game exit...");
32-
Logger.Warning("Do not close this window if you want me to cleanup after you finish playing!");
30+
var gameProcess = StartGame();
3331

34-
gameProcess.WaitForExit();
32+
if (gameProcess != null)
33+
{
34+
Logger.Log("Waiting for game exit...");
35+
Logger.Warning("Do not close this window if you want me to cleanup after you finish playing!");
3536

36-
Logger.Log("Game exited! Start restoring files...\n");
37-
Cleanup();
37+
gameProcess.WaitForExit();
3838

39-
Logger.Log("Done! Thanks for using EasyERPMod :D");
40-
System.Threading.Thread.Sleep(3000);
39+
Logger.Log("Game exited! Start restoring files...\n");
40+
Cleanup();
41+
}
4142
}
43+
44+
Logger.Log("Done! Thanks for using EasyERPMod :D");
45+
System.Threading.Thread.Sleep(3000);
4246
}
4347

4448
private static void PrintIntro()
4549
{
46-
Console.WriteLine("[ ]----------------------[ ]");
47-
Console.WriteLine("[ ] EasyERPMod by Maxhyt [ ]");
48-
Console.WriteLine("[ ]----------------------[ ]");
50+
var version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(2);
51+
var versionStrLen = $"v{version} ".Length;
52+
53+
Console.Title = "EasyERPMod v" + version;
54+
55+
Console.Write("[ ]----------------------" + "-".Multiply(versionStrLen) + "[ ]");
56+
Console.WriteLine($"[ ] EasyERPMod by Maxhyt v{version} [ ]");
57+
Console.Write("[ ]----------------------" + "-".Multiply(versionStrLen) + "[ ]");
58+
4959
Console.WriteLine(@"
5060
-_______----.._pBQ;
5161
,^~|?|v^` .!|JWRd9NRNND00R0dJ1lllt
@@ -68,6 +78,11 @@ private static void InitSettings()
6878
{
6979
EasyModSettings = JsonSerializer.Deserialize<Settings>(File.ReadAllText(settingsFile));
7080
}
81+
else
82+
{
83+
EasyModSettings = new();
84+
Logger.Warning($"A new {settingsFile} file has been created, please update your F1 game path in the file.");
85+
}
7186

7287
File.WriteAllText(settingsFile, JsonSerializer.Serialize(EasyModSettings, new JsonSerializerOptions() { WriteIndented = true }));
7388
}
@@ -97,10 +112,7 @@ private static void LoadMods()
97112

98113
private static void StartMods()
99114
{
100-
foreach (var mod in ModsList)
101-
{
102-
mod.Process();
103-
}
115+
ModsList.ForEach(mod => mod.Process());
104116
}
105117

106118
private static Process StartGame()
@@ -131,6 +143,7 @@ private static Process StartGame()
131143
}
132144

133145
Logger.Log("Cannot find game's window");
146+
break;
134147
}
135148
}
136149

ERPLoader/Utils.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace ERPLoader
66
{
7-
class Utils
7+
static class Utils
88
{
99
private static readonly Dictionary<string, string[]> FilesCache = new();
1010

@@ -32,5 +32,11 @@ public static bool FileExists(Regex re, string folderPath)
3232

3333
return found;
3434
}
35+
36+
// I miss python "-" * length
37+
public static string Multiply(this string a, int times)
38+
{
39+
return string.Concat(System.Linq.Enumerable.Repeat(a, times));
40+
}
3541
}
3642
}

0 commit comments

Comments
 (0)