LeviLamina
Loading...
Searching...
No Matches
PlayScreenModel.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/gui/screens/models/LegacyWorldConversionManager.h"
7#include "mc/client/gui/screens/models/MainMenuScreenModel.h"
8#include "mc/client/gui/screens/models/WorldType.h"
9#include "mc/client/gui/screens/models/interface/IWorldsProvider.h"
10#include "mc/client/legacy/ImportStatus.h"
11#include "mc/client/network/realms/GenericStatus.h"
12#include "mc/client/network/realms/RealmId.h"
13#include "mc/client/world/NetworkWorldType.h"
14#include "mc/deps/core/file/PathBuffer.h"
15#include "mc/deps/core/resource/PackType.h"
16#include "mc/deps/core/threading/Async.h"
17#include "mc/deps/core/utility/pub_sub/Subscription.h"
18#include "mc/events/IMinecraftEventing.h"
19#include "mc/platform/ErrorInfo.h"
20#include "mc/platform/Result.h"
21#include "mc/util/CallbackToken.h"
22#include "mc/util/UploadState.h"
23#include "mc/world/level/LevelListCacheObserver.h"
24
25// auto generated forward declare list
26// clang-format off
28class ILevelListCache;
30class LevelSettings;
32struct ExternalServer;
33struct ImportResult;
34struct LegacyWorldInfo;
35struct LocalWorldInfo;
37struct NetworkWorldInfo;
39struct RealmsWorldInfo;
41namespace Core { class Path; }
42namespace Legacy { class WorldImporter; }
43namespace MSGraph::Models { struct DriveItemCollection; }
44namespace MSGraph::Models { struct GraphError; }
45namespace Realms { struct World; }
46namespace Social { class MultiplayerGameInfo; }
47// clang-format on
48
50public:
51 // PlayScreenModel inner types declare
52 // clang-format off
53 struct LiveServer;
55 // clang-format on
56
57 // PlayScreenModel inner types define
58 struct LiveServer {
59 public:
60 // member variables
61 // NOLINTBEGIN
62 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Social::MultiplayerGameInfo>> server;
63 ::ll::TypedStorage<1, 1, bool> found;
64 ::ll::TypedStorage<8, 8, double> lastFoundTime;
65 ::ll::TypedStorage<1, 1, bool> dead;
66 // NOLINTEND
67 };
68
69 class PlayScreenLevelListCacheObserver : public ::LevelListCacheObserver {
70 public:
71 // member variables
72 // NOLINTBEGIN
73 ::ll::TypedStorage<8, 8, ::PlayScreenModel&> mModel;
74 // NOLINTEND
75
76 public:
77 // prevent constructor by default
78 PlayScreenLevelListCacheObserver& operator=(PlayScreenLevelListCacheObserver const&);
79 PlayScreenLevelListCacheObserver(PlayScreenLevelListCacheObserver const&);
80 PlayScreenLevelListCacheObserver();
81
82 public:
83 // virtual functions
84 // NOLINTBEGIN
85 virtual void
86 onLevelAdded(::std::string const& levelId, ::LevelListCacheObserver::LevelAddedType type) /*override*/;
87
88 virtual void onLevelUpdated(::std::string const& levelId) /*override*/;
89
90 virtual void onLevelDeleted(::std::string const& levelId) /*override*/;
91
92 virtual void onStorageChanged() /*override*/;
93 // NOLINTEND
94
95 public:
96 // virtual function thunks
97 // NOLINTBEGIN
98 MCAPI void $onLevelAdded(::std::string const& levelId, ::LevelListCacheObserver::LevelAddedType type);
99
100 MCAPI void $onLevelUpdated(::std::string const& levelId);
101
102 MCAPI void $onLevelDeleted(::std::string const& levelId);
103
104 MCAPI void $onStorageChanged();
105 // NOLINTEND
106 };
107
108 using PlayerCountMap = ::std::map<::Realms::RealmId, int>;
109
110 using RealmFullMap = ::std::map<::Realms::RealmId, bool>;
111
112 using RealmsWorldList = ::std::vector<::Realms::World>;
113
114 using StashedNetworkSelection = ::std::pair<::NetworkWorldInfo const, ::NetworkWorldType>;
115
116public:
117 // member variables
118 // NOLINTBEGIN
119 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::std::pair<::NetworkWorldInfo const, ::NetworkWorldType>>>
120 mLastNetworkSelection;
121 ::ll::TypedStorage<1, 1, bool> mIsDirty;
122 ::ll::TypedStorage<8, 24, ::std::vector<::LocalWorldInfo>> mLocalWorldList;
123 ::ll::TypedStorage<8, 24, ::std::vector<::LocalWorldInfo>> mBetaRetailLocalWorldList;
124 ::ll::TypedStorage<8, 24, ::std::vector<::WorldTemplateInfo>> mWorldTemplates;
125 ::ll::TypedStorage<8, 24, ::std::vector<::NetworkWorldInfo>> mFriendsNetworkWorldList;
126 ::ll::TypedStorage<8, 24, ::std::vector<::NetworkWorldInfo>> mCrossPlatformFriendsNetworkWorldList;
127 ::ll::TypedStorage<8, 24, ::std::vector<::NetworkWorldInfo>> mLANNetworkWorldList;
128 ::ll::TypedStorage<8, 24, ::std::vector<::NetworkWorldInfo>> mServerNetworkWorldList;
129 ::ll::TypedStorage<8, 24, ::std::vector<::RealmsWorldInfo>> mRealmWorldList;
130 ::ll::TypedStorage<8, 24, ::std::vector<::RealmsWorldInfo>> mUnpairedParentRealmWorldList;
131 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::NetworkWorldInfo>>> mThirdPartyServerWorldList;
132 ::ll::TypedStorage<8, 24, ::std::vector<::LegacyWorldInfo>> mLegacyWorldList;
133 ::ll::TypedStorage<8, 24, ::std::vector<::LegacyWorldInfo>> mBetaRetailLegacyWorldList;
134 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::ResourceLocation>> mNetworkedFriendsGamerpicMap;
135 ::ll::TypedStorage<8, 72, ::std::chrono::steady_clock::time_point[9]> mUpdateTimes;
136 ::ll::TypedStorage<8, 24, ::std::vector<::Realms::World>> mWorlds;
137 ::ll::TypedStorage<1, 1, bool> mWorldsFetched;
138 ::ll::TypedStorage<8, 24, ::std::vector<::Realms::World>> mUnpairedParentWorlds;
139 ::ll::TypedStorage<1, 1, bool> mUnpairedWorldsFetched;
140 ::ll::TypedStorage<8, 16, ::std::map<::Realms::RealmId, int>> mUnreadCounts;
141 ::ll::TypedStorage<4, 4, int> mRealmWorldPartitionIndex;
142 ::ll::TypedStorage<4, 24, ::std::array<int, 6>> mSeenUnreadPosts;
143 ::ll::TypedStorage<1, 1, bool> mLocalWorldsPopulated;
144 ::ll::TypedStorage<1, 1, bool> mHasPendingInvites;
145 ::ll::TypedStorage<4, 4, int> mPendingInviteCount;
146 ::ll::TypedStorage<1, 1, bool> mFetchingInvites;
147 ::ll::TypedStorage<1, 1, bool> mFetchingLegacyWorldsInProgress;
148 ::ll::TypedStorage<1, 1, bool> mLegacyWorldsFetched;
149 ::ll::TypedStorage<1, 1, bool> mFoundLegacyWorlds;
150 ::ll::TypedStorage<8, 128, ::LegacyWorldConversionManager> mLegacyWorldConversionManager;
151 ::ll::TypedStorage<8, 24, ::std::vector<::LocalWorldInfo>> mEduCloudWorlds;
152 ::ll::TypedStorage<1, 1, bool> mFetchingEduCloudWorldsInProgress;
153 ::ll::TypedStorage<1, 1, bool> mEduCloudWorldsFetched;
154 ::ll::TypedStorage<1, 1, bool> mEduCloudWorldsPopulated;
155 ::ll::TypedStorage<1, 1, bool> mEduCloudFetchFailed;
156 ::ll::TypedStorage<4, 4, int> mEduCloudWorldsFetchRetriesRemaining;
157 ::ll::TypedStorage<8, 32, ::std::string> mEduCloudWorldsFetchNextLinkUrl;
158 ::ll::TypedStorage<
159 8,
160 16,
161 ::Bedrock::Threading::Async<
162 ::Bedrock::Result<::MSGraph::Models::DriveItemCollection, ::MSGraph::Models::GraphError>>>
163 mEduCloudWorldsHandle;
164 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mFetchStartTimestamp;
165 ::ll::TypedStorage<8, 32, ::std::string> mFetchCorrelationId;
166 ::ll::TypedStorage<1, 1, bool> mFetchingPlayerCounts;
167 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastRealmsUpdate;
168 ::ll::TypedStorage<1, 1, bool> mJoiningRealm;
169 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastTryJoin;
170 ::ll::TypedStorage<8, 8, ::std::chrono::seconds> mRetryJoinInterval;
171 ::ll::TypedStorage<4, 4, int> mRetryTime;
172 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mPendingInviteCountSubscriber;
173 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Legacy::WorldImporter>> mLegacyWorldImporter;
174 ::ll::TypedStorage<8, 16, ::CallbackToken> mRetrieveCallbackToken;
175 ::ll::TypedStorage<8, 16, ::CallbackToken> mImportCallbackToken;
176 ::ll::TypedStorage<1, 1, bool> mFirstRealmsFetchComplete;
177 ::ll::TypedStorage<1, 1, bool> mFirstUnpairedParentRealmsFetchComplete;
178 ::ll::TypedStorage<4, 4, ::Realms::GenericStatus> mRealmsStatus;
179 ::ll::TypedStorage<4, 4, ::Realms::GenericStatus> mUnpairedParentRealmsStatus;
180 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastPlayerCountUpdate;
181 ::ll::TypedStorage<8, 24, ::PlayScreenModel::PlayScreenLevelListCacheObserver> mLevelListCacheObserver;
182 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mTrialModeUpdateSubscription;
183 ::ll::TypedStorage<1, 1, bool> mAreTrialWorldsHidden;
184 ::ll::TypedStorage<1, 1, bool> mIsEditScreenLoading;
185 ::ll::TypedStorage<1, 1, bool> mIsLoadingAdditionalRealmInfo;
186 ::ll::TypedStorage<4, 4, int> mNumRealmsWorldsToQuery;
187 ::ll::TypedStorage<8, 16, ::std::set<::Realms::RealmId>> mWorldsWithDetailedInfo;
188 ::ll::TypedStorage<1, 1, bool> initRequestPendingInvites;
189 // NOLINTEND
190
191public:
192 // prevent constructor by default
193 PlayScreenModel();
194
195public:
196 // virtual functions
197 // NOLINTBEGIN
198 virtual ~PlayScreenModel() /*override*/ = default;
199
200 virtual int getWorldCount(::WorldType worldType, ::NetworkWorldType networkType) const /*override*/;
201
202 virtual ::LocalWorldInfo const* getLocalWorldAtIndex(int const index) const /*override*/;
203
204 virtual ::LocalWorldInfo const* getLocalWorldById(::std::string const& id) const /*override*/;
205
206 virtual bool refresh(::WorldType tabType) /*override*/;
207
208 virtual void startLocalWorld(::LocalWorldInfo worldInfo, ::LevelSettings const* settings) /*override*/;
209
210 virtual bool isDirty() const /*override*/;
211
212 virtual ::IMinecraftEventing& getMinecraftEventing() const /*override*/;
213 // NOLINTEND
214
215public:
216 // member functions
217 // NOLINTBEGIN
218 MCAPI explicit PlayScreenModel(::MinecraftScreenModelContext context);
219
220 MCAPI void _fetchTrialAvailability();
221
222 MCAPI void _navigateToEditWorldScreen(::LocalWorldInfo const& info);
223
224 MCAPI void _populateAdditionalRealmsWorldsInfo();
225
226 MCAPI void _populateLocalWorldsFromStorageSource(
227 ::ILevelListCache& levelListCache,
228 ::std::vector<::LocalWorldInfo>& localWorlds,
229 ::std::vector<::LocalWorldInfo>& betaRetailWorlds,
230 bool restrictTrial,
231 bool fireTelemetry
232 );
233
234 MCAPI void _populateNetworkWorlds();
235
236 MCAPI void _populateRealmsWorldsInternal(bool ofUnpairedParentRealms);
237
238 MCAPI void _remove3PServersMismatchingEditorMode();
239
240 MCAPI void _requestPendingInviteCount();
241
242 MCAPI void _sortRealmsWorlds(::std::string const currentUserXUID, ::std::vector<::Realms::World>& worlds);
243
244 MCAPI void _start3PNetworkWorld(::NetworkWorldInfo& world);
245
246 MCAPI void _startFriendNetworkWorld(::NetworkWorldInfo const& world);
247
248 MCAPI void _startRemoteNetworkWorld(::NetworkWorldInfo const& world);
249
250 MCAPI bool areExternalAndRemoteServerSame(::ExternalServer& externalServer, ::PingedCompatibleServer remoteServer);
251
252 MCAPI void convertLegacyWorld(
253 ::LegacyWorldInfo worldInfo,
254 ::std::string const& newWorldDir,
255 ::std::function<void(::Legacy::ImportStatus, float, ::std::shared_ptr<::ImportResult>)> callback
256 );
257
258 MCAPI ::Core::PathBuffer<::std::string> const createUniquePathForWorld() const;
259
260 MCAPI void deleteLegacyWorld(uint legacyWorldIndex);
261
262 MCAPI void fetchEduCloudWorlds();
263
264 MCAPI void fetchRealmsPlayerCounts();
265
266 MCAPI void fetchRealmsWorldsForPlayScreen();
267
268 MCAPI void fetchThirdPartyServerWorlds(bool forceFetch);
269
270 MCAPI void fireIgnoredNotificationsEvent(
271 ::IMinecraftEventing::IgnoredNotificationsType notificationType,
272 int notificationCount,
273 ::std::set<::IMinecraftEventing::IgnoredNotificationSource> notificationSources
274 );
275
276 MCAPI ::std::shared_ptr<::FilePickerSettings> generateFilePickerSettingsForImport();
277
278 MCAPI bool getFetchingThirdPartyWorldsInProgress() const;
279
280 MCAPI ::std::vector<::ResourceLocation> getLoadingPacks(::PackType type) const;
281
282 MCAPI void handleLegacyWorldConversionComplete(::ImportResult const& result);
283
284 MCAPI bool hasLocalWorldWithId(::std::string const& levelId);
285
286 MCAPI void initLegacyWorldImporter();
287
288 MCAPI void initializeRealmsWorlds();
289
290 MCAPI bool isEditorPlaytestRoundtrip() const;
291
292 MCAPI bool isLocalWorldRealmsPlus(::LocalWorldInfo const& world);
293
294 MCAPI void navigateToAddEditExternalScreen(int id);
295
296 MCAPI void navigateToEditWorldScreen(int index, ::std::function<void(::Core::Path const&)> onErrorCallback);
297
298 MCAPI void
299 navigateToEditWorldScreen(::LocalWorldInfo* info, ::std::function<void(::Core::Path const&)> onErrorCallback);
300
301 MCAPI void
302 navigateToEditWorldScreen(::std::string const& levelId, ::std::function<void(::Core::Path const&)> onErrorCallback);
303
304 MCAPI void navigateToRealmsSharingLauncherScreen(::std::string const& realmsInvite);
305
306 MCAPI void navigateToWorldSyncModalScreen(
307 ::std::string const& levelId,
308 ::std::function<void(::nonstd::expected<void, ::Bedrock::ErrorInfo<::std::error_code>>)> onCompleteCallback
309 );
310
311 MCAPI ::LocalWorldInfo refreshLocalWorldInfo(::LocalWorldInfo const& worldInfo);
312
313 MCAPI void repopulateLocalWorlds();
314
315 MCAPI void startNetworkWorld(::NetworkWorldInfo worldInfo, ::NetworkWorldType worldType);
316
317 MCAPI ::Bedrock::PubSub::Subscription subscribeToBuildGameList();
318
319 MCAPI bool supportsEduCloudWorlds() const;
320
321 MCAPI void triggerMultiplayerGameRefresh(bool tryToReconnect);
322
323 MCAPI void updateWorldTimestamp(::NetworkWorldInfo const& worldInfo);
324
325 MCAPI void uploadLocalWorldFileAtIndex(
326 ::std::string const& realmID,
327 int slotIndex,
328 int index,
329 ::std::function<void(::UploadState, ::Realms::World)> callbackAfterUpload
330 );
331 // NOLINTEND
332
333public:
334 // constructor thunks
335 // NOLINTBEGIN
336 MCAPI void* $ctor(::MinecraftScreenModelContext context);
337 // NOLINTEND
338
339public:
340 // virtual function thunks
341 // NOLINTBEGIN
342 MCAPI int $getWorldCount(::WorldType worldType, ::NetworkWorldType networkType) const;
343
344 MCAPI ::LocalWorldInfo const* $getLocalWorldAtIndex(int const index) const;
345
346 MCAPI ::LocalWorldInfo const* $getLocalWorldById(::std::string const& id) const;
347
348 MCAPI bool $refresh(::WorldType tabType);
349
350 MCAPI void $startLocalWorld(::LocalWorldInfo worldInfo, ::LevelSettings const* settings);
351
352 MCAPI bool $isDirty() const;
353
354 MCFOLD ::IMinecraftEventing& $getMinecraftEventing() const;
355 // NOLINTEND
356};
Definition Path.h:11
Definition FilePickerSettings.h:5
Definition ILevelListCache.h:27
Definition IMinecraftEventing.h:145
Definition IWorldsProvider.h:5
Definition WorldImporter.h:7
Definition LevelSettings.h:38
Definition MainMenuScreenModel.h:5
Definition PlayScreenModel.h:5
Definition ResourceLocation.h:15
Definition MultiplayerGameInfo.h:7
Definition ExternalServer.h:5
Definition ImportResult.h:5
Definition LegacyWorldInfo.h:5
Definition LocalWorldInfo.h:5
Definition DriveItemCollection.h:7
Definition GraphError.h:7
Definition MinecraftScreenModelContext.h:5
Definition NetworkWorldInfo.h:5
Definition PingedCompatibleServer.h:5
Definition PlayScreenModel.h:14
Definition RealmsWorldInfo.h:5
Definition World.h:7
Definition WorldTemplateInfo.h:12