AMI -> MissionSelect
This commit is contained in:
parent
654c71f3ee
commit
2e76523bf4
@ -39,7 +39,7 @@ add_executable(
|
|||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/App.cpp
|
src/App.cpp
|
||||||
src/View.cpp
|
src/View.cpp
|
||||||
src/AMI.cpp
|
src/MissionSelect.cpp
|
||||||
src/widgets.cpp
|
src/widgets.cpp
|
||||||
src/util.cpp
|
src/util.cpp
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AMI.h"
|
#include "MissionSelect.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
enum class AppView { AMI, DRIVER, TESTING };
|
enum class AppView { MISSION_SELECT, AMI, DRIVER, TESTING };
|
||||||
|
|
||||||
class SDLManager {
|
class SDLManager {
|
||||||
public:
|
public:
|
||||||
@ -33,7 +33,7 @@ private:
|
|||||||
// others and its destructor is called after the others.
|
// others and its destructor is called after the others.
|
||||||
SDLManager sdl_manager;
|
SDLManager sdl_manager;
|
||||||
|
|
||||||
std::unique_ptr<AMI> ami;
|
std::unique_ptr<MissionSelect> mission_select;
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
AppView view;
|
AppView view;
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class AMI final : public View {
|
class MissionSelect final : public View {
|
||||||
public:
|
public:
|
||||||
AMI(SDL_Renderer* renderer);
|
MissionSelect(SDL_Renderer* renderer);
|
||||||
~AMI();
|
~MissionSelect();
|
||||||
|
|
||||||
void draw() override;
|
void draw() override;
|
||||||
void handle_events(std::queue<Event>& events) override;
|
void handle_events(std::queue<Event>& events) override;
|
14
src/App.cpp
14
src/App.cpp
@ -1,6 +1,6 @@
|
|||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
|
||||||
#include "AMI.h"
|
#include "MissionSelect.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
App::App() : view{AppView::AMI} { init_sdl(); }
|
App::App() : view{AppView::MISSION_SELECT} { init_sdl(); }
|
||||||
|
|
||||||
App::~App() {
|
App::~App() {
|
||||||
// Destroy window
|
// Destroy window
|
||||||
@ -38,7 +38,7 @@ void App::init_sdl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int App::run() {
|
int App::run() {
|
||||||
ami = std::make_unique<AMI>(renderer);
|
mission_select = std::make_unique<MissionSelect>(renderer);
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
|
|
||||||
@ -77,8 +77,8 @@ void App::handle_events() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case AppView::AMI:
|
case AppView::MISSION_SELECT:
|
||||||
ami->handle_events(events);
|
mission_select->handle_events(events);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
||||||
@ -87,8 +87,8 @@ void App::handle_events() {
|
|||||||
|
|
||||||
void App::render() {
|
void App::render() {
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case AppView::AMI:
|
case AppView::MISSION_SELECT:
|
||||||
ami->draw();
|
mission_select->draw();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
throw std::runtime_error(fmt::format("Unknown view: {}", (int)view));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "AMI.h"
|
#include "MissionSelect.h"
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
@ -24,7 +24,7 @@ constexpr std::array MISSIONS = {"ACCELERATION", "SKIDPAD", "AUTOCROSS",
|
|||||||
"TRACKDRIVE", "EBS TEST", "INSPECTION",
|
"TRACKDRIVE", "EBS TEST", "INSPECTION",
|
||||||
"MANUAL DRIVING"};
|
"MANUAL DRIVING"};
|
||||||
|
|
||||||
AMI::AMI(SDL_Renderer* renderer)
|
MissionSelect::MissionSelect(SDL_Renderer* renderer)
|
||||||
: View{renderer}, avenir{util::load_font(AVENIR_FONT_PATH, AVENIR_PTS)},
|
: View{renderer}, avenir{util::load_font(AVENIR_FONT_PATH, AVENIR_PTS)},
|
||||||
chinat{util::load_font(CHINAT_FONT_PATH, CHINAT_PTS)} {
|
chinat{util::load_font(CHINAT_FONT_PATH, CHINAT_PTS)} {
|
||||||
ft_logo = std::make_unique<ImageWidget>(renderer, FT_LOGO_PATH);
|
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());
|
widgets.push_back(missions_widget.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
AMI::~AMI() {
|
MissionSelect::~MissionSelect() {
|
||||||
TTF_CloseFont(avenir);
|
TTF_CloseFont(avenir);
|
||||||
TTF_CloseFont(chinat);
|
TTF_CloseFont(chinat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMI::draw() {
|
void MissionSelect::draw() {
|
||||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
for (const auto& widget : widgets) {
|
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()) {
|
while (!events.empty()) {
|
||||||
Event e = events.front();
|
Event e = events.front();
|
||||||
events.pop();
|
events.pop();
|
Loading…
x
Reference in New Issue
Block a user