mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 21:24:18 +01:00
Cleanup fixed design display code a bit.
This commit is contained in:
parent
79d2c63ddb
commit
2ebca491fc
3 changed files with 356 additions and 314 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Dalamud.Configuration;
|
using Dalamud.Configuration;
|
||||||
|
|
||||||
namespace Glamourer
|
namespace Glamourer;
|
||||||
{
|
|
||||||
public class GlamourerConfig : IPluginConfiguration
|
public class GlamourerConfig : IPluginConfiguration
|
||||||
{
|
{
|
||||||
public class FixedDesign
|
public class FixedDesign
|
||||||
|
|
@ -28,6 +28,7 @@ namespace Glamourer
|
||||||
public uint CustomizationColor { get; set; } = DefaultCustomizationColor;
|
public uint CustomizationColor { get; set; } = DefaultCustomizationColor;
|
||||||
public uint StateColor { get; set; } = DefaultStateColor;
|
public uint StateColor { get; set; } = DefaultStateColor;
|
||||||
public uint EquipmentColor { get; set; } = DefaultEquipmentColor;
|
public uint EquipmentColor { get; set; } = DefaultEquipmentColor;
|
||||||
|
public ushort GroupFixedWhen { get; set; } = 2;
|
||||||
|
|
||||||
public List<FixedDesign> FixedDesigns { get; set; } = new();
|
public List<FixedDesign> FixedDesigns { get; set; } = new();
|
||||||
|
|
||||||
|
|
@ -44,4 +45,3 @@ namespace Glamourer
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Dalamud.Interface;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace Glamourer.Gui
|
namespace Glamourer.Gui;
|
||||||
{
|
|
||||||
internal partial class Interface
|
internal partial class Interface
|
||||||
{
|
{
|
||||||
private static void DrawConfigCheckMark(string label, string tooltip, bool value, Action<bool> setter)
|
private static void DrawConfigCheckMark(string label, string tooltip, bool value, Action<bool> setter)
|
||||||
|
|
@ -57,6 +58,8 @@ namespace Glamourer.Gui
|
||||||
"If Penumbra did not register the functions for some reason, pressing this button might help restore functionality.");
|
"If Penumbra did not register the functions for some reason, pressing this button might help restore functionality.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int _currentFixedDesignGroup = -1;
|
||||||
|
|
||||||
private void DrawConfigTab()
|
private void DrawConfigTab()
|
||||||
{
|
{
|
||||||
using var raii = new ImGuiRaii();
|
using var raii = new ImGuiRaii();
|
||||||
|
|
@ -98,6 +101,7 @@ namespace Glamourer.Gui
|
||||||
else
|
else
|
||||||
Glamourer.PlayerWatcher.Disable();
|
Glamourer.PlayerWatcher.Disable();
|
||||||
});
|
});
|
||||||
|
DrawFixedDesignGroup();
|
||||||
|
|
||||||
ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeightWithSpacing() / 2);
|
ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeightWithSpacing() / 2);
|
||||||
|
|
||||||
|
|
@ -108,5 +112,28 @@ namespace Glamourer.Gui
|
||||||
DrawColorPicker("State Color", "The color for designs that only apply some state modification.",
|
DrawColorPicker("State Color", "The color for designs that only apply some state modification.",
|
||||||
cfg.StateColor, GlamourerConfig.DefaultStateColor, c => cfg.StateColor = c);
|
cfg.StateColor, GlamourerConfig.DefaultStateColor, c => cfg.StateColor = c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawFixedDesignGroup()
|
||||||
|
{
|
||||||
|
if (_currentFixedDesignGroup == -1)
|
||||||
|
_currentFixedDesignGroup = Glamourer.Config.GroupFixedWhen;
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
|
||||||
|
ImGui.DragInt("Group Fixed Designs From", ref _currentFixedDesignGroup, 0.01f, 2, ushort.MaxValue);
|
||||||
|
if (ImGui.IsItemDeactivatedAfterEdit())
|
||||||
|
{
|
||||||
|
_currentFixedDesignGroup = Math.Clamp(_currentFixedDesignGroup, 2, ushort.MaxValue);
|
||||||
|
if (_currentFixedDesignGroup != Glamourer.Config.GroupFixedWhen)
|
||||||
|
{
|
||||||
|
Glamourer.Config.GroupFixedWhen = (ushort)_currentFixedDesignGroup;
|
||||||
|
Glamourer.Config.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentFixedDesignGroup = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
ImGui.SetTooltip(
|
||||||
|
"Set how many fixed designs have to be set to a specific character before their designs are grouped with a header in the Fixed Designs tab.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
using Glamourer.FileSystem;
|
using Glamourer.FileSystem;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Penumbra.PlayerWatch;
|
|
||||||
|
|
||||||
namespace Glamourer.Gui
|
namespace Glamourer.Gui;
|
||||||
{
|
|
||||||
internal partial class Interface
|
internal partial class Interface
|
||||||
{
|
{
|
||||||
private const string FixDragDropLabel = "##FixDragDrop";
|
private const string FixDragDropLabel = "##FixDragDrop";
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Glamourer.Gui
|
||||||
private JobGroup? _newFixDesignGroup;
|
private JobGroup? _newFixDesignGroup;
|
||||||
private Design? _newFixDesign;
|
private Design? _newFixDesign;
|
||||||
private int _fixDragDropIdx = -1;
|
private int _fixDragDropIdx = -1;
|
||||||
private readonly HashSet<string> _openNames = new();
|
private readonly HashSet<string> _closedGroups = new();
|
||||||
|
|
||||||
private static unsafe bool IsDropping()
|
private static unsafe bool IsDropping()
|
||||||
=> ImGui.AcceptDragDropPayload(FixDragDropLabel).NativePtr != null;
|
=> ImGui.AcceptDragDropPayload(FixDragDropLabel).NativePtr != null;
|
||||||
|
|
@ -43,129 +43,144 @@ namespace Glamourer.Gui
|
||||||
|
|
||||||
_fullPathCache ??= _plugin.FixedDesigns.Data.Select(d => d.Design.FullName()).ToList();
|
_fullPathCache ??= _plugin.FixedDesigns.Data.Select(d => d.Design.FullName()).ToList();
|
||||||
|
|
||||||
raii.Begin(() => ImGui.BeginTable("##FixedTable", 4), ImGui.EndTable);
|
Action? endAction = null;
|
||||||
|
var buttonWidth = ImGui.GetFrameHeight();
|
||||||
|
var groups = _plugin.FixedDesigns.Data.Select((d, i) => (d, i)).GroupBy(d => d.d.Name)
|
||||||
|
.OrderBy(g => g.Key)
|
||||||
|
.Select(g => (g.Key, g.ToList()))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var buttonWidth = 23.5f * ImGuiHelpers.GlobalScale;
|
|
||||||
|
|
||||||
ImGui.TableSetupColumn("##DeleteColumn", ImGuiTableColumnFlags.WidthFixed, 2 * buttonWidth);
|
raii.PushStyle(ImGuiStyleVar.FrameRounding, 0);
|
||||||
|
raii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||||
|
if (ImGui.Button("Collapse All Groups", new Vector2(ImGui.GetContentRegionAvail().X / 2, 0)))
|
||||||
|
_closedGroups.UnionWith(groups.Select(kvp => kvp.Key));
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGui.Button("Expand All Groups", new Vector2(ImGui.GetContentRegionAvail().X, 0)))
|
||||||
|
_closedGroups.Clear();
|
||||||
|
raii.PopStyles(2);
|
||||||
|
|
||||||
|
raii.Begin(() => ImGui.BeginTable("##FixedTable", 5, ImGuiTableFlags.RowBg), ImGui.EndTable);
|
||||||
|
|
||||||
|
|
||||||
|
ImGui.TableSetupColumn("##DeleteColumn", ImGuiTableColumnFlags.WidthFixed, buttonWidth);
|
||||||
|
ImGui.TableSetupColumn("##EnableColumn", ImGuiTableColumnFlags.WidthFixed, buttonWidth);
|
||||||
ImGui.TableSetupColumn("Character", ImGuiTableColumnFlags.WidthFixed, 200 * ImGuiHelpers.GlobalScale);
|
ImGui.TableSetupColumn("Character", ImGuiTableColumnFlags.WidthFixed, 200 * ImGuiHelpers.GlobalScale);
|
||||||
ImGui.TableSetupColumn("Jobs", ImGuiTableColumnFlags.WidthFixed, 175 * ImGuiHelpers.GlobalScale);
|
ImGui.TableSetupColumn("Jobs", ImGuiTableColumnFlags.WidthFixed, 175 * ImGuiHelpers.GlobalScale);
|
||||||
ImGui.TableSetupColumn("Design", ImGuiTableColumnFlags.WidthStretch);
|
ImGui.TableSetupColumn("Design", ImGuiTableColumnFlags.WidthStretch);
|
||||||
ImGui.TableHeadersRow();
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
var grouping = new Dictionary<string, List<int>>();
|
void DrawDesign(FixedDesigns.FixedDesign design, int idx)
|
||||||
|
|
||||||
for (var i = 0; i < _fullPathCache.Count; ++i)
|
|
||||||
{
|
{
|
||||||
var name = _plugin.FixedDesigns.Data[i].Name;
|
ImGui.PushID(idx);
|
||||||
|
var path = _fullPathCache[idx];
|
||||||
grouping.TryAdd(name, new List<int>());
|
|
||||||
grouping[name].Add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
var xPos = 0f;
|
|
||||||
|
|
||||||
foreach (var (groupedName, indices) in grouping.OrderBy(kvp => kvp.Key))
|
|
||||||
{
|
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
raii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing / 2);
|
|
||||||
raii.PushFont(UiBuilder.IconFont);
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
var isOpen = _openNames.Contains(groupedName);
|
if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString()))
|
||||||
var groupIcon = isOpen ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
|
endAction = () =>
|
||||||
if (ImGui.Button($"{groupIcon.ToIconChar()}##group_{NormalizeIdentifier(groupedName)}"))
|
|
||||||
{
|
{
|
||||||
if (isOpen)
|
_fullPathCache.RemoveAt(idx);
|
||||||
{
|
_plugin.FixedDesigns.Remove(design);
|
||||||
_openNames.Remove(groupedName);
|
};
|
||||||
} else
|
|
||||||
{
|
|
||||||
_openNames.Add(groupedName);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
raii.PopStyles();
|
|
||||||
raii.PopFonts();
|
raii.PopFonts();
|
||||||
|
|
||||||
ImGui.SameLine();
|
var tmp = design.Enabled;
|
||||||
xPos = ImGui.GetCursorPosX();
|
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text(groupedName);
|
if (ImGui.Checkbox("##Enabled", ref tmp))
|
||||||
|
if (tmp && _plugin.FixedDesigns.EnableDesign(design)
|
||||||
if (!_openNames.Contains(groupedName))
|
|| !tmp && _plugin.FixedDesigns.DisableDesign(design))
|
||||||
{
|
{
|
||||||
ImGui.TableNextRow();
|
Glamourer.Config.FixedDesigns[idx].Enabled = tmp;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var i in indices)
|
|
||||||
{
|
|
||||||
var path = _fullPathCache[i];
|
|
||||||
var name = _plugin.FixedDesigns.Data[i];
|
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
|
||||||
ImGui.TableNextColumn();
|
|
||||||
raii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing / 2);
|
|
||||||
raii.PushFont(UiBuilder.IconFont);
|
|
||||||
if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconChar()}##{i}"))
|
|
||||||
{
|
|
||||||
_fullPathCache.RemoveAt(i);
|
|
||||||
_plugin.FixedDesigns.Remove(name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var tmp = name.Enabled;
|
|
||||||
ImGui.SameLine();
|
|
||||||
xPos = ImGui.GetCursorPosX();
|
|
||||||
if (ImGui.Checkbox($"##Enabled{i}", ref tmp))
|
|
||||||
if (tmp && _plugin.FixedDesigns.EnableDesign(name)
|
|
||||||
|| !tmp && _plugin.FixedDesigns.DisableDesign(name))
|
|
||||||
{
|
|
||||||
Glamourer.Config.FixedDesigns[i].Enabled = tmp;
|
|
||||||
Glamourer.Config.Save();
|
Glamourer.Config.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
raii.PopStyles();
|
|
||||||
raii.PopFonts();
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Selectable($"{name.Name}##Fix{i}");
|
ImGui.Selectable($"{design.Name}##Fix");
|
||||||
if (ImGui.BeginDragDropSource())
|
if (ImGui.BeginDragDropSource())
|
||||||
{
|
{
|
||||||
_fixDragDropIdx = i;
|
_fixDragDropIdx = idx;
|
||||||
ImGui.SetDragDropPayload("##FixDragDrop", IntPtr.Zero, 0);
|
ImGui.SetDragDropPayload("##FixDragDrop", IntPtr.Zero, 0);
|
||||||
ImGui.Text($"Dragging {name.Name} ({path})...");
|
ImGui.Text($"Dragging {design.Name} ({path})...");
|
||||||
ImGui.EndDragDropSource();
|
ImGui.EndDragDropSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginDragDropTarget())
|
if (ImGui.BeginDragDropTarget())
|
||||||
{
|
{
|
||||||
if (IsDropping() && _fixDragDropIdx >= 0)
|
if (IsDropping() && _fixDragDropIdx >= 0)
|
||||||
{
|
{
|
||||||
|
var i = _fixDragDropIdx;
|
||||||
var d = _plugin.FixedDesigns.Data[_fixDragDropIdx];
|
var d = _plugin.FixedDesigns.Data[_fixDragDropIdx];
|
||||||
_plugin.FixedDesigns.Move(d, i);
|
|
||||||
var p = _fullPathCache[_fixDragDropIdx];
|
var p = _fullPathCache[_fixDragDropIdx];
|
||||||
_fullPathCache.RemoveAt(_fixDragDropIdx);
|
endAction = () =>
|
||||||
_fullPathCache.Insert(i, p);
|
{
|
||||||
|
_plugin.FixedDesigns.Move(d, idx);
|
||||||
|
_fullPathCache.RemoveAt(i);
|
||||||
|
_fullPathCache.Insert(idx, p);
|
||||||
_fixDragDropIdx = -1;
|
_fixDragDropIdx = -1;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndDragDropTarget();
|
ImGui.EndDragDropTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text(_plugin.FixedDesigns.Data[i].Jobs.Name);
|
ImGui.TextUnformatted(_plugin.FixedDesigns.Data[idx].Jobs.Name);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.Text(path);
|
ImGui.TextUnformatted(path);
|
||||||
|
ImGui.PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
foreach (var (playerName, designs) in groups)
|
||||||
|
{
|
||||||
|
if (designs.Count >= Glamourer.Config.GroupFixedWhen)
|
||||||
|
{
|
||||||
|
var isOpen = !_closedGroups.Contains(playerName);
|
||||||
|
var color = isOpen ? 0x40005000u : 0x40000050u;
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, color);
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, color);
|
||||||
|
|
||||||
|
var groupIcon = isOpen ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
|
||||||
|
ImGui.PushID(playerName);
|
||||||
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
|
if (ImGui.Button(groupIcon.ToIconString(), new Vector2(buttonWidth)))
|
||||||
|
{
|
||||||
|
if (isOpen)
|
||||||
|
_closedGroups.Add(playerName);
|
||||||
|
else
|
||||||
|
_closedGroups.Remove(playerName);
|
||||||
|
isOpen = !isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
raii.PopFonts();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, color);
|
||||||
|
ImGui.TextUnformatted(playerName);
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, color);
|
||||||
|
ImGui.TextUnformatted($"{designs.Count} Designs");
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableSetBgColor(ImGuiTableBgTarget.CellBg, color);
|
||||||
|
if (isOpen)
|
||||||
|
foreach (var (d, i) in designs)
|
||||||
|
DrawDesign(d, i);
|
||||||
|
ImGui.PopID();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var (d, i) in designs)
|
||||||
|
DrawDesign(d, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endAction?.Invoke();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
raii.PushFont(UiBuilder.IconFont);
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
|
|
||||||
ImGui.SetCursorPosX(xPos);
|
|
||||||
if (_newFixDesign == null || _newFixCharacterName == string.Empty)
|
if (_newFixDesign == null || _newFixCharacterName == string.Empty)
|
||||||
{
|
{
|
||||||
raii.PushStyle(ImGuiStyleVar.Alpha, 0.5f);
|
raii.PushStyle(ImGuiStyleVar.Alpha, 0.5f);
|
||||||
|
|
@ -188,7 +203,7 @@ namespace Glamourer.Gui
|
||||||
raii.PopFonts();
|
raii.PopFonts();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
|
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
|
||||||
ImGui.InputTextWithHint("##NewFix", "Enter new Character", ref _newFixCharacterName, 64);
|
ImGui.InputTextWithHint("##NewFix", "Enter new Character (current: {", ref _newFixCharacterName, 64);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
ImGui.SetNextItemWidth(-1);
|
ImGui.SetNextItemWidth(-1);
|
||||||
if (raii.Begin(() => ImGui.BeginCombo("##NewFixDesignGroup", _newFixDesignGroup.Value.Name), ImGui.EndCombo))
|
if (raii.Begin(() => ImGui.BeginCombo("##NewFixDesignGroup", _newFixDesignGroup.Value.Name), ImGui.EndCombo))
|
||||||
|
|
@ -199,6 +214,7 @@ namespace Glamourer.Gui
|
||||||
if (ImGui.Selectable($"{group.Name}##NewFixDesignGroup", group.Name == _newFixDesignGroup.Value.Name))
|
if (ImGui.Selectable($"{group.Name}##NewFixDesignGroup", group.Name == _newFixDesignGroup.Value.Name))
|
||||||
_newFixDesignGroup = group;
|
_newFixDesignGroup = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
raii.End();
|
raii.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,4 +235,3 @@ namespace Glamourer.Gui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue