Visuals - Custom Onroad UI - Road Name
Display the current road's name at the bottom of the screen. Sourced from OpenStreetMap. Credit goes to Pfeiferj! https: //github.com/pfeiferj Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev>
This commit is contained in:
parent
e244f4fc98
commit
cc2cf306f3
@ -230,7 +230,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
|||||||
|
|
||||||
int margin = 40;
|
int margin = 40;
|
||||||
int radius = 30;
|
int radius = 30;
|
||||||
int offset = scene.show_aol_status_bar || scene.show_cem_status_bar ? 25 : 0;
|
int offset = scene.show_aol_status_bar || scene.show_cem_status_bar || scene.road_name_ui ? 25 : 0;
|
||||||
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||||
margin = 0;
|
margin = 0;
|
||||||
radius = 0;
|
radius = 0;
|
||||||
@ -715,7 +715,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
|
|||||||
int offset = UI_BORDER_SIZE + btn_size / 2;
|
int offset = UI_BORDER_SIZE + btn_size / 2;
|
||||||
int x = rightHandDM ? width() - offset : offset;
|
int x = rightHandDM ? width() - offset : offset;
|
||||||
x += onroadDistanceButton ? 250 : 0;
|
x += onroadDistanceButton ? 250 : 0;
|
||||||
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar ? 25 : 0;
|
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI ? 25 : 0;
|
||||||
int y = height() - offset;
|
int y = height() - offset;
|
||||||
float opacity = dmActive ? 0.65 : 0.2;
|
float opacity = dmActive ? 0.65 : 0.2;
|
||||||
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
||||||
@ -951,6 +951,8 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
|
|||||||
|
|
||||||
onroadDistanceButton = scene.onroad_distance_button;
|
onroadDistanceButton = scene.onroad_distance_button;
|
||||||
|
|
||||||
|
roadNameUI = scene.road_name_ui;
|
||||||
|
|
||||||
speedLimitController = scene.speed_limit_controller;
|
speedLimitController = scene.speed_limit_controller;
|
||||||
showSLCOffset = speedLimitController && scene.show_slc_offset;
|
showSLCOffset = speedLimitController && scene.show_slc_offset;
|
||||||
slcOverridden = speedLimitController && scene.speed_limit_overridden;
|
slcOverridden = speedLimitController && scene.speed_limit_overridden;
|
||||||
@ -961,7 +963,7 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
||||||
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar) {
|
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI) {
|
||||||
drawStatusBar(p);
|
drawStatusBar(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1288,6 +1290,8 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
|||||||
{16, tr("Experimental Mode activated for stop") + (mapOpen ? "" : tr(" sign / stop light"))},
|
{16, tr("Experimental Mode activated for stop") + (mapOpen ? "" : tr(" sign / stop light"))},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString roadName = roadNameUI ? QString::fromStdString(paramsMemory.get("RoadName")) : QString();
|
||||||
|
|
||||||
if (alwaysOnLateralActive && showAlwaysOnLateralStatusBar) {
|
if (alwaysOnLateralActive && showAlwaysOnLateralStatusBar) {
|
||||||
newStatus = tr("Always On Lateral active") + (mapOpen ? "" : tr(". Press the \"Cruise Control\" button to disable"));
|
newStatus = tr("Always On Lateral active") + (mapOpen ? "" : tr(". Press the \"Cruise Control\" button to disable"));
|
||||||
} else if (showConditionalExperimentalStatusBar) {
|
} else if (showConditionalExperimentalStatusBar) {
|
||||||
@ -1308,7 +1312,7 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStatus != lastShownStatus) {
|
if (newStatus != lastShownStatus || roadName.isEmpty()) {
|
||||||
displayStatusText = true;
|
displayStatusText = true;
|
||||||
lastShownStatus = newStatus;
|
lastShownStatus = newStatus;
|
||||||
timer.restart();
|
timer.restart();
|
||||||
@ -1320,10 +1324,15 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
|||||||
p.setPen(Qt::white);
|
p.setPen(Qt::white);
|
||||||
p.setRenderHint(QPainter::TextAntialiasing);
|
p.setRenderHint(QPainter::TextAntialiasing);
|
||||||
|
|
||||||
|
static qreal roadNameOpacity;
|
||||||
static qreal statusTextOpacity;
|
static qreal statusTextOpacity;
|
||||||
int elapsed = timer.elapsed();
|
int elapsed = timer.elapsed();
|
||||||
if (displayStatusText) {
|
if (displayStatusText) {
|
||||||
statusTextOpacity = qBound(0.0, 1.0 - (elapsed - textDuration) / fadeDuration, 1.0);
|
statusTextOpacity = qBound(0.0, 1.0 - (elapsed - textDuration) / fadeDuration, 1.0);
|
||||||
|
roadNameOpacity = 1.0 - statusTextOpacity;
|
||||||
|
} else {
|
||||||
|
roadNameOpacity = qBound(0.0, elapsed / fadeDuration, 1.0);
|
||||||
|
statusTextOpacity = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOpacity(statusTextOpacity);
|
p.setOpacity(statusTextOpacity);
|
||||||
@ -1331,5 +1340,12 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
|||||||
textRect.moveBottom(statusBarRect.bottom() - 50);
|
textRect.moveBottom(statusBarRect.bottom() - 50);
|
||||||
p.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, newStatus);
|
p.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, newStatus);
|
||||||
|
|
||||||
|
if (!roadName.isEmpty()) {
|
||||||
|
p.setOpacity(roadNameOpacity);
|
||||||
|
textRect = p.fontMetrics().boundingRect(statusBarRect, Qt::AlignCenter | Qt::TextWordWrap, roadName);
|
||||||
|
textRect.moveBottom(statusBarRect.bottom() - 50);
|
||||||
|
p.drawText(textRect, Qt::AlignCenter | Qt::TextWordWrap, roadName);
|
||||||
|
}
|
||||||
|
|
||||||
p.restore();
|
p.restore();
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,7 @@ private:
|
|||||||
bool experimentalMode;
|
bool experimentalMode;
|
||||||
bool mapOpen;
|
bool mapOpen;
|
||||||
bool onroadDistanceButton;
|
bool onroadDistanceButton;
|
||||||
|
bool roadNameUI;
|
||||||
bool showAlwaysOnLateralStatusBar;
|
bool showAlwaysOnLateralStatusBar;
|
||||||
bool showConditionalExperimentalStatusBar;
|
bool showConditionalExperimentalStatusBar;
|
||||||
bool showSLCOffset;
|
bool showSLCOffset;
|
||||||
|
@ -309,6 +309,7 @@ void ui_update_frogpilot_params(UIState *s) {
|
|||||||
scene.pedals_on_ui = custom_onroad_ui && params.getBool("PedalsOnUI");
|
scene.pedals_on_ui = custom_onroad_ui && params.getBool("PedalsOnUI");
|
||||||
scene.dynamic_pedals_on_ui = scene.pedals_on_ui && params.getBool("DynamicPedalsOnUI");
|
scene.dynamic_pedals_on_ui = scene.pedals_on_ui && params.getBool("DynamicPedalsOnUI");
|
||||||
scene.static_pedals_on_ui = scene.pedals_on_ui && params.getBool("StaticPedalsOnUI");
|
scene.static_pedals_on_ui = scene.pedals_on_ui && params.getBool("StaticPedalsOnUI");
|
||||||
|
scene.road_name_ui = custom_onroad_ui && params.getBool("RoadNameUI");
|
||||||
|
|
||||||
scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing");
|
scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing");
|
||||||
scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing");
|
scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing");
|
||||||
|
@ -210,6 +210,7 @@ typedef struct UIScene {
|
|||||||
bool reverse_cruise;
|
bool reverse_cruise;
|
||||||
bool reverse_cruise_ui;
|
bool reverse_cruise_ui;
|
||||||
bool right_hand_drive;
|
bool right_hand_drive;
|
||||||
|
bool road_name_ui;
|
||||||
bool show_aol_status_bar;
|
bool show_aol_status_bar;
|
||||||
bool show_cem_status_bar;
|
bool show_cem_status_bar;
|
||||||
bool show_slc_offset;
|
bool show_slc_offset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user