diff --git a/client/EorzeaVotes/Model/BasicQuestion.cs b/client/EorzeaVotes/Model/BasicQuestion.cs index 18a7be9..049501a 100644 --- a/client/EorzeaVotes/Model/BasicQuestion.cs +++ b/client/EorzeaVotes/Model/BasicQuestion.cs @@ -16,4 +16,7 @@ internal class BasicQuestion : IQuestion { /// public required string[] Answers { get; init; } + + /// + public required string? Suggester { get; init; } } diff --git a/client/EorzeaVotes/Model/FullQuestion.cs b/client/EorzeaVotes/Model/FullQuestion.cs index a679def..862336f 100644 --- a/client/EorzeaVotes/Model/FullQuestion.cs +++ b/client/EorzeaVotes/Model/FullQuestion.cs @@ -20,6 +20,9 @@ internal class FullQuestion : IQuestion { /// public required string[] Answers { get; init; } + /// + public required string? Suggester { get; init; } + /// /// A map of country to a list of responses to the question. ///

diff --git a/client/EorzeaVotes/Ui/Tabs/Questions.cs b/client/EorzeaVotes/Ui/Tabs/Questions.cs index 8763e38..8f59760 100644 --- a/client/EorzeaVotes/Ui/Tabs/Questions.cs +++ b/client/EorzeaVotes/Ui/Tabs/Questions.cs @@ -34,22 +34,6 @@ internal class QuestionsTab { ImGui.TextUnformatted("There is no active question at the moment."); } else { ImGui.TextUnformatted(active.Text); - - if (active.Suggester is { } suggester) { - var disabled = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]; - ImGui.PushStyleColor(ImGuiCol.Text, disabled); - using var popStyleColor = new OnDispose(ImGui.PopStyleColor); - - var label = $"Suggested by {suggester}"; - var width = ImGui.CalcTextSize(label).X; - var currentX = ImGui.GetCursorPosX(); - var availX = ImGui.GetContentRegionAvail().X; - - var move = availX - width - currentX; - ImGui.SetCursorPosX(currentX + move); - ImGui.TextUnformatted(label); - } - for (var i = 0; i < active.Answers.Length; i++) { if (i != 0) { ImGui.SameLine(); @@ -80,6 +64,8 @@ internal class QuestionsTab { full.DrawResponses(); this.DrawMoreDetailsButton(full); } + + DrawSuggester(active); } ImGui.Separator(); @@ -87,6 +73,25 @@ internal class QuestionsTab { this.DrawInactive(); } + private static void DrawSuggester(IQuestion question) { + if (question.Suggester is not { } suggester) { + return; + } + + var disabled = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]; + ImGui.PushStyleColor(ImGuiCol.Text, disabled); + using var popStyleColor = new OnDispose(ImGui.PopStyleColor); + + var label = $"Suggested by {suggester}"; + var width = ImGui.CalcTextSize(label).X; + var currentX = ImGui.GetCursorPosX(); + var availX = ImGui.GetContentRegionAvail().X; + + var move = availX - width - currentX; + ImGui.SetCursorPosX(currentX + move); + ImGui.TextUnformatted(label); + } + private void DrawMoreDetailsButton(FullQuestion full) { var open = this.Plugin.Ui.IsMoreDetailsOpen(full.Id); using var endDisabled = ImGuiHelper.WithDisabled(open); @@ -136,6 +141,7 @@ internal class QuestionsTab { ImGui.TextUnformatted(full.Text); full.DrawResponses(); this.DrawMoreDetailsButton(full); + DrawSuggester(full); ImGui.Spacing(); }