feat: automatically import HUD slots on first run

This commit is contained in:
Anna 2020-07-30 13:53:13 -04:00
parent d1b122576d
commit 3b3a14e7b1
3 changed files with 20 additions and 2 deletions

View File

@ -11,6 +11,8 @@ namespace HudSwap {
[NonSerialized]
private DalamudPluginInterface pi;
public bool FirstRun { get; set; } = true;
public bool SwapsEnabled { get; set; } = false;
public Guid defaultLayout = Guid.Empty;

View File

@ -23,6 +23,16 @@ namespace HudSwap {
this.ui = new PluginUI(this, this.pi);
this.hud = new HUD(this.pi);
if (this.config.FirstRun) {
this.config.FirstRun = false;
if (this.config.Layouts.Count == 0) {
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
this.ui.ImportSlot(slot, $"Auto-import {(int)slot + 1}", false);
}
}
this.config.Save();
}
this.pi.UiBuilder.OnBuildUi += this.ui.Draw;
this.pi.UiBuilder.OnOpenConfigUi += this.ui.ConfigUI;

View File

@ -92,9 +92,8 @@ namespace HudSwap {
foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) {
string buttonName = $"{(int)slot + 1}##import";
if (ImGui.Button(buttonName) && this.importName != "") {
this.plugin.config.Layouts[Guid.NewGuid()] = new Tuple<string, byte[]>(this.importName, this.plugin.hud.ReadLayout(slot));
this.ImportSlot(slot, this.importName);
this.importName = "";
this.plugin.config.Save();
}
if (slot != HudSlot.Four) {
ImGui.SameLine();
@ -198,6 +197,13 @@ namespace HudSwap {
}
ImGui.NextColumn();
}
public void ImportSlot(HudSlot slot, string name, bool save = true) {
this.plugin.config.Layouts[Guid.NewGuid()] = new Tuple<string, byte[]>(name, this.plugin.hud.ReadLayout(slot));
if (save) {
this.plugin.config.Save();
}
}
}
public class Statuses {