Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit eaf4f83

Browse files
authored
Merge pull request #39 from sepluginloader/dev
v1.10.3
2 parents 8662c4d + e7362ba commit eaf4f83

18 files changed

+115
-346
lines changed

PluginLoader/Data/GitHubPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public override Assembly GetAssembly()
8585

8686
string dllFile = Path.Combine(cacheDir, pluginFile);
8787
string commitFile = Path.Combine(cacheDir, commitHashFile);
88-
if (!File.Exists(dllFile) || !File.Exists(commitFile) || File.ReadAllText(commitFile) != Commit)
88+
if (!File.Exists(dllFile) || !File.Exists(commitFile) || File.ReadAllText(commitFile) != Commit || Main.Instance.Config.GameVersionChanged)
8989
{
9090
var lbl = Main.Instance.Splash;
9191
lbl.SetText($"Downloading '{FriendlyName}'");
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Reflection;
2+
3+
namespace avaness.PluginLoader.Data
4+
{
5+
internal class ObsoletePlugin : PluginData
6+
{
7+
public override string Source => "Obsolete";
8+
9+
public override Assembly GetAssembly()
10+
{
11+
return null;
12+
}
13+
14+
public override void Show()
15+
{
16+
17+
}
18+
}
19+
}

PluginLoader/Data/PluginData.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414

1515
namespace avaness.PluginLoader.Data
1616
{
17-
[XmlInclude(typeof(WorkshopPlugin))]
18-
[XmlInclude(typeof(SEPMPlugin))]
1917
[XmlInclude(typeof(GitHubPlugin))]
2018
[XmlInclude(typeof(ModPlugin))]
2119
[ProtoContract]
22-
[ProtoInclude(100, typeof(SteamPlugin))]
20+
[ProtoInclude(100, typeof(ObsoletePlugin))]
2321
[ProtoInclude(103, typeof(GitHubPlugin))]
2422
[ProtoInclude(104, typeof(ModPlugin))]
2523
public abstract class PluginData : IEquatable<PluginData>

PluginLoader/Data/SEPMPlugin.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.

PluginLoader/Data/SteamPlugin.cs

Lines changed: 0 additions & 117 deletions
This file was deleted.

PluginLoader/Data/WorkshopPlugin.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

PluginLoader/GUI/SplashScreen.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class SplashScreen : Form
1111
{
1212
private const float barWidth = 0.98f; // 98% of width
1313
private const float barHeight = 0.06f; // 6% of height
14+
private static readonly Color backgroundColor = Color.FromArgb(4, 4, 4);
1415

1516
private readonly bool invalid;
1617
private readonly Label lbl;
@@ -49,7 +50,7 @@ public SplashScreen()
4950
{
5051
Name = "PluginLoaderInfo",
5152
Font = lblFont,
52-
BackColor = Color.Black,
53+
BackColor = backgroundColor,
5354
ForeColor = Color.White,
5455
MaximumSize = Size,
5556
Size = new Size(Size.Width, lblFont.Height),

PluginLoader/LoaderTools.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Sandbox;
33
using Sandbox.Game.World;
44
using Sandbox.Graphics.GUI;
5-
using SEPluginManager;
65
using System;
76
using System.Diagnostics;
87
using System.IO;
@@ -50,12 +49,6 @@ public static void Restart()
5049
Process.GetCurrentProcess().Kill();
5150
}
5251

53-
public static void ExecuteMain(SEPMPlugin plugin)
54-
{
55-
string name = plugin.GetType().ToString();
56-
plugin.Main(new Harmony(name), new Logger());
57-
}
58-
5952
public static string GetHash1(string file)
6053
{
6154
using (SHA1Managed sha = new SHA1Managed())

PluginLoader/Main.cs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace avaness.PluginLoader
1919
{
2020
public class Main : IHandleInputPlugin
2121
{
22-
const string HarmonyVersion = "2.2.1.0";
22+
const string HarmonyVersion = "2.2.2.0";
2323

2424
public static Main Instance;
2525

@@ -68,11 +68,17 @@ public Main()
6868

6969
AppDomain.CurrentDomain.AssemblyResolve += ResolveDependencies;
7070

71+
Splash.SetText("Starting...");
7172
Config = PluginConfig.Load(pluginsDir);
73+
Config.CheckGameVersion();
7274
List = new PluginList(pluginsDir, Config);
73-
75+
76+
Splash.SetText("Starting...");
7477
Config.Init(List);
7578

79+
if (Config.GameVersionChanged)
80+
ClearGitHubCache(pluginsDir);
81+
7682
StatsClient.OverrideBaseUrl(Config.StatsServerBaseUrl);
7783

7884
Splash.SetText("Patching...");
@@ -114,6 +120,36 @@ public Main()
114120
Splash = null;
115121
}
116122

123+
private void ClearGitHubCache(string pluginsDir)
124+
{
125+
string pluginCache = Path.Combine(pluginsDir, "GitHub");
126+
if (!Directory.Exists(pluginCache))
127+
return;
128+
129+
bool hasGitHub = false;
130+
foreach(string id in Config.EnabledPlugins)
131+
{
132+
if(List.TryGetPlugin(id, out PluginData pluginData) && pluginData is GitHubPlugin)
133+
{
134+
hasGitHub = true;
135+
break;
136+
}
137+
}
138+
139+
if(hasGitHub)
140+
{
141+
DialogResult result = MessageBox.Show(LoaderTools.GetMainForm(), "Space Engineers has been updated so all GitHub plugins that are currently enabled must be downloaded and compiled. Press OK to continue.", "PluginLoader", MessageBoxButtons.OKCancel);
142+
if (result == DialogResult.Cancel)
143+
return;
144+
}
145+
146+
try
147+
{
148+
Directory.Delete(pluginCache);
149+
}
150+
catch { }
151+
}
152+
117153
public bool TryGetPluginInstance(string id, out PluginInstance instance)
118154
{
119155
instance = null;
@@ -237,14 +273,6 @@ private Assembly ResolveDependencies(object sender, ResolveEventArgs args)
237273
LogFile.WriteLine("Resolving 0Harmony");
238274
return typeof(Harmony).Assembly;
239275
}
240-
else if (args.Name.Contains("SEPluginManager"))
241-
{
242-
if (assembly != null)
243-
LogFile.WriteLine("Resolving SEPluginManager for " + assembly);
244-
else
245-
LogFile.WriteLine("Resolving SEPluginManager");
246-
return typeof(SEPluginManager.SEPMPlugin).Assembly;
247-
}
248276

249277
return null;
250278
}

0 commit comments

Comments
 (0)