3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/client/gui/screens/models/ContentFlags.h"
7#include "mc/client/gui/screens/models/ContentManagerContextCollection.h"
8#include "mc/client/gui/screens/models/ContentType.h"
9#include "mc/client/gui/screens/models/IContentManager.h"
10#include "mc/deps/core/file/PathBuffer.h"
11#include "mc/deps/core/resource/PackType.h"
12#include "mc/deps/core/threading/Async.h"
13#include "mc/deps/core/utility/NonOwnerPointer.h"
14#include "mc/deps/core/utility/pub_sub/Publisher.h"
15#include "mc/world/level/LevelListCacheObserver.h"
29class IEntitlementManager;
40class StoreCatalogRepository;
52namespace Realms {
struct Content; }
53namespace Realms {
struct RealmId; }
57namespace mce {
class UUID; }
62 public ::std::enable_shared_from_this<::ContentManager> {
66 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ContentManager>> mSelf;
67 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IWorldTemplateManager>> mWorldTemplateManager;
68 ::ll::TypedStorage<8, 8, ::IPackManifestFactory&> mPackManifestFactory;
69 ::ll::TypedStorage<8, 16, ::gsl::not_null<::std::shared_ptr<::MutableContentItemCollection>>> mContent;
70 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::ContentSource>>> mContentSources;
71 ::ll::TypedStorage<8, 24, ::ContentManagerContextCollection> mContexts;
72 ::ll::TypedStorage<8, 8, uint64> mContentId;
73 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IContentCatalogPackSource>> mCatalogResourcePackSource;
74 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::Realms::RealmsServicePackSource>>>
75 mRealmsServicePackSources;
76 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::CachedHostPackIdProvider>> mCachedHostPackIdProvider;
77 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ContentManagerProxy>> mProxy;
78 ::ll::TypedStorage<1, 1, bool> mInitialized;
79 ::ll::TypedStorage<8, 32, ::std::string const> WORLD_RESOURCE_PACK_FILENAME;
80 ::ll::TypedStorage<8, 32, ::std::string const> WORLD_BEHAVIOR_PACK_FILENAME;
81 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager>> mFilePathManager;
82 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mMutex;
83 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IContentManagerFactory>> mFactory;
84 ::ll::TypedStorage<8, 16, ::gsl::not_null<::std::shared_ptr<::ContentManagerUtils::SourcesAsyncReloader>>>
86 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager>> mEntitlementManager;
87 ::ll::TypedStorage<8, 48, ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::SingleThreaded, 0>>
88 mReloadViewsPublisher;
89 ::ll::TypedStorage<8, 48, ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::SingleThreaded, 0>>
90 mDeleteContentPublisher;
91 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::StorageManager::ContentItemProvider>> mWeakStorageContentItemProvider;
92 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::StorageManager::IContentHandler>>>
93 mStorageContentHandler;
94 ::ll::TypedStorage<8, 64, ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()>>
95 mStorageWorldConverterConstructor;
96 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::StorageManager::WorldConverter>> mWeakStorageWorldConverter;
101 ContentManager& operator=(ContentManager
const&);
102 ContentManager(ContentManager
const&);
108 virtual ~ContentManager() =
default;
110 virtual ::ContentSource* loadContent(::ContentType contentType, ::ContentFlags flags) ;
112 virtual ::ContentSource* loadContent(::InvalidPacksFilterGroup
const& invalidFilter) ;
114 virtual ::ContentSource*
115 loadContentForLevel(::std::string
const& levelId, ::mce::UUID
const& premiumTemplateId) ;
117 virtual ::ContentSource* loadContentForRealm(int64
const realmId) ;
119 virtual ::std::unique_ptr<::ContentSource> loadContentForRealmsWorld(
120 ::Realms::RealmId realmId,
121 ::std::vector<::Realms::Content>
const& servicePackData
124 virtual void addPackSourceFromPremiumTemplate(
125 ::RealmPackManagerContentSource* source,
126 ::mce::UUID
const& premiumTemplateId,
130 virtual void addRealmsUnknownPackSources(::RealmPackManagerContentSource* contentSource) ;
132 virtual void addPacksToRealmsUnknownPackSource(::std::unique_ptr<::Pack> pack) ;
134 virtual void addCachedHostPackIdProvider(::std::weak_ptr<::CachedHostPackIdProvider> provider) ;
136 virtual void clearRealmsUnknownPackSource() ;
138 virtual void removeUnneededItemFromRealmsUnknownContentSource(::mce::UUID
const&
id) ;
140 virtual ::gsl::not_null<::std::shared_ptr<::ContentItemCollection>>
141 getGlobalResourcePackCollection(
bool isEditorMode) ;
143 virtual ::std::unique_ptr<::IContentManagerContext>
144 createContext(::std::function<
bool(::std::shared_ptr<::ContentItem const>
const&)> contextPredicate) ;
146 virtual void removeContext(::IContentManagerContext& context) ;
148 virtual ::std::vector<::std::unique_ptr<::ContentSource>>
const& getSources() const ;
150 virtual ::std::vector<::std::shared_ptr<::ContentItem>> getContentItems() const ;
152 virtual ::std::shared_ptr<::IVersionedContentItemCollection const> getVersionedItems() const ;
154 virtual
void enableCatalogPackSource() ;
156 virtual
void generateItems(::ContentSource* source) ;
158 virtual ::Bedrock::Threading::Async<
void> reloadSources(
bool saveSources) ;
160 virtual
void reloadItems() ;
162 virtual
void reloadViews() ;
164 virtual
void populateDependencies() const ;
166 virtual
void deleteContent(::std::shared_ptr<::ContentItem const> const& contentItem) ;
168 virtual
void deleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) ;
170 virtual
void deleteContentFiles(::std::shared_ptr<::ContentItem const> const& contentItem) ;
173 deleteContentFiles(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) ;
175 virtual
void postDeleteContent(::std::shared_ptr<::ContentItem const> const& contentItem) ;
178 postDeleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems) ;
180 virtual uint64 generateContentId() ;
182 virtual ::Core::PathBuffer<::std::
string> const getWorldResourcePath(::std::
string const& levelId) const
185 virtual ::Core::PathBuffer<::std::
string> const getWorldBehaviorPath(::std::
string const& levelId) const
188 virtual ::Core::PathBuffer<::std::
string> const getWorldResourceFolder(::std::
string const& levelId) const
191 virtual ::Core::PathBuffer<::std::
string> const getWorldBehaviorFolder(::std::
string const& levelId) const
194 virtual ::Core::PathBuffer<::std::
string> const getWorldPath(::std::
string const& levelId) const ;
196 virtual ::Core::PathBuffer<::std::
string> const&
197 getPremiumWorldTemplateFolder(::ContentIdentity const& templateId) ;
199 virtual ::ContentManagerProxy* getProxy() ;
201 virtual
void beginAsyncInit(::TaskGroup& taskGroup) ;
203 virtual
bool isInitialized() const ;
205 virtual
void onLanguageChanged() ;
207 virtual
void refreshContentCatalogPackSource() ;
209 virtual ::Bedrock::PubSub::Subscription
210 refreshContentCatalogPackSource(::std::function<
void()>&& callback) ;
212 virtual ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> getFilePathManager() ;
214 virtual
void onLevelDeleted(::std::
string const& levelId) ;
216 virtual
void onRealmsReset(::Realms::RealmId const realmsId) ;
218 virtual ::Bedrock::PubSub::Subscription
219 subscribeToSourcesReloadedAsyncCompleted(::std::function<
void()>&& onSourcesReloadedAsyncCallback) ;
221 virtual ::std::shared_ptr<::StorageManager::ContentItemProvider> getStorageContentItemProvider() ;
223 virtual ::StorageManager::IContentHandler& getStorageContentHandler() ;
225 virtual ::std::shared_ptr<::StorageManager::WorldConverter> getStorageWorldConverter() ;
227 virtual ::Bedrock::PubSub::Subscription registerToReloadViews(::std::function<
void()> callback) ;
229 virtual ::Bedrock::PubSub::Subscription registerToDeleteContent(::std::function<
void()> callback) ;
235 MCAPI ContentManager(
236 ::ILevelListCache& levelListCache,
237 ::Bedrock::NotNullNonOwnerPtr<::WorldTemplateManager> const& worldTemplateManager,
238 ::IResourcePackRepository& resourcePackRepository,
239 ::ResourcePackManager& resourcePackManager,
240 ::PackManifestFactory& packManifestFactory,
241 ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager> entitlementManager,
242 ::Bedrock::NotNullNonOwnerPtr<::IContentTierManager const> const& contentTierManager,
243 ::Bedrock::NotNullNonOwnerPtr<::StoreCatalogRepository> const& storeCatalog,
244 ::Bedrock::NotNullNonOwnerPtr<::ContentCatalogService> const& contentCatalogService,
245 ::ClientPackSourceFactory& packSourceFactory,
246 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& filePathManager,
247 ::std::unique_ptr<::StorageManager::IContentHandler> storageContentHandler,
248 ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()> storageWorldConverterConstructor
251 MCAPI
void _removeContentItemsFromSource(::gsl::not_null<::ContentSource*> source);
253 MCAPI
void _retrievePackSources(::PackType packType, ::std::vector<::PackSource*>& packSources);
255 MCAPI ::Bedrock::NotNullNonOwnerPtr<::Realms::RealmsServicePackSource> _updateOrCreateRealmsServicePackSource(
258 ::std::vector<::gsl::not_null<::std::shared_ptr<::Pack>>>&& servicePackData
265 MCAPI static
void _deleteContent(
266 ::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems,
267 ::std::function<
void(::ContentSource&, ::std::vector<::std::shared_ptr<::ContentItem const>> const&)>
276 ::ILevelListCache& levelListCache,
277 ::Bedrock::NotNullNonOwnerPtr<::WorldTemplateManager> const& worldTemplateManager,
278 ::IResourcePackRepository& resourcePackRepository,
279 ::ResourcePackManager& resourcePackManager,
280 ::PackManifestFactory& packManifestFactory,
281 ::Bedrock::NotNullNonOwnerPtr<::IEntitlementManager> entitlementManager,
282 ::Bedrock::NotNullNonOwnerPtr<::IContentTierManager const> const& contentTierManager,
283 ::Bedrock::NotNullNonOwnerPtr<::StoreCatalogRepository> const& storeCatalog,
284 ::Bedrock::NotNullNonOwnerPtr<::ContentCatalogService> const& contentCatalogService,
285 ::ClientPackSourceFactory& packSourceFactory,
286 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& filePathManager,
287 ::std::unique_ptr<::StorageManager::IContentHandler> storageContentHandler,
288 ::std::function<::std::shared_ptr<::StorageManager::WorldConverter>()> storageWorldConverterConstructor
295 MCAPI ::ContentSource* $loadContent(::ContentType contentType, ::ContentFlags flags);
297 MCAPI ::ContentSource* $loadContent(::InvalidPacksFilterGroup const& invalidFilter);
299 MCAPI ::ContentSource* $loadContentForLevel(::std::
string const& levelId, ::mce::UUID const& premiumTemplateId);
301 MCAPI ::ContentSource* $loadContentForRealm(int64 const realmId);
303 MCAPI ::std::unique_ptr<::ContentSource>
304 $loadContentForRealmsWorld(::Realms::RealmId realmId, ::std::vector<::Realms::Content> const& servicePackData);
306 MCAPI
void $addPackSourceFromPremiumTemplate(
307 ::RealmPackManagerContentSource* source,
308 ::mce::UUID const& premiumTemplateId,
312 MCAPI
void $addRealmsUnknownPackSources(::RealmPackManagerContentSource* contentSource);
314 MCAPI
void $addPacksToRealmsUnknownPackSource(::std::unique_ptr<::Pack> pack);
316 MCAPI
void $addCachedHostPackIdProvider(::std::weak_ptr<::CachedHostPackIdProvider> provider);
318 MCAPI
void $clearRealmsUnknownPackSource();
320 MCAPI
void $removeUnneededItemFromRealmsUnknownContentSource(::mce::UUID const&
id);
322 MCAPI ::gsl::not_null<::std::shared_ptr<::ContentItemCollection>>
323 $getGlobalResourcePackCollection(
bool isEditorMode);
325 MCAPI ::std::unique_ptr<::IContentManagerContext>
326 $createContext(::std::function<
bool(::std::shared_ptr<::ContentItem const> const&)> contextPredicate);
328 MCAPI
void $removeContext(::IContentManagerContext& context);
330 MCFOLD ::std::vector<::std::unique_ptr<::ContentSource>> const& $getSources() const;
332 MCAPI ::std::vector<::std::shared_ptr<::ContentItem>> $getContentItems() const;
334 MCFOLD ::std::shared_ptr<::IVersionedContentItemCollection const> $getVersionedItems() const;
336 MCAPI
void $enableCatalogPackSource();
338 MCAPI
void $generateItems(::ContentSource* source);
340 MCAPI ::Bedrock::Threading::Async<
void> $reloadSources(
bool saveSources);
342 MCAPI
void $reloadItems();
344 MCAPI
void $reloadViews();
346 MCAPI
void $populateDependencies() const;
348 MCAPI
void $deleteContent(::std::shared_ptr<::ContentItem const> const& contentItem);
350 MCAPI
void $deleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
352 MCAPI
void $deleteContentFiles(::std::shared_ptr<::ContentItem const> const& contentItem);
354 MCAPI
void $deleteContentFiles(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
356 MCAPI
void $postDeleteContent(::std::shared_ptr<::ContentItem const> const& contentItem);
358 MCAPI
void $postDeleteContent(::std::vector<::std::shared_ptr<::ContentItem const>> const& contentItems);
360 MCAPI uint64 $generateContentId();
362 MCAPI ::Core::PathBuffer<::std::
string> const $getWorldResourcePath(::std::
string const& levelId) const;
364 MCAPI ::Core::PathBuffer<::std::
string> const $getWorldBehaviorPath(::std::
string const& levelId) const;
366 MCAPI ::Core::PathBuffer<::std::
string> const $getWorldResourceFolder(::std::
string const& levelId) const;
368 MCAPI ::Core::PathBuffer<::std::
string> const $getWorldBehaviorFolder(::std::
string const& levelId) const;
370 MCAPI ::Core::PathBuffer<::std::
string> const $getWorldPath(::std::
string const& levelId) const;
372 MCAPI ::Core::PathBuffer<::std::
string> const& $getPremiumWorldTemplateFolder(::ContentIdentity const& templateId);
374 MCAPI ::ContentManagerProxy* $getProxy();
376 MCAPI
void $beginAsyncInit(::TaskGroup& taskGroup);
378 MCAPI
bool $isInitialized() const;
380 MCAPI
void $onLanguageChanged();
382 MCAPI
void $refreshContentCatalogPackSource();
384 MCAPI ::Bedrock::PubSub::Subscription $refreshContentCatalogPackSource(::std::function<
void()>&& callback);
386 MCAPI ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> $getFilePathManager();
388 MCAPI
void $onLevelDeleted(::std::
string const& levelId);
390 MCAPI
void $onRealmsReset(::Realms::RealmId const realmsId);
392 MCAPI ::Bedrock::PubSub::Subscription
393 $subscribeToSourcesReloadedAsyncCompleted(::std::function<
void()>&& onSourcesReloadedAsyncCallback);
395 MCAPI ::std::shared_ptr<::StorageManager::ContentItemProvider> $getStorageContentItemProvider();
397 MCAPI ::StorageManager::IContentHandler& $getStorageContentHandler();
399 MCAPI ::std::shared_ptr<::StorageManager::WorldConverter> $getStorageWorldConverter();
401 MCAPI ::Bedrock::PubSub::Subscription $registerToReloadViews(::std::function<
void()> callback);
403 MCAPI ::Bedrock::PubSub::Subscription $registerToDeleteContent(::std::function<
void()> callback);
Definition Subscription.h:10
Definition CachedHostPackIdProvider.h:5
Definition ClientPackSourceFactory.h:5
Definition ContentCatalogService.h:5
Definition ContentIdentity.h:8
Definition ContentItemCollection.h:5
Definition ContentManagerProxy.h:5
Definition SourcesAsyncReloader.h:7
Definition ContentManager.h:5
Definition FilePathManager.h:18
Definition IContentCatalogPackSource.h:5
Definition IContentManagerContext.h:5
Definition IContentManagerFactory.h:5
Definition IContentManager.h:5
Definition IContentTierManager.h:13
Definition ILevelListCache.h:27
Definition IPackManifestFactory.h:17
Definition IResourcePackRepository.h:35
Definition IVersionedContentItemCollection.h:5
Definition IWorldTemplateManager.h:17
Definition LevelListCacheObserver.h:13
Definition MutableContentItemCollection.h:5
Definition PackManifestFactory.h:21
Definition PackSource.h:28
Definition RealmsServicePackSource.h:18
Definition ResourcePackManager.h:36
Definition ContentItemProvider.h:7
Definition IContentHandler.h:7
Definition WorldConverter.h:7
Definition TaskGroup.h:86
Definition WorldTemplateManager.h:21
Definition SingleThreaded.h:7
Definition ContentItem.h:5
Definition ContentSource.h:5
Definition InvalidPacksFilterGroup.h:5
Definition RealmPackManagerContentSource.h:5