feat: add error window for bad configs

This commit is contained in:
Anna 2020-07-29 22:42:57 -04:00
parent 1f51eb9ce4
commit 356c9854a3
2 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using Dalamud.Plugin;
using System;
namespace HudSwap {
public class HudSwapPlugin : IDalamudPlugin {
@ -11,8 +12,12 @@ namespace HudSwap {
public void Initialize(DalamudPluginInterface pluginInterface) {
this.pi = pluginInterface;
this.config = this.pi.GetPluginConfig() as Configuration ?? new Configuration();
try {
this.config = this.pi.GetPluginConfig() as Configuration ?? new Configuration();
} catch (Exception) {
this.pi.UiBuilder.OnBuildUi += PluginUI.ConfigError;
return;
}
this.config.Initialize(this.pi);
this.ui = new PluginUI(this, this.pi);

View File

@ -32,6 +32,17 @@ namespace HudSwap {
private string importName = "";
private Guid selectedLayout = Guid.Empty;
private static bool configErrorOpen = true;
public static void ConfigError() {
if (ImGui.Begin("HudSwap error", ref configErrorOpen)) {
ImGui.Text("Could not load HudSwap configuration.");
ImGui.Spacing();
ImGui.Text("If you are updating from a previous version, please\ndelete your configuration file and restart the game.");
ImGui.End();
}
}
public void DrawSettings() {
if (!this.SettingsVisible) {
return;