-
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 #234 from andy840119/andy840119/implement-singer-e…
…ditor Implement singer editor
- Loading branch information
Showing
11 changed files
with
582 additions
and
230 deletions.
There are no files selected for viewing
258 changes: 55 additions & 203 deletions
258
osu.Game.Rulesets.Karaoke.Tests/Edit/TestSceneSinger.cs
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,236 +1,88 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Extensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; | ||
using osu.Game.Rulesets.Edit; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Edit.Singers; | ||
using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; | ||
using osu.Game.Screens.Edit; | ||
using osu.Game.Tests.Visual; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Edit | ||
{ | ||
[TestFixture] | ||
public class TestSceneSinger : OsuTestScene | ||
public class TestSceneSinger : OsuManualInputManagerTestScene | ||
{ | ||
private readonly Box background; | ||
private readonly SingerTableContainer singerTableContainer; | ||
private readonly SingerInfoContainer singerInfoContainer; | ||
[Cached(typeof(EditorBeatmap))] | ||
[Cached(typeof(IBeatSnapProvider))] | ||
private readonly EditorBeatmap editorBeatmap; | ||
|
||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both }; | ||
|
||
public TestSceneSinger() | ||
{ | ||
Child = new Container | ||
var beatmap = new TestKaraokeBeatmap(null); | ||
var karaokeBeatmap = new KaraokeBeatmapConverter(beatmap, new KaraokeRuleset()).Convert() as KaraokeBeatmap; | ||
// todo : insert singers | ||
karaokeBeatmap.SingerMetadata.CreateSinger(singer => | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Width = 700, | ||
Height = 500, | ||
Masking = true, | ||
CornerRadius = 5, | ||
Children = new Drawable[] | ||
{ | ||
background = new Box | ||
{ | ||
Name = "Background", | ||
RelativeSizeAxes = Axes.Both | ||
}, | ||
new GridContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
ColumnDimensions = new[] | ||
{ | ||
new Dimension(GridSizeMode.Absolute, 300) | ||
}, | ||
Content = new[] | ||
{ | ||
new Drawable[] | ||
{ | ||
new OsuScrollContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Child = singerTableContainer = new SingerTableContainer() | ||
}, | ||
new OsuScrollContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Child = singerInfoContainer = new SingerInfoContainer | ||
{ | ||
RelativeSizeAxes = Axes.X | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
// todo : add singer. | ||
var singerMetadata = new SingerMetadata(); | ||
singerTableContainer.Metadata = singerMetadata; | ||
|
||
singerTableContainer.BindableSinger.BindValueChanged(x => | ||
singer.Name = "初音ミク"; | ||
singer.RomajiName = "Hatsune Miku"; | ||
singer.EnglishName = "Miku"; | ||
singer.Description = "International superstar vocaloid Hatsune Miku."; | ||
singer.Color = Colour4.AliceBlue; | ||
}); | ||
karaokeBeatmap.SingerMetadata.CreateSinger(singer => | ||
{ | ||
// Update singer info | ||
singerInfoContainer.Singer = x.NewValue; | ||
singer.Name = "ハク"; | ||
singer.RomajiName = "haku"; | ||
singer.EnglishName = "andy840119"; | ||
singer.Description = "Creator of this ruleset."; | ||
singer.Color = Colour4.Yellow; | ||
}); | ||
karaokeBeatmap.SingerMetadata.CreateSinger(singer => | ||
{ | ||
singer.Name = "ゴミパソコン"; | ||
singer.RomajiName = "gomi-pasokonn"; | ||
singer.EnglishName = "garbage desktop"; | ||
singer.Description = "My fucking slow desktop."; | ||
singer.Color = Colour4.Brown; | ||
}); | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours) | ||
{ | ||
background.Colour = colours.Gray9; | ||
editorBeatmap = new EditorBeatmap(karaokeBeatmap); | ||
} | ||
|
||
public class SingerTableContainer : TableContainer | ||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
private const float horizontal_inset = 20; | ||
private const float row_height = 10; | ||
|
||
public Bindable<Singer> BindableSinger { get; } = new Bindable<Singer>(); | ||
|
||
private readonly FillFlowContainer backgroundFlow; | ||
|
||
public SingerTableContainer() | ||
{ | ||
RelativeSizeAxes = Axes.X; | ||
AutoSizeAxes = Axes.Y; | ||
|
||
Padding = new MarginPadding { Horizontal = horizontal_inset }; | ||
RowSize = new Dimension(GridSizeMode.AutoSize); | ||
|
||
AddInternal(backgroundFlow = new FillFlowContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Depth = 1f, | ||
Padding = new MarginPadding { Horizontal = -horizontal_inset }, | ||
Margin = new MarginPadding { Top = row_height } | ||
}); | ||
} | ||
|
||
private SingerMetadata metadata; | ||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); | ||
|
||
public SingerMetadata Metadata | ||
var beatDivisor = new BindableBeatDivisor | ||
{ | ||
get => metadata; | ||
set | ||
{ | ||
metadata = value; | ||
|
||
Content = null; | ||
backgroundFlow.Clear(); | ||
|
||
var signer = Metadata.Singers; | ||
if (signer?.Any() != true) | ||
return; | ||
|
||
Columns = createHeaders(); | ||
Content = signer.Select(s => createContent(s.ID, s)).ToArray().ToRectangular(); | ||
|
||
// All the singer is not selected | ||
BindableSinger.Value = signer.FirstOrDefault(); | ||
} | ||
} | ||
|
||
private TableColumn[] createHeaders() | ||
{ | ||
var columns = new List<TableColumn> | ||
{ | ||
new TableColumn("Selected", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), | ||
new TableColumn("Singer name", Anchor.Centre), | ||
}; | ||
|
||
return columns.ToArray(); | ||
} | ||
Value = Beatmap.Value.BeatmapInfo.BeatDivisor | ||
}; | ||
var editorClock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false }; | ||
Dependencies.CacheAs(editorClock); | ||
|
||
private Drawable[] createContent(int index, Singer singer) | ||
{ | ||
return new Drawable[] | ||
{ | ||
new OsuSpriteText | ||
{ | ||
Text = $"# {index}" | ||
}, | ||
new OsuSpriteText | ||
{ | ||
Text = singer.Name | ||
}, | ||
}; | ||
} | ||
base.Content.Add(Content); | ||
} | ||
|
||
public class SingerInfoContainer : TableContainer | ||
[SetUp] | ||
public void SetUp() => Schedule(() => | ||
{ | ||
private readonly OsuTextBox nameTextBox; | ||
private readonly OsuTextBox englishNameTextBox; | ||
private readonly OsuTextBox romajiNameTextBox; | ||
Child = new SingerScreen(); | ||
}); | ||
|
||
public SingerInfoContainer() | ||
{ | ||
AutoSizeAxes = Axes.Y; | ||
RowSize = new Dimension(GridSizeMode.AutoSize); | ||
Content = new Drawable[,] | ||
{ | ||
{ | ||
new OsuSpriteText | ||
{ | ||
Text = "Singer name :" | ||
}, | ||
nameTextBox = new OsuTextBox | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
} | ||
}, | ||
{ | ||
new OsuSpriteText | ||
{ | ||
Text = "English name :" | ||
}, | ||
englishNameTextBox = new OsuTextBox | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
} | ||
}, | ||
{ | ||
new OsuSpriteText | ||
{ | ||
Text = "Romaji name :" | ||
}, | ||
romajiNameTextBox = new OsuTextBox | ||
{ | ||
RelativeSizeAxes = Axes.X, | ||
} | ||
}, | ||
}; | ||
|
||
nameTextBox.Current.BindValueChanged(x => { Singer.Name = x.NewValue; }); | ||
|
||
englishNameTextBox.Current.BindValueChanged(x => { Singer.EnglishName = x.NewValue; }); | ||
|
||
romajiNameTextBox.Current.BindValueChanged(x => { Singer.RomajiName = x.NewValue; }); | ||
} | ||
|
||
private Singer singer; | ||
|
||
public Singer Singer | ||
{ | ||
get => singer; | ||
set | ||
{ | ||
singer = value; | ||
nameTextBox.Text = singer.Name; | ||
englishNameTextBox.Text = singer.EnglishName; | ||
romajiNameTextBox.Text = singer.RomajiName; | ||
} | ||
} | ||
[Test] | ||
public void HoverToSingerArea() | ||
{ | ||
// todo : add this step because description is not showing. | ||
AddStep("Move mouse to singer area", () => InputManager.MoveMouseTo(Child, new Vector2(-400,-100))); | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
osu.Game.Rulesets.Karaoke/Edit/Singers/Components/DefaultLyricPlacementColumn.cs
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps.Metadatas; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Singers.Components | ||
{ | ||
public class DefaultLyricPlacementColumn : LyricPlacementColumn | ||
{ | ||
public DefaultLyricPlacementColumn() | ||
: base(new Singer(-1) { Name = "Default" }) | ||
{ | ||
} | ||
|
||
protected override float SingerInfoSize => 200; | ||
|
||
// todo : might display song info? | ||
protected override Drawable CreateSingerInfo(Singer singer) => new Container(); | ||
} | ||
} |
Oops, something went wrong.