mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 05:04:16 +01:00
Merge pull request #85 from MikeMatrix/main
Implement a hacky way of grouping Fixed Designs by character
This commit is contained in:
commit
79d2c63ddb
1 changed files with 103 additions and 50 deletions
|
|
@ -19,10 +19,14 @@ 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 static unsafe bool IsDropping()
|
private static unsafe bool IsDropping()
|
||||||
=> ImGui.AcceptDragDropPayload(FixDragDropLabel).NativePtr != null;
|
=> ImGui.AcceptDragDropPayload(FixDragDropLabel).NativePtr != null;
|
||||||
|
|
||||||
|
private static string NormalizeIdentifier(string value)
|
||||||
|
=> value.Replace(" ", "_").Replace("#", "_");
|
||||||
|
|
||||||
private void DrawFixedDesignsTab()
|
private void DrawFixedDesignsTab()
|
||||||
{
|
{
|
||||||
_newFixDesignGroup ??= _plugin.FixedDesigns.JobGroups[1];
|
_newFixDesignGroup ??= _plugin.FixedDesigns.JobGroups[1];
|
||||||
|
|
@ -43,14 +47,60 @@ namespace Glamourer.Gui
|
||||||
|
|
||||||
var buttonWidth = 23.5f * ImGuiHelpers.GlobalScale;
|
var buttonWidth = 23.5f * ImGuiHelpers.GlobalScale;
|
||||||
|
|
||||||
|
|
||||||
ImGui.TableSetupColumn("##DeleteColumn", ImGuiTableColumnFlags.WidthFixed, 2 * buttonWidth);
|
ImGui.TableSetupColumn("##DeleteColumn", ImGuiTableColumnFlags.WidthFixed, 2 * 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 xPos = 0f;
|
|
||||||
|
var grouping = new Dictionary<string, List<int>>();
|
||||||
|
|
||||||
for (var i = 0; i < _fullPathCache.Count; ++i)
|
for (var i = 0; i < _fullPathCache.Count; ++i)
|
||||||
|
{
|
||||||
|
var name = _plugin.FixedDesigns.Data[i].Name;
|
||||||
|
|
||||||
|
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();
|
||||||
|
raii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing / 2);
|
||||||
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
|
var isOpen = _openNames.Contains(groupedName);
|
||||||
|
var groupIcon = isOpen ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
|
||||||
|
if (ImGui.Button($"{groupIcon.ToIconChar()}##group_{NormalizeIdentifier(groupedName)}"))
|
||||||
|
{
|
||||||
|
if (isOpen)
|
||||||
|
{
|
||||||
|
_openNames.Remove(groupedName);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
_openNames.Add(groupedName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
raii.PopStyles();
|
||||||
|
raii.PopFonts();
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
xPos = ImGui.GetCursorPosX();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Text(groupedName);
|
||||||
|
|
||||||
|
if (!_openNames.Contains(groupedName))
|
||||||
|
{
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var i in indices)
|
||||||
{
|
{
|
||||||
var path = _fullPathCache[i];
|
var path = _fullPathCache[i];
|
||||||
var name = _plugin.FixedDesigns.Data[i];
|
var name = _plugin.FixedDesigns.Data[i];
|
||||||
|
|
@ -61,7 +111,7 @@ namespace Glamourer.Gui
|
||||||
raii.PushFont(UiBuilder.IconFont);
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconChar()}##{i}"))
|
if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconChar()}##{i}"))
|
||||||
{
|
{
|
||||||
_fullPathCache.RemoveAt(i--);
|
_fullPathCache.RemoveAt(i);
|
||||||
_plugin.FixedDesigns.Remove(name);
|
_plugin.FixedDesigns.Remove(name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +158,9 @@ namespace Glamourer.Gui
|
||||||
ImGui.Text(path);
|
ImGui.Text(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
raii.PushFont(UiBuilder.IconFont);
|
raii.PushFont(UiBuilder.IconFont);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue