feat: warning modal for testing plugin downgrades

This commit is contained in:
goat 2022-10-29 23:29:51 +02:00
parent 09c4828a9e
commit 86b381ea49
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -69,6 +69,9 @@ internal class PluginInstallerWindow : Window, IDisposable
private LocalPlugin? updateModalPlugin = null;
private TaskCompletionSource<bool>? updateModalTaskCompletionSource;
private bool testingWarningModalDrawing = true;
private bool testingWarningModalOnNextFrame = false;
private bool feedbackModalDrawing = true;
private bool feedbackModalOnNextFrame = false;
private bool feedbackModalOnNextFrameDontClear = false;
@ -215,6 +218,7 @@ internal class PluginInstallerWindow : Window, IDisposable
this.DrawFooter();
this.DrawErrorModal();
this.DrawUpdateModal();
this.DrawTestingWarningModal();
this.DrawFeedbackModal();
this.DrawProgressOverlay();
}
@ -634,6 +638,39 @@ internal class PluginInstallerWindow : Window, IDisposable
}
}
private void DrawTestingWarningModal()
{
var modalTitle = Locs.TestingWarningModal_Title;
if (ImGui.BeginPopupModal(modalTitle, ref this.testingWarningModalDrawing, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar))
{
ImGui.Text(Locs.TestingWarningModal_DowngradeBody);
ImGuiHelpers.ScaledDummy(10);
var buttonWidth = 120f;
ImGui.SetCursorPosX((ImGui.GetWindowWidth() - buttonWidth) / 2);
if (ImGui.Button(Locs.ErrorModalButton_Ok, new Vector2(buttonWidth, 40)))
{
ImGui.CloseCurrentPopup();
}
ImGui.EndPopup();
}
if (this.testingWarningModalOnNextFrame)
{
// NOTE(goat): ImGui cannot open a modal if no window is focused, at the moment.
// If people click out of the installer into the game while a plugin is installing, we won't be able to show a modal if we don't grab focus.
ImGui.SetWindowFocus(this.WindowName);
ImGui.OpenPopup(modalTitle);
this.testingWarningModalOnNextFrame = false;
this.testingWarningModalDrawing = true;
}
}
private void DrawFeedbackModal()
{
var modalTitle = Locs.FeedbackModal_Title;
@ -2063,6 +2100,11 @@ internal class PluginInstallerWindow : Window, IDisposable
if (optIn != null)
{
configuration.PluginTestingOptIns!.Remove(optIn);
if (plugin.Manifest.TestingAssemblyVersion > repoManifest?.AssemblyVersion)
{
this.testingWarningModalOnNextFrame = true;
}
}
else
{
@ -3028,6 +3070,14 @@ internal class PluginInstallerWindow : Window, IDisposable
#endregion
#region Testing Warning Modal
public static string TestingWarningModal_Title => Loc.Localize("InstallerTestingWarning", "Warning###InstallerTestingWarning");
public static string TestingWarningModal_DowngradeBody => Loc.Localize("InstallerTestingWarningDowngradeBody", "Take care! If you opt out of testing for a plugin, you will remain on the testing version until it is deleted and reinstalled, or the non-testing version of the plugin is updated.\nKeep in mind that you may lose the settings for this plugin if you downgrade manually.");
#endregion
#region Plugin Update chatbox
public static string PluginUpdateHeader_Chatbox => Loc.Localize("DalamudPluginUpdates", "Updates:");