Skip to content

Commit

Permalink
Merge pull request #233 from andy840119/andy840119/note-style-editor
Browse files Browse the repository at this point in the history
Implement note style editor
  • Loading branch information
andy840119 authored Oct 31, 2020
2 parents 8f0ef74 + 866e348 commit 13f664d
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class ColorSection : StyleSection
internal class LyricColorSection : StyleSection
{
private LabelledDropdown<ColorArea> colorAreaDropdown;
private LabelledDropdown<BrushType> brushTypeDropdown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class FontSection : StyleSection
internal class LyricFontSection : StyleSection
{
private LabelledDropdown<Font> fontDropdown;
private LabelledSwitchButton boldSwitchButton;
Expand Down Expand Up @@ -49,7 +49,7 @@ private void load(SkinManager manager)
},
borderSliderBar = new LabelledRealTimeSliderBar<int>
{
Label = "Bold",
Label = "Border size",
Description = "Adjust border size.",
Current = new BindableInt
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class ShadowSection : StyleSection
internal class LyricShadowSection : StyleSection
{
private LabelledSwitchButton displayShaderSwitchButton;
private LabelledRealTimeSliderBar<float> shadowXSliderBar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class StylePreview : Container
internal class LyricStylePreview : Container
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, StyleManager manager)
Expand Down
34 changes: 34 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Style/NoteColorSection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Karaoke.Graphics.UserInterface;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class NoteColorSection : StyleSection
{
private ColorPicker noteColorPicker;
private ColorPicker blinkColorPicker;

protected override string Title => "Color";

[BackgroundDependencyLoader]
private void load(SkinManager manager)
{
Children = new Drawable[]
{
noteColorPicker = new ColorPicker
{
RelativeSizeAxes = Axes.X,
},
blinkColorPicker = new ColorPicker
{
RelativeSizeAxes = Axes.X,
}
};
}
}
}
36 changes: 36 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Style/NoteFontSection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Rulesets.Karaoke.Graphics.UserInterface;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class NoteFontSection : StyleSection
{
private ColorPicker textColorPicker;
private LabelledSwitchButton boldSwitchButton;

protected override string Title => "Font";

[BackgroundDependencyLoader]
private void load(SkinManager manager)
{
Children = new Drawable[]
{
textColorPicker = new ColorPicker
{
RelativeSizeAxes = Axes.X,
},
boldSwitchButton = new LabelledSwitchButton
{
Label = "Bold",
Description = "Select bold or not.",
}
};
}
}
}
98 changes: 98 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Style/NoteStylePreview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Configuration;
using osu.Game.Rulesets.Karaoke.UI;
using osu.Game.Rulesets.Karaoke.UI.Position;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.UI.Scrolling.Algorithms;

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
public class NoteStylePreview : Container
{
private const int preview_column = 9;

[Cached(Type = typeof(IScrollingInfo))]
private readonly PreviewScrollingInfo scrollingInfo = new PreviewScrollingInfo();

[Cached(Type = typeof(IPositionCalculator))]
private readonly PositionCalculator positionCalculator = new PositionCalculator(preview_column);

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var configCache = parent.Get<RulesetConfigCache>();
var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(new KaraokeRuleset());
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.Cache(new KaraokeSessionStatics(config, null));

return dependencies;
}

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, StyleManager manager)
{
Masking = true;
CornerRadius = 15;
FillMode = FillMode.Fit;
FillAspectRatio = 2f;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background1,
},
new PreviewDrawableNoteArea
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
};
}

public class PreviewDrawableNoteArea : NotePlayfield
{
public PreviewDrawableNoteArea()
: base(preview_column)
{
}
}

public class PreviewScrollingInfo : IScrollingInfo
{
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>();

public IBindable<double> TimeRange { get; } = new BindableDouble();

public IScrollAlgorithm Algorithm { get; set; } = new ZeroScrollAlgorithm();

private class ZeroScrollAlgorithm : IScrollAlgorithm
{
protected const double START_TIME = 1000000000;

public double GetDisplayStartTime(double originTime, float offset, double timeRange, float scrollLength)
=> double.MinValue;

public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
=> scrollLength;

public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
=> (float)((time - START_TIME) / timeRange) * scrollLength;

public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)
=> 0;

public void Reset()
{
}
}
}
}
}
135 changes: 110 additions & 25 deletions osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Screens.Edit;
using osuTK;
Expand All @@ -14,14 +16,15 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
public class StyleScreen : EditorScreen
{
private const float section_scale = 0.75f;

[Cached]
protected readonly OverlayColourProvider ColourProvider;

[Cached]
protected readonly StyleManager StyleManager;

private StyleSectionsContainer styleSections;
private Container previewContainer;

public StyleScreen()
: base(EditorScreenMode.SongSetup)
{
Expand Down Expand Up @@ -58,47 +61,129 @@ private void load()
Colour = ColourProvider.Background2,
RelativeSizeAxes = Axes.Both,
},
new SectionsContainer<StyleSection>
styleSections = new StyleSectionsContainer
{
FixedHeader = new StyleScreenHeader(),
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(section_scale),
Size = new Vector2(1 / section_scale),
Children = new StyleSection[]
{
new ColorSection(),
new FontSection(),
new ShadowSection(),
}
}
}
},
new StylePreview
previewContainer = new Container
{
RelativeSizeAxes = Axes.Both,
}
}
},
};

styleSections.BindableStyle.BindValueChanged(e =>
{
switch (e.NewValue)
{
case Style.Lyric:
previewContainer.Child = new LyricStylePreview
{
Name = "Layout preview area",
Name = "Lyric style preview area",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.95f),
RelativeSizeAxes = Axes.Both
},
}
},
};
};
break;

case Style.Note:
previewContainer.Child = new NoteStylePreview
{
Name = "Note style preview area",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.95f),
RelativeSizeAxes = Axes.Both
};
break;
};
}, true);
}

internal class StyleScreenHeader : OverlayHeader
internal class StyleSectionsContainer : SectionsContainer<StyleSection>
{
protected override OverlayTitle CreateTitle() => new LayoutScreenTitle();
private readonly StyleScreenHeader header;

private const float section_scale = 0.75f;

private class LayoutScreenTitle : OverlayTitle
public IBindable<Style> BindableStyle => header.BindableStyle;

public StyleSectionsContainer()
{
public LayoutScreenTitle()
FixedHeader = header = new StyleScreenHeader();

Scale = new Vector2(section_scale);
Size = new Vector2(1 / section_scale);

header.BindableStyle.BindValueChanged(e =>
{
switch (e.NewValue)
{
case Style.Lyric:
Children = new StyleSection[]
{
new LyricColorSection(),
new LyricFontSection(),
new LyricShadowSection(),
};
break;
case Style.Note:
Children = new StyleSection[]
{
new NoteColorSection(),
new NoteFontSection(),
};
break;
}
}, true);
}

internal class StyleScreenHeader : OverlayHeader
{
public Bindable<Style> BindableStyle = new Bindable<Style>();

protected override OverlayTitle CreateTitle() => new LayoutScreenTitle();

protected override Drawable CreateTitleContent()
{
Title = "style";
Description = "create style of your beatmap";
IconTexture = "Icons/Hexacons/social";
return new Container
{
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Left = 100 },
Height = 40,
Child = new OsuEnumDropdown<Style>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
Current = BindableStyle,
}
};
}

private class LayoutScreenTitle : OverlayTitle
{
public LayoutScreenTitle()
{
Title = "style";
Description = "create style of your beatmap";
IconTexture = "Icons/Hexacons/social";
}
}
}
}
}

public enum Style
{
[System.ComponentModel.Description("Lyric")]
Lyric,

[System.ComponentModel.Description("Note")]
Note
}
}

0 comments on commit 13f664d

Please sign in to comment.