Esempio n. 1
0
        protected override void Dispose(bool isDisposing)
        {
            //refresh token may have changed.
            Config.Set(OsuConfig.Token, API.Token);

            base.Dispose(isDisposing);
        }
        public void TestExplicitConfig()
        {
            AddStep("configure explicit content to allowed", () => localConfig.Set(OsuSetting.ShowOnlineExplicitContent, true));
            AddAssert("explicit control set to show", () => control.ExplicitContent.Value == SearchExplicit.Show);

            AddStep("configure explicit content to disallowed", () => localConfig.Set(OsuSetting.ShowOnlineExplicitContent, false));
            AddAssert("explicit control set to hide", () => control.ExplicitContent.Value == SearchExplicit.Hide);
        }
Esempio n. 3
0
 public void APIStateChanged(APIAccess api, APIState state)
 {
     switch (state)
     {
     case APIState.Online:
         LocalConfig.Set(OsuSetting.Username, LocalConfig.Get <bool>(OsuSetting.SaveUsername) ? API.Username : string.Empty);
         break;
     }
 }
Esempio n. 4
0
 public void APIStateChanged(APIAccess api, APIState state)
 {
     switch (state)
     {
     case APIState.Online:
         Config.Set(OsuConfig.Username, Config.Get <bool>(OsuConfig.SaveUsername) ? API.Username : string.Empty);
         Config.Set(OsuConfig.Password, Config.Get <bool>(OsuConfig.SavePassword) ? API.Password : string.Empty);
         break;
     }
 }
Esempio n. 5
0
        public override void RecycleLocalStorage()
        {
            base.RecycleLocalStorage();

            using (var config = new OsuConfigManager(LocalStorage))
            {
                config.Set(OsuSetting.Version, "2020.101.0");
                config.Set(OsuSetting.DisplayStarsMaximum, 10.0);
            }
        }
Esempio n. 6
0
        public void TestFilterOnResumeAfterChange()
        {
            addRulesetImportStep(0);
            addRulesetImportStep(0);

            AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, false));

            createSongSelect();

            AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
            AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());

            AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, true));

            AddStep("return", () => songSelect.MakeCurrent());
            AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
            AddAssert("filter count is 2", () => songSelect.FilterCount == 2);
        }
Esempio n. 7
0
        protected override void Dispose(bool isDisposing)
        {
            //refresh token may have changed.
            if (Config != null && API != null)
            {
                Config.Set(OsuConfig.Token, API.Token);
                Config.Save();
            }

            base.Dispose(isDisposing);
        }
        private void load(OsuConfigManager config)
        {
            config.Set(OsuSetting.ShowStoryboard, true);

            storyboard = new Storyboard();
            var backgroundLayer = storyboard.GetLayer("Background");

            backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -7000, volume: 20));
            backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -5000, volume: 20));
            backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: 0, volume: 20));
        }
Esempio n. 9
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            var version     = game.Version;
            var lastVersion = config.Get <string>(OsuSetting.Version);

            if (game.IsDeployedBuild && version != lastVersion)
            {
                config.Set(OsuSetting.Version, version);

                // only show a notification if we've previously saved a version to the config file (ie. not the first run).
                if (!string.IsNullOrEmpty(lastVersion))
                {
                    notificationOverlay.Post(new UpdateCompleteNotification(version));
                }
            }
        }
Esempio n. 10
0
 private void onTokenChanged(ValueChangedEvent <OAuthToken> e) => config.Set(OsuSetting.Token, config.Get <bool>(OsuSetting.SavePassword) ? authentication.TokenString : string.Empty);
Esempio n. 11
0
 private void window_OnSizeChanged()
 {
     Config.Set <int>(OsuConfig.Width, Window.Size.Width);
     Config.Set <int>(OsuConfig.Height, Window.Size.Height);
 }
Esempio n. 12
0
        private void run()
        {
            while (thread.IsAlive)
            {
                switch (State)
                {
                case APIState.Failing:
                    //todo: replace this with a ping request.
                    log.Add(@"In a failing state, waiting a bit before we try again...");
                    Thread.Sleep(5000);
                    if (queue.Count == 0)
                    {
                        log.Add(@"Queueing a ping request");
                        Queue(new ListChannelsRequest {
                            Timeout = 5000
                        });
                    }
                    break;

                case APIState.Offline:
                case APIState.Connecting:
                    //work to restore a connection...
                    if (!HasLogin)
                    {
                        State = APIState.Offline;
                        Thread.Sleep(50);
                        continue;
                    }

                    State = APIState.Connecting;

                    // save the username at this point, if the user requested for it to be.
                    config.Set(OsuSetting.Username, config.Get <bool>(OsuSetting.SaveUsername) ? ProvidedUsername : string.Empty);

                    if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(ProvidedUsername, password))
                    {
                        //todo: this fails even on network-related issues. we should probably handle those differently.
                        //NotificationOverlay.ShowMessage("Login failed!");
                        log.Add(@"Login failed!");
                        password = null;
                        authentication.Clear();
                        continue;
                    }

                    var userReq = new GetUserRequest();
                    userReq.Success += u =>
                    {
                        LocalUser.Value = u;
                        failureCount    = 0;

                        //we're connected!
                        State = APIState.Online;
                    };

                    if (!handleRequest(userReq))
                    {
                        Thread.Sleep(500);
                        continue;
                    }

                    // The Success callback event is fired on the main thread, so we should wait for that to run before proceeding.
                    // Without this, we will end up circulating this Connecting loop multiple times and queueing up many web requests
                    // before actually going online.
                    while (State != APIState.Online)
                    {
                        Thread.Sleep(500);
                    }

                    break;
                }

                //hard bail if we can't get a valid access token.
                if (authentication.RequestAccessToken() == null)
                {
                    Logout(false);
                    State = APIState.Offline;
                    continue;
                }

                //process the request queue.
                APIRequest req;
                while (queue.TryPeek(out req))
                {
                    if (handleRequest(req))
                    {
                        //we have succeeded, so let's unqueue.
                        queue.TryDequeue(out req);
                    }
                }

                Thread.Sleep(1);
            }
        }