small fixes
This commit is contained in:
parent
1e378d1093
commit
0a97a07da0
@ -45,10 +45,10 @@ private:
|
||||
|
||||
AppView view;
|
||||
Mission mission;
|
||||
DemoDataSource data_source;
|
||||
|
||||
#ifndef NDEBUG
|
||||
friend class KeyboardHandler;
|
||||
DemoDataSource data_source;
|
||||
#endif // !NDEBUG
|
||||
};
|
||||
|
||||
|
@ -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<int>(state.mission) + 1;
|
||||
if (new_mission > 7) {
|
||||
new_mission = 1;
|
||||
}
|
||||
std::cout << "New mission: " << new_mission << std::endl;
|
||||
state.mission = static_cast<Mission>(new_mission);
|
||||
} else if (pressed_key == SDLK_UP || pressed_key == SDLK_LEFT) {
|
||||
auto new_mission = static_cast<int>(state.mission) - 1;
|
||||
@ -168,6 +171,8 @@ void KeyboardHandler::handle_keyup(const SDL_Event& ev, AppState& state) {
|
||||
new_mission = 7;
|
||||
}
|
||||
state.mission = static_cast<Mission>(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) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#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<TextWidget>(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<TextWidget>(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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user