From eb368b40dffb9e93eb5229cd5a3447c1c9164704 Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 14 Mar 2024 14:43:46 -0400 Subject: [PATCH] feat: show who suggested a question --- client/EorzeaVotes/Model/IQuestion.cs | 5 +++++ client/EorzeaVotes/Ui/Tabs/Questions.cs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/client/EorzeaVotes/Model/IQuestion.cs b/client/EorzeaVotes/Model/IQuestion.cs index 2c167bf..0815bdb 100644 --- a/client/EorzeaVotes/Model/IQuestion.cs +++ b/client/EorzeaVotes/Model/IQuestion.cs @@ -29,6 +29,11 @@ internal interface IQuestion { /// A list of possible answers to the question. /// public string[] Answers { get; init; } + + /// + /// The name given by the person who suggested this question. + /// + public string? Suggester { get; init; } } internal class QuestionConverter : JsonConverter { diff --git a/client/EorzeaVotes/Ui/Tabs/Questions.cs b/client/EorzeaVotes/Ui/Tabs/Questions.cs index 7cc6db6..8763e38 100644 --- a/client/EorzeaVotes/Ui/Tabs/Questions.cs +++ b/client/EorzeaVotes/Ui/Tabs/Questions.cs @@ -34,6 +34,22 @@ 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();