Skip to content

Commit

Permalink
Added plugin install button
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzTacosOfficial committed Apr 19, 2023
1 parent c59ec9f commit 701a36d
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 104 deletions.
212 changes: 115 additions & 97 deletions NSMBe5/Plugin/PluginSelector.Designer.cs

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

52 changes: 45 additions & 7 deletions NSMBe5/Plugin/PluginSelector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using NSMBe5.DSFileSystem;
using System;
using System.Windows.Forms;

namespace NSMBe5.Plugin
Expand All @@ -14,12 +15,7 @@ public PluginSelector()

romPlugsCb.Checked = Properties.Settings.Default.EnableRomPlugin;

PluginInfo[] infos = PluginManager.GetAvailablePlugins();

foreach (PluginInfo info in infos)
{
pluginGridView.Rows.Add(info.id, info.name, info.priority.ToString(), info.enabled);
}
LoadGridViewElements();

Current = this;
}
Expand Down Expand Up @@ -51,6 +47,36 @@ private void saveBtn_Click(object sender, EventArgs e)
Close();
}

private void installButton_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();

dialog.Filter = "NSMBe Plugins (*.dll)|*.dll|All Files (*.*)|*.*";
dialog.FilterIndex = 1;
dialog.Multiselect = true;

DialogResult result = dialog.ShowDialog(this);

if (result != DialogResult.OK)
return;

string pluginPath = PluginManager.GetPluginDirectory();

if (!System.IO.Directory.Exists(pluginPath))
System.IO.Directory.CreateDirectory(pluginPath);

foreach (string path in dialog.FileNames)
{
string dest = System.IO.Path.Combine(pluginPath, System.IO.Path.GetFileName(path));

System.IO.File.Copy(path, dest);

PluginManager.LoadPlugin(dest);
}

LoadGridViewElements();
}

private void pluginGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 2)
Expand All @@ -68,6 +94,18 @@ private void PluginSelector_FormClosed(object sender, FormClosedEventArgs e)
Current = null;
}

private void LoadGridViewElements()
{
pluginGridView.Rows.Clear();

PluginInfo[] infos = PluginManager.GetAvailablePlugins();

foreach (PluginInfo info in infos)
{
pluginGridView.Rows.Add(info.id, info.name, info.priority.ToString(), info.enabled);
}
}

public static void Open()
{
if (Current != null)
Expand Down

0 comments on commit 701a36d

Please sign in to comment.