mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-02 05:43:42 +01:00
initial commit
This commit is contained in:
commit
0e7650f89b
27 changed files with 1596 additions and 0 deletions
68
Penumbra/Plugin.cs
Normal file
68
Penumbra/Plugin.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System.IO;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace Penumbra
|
||||
{
|
||||
public class Plugin : IDalamudPlugin
|
||||
{
|
||||
public string Name => "Penumbra";
|
||||
|
||||
private const string CommandName = "/penumbra";
|
||||
|
||||
public DalamudPluginInterface PluginInterface { get; set; }
|
||||
public Configuration Configuration { get; set; }
|
||||
|
||||
public Penumbra Penumbra { get; set; }
|
||||
|
||||
public ModManager ModManager { get; set; }
|
||||
|
||||
public SettingsInterface SettingsInterface { get; set; }
|
||||
|
||||
public void Initialize( DalamudPluginInterface pluginInterface )
|
||||
{
|
||||
PluginInterface = pluginInterface;
|
||||
|
||||
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
Configuration.Initialize( PluginInterface );
|
||||
|
||||
SettingsInterface = new SettingsInterface( this );
|
||||
PluginInterface.UiBuilder.OnBuildUi += SettingsInterface.Draw;
|
||||
|
||||
ModManager = new ModManager( new DirectoryInfo( Configuration.BaseFolder ) );
|
||||
ModManager.DiscoverMods();
|
||||
|
||||
Penumbra = new Penumbra( this );
|
||||
|
||||
|
||||
PluginInterface.CommandManager.AddHandler( CommandName, new CommandInfo( OnCommand )
|
||||
{
|
||||
HelpMessage = "/penumbra 0 will disable penumbra, /penumbra 1 will enable it."
|
||||
} );
|
||||
|
||||
Penumbra.Init();
|
||||
Penumbra.Enable();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
PluginInterface.UiBuilder.OnBuildUi -= SettingsInterface.Draw;
|
||||
|
||||
PluginInterface.CommandManager.RemoveHandler( CommandName );
|
||||
PluginInterface.Dispose();
|
||||
|
||||
Penumbra.Dispose();
|
||||
}
|
||||
|
||||
private void OnCommand( string command, string args )
|
||||
{
|
||||
if( args.Length > 0 )
|
||||
Configuration.IsEnabled = args[ 0 ] == '1';
|
||||
|
||||
if( Configuration.IsEnabled )
|
||||
Penumbra.Enable();
|
||||
else
|
||||
Penumbra.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue