mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-07 22:12:05 +08:00
+9
-26
@@ -288,39 +288,22 @@ static void ui_draw_world(UIState *s) {
|
||||
}
|
||||
|
||||
static void ui_draw_vision_maxspeed(UIState *s) {
|
||||
char maxspeed_str[32];
|
||||
float maxspeed = s->scene.controls_state.getVCruise();
|
||||
int maxspeed_calc = maxspeed * 0.6225 + 0.5;
|
||||
if (s->is_metric) {
|
||||
maxspeed_calc = maxspeed + 0.5;
|
||||
}
|
||||
const bool is_cruise_set = maxspeed != 0 && maxspeed != SET_SPEED_NA;
|
||||
if (is_cruise_set && !s->is_metric) { maxspeed *= 0.6225; }
|
||||
|
||||
bool is_cruise_set = (maxspeed != 0 && maxspeed != SET_SPEED_NA);
|
||||
auto [x, y, w, h] = std::tuple(s->scene.viz_rect.x + (bdr_s * 2), s->scene.viz_rect.y + (bdr_s * 1.5), 184, 202);
|
||||
|
||||
int viz_maxspeed_w = 184;
|
||||
int viz_maxspeed_h = 202;
|
||||
int viz_maxspeed_x = s->scene.viz_rect.x + (bdr_s*2);
|
||||
int viz_maxspeed_y = s->scene.viz_rect.y + (bdr_s*1.5);
|
||||
int viz_maxspeed_xo = 180;
|
||||
|
||||
viz_maxspeed_xo = 0;
|
||||
|
||||
// Draw Background
|
||||
ui_draw_rect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, COLOR_BLACK_ALPHA(100), 30);
|
||||
|
||||
// Draw Border
|
||||
NVGcolor color = COLOR_WHITE_ALPHA(100);
|
||||
ui_draw_rect(s->vg, viz_maxspeed_x, viz_maxspeed_y, viz_maxspeed_w, viz_maxspeed_h, color, 20, 10);
|
||||
ui_draw_rect(s->vg, x, y, w, h, COLOR_BLACK_ALPHA(100), 30);
|
||||
ui_draw_rect(s->vg, x, y, w, h, COLOR_WHITE_ALPHA(100), 20, 10);
|
||||
|
||||
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE);
|
||||
const int text_x = viz_maxspeed_x + (viz_maxspeed_xo / 2) + (viz_maxspeed_w / 2);
|
||||
ui_draw_text(s->vg, text_x, 148, "MAX", 26 * 2.5, COLOR_WHITE_ALPHA(is_cruise_set ? 200 : 100), s->font_sans_regular);
|
||||
|
||||
ui_draw_text(s->vg, x + w / 2, 148, "MAX", 26 * 2.5, COLOR_WHITE_ALPHA(is_cruise_set ? 200 : 100), s->font_sans_regular);
|
||||
if (is_cruise_set) {
|
||||
snprintf(maxspeed_str, sizeof(maxspeed_str), "%d", maxspeed_calc);
|
||||
ui_draw_text(s->vg, text_x, 242, maxspeed_str, 48 * 2.5, COLOR_WHITE, s->font_sans_bold);
|
||||
const std::string maxspeed_str = std::to_string((int)std::nearbyint(maxspeed));
|
||||
ui_draw_text(s->vg, x + w / 2, 242, maxspeed_str.c_str(), 48 * 2.5, COLOR_WHITE, s->font_sans_bold);
|
||||
} else {
|
||||
ui_draw_text(s->vg, text_x, 242, "N/A", 42 * 2.5, COLOR_WHITE_ALPHA(100), s->font_sans_semibold);
|
||||
ui_draw_text(s->vg, x + w / 2, 242, "N/A", 42 * 2.5, COLOR_WHITE_ALPHA(100), s->font_sans_semibold);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user