General.WriteLogLine("Loading plugin '"+name+"' from '"+shortfilename+"'...");
try
{
// Load assembly
asm=Assembly.LoadFrom(filename);
}
catch(Exception)
{
General.ErrorLogger.Add(ErrorType.Error,"Could not load plugin \""+shortfilename+"\", the DLL file could not be read. This file is not supposed to be in the Plugins subdirectory.");
thrownewInvalidProgramException();
}
// Find the class that inherits from Plugin
Typet=FindSingleClass(typeof(Plug));
if(t!=null)
{
// Are the multiple plug classes?
if(FindClasses(typeof(Plug)).Length>1)
{
// Show a warning
General.ErrorLogger.Add(ErrorType.Warning,"Plugin \""+shortfilename+"\" has more than one Plug class. The following class is used to create in instance: "+t.FullName);
// Can't load this plugin because it is meant for a newer version
General.ErrorLogger.Add(ErrorType.Error,"Could not load plugin \""+shortfilename+"\", the Plugin is made for GZDoom Builder R"+plug.MinimumRevision+" or newer and you are running R"+thisrevision+".");
thrownewInvalidProgramException();
}
}
else
{
// How can we plug something in without a plug?
General.ErrorLogger.Add(ErrorType.Error,"Could not load plugin \""+shortfilename+"\", plugin is missing the Plug class. This file is not supposed to be in the Plugins subdirectory.");
thrownewInvalidProgramException();
}
// We have no destructor
GC.SuppressFinalize(this);
}
// Disposer
publicvoidDispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
plug.Dispose();//mxd
plug=null;//mxd
asm=null;
// Done
isdisposed=true;
}
}
#endregion
#region==================Methods
// This creates a stream to read a resource or returns null when not found
publicStreamGetResourceStream(stringresourcename)
{
// Find a resource
resourcename="."+resourcename;//mxd. Otherwise, we can get Properties.Resources.SuperCoolMode.png while searching for CoolMode.png