예제 #1
0
        /// <summary>
        /// Attempts to retrieve the UserInfo. Returns null if <see cref="IPlatformUserModel"/> is unavailable.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException">Thrown if <see cref="IPlatformUserModel"/> returns null for the <see cref="UserInfo"/>.</exception>
        public static async Task <UserInfo> GetUserAsync()
        {
            try
            {
                if (!isReady)
                {
                    await shouldBeReadyTask.Task;
                }
                await Task.Delay(200);

                lock (getUserLock)
                {
                    IPlatformUserModel platformUserModel = GetPlatformUserModel();
                    if (platformUserModel == null)
                    {
                        Logger.log.Error($"IPlatformUserModel not found, cannot update user info.");
                        return(null);
                    }
                    if (getUserTask == null || getUserTask.Status == TaskStatus.Faulted)
                    {
                        getUserTask = InternalGetUserAsync();
                    }
                }
                return(await getUserTask);
            }
            catch (Exception ex)
            {
                Logger.log.Error($"Error retrieving UserInfo: {ex.Message}.");
                Logger.log.Debug(ex);
                throw;
            }
        }
예제 #2
0
        internal static IPlatformUserModel SetPlatformUserModel()
        {
            if (_platformUserModel != null)
            {
                return(_platformUserModel);
            }
            try
            {
                // Need to check for null because there's multiple PlatformLeaderboardsModels (at least sometimes), and one has a null IPlatformUserModel with 'vrmode oculus'
                var leaderboardsModel = Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().Where(p => AccessPlatformUserModel(ref p) != null).LastOrDefault();
                //    Logger.log.Info(Resources.FindObjectsOfTypeAll<PlatformLeaderboardsModel>().Count().ToString());
                IPlatformUserModel platformUserModel = null;
                if (leaderboardsModel == null)
                {
                    Logger.log.Error($"Could not find a 'PlatformLeaderboardsModel', GetUserInfo unavailable.");
                    return(null);
                }
                if (AccessPlatformUserModel == null)
                {
                    Logger.log.Error($"Accessor for 'PlatformLeaderboardsModel._platformUserModel' is null, GetUserInfo unavailable.");
                    return(null);
                }

                platformUserModel  = AccessPlatformUserModel(ref leaderboardsModel);
                _platformUserModel = platformUserModel;
            }
            catch (Exception ex)
            {
                Logger.log.Error($"Error getting 'IPlatformUserModel', GetUserInfo unavailable: {ex.Message}");
                Logger.log.Debug(ex);
            }
            return(_platformUserModel);
        }
예제 #3
0
 public AprilFools(ScoreController scoreController, IPlatformUserModel platformUserModel, CachedMediaAsyncLoader cachedMediaAsyncLoader, AudioTimeSyncController audioTimeSyncController)
 {
     _random                  = new Random();
     _scoreController         = scoreController;
     _platformUserModel       = platformUserModel;
     _cachedMediaAsyncLoader  = cachedMediaAsyncLoader;
     _audioTimeSyncController = audioTimeSyncController;
 }
예제 #4
0
 public DetailViewHost(SiraLog siraLog, LevelDataService levelDataService, IPlatformUserModel platformUserModel, DetailContextManager detailContextManager)
 {
     _siraLog              = siraLog;
     _levelDataService     = levelDataService;
     _platformUserModel    = platformUserModel;
     _detailContextManager = detailContextManager;
     _cts = new CancellationTokenSource();
 }
예제 #5
0
        internal PlaylistUIManager(AnnotatedBeatmapLevelCollectionsViewController annotatedBeatmapLevelCollectionsViewController, SelectLevelCategoryViewController selectLevelCategoryViewController,
                                   StandardLevelDetailViewController standardLevelDetailViewController, List <ILevelCategoryUpdater> levelCategoryUpdaters, IPMRefreshable refreshable, IPlatformUserModel platformUserModel)
        {
            this.annotatedBeatmapLevelCollectionsViewController = annotatedBeatmapLevelCollectionsViewController;
            this.selectLevelCategoryViewController = selectLevelCategoryViewController;
            this.standardLevelDetailViewController = standardLevelDetailViewController;

            this.levelCategoryUpdaters = levelCategoryUpdaters;
            this.refreshable           = refreshable;
            this.platformUserModel     = platformUserModel;
        }
        PlaylistUIManager(AnnotatedBeatmapLevelCollectionsViewController annotatedBeatmapLevelCollectionsViewController, SelectLevelCategoryViewController selectLevelCategoryViewController,
                          LevelPackDetailViewController levelPackDetailViewController, StandardLevelDetailViewController standardLevelDetailViewController, PlaylistViewController playlistViewController,
                          ILevelCollectionUpdater levelCollectionUpdater, List <IPreviewBeatmapLevelUpdater> previewBeatmapLevelUpdaters, List <IPlaylistManagerModal> playlistManagerModals,
                          List <IRefreshable> refreshables, IPlatformUserModel platformUserModel)
        {
            this.annotatedBeatmapLevelCollectionsViewController = annotatedBeatmapLevelCollectionsViewController;
            this.selectLevelCategoryViewController = selectLevelCategoryViewController;
            this.levelPackDetailViewController     = levelPackDetailViewController;
            this.standardLevelDetailViewController = standardLevelDetailViewController;
            this.playlistViewController            = playlistViewController;

            this.levelCollectionUpdater      = levelCollectionUpdater;
            this.previewBeatmapLevelUpdaters = previewBeatmapLevelUpdaters;
            this.playlistManagerModals       = playlistManagerModals;
            this.refreshables      = refreshables;
            this.platformUserModel = platformUserModel;
        }
예제 #7
0
 internal LevelDataService(SiraLog siraLog, IPlatformUserModel platformUserModel, UBinder <Plugin, PluginMetadata> metadataBinder)
 {
     _siraLog           = siraLog;
     _platformUserModel = platformUserModel;
     _beatSaver         = new BeatSaver("DiTails", Version.Parse(metadataBinder.Value.HVersion.ToString()));
 }