10#include "absl/strings/substitute.h"
20constexpr float kSmoothing = 0.1f;
27 const auto sent = sent_.find(acked);
28 if (sent == sent_.end()) {
31 const float measured =
static_cast<float>((now - sent->second) * 1000.0);
32 milliseconds_ = milliseconds_ == 0.0f
34 : milliseconds_ + (measured - milliseconds_) * kSmoothing;
36 sent_.erase(sent_.begin(), std::next(sent));
40 if (milliseconds == 0.0f) {
43 const std::string text = absl::Substitute(
44 Tr(
"$0 ms"),
static_cast<int>(std::lround(milliseconds)));
46 const float size =
Ui(13.0f);
47 const ImVec2 extent = font->CalcTextSizeA(size, FLT_MAX, 0.0f, text.c_str());
48 const float right = ImGui::GetIO().DisplaySize.x -
Ui(24.0f);
52 return extent.y +
Ui(6.0f);
void Sent(uint32_t sequence, double now)
We sent the input of that sequence, at the time, in seconds.
void Acked(uint32_t acked, double now)
The world says the server applied the inputs up to acked.
const char * Tr(const char *text)
float DrawRoundTrip(float milliseconds, float top)
void DrawShadowedText(ImDrawList *draw, ImFont *font, float size, ImVec2 at, ImU32 color, const char *text)
Text with a shadow under it.