Пример #1
0
        private void load(FrameworkConfigManager frameworkConfig)
        {
            this.frameworkConfig = frameworkConfig;

            ScoreStore.ScoreImported += score => Schedule(() => LoadScore(score));

            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-"));

                Task.Run(() => Import(paths.ToArray()));
            }

            dependencies.CacheAs(this);

            // bind config int to database RulesetInfo
            configRuleset         = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);
            Ruleset.Value         = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
            Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable <int>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += s => configSkin.Value = s.ID;
            configSkin.ValueChanged += id => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == id) ?? SkinInfo.Default;
            configSkin.TriggerChange();

            LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust);
        }
Пример #2
0
        private void load()
        {
            dependencies.CacheAs(this);

            dependencies.Cache(SentryLogger);

            dependencies.Cache(osuLogo = new OsuLogo {
                Alpha = 0
            });

            // bind config int to database RulesetInfo
            configRuleset = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);

            var preferredRuleset = RulesetStore.GetRuleset(configRuleset.Value);

            try
            {
                Ruleset.Value = preferredRuleset ?? RulesetStore.AvailableRulesets.First();
            }
            catch (Exception e)
            {
                // on startup, a ruleset may be selected which has compatibility issues.
                Logger.Error(e, $@"Failed to switch to preferred ruleset {preferredRuleset}.");
                Ruleset.Value = RulesetStore.AvailableRulesets.First();
            }

            Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable <int>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
            configSkin.ValueChanged += skinId =>
            {
                var skinInfo = SkinManager.Query(s => s.ID == skinId.NewValue);

                if (skinInfo == null)
                {
                    switch (skinId.NewValue)
                    {
                    case -1:
                        skinInfo = DefaultLegacySkin.Info;
                        break;

                    default:
                        skinInfo = SkinInfo.Default;
                        break;
                    }
                }

                SkinManager.CurrentSkinInfo.Value = skinInfo;
            };
            configSkin.TriggerChange();

            IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);

            Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);

            SelectedMods.BindValueChanged(modsChanged);
            Beatmap.BindValueChanged(beatmapChanged, true);
        }
Пример #3
0
        private void load()
        {
            if (!Host.IsPrimaryInstance && !DebugUtils.IsDebugBuild)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith('-')).ToArray();
                if (paths.Length > 0)
                    Task.Run(() => Import(paths));
            }

            dependencies.CacheAs(this);

            dependencies.Cache(SentryLogger);

            dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });

            // bind config int to database RulesetInfo
            configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset);
            Ruleset.Value = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
            Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
            configSkin.ValueChanged += skinId =>
            {
                var skinInfo = SkinManager.Query(s => s.ID == skinId.NewValue);

                if (skinInfo == null)
                {
                    switch (skinId.NewValue)
                    {
                        case -1:
                            skinInfo = DefaultLegacySkin.Info;
                            break;

                        default:
                            skinInfo = SkinInfo.Default;
                            break;
                    }
                }

                SkinManager.CurrentSkinInfo.Value = skinInfo;
            };
            configSkin.TriggerChange();

            IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);

            Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);

            SelectedMods.BindValueChanged(modsChanged);
            Beatmap.BindValueChanged(beatmapChanged, true);
        }
Пример #4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            // TODO: This is temporary until we reimplement the local FPS display.
            // It's just to allow end-users to access the framework FPS display without knowing the shortcut key.
            fpsDisplayVisible = LocalConfig.GetBindable <bool>(OsuSetting.ShowFpsDisplay);
            fpsDisplayVisible.ValueChanged += visible => { FrameStatistics.Value = visible.NewValue ? FrameStatisticsMode.Minimal : FrameStatisticsMode.None; };
            fpsDisplayVisible.TriggerChange();

            FrameStatistics.ValueChanged += e => fpsDisplayVisible.Value = e.NewValue != FrameStatisticsMode.None;
        }
        public override void SetHost(GameHost host)
        {
            base.SetHost(host);

            if (host.Window is not SDL2DesktopWindow window)
            {
                return;
            }

            window.ConfineMouseMode.Value = ConfineMouseMode.Never;
            window.Title = Name;
            window.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "vignette.ico"));

            resizable = LocalConfig.GetBindable <bool>(VignetteSetting.WindowResizable);
            resizable.BindValueChanged(e => window.Resizable = e.NewValue, true);
        }
        public override void SetHost(GameHost host)
        {
            base.SetHost(host);

            var icon      = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "app.ico");
            var resizable = LocalConfig.GetBindable <bool>(ApplicationSetting.WindowResizable);

            switch (host.Window)
            {
            case SDL2DesktopWindow sdlWindow:
                sdlWindow.Title     = Name;
                sdlWindow.Resizable = resizable.Value;
                sdlWindow.CursorStateBindable.Value |= CursorState.Default;
                sdlWindow.SetIconFromStream(icon);
                break;
            }
        }
Пример #7
0
        private void load(FrameworkConfigManager frameworkConfig)
        {
            this.frameworkConfig = frameworkConfig;

            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-")).ToArray();
                if (paths.Length > 0)
                {
                    Task.Run(() => Import(paths));
                }
            }

            dependencies.CacheAs(this);

            dependencies.Cache(RavenLogger);

            dependencies.CacheAs(ruleset);
            dependencies.CacheAs <IBindable <RulesetInfo> >(ruleset);

            dependencies.Cache(osuLogo = new OsuLogo {
                Alpha = 0
            });

            // bind config int to database RulesetInfo
            configRuleset         = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);
            ruleset.Value         = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
            ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable <int>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
            configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default;
            configSkin.TriggerChange();

            LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust);

            IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
        }
Пример #8
0
        private void load()
        {
            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-"));
                Task.Run(() => BeatmapDatabase.Import(paths));
            }

            Dependencies.Cache(this);

            PlayMode = LocalConfig.GetBindable <PlayMode>(OsuConfig.PlayMode);
        }
Пример #9
0
        private void load()
        {
            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-"));
                Task.Run(() => BeatmapDatabase.Import(paths.ToArray()));
            }

            Dependencies.Cache(this);

            configRuleset         = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);
            Ruleset.Value         = RulesetDatabase.GetRuleset(configRuleset.Value);
            Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
        }
Пример #10
0
        private void load(FrameworkConfigManager frameworkConfig)
        {
            this.frameworkConfig = frameworkConfig;

            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            if (args?.Length > 0)
            {
                var paths = args.Where(a => !a.StartsWith(@"-"));
                Task.Run(() => BeatmapManager.Import(paths.ToArray()));
            }

            dependencies.CacheAs <OsuGame>(this);

            configRuleset         = LocalConfig.GetBindable <int>(OsuSetting.Ruleset);
            Ruleset.Value         = RulesetStore.GetRuleset(configRuleset.Value) ?? RulesetStore.AvailableRulesets.First();
            Ruleset.ValueChanged += r => configRuleset.Value = r.ID ?? 0;
        }
Пример #11
0
        public void TestPauseWithLargeOffset()
        {
            double lastTime;
            bool   alwaysGoingForward = true;

            AddStep("force large offset", () =>
            {
                var offset = (BindableDouble)LocalConfig.GetBindable <double>(OsuSetting.AudioOffset);

                // use a large negative offset to avoid triggering a fail from forwards seeking.
                offset.MinValue = -5000;
                offset.Value    = -5000;
            });

            AddStep("add time forward check hook", () =>
            {
                lastTime           = double.MinValue;
                alwaysGoingForward = true;

                Player.OnUpdate += _ =>
                {
                    double currentTime  = Player.GameplayClockContainer.CurrentTime;
                    alwaysGoingForward &= currentTime >= lastTime;
                    lastTime            = currentTime;
                };
            });

            AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));

            pauseAndConfirm();

            resumeAndConfirm();

            AddAssert("time didn't go backwards", () => alwaysGoingForward);

            AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0));
        }
Пример #12
0
        private void load()
        {
            dependencies.CacheAs(this);

            dependencies.Cache(SentryLogger);

            dependencies.Cache(osuLogo = new OsuLogo {
                Alpha = 0
            });

            // bind config int to database RulesetInfo
            configRuleset = LocalConfig.GetBindable <string>(OsuSetting.Ruleset);
            uiScale       = LocalConfig.GetBindable <float>(OsuSetting.UIScale);

            var preferredRuleset = int.TryParse(configRuleset.Value, out int rulesetId)
                                   // int parsing can be removed 20220522
                ? RulesetStore.GetRuleset(rulesetId)
                : RulesetStore.GetRuleset(configRuleset.Value);

            try
            {
                Ruleset.Value = preferredRuleset ?? RulesetStore.AvailableRulesets.First();
            }
            catch (Exception e)
            {
                // on startup, a ruleset may be selected which has compatibility issues.
                Logger.Error(e, $@"Failed to switch to preferred ruleset {preferredRuleset}.");
                Ruleset.Value = RulesetStore.AvailableRulesets.First();
            }

            Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ShortName;

            // bind config int to database SkinInfo
            configSkin = LocalConfig.GetBindable <string>(OsuSetting.Skin);
            SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
            configSkin.ValueChanged += skinId =>
            {
                ILive <SkinInfo> skinInfo = null;

                if (Guid.TryParse(skinId.NewValue, out var guid))
                {
                    skinInfo = SkinManager.Query(s => s.ID == guid);
                }

                if (skinInfo == null)
                {
                    if (guid == SkinInfo.CLASSIC_SKIN)
                    {
                        skinInfo = DefaultLegacySkin.CreateInfo().ToLive();
                    }
                }

                SkinManager.CurrentSkinInfo.Value = skinInfo ?? DefaultSkin.CreateInfo().ToLive();
            };
            configSkin.TriggerChange();

            IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);

            Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);

            SelectedMods.BindValueChanged(modsChanged);
            Beatmap.BindValueChanged(beatmapChanged, true);
        }