-
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 #2112 from andy840119/should-be-able-to-record-rub…
…y-edit-type Should be able to drag the main lyric text to generate the ruby/romaji text.
- Loading branch information
Showing
14 changed files
with
261 additions
and
11 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
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
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
130 changes: 130 additions & 0 deletions
130
...reens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaretPosition.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,130 @@ | ||
// 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.Primitives; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Logging; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
using osu.Game.Rulesets.Karaoke.Objects; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.CaretPosition; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Carets; | ||
|
||
public partial class DrawableCreateRubyTagCaretPosition : DrawableRangeCaret<CreateRubyTagCaretPosition> | ||
{ | ||
private const float border_spacing = 5; | ||
private const float caret_move_time = 60; | ||
private const float caret_resize_time = 60; | ||
|
||
[Resolved] | ||
private ILyricRubyTagsChangeHandler lyricRubyTagsChangeHandler { get; set; } = null!; | ||
|
||
[Resolved] | ||
private ILyricCaretState lyricCaretState { get; set; } = null!; | ||
|
||
private readonly IconButton icon; | ||
|
||
public DrawableCreateRubyTagCaretPosition(DrawableCaretType type) | ||
: base(type) | ||
{ | ||
InternalChildren = new Drawable[] | ||
{ | ||
new Container | ||
{ | ||
Masking = true, | ||
BorderThickness = border_spacing, | ||
BorderColour = Colour4.White, | ||
RelativeSizeAxes = Axes.Both, | ||
Alpha = GetAlpha(type), | ||
Child = new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = Colour4.White, | ||
Alpha = 0.1f, | ||
}, | ||
}, | ||
icon = new IconButton | ||
{ | ||
Anchor = Anchor.TopRight, | ||
Origin = Anchor.BottomLeft, | ||
Icon = FontAwesome.Solid.PlusCircle, | ||
Size = new Vector2(15), | ||
Alpha = GetAlpha(type), | ||
}, | ||
}; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours) | ||
{ | ||
icon.IconColour = colours.Green; | ||
icon.IconHoverColour = colours.GreenLight; | ||
} | ||
|
||
protected override void ApplyCaretPosition(CreateRubyTagCaretPosition caret) | ||
{ | ||
// should not show the hover caret if already contains the selected range. | ||
if (Type == DrawableCaretType.HoverCaret && lyricCaretState.CaretPosition?.Lyric == caret.Lyric) | ||
{ | ||
Hide(); | ||
return; | ||
} | ||
|
||
var rect = LyricPositionProvider.GetRectByCharIndex(caret.CharIndex); | ||
changeTheSizeByRect(rect); | ||
|
||
icon.Action = () => | ||
{ | ||
lyricRubyTagsChangeHandler.Add(new RubyTag | ||
{ | ||
StartIndex = caret.CharIndex, | ||
EndIndex = caret.CharIndex, | ||
Text = "Ruby", | ||
}); | ||
}; | ||
} | ||
|
||
protected override void ApplyRangeCaretPosition(RangeCaretPosition<CreateRubyTagCaretPosition> caret) | ||
{ | ||
int minIndex = caret.GetRangeCaretPosition().Item1.CharIndex; | ||
int maxIndex = caret.GetRangeCaretPosition().Item2.CharIndex; | ||
|
||
Logger.Log($"{minIndex}, {maxIndex}"); | ||
|
||
var rect = RectangleF.Union(LyricPositionProvider.GetRectByCharIndex(minIndex), LyricPositionProvider.GetRectByCharIndex(maxIndex)); | ||
changeTheSizeByRect(rect); | ||
|
||
icon.Action = () => | ||
{ | ||
lyricRubyTagsChangeHandler.Add(new RubyTag | ||
{ | ||
StartIndex = minIndex, | ||
EndIndex = maxIndex, | ||
Text = "Ruby", | ||
}); | ||
}; | ||
} | ||
|
||
private void changeTheSizeByRect(RectangleF rect) | ||
{ | ||
var position = rect.TopLeft - new Vector2(border_spacing); | ||
float width = rect.Width + border_spacing * 2; | ||
|
||
this.MoveTo(position, caret_move_time, Easing.Out); | ||
this.ResizeWidthTo(width, caret_resize_time, Easing.Out); | ||
Height = rect.Height + border_spacing * 2; | ||
} | ||
|
||
protected override void TriggerDisallowEditEffect(OsuColour colour) | ||
{ | ||
this.FlashColour(colour.Red, 200); | ||
} | ||
} |
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
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
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
26 changes: 26 additions & 0 deletions
26
...sets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagConfigToolSection.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,26 @@ | ||
// 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.Localisation; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; | ||
|
||
public partial class RubyTagConfigToolSection : EditorSection | ||
{ | ||
protected override LocalisableString Title => "Config Tool"; | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(IEditRubyModeState editRubyModeState) | ||
{ | ||
Children = new Drawable[] | ||
{ | ||
new RubyTagEditModeSubsection() | ||
{ | ||
Current = editRubyModeState.BindableRubyTagEditMode, | ||
}, | ||
}; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/RubyRomaji/RubyTagEditModeSubsection.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,38 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Localisation; | ||
using osu.Game.Graphics; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.States.Modes; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Components.Markdown; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Settings.RubyRomaji; | ||
|
||
public partial class RubyTagEditModeSubsection : EditModeSwitchSubsection<RubyTagEditMode> | ||
{ | ||
protected override LocalisableString GetButtonTitle(RubyTagEditMode mode) | ||
=> mode switch | ||
{ | ||
RubyTagEditMode.Create => "Create", | ||
RubyTagEditMode.Modify => "Modify", | ||
_ => throw new InvalidOperationException(nameof(mode)), | ||
}; | ||
|
||
protected override Color4 GetButtonColour(OsuColour colours, RubyTagEditMode mode, bool active) | ||
=> mode switch | ||
{ | ||
RubyTagEditMode.Create => active ? colours.Green : colours.GreenDarker, | ||
RubyTagEditMode.Modify => active ? colours.Pink : colours.PinkDarker, | ||
_ => throw new InvalidOperationException(nameof(mode)), | ||
}; | ||
|
||
protected override DescriptionFormat GetDescription(RubyTagEditMode mode) => | ||
mode switch | ||
{ | ||
RubyTagEditMode.Create => "Use mouse to select range of the lyric text to create the ruby tag.", | ||
RubyTagEditMode.Modify => "Select ruby to change the start/end position or delete it.", | ||
_ => throw new InvalidOperationException(nameof(mode)), | ||
}; | ||
} |
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
Oops, something went wrong.