diff --git a/TouchGFX/gui/include/gui/ami_screen/AMIPresenter.hpp b/TouchGFX/gui/include/gui/ami_screen/AMIPresenter.hpp index f697835..901b29e 100644 --- a/TouchGFX/gui/include/gui/ami_screen/AMIPresenter.hpp +++ b/TouchGFX/gui/include/gui/ami_screen/AMIPresenter.hpp @@ -28,6 +28,7 @@ public: virtual ~AMIPresenter(){}; void vehicleStateUpdated() override; + void nextScreen() override; private: AMIPresenter(); diff --git a/TouchGFX/gui/include/gui/common/FrontendApplication.hpp b/TouchGFX/gui/include/gui/common/FrontendApplication.hpp index 3d4b6f2..b611897 100644 --- a/TouchGFX/gui/include/gui/common/FrontendApplication.hpp +++ b/TouchGFX/gui/include/gui/common/FrontendApplication.hpp @@ -17,7 +17,11 @@ public: model.tick(); } + void setBackToMissionSelect(bool backToMissionSelect); + bool getBackToMissionSelect() const; + private: + bool backToMissionSelect; }; #endif // FRONTENDAPPLICATION_HPP diff --git a/TouchGFX/gui/include/gui/missionselect_screen/MissionSelectPresenter.hpp b/TouchGFX/gui/include/gui/missionselect_screen/MissionSelectPresenter.hpp index 0f3ea70..e6a791d 100644 --- a/TouchGFX/gui/include/gui/missionselect_screen/MissionSelectPresenter.hpp +++ b/TouchGFX/gui/include/gui/missionselect_screen/MissionSelectPresenter.hpp @@ -1,6 +1,7 @@ #ifndef MISSIONSELECTPRESENTER_HPP #define MISSIONSELECTPRESENTER_HPP +#include "stw_defines.h" #include #include @@ -30,10 +31,14 @@ public: void vehicleStateUpdated() override; + void nextScreen() override; + private: MissionSelectPresenter(); MissionSelectView &view; + + Mission initialMission; }; #endif // MISSIONSELECTPRESENTER_HPP diff --git a/TouchGFX/gui/src/ami_screen/AMIPresenter.cpp b/TouchGFX/gui/src/ami_screen/AMIPresenter.cpp index d8c8452..04f06ad 100644 --- a/TouchGFX/gui/src/ami_screen/AMIPresenter.cpp +++ b/TouchGFX/gui/src/ami_screen/AMIPresenter.cpp @@ -33,3 +33,9 @@ void AMIPresenter::vehicleStateUpdated() { } view.setConePositions(vehicle_state.cone_pos, cone_count); } + +void AMIPresenter::nextScreen() { + FrontendApplication *app = + static_cast(FrontendApplication::getInstance()); + app->gotoDebugViewScreenNoTransition(); +} diff --git a/TouchGFX/gui/src/common/FrontendApplication.cpp b/TouchGFX/gui/src/common/FrontendApplication.cpp index 687f272..3b3b193 100644 --- a/TouchGFX/gui/src/common/FrontendApplication.cpp +++ b/TouchGFX/gui/src/common/FrontendApplication.cpp @@ -3,6 +3,14 @@ #include "gui/common/NamedField.hpp" FrontendApplication::FrontendApplication(Model &m, FrontendHeap &heap) - : FrontendApplicationBase(m, heap) { + : FrontendApplicationBase(m, heap), backToMissionSelect(false) { namedFieldSort(); } + +void FrontendApplication::setBackToMissionSelect(bool backToMissionSelect) { + this->backToMissionSelect = backToMissionSelect; +} + +bool FrontendApplication::getBackToMissionSelect() const { + return backToMissionSelect; +} diff --git a/TouchGFX/gui/src/debugview_screen/DebugViewPresenter.cpp b/TouchGFX/gui/src/debugview_screen/DebugViewPresenter.cpp index 10cad53..f19de2e 100644 --- a/TouchGFX/gui/src/debugview_screen/DebugViewPresenter.cpp +++ b/TouchGFX/gui/src/debugview_screen/DebugViewPresenter.cpp @@ -1,3 +1,4 @@ +#include "gui/common/FrontendApplication.hpp" #include #include @@ -10,6 +11,8 @@ void DebugViewPresenter::deactivate() {} void DebugViewPresenter::vehicleStateUpdated() { view.updateFieldValues(); } void DebugViewPresenter::nextScreen() { - static_cast(Application::getInstance()) - ->gotoDriverViewScreenNoTransition(); + FrontendApplication *app = + static_cast(Application::getInstance()); + app->setBackToMissionSelect(true); + app->gotoMissionSelectScreenNoTransition(); } diff --git a/TouchGFX/gui/src/missionselect_screen/MissionSelectPresenter.cpp b/TouchGFX/gui/src/missionselect_screen/MissionSelectPresenter.cpp index e8c79c3..70d3a9b 100644 --- a/TouchGFX/gui/src/missionselect_screen/MissionSelectPresenter.cpp +++ b/TouchGFX/gui/src/missionselect_screen/MissionSelectPresenter.cpp @@ -9,13 +9,19 @@ MissionSelectPresenter::MissionSelectPresenter(MissionSelectView &v) : view(v) {} -void MissionSelectPresenter::activate() {} +void MissionSelectPresenter::activate() { + initialMission = vehicle_state.active_mission; +} void MissionSelectPresenter::deactivate() {} void MissionSelectPresenter::vehicleStateUpdated() { FrontendApplication *app = static_cast(FrontendApplication::getInstance()); + if (app->getBackToMissionSelect() && + vehicle_state.active_mission == initialMission) { + return; + } switch (vehicle_state.active_mission) { case MISSION_NONE: // Do nothing @@ -27,3 +33,12 @@ void MissionSelectPresenter::vehicleStateUpdated() { app->gotoAMIScreenNoTransition(); } } + +void MissionSelectPresenter::nextScreen() { + FrontendApplication *app = + static_cast(FrontendApplication::getInstance()); + if (app->getBackToMissionSelect()) { + app->gotoAMIScreenNoTransition(); + return; + } +}