Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/Languages/en-US.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@
<trans-unit id="type_other">
<source>Other</source>
</trans-unit>
<trans-unit id="type_plugin">
<source>Plugin</source>
</trans-unit>
<trans-unit id="type_select">
<source>Please select the package type:</source>
</trans-unit>
Expand Down
4 changes: 4 additions & 0 deletions source/OpenBVE/Game/Menu/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ internal void ProcessCommand(Translations.Command cmd, double timeElapsed)
installedFiles = string.Empty;
Manipulation.ExtractPackage(currentPackage, Program.FileSystem.OtherInstallationDirectory, Program.FileSystem.PackageDatabaseFolder, ref installedFiles);
break;
case PackageType.ContentPlugin:
installedFiles = string.Empty;
Manipulation.ExtractPackage(currentPackage, Program.FileSystem.PluginInstallationDirectory, Program.FileSystem.PackageDatabaseFolder, ref installedFiles);
break;
}
}
break;
Expand Down
41 changes: 28 additions & 13 deletions source/OpenBVE/UserInterface/formMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion source/OpenBVE/UserInterface/formMain.Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ private void Extract(Package packageToReplace = null)
case PackageType.Loksim3D:
ExtractionDirectory = Program.FileSystem.LoksimPackageInstallationDirectory;
break;
case PackageType.ContentPlugin:
ExtractionDirectory = Program.FileSystem.PluginInstallationDirectory;
break;
default:
ExtractionDirectory = Program.FileSystem.OtherInstallationDirectory;
break;
Expand Down Expand Up @@ -507,6 +510,7 @@ internal void UninstallPackage(Package packageToUninstall, bool force = false)
case PackageType.Train:
Packages = Database.currentDatabase.InstalledTrains;
break;
case PackageType.ContentPlugin:
case PackageType.Other:
Packages = Database.currentDatabase.InstalledOther;
break;
Expand Down Expand Up @@ -642,6 +646,7 @@ private void buttonUninstallPackage_Click(object sender, EventArgs e)
case PackageType.Train:
UninstallPackage(currentPackage);
break;
case PackageType.ContentPlugin:
case PackageType.Other:
case PackageType.Loksim3D:
UninstallPackage(currentPackage);
Expand Down Expand Up @@ -671,6 +676,7 @@ private void buttonUninstallFinish_Click(object sender, EventArgs e)
{
switch (currentPackage.PackageType)
{
case PackageType.ContentPlugin:
case PackageType.Other:
Database.currentDatabase.InstalledOther.Remove(currentPackage);
break;
Expand Down Expand Up @@ -1092,9 +1098,14 @@ private void Q2_CheckedChanged(object sender, EventArgs e)
{
newPackageType = PackageType.Train;
}
else if (radioButtonQ2Plugin.Checked)
{
newPackageType = PackageType.ContentPlugin;
}
else
{
newPackageType = PackageType.Other;
groupBoxQ1.Enabled = true;
}
if (radioButtonQ1Yes.Checked)
{
Expand Down Expand Up @@ -1585,7 +1596,7 @@ private void ResetInstallerPanels()
radioButtonQ1No.Checked = false;
radioButtonQ2Route.Checked = false;
radioButtonQ2Train.Checked = false;
radioButtonQ2Other.Checked = false;
radioButtonQ2Plugin.Checked = false;
//Reset picturebox
TryLoadImage(pictureBoxPackageImage, "route_unknown.png");
TryLoadImage(pictureBoxProcessing, "logo.png");
Expand Down
1 change: 1 addition & 0 deletions source/OpenBVE/UserInterface/formMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ private void ApplyLanguage()
replacePackageButton.Text = Translations.GetInterfaceString("packages_replace_select");
packageToReplaceLabel.Text = Translations.GetInterfaceString("packages_replace_choose");
//New package panel
radioButtonQ2Plugin.Text = Translations.GetInterfaceString("packages_type_plugin");
radioButtonQ2Other.Text = Translations.GetInterfaceString("packages_type_other");
radioButtonQ2Route.Text = Translations.GetInterfaceString("packages_type_route");
radioButtonQ2Train.Text = Translations.GetInterfaceString("packages_type_train");
Expand Down
24 changes: 12 additions & 12 deletions source/OpenBVE/UserInterface/formMain.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@
<metadata name="timerEvents.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn21.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn22.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn24.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down Expand Up @@ -192,18 +204,6 @@
<metadata name="dataGridViewTextBoxColumn12.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn21.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn22.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn24.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="openPackageFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
Expand Down
8 changes: 8 additions & 0 deletions source/OpenBveApi/Interface/Input/InputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ public static void LoadPlugins(FileSystem.FileSystem fileSystem)
return;
}
string[] PluginFiles = System.IO.Directory.GetFiles(PluginsFolder, "*.dll");
string[] UserPluginFiles = System.IO.Directory.GetFiles(FileSystem.PluginInstallationDirectory, "*.dll");
if (UserPluginFiles.Length != 0)
{
int startIdx = PluginFiles.Length;
Array.Resize(ref PluginFiles, startIdx + UserPluginFiles.Length);
Array.Copy(UserPluginFiles, 0, PluginFiles, startIdx, UserPluginFiles.Length);
}

foreach (var File in PluginFiles)
{
Assembly Plugin;
Expand Down
2 changes: 2 additions & 0 deletions source/OpenBveApi/Packages/Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public enum PackageType
Other = 3,
/// <summary>The package contains imported Loksim3D content.</summary>
Loksim3D = 4,
/// <summary>The package contains a content loading plugin</summary>
ContentPlugin = 5
}

/// <summary>Holds the properties of a file, used during creation of a package.</summary>
Expand Down
4 changes: 4 additions & 0 deletions source/OpenBveApi/System/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class FileSystem {

/// <summary>The location to which packaged other items will be installed</summary>
public string OtherInstallationDirectory;

/// <summary>The location to which user plugins will be installed</summary>
public string PluginInstallationDirectory;

/// <summary>The location to which Loksim3D packages will be installed</summary>
public string LoksimPackageInstallationDirectory;
Expand Down Expand Up @@ -99,6 +102,7 @@ internal FileSystem(HostInterface Host)
this.DataFolder = OpenBveApi.Path.CombineDirectory(assemblyFolder, "Data");
this.ManagedContentFolders = new string[] { OpenBveApi.Path.CombineDirectory(userDataFolder, "ManagedContent") };
this.SettingsFolder = OpenBveApi.Path.CombineDirectory(userDataFolder, "Settings");
this.PluginInstallationDirectory = OpenBveApi.Path.CombineDirectory(userDataFolder, "Plugins");
this.InitialRouteFolder = OpenBveApi.Path.CombineDirectory(OpenBveApi.Path.CombineDirectory(OpenBveApi.Path.CombineDirectory(userDataFolder, "LegacyContent"), "Railway"), "Route");
this.RouteInstallationDirectory = OpenBveApi.Path.CombineDirectory(OpenBveApi.Path.CombineDirectory(userDataFolder, "LegacyContent"), "Railway");
this.InitialTrainFolder = OpenBveApi.Path.CombineDirectory(OpenBveApi.Path.CombineDirectory(userDataFolder, "LegacyContent"), "Train");
Expand Down
16 changes: 12 additions & 4 deletions source/OpenBveApi/System/Hosts.Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Reflection;
using System.Text;
using OpenBveApi.Interface;

namespace OpenBveApi.Hosts
{
Expand All @@ -18,6 +19,13 @@ public bool LoadPlugins(FileSystem.FileSystem fileSystem, BaseOptions currentOpt
try
{
files = Directory.GetFiles(folder);
string[] UserPluginFiles = Directory.GetFiles(fileSystem.PluginInstallationDirectory, "*.dll");
if (UserPluginFiles.Length != 0)
{
int startIdx = files.Length;
Array.Resize(ref files, startIdx + UserPluginFiles.Length);
Array.Copy(UserPluginFiles, 0, files, startIdx, UserPluginFiles.Length);
}
}
catch
{
Expand Down Expand Up @@ -59,7 +67,7 @@ public bool LoadPlugins(FileSystem.FileSystem fileSystem, BaseOptions currentOpt

continue;
}
bool iruntime = false;
bool knownType = false;
foreach (Type type in types)
{
if (type.FullName == null)
Expand Down Expand Up @@ -90,9 +98,9 @@ public bool LoadPlugins(FileSystem.FileSystem fileSystem, BaseOptions currentOpt
plugin.Train = (Trains.TrainInterface) assembly.CreateInstance(type.FullName);
}

if (typeof(Runtime.IRuntime).IsAssignableFrom(type))
if (typeof(Runtime.IRuntime).IsAssignableFrom(type) || typeof(IInputDevice).IsAssignableFrom(type))
{
iruntime = true;
knownType = true;
}
}

Expand All @@ -101,7 +109,7 @@ public bool LoadPlugins(FileSystem.FileSystem fileSystem, BaseOptions currentOpt
plugin.Load(this, fileSystem, currentOptions, TrainManagerReference, RendererReference);
list.Add(plugin);
}
else if (!iruntime)
else if (!knownType)
{
builder.Append("Plugin ").Append(System.IO.Path.GetFileName(file)).AppendLine(" does not implement compatible interfaces.");
builder.AppendLine();
Expand Down