Exemple #1
0
        public LyricEditor()
        {
            Child = new SkinProvidingContainer(skin = new KaraokeLyricEditorSkin())
            {
                RelativeSizeAxes = Axes.Both,
                Child            = container = new DrawableLyricEditList
                {
                    RelativeSizeAxes = Axes.Both,
                }
            };

            container.Items.BindTo(BindableLyrics);
            if (lyricManager != null)
            {
                container.OnOrderChanged += lyricManager.ChangeLyricOrder;
            }

            MoveCaret(MovingCaretAction.First);

            BindableMode.BindValueChanged(e =>
            {
                // display add new lyric only with edit mode.
                container.DisplayBottomDrawable = e.NewValue == Mode.EditMode;
            }, true);
        }
Exemple #2
0
        private void addGameplayComponents(Container target, WorkingBeatmap working)
        {
            var beatmapSkinProvider = new BeatmapSkinProvidingContainer(working.Skin);

            // the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
            // full access to all skin sources.
            var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider));

            // load the skinning hierarchy first.
            // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
            target.Add(new ScalingContainer(ScalingMode.Gameplay)
                       .WithChild(beatmapSkinProvider
                                  .WithChild(target = rulesetSkinProvider)));

            target.AddRange(new Drawable[]
            {
                DrawableRuleset,
                new ComboEffects(ScoreProcessor)
            });

            DrawableRuleset.FrameStableComponents.AddRange(new Drawable[]
            {
                ScoreProcessor,
                HealthProcessor,
                breakTracker = new BreakTracker(DrawableRuleset.GameplayStartTime, ScoreProcessor)
                {
                    Breaks = working.Beatmap.Breaks
                }
            });

            HealthProcessor.IsBreakTime.BindTo(breakTracker.IsBreakTime);
        }
Exemple #3
0
        public void TestConfineScaleUp()
        {
            FillFlowContainer <ExposedSkinnableDrawable> fill = null;

            AddStep("setup layout larger source", () =>
            {
                Child = new SkinProvidingContainer(new SizedSource(30))
                {
                    RelativeSizeAxes = Axes.Both,
                    Child            = fill = new FillFlowContainer <ExposedSkinnableDrawable>
                    {
                        Size     = new Vector2(50),
                        Anchor   = Anchor.Centre,
                        Origin   = Anchor.Centre,
                        Spacing  = new Vector2(10),
                        Children = new[]
                        {
                            new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
                            new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
                            new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
                            new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
                        }
                    },
                };
            });

            AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
            AddStep("adjust scale", () => fill.Scale = new Vector2(2));
            AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
        }
        public void TestBallTintChangedOnAccentChange()
        {
            DrawableSlider dho = null;

            AddStep("create slider", () =>
            {
                var tintingSkin = skinManager.GetSkin(DefaultLegacySkin.CreateInfo());
                tintingSkin.Configuration.ConfigDictionary["AllowSliderBallTint"] = "1";

                Child = new SkinProvidingContainer(tintingSkin)
                {
                    RelativeSizeAxes = Axes.Both,
                    Child            = dho = new DrawableSlider(prepareObject(new Slider
                    {
                        Position            = new Vector2(256, 192),
                        IndexInCurrentCombo = 0,
                        StartTime           = Time.Current,
                        Path = new SliderPath(PathType.Linear, new[]
                        {
                            Vector2.Zero,
                            new Vector2(150, 100),
                            new Vector2(300, 0),
                        })
                    }))
                };
            });

            AddStep("set accent white", () => dho.AccentColour.Value = Color4.White);
            AddAssert("ball is white", () => dho.ChildrenOfType <SliderBall>().Single().AccentColour == Color4.White);

            AddStep("set accent red", () => dho.AccentColour.Value = Color4.Red);
            AddAssert("ball is red", () => dho.ChildrenOfType <SliderBall>().Single().AccentColour == Color4.Red);
        }
Exemple #5
0
        private Drawable createProvider(Skin skin, Func <Drawable> creationFunction, IBeatmap beatmap)
        {
            var created = creationFunction();

            createdDrawables.Add(created);

            var autoSize = created.RelativeSizeAxes == Axes.None;

            var mainProvider = new SkinProvidingContainer(skin)
            {
                RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None,
                AutoSizeAxes     = autoSize ? Axes.Both : Axes.None,
            };

            return(new Container
            {
                RelativeSizeAxes = Axes.Both,
                BorderColour = Color4.White,
                BorderThickness = 5,
                Masking = true,

                Children = new Drawable[]
                {
                    new Box
                    {
                        AlwaysPresent = true,
                        Alpha = 0,
                        RelativeSizeAxes = Axes.Both,
                    },
                    new OsuSpriteText
                    {
                        Text = skin?.SkinInfo?.Name ?? "none",
                        Scale = new Vector2(1.5f),
                        Padding = new MarginPadding(5),
                    },
                    new Container
                    {
                        RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None,
                        AutoSizeAxes = autoSize ? Axes.Both : Axes.None,
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Children = new Drawable[]
                        {
                            new OutlineBox {
                                Alpha = autoSize ? 1 : 0
                            },
                            mainProvider.WithChild(
                                new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider, beatmap))
                            {
                                Child = created,
                                RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None,
                                AutoSizeAxes = autoSize ? Axes.Both : Axes.None,
                            }
                                )
                        }
                    },
                }
            });
        }
 private void load()
 {
     Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
     Child         = new SkinProvidingContainer(skin)
     {
         RelativeSizeAxes = Axes.Both,
         Child            = new StyleScreen(),
     };
 }
Exemple #7
0
        private Drawable createProvider(Skin skin, Func <Drawable> creationFunction)
        {
            var mainProvider = new SkinProvidingContainer(skin);

            return(mainProvider
                   .WithChild(new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider))
            {
                Child = creationFunction()
            }));
        }
        private Drawable setupSkinHierarchy(Drawable child, ISkin skin)
        {
            var legacySkinProvider    = new SkinProvidingContainer(skins.GetSkin(DefaultLegacySkin.CreateInfo()));
            var testSkinProvider      = new SkinProvidingContainer(skin);
            var legacySkinTransformer = new SkinProvidingContainer(new CatchLegacySkinTransformer(testSkinProvider));

            return(legacySkinProvider
                   .WithChild(testSkinProvider
                              .WithChild(legacySkinTransformer
                                         .WithChild(child))));
        }
Exemple #9
0
        public void TestCatchSkinColourDecoding()
        {
            var store   = new NamespacedResourceStore <byte[]>(new DllResourceStore(GetType().Assembly), "Resources/special-skin");
            var rawSkin = new TestLegacySkin(new SkinInfo {
                Name = "special-skin"
            }, store);
            var skinSource = new SkinProvidingContainer(rawSkin);
            var skin       = new CatchLegacySkinTransformer(skinSource);

            Assert.AreEqual(new Colour4(232, 185, 35, 255), skin.GetConfig <CatchSkinColour, Colour4>(CatchSkinColour.HyperDash)?.Value);
            Assert.AreEqual(new Colour4(232, 74, 35, 255), skin.GetConfig <CatchSkinColour, Colour4>(CatchSkinColour.HyperDashAfterImage)?.Value);
            Assert.AreEqual(new Colour4(0, 255, 255, 255), skin.GetConfig <CatchSkinColour, Colour4>(CatchSkinColour.HyperDashFruit)?.Value);
        }
 public void SetUp() => Schedule(() =>
 {
     Child = new SkinProvidingContainer(skin)
     {
         RelativeSizeAxes = Axes.Both,
         Child            = toolTip = new LayoutToolTip
         {
             Anchor = Anchor.Centre,
             Origin = Anchor.Centre
         }
     };
     toolTip.Show();
 });
Exemple #11
0
        private Drawable wrapSkinnableContent(Drawable content)
        {
            Debug.Assert(ruleset != null);

            var beatmapSkinProvider = new BeatmapSkinProvidingContainer(beatmap.Value.Skin);

            // the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
            // full access to all skin sources.
            var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, EditorBeatmap.PlayableBeatmap));

            // load the skinning hierarchy first.
            // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
            return(beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(content)));
        }
Exemple #12
0
        protected override Drawable CreateMainContent()
        {
            if (ruleset == null || composer == null)
            {
                return(new ScreenWhiteBox.UnderConstructionMessage(ruleset == null ? "This beatmap" : $"{ruleset.Description}'s composer"));
            }

            var beatmapSkinProvider = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);

            // the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
            // full access to all skin sources.
            var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, EditorBeatmap.PlayableBeatmap));

            // load the skinning hierarchy first.
            // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
            return(beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(composer)));
        }
Exemple #13
0
        public void SetUp() => Schedule(() =>
        {
            hitCircle = new HitCircle
            {
                Position  = new Vector2(100, 100),
                StartTime = Time.Current + 500
            };

            hitCircle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

            Child = new SkinProvidingContainer(new DefaultSkin(null))
            {
                RelativeSizeAxes = Axes.Both,
                Child            = drawableHitCircle = new DrawableHitCircle(hitCircle)
                {
                    Size = new Vector2(100)
                }
            };
        });
Exemple #14
0
        public void TestOverride()
        {
            var secondarySource = new SecondarySource();

            SkinConsumer consumer = null;
            Container    target   = null;

            AddStep("setup layout", () =>
            {
                Child = new SkinSourceContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Child            = target = new SkinProvidingContainer(secondarySource)
                    {
                        RelativeSizeAxes = Axes.Both,
                    }
                };
            });

            AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
            AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
            AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
        }
Exemple #15
0
        private Drawable createProvider(Skin skin, Func <ISkin, Drawable> creationFunction, IBeatmap beatmap)
        {
            var created = creationFunction(skin);

            createdDrawables.Add(created);

            SkinProvidingContainer mainProvider;
            Container              childContainer;
            OutlineBox             outlineBox;
            SkinProvidingContainer skinProvider;

            var children = new Container
            {
                RelativeSizeAxes = Axes.Both,
                BorderColour     = Colour4.White,
                BorderThickness  = 5,
                Masking          = true,

                Children = new Drawable[]
                {
                    new Box
                    {
                        AlwaysPresent    = true,
                        Alpha            = 0,
                        RelativeSizeAxes = Axes.Both,
                    },
                    new OsuSpriteText
                    {
                        Text    = skin?.SkinInfo?.Name ?? "none",
                        Scale   = new Vector2(1.5f),
                        Padding = new MarginPadding(5),
                    },
                    childContainer = new Container
                    {
                        Anchor   = Anchor.Centre,
                        Origin   = Anchor.Centre,
                        Children = new Drawable[]
                        {
                            outlineBox = new OutlineBox(),
                            (mainProvider = new SkinProvidingContainer(skin)).WithChild(
                                skinProvider = new SkinProvidingContainer(Ruleset.Value.CreateInstance().CreateLegacySkinProvider(mainProvider, beatmap))
                            {
                                Child = created,
                            }
                                )
                        }
                    },
                }
            };

            // run this once initially to bring things into a sane state as early as possible.
            updateSizing();

            // run this once after construction to handle the case the changes are made in a BDL/LoadComplete call.
            Schedule(updateSizing);

            return(children);

            void updateSizing()
            {
                bool autoSize = created.RelativeSizeAxes == Axes.None;

                foreach (var c in new[] { mainProvider, childContainer, skinProvider })
                {
                    c.RelativeSizeAxes = Axes.None;
                    c.AutoSizeAxes     = Axes.None;

                    c.RelativeSizeAxes = !autoSize ? Axes.Both : Axes.None;
                    c.AutoSizeAxes     = autoSize ? Axes.Both : Axes.None;
                }

                outlineBox.Alpha = autoSize ? 1 : 0;
            }
        }
Exemple #16
0
        private void load(AudioManager audio, OsuConfigManager config, OsuGame game)
        {
            Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();

            if (Beatmap.Value is DummyWorkingBeatmap)
            {
                return;
            }

            IBeatmap playableBeatmap = loadPlayableBeatmap();

            if (playableBeatmap == null)
            {
                return;
            }

            sampleRestart = audio.Samples.Get(@"Gameplay/restart");

            mouseWheelDisabled = config.GetBindable <bool>(OsuSetting.MouseDisableWheel);

            if (game != null)
            {
                LocalUserPlaying.BindTo(game.LocalUserPlaying);
            }

            DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);

            ScoreProcessor = ruleset.CreateScoreProcessor();
            ScoreProcessor.ApplyBeatmap(playableBeatmap);
            ScoreProcessor.Mods.BindTo(Mods);

            HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
            HealthProcessor.ApplyBeatmap(playableBeatmap);

            if (!ScoreProcessor.Mode.Disabled)
            {
                config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
            }

            InternalChild = GameplayClockContainer = CreateGameplayClockContainer(Beatmap.Value, DrawableRuleset.GameplayStartTime);

            AddInternal(gameplayBeatmap  = new GameplayBeatmap(playableBeatmap));
            AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));

            dependencies.CacheAs(gameplayBeatmap);

            var beatmapSkinProvider = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);

            // the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
            // full access to all skin sources.
            var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, playableBeatmap));

            // load the skinning hierarchy first.
            // this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
            GameplayClockContainer.Add(beatmapSkinProvider.WithChild(rulesetSkinProvider));

            rulesetSkinProvider.AddRange(new[]
            {
                // underlay and gameplay should have access the to skinning sources.
                createUnderlayComponents(),
                createGameplayComponents(Beatmap.Value, playableBeatmap)
            });

            // also give the HUD a ruleset container to allow rulesets to potentially override HUD elements (used to disable combo counters etc.)
            // we may want to limit this in the future to disallow rulesets from outright replacing elements the user expects to be there.
            var hudRulesetContainer = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, playableBeatmap));

            // add the overlay components as a separate step as they proxy some elements from the above underlay/gameplay components.
            GameplayClockContainer.Add(hudRulesetContainer.WithChild(createOverlayComponents(Beatmap.Value)));

            if (!DrawableRuleset.AllowGameplayOverlays)
            {
                HUDOverlay.ShowHud.Value    = false;
                HUDOverlay.ShowHud.Disabled = true;
                BreakOverlay.Hide();
                skipOverlay.Hide();
            }

            DrawableRuleset.FrameStableClock.WaitingOnFrames.BindValueChanged(waiting =>
            {
                if (waiting.NewValue)
                {
                    GameplayClockContainer.Stop();
                }
                else
                {
                    GameplayClockContainer.Start();
                }
            });

            DrawableRuleset.IsPaused.BindValueChanged(paused =>
            {
                updateGameplayState();
                updateSampleDisabledState();
            });

            DrawableRuleset.FrameStableClock.IsCatchingUp.BindValueChanged(_ => updateSampleDisabledState());

            DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());

            DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);

            // bind clock into components that require it
            DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);

            DrawableRuleset.NewResult += r =>
            {
                HealthProcessor.ApplyResult(r);
                ScoreProcessor.ApplyResult(r);
                gameplayBeatmap.ApplyResult(r);
            };

            DrawableRuleset.RevertResult += r =>
            {
                HealthProcessor.RevertResult(r);
                ScoreProcessor.RevertResult(r);
            };

            // Bind the judgement processors to ourselves
            ScoreProcessor.HasCompleted.ValueChanged += updateCompletionState;
            HealthProcessor.Failed += onFail;

            foreach (var mod in Mods.Value.OfType <IApplicableToScoreProcessor>())
            {
                mod.ApplyToScoreProcessor(ScoreProcessor);
            }

            foreach (var mod in Mods.Value.OfType <IApplicableToHealthProcessor>())
            {
                mod.ApplyToHealthProcessor(HealthProcessor);
            }

            IsBreakTime.BindTo(breakTracker.IsBreakTime);
            IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
        }
Exemple #17
0
        public TestSceneLyricLineStyle()
        {
            Child = new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                ColumnDimensions = new[]
                {
                    new Dimension(GridSizeMode.Absolute, 410f)
                },
                Content = new[]
                {
                    new Drawable[]
                    {
                        new GridContainer
                        {
                            Name             = "Edit container",
                            RelativeSizeAxes = Axes.Both,
                            Content          = new[]
                            {
                                new Drawable[]
                                {
                                    new Container
                                    {
                                        Name             = "Color section",
                                        RelativeSizeAxes = Axes.Both,
                                        Children         = new Drawable[]
                                        {
                                            new Box
                                            {
                                                Name             = "Setting background",
                                                RelativeSizeAxes = Axes.Both,
                                                Colour           = Color4.Gray
                                            },
                                            new FillFlowContainer
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding(5),
                                                Spacing          = new Vector2(10),
                                                Children         = new Drawable[]
                                                {
                                                    new EditSection
                                                    {
                                                        Name     = "Color",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Color"
                                                            },
                                                            colorAreaDropdown = new OsuDropdown <ColorArea>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items            = EnumUtils.GetValues <ColorArea>()
                                                            }
                                                        }
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Brush type",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Brush type"
                                                            },
                                                            brushTypeDropdown = new OsuDropdown <BrushType>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items            = EnumUtils.GetValues <BrushType>()
                                                            }
                                                        }
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Color picker",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Color picker"
                                                            },
                                                            colorPicker = new ColorPicker
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                            }
                                                        }
                                                    },
                                                }
                                            }
                                        }
                                    }
                                },
                                new Drawable[]
                                {
                                    new Container
                                    {
                                        Name             = "Font section",
                                        RelativeSizeAxes = Axes.Both,
                                        Children         = new Drawable[]
                                        {
                                            new Box
                                            {
                                                Name             = "Setting background",
                                                RelativeSizeAxes = Axes.Both,
                                                Colour           = Color4.Gray
                                            },
                                            fontSection = new FillFlowContainer
                                            {
                                                RelativeSizeAxes = Axes.Both,
                                                Padding          = new MarginPadding(5),
                                                Spacing          = new Vector2(10),
                                                Children         = new Drawable[]
                                                {
                                                    new EditSection
                                                    {
                                                        Name     = "Font area",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Font area"
                                                            },
                                                            fontAreaDropdown = new OsuDropdown <FontArea>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items            = EnumUtils.GetValues <FontArea>()
                                                            }
                                                        }
                                                    },
                                                    new EditSection
                                                    {
                                                        // TODO : implement
                                                        Name     = "Font",
                                                        Alpha    = 0,
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Font"
                                                            },
                                                            fontDropdown = new OsuDropdown <Font>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Items            = EnumUtils.GetValues <Font>()
                                                            }
                                                        }
                                                    },
                                                    boldCheckbox = new OsuCheckbox
                                                    {
                                                        LabelText = "Bold"
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Font size",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Font size"
                                                            },
                                                            fontSizeSliderBar = new OsuSliderBar <float>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Current          = new BindableFloat
                                                                {
                                                                    Value    = 30,
                                                                    MinValue = 10,
                                                                    MaxValue = 70
                                                                }
                                                            }
                                                        }
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Border size",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Border size"
                                                            },
                                                            borderSliderBar = new OsuSliderBar <int>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Current          = new BindableInt
                                                                {
                                                                    Value    = 10,
                                                                    MinValue = 0,
                                                                    MaxValue = 20
                                                                }
                                                            }
                                                        }
                                                    },
                                                    displayShaderCheckbox = new OsuCheckbox
                                                    {
                                                        LabelText = "Display shadow"
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Shadow X",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Shadow X"
                                                            },
                                                            shadowXSliderBar = new OsuSliderBar <float>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Current          = new BindableFloat
                                                                {
                                                                    Value    = 10,
                                                                    MinValue = 0,
                                                                    MaxValue = 20
                                                                }
                                                            }
                                                        }
                                                    },
                                                    new EditSection
                                                    {
                                                        Name     = "Shadow Y",
                                                        Children = new Drawable[]
                                                        {
                                                            new OsuSpriteText {
                                                                Text = "Shadow Y"
                                                            },
                                                            shadowYSliderBar = new OsuSliderBar <float>
                                                            {
                                                                RelativeSizeAxes = Axes.X,
                                                                Current          = new BindableFloat
                                                                {
                                                                    Value    = 10,
                                                                    MinValue = 0,
                                                                    MaxValue = 20
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            Name             = "Preview container",
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Name             = "Preview background",
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.WhiteSmoke
                                },
                                layoutArea = new SkinProvidingContainer(new KaraokeStyleEditorSkin())
                                {
                                    RelativeSizeAxes = Axes.Both,
                                }
                            }
                        }
                    },
                }
            };

            colorAreaDropdown.Current.BindValueChanged(value => { brushTypeDropdown.Current.Value = drawableLyricLine.GetBrushInfo(value.NewValue).Type; });

            brushTypeDropdown.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(selectedColorArea, x => x.Type = value.NewValue));

            fontAreaDropdown.Current.BindValueChanged(value =>
            {
                var fontInfo = drawableLyricLine.GetFontInfo(value.NewValue);
                boldCheckbox.Current.Value      = fontInfo.Bold;
                fontSizeSliderBar.Current.Value = fontInfo.CharSize;
                borderSliderBar.Current.Value   = fontInfo.EdgeSize;
            });

            boldCheckbox.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(selectedFontArea, x => x.Bold          = value.NewValue));
            fontSizeSliderBar.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(selectedFontArea, x => x.CharSize = value.NewValue));
            borderSliderBar.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(selectedFontArea, x => x.EdgeSize   = value.NewValue));

            displayShaderCheckbox.Current.BindValueChanged(value =>
            {
                var karaokeFont = drawableLyricLine.Font;
                shadowXSliderBar.Current.Value = karaokeFont.ShadowOffset.X;
                shadowYSliderBar.Current.Value = karaokeFont.ShadowOffset.Y;

                // Update view
                fontSection.Children.Where(x => x.Name.StartsWith("Shadow ")).ForEach(x => x.Alpha = value.NewValue ? 1 : 0);

                // Update property
                drawableLyricLine.ApplyProperty(x => x.UseShadow = value.NewValue);
            });

            shadowXSliderBar.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(x => x.ShadowOffset = new Vector2(value.NewValue, x.ShadowOffset.Y)));
            shadowYSliderBar.Current.BindValueChanged(value => drawableLyricLine.ApplyProperty(x => x.ShadowOffset = new Vector2(x.ShadowOffset.X, value.NewValue)));

            AddStep("Test", () => initialLyricLine(createDefaultLyricLine()));
        }
Exemple #18
0
        public TestSceneLyricLineLayout()
        {
            Child = new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                ColumnDimensions = new[]
                {
                    new Dimension(GridSizeMode.Absolute, 210f)
                },
                Content = new[]
                {
                    new Drawable[]
                    {
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Name             = "Setting background",
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Gray
                                },
                                new FillFlowContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Padding          = new MarginPadding(5),
                                    Spacing          = new Vector2(10),
                                    Children         = new Drawable[]
                                    {
                                        new EditSection
                                        {
                                            Name     = "Name section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Name"
                                                },
                                                nameTextBox = new OsuTextBox
                                                {
                                                    Width = 200
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Anchor section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Anchor"
                                                },
                                                alignmentDropdown = new OsuDropdown <Anchor>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Items            = (Anchor[])Enum.GetValues(typeof(Anchor))
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Horizontal margin section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Horizontal margin"
                                                },
                                                horizontalMarginSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 500,
                                                        Value    = 30,
                                                        Default  = 30
                                                    }
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Vertical margin section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Vertical margin"
                                                },
                                                verticalMarginSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 500,
                                                        Value    = 30,
                                                        Default  = 30
                                                    }
                                                }
                                            }
                                        },
                                        continuousCheckbox = new OsuCheckbox
                                        {
                                            Name      = "Continuous section",
                                            LabelText = "Continuous"
                                        },
                                        new EditSection
                                        {
                                            Name     = "Smart horizon section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Smart horizon"
                                                },
                                                smartHorizonDropdown = new OsuDropdown <KaraokeTextSmartHorizon>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Items            = (KaraokeTextSmartHorizon[])Enum.GetValues(typeof(KaraokeTextSmartHorizon))
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Lyrics interval section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Lyrics interval"
                                                },
                                                lyricIntervalSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 30,
                                                        Value    = 10,
                                                        Default  = 10
                                                    }
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Ruby interval section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Ruby interval"
                                                },
                                                rubyIntervalSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 30,
                                                        Value    = 10,
                                                        Default  = 10
                                                    }
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Romaji interval section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Romaji interval"
                                                },
                                                romajiIntervalSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 30,
                                                        Value    = 10,
                                                        Default  = 10
                                                    }
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Ruby alignment section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Ruby alignment"
                                                },
                                                rubyAlignmentDropdown = new OsuDropdown <LyricTextAlignment>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Items            = (LyricTextAlignment[])Enum.GetValues(typeof(LyricTextAlignment))
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Romaji alignment section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Romaji alignment"
                                                },
                                                romajiAlignmentDropdown = new OsuDropdown <LyricTextAlignment>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Items            = (LyricTextAlignment[])Enum.GetValues(typeof(LyricTextAlignment))
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Ruby margin section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Ruby margin"
                                                },
                                                rubyMarginSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 30,
                                                        Value    = 10,
                                                        Default  = 10
                                                    }
                                                }
                                            }
                                        },
                                        new EditSection
                                        {
                                            Name     = "Romaji margin section",
                                            Children = new Drawable[]
                                            {
                                                new OsuSpriteText {
                                                    Text = "Romaji margin"
                                                },
                                                romajiMarginSliderBar = new OsuSliderBar <int>
                                                {
                                                    RelativeSizeAxes = Axes.X,
                                                    Current          = new BindableNumber <int>
                                                    {
                                                        MinValue = 0,
                                                        MaxValue = 30,
                                                        Value    = 10,
                                                        Default  = 10
                                                    }
                                                }
                                            }
                                        },
                                    }
                                }
                            }
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                new Box
                                {
                                    Name             = "Setting background",
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.WhiteSmoke
                                },
                                layoutArea = new SkinProvidingContainer(new KaraokeLayoutEditorSkin())
                                {
                                    RelativeSizeAxes = Axes.Both,
                                }
                            }
                        }
                    }
                }
            };

            // Initial bindable
            nameTextBox.Current.BindValueChanged(x =>
            {
                /*TODO : maybe do something in the future.*/
            });
            alignmentDropdown.Current.BindValueChanged(x => applyChange(l => l.Alignment = x.NewValue));
            horizontalMarginSliderBar.Current.BindValueChanged(x => applyChange(l => l.HorizontalMargin = x.NewValue));
            verticalMarginSliderBar.Current.BindValueChanged(x => applyChange(l => l.VerticalMargin     = x.NewValue));
            continuousCheckbox.Current.BindValueChanged(x => applyChange(l => l.Continuous           = x.NewValue));
            smartHorizonDropdown.Current.BindValueChanged(x => applyChange(l => l.SmartHorizon       = x.NewValue));
            lyricIntervalSliderBar.Current.BindValueChanged(x => applyChange(l => l.LyricsInterval   = x.NewValue));
            rubyIntervalSliderBar.Current.BindValueChanged(x => applyChange(l => l.RubyInterval      = x.NewValue));
            romajiIntervalSliderBar.Current.BindValueChanged(x => applyChange(l => l.RomajiInterval  = x.NewValue));
            rubyAlignmentDropdown.Current.BindValueChanged(x => applyChange(l => l.RubyAlignment     = x.NewValue));
            romajiAlignmentDropdown.Current.BindValueChanged(x => applyChange(l => l.RomajiAlignment = x.NewValue));
            rubyMarginSliderBar.Current.BindValueChanged(x => applyChange(l => l.RubyMargin          = x.NewValue));
            romajiMarginSliderBar.Current.BindValueChanged(x => applyChange(l => l.RomajiMargin      = x.NewValue));

            AddStep("Small size lyric layout",
                    () => initialLyricLine(createDefaultLyricLine("@カラオケ",
                                                                  new[]
            {
                "@Ruby1=カ,か",
                "@Ruby2=ラ,ら",
                "@Ruby3=オ,お",
                "@Ruby4=ケ,け"
            },
                                                                  new[]
            {
                "@Romaji1=カ,ka",
                "@Romaji2=ラ,ra",
                "@Romaji3=オ,o",
                "@Romaji4=ケ,ke"
            }
                                                                  , "karaoke")));
            AddStep("Medium size lyric layout",
                    () => initialLyricLine(createDefaultLyricLine("@[00:18:58]た[00:18:81]だ[00:19:36]風[00:20:09]に[00:20:29]揺[00:20:49]ら[00:20:68]れ[00:20:89]て[00:20:93]",
                                                                  new[]
            {
                "@Ruby1=風,かぜ",
                "@Ruby2=揺,ゆ"
            },
                                                                  new[]
            {
                "@Romaji1=た,ta",
                "@Romaji2=だ,da",
                "@Romaji3=風,kaze",
                "@Romaji4=に,ni",
                "@Romaji5=揺,yu",
                "@Romaji6=ら,ra",
                "@Romaji7=れ,re",
                "@Romaji8=て,te"
            }
                                                                  , "karaoke")));
            AddStep("Large size lyric layout", () => initialLyricLine(createDefaultLyricLine("@灰色(いろ)(いろ)の景色(いろ)(いろ)さえ色づき始める",
                                                                                             Array.Empty <string>(), Array.Empty <string>(), "karaoke")));
        }