1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-11-26 06:09:02 +00:00

Merge pull request #411 from FunkinCrew/feature/video-cutscene-hide

Hide a video cutscene after playing it
This commit is contained in:
Cameron Taylor 2024-03-25 13:37:00 -04:00 committed by GitHub
commit 3c9f63892b

View file

@ -5,6 +5,7 @@ import flixel.FlxSprite;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.util.FlxSignal;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
#if html5 #if html5
import funkin.graphics.video.FlxVideo; import funkin.graphics.video.FlxVideo;
@ -28,6 +29,31 @@ class VideoCutscene
static var vid:FlxVideoSprite; static var vid:FlxVideoSprite;
#end #end
/**
* Called when the video is started.
*/
public static final onVideoStarted:FlxSignal = new FlxSignal();
/**
* Called if the video is paused.
*/
public static final onVideoPaused:FlxSignal = new FlxSignal();
/**
* Called if the video is resumed.
*/
public static final onVideoResumed:FlxSignal = new FlxSignal();
/**
* Called if the video is restarted. onVideoStarted is not called.
*/
public static final onVideoRestarted:FlxSignal = new FlxSignal();
/**
* Called when the video is ended or skipped.
*/
public static final onVideoEnded:FlxSignal = new FlxSignal();
/** /**
* Play a video cutscene. * Play a video cutscene.
* TODO: Currently this is hardcoded to start the countdown after the video is done. * TODO: Currently this is hardcoded to start the countdown after the video is done.
@ -94,6 +120,8 @@ class VideoCutscene
PlayState.instance.add(vid); PlayState.instance.add(vid);
PlayState.instance.refresh(); PlayState.instance.refresh();
onVideoStarted.dispatch();
} }
else else
{ {
@ -129,6 +157,8 @@ class VideoCutscene
vid.y = 0; vid.y = 0;
// vid.scale.set(0.5, 0.5); // vid.scale.set(0.5, 0.5);
}); });
onVideoStarted.dispatch();
} }
else else
{ {
@ -143,6 +173,7 @@ class VideoCutscene
if (vid != null) if (vid != null)
{ {
vid.restartVideo(); vid.restartVideo();
onVideoRestarted.dispatch();
} }
#end #end
@ -156,6 +187,8 @@ class VideoCutscene
// Resume the video if it was paused. // Resume the video if it was paused.
vid.resume(); vid.resume();
} }
onVideoRestarted.dispatch();
} }
#end #end
} }
@ -166,6 +199,7 @@ class VideoCutscene
if (vid != null) if (vid != null)
{ {
vid.pauseVideo(); vid.pauseVideo();
onVideoPaused.dispatch();
} }
#end #end
@ -173,6 +207,45 @@ class VideoCutscene
if (vid != null) if (vid != null)
{ {
vid.pause(); vid.pause();
onVideoPaused.dispatch();
}
#end
}
public static function hideVideo():Void
{
#if html5
if (vid != null)
{
vid.visible = false;
blackScreen.visible = false;
}
#end
#if hxCodec
if (vid != null)
{
vid.visible = false;
blackScreen.visible = false;
}
#end
}
public static function showVideo():Void
{
#if html5
if (vid != null)
{
vid.visible = true;
blackScreen.visible = false;
}
#end
#if hxCodec
if (vid != null)
{
vid.visible = true;
blackScreen.visible = false;
} }
#end #end
} }
@ -183,6 +256,7 @@ class VideoCutscene
if (vid != null) if (vid != null)
{ {
vid.resumeVideo(); vid.resumeVideo();
onVideoResumed.dispatch();
} }
#end #end
@ -190,6 +264,7 @@ class VideoCutscene
if (vid != null) if (vid != null)
{ {
vid.resume(); vid.resume();
onVideoResumed.dispatch();
} }
#end #end
} }
@ -240,6 +315,7 @@ class VideoCutscene
{ {
ease: FlxEase.quadInOut, ease: FlxEase.quadInOut,
onComplete: function(twn:FlxTween) { onComplete: function(twn:FlxTween) {
onVideoEnded.dispatch();
onCutsceneFinish(cutsceneType); onCutsceneFinish(cutsceneType);
} }
}); });