diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp index 3e3e46d4f4..3f77dc0838 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp @@ -43,27 +43,6 @@ void SimHUD::EndPlay() } } -SimHUD::ImageType SimHUD::getSubwindowCameraType(int window_index) -{ - //TODO: index check - return getSubWindowSettings().at(window_index).image_type; -} - -void SimHUD::setSubwindowCameraType(int window_index, ImageType type) -{ - getSubWindowSettings().at(window_index).image_type = type; -} - -bool SimHUD::getSubwindowVisible(int window_index) -{ - return getSubWindowSettings().at(window_index).visible; -} - -void SimHUD::setSubwindowVisible(int window_index, bool is_visible) -{ - getSubWindowSettings().at(window_index).visible = is_visible; -} - void SimHUD::initializeSettings() { std::string settingsText; diff --git a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h index b6178273ae..b65879f2b2 100644 --- a/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h +++ b/Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h @@ -20,10 +20,6 @@ class SimHUD public: SimHUD(std::string sime_mode_name, int port_number); SimModeBase* GetSimMode(); - ImageType getSubwindowCameraType(int window_index); - void setSubwindowCameraType(int window_index, ImageType type); - bool getSubwindowVisible(int window_index); - void setSubwindowVisible(int window_index, bool is_visible); virtual void BeginPlay(); virtual void EndPlay(); virtual void Tick(float DeltaSeconds); diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp index bffda000ff..283109e398 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp @@ -88,41 +88,7 @@ void ASimHUD::inputEventToggleHelp() void ASimHUD::inputEventToggleTrace() { - simmode_->getVehicleSimApi()->toggleTrace(); -} - -ASimHUD::ImageType ASimHUD::getSubwindowCameraType(int window_index) -{ - //TODO: index check - return getSubWindowSettings().at(window_index).image_type; -} - -void ASimHUD::setSubwindowCameraType(int window_index, ImageType type) -{ - getSubWindowSettings().at(window_index).image_type = type; - updateWidgetSubwindowVisibility(); -} - -APIPCamera* ASimHUD::getSubwindowCamera(int window_index) -{ - return subwindow_cameras_[window_index]; //TODO: index check -} - -void ASimHUD::setSubwindowCamera(int window_index, APIPCamera* camera) -{ - subwindow_cameras_[window_index] = camera; //TODO: index check - updateWidgetSubwindowVisibility(); -} - -bool ASimHUD::getSubwindowVisible(int window_index) -{ - return getSubWindowSettings().at(window_index).visible; -} - -void ASimHUD::setSubwindowVisible(int window_index, bool is_visible) -{ - getSubWindowSettings().at(window_index).visible = is_visible; - updateWidgetSubwindowVisibility(); + simmode_->toggleTraceAll(); } void ASimHUD::updateWidgetSubwindowVisibility() @@ -135,7 +101,7 @@ void ASimHUD::updateWidgetSubwindowVisibility() if (camera != nullptr) { camera->setCameraTypeEnabled(camera_type, is_visible); - //sub-window captures don’t count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow + //sub-window captures don't count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow camera->setCameraTypeUpdate(camera_type, false); } @@ -150,22 +116,25 @@ bool ASimHUD::isWidgetSubwindowVisible(int window_index) return widget_->getSubwindowVisibility(window_index) != 0; } -void ASimHUD::inputEventToggleSubwindow0() +void ASimHUD::toggleSubwindowVisibility(int window_index) { - getSubWindowSettings().at(0).visible = !getSubWindowSettings().at(0).visible; + getSubWindowSettings().at(window_index).visible = !getSubWindowSettings().at(window_index).visible; updateWidgetSubwindowVisibility(); } +void ASimHUD::inputEventToggleSubwindow0() +{ + toggleSubwindowVisibility(0); +} + void ASimHUD::inputEventToggleSubwindow1() { - getSubWindowSettings().at(1).visible = !getSubWindowSettings().at(1).visible; - updateWidgetSubwindowVisibility(); + toggleSubwindowVisibility(1); } void ASimHUD::inputEventToggleSubwindow2() { - getSubWindowSettings().at(2).visible = !getSubWindowSettings().at(2).visible; - updateWidgetSubwindowVisibility(); + toggleSubwindowVisibility(2); } void ASimHUD::inputEventToggleAll() diff --git a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h index 98ebaaa502..cc4df14f7b 100644 --- a/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h +++ b/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h @@ -34,13 +34,6 @@ class AIRSIM_API ASimHUD : public AHUD void inputEventToggleSubwindow2(); void inputEventToggleAll(); - ImageType getSubwindowCameraType(int window_index); - void setSubwindowCameraType(int window_index, ImageType type); - APIPCamera* getSubwindowCamera(int window_index); - void setSubwindowCamera(int window_index, APIPCamera* camera); - bool getSubwindowVisible(int window_index); - void setSubwindowVisible(int window_index, bool is_visible); - ASimHUD(); virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; @@ -51,6 +44,7 @@ class AIRSIM_API ASimHUD : public AHUD void toggleRecordHandler(); void updateWidgetSubwindowVisibility(); bool isWidgetSubwindowVisible(int window_index); + void toggleSubwindowVisibility(int window_index); private: void initializeSubWindows(); diff --git a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp index 4e755a2d8e..6edb123860 100644 --- a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp +++ b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp @@ -513,6 +513,14 @@ bool ASimModeBase::isRecording() const return FRecordingThread::isRecording(); } +void ASimModeBase::toggleTraceAll() +{ + for (auto sim_api : getApiProvider()->getVehicleSimApis()) { + auto* pawn_sim_api = static_cast(sim_api); + pawn_sim_api->toggleTrace(); + } +} + const APIPCamera* ASimModeBase::getCamera(const msr::airlib::CameraDetails& camera_details) const { return camera_details.external ? getExternalCamera(camera_details.camera_name) diff --git a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h index 3b867d57a6..943cece855 100644 --- a/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h +++ b/Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h @@ -71,6 +71,8 @@ class AIRSIM_API ASimModeBase : public AActor virtual void stopRecording(); virtual bool isRecording() const; + virtual void toggleTraceAll(); + void startApiServer(); void stopApiServer(); bool isApiServerStarted();