AMI -> MissionSelect
This commit is contained in:
14
src/App.cpp
14
src/App.cpp
@ -1,6 +1,6 @@
|
||||
#include "App.h"
|
||||
|
||||
#include "AMI.h"
|
||||
#include "MissionSelect.h"
|
||||
#include "events.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
@ -12,7 +12,7 @@
|
||||
#include <queue>
|
||||
#include <stdexcept>
|
||||
|
||||
App::App() : view{AppView::AMI} { init_sdl(); }
|
||||
App::App() : view{AppView::MISSION_SELECT} { init_sdl(); }
|
||||
|
||||
App::~App() {
|
||||
// Destroy window
|
||||
@ -38,7 +38,7 @@ void App::init_sdl() {
|
||||
}
|
||||
|
||||
int App::run() {
|
||||
ami = std::make_unique<AMI>(renderer);
|
||||
mission_select = std::make_unique<MissionSelect>(renderer);
|
||||
|
||||
running = true;
|
||||
|
||||
@ -77,8 +77,8 @@ void App::handle_events() {
|
||||
}
|
||||
|
||||
switch (view) {
|
||||
case AppView::AMI:
|
||||
ami->handle_events(events);
|
||||
case AppView::MISSION_SELECT:
|
||||
mission_select->handle_events(events);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
||||
@ -87,8 +87,8 @@ void App::handle_events() {
|
||||
|
||||
void App::render() {
|
||||
switch (view) {
|
||||
case AppView::AMI:
|
||||
ami->draw();
|
||||
case AppView::MISSION_SELECT:
|
||||
mission_select->draw();
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "AMI.h"
|
||||
#include "MissionSelect.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "events.h"
|
||||
@ -24,7 +24,7 @@ constexpr std::array MISSIONS = {"ACCELERATION", "SKIDPAD", "AUTOCROSS",
|
||||
"TRACKDRIVE", "EBS TEST", "INSPECTION",
|
||||
"MANUAL DRIVING"};
|
||||
|
||||
AMI::AMI(SDL_Renderer* renderer)
|
||||
MissionSelect::MissionSelect(SDL_Renderer* renderer)
|
||||
: View{renderer}, avenir{util::load_font(AVENIR_FONT_PATH, AVENIR_PTS)},
|
||||
chinat{util::load_font(CHINAT_FONT_PATH, CHINAT_PTS)} {
|
||||
ft_logo = std::make_unique<ImageWidget>(renderer, FT_LOGO_PATH);
|
||||
@ -55,12 +55,12 @@ AMI::AMI(SDL_Renderer* renderer)
|
||||
widgets.push_back(missions_widget.get());
|
||||
}
|
||||
|
||||
AMI::~AMI() {
|
||||
MissionSelect::~MissionSelect() {
|
||||
TTF_CloseFont(avenir);
|
||||
TTF_CloseFont(chinat);
|
||||
}
|
||||
|
||||
void AMI::draw() {
|
||||
void MissionSelect::draw() {
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
for (const auto& widget : widgets) {
|
||||
@ -68,7 +68,7 @@ void AMI::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void AMI::handle_events(std::queue<Event>& events) {
|
||||
void MissionSelect::handle_events(std::queue<Event>& events) {
|
||||
while (!events.empty()) {
|
||||
Event e = events.front();
|
||||
events.pop();
|
||||
Reference in New Issue
Block a user