fix(DTR): make ordering a bit nicer

This commit is contained in:
goaaats 2022-01-30 02:12:56 +01:00
parent 30d4c8a93d
commit bbbac0dc29
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 45 additions and 62 deletions

View file

@ -46,6 +46,7 @@ Aireil
kalilistic
MgAl2O4
ascclemens
r00telement
@ -109,8 +110,7 @@ Copyright (c) Nate McMaster
Licensed under the Apache License, Version 2.0
See License.txt for license information.
Thanks to everyone in the XIVLauncher
Discord server
Thanks to everyone in the XIVLauncher Discord server
Join us at: https://discord.gg/3NMcUV5

View file

@ -112,6 +112,7 @@ namespace Dalamud.Interface.Internal.Windows
// DTR
private DtrBarEntry? dtrTest1;
private DtrBarEntry? dtrTest2;
private DtrBarEntry? dtrTest3;
private uint copyButtonIndex = 0;
@ -1601,61 +1602,12 @@ namespace Dalamud.Interface.Internal.Windows
private void DrawDtr()
{
var dtrBar = Service<DtrBar>.Get();
if (this.dtrTest1 != null)
{
ImGui.Text("DtrTest1");
var text = this.dtrTest1.Text?.TextValue ?? string.Empty;
if (ImGui.InputText("Text###dtr1t", ref text, 255))
this.dtrTest1.Text = text;
var shown = this.dtrTest1.Shown;
if (ImGui.Checkbox("Shown###dtr1s", ref shown))
this.dtrTest1.Shown = shown;
if (ImGui.Button("Remove###dtr1r"))
{
this.dtrTest1.Remove();
this.dtrTest1 = null;
}
}
else
{
if (ImGui.Button("Add #1"))
{
this.dtrTest1 = dtrBar.Get("DTR Test #1");
}
}
DrawDtrTestEntry(ref this.dtrTest1, "DTR Test #1");
ImGui.Separator();
DrawDtrTestEntry(ref this.dtrTest2, "DTR Test #2");
ImGui.Separator();
DrawDtrTestEntry(ref this.dtrTest3, "DTR Test #3");
ImGui.Separator();
if (this.dtrTest2 != null)
{
ImGui.Text("DtrTest2");
var text = this.dtrTest2.Text?.TextValue ?? string.Empty;
if (ImGui.InputText("Text###dtr2t", ref text, 255))
this.dtrTest2.Text = text;
var shown = this.dtrTest2.Shown;
if (ImGui.Checkbox("Shown###dtr2s", ref shown))
this.dtrTest2.Shown = shown;
if (ImGui.Button("Remove###dtr2r"))
{
this.dtrTest2.Remove();
this.dtrTest2 = null;
}
}
else
{
if (ImGui.Button("Add #2"))
{
this.dtrTest2 = dtrBar.Get("DTR Test #2");
}
}
var configuration = Service<DalamudConfiguration>.Get();
if (configuration.DtrOrder != null)
@ -1669,6 +1621,37 @@ namespace Dalamud.Interface.Internal.Windows
}
}
private void DrawDtrTestEntry(ref DtrBarEntry? entry, string title)
{
var dtrBar = Service<DtrBar>.Get();
if (entry != null)
{
ImGui.Text(title);
var text = entry.Text?.TextValue ?? string.Empty;
if (ImGui.InputText($"Text###{entry.Title}t", ref text, 255))
entry.Text = text;
var shown = entry.Shown;
if (ImGui.Checkbox($"Shown###{entry.Title}s", ref shown))
entry.Shown = shown;
if (ImGui.Button($"Remove###{entry.Title}r"))
{
entry.Remove();
entry = null;
}
}
else
{
if (ImGui.Button($"Add###{title}"))
{
entry = dtrBar.Get(title, title);
}
}
}
private async Task TestTaskInTaskDelay()
{
await Task.Delay(5000);

View file

@ -324,8 +324,10 @@ namespace Dalamud.Interface.Internal.Windows
var configuration = Service<DalamudConfiguration>.Get();
var dtrBar = Service<DtrBar>.Get();
var order = configuration.DtrOrder!;
var ignore = configuration.DtrIgnore!;
var order = configuration.DtrOrder!.Where(x => dtrBar.HasEntry(x)).ToList();
var ignore = configuration.DtrIgnore!.Where(x => dtrBar.HasEntry(x)).ToList();
var orderLeft = configuration.DtrOrder!.Where(x => !order.Contains(x)).ToList();
var ignoreLeft = configuration.DtrIgnore!.Where(x => !ignore.Contains(x)).ToList();
if (order.Count == 0)
{
@ -336,8 +338,6 @@ namespace Dalamud.Interface.Internal.Windows
for (var i = 0; i < order.Count; i++)
{
var title = order[i];
if (!dtrBar.HasEntry(title))
continue;
// TODO: Maybe we can also resort the rest of the bar in the future?
// var isRequired = search is Configuration.SearchSetting.Internal or Configuration.SearchSetting.MacroLinks;
@ -397,8 +397,8 @@ namespace Dalamud.Interface.Internal.Windows
// }
}
configuration.DtrOrder = order;
configuration.DtrIgnore = ignore;
configuration.DtrOrder = order.Concat(orderLeft).ToList();
configuration.DtrIgnore = ignore.Concat(ignoreLeft).ToList();
if (isOrderChange)
dtrBar.ApplySort();