Skip to content

Commit

Permalink
Merge pull request #225 from andy840119/meow/create-style-editor-righ…
Browse files Browse the repository at this point in the history
…t-side

Implement style editor right side
  • Loading branch information
andy840119 authored Oct 31, 2020
2 parents 83e5428 + 049df87 commit 8f0ef74
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
28 changes: 28 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Style/StyleManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
// 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.Game.Rulesets.Karaoke.Skinning.Components;
using osu.Game.Skinning;
using System;

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
public class StyleManager : Component
{
public readonly Bindable<KaraokeFont> EditStyle = new Bindable<KaraokeFont>();

public readonly Bindable<NoteSkin> EditNoteStyle = new Bindable<NoteSkin>();

[Resolved]
private ISkinSource source { get; set; }

[BackgroundDependencyLoader]
private void load()
{
}

public void ApplyCurrentStyleChange(Action<KaraokeFont> action)
{
action?.Invoke(EditStyle.Value);
EditStyle.TriggerChange();
}

public void ApplyCurrentNoteStyle(Action<NoteSkin> action)
{
action?.Invoke(EditNoteStyle.Value);
EditNoteStyle.TriggerChange();
}
}
}
101 changes: 101 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Style/StylePreview.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,112 @@
// 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.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Objects.Drawables;
using osu.Game.Rulesets.Karaoke.Skinning.Components;
using System.Collections.Generic;

namespace osu.Game.Rulesets.Karaoke.Edit.Style
{
internal class StylePreview : Container
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, StyleManager manager)
{
Masking = true;
CornerRadius = 15;
FillMode = FillMode.Fit;
FillAspectRatio = 1.25f;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background1,
},
new PreviewDrawableLyricLine(createDefaultLyricLine())
};
}

private Lyric createDefaultLyricLine()
{
var startTime = Time.Current;
const double duration = 1000000;

return new Lyric
{
StartTime = startTime,
Duration = duration,
Text = "カラオケ!",
TimeTags = new Dictionary<TimeTagIndex, double>
{
{ new TimeTagIndex(0), startTime + 500 },
{ new TimeTagIndex(1), startTime + 600 },
{ new TimeTagIndex(2), startTime + 1000 },
{ new TimeTagIndex(3), startTime + 1500 },
{ new TimeTagIndex(4), startTime + 2000 },
},
RubyTags = new[]
{
new RubyTag
{
StartIndex = 0,
EndIndex = 1,
Text = "か"
},
new RubyTag
{
StartIndex = 2,
EndIndex = 3,
Text = "お"
}
},
RomajiTags = new[]
{
new RomajiTag
{
StartIndex = 1,
EndIndex = 2,
Text = "ra"
},
new RomajiTag
{
StartIndex = 3,
EndIndex = 4,
Text = "ke"
}
}
};
}

public class PreviewDrawableLyricLine : DrawableLyric
{
private KaraokeFont style;

public PreviewDrawableLyricLine(Lyric hitObject)
: base(hitObject)
{
}

/// <summary>
/// It's an tricky to force add style into here.
/// Should be removed eventually.
/// </summary>
public KaraokeFont PreviewStyle
{
get => style;
set
{
style = value;
ApplyFont(style);
}
}
}
}
}

0 comments on commit 8f0ef74

Please sign in to comment.