From b551cef7691457653ffb3449d9a9a6fd544ae888 Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Wed, 16 Jan 2019 11:22:38 +0300 Subject: [PATCH] [power manager] support turning on/off perspective view and 3d buildings --- map/framework.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index d5c1bd98a7..fd53a31971 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2583,8 +2583,16 @@ void Framework::SaveTransliteration(bool allowTranslit) void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings) { - if (m_drapeEngine != nullptr) - m_drapeEngine->Allow3dMode(allow3d, allow3dBuildings); + if (m_drapeEngine == nullptr) + return; + + if (!m_powerManager.IsFacilityEnabled(power_management::Facility::PerspectiveView)) + allow3d = false; + + if (!m_powerManager.IsFacilityEnabled(power_management::Facility::Buildings3d)) + allow3dBuildings = false; + + m_drapeEngine->Allow3dMode(allow3d, allow3dBuildings); } void Framework::Save3dMode(bool allow3d, bool allow3dBuildings) @@ -3776,8 +3784,19 @@ booking::AvailabilityParams Framework::GetLastBookingAvailabilityParams() const void Framework::OnPowerFacilityChanged(power_management::Facility const facility, bool enabled) { - // Dummy. - // TODO: process facilities which do not have switch in UI. + if (facility == power_management::Facility::PerspectiveView || + facility == power_management::Facility::Buildings3d) + { + bool allow3d = true, allow3dBuildings = true; + Load3dMode(allow3d, allow3dBuildings); + + if (facility == power_management::Facility::PerspectiveView) + allow3d = allow3d && enabled; + else + allow3dBuildings = allow3dBuildings && enabled; + + Allow3dMode(allow3d, allow3dBuildings); + } } TipsApi const & Framework::GetTipsApi() const