From f6206bc91316d852d6bfc63ab2b4c20e8dddec4b Mon Sep 17 00:00:00 2001 From: liam Date: Mon, 7 Feb 2022 00:10:34 -0500 Subject: [PATCH] feat(DtrBar): allow for swapping draw direction --- .../Internal/DalamudConfiguration.cs | 9 ++++++++ Dalamud/Game/Gui/Dtr/DtrBar.cs | 21 +++++++++++++++---- .../Internal/Windows/SettingsWindow.cs | 7 +++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index 4405a11a7..3d2b58683 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -261,6 +261,15 @@ namespace Dalamud.Configuration.Internal /// public int DtrSpacing { get; set; } = 10; + /// + /// Gets or sets a value indicating whether to swap the + /// direction in which elements are drawn in the DTR. + /// False indicates that elements will be drawn from the end of + /// the left side of the Server Info bar, and continue leftwards. + /// True indicates the opposite. + /// + public bool DtrSwapDirection { get; set; } = false; + /// /// Gets or sets a value indicating whether the title screen menu is shown. /// diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index 658a46a95..85b1ece65 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -142,10 +142,13 @@ namespace Dalamud.Game.Gui.Dtr var collisionNode = dtr->UldManager.NodeList[1]; if (collisionNode == null) return; - var runningXPos = collisionNode->X; var configuration = Service.Get(); + // If we are drawing backwards, we should start from the right side of the collision node. That is, + // collisionNode->X + collisionNode->Width. + var runningXPos = configuration.DtrSwapDirection ? collisionNode->X + collisionNode->Width : collisionNode->X; + for (var i = 0; i < this.entries.Count; i++) { var data = this.entries[i]; @@ -178,8 +181,18 @@ namespace Dalamud.Game.Gui.Dtr if (!isHide) { - runningXPos -= data.TextNode->AtkResNode.Width + configuration.DtrSpacing; - data.TextNode->AtkResNode.SetPositionFloat(runningXPos, 2); + var elementWidth = data.TextNode->AtkResNode.Width + configuration.DtrSpacing; + + if (configuration.DtrSwapDirection) + { + data.TextNode->AtkResNode.SetPositionFloat(runningXPos, 2); + runningXPos += elementWidth; + } + else + { + runningXPos -= elementWidth; + data.TextNode->AtkResNode.SetPositionFloat(runningXPos, 2); + } } this.entries[i] = data; diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index e4c6281da..d02dae56d 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -49,6 +49,7 @@ namespace Dalamud.Interface.Internal.Windows private List? dtrOrder; private List? dtrIgnore; private int dtrSpacing; + private bool dtrSwapDirection; private List thirdRepoList; private bool thirdRepoListChanged; @@ -99,6 +100,7 @@ namespace Dalamud.Interface.Internal.Windows this.doTsm = configuration.ShowTsm; this.dtrSpacing = configuration.DtrSpacing; + this.dtrSwapDirection = configuration.DtrSwapDirection; this.doPluginTest = configuration.DoPluginTest; this.thirdRepoList = configuration.ThirdRepoList.Select(x => x.Clone()).ToList(); @@ -416,6 +418,10 @@ namespace Dalamud.Interface.Internal.Windows ImGui.Text(Loc.Localize("DalamudSettingServerInfoBarSpacing", "Server Info Bar spacing")); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarSpacingHint", "Configure the amount of space between entries in the server info bar here.")); ImGui.SliderInt("Spacing", ref this.dtrSpacing, 0, 40); + + ImGui.Text(Loc.Localize("DalamudSettingServerInfoBarDirection", "Server Info Bar direction")); + ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarDirectionHint", "If checked, the Server Info Bar elements will expand to the right instead of the left.")); + ImGui.Checkbox("Swap Direction", ref this.dtrSwapDirection); } private void DrawExperimentalTab() @@ -823,6 +829,7 @@ namespace Dalamud.Interface.Internal.Windows this.dtrIgnore = configuration.DtrIgnore; configuration.DtrSpacing = this.dtrSpacing; + configuration.DtrSwapDirection = this.dtrSwapDirection; configuration.DoPluginTest = this.doPluginTest; configuration.ThirdRepoList = this.thirdRepoList.Select(x => x.Clone()).ToList();