Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogAi committed Dec 13, 2024
1 parent 16ae2f8 commit 4c27d9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
13 changes: 10 additions & 3 deletions selfdrive/frogpilot/assets/theme_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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":
Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions selfdrive/frogpilot/frogpilot_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions selfdrive/frogpilot/ui/qt/offroad/frogpilot_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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;
}
}
Expand Down Expand Up @@ -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);

Expand Down
21 changes: 12 additions & 9 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 4c27d9d

Please sign in to comment.