From 4c27d9d7d660cfd54586aff85a29fcbe745799a7 Mon Sep 17 00:00:00 2001 From: FrogAi <91348155+FrogAi@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:34:00 -0700 Subject: [PATCH] Fixes --- selfdrive/frogpilot/assets/theme_manager.py | 13 +++++++++--- selfdrive/frogpilot/frogpilot_process.py | 3 +-- .../ui/qt/offroad/frogpilot_settings.cc | 18 ++++++++-------- selfdrive/ui/ui.cc | 21 +++++++++++-------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/selfdrive/frogpilot/assets/theme_manager.py b/selfdrive/frogpilot/assets/theme_manager.py index a4848b53b776042..cae4c0f4fba32ec 100644 --- a/selfdrive/frogpilot/assets/theme_manager.py +++ b/selfdrive/frogpilot/assets/theme_manager.py @@ -108,7 +108,15 @@ def update_wheel_image(image, holiday_theme="stock", random_event=True): class ThemeManager: def __init__(self): - self.theme_assets = {} + self.theme_assets = { + "holiday_theme": "stock", + "color_scheme": "stock", + "distance_icons": "stock", + "icon_pack": "stock", + "sound_pack": "stock", + "turn_signal_pack": "stock", + "wheel_image": "stock" + } @staticmethod def calculate_thanksgiving(year): @@ -393,7 +401,7 @@ def validate_themes(self, frogpilot_toggles): } for theme_param, (theme_component, theme_name) in asset_mappings.items(): - if not theme_name or theme_name == "stock": + if theme_name == "stock": continue if theme_component == "distance_icons": @@ -412,7 +420,6 @@ def validate_themes(self, frogpilot_toggles): if theme_path is None or not os.path.exists(theme_path): print(f"{theme_name} for {theme_component} not found. Downloading...") self.download_theme(theme_component, theme_name, theme_param) - self.theme_assets = {} def update_themes(self, frogpilot_toggles, boot_run=False): repo_url = get_repository_url() diff --git a/selfdrive/frogpilot/frogpilot_process.py b/selfdrive/frogpilot/frogpilot_process.py index f56117f8327dfb9..177b6f165fd67a7 100644 --- a/selfdrive/frogpilot/frogpilot_process.py +++ b/selfdrive/frogpilot/frogpilot_process.py @@ -156,8 +156,7 @@ def frogpilot_thread(): started = sm['deviceState'].started if params_memory.get_bool("FrogPilotTogglesUpdated") or theme_updated: - if theme_updated: - frogpilot_toggles.current_holiday_theme = theme_manager.theme_assets["holiday_theme"] + theme_updated = theme_manager.update_active_theme(time_validated, frogpilot_toggles) frogpilot_variables.update(started) frogpilot_toggles = get_frogpilot_toggles() diff --git a/selfdrive/frogpilot/ui/qt/offroad/frogpilot_settings.cc b/selfdrive/frogpilot/ui/qt/offroad/frogpilot_settings.cc index f0511f14a7e2fb1..f06c063c00a9a75 100644 --- a/selfdrive/frogpilot/ui/qt/offroad/frogpilot_settings.cc +++ b/selfdrive/frogpilot/ui/qt/offroad/frogpilot_settings.cc @@ -18,16 +18,16 @@ #include "selfdrive/frogpilot/ui/qt/offroad/visual_settings.h" bool checkNNFFLogFileExists(const std::string &carFingerprint) { - const std::filesystem::path latModelsPath("../car/torque_data/lat_models"); - - if (!std::filesystem::exists(latModelsPath)) { - std::cerr << "Lat models directory does not exist." << std::endl; - return false; + static std::vector files; + if (files.empty()) { + for (std::filesystem::directory_entry entry : std::filesystem::directory_iterator("../car/torque_data/lat_models")) { + files.emplace_back(entry.path().filename().stem().string()); + } } - for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(latModelsPath)) { - if (entry.path().filename().string().rfind(carFingerprint, 0) == 0) { - std::cout << "NNFF supports fingerprint: " << entry.path().filename() << std::endl; + for (const std::string &file : files) { + if (file.rfind(carFingerprint, 0) == 0) { + std::cout << "NNFF supports fingerprint: " << file << std::endl; return true; } } @@ -156,8 +156,8 @@ FrogPilotSettingsWindow::FrogPilotSettingsWindow(SettingsWindow *parent) : QFram QObject::connect(parent, &SettingsWindow::closeMapBoxInstructions, this, &FrogPilotSettingsWindow::closeMapBoxInstructions); QObject::connect(parent, &SettingsWindow::closeMapSelection, this, &FrogPilotSettingsWindow::closeMapSelection); QObject::connect(parent, &SettingsWindow::closePanel, this, &FrogPilotSettingsWindow::closePanel); + QObject::connect(parent, &SettingsWindow::closePanel, this, &updateFrogPilotToggles); QObject::connect(parent, &SettingsWindow::closeParentToggle, this, &FrogPilotSettingsWindow::closeParentToggle); - QObject::connect(parent, &SettingsWindow::closeSettings, this, &updateFrogPilotToggles); QObject::connect(parent, &SettingsWindow::closeSubParentToggle, this, &FrogPilotSettingsWindow::closeSubParentToggle); QObject::connect(parent, &SettingsWindow::updateMetric, this, &FrogPilotSettingsWindow::updateMetric); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index cc2c9e4177a68a5..a6f67a9a86a274d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -460,20 +460,23 @@ void ui_update_frogpilot_params(UIState *s) { } void ui_update_theme(UIState *s) { - loadThemeColors("", true); - UIScene &scene = s->scene; - scene.lane_lines_color = loadThemeColors("LaneLines"); - scene.lead_marker_color = loadThemeColors("LeadMarker"); - scene.path_color = loadThemeColors("Path"); - scene.path_edges_color = loadThemeColors("PathEdge"); - scene.sidebar_color1 = loadThemeColors("Sidebar1"); - scene.sidebar_color2 = loadThemeColors("Sidebar2"); - scene.sidebar_color3 = loadThemeColors("Sidebar3"); scene.use_stock_colors = scene.frogpilot_toggles.value("color_scheme").toString() == "stock" && scene.frogpilot_toggles.value("current_holiday_theme").toString() == "stock"; scene.use_stock_wheel = scene.frogpilot_toggles.value("wheel_image").toString() == "stock" && scene.frogpilot_toggles.value("current_holiday_theme").toString() == "stock"; + if (!scene.use_stock_colors) { + loadThemeColors("", true); + + scene.lane_lines_color = loadThemeColors("LaneLines"); + scene.lead_marker_color = loadThemeColors("LeadMarker"); + scene.path_color = loadThemeColors("Path"); + scene.path_edges_color = loadThemeColors("PathEdge"); + scene.sidebar_color1 = loadThemeColors("Sidebar1"); + scene.sidebar_color2 = loadThemeColors("Sidebar2"); + scene.sidebar_color3 = loadThemeColors("Sidebar3"); + } + emit s->themeUpdated(); }