feat: automatically import HUD slots on first run
This commit is contained in:
parent
d1b122576d
commit
3b3a14e7b1
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue