Skip to content

Commit 4b94a64

Browse files
authored
[glass] Fix FMS game data display and editing (#6381)
Also don't require Enter for editing game data or match time.
1 parent 63d9e94 commit 4b94a64

File tree

1 file changed

+11
-14
lines changed
  • glass/src/lib/native/cpp/other

1 file changed

+11
-14
lines changed

glass/src/lib/native/cpp/other/FMS.cpp

+11-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "glass/other/FMS.h"
66

77
#include <imgui.h>
8+
#include <imgui_stdlib.h>
89
#include <wpi/SmallString.h>
910

1011
#include "glass/DataSource.h"
@@ -58,8 +59,7 @@ void glass::DisplayFMS(FMSModel* model, bool editableDsAttached) {
5859
if (auto data = model->GetMatchTimeData()) {
5960
double val = data->GetValue();
6061
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
61-
if (ImGui::InputDouble("Match Time", &val, 0, 0, "%.1f",
62-
ImGuiInputTextFlags_EnterReturnsTrue)) {
62+
if (ImGui::InputDouble("Match Time", &val, 0, 0, "%.1f")) {
6363
model->SetMatchTime(val);
6464
}
6565
data->EmitDrag();
@@ -78,16 +78,12 @@ void glass::DisplayFMS(FMSModel* model, bool editableDsAttached) {
7878
}
7979

8080
// Game Specific Message
81-
// make buffer full 64 width, null terminated, for editability
82-
wpi::SmallString<64> gameSpecificMessage;
83-
model->GetGameSpecificMessage(gameSpecificMessage);
84-
gameSpecificMessage.resize(63);
85-
gameSpecificMessage.push_back('\0');
81+
wpi::SmallString<64> gameSpecificMessageBuf;
82+
std::string gameSpecificMessage{
83+
model->GetGameSpecificMessage(gameSpecificMessageBuf)};
8684
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
87-
if (ImGui::InputText("Game Specific", gameSpecificMessage.data(),
88-
gameSpecificMessage.size(),
89-
ImGuiInputTextFlags_EnterReturnsTrue)) {
90-
model->SetGameSpecificMessage(gameSpecificMessage.data());
85+
if (ImGui::InputText("Game Specific", &gameSpecificMessage)) {
86+
model->SetGameSpecificMessage(gameSpecificMessage);
9187
}
9288
}
9389

@@ -151,9 +147,10 @@ void glass::DisplayFMSReadOnly(FMSModel* model) {
151147
}
152148
}
153149

154-
wpi::SmallString<64> gameSpecificMessage;
155-
model->GetGameSpecificMessage(gameSpecificMessage);
156-
ImGui::Text("Game Specific: %s", exists ? gameSpecificMessage.c_str() : "?");
150+
wpi::SmallString<64> gameSpecificMessageBuf;
151+
std::string_view gameSpecificMessage =
152+
model->GetGameSpecificMessage(gameSpecificMessageBuf);
153+
ImGui::Text("Game Specific: %s", exists ? gameSpecificMessage.data() : "?");
157154

158155
if (!exists) {
159156
ImGui::PopStyleColor();

0 commit comments

Comments
 (0)