show modal
This commit is contained in:
parent
cec8463118
commit
215946ba2b
|
@ -11,6 +11,7 @@ public class PluginUi : IDisposable {
|
|||
internal ViewerButton ViewerButton { get; }
|
||||
|
||||
private List<(string, string)> Modals { get; } = new();
|
||||
private Queue<string> ToShow { get; } = new();
|
||||
|
||||
internal PluginUi(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
@ -33,6 +34,10 @@ public class PluginUi : IDisposable {
|
|||
}
|
||||
|
||||
private void DrawModals() {
|
||||
while (this.ToShow.TryDequeue(out var toShow)) {
|
||||
ImGui.OpenPopup(toShow);
|
||||
}
|
||||
|
||||
var toRemove = -1;
|
||||
for (var i = 0; i < this.Modals.Count; i++) {
|
||||
var (id, text) = this.Modals[i];
|
||||
|
@ -57,11 +62,12 @@ public class PluginUi : IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
internal void AddModal(string text) {
|
||||
this.AddModal(Guid.NewGuid().ToString(), text);
|
||||
internal void ShowModal(string text) {
|
||||
this.ShowModal(Guid.NewGuid().ToString(), text);
|
||||
}
|
||||
|
||||
internal void AddModal(string id, string text) {
|
||||
internal void ShowModal(string id, string text) {
|
||||
this.Modals.Add((id, text));
|
||||
this.ToShow.Enqueue(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ internal class Settings : ITab {
|
|||
var text = await resp.Content.ReadAsStringAsync();
|
||||
if (uint.TryParse(text, out var extra)) {
|
||||
this.Plugin.Ui.MainWindow.ExtraMessages = extra;
|
||||
this.Plugin.Ui.AddModal($"Code claimed.\n\nYou can now post up to {10 + extra:N0} messages.");
|
||||
this.Plugin.Ui.ShowModal($"Code claimed.\n\nYou can now post up to {10 + extra:N0} messages.");
|
||||
} else {
|
||||
this.Plugin.Ui.AddModal("Code claimed but the server gave an unexpected response.");
|
||||
this.Plugin.Ui.ShowModal("Code claimed but the server gave an unexpected response.");
|
||||
}
|
||||
} else {
|
||||
this.Plugin.Ui.AddModal("Invalid code.");
|
||||
this.Plugin.Ui.ShowModal("Invalid code.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ internal class Write : ITab {
|
|||
this.Plugin.Ui.MainWindow.Visible = false;
|
||||
} else {
|
||||
var error = JsonConvert.DeserializeObject<ErrorMessage>(content);
|
||||
this.Plugin.Ui.AddModal($"Error writing message.\n\nMessage from server:\n{error?.Message}");
|
||||
this.Plugin.Ui.ShowModal($"Error writing message.\n\nMessage from server:\n{error?.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue