1414
1515Variable sar_velocitygraph (" sar_velocitygraph" , " 0" , " Shows velocity graph.\n " );
1616Variable sar_velocitygraph_font_index (" sar_velocitygraph_font_index" , " 21" , 0 , " Font index of velocity graph.\n " ); // 21 looks pretty good
17+ Variable sar_velocitygraph_show_line (" sar_velocitygraph_show_line" , " 1" , " Shows line for velocity graph.\n " );
1718Variable sar_velocitygraph_x (" sar_velocitygraph_x" , " -250" , " Velocity graph x axis offset.\n " );
1819Variable sar_velocitygraph_y (" sar_velocitygraph_y" , " -175" , " Velocity graph y axis offset.\n " );
1920Variable 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) {
8182 const Vector2<int > graphPos = Vector2<int >(x / 2 , y) +
8283 Vector2<int >(sar_velocitygraph_x.GetInt (), sar_velocitygraph_y.GetInt ());
8384
84- if (sar_velocitygraph_background.GetBool ())
85- surface->DrawRect ({0 , 0 , 0 , 192 }, graphPos - Vector2<int >(5 , 150 + 5 ), graphPos + Vector2<int >(5 + 500 , 5 ));
85+ bool should_draw_takeoff = !last_on_ground[slot] || take_off_display_timeout[slot] > engine->GetClientTime ();
86+ int recentSpeed = velocityStamps[slot][velocityStamps[slot].size - 10 ].speed ;
87+ Color c = Color (30 , 255 , 109 );
88+ if (sar_velocitygraph_rainbow.GetBool ()) {
89+ c = Utils::HSVToRGB (speed, 100 , 100 );
90+ } else if (std::abs (speed - recentSpeed) < 5 ) {
91+ c = Color (255 , 199 , 89 );
92+ } else if (speed < recentSpeed + 5 ) {
93+ c = Color (255 , 119 , 119 );
94+ }
95+
96+ auto font = scheme->GetFontByID (sar_velocitygraph_font_index.GetInt ());
97+ auto length = surface->GetFontLength (font, should_draw_takeoff ? " %i (%i)\n " : " %i" , speed, take_off[slot]);
98+
99+ surface->DrawTxt (font, graphPos.x + 250 - length / 2 , graphPos.y + 25 , c, should_draw_takeoff ? " %i (%i)\n " : " %i" , speed, take_off[slot]);
100+
101+ if (!sar_velocitygraph_show_line.GetBool ()) return ;
86102
87103 for (int i = 1 ; i < velocityStamps[slot].size - 1 ; i++) {
88104 const auto current = velocityStamps[slot][i];
@@ -102,28 +118,14 @@ void VelocityGraph::Paint(int slot) {
102118 Color (255 , 255 , 255 ), std::to_string (next.speed ).c_str ());
103119 }
104120 }
105-
106121 surface->DrawColoredLine (
107122 graphPos + Vector2<int >(i - 1 , -current_speed),
108123 graphPos + Vector2<int >(i, -next_speed),
109124 Color (255 , 255 , 255 ));
110125 }
111126
112- bool should_draw_takeoff = !last_on_ground[slot] || take_off_display_timeout[slot] > engine->GetClientTime ();
113- int recentSpeed = velocityStamps[slot][velocityStamps[slot].size - 10 ].speed ;
114- Color c = Color (30 , 255 , 109 );
115- if (sar_velocitygraph_rainbow.GetBool ()) {
116- c = Utils::HSVToRGB (speed, 100 , 100 );
117- } else if (std::abs (speed - recentSpeed) < 5 ) {
118- c = Color (255 , 199 , 89 );
119- } else if (speed < recentSpeed + 5 ) {
120- c = Color (255 , 119 , 119 );
121- }
122-
123- auto font = scheme->GetFontByID (sar_velocitygraph_font_index.GetInt ());
124- auto length = surface->GetFontLength (font, should_draw_takeoff ? " %i (%i)\n " : " %i" , speed, take_off[slot]);
125-
126- surface->DrawTxt (font, graphPos.x + 250 - length / 2 , graphPos.y + 25 , c, should_draw_takeoff ? " %i (%i)\n " : " %i" , speed, take_off[slot]);
127+ if (sar_velocitygraph_background.GetBool ())
128+ surface->DrawRect ({0 , 0 , 0 , 192 }, graphPos - Vector2<int >(5 , 150 + 5 ), graphPos + Vector2<int >(5 + 500 , 5 ));
127129}
128130bool VelocityGraph::GetCurrentSize (int &xSize, int &ySize) {
129131 return false ;
0 commit comments