All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CityThemesService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "ICityThemesService.h"
6 #include "Types.h"
7 #include "Rendering.h"
8 #include "Web.h"
9 #include "WebMessages.h"
10 #include "CityThemes.h"
11 #include "CityThemeData.h"
12 #include "CallbackCollection.h"
13 #include "LandmarkToRenderableRepository.h"
14 #include <string>
15 #include <vector>
16 
17 namespace Eegeo
18 {
19  namespace Resources
20  {
21  namespace CityThemes
22  {
24  {
25  public:
27  CityThemesTextureUpdater& themeTextureUpdater,
28  CityThemesAnimatedObjectsLoader& animatedObjectsLoader,
29  ThemeStateTransitionController& themeStateTransitionController,
30  Rendering::EnvironmentTextures& environmentTextures,
31  Web::WebConnectivityValidator& webConnectivityValidator,
32  bool downloadThemeTextures,
33  Buildings::LandmarkToRenderableRepository& landmarkToRenderableRepository,
34  Resources::Buildings::ILandmarkTextureLoader& landmarkTextureLoader);
35 
37 
38  const EnvironmentThemesData& GetSharedThemeData() const { return m_environmentThemesData; }
39 
40  bool ThemeChangeInProgress() const { return m_themeChangeInProgress; }
41  const CityThemeData& GetCurrentTheme() const { return m_currentTheme; }
42 
43  void RegisterThemeChangedObserver(ICityThemeChangedObserver& observerToAdd);
44  void UnregisterThemeChangedObserver(ICityThemeChangedObserver& observerToRemove);
45 
46  bool HasCurrentTheme() const { return !m_currentTheme.Name.empty(); }
47 
48  bool IsStreaming() const;
49 
50  void Update(float deltaSeconds);
51  void ClearTheme();
52  void SetSpecificTheme(CityThemeData const & newTheme);
53  void UpdateSharedData(const EnvironmentThemesData& sharedData);
54 
55  bool RequestTransitionToState(const std::string& stateName, const float transitionSpeed);
56  bool RequestTransitionToGlobeView(const std::string& globeViewStateName, const float transitionSpeed);
57  bool RequestTransitionToLastRequestedState(const float transitionSpeed);
58 
59  void SubscribeSharedThemeDataChanged(Helpers::ICallback0& callback);
60  void UnsubscribeSharedThemeDataChanged(Helpers::ICallback0& callback);
61 
62  private:
63  bool BeginTransitionToState(const std::string& stateName, const float transitionSpeed);
64 
65  void NotifyChanged(const CityThemeData& newTheme);
66  void NotifyRequsted(const CityThemeData& newTheme);
67  void ApplyTheme(const CityThemeData& newTheme);
68 
69  void RetryFailedLoads();
70 
71  CityThemesTextureUpdater& m_themeTextureUpdater;
72  CityThemesAnimatedObjectsLoader& m_animatedObjectsLoader;
73  ThemeStateTransitionController& m_themeStateTransitionController;
74  Rendering::EnvironmentTextures& m_environmentTextures;
75  Web::WebConnectivityValidator& m_webConnectivityValidator;
76  Resources::Buildings::LandmarkToRenderableRepository& m_landmarkToRenderableRepository;
77  Resources::Buildings::ILandmarkTextureLoader& m_landmarkTextureLoader;
78 
79  Helpers::TCallback0<CityThemesService> m_webConnectivityStateChangedCallback;
80  void OnWebConnectivityStateChanged();
81 
82  CityThemeData m_currentTheme;
83  CityThemeData m_targetTheme;
84  bool m_themeChangeInProgress;
85  const bool m_loadThemeTextures;
86  std::string m_lastRequestedState;
87 
88  bool m_shouldRetryFailedLoads;
89  bool m_themeTexturesLoadFailed;
90  bool m_animatedObjectsLoadFailed;
91 
92  typedef std::vector<ICityThemeChangedObserver*> TThemeChangedObservers;
93  TThemeChangedObservers m_observers;
94  EnvironmentThemesData m_environmentThemesData;
95 
96  Helpers::CallbackCollection0 m_sharedThemeDataChangedCallbacks;
97  };
98  }
99  }
100 }