feat: add way to open ui
This commit is contained in:
parent
d0d717a56d
commit
33068f3ce8
|
@ -24,6 +24,10 @@ internal class Command : IDisposable {
|
|||
|
||||
|
||||
private void OnCommand(string command, string arguments) {
|
||||
if (arguments == "config") {
|
||||
this.Plugin.Ui.Visible ^= true;
|
||||
}
|
||||
|
||||
using var bitmap = Photographer.Capture();
|
||||
if (bitmap == null) {
|
||||
return;
|
||||
|
|
|
@ -12,17 +12,25 @@ internal class PluginUi : IDisposable {
|
|||
private Plugin Plugin { get; }
|
||||
private FileDialogManager FileDialogManager { get; }
|
||||
|
||||
internal bool Visible;
|
||||
|
||||
internal PluginUi(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
this.FileDialogManager = new FileDialogManager();
|
||||
|
||||
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
|
||||
this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OpenConfigUi;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfigUi;
|
||||
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
|
||||
}
|
||||
|
||||
private void OpenConfigUi() {
|
||||
this.Visible = true;
|
||||
}
|
||||
|
||||
private void Draw() {
|
||||
try {
|
||||
this.FileDialogManager.Draw();
|
||||
|
@ -30,10 +38,14 @@ internal class PluginUi : IDisposable {
|
|||
Plugin.Log.Error(e, "Error in FileDialogManager.Draw");
|
||||
}
|
||||
|
||||
if (!this.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
using var end = new OnDispose(ImGui.End);
|
||||
|
||||
ImGui.SetNextWindowSize(new Vector2(350, 500), ImGuiCond.FirstUseEver);
|
||||
if (!ImGui.Begin(Plugin.Name)) {
|
||||
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue