Skip to content

Commit

Permalink
Merge pull request #2115 from andy840119/implement-create-ruby-caret
Browse files Browse the repository at this point in the history
Refactor the drawable caret.
  • Loading branch information
andy840119 authored Sep 5, 2023
2 parents 62b8ae5 + ed65e09 commit 16f4ac0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override RomajiTag ReadJson(JsonReader reader, Type objectType, RomajiTag
if (string.IsNullOrEmpty(value))
return new RomajiTag();

var regex = new Regex("\\[(?<start>[-0-9]+)(?:,(?<end>[-0-9]+))?\\]:(?<romaji>.*$)");
var regex = new Regex(@"\[(?<start>[-0-9]+)(?:,(?<end>[-0-9]+))?\]:(?<romaji>.*$)");
var result = regex.Match(value);
if (!result.Success)
return new RomajiTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override RubyTag ReadJson(JsonReader reader, Type objectType, RubyTag? ex
if (string.IsNullOrEmpty(value))
return new RubyTag();

var regex = new Regex("\\[(?<start>[-0-9]+)(?:,(?<end>[-0-9]+))?\\]:(?<ruby>.*$)");
var regex = new Regex(@"\[(?<start>[-0-9]+)(?:,(?<end>[-0-9]+))?\]:(?<ruby>.*$)");
var result = regex.Match(value);
if (!result.Success)
return new RubyTag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void updateDrawableCaret(ICaretPosition? position, DrawableCaretType typ
// typing
TypingCaretPosition => new DrawableTypingCaret(type),
// creat ruby-tag
CreateRubyTagCaretPosition => new DrawableCreateRubyTagCaretPosition(type),
CreateRubyTagCaretPosition => new DrawableCreateRubyTagCaret(type),
// creat time-tag
TimeTagIndexCaretPosition => new DrawableTimeTagIndexCaret(type),
// record time-tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;
Expand All @@ -18,7 +17,7 @@

namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Components.Lyrics.Carets;

public partial class DrawableCreateRubyTagCaretPosition : DrawableRangeCaret<CreateRubyTagCaretPosition>
public partial class DrawableCreateRubyTagCaret : DrawableRangeCaret<CreateRubyTagCaretPosition>
{
private const float border_spacing = 5;
private const float caret_move_time = 60;
Expand All @@ -32,7 +31,7 @@ public partial class DrawableCreateRubyTagCaretPosition : DrawableRangeCaret<Cre

private readonly IconButton icon;

public DrawableCreateRubyTagCaretPosition(DrawableCaretType type)
public DrawableCreateRubyTagCaret(DrawableCaretType type)
: base(type)
{
InternalChildren = new Drawable[]
Expand Down Expand Up @@ -97,8 +96,6 @@ protected override void ApplyRangeCaretPosition(RangeCaretPosition<CreateRubyTag
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);

Expand Down

0 comments on commit 16f4ac0

Please sign in to comment.