-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cb7ba2
commit b26baad
Showing
7 changed files
with
115 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Heliosphere.Util; | ||
using ImGuiNET; | ||
|
||
namespace Heliosphere.Ui.Dialogs; | ||
|
||
internal abstract class Dialog : IDrawable { | ||
internal string Title { get; } | ||
private ImGuiWindowFlags WindowFlags { get; } | ||
private bool _visible = true; | ||
|
||
protected Dialog(string title, ImGuiWindowFlags windowFlags = ImGuiWindowFlags.None) { | ||
this.Title = title; | ||
this.WindowFlags = windowFlags; | ||
} | ||
|
||
public virtual void Dispose() { | ||
} | ||
|
||
public DrawStatus Draw() { | ||
if (!this._visible) { | ||
return DrawStatus.Finished; | ||
} | ||
|
||
using var end = new OnDispose(ImGui.End); | ||
if (!ImGui.Begin(this.Title, ref this._visible, this.WindowFlags)) { | ||
return DrawStatus.Continue; | ||
} | ||
|
||
return this.InnerDraw(); | ||
} | ||
|
||
protected abstract DrawStatus InnerDraw(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using ImGuiNET; | ||
|
||
namespace Heliosphere.Ui.Dialogs; | ||
|
||
internal class GenericDialog : Dialog { | ||
private Func<DrawStatus> Drawer { get; } | ||
|
||
internal GenericDialog(string title, Func<DrawStatus> draw, ImGuiWindowFlags flags = ImGuiWindowFlags.None) : base(title, flags) { | ||
this.Drawer = draw; | ||
} | ||
|
||
protected override DrawStatus InnerDraw() { | ||
try { | ||
return this.Drawer(); | ||
} catch (Exception ex) { | ||
Plugin.Log.Error(ex, $"Failed to draw generic dialog \"{this.Title}\""); | ||
return DrawStatus.Finished; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Numerics; | ||
using Heliosphere.Util; | ||
using ImGuiNET; | ||
|
||
namespace Heliosphere.Ui.Dialogs; | ||
|
||
internal class VersionMismatchDialog : Dialog { | ||
private Version Dalamud { get; } | ||
private Version Actual { get; } | ||
|
||
public VersionMismatchDialog(Version dalamud, Version actual) : base("Heliosphere##version-mismatch") { | ||
this.Dalamud = dalamud; | ||
this.Actual = actual; | ||
} | ||
|
||
protected override DrawStatus InnerDraw() { | ||
ImGuiHelper.TextUnformattedCentred("Version mismatch", PluginUi.TitleSize); | ||
|
||
ImGui.Spacing(); | ||
|
||
ImGui.TextUnformatted($"Dalamud thinks you have version {this.Dalamud.ToString(3)} installed, but this is actually version {this.Actual.ToString(3)}."); | ||
ImGui.TextUnformatted($"To fix this, open the plugin installer and disable, delete, and reinstall {Plugin.Name}."); | ||
|
||
ImGui.Spacing(); | ||
|
||
return ImGui.Button("Close", new Vector2(ImGui.GetContentRegionAvail().X, 0)) | ||
? DrawStatus.Finished | ||
: DrawStatus.Continue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters