Emergency 20 Dokumentation  4.2.0
ModSystem.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/modding/Mod.h"
14 
15 #include <qsf/base/System.h>
18 
19 #include <boost/container/flat_map.hpp>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declaration ]
24 //[-------------------------------------------------------]
25 namespace qsf
26 {
27  class NamedIdentifier;
28 }
29 namespace boost
30 {
31  namespace filesystem
32  {
33  class path;
34  }
35 }
36 
37 
38 //[-------------------------------------------------------]
39 //[ Namespace ]
40 //[-------------------------------------------------------]
41 namespace em5
42 {
43 
44 
45  //[-------------------------------------------------------]
46  //[ Classes ]
47  //[-------------------------------------------------------]
56  {
57 
58 
59  //[-------------------------------------------------------]
60  //[ Public methods ]
61  //[-------------------------------------------------------]
62  public:
67  ModSystem();
68 
73  virtual ~ModSystem();
74 
75  inline const std::string& getModsUserDirectory() const;
76 
77  inline const boost::container::flat_map<uint32, Mod*>& getMods() const;
78  void getModsSorted(std::vector<Mod*>& outModList) const;
79 
80  bool isAnyModEnabled() const;
81  void getEnabledMods(std::vector<Mod*>& outMods) const;
82  void disableAllMods() const;
83 
84  void mountEnabledMods();
85  void unmountMods();
86 
87  void filterCoreProjectsFromMods();
88 
89  void loadModPluginsForApplicationTags(const std::vector<qsf::NamedIdentifier>& applicationTags);
90 
91  bool loadModUserSettings();
92  bool saveModUserSettings();
93 
94  void gatherModStateFromProjects();
95 
96  void eraseModFromDisk(uint32 modId);
97 
98 
99  //[-------------------------------------------------------]
100  //[ Public virtual qsf::System methods ]
101  //[-------------------------------------------------------]
102  public:
103  inline virtual const char* getName() const override;
104 
105  //[-------------------------------------------------------]
106  //[ Lifecycle ]
107  //[-------------------------------------------------------]
108  virtual bool onStartup(bool serverMode) override;
109  virtual void onShutdown() override;
110 
111 
112  //[-------------------------------------------------------]
113  //[ Private definitions ]
114  //[-------------------------------------------------------]
115  private:
117 
118 
119  //[-------------------------------------------------------]
120  //[ Private methods ]
121  //[-------------------------------------------------------]
122  private:
123  void addProjectAsMod(qsf::Project& project);
124  void scanProjectsForMods();
125 
126  bool loadModUserSettings(const boost::filesystem::path& filePath);
127  bool saveModUserSettings(const boost::filesystem::path& filePath);
128 
129  void onProjectAdded(qsf::Project& project);
130  void onProjectRemoval(qsf::Project& project);
131 
132 
133  //[-------------------------------------------------------]
134  //[ Private data ]
135  //[-------------------------------------------------------]
136  private:
137  ModManager mMods;
138  std::string mModsUserDirectory;
139 
140  boost::signals2::connection mConnectionProjectAdded;
141  boost::signals2::connection mConnectionProjectRemoval;
142 
143 
144  //[-------------------------------------------------------]
145  //[ CAMP reflection system ]
146  //[-------------------------------------------------------]
147  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
148 
149 
150  };
151 
152 
153 //[-------------------------------------------------------]
154 //[ Namespace ]
155 //[-------------------------------------------------------]
156 } // em5
157 
158 
159 //[-------------------------------------------------------]
160 //[ Implementation ]
161 //[-------------------------------------------------------]
163 
164 
165 //[-------------------------------------------------------]
166 //[ CAMP reflection system ]
167 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Definition: DensityCalculator.h:24
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: PickupPersonByParamedicAction.h:21
Abstract system class.
Definition: System.h:48
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
EMERGENCY 5 mod system.
Definition: ModSystem.h:55
Project class.
Definition: Project.h:40