diff --git a/docs/cvars.md b/docs/cvars.md index dc9d9b09..136084fe 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -638,6 +638,7 @@ |sar_velocitygraph|0|Shows velocity graph.| |sar_velocitygraph_background|0|Background of velocity graph.| |sar_velocitygraph_font_index|21|Font index of velocity graph.| +|sar_velocitygraph_show_line|1|Shows line for velocity graph.| |sar_velocitygraph_rainbow|0|Rainbow mode of velocity graph text.| |sar_velocitygraph_show_speed_on_graph|1|Show speed between jumps.| |sar_velocitygraph_x|-250|Velocity graph x axis offset.| diff --git a/src/Features/Hud/VelocityGraph.cpp b/src/Features/Hud/VelocityGraph.cpp index 4101e5a7..753a50b7 100644 --- a/src/Features/Hud/VelocityGraph.cpp +++ b/src/Features/Hud/VelocityGraph.cpp @@ -14,6 +14,7 @@ Variable sar_velocitygraph("sar_velocitygraph", "0", "Shows velocity graph.\n"); Variable sar_velocitygraph_font_index("sar_velocitygraph_font_index", "21", 0, "Font index of velocity graph.\n"); // 21 looks pretty good +Variable sar_velocitygraph_show_line("sar_velocitygraph_show_line", "1", "Shows line for velocity graph.\n"); Variable sar_velocitygraph_x("sar_velocitygraph_x", "-250", "Velocity graph x axis offset.\n"); Variable sar_velocitygraph_y("sar_velocitygraph_y", "-175", "Velocity graph y axis offset.\n"); Variable sar_velocitygraph_background("sar_velocitygraph_background", "0", "Background of velocity graph.\n"); // imo this should be off by default @@ -81,8 +82,23 @@ void VelocityGraph::Paint(int slot) { const Vector2 graphPos = Vector2(x / 2, y) + Vector2(sar_velocitygraph_x.GetInt(), sar_velocitygraph_y.GetInt()); - if (sar_velocitygraph_background.GetBool()) - surface->DrawRect({0, 0, 0, 192}, graphPos - Vector2(5, 150 + 5), graphPos + Vector2(5 + 500, 5)); + bool should_draw_takeoff = !last_on_ground[slot] || take_off_display_timeout[slot] > engine->GetClientTime(); + int recentSpeed = velocityStamps[slot][velocityStamps[slot].size - 10].speed; + Color c = Color(30, 255, 109); + if (sar_velocitygraph_rainbow.GetBool()) { + c = Utils::HSVToRGB(speed, 100, 100); + } else if (std::abs(speed - recentSpeed) < 5) { + c = Color(255, 199, 89); + } else if (speed < recentSpeed + 5) { + c = Color(255, 119, 119); + } + + auto font = scheme->GetFontByID(sar_velocitygraph_font_index.GetInt()); + auto length = surface->GetFontLength(font, should_draw_takeoff ? "%i (%i)\n" : "%i", speed, take_off[slot]); + + surface->DrawTxt(font, graphPos.x + 250 - length / 2, graphPos.y + 25, c, should_draw_takeoff ? "%i (%i)\n" : "%i", speed, take_off[slot]); + + if (!sar_velocitygraph_show_line.GetBool()) return; for (int i = 1; i < velocityStamps[slot].size - 1; i++) { const auto current = velocityStamps[slot][i]; @@ -102,28 +118,14 @@ void VelocityGraph::Paint(int slot) { Color(255, 255, 255), std::to_string(next.speed).c_str()); } } - surface->DrawColoredLine( graphPos + Vector2(i - 1, -current_speed), graphPos + Vector2(i, -next_speed), Color(255, 255, 255)); } - bool should_draw_takeoff = !last_on_ground[slot] || take_off_display_timeout[slot] > engine->GetClientTime(); - int recentSpeed = velocityStamps[slot][velocityStamps[slot].size - 10].speed; - Color c = Color(30, 255, 109); - if (sar_velocitygraph_rainbow.GetBool()) { - c = Utils::HSVToRGB(speed, 100, 100); - } else if (std::abs(speed - recentSpeed) < 5) { - c = Color(255, 199, 89); - } else if (speed < recentSpeed + 5) { - c = Color(255, 119, 119); - } - - auto font = scheme->GetFontByID(sar_velocitygraph_font_index.GetInt()); - auto length = surface->GetFontLength(font, should_draw_takeoff ? "%i (%i)\n" : "%i", speed, take_off[slot]); - - surface->DrawTxt(font, graphPos.x + 250 - length / 2, graphPos.y + 25, c, should_draw_takeoff ? "%i (%i)\n" : "%i", speed, take_off[slot]); + if (sar_velocitygraph_background.GetBool()) + surface->DrawRect({0, 0, 0, 192}, graphPos - Vector2(5, 150 + 5), graphPos + Vector2(5 + 500, 5)); } bool VelocityGraph::GetCurrentSize(int &xSize, int &ySize) { return false; diff --git a/src/Features/Hud/VelocityGraph.hpp b/src/Features/Hud/VelocityGraph.hpp index 2e9b1e5c..e0b7d55f 100644 --- a/src/Features/Hud/VelocityGraph.hpp +++ b/src/Features/Hud/VelocityGraph.hpp @@ -16,6 +16,7 @@ extern VelocityGraph *velocityGraph; extern Variable sar_velocitygraph; extern Variable sar_velocitygraph_font_index; +extern Variable sar_velocitygraph_show_line; extern Variable sar_velocitygraph_x; extern Variable sar_velocitygraph_y; extern Variable sar_velocitygraph_background;