Increase max speed by 5 on short press

Added function to increase the value of the max speed by 5 instead of 1 by taping the "Max" speed icon in the onroad UI.
This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent f4caa201cc
commit 72fac6ed9d
7 changed files with 40 additions and 14 deletions

View File

@@ -106,13 +106,25 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
// FrogPilot clickable widgets
bool widgetClicked = false;
// Change cruise control increments button
QRect maxSpeedRect(7, 25, 225, 225);
bool isMaxSpeedClicked = maxSpeedRect.contains(e->pos());
// Hide speed button
QRect speedRect(rect().center().x() - 175, 50, 350, 350);
bool isSpeedClicked = speedRect.contains(e->pos());
if (isSpeedClicked) {
speedHidden = !params.getBool("HideSpeed");
params.putBoolNonBlocking("HideSpeed", speedHidden);
if (isMaxSpeedClicked || isSpeedClicked) {
// Check if the click was within the max speed area
if (isMaxSpeedClicked) {
reverseCruise = !params.getBool("ReverseCruise");
params.putBoolNonBlocking("ReverseCruise", reverseCruise);
paramsMemory.putBoolNonBlocking("FrogPilotTogglesUpdated", true);
// Check if the click was within the speed text area
} else {
speedHidden = !params.getBool("HideSpeed");
params.putBoolNonBlocking("HideSpeed", speedHidden);
}
widgetClicked = true;
// If the click wasn't for anything specific, change the value of "ExperimentalMode"
} else if (scene.experimental_mode_via_press && e->pos() != timeoutPoint) {
@@ -500,7 +512,11 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
int bottom_radius = has_eu_speed_limit ? 100 : 32;
QRect set_speed_rect(QPoint(60 + (default_size.width() - set_speed_size.width()) / 2, 45), set_speed_size);
p.setPen(QPen(whiteColor(75), 6));
if (reverseCruise) {
p.setPen(QPen(QColor(0, 150, 255), 6));
} else {
p.setPen(QPen(whiteColor(75), 6));
}
p.setBrush(blackColor(166));
drawRoundedRect(p, set_speed_rect, top_radius, top_radius, bottom_radius, bottom_radius);
@@ -1034,6 +1050,10 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
speedHidden = true;
}
if (params.getBool("ReverseCruise")) {
reverseCruise = true;
}
// Custom themes configuration
themeConfiguration = {
{1, {QString("frog_theme"), {QColor(23, 134, 68, 242), {{0.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.9))},