@@ -45,6 +45,7 @@ import funkin.play.notes.notekind.NoteKindManager;
4545import funkin .play .character .BaseCharacter .CharacterType ;
4646import funkin .data .character .CharacterData .CharacterDataParser ;
4747import funkin .play .components .HealthIcon ;
48+ import funkin .play .components .Subtitles ;
4849import funkin .play .notes .NoteSprite ;
4950import funkin .play .PlayStatePlaylist ;
5051import funkin .play .song .Song ;
@@ -640,6 +641,23 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
640641 */
641642 var showNoteKindIndicators : Bool = false ;
642643
644+ /**
645+ * Toggles the subtitles.
646+ */
647+ var showSubtitles (default , set ): Bool = false ;
648+
649+ function set_showSubtitles (value : Bool ): Bool
650+ {
651+ showSubtitles = value ;
652+
653+ if (subtitles != null )
654+ {
655+ subtitles .exists = showSubtitles ;
656+ }
657+
658+ return showSubtitles ;
659+ }
660+
643661 /**
644662 * The current theme used by the editor.
645663 * Dictates the appearance of many UI elements.
@@ -1915,6 +1933,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
19151933 */
19161934 var menubarItemViewIndicators : MenuCheckBox ;
19171935
1936+ /**
1937+ * The `View -> Subtitles` menu item.
1938+ */
1939+ var menubarItemViewSubtitles : MenuCheckBox ;
1940+
19181941 /**
19191942 * The `View -> Increase Difficulty` menu item.
19201943 */
@@ -2226,6 +2249,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
22262249 */
22272250 var menuBG : Null <FlxSprite > = null ;
22282251
2252+ /**
2253+ * The subtitles to display song's lyrics.
2254+ */
2255+ var subtitles : Null <Subtitles > = null ;
2256+
22292257 /**
22302258 * The sprite group containing the note graphics.
22312259 * Only displays a subset of the data from `currentSongChartNoteData`,
@@ -2338,6 +2366,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
23382366 populateOpenRecentMenu ();
23392367 this .applyPlatformShortcutText ();
23402368
2369+ createSubtitles ();
2370+
23412371 // Setup the onClick listeners for the UI after it's been created.
23422372 setupUIListeners ();
23432373 setupContextMenu ();
@@ -2435,6 +2465,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
24352465 currentLiveInputStyle = save .chartEditorLiveInputStyle ;
24362466 isViewDownscroll = save .chartEditorDownscroll ;
24372467 showNoteKindIndicators = save .chartEditorShowNoteKinds ;
2468+ showSubtitles = save .chartEditorShowSubtitles ;
24382469 playtestStartTime = save .chartEditorPlaytestStartTime ;
24392470 currentTheme = save .chartEditorTheme ;
24402471 metronomeVolume = save .chartEditorMetronomeVolume ;
@@ -2654,6 +2685,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
26542685 add (audioWaveforms );
26552686 }
26562687
2688+ function createSubtitles (): Void
2689+ {
2690+ subtitles = new Subtitles (FlxG .height * 0.85 );
2691+ subtitles .zIndex = 100 ;
2692+ subtitles .cameras = [uiCamera ];
2693+ add (subtitles );
2694+ }
2695+
26572696 function buildMeasureTicks (): Void
26582697 {
26592698 measureTicks = new ChartEditorMeasureTicks (this );
@@ -3179,6 +3218,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
31793218 menubarItemViewIndicators .onClick = event -> showNoteKindIndicators = menubarItemViewIndicators .selected ;
31803219 menubarItemViewIndicators .selected = showNoteKindIndicators ;
31813220
3221+ menubarItemViewSubtitles .onClick = event -> showSubtitles = menubarItemViewSubtitles .selected ;
3222+ menubarItemViewSubtitles .selected = showSubtitles ;
3223+
31823224 menubarItemDifficultyUp .onClick = _ -> incrementDifficulty (1 );
31833225 menubarItemDifficultyDown .onClick = _ -> incrementDifficulty (- 1 );
31843226
@@ -6866,6 +6908,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
68666908 healthIconsDirty = true ;
68676909 }
68686910
6911+ public function loadSubtitles (): Void
6912+ {
6913+ var subtitlesFile : String = ' songs/ ${currentSongId }/subtitles/song-lyrics' ;
6914+ if (selectedVariation != Constants .DEFAULT_VARIATION )
6915+ {
6916+ subtitlesFile + = ' - ${selectedVariation }' ;
6917+ }
6918+ subtitles .assignSubtitles (subtitlesFile , audioInstTrack );
6919+ }
6920+
68696921 public function postLoadVocals (): Void
68706922 {
68716923 // Reapply the volume and playback rate.
0 commit comments