mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-31 21:23:49 +08:00
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:
@@ -15,6 +15,7 @@ void OnroadAlerts::updateState(const UIState &s) {
|
||||
// FrogPilot variables
|
||||
const UIScene &scene = s.scene;
|
||||
|
||||
roadNameUI = scene.road_name_ui;
|
||||
showAOLStatusBar = scene.show_aol_status_bar;
|
||||
showCEMStatusBar = scene.show_cem_status_bar;
|
||||
}
|
||||
@@ -73,7 +74,7 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
|
||||
int margin = 40;
|
||||
int radius = 30;
|
||||
int offset = showAOLStatusBar || showCEMStatusBar ? 25 : 0;
|
||||
int offset = roadNameUI || showAOLStatusBar || showCEMStatusBar ? 25 : 0;
|
||||
if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||
margin = 0;
|
||||
radius = 0;
|
||||
|
||||
@@ -41,6 +41,7 @@ protected:
|
||||
Alert alert = {};
|
||||
|
||||
// FrogPilot variables
|
||||
bool roadNameUI;
|
||||
bool showAOLStatusBar;
|
||||
bool showCEMStatusBar;
|
||||
};
|
||||
|
||||
@@ -389,7 +389,7 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
|
||||
int offset = UI_BORDER_SIZE + btn_size / 2;
|
||||
int x = rightHandDM ? width() - offset : offset;
|
||||
x += onroadDistanceButton ? 250 : 0;
|
||||
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar ? 25 : 0;
|
||||
offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI ? 25 : 0;
|
||||
int y = height() - offset;
|
||||
float opacity = dmActive ? 0.65 : 0.2;
|
||||
drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
||||
@@ -606,7 +606,7 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce
|
||||
|
||||
alwaysOnLateralActive = scene.always_on_lateral_active;
|
||||
showAlwaysOnLateralStatusBar = scene.show_aol_status_bar;
|
||||
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar) {
|
||||
if (showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI) {
|
||||
drawStatusBar(painter);
|
||||
}
|
||||
|
||||
@@ -659,6 +659,8 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &painter, const UISce
|
||||
|
||||
reverseCruise = scene.reverse_cruise;
|
||||
|
||||
roadNameUI = scene.road_name_ui;
|
||||
|
||||
speedLimitController = scene.speed_limit_controller;
|
||||
showSLCOffset = speedLimitController && scene.show_slc_offset;
|
||||
slcOverridden = speedLimitController && scene.speed_limit_overridden;
|
||||
@@ -861,6 +863,7 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
constexpr qreal fadeDuration = 1500.0;
|
||||
constexpr qreal textDuration = 5000.0;
|
||||
|
||||
static qreal roadNameOpacity = 0.0;
|
||||
static qreal statusTextOpacity = 0.0;
|
||||
|
||||
QString newStatus;
|
||||
@@ -911,7 +914,9 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
}
|
||||
}
|
||||
|
||||
if (newStatus != lastShownStatus) {
|
||||
QString roadName = roadNameUI ? QString::fromStdString(paramsMemory.get("RoadName")) : QString();
|
||||
|
||||
if (newStatus != lastShownStatus || roadName.isEmpty()) {
|
||||
lastShownStatus = newStatus;
|
||||
displayStatusText = true;
|
||||
timer.restart();
|
||||
@@ -921,7 +926,9 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
|
||||
if (displayStatusText) {
|
||||
statusTextOpacity = qBound(0.0, 1.0 - (timer.elapsed() - textDuration) / fadeDuration, 1.0);
|
||||
roadNameOpacity = 1.0 - statusTextOpacity;
|
||||
} else {
|
||||
roadNameOpacity = qBound(0.0, timer.elapsed() / fadeDuration, 1.0);
|
||||
statusTextOpacity = 0.0;
|
||||
}
|
||||
|
||||
@@ -934,5 +941,12 @@ void AnnotatedCameraWidget::drawStatusBar(QPainter &p) {
|
||||
textRect.moveBottom(statusBarRect.bottom() - 50);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ private:
|
||||
bool mapOpen;
|
||||
bool onroadDistanceButton;
|
||||
bool reverseCruise;
|
||||
bool roadNameUI;
|
||||
bool showAlwaysOnLateralStatusBar;
|
||||
bool showConditionalExperimentalStatusBar;
|
||||
bool showSLCOffset;
|
||||
|
||||
@@ -319,6 +319,7 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
scene.pedals_on_ui = custom_onroad_ui && params.getBool("PedalsOnUI");
|
||||
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.road_name_ui = custom_onroad_ui && params.getBool("RoadNameUI");
|
||||
|
||||
scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing");
|
||||
scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing");
|
||||
|
||||
@@ -147,6 +147,7 @@ typedef struct UIScene {
|
||||
bool reverse_cruise;
|
||||
bool reverse_cruise_ui;
|
||||
bool right_hand_drive;
|
||||
bool road_name_ui;
|
||||
bool show_aol_status_bar;
|
||||
bool show_cem_status_bar;
|
||||
bool show_slc_offset;
|
||||
|
||||
Reference in New Issue
Block a user