feat: show who suggested a question
This commit is contained in:
parent
c42d85c380
commit
eb368b40df
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue