Skip to content

Commit

Permalink
Added PluginUI and DisabledPluigins setting
Browse files Browse the repository at this point in the history
  • Loading branch information
EosBandi authored and meee1 committed Mar 3, 2020
1 parent 91fe003 commit 0375950
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 203 deletions.
8 changes: 8 additions & 0 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2994,6 +2994,8 @@ protected override void OnLoad(EventArgs e)
else
{
log.Info("Load Pluggins");
Plugin.PluginLoader.DisabledPluginNames.Clear();
foreach (var s in Settings.Instance.GetList("DisabledPlugins")) Plugin.PluginLoader.DisabledPluginNames.Add(s);
Plugin.PluginLoader.LoadAll();
log.Info("Load Pluggins... Done");
}
Expand Down Expand Up @@ -3771,6 +3773,12 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
ScreenShot();
return true;
}*/
if (keyData == (Keys.Control | Keys.P))
{
new PluginUI().Show();
return true;
}

if (keyData == (Keys.Control | Keys.G)) // nmea out
{
Form frm = new SerialOutputNMEA();
Expand Down
3 changes: 0 additions & 3 deletions MissionPlanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4229,9 +4229,6 @@
<EmbeddedResource Include="Log\MavlinkLog.zh-Hans.resx">
<DependentUpon>MavlinkLog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Plugin\PluginUI.resx">
<DependentUpon>PluginUI.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Radio\Sikradio.resx">
<DependentUpon>Sikradio.cs</DependentUpon>
</EmbeddedResource>
Expand Down
12 changes: 12 additions & 0 deletions Plugin/PluginLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class PluginLoader
{
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

//List of disabled plugins (as dll file names)
public static List<String> DisabledPluginNames = new List<String>();
// Plugin enable/disable settings changed not loaded but enabled plugins will not shown
public static bool bRestartRequired = false;

public static List<Plugin> Plugins = new List<Plugin>();

public static Dictionary<string, string[]> filecache = new Dictionary<string, string[]>();
Expand Down Expand Up @@ -87,6 +92,13 @@ public static void Load(String file)
)
return;

//Check if it is disabled (moved out from the previous IF, to make it loggable)
if (DisabledPluginNames.Contains(Path.GetFileName(file).ToLower()))
{
log.InfoFormat("Plugin {0} is disabled in config.xml", Path.GetFileName(file));
return;
}

// file exists in the install directory, so skip trying to load it as a plugin
if (File.Exists(file) && File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) +
Path.DirectorySeparatorChar + Path.GetFileName(file)))
Expand Down
177 changes: 119 additions & 58 deletions Plugin/PluginUI.Designer.cs

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

0 comments on commit 0375950

Please sign in to comment.