1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-10-03 15:59:04 +00:00

Fixes to cutscene pausing.

This commit is contained in:
EliteMasterEric 2024-02-28 03:53:36 -05:00
parent 5d030b8a31
commit 8683900922
4 changed files with 85 additions and 4 deletions

View file

@ -40,6 +40,23 @@ class FlxVideo extends FlxBasic
netStream.play(videoPath);
}
public function pauseVideo():Void
{
if (netStream != null)
{
netStream.pause();
}
}
public function resumeVideo():Void
{
// Resume playing the video.
if (netStream != null)
{
netStream.resume();
}
}
public function restartVideo():Void
{
// Seek to the beginning of the video.

View file

@ -82,6 +82,7 @@ class PauseSubState extends MusicBeatSubState
var background:FunkinSprite;
var metadata:FlxTypedSpriteGroup<FlxText>;
var metadataPractice:FlxText;
var metadataDeaths:FlxText;
var menuEntryText:FlxTypedSpriteGroup<AtlasText>;
// Audio
@ -172,9 +173,8 @@ class PauseSubState extends MusicBeatSubState
metadataDifficulty.scrollFactor.set(0, 0);
metadata.add(metadataDifficulty);
var metadataDeaths:FlxText = new FlxText(20, 15 + 64, FlxG.width - 40, '0 Blue Balls');
metadataDeaths = new FlxText(20, 15 + 64, FlxG.width - 40, '${PlayState.instance?.deathCounter} Blue Balls');
metadataDeaths.setFormat(Paths.font('vcr.ttf'), 32, FlxColor.WHITE, FlxTextAlign.RIGHT);
metadataDeaths.text = '${PlayState.instance?.deathCounter} Blue Balls';
metadataDeaths.scrollFactor.set(0, 0);
metadata.add(metadataDeaths);
@ -183,6 +183,8 @@ class PauseSubState extends MusicBeatSubState
metadataPractice.visible = PlayState.instance?.isPracticeMode ?? false;
metadataPractice.scrollFactor.set(0, 0);
metadata.add(metadataPractice);
updateMetadataText();
}
function regenerateMenu(?targetMode:PauseMode):Void
@ -250,11 +252,28 @@ class PauseSubState extends MusicBeatSubState
currentMenuEntries.remove(entry);
}
metadataPractice.visible = PlayState.instance?.isPracticeMode ?? false;
updateMetadataText();
changeSelection();
}
function updateMetadataText():Void
{
metadataPractice.visible = PlayState.instance?.isPracticeMode ?? false;
switch (this.currentMode)
{
case Standard | Difficulty:
metadataDeaths.text = '${PlayState.instance?.deathCounter} Blue Balls';
case Charting:
metadataDeaths.text = 'Chart Editor Preview';
case Conversation:
metadataDeaths.text = 'Dialogue Paused';
case Cutscene:
metadataDeaths.text = 'Video Paused';
}
}
function transitionIn():Void
{
FlxTween.tween(background, {alpha: 0.6}, 0.4, {ease: FlxEase.quartInOut});
@ -339,6 +358,9 @@ class PauseSubState extends MusicBeatSubState
// ===============
static function resume(state:PauseSubState):Void
{
// Resume a paused video if it exists.
VideoCutscene.resumeVideo();
state.close();
}

View file

@ -2480,6 +2480,8 @@ class PlayState extends MusicBeatSubState
// This is a video cutscene.
if (controls.PAUSE && !justUnpaused)
{
VideoCutscene.pauseVideo();
var pauseSubState:FlxSubState = new PauseSubState({mode: Cutscene});
persistentUpdate = false;

View file

@ -112,6 +112,7 @@ class VideoCutscene
{
vid.zIndex = 0;
vid.bitmap.onEndReached.add(finishVideo.bind(0.5));
vid.autoPause = false;
vid.cameras = [PlayState.instance.camCutscene];
@ -136,7 +137,7 @@ class VideoCutscene
}
#end
public static function restartVideo():Void
public static function restartVideo(resume:Bool = true):Void
{
#if html5
if (vid != null)
@ -150,6 +151,45 @@ class VideoCutscene
{
// Seek to the start of the video.
vid.bitmap.time = 0;
if (resume)
{
// Resume the video if it was paused.
vid.resume();
}
}
#end
}
public static function pauseVideo():Void
{
#if html5
if (vid != null)
{
vid.pauseVideo();
}
#end
#if hxCodec
if (vid != null)
{
vid.pause();
}
#end
}
public static function resumeVideo():Void
{
#if html5
if (vid != null)
{
vid.resumeVideo();
}
#end
#if hxCodec
if (vid != null)
{
vid.resume();
}
#end
}