feat(mosstank): add VTank-style automation PoC
This commit is contained in:
parent
f6fe0f2a4f
commit
4e6e9bc9d9
212 changed files with 49462 additions and 416 deletions
|
|
@ -17,6 +17,7 @@ public sealed class MossTankPlugin : IAcDreamPlugin
|
|||
private IPluginHost? _host;
|
||||
private MossTankPanel? _panel;
|
||||
private Action<double>? _tick;
|
||||
private IDisposable? _commandRegistration;
|
||||
|
||||
public void Initialize(IPluginHost host)
|
||||
{
|
||||
|
|
@ -36,10 +37,19 @@ public sealed class MossTankPlugin : IAcDreamPlugin
|
|||
string directory =
|
||||
Path.GetDirectoryName(typeof(MossTankPlugin).Assembly.Location) ?? ".";
|
||||
|
||||
// Two panels with complementary visible bindings stand in for a tab
|
||||
// control: only one is ever on screen, and switching is just an Action.
|
||||
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank.xml"), _panel);
|
||||
_host.Ui.AddMarkupPanel(Path.Combine(directory, "mosstank-settings.xml"), _panel);
|
||||
_host.Ui.AddPanel(
|
||||
new PluginPanelDescriptor("main", "MossTank")
|
||||
{
|
||||
IconText = "MT",
|
||||
StartVisible = true,
|
||||
ShowInSidePanel = true,
|
||||
},
|
||||
Path.Combine(directory, "mosstank.xml"),
|
||||
_panel);
|
||||
|
||||
_commandRegistration = _host.Commands.Register(
|
||||
"vt",
|
||||
_panel.ExecuteVtankCommand);
|
||||
|
||||
_tick = _panel.OnTick;
|
||||
_host.Events.Tick += _tick;
|
||||
|
|
@ -55,7 +65,10 @@ public sealed class MossTankPlugin : IAcDreamPlugin
|
|||
{
|
||||
if (_host is not null && _tick is not null)
|
||||
_host.Events.Tick -= _tick;
|
||||
_commandRegistration?.Dispose();
|
||||
_commandRegistration = null;
|
||||
_tick = null;
|
||||
_panel?.Disable();
|
||||
_host?.Log.Info("MossTank disabled");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue