Skip to content

Commit

Permalink
Lib folder now supports loading from a direct subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
soopercool101 committed Mar 5, 2024
1 parent 99fa8a5 commit e3a2d4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions BrawlCrate/API/BrawlAPIInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ static BrawlAPIInternal()
Directory.Delete($"{Application.StartupPath}\\BrawlAPI\\Python", true);
}
// Setup IronPython engine
Engine.SetSearchPaths(new[]
{
$"{Application.StartupPath}\\BrawlAPI\\Lib\\Python",
$"{Application.StartupPath}\\BrawlAPI\\Lib"
});

UpdateSearchPaths();
fsi_path = Properties.Settings.Default.FSharpInstallationPath;

//Import BrawlCrate and Brawllib
Expand All @@ -76,6 +71,15 @@ static BrawlAPIInternal()
MainForm.Instance.resourceTree.SelectionChanged += ResourceTree_SelectionChanged;
}

internal static void UpdateSearchPaths()
{
string libPath = Path.GetFullPath($"{Application.StartupPath}\\BrawlAPI\\Lib");
if (!string.IsNullOrEmpty(libPath))
{
Engine.SetSearchPaths(Directory.GetDirectories(libPath).Append(libPath).ToArray());
}
}

internal static ScriptEngine Engine { get; set; }
internal static ScriptRuntime Runtime { get; set; }

Expand Down
1 change: 1 addition & 0 deletions BrawlCrate/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ public void reloadPluginsToolStripMenuItem_Click(object sender, EventArgs e)
pluginToolStripMenuItem.DropDown.Items.Clear();
AddPlugins(pluginToolStripMenuItem, Program.ApiPluginPath);
pluginToolStripMenuItem.Enabled = pluginToolStripMenuItem.HasDropDownItems;
BrawlAPIInternal.UpdateSearchPaths();
}

public static List<FileInfo> GetScripts(string path)
Expand Down

0 comments on commit e3a2d4a

Please sign in to comment.