-
Notifications
You must be signed in to change notification settings - Fork 15
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 #1665 from andy840119/add-button-to-set-time-tag-t…
…ime-im-composer Add button to set and clear the time tag time in the composer.
- Loading branch information
Showing
9 changed files
with
156 additions
and
5 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
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
osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/Toolbar/TimeTags/ClearAllTimeTagTimeButton.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 System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Compose.Toolbar.TimeTags | ||
{ | ||
public class ClearAllTimeTagTimeButton : ActionButton | ||
{ | ||
[Resolved, AllowNull] | ||
private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } | ||
|
||
public ClearAllTimeTagTimeButton() | ||
{ | ||
SetIcon(FontAwesome.Solid.Redo); | ||
|
||
Action = () => | ||
{ | ||
lyricTimeTagsChangeHandler.ClearAllTimeTagTime(); | ||
}; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/Toolbar/TimeTags/ClearTimeTagTimeButton.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 System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.States; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Compose.Toolbar.TimeTags | ||
{ | ||
public class ClearTimeTagTimeButton : KeyActionButton | ||
{ | ||
protected override KaraokeEditAction EditAction => KaraokeEditAction.ClearTime; | ||
|
||
[Resolved, AllowNull] | ||
private ILyricCaretState lyricCaretState { get; set; } | ||
|
||
[Resolved, AllowNull] | ||
private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } | ||
|
||
public ClearTimeTagTimeButton() | ||
{ | ||
SetIcon(FontAwesome.Solid.Eraser); | ||
|
||
Action = () => | ||
{ | ||
if (lyricCaretState.BindableCaretPosition.Value is not TimeTagCaretPosition timeTagCaretPosition) | ||
throw new InvalidOperationException(); | ||
|
||
var timeTag = timeTagCaretPosition.TimeTag; | ||
lyricTimeTagsChangeHandler.ClearTimeTagTime(timeTag); | ||
}; | ||
} | ||
} | ||
} |
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,13 +1,13 @@ | ||
// 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 System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.States; | ||
using TagLib; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Compose.Toolbar.TimeTags | ||
{ | ||
|
@@ -28,7 +28,7 @@ public CreateTimeTagButton() | |
Action = () => | ||
{ | ||
if (lyricCaretState.BindableCaretPosition.Value is not TimeTagIndexCaretPosition timeTagIndexCaretPosition) | ||
throw new UnsupportedFormatException(); | ||
throw new InvalidOperationException(); | ||
|
||
var index = timeTagIndexCaretPosition.Index; | ||
lyricTimeTagsChangeHandler.AddByPosition(index); | ||
|
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,13 +1,13 @@ | ||
// 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 System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.States; | ||
using TagLib; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Compose.Toolbar.TimeTags | ||
{ | ||
|
@@ -28,7 +28,7 @@ public RemoveTimeTagButton() | |
Action = () => | ||
{ | ||
if (lyricCaretState.BindableCaretPosition.Value is not TimeTagIndexCaretPosition timeTagIndexCaretPosition) | ||
throw new UnsupportedFormatException(); | ||
throw new InvalidOperationException(); | ||
|
||
var index = timeTagIndexCaretPosition.Index; | ||
lyricTimeTagsChangeHandler.RemoveByPosition(index); | ||
|
43 changes: 43 additions & 0 deletions
43
osu.Game.Rulesets.Karaoke/Edit/Lyrics/Compose/Toolbar/TimeTags/SetTimeTagTimeButton.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,43 @@ | ||
// 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 System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Lyrics; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; | ||
using osu.Game.Rulesets.Karaoke.Edit.Lyrics.States; | ||
using osu.Game.Screens.Edit; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.Compose.Toolbar.TimeTags | ||
{ | ||
public class SetTimeTagTimeButton : KeyActionButton | ||
{ | ||
protected override KaraokeEditAction EditAction => KaraokeEditAction.SetTime; | ||
|
||
[Resolved, AllowNull] | ||
private ILyricCaretState lyricCaretState { get; set; } | ||
|
||
[Resolved, AllowNull] | ||
private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } | ||
|
||
[Resolved, AllowNull] | ||
private EditorClock editorClock { get; set; } | ||
|
||
public SetTimeTagTimeButton() | ||
{ | ||
SetIcon(FontAwesome.Solid.Stopwatch); | ||
|
||
Action = () => | ||
{ | ||
if (lyricCaretState.BindableCaretPosition.Value is not TimeTagCaretPosition timeTagCaretPosition) | ||
throw new InvalidOperationException(); | ||
|
||
var timeTag = timeTagCaretPosition.TimeTag; | ||
double currentTime = editorClock.CurrentTime; | ||
lyricTimeTagsChangeHandler.SetTimeTagTime(timeTag, currentTime); | ||
}; | ||
} | ||
} | ||
} |