From 0a97a07da0a342c586abde6533fe22b049c050a2 Mon Sep 17 00:00:00 2001
From: Panagiotis Tomer Karagiannis
Date: Sat, 9 Jul 2022 12:19:01 +0200
Subject: [PATCH] small fixes
---
include/AppState.h | 2 +-
src/App.cpp | 9 ++++++++-
src/DriverView.cpp | 15 +++++++++++----
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/include/AppState.h b/include/AppState.h
index 763b424..a75b0f2 100644
--- a/include/AppState.h
+++ b/include/AppState.h
@@ -45,10 +45,10 @@ private:
AppView view;
Mission mission;
- DemoDataSource data_source;
#ifndef NDEBUG
friend class KeyboardHandler;
+ DemoDataSource data_source;
#endif // !NDEBUG
};
diff --git a/src/App.cpp b/src/App.cpp
index 44bba77..ace16b0 100644
--- a/src/App.cpp
+++ b/src/App.cpp
@@ -154,13 +154,16 @@ Handle key presses
*/
void KeyboardHandler::handle_keyup(const SDL_Event& ev, AppState& state) {
auto pressed_key = ev.key.keysym.sym;
+
+ // we are in the first screen (mission select)
if (state.view == AppView::MISSION_SELECT) {
+
+ // handle change selected mission
if (pressed_key == SDLK_DOWN || pressed_key == SDLK_RIGHT) {
auto new_mission = static_cast(state.mission) + 1;
if (new_mission > 7) {
new_mission = 1;
}
- std::cout << "New mission: " << new_mission << std::endl;
state.mission = static_cast(new_mission);
} else if (pressed_key == SDLK_UP || pressed_key == SDLK_LEFT) {
auto new_mission = static_cast(state.mission) - 1;
@@ -168,6 +171,8 @@ void KeyboardHandler::handle_keyup(const SDL_Event& ev, AppState& state) {
new_mission = 7;
}
state.mission = static_cast(new_mission);
+
+ // commit mission selection
} else if (pressed_key == SDLK_RETURN) {
if (state.mission == Mission::MANUAL) {
@@ -178,12 +183,14 @@ void KeyboardHandler::handle_keyup(const SDL_Event& ev, AppState& state) {
}
}
+ // go back to mission select
if (state.view == AppView::AMI || state.view == AppView::DRIVER) {
if (pressed_key == SDLK_ESCAPE) {
state.view = AppView::MISSION_SELECT;
}
}
+ // handle mock brake balance change
if (pressed_key == SDLK_w) {
state.data_source.bump_brake_balance_up();
} else if (pressed_key == SDLK_s) {
diff --git a/src/DriverView.cpp b/src/DriverView.cpp
index 327a0c3..823a504 100644
--- a/src/DriverView.cpp
+++ b/src/DriverView.cpp
@@ -8,7 +8,7 @@
#include
#define LARGE_FONT_SIZE_POINTS 170
-#define GIANT_FONT_SIZE_POINTS 200
+#define GIANT_FONT_SIZE_POINTS 250
#define MEDIUM_FONT_SIZE_POINTS 50
#define SOC_BAR_HEIGHT 80
#define SPEED_TEXT_X 22
@@ -46,14 +46,21 @@ DriverView::DriverView(SDL_Renderer* renderer)
general_info_widget->set_wrap_width(SCREEN_WIDTH - 50);
focus_widget = std::make_unique(renderer, font_giant, "");
- focus_widget->set_position(120, 70);
+ focus_widget->set_position(120, 50);
focus_widget->set_alignment(Alignment::LEFT, Alignment::TOP);
focus_hint_widget = std::make_unique(renderer, font_medium, "");
- focus_hint_widget->set_position(120, 40);
+ focus_hint_widget->set_position(120, 30);
// focus_hint_widget->set_alignment(Alignment::CENTER, Alignment::CENTER);
}
-DriverView::~DriverView() {}
+DriverView::~DriverView() {
+
+ TTF_CloseFont(font_medium);
+ TTF_CloseFont(font_large);
+ TTF_CloseFont(font_detail);
+ TTF_CloseFont(font_tiny);
+ TTF_CloseFont(font_giant);
+}
void DriverView::draw(const AppState& state) {
auto ds = state.get_data_source();