private void load() { InterpretedDifficulty.Default = BeatmapDifficultyCache.GetDifficultyRating(EditorBeatmap.BeatmapInfo.StarRating); InterpretedDifficulty.SetDefault(); Child = new Container { RelativeSizeAxes = Axes.Both, Child = new GridContainer { RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(), new Dimension(GridSizeMode.Absolute, 250), }, Content = new[] { new Drawable[] { IssueList = new IssueList(), new IssueSettings(), }, } } }; }
public void Bindability() { var a = new Bindable <int>(2, 1); var b = new Bindable <int>(3, 4); a.BindTo(b); AssertBindableValues(2, 3); b.SetDefault(); AssertBindableValues(4, 4); a.SetDefault(); AssertBindableValues(1, 4); a.Value = 412; AssertBindableValues(412, 4); b.Value = 425; AssertBindableValues(425, 425); void AssertBindableValues(int va, int vb) { Assert.AreEqual(va, a.Value); Assert.AreEqual(vb, b.Value); } }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var baseDependencies = base.CreateChildDependencies(parent); var providedRuleset = CreateRuleset(); if (providedRuleset != null) { baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = new OsuScreenDependencies(false, baseDependencies); Beatmap = Dependencies.Beatmap; Beatmap.SetDefault(); Ruleset = Dependencies.Ruleset; Ruleset.SetDefault(); SelectedMods = Dependencies.Mods; SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); Add(dummyAPI); } return(Dependencies); }
public void TestGameplayExitFlow() { Bindable <double> holdDelay = null; AddStep("Set hold delay to zero", () => { holdDelay = config.GetBindable <double>(OsuSetting.UIHoldActivationDelay); holdDelay.Value = 0; }); createRoom(() => new Room { Name = { Value = "Test Room" }, Playlist = { new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo) { RulesetID = new OsuRuleset().RulesetInfo.OnlineID, } } }); enterGameplay(); AddUntilStep("wait for playing", () => this.ChildrenOfType <Player>().FirstOrDefault()?.LocalUserPlaying.Value == true); AddStep("attempt exit without hold", () => InputManager.Key(Key.Escape)); AddAssert("still in gameplay", () => multiplayerComponents.CurrentScreen is Player); AddStep("attempt exit with hold", () => InputManager.PressKey(Key.Escape)); AddUntilStep("wait for lounge", () => multiplayerComponents.CurrentScreen is Screens.OnlinePlay.Multiplayer.Multiplayer); AddStep("stop holding", () => InputManager.ReleaseKey(Key.Escape)); AddStep("set hold delay to default", () => holdDelay.SetDefault()); }
protected override bool OnClick(InputState state) { if (bindable != null && !bindable.Disabled) { bindable.SetDefault(); } return(true); }
protected override bool OnClick(InputState state) { if (!Bindable.Disabled) { Bindable.SetDefault(); } return(true); }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { if (!UseFreshStoragePerRun) { isolatedHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage; } Resources = parent.Get <OsuGameBase>().Resources; contextFactory = new Lazy <DatabaseContextFactory>(() => { var factory = new DatabaseContextFactory(LocalStorage); // only reset the database if not using the host storage. // if we reset the host storage, it will delete global key bindings. if (isolatedHostStorage == null) { factory.ResetDatabase(); } using (var usage = factory.Get()) usage.Migrate(); return(factory); }); RecycleLocalStorage(); var baseDependencies = base.CreateChildDependencies(parent); var providedRuleset = CreateRuleset(); if (providedRuleset != null) { baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = new OsuScreenDependencies(false, baseDependencies); Beatmap = Dependencies.Beatmap; Beatmap.SetDefault(); Ruleset = Dependencies.Ruleset; Ruleset.SetDefault(); SelectedMods = Dependencies.Mods; SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); base.Content.Add(dummyAPI); } return(Dependencies); }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { headlessHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage; Resources = parent.Get <OsuGameBase>().Resources; contextFactory = new Lazy <DatabaseContextFactory>(() => { var factory = new DatabaseContextFactory(LocalStorage); using (var usage = factory.Get()) usage.Migrate(); return(factory); }); RecycleLocalStorage(false); var baseDependencies = base.CreateChildDependencies(parent); // to isolate ruleset configs in tests from the actual database and avoid state pollution problems, // as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`), // cache a test implementation of the ruleset config cache over the "real" one. var isolatedBaseDependencies = new DependencyContainer(baseDependencies); isolatedBaseDependencies.CacheAs(RulesetConfigs = new TestRulesetConfigCache()); baseDependencies = isolatedBaseDependencies; var providedRuleset = CreateRuleset(); if (providedRuleset != null) { baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = new OsuScreenDependencies(false, baseDependencies); Beatmap = Dependencies.Beatmap; Beatmap.SetDefault(); Ruleset = Dependencies.Ruleset; Ruleset.SetDefault(); SelectedMods = Dependencies.Mods; SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); base.Content.Add(dummyAPI); } return(Dependencies); }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { headlessHostStorage = (parent.Get <GameHost>() as HeadlessGameHost)?.Storage; Resources = parent.Get <OsuGameBase>().Resources; contextFactory = new Lazy <DatabaseContextFactory>(() => { var factory = new DatabaseContextFactory(LocalStorage); using (var usage = factory.Get()) usage.Migrate(); return(factory); }); RecycleLocalStorage(false); var baseDependencies = base.CreateChildDependencies(parent); var providedRuleset = CreateRuleset(); if (providedRuleset != null) { baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies); } Dependencies = new OsuScreenDependencies(false, baseDependencies); Beatmap = Dependencies.Beatmap; Beatmap.SetDefault(); Ruleset = Dependencies.Ruleset; Ruleset.SetDefault(); SelectedMods = Dependencies.Mods; SelectedMods.SetDefault(); if (!UseOnlineAPI) { dummyAPI = new DummyAPIAccess(); Dependencies.CacheAs <IAPIProvider>(dummyAPI); base.Content.Add(dummyAPI); } return(Dependencies); }
private void migrateSettingFromConfig() { Bindable <bool> configShowGraph = config.GetBindable <bool>(OsuSetting.ShowProgressGraph); if (!configShowGraph.IsDefault) { ShowGraph.Value = configShowGraph.Value; // This is pretty ugly, but the only way to make this stick... if (skinManager != null) { var skinnableTarget = this.FindClosestParent <ISkinnableTarget>(); if (skinnableTarget != null) { // If the skin is not mutable, a mutable instance will be created, causing this migration logic to run again on the correct skin. // Therefore we want to avoid resetting the config value on this invocation. if (skinManager.EnsureMutableSkin()) { return; } // If `EnsureMutableSkin` actually changed the skin, default layout may take a frame to apply. // See `SkinnableTargetComponentsContainer`'s use of ScheduleAfterChildren. ScheduleAfterChildren(() => { var skin = skinManager.CurrentSkin.Value; skin.UpdateDrawableTarget(skinnableTarget); skinManager.Save(skin); }); configShowGraph.SetDefault(); } } } }
private void load() { Children = new Drawable[] { new SettingsCheckbox { LabelText = "Enabled", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Current = tabletHandler.Enabled }, noTabletMessage = new OsuSpriteText { Text = "No tablet detected!", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS } }, mainSettings = new FillFlowContainer { Alpha = 0, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 8), Direction = FillDirection.Vertical, Children = new Drawable[] { new TabletAreaSelection(tabletHandler) { RelativeSizeAxes = Axes.X, Height = 300, }, new DangerousSettingsButton { Text = "Reset to full area", Action = () => { aspectLock.Value = false; areaOffset.SetDefault(); areaSize.SetDefault(); }, }, new SettingsButton { Text = "Conform to current game aspect ratio", Action = () => { forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height); } }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = "Aspect Ratio", Current = aspectRatio }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = "X Offset", Current = offsetX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = "Y Offset", Current = offsetY }, new SettingsCheckbox { LabelText = "Lock aspect ratio", Current = aspectLock }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = "Width", Current = sizeX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = "Height", Current = sizeY }, } }, }; }
private void load(OsuColour colours) { Children = new Drawable[] { new SettingsCheckbox { LabelText = CommonStrings.Enabled, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Current = enabled, }, noTabletMessage = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }, Spacing = new Vector2(5f), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = TabletSettingsStrings.NoTabletDetected, }, new SettingsNoticeText(colours) { TextAnchor = Anchor.TopCentre, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }.With(t => { if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows || RuntimeInfo.OS == RuntimeInfo.Platform.Linux) { t.NewLine(); t.AddText("If your tablet is not detected, please read "); t.AddLink("this FAQ", LinkAction.External, RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? @"https://opentabletdriver.net/Wiki/FAQ/Windows" : @"https://opentabletdriver.net/Wiki/FAQ/Linux"); t.AddText(" for troubleshooting steps."); } }), } }, mainSettings = new FillFlowContainer { Alpha = 0, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 8), Direction = FillDirection.Vertical, Children = new Drawable[] { AreaSelection = new TabletAreaSelection(tabletHandler) { RelativeSizeAxes = Axes.X, Height = 300, }, new DangerousSettingsButton { Text = TabletSettingsStrings.ResetToFullArea, Action = () => { aspectLock.Value = false; areaOffset.SetDefault(); areaSize.SetDefault(); }, }, new SettingsButton { Text = TabletSettingsStrings.ConformToCurrentGameAspectRatio, Action = () => { forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height); } }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.XOffset, Current = offsetX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.YOffset, Current = offsetY }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.Rotation, Current = rotation }, new RotationPresetButtons(tabletHandler) { Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS } }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.AspectRatio, Current = aspectRatio }, new SettingsCheckbox { LabelText = TabletSettingsStrings.LockAspectRatio, Current = aspectLock }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = CommonStrings.Width, Current = sizeX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = CommonStrings.Height, Current = sizeY }, } }, }; }
private void ensureDefault <T>(Bindable <T> bindable) => bindable.SetDefault();
private void load() { Children = new Drawable[] { new SettingsCheckbox { LabelText = CommonStrings.Enabled, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Current = tabletHandler.Enabled }, noTabletMessage = new OsuSpriteText { Text = TabletSettingsStrings.NoTabletDetected, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS } }, mainSettings = new FillFlowContainer { Alpha = 0, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 8), Direction = FillDirection.Vertical, Children = new Drawable[] { new TabletAreaSelection(tabletHandler) { RelativeSizeAxes = Axes.X, Height = 300, }, new DangerousSettingsButton { Text = TabletSettingsStrings.ResetToFullArea, Action = () => { aspectLock.Value = false; areaOffset.SetDefault(); areaSize.SetDefault(); }, }, new SettingsButton { Text = TabletSettingsStrings.ConformToCurrentGameAspectRatio, Action = () => { forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height); } }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.XOffset, Current = offsetX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.YOffset, Current = offsetY }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.Rotation, Current = rotation }, new RotationPresetButtons(tabletHandler), new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = TabletSettingsStrings.AspectRatio, Current = aspectRatio }, new SettingsCheckbox { LabelText = TabletSettingsStrings.LockAspectRatio, Current = aspectLock }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = CommonStrings.Width, Current = sizeX }, new SettingsSlider <float> { TransferValueOnCommit = true, LabelText = CommonStrings.Height, Current = sizeY }, } }, }; }