v1.0.2.0: Restore Hotbar Layout, fix config right-click menu, hotbar fallback
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using HSUI.Config;
|
||||
using HSUI.Config.Attributes;
|
||||
using HSUI.Enums;
|
||||
using HSUI.Helpers;
|
||||
using HSUI.Interface;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
@@ -83,7 +84,7 @@ namespace HSUI.Interface.GeneralElements
|
||||
return config;
|
||||
}
|
||||
|
||||
protected static void ApplyDefaults(HotbarBarConfig config, int hotbarIndex)
|
||||
public static void ApplyDefaults(HotbarBarConfig config, int hotbarIndex)
|
||||
{
|
||||
var viewport = ImGui.GetMainViewport().Size;
|
||||
float yOffset = 60 + (hotbarIndex - 1) * 50;
|
||||
@@ -106,7 +107,62 @@ namespace HSUI.Interface.GeneralElements
|
||||
[NestedConfig("Drag & Drop Options", 5, separator = true, collapseWith = null)]
|
||||
public HotbarsGeneralOptionsConfig GeneralOptions = new();
|
||||
|
||||
[ManualDraw]
|
||||
public bool DrawRestoreHotbarsButton(ref bool changed)
|
||||
{
|
||||
ImGuiHelper.DrawSeparator(2, 1);
|
||||
if (ImGui.Button("Restore Hotbar Layout", new Vector2(200, 24)))
|
||||
{
|
||||
RestoreAllHotbarsToDefaults();
|
||||
changed = true;
|
||||
return true;
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Reset positions and re-enable all hotbars. Use if your hotbars disappeared after an update.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public new static HotbarsConfig DefaultConfig() => new HotbarsConfig();
|
||||
|
||||
private static void RestoreAllHotbarsToDefaults()
|
||||
{
|
||||
var cfg = ConfigurationManager.Instance;
|
||||
if (cfg == null) return;
|
||||
var bars = new (HotbarBarConfig config, int index)[]
|
||||
{
|
||||
(cfg.GetConfigObject<Hotbar1BarConfig>(), 1),
|
||||
(cfg.GetConfigObject<Hotbar2BarConfig>(), 2),
|
||||
(cfg.GetConfigObject<Hotbar3BarConfig>(), 3),
|
||||
(cfg.GetConfigObject<Hotbar4BarConfig>(), 4),
|
||||
(cfg.GetConfigObject<Hotbar5BarConfig>(), 5),
|
||||
(cfg.GetConfigObject<Hotbar6BarConfig>(), 6),
|
||||
(cfg.GetConfigObject<Hotbar7BarConfig>(), 7),
|
||||
(cfg.GetConfigObject<Hotbar8BarConfig>(), 8),
|
||||
(cfg.GetConfigObject<Hotbar9BarConfig>(), 9),
|
||||
(cfg.GetConfigObject<Hotbar10BarConfig>(), 10)
|
||||
};
|
||||
foreach (var (bar, idx) in bars)
|
||||
{
|
||||
if (bar == null) continue;
|
||||
bar.Enabled = true;
|
||||
HotbarBarConfig.ApplyDefaults(bar, idx);
|
||||
}
|
||||
var vis = cfg.GetConfigObject<HotbarsVisibilityConfig>();
|
||||
if (vis != null)
|
||||
{
|
||||
var defaults = new VisibilityConfig();
|
||||
vis.HotbarConfig1.CopyFrom(defaults);
|
||||
vis.HotbarConfig2.CopyFrom(defaults);
|
||||
vis.HotbarConfig3.CopyFrom(defaults);
|
||||
vis.HotbarConfig4.CopyFrom(defaults);
|
||||
vis.HotbarConfig5.CopyFrom(defaults);
|
||||
vis.HotbarConfig6.CopyFrom(defaults);
|
||||
vis.HotbarConfig7.CopyFrom(defaults);
|
||||
vis.HotbarConfig8.CopyFrom(defaults);
|
||||
vis.HotbarConfig9.CopyFrom(defaults);
|
||||
vis.HotbarConfig10.CopyFrom(defaults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ComboHighlightLineStyle
|
||||
|
||||
@@ -263,6 +263,30 @@ namespace HSUI.Interface
|
||||
SetGameHudElementsHidden(hashesToHide.ToArray(), false);
|
||||
}
|
||||
|
||||
private static bool AnyHotbarEnabled()
|
||||
{
|
||||
var cfg = ConfigurationManager.Instance;
|
||||
if (cfg == null) return true;
|
||||
var bars = new HotbarBarConfig?[]
|
||||
{
|
||||
cfg.GetConfigObject<Hotbar1BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar2BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar3BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar4BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar5BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar6BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar7BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar8BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar9BarConfig>(),
|
||||
cfg.GetConfigObject<Hotbar10BarConfig>()
|
||||
};
|
||||
foreach (var bar in bars)
|
||||
{
|
||||
if (bar?.Enabled == true) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Visibility (ByteValue2) of game HUD elements before we hid them. Restored on disable/unload.</summary>
|
||||
private readonly Dictionary<uint, byte> _gameHudVisibilityBeforeHide = new();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user