-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from andy840119/meow/create-style-editor-righ…
…t-side Implement style editor right side
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} |