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); }
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); }
private void updateActiveState(bool isActive) { if (isActive) { Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); } else { Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); } }
private void updateActiveState(bool isActive) { if (isActive) { this.TransformBindableTo(inactiveVolumeFade, 1, 500, Easing.OutQuint) .Finally(_ => Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeFade)); //wait for the transition to finish to remove the inactive audio adjustment } else { Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade); this.TransformBindableTo(inactiveVolumeFade, userInactiveVolume.Value, 1500, Easing.OutSine); } }
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.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(); IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true); Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade); Beatmap.BindValueChanged(beatmapChanged, true); }
protected override void OnDeactivated() { base.OnDeactivated(); Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); }
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); }