fix: display suggester names correctly
This commit is contained in:
parent
eb368b40df
commit
5033ac5eb1
|
@ -16,4 +16,7 @@ internal class BasicQuestion : IQuestion {
|
|||
|
||||
/// <inheritdoc/>
|
||||
public required string[] Answers { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public required string? Suggester { get; init; }
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ internal class FullQuestion : IQuestion {
|
|||
/// <inheritdoc/>
|
||||
public required string[] Answers { get; init; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public required string? Suggester { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// A map of country to a list of responses to the question.
|
||||
/// <br/><br/>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue