feat: show who suggested a question

This commit is contained in:
Anna 2024-03-14 14:43:46 -04:00
parent c42d85c380
commit eb368b40df
Signed by: anna
GPG Key ID: D0943384CD9F87D1
2 changed files with 21 additions and 0 deletions

View File

@ -29,6 +29,11 @@ internal interface IQuestion {
/// A list of possible answers to the question.
/// </summary>
public string[] Answers { get; init; }
/// <summary>
/// The name given by the person who suggested this question.
/// </summary>
public string? Suggester { get; init; }
}
internal class QuestionConverter : JsonConverter {

View File

@ -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();