diff --git a/Project.xml b/Project.xml index fc88ced80be..76e043adc54 100644 --- a/Project.xml +++ b/Project.xml @@ -118,15 +118,15 @@ -
-
+ + diff --git a/source/PlayState.hx b/source/PlayState.hx index 4ddf90b23f5..9c41ed94884 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1928,12 +1928,12 @@ class PlayState extends MusicBeatState /* VIDEO */ /***************/ var videoCutscene:FlxVideoSprite = null; - public function startVideo(name:String, ?callback:Void->Void = null) + public function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null) { #if VIDEOS_ALLOWED inCutscene = true; - var filepath:String = Paths.video(name); + var filepath:String = Paths.video(name, library); #if sys if(!FileSystem.exists(filepath)) #else @@ -1947,19 +1947,18 @@ class PlayState extends MusicBeatState videoCutscene = new FlxVideoSprite(0, 0); videoCutscene.active = false; videoCutscene.antialiasing = true; - videoCutscene.bitmap.onFormatSetup.add(function():Void + videoCutscene.bitmap.onFormatSetup.add(function() { - if (video.bitmap != null && video.bitmap.bitmapData != null) + if (videoCutscene.bitmap != null && videoCutscene.bitmap.bitmapData != null) { - final scale:Float = Math.min(FlxG.width / video.bitmap.bitmapData.width, FlxG.height / video.bitmap.bitmapData.height); + final scale:Float = Math.min(FlxG.width / videoCutscene.bitmap.bitmapData.width, FlxG.height / videoCutscene.bitmap.bitmapData.height); - videoCutscene.setGraphicSize(video.bitmap.bitmapData.width * scale, video.bitmap.bitmapData.height * scale); + videoCutscene.setGraphicSize(videoCutscene.bitmap.bitmapData.width * scale, videoCutscene.bitmap.bitmapData.height * scale); videoCutscene.updateHitbox(); videoCutscene.screenCenter(); } }); videoCutscene.bitmap.onEndReached.add(videoCutscene.destroy); - //#if (hxCodec < "3.0.0") videoCutscene.load(filepath); function startAndEnd() @@ -1970,49 +1969,16 @@ class PlayState extends MusicBeatState startCountdown(); } - // Lily, if you're reading this, copy this to the mobile branch, thanks! - SyncGit12 - /*#if mobile - final file:String = FileSystem.readDirectory('./')[0]; - #else - final file:String = haxe.io.Path.join(['Paths.video', FileSystem.readDirectory('Paths.video')[0]]); - #end*/ - - trace('This might not work! YAY :DDDDD'); - - if (file != null && file.length > 0) - video.load(file); - else - { - return; - } - - /* - if (callback != null) - videoCutscene.finishCallback = callback; - else{ - videoCutscene.finishCallback = function() - { - startAndEnd(); - if (heyStopTrying) openfl.system.System.exit(0); - return; - } - } - */ - add(videoCutscene); - - #else - videoCutscene.play(filepath); + videoCutscene.play(); if (callback != null) - return; // Might crash the game btw - else{ - return; // Might crash the game btw - } - //#end // No... + callback(); + else + startAndEnd(); #else FlxG.log.warn('Platform not supported!'); if (callback != null) - return; + callback(); else startAndEnd(); return; @@ -3605,28 +3571,7 @@ class PlayState extends MusicBeatState new FlxTimer().start(10, function(tmr:FlxTimer) { #if VIDEOS_ALLOWED - var vidSpr:FlxSprite; - var videoDone:Bool = true; - var video:MP4Handler = new MP4Handler(); // it plays but it doesn't show??? - vidSpr = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.WHITE); - add(vidSpr); - #if (hxCodec < "3.0.0") - video.playVideo(Paths.video('scary'), false, false); - video.finishCallback = function() - { - videoDone = true; - vidSpr.visible = false; - Sys.exit(0); - }; - #else - video.play(Paths.video('scary')); - video.onEndReached.add(function(){ - video.dispose(); - videoDone = true; - vidSpr.visible = false; - Sys.exit(0); - }); - #end + startVideo('scary', function() Sys.exit(0)); #else throw 'You should RUN, any minute now.'; // thought this'd be cooler // Sys.exit(0); diff --git a/source/StartupState.hx b/source/StartupState.hx index 7e353fc3b80..b23f0aa7711 100644 --- a/source/StartupState.hx +++ b/source/StartupState.hx @@ -19,103 +19,54 @@ class StartupState extends MusicBeatState var canChristmas = false; - public function startVideo(name:String, ?callback:Void->Void = null) + var vidSprite:FlxVideoSprite = null; + + public function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null) + { + #if VIDEOS_ALLOWED + var filepath:String = Paths.video(name, library); + #if sys + if(!FileSystem.exists(filepath)) + #else + if(!OpenFlAssets.exists(filepath)) + #end + { + FlxG.log.warn('Couldnt find video file: ' + name); + return; + } + + vidSprite = new FlxVideoSprite(0, 0); + vidSprite.active = false; + vidSprite.antialiasing = true; + vidSprite.bitmap.onFormatSetup.add(function() { - #if VIDEOS_ALLOWED - inCutscene = true; - - var filepath:String = Paths.video(name); - #if sys - if(!FileSystem.exists(filepath)) - #else - if(!OpenFlAssets.exists(filepath)) - #end + if (vidSprite.bitmap != null && vidSprite.bitmap.bitmapData != null) { - FlxG.log.warn('Couldnt find video file: ' + name); - return; + final scale:Float = Math.min(FlxG.width / vidSprite.bitmap.bitmapData.width, FlxG.height / vidSprite.bitmap.bitmapData.height); + + vidSprite.setGraphicSize(vidSprite.bitmap.bitmapData.width * scale, vidSprite.bitmap.bitmapData.height * scale); + vidSprite.updateHitbox(); + vidSprite.screenCenter(); } - - vidSprite = new FlxVideoSprite(0, 0); - vidSprite.active = false; - vidSprite.antialiasing = true; - vidSprite.bitmap.onFormatSetup.add(function():Void - { - if (video.bitmap != null && video.bitmap.bitmapData != null) - { - final scale:Float = Math.min(FlxG.width / video.bitmap.bitmapData.width, FlxG.height / video.bitmap.bitmapData.height); - - vidSprite.setGraphicSize(video.bitmap.bitmapData.width * scale, video.bitmap.bitmapData.height * scale); - vidSprite.updateHitbox(); - vidSprite.screenCenter(); - } - }); - vidSprite.bitmap.onEndReached.add(vidSprite.destroy); - //#if (hxCodec < "3.0.0") - vidSprite.load(filepath); - - /*public function startAndEnd() - { - if(endingSong) - endSong(); - else - startCountdown(); - }*/ - - /*public function goToTitle() - { - FlxG.switchState(TitleState.new); - super.update(elapsed); - }*/ + }); + vidSprite.bitmap.onEndReached.add(vidSprite.destroy); + vidSprite.load(filepath); + trace('This might not work! YAY :DDDDD'); - // Lily, if you're reading this, copy this to the mobile branch, thanks! - SyncGit12 - /*#if mobile - final file:String = FileSystem.readDirectory('./')[0]; - #else - final file:String = haxe.io.Path.join(['Paths.video', FileSystem.readDirectory('Paths.video')[0]]); - #end*/ - - trace('This might not work! YAY :DDDDD'); - - if (file != null && file.length > 0) - video.load(file); - else - { - return; - } - - /* - if (callback != null) - vidSprite.finishCallback = callback; - else{ - vidSprite.finishCallback = function() - { - startAndEnd(); - if (heyStopTrying) openfl.system.System.exit(0); - return; - } - } - */ - - add(vidSprite); - - #else - vidSprite.load(filepath); - if (callback != null) - return; // Might crash the game btw - else{ - return; // Might crash the game btw - } - //#end // No... - #else - FlxG.log.warn('Platform not supported!'); - if (callback != null) - return; // Might crash the game btw - else - return; // Might crash the game btw - return; - #end - } + insert(0, vidSprite); + vidSprite.play(); + + if (callback != null) + callback(); + #else + FlxG.log.warn('Platform not supported!'); + if (callback != null) + callback(); + + return; + #end + } override public function create():Void { @@ -142,7 +93,10 @@ class StartupState extends MusicBeatState skipTxt.scrollFactor.set(); skipTxt.alpha = 0; skipTxt.y -= skipTxt.textField.textHeight; - add(skipTxt); + if (vidSprite != null) + insert(1, skipTxt); + else + add(skipTxt); FlxTween.tween(skipTxt, {alpha: 1}, 1); @@ -164,26 +118,9 @@ class StartupState extends MusicBeatState } function doIntro() { - /* #if debug // for testing purposes - final vidSprite = new MP4Handler(); // it plays but it doesn't show??? - #if (hxCodec < "3.0.0") - vidSprite.playVideo(Paths.video('broCopiedDenpa', 'splash'), false, false); - vidSprite.finishCallback = function() - { - try { vidSprite.dispose(); } - catch (e) {} - FlxG.switchState(TitleState.new); - }; - #else - vidSprite.play(Paths.video('broCopiedDenpa', 'splash')); - vidSprite.onEndReached.add(function(){ - vidSprite.dispose(); - FlxG.switchState(TitleState.new); - }); - #end + startVideo('broCopiedDenpa', 'splash'); #else - */ final theIntro:Int = FlxG.random.int(0, maxIntros); switch (theIntro) { case 0: @@ -217,41 +154,11 @@ class StartupState extends MusicBeatState FlxTween.tween(logo, {alpha: 1, "scale.x": 1, "scale.y": 1}, 1.35, {ease: FlxEase.expoOut, onComplete: _ -> onIntroDone(0.6)}); case 4: #if VIDEOS_ALLOWED - var vidSprite = new FlxVideoSprite(); // it plays but it doesn't show?? - vidSprite.load(Paths.video('bambiStartup', 'splash')); - vidSprite.finishCallback = function() - { - try { vidSprite.dispose(); } - catch (e) {} - FlxG.switchState(TitleState.new); - }; - #else - vidSprite.load(Paths.video('bambiStartup', 'splash')); - vidSprite.onEndReached.add(function(){ - vidSprite.dispose(); - FlxG.switchState(TitleState.new); - }); - #end - //#end // No... + startVideo('bambiStartup', 'splash'); + #end case 5: #if VIDEOS_ALLOWED - var vidSprite = new MP4Handler(); // it plays but it doesn't show??? - //#if (hxCodec < "3.0.0") - var vidSprite = new FlxVideoSprite(); // it plays but it doesn't show?? - vidSprite.load(Paths.video('broCopiedDenpa', 'splash')); - vidSprite.finishCallback = function() - { - try { vidSprite.dispose(); } - catch (e) {} - FlxG.switchState(TitleState.new); - }; - #else - vidSprite.load(Paths.video('broCopiedDenpa', 'splash')); - vidSprite.onEndReached.add(function(){ - vidSprite.dispose(); - FlxG.switchState(TitleState.new); - }); - #end + startVideo('broCopiedDenpa', 'splash'); #end case 6: if (canChristmas) @@ -262,9 +169,11 @@ class StartupState extends MusicBeatState logo.updateHitbox(); logo.screenCenter(); FlxTween.tween(logo, {alpha: 1, "scale.x": 1, "scale.y": 1}, 2, {ease: FlxEase.expoOut, onComplete: _ -> onIntroDone(1.5)}); - } else doIntro(); + } + else + doIntro(); } - // #end + #end } override function update(elapsed:Float)