From 0ed4f87bdb8259c83c4be90d9bbc5cb6700893d2 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 10 Apr 2021 02:53:23 -0400 Subject: [PATCH] weird polish bullshit --- source/MainMenuState.hx | 7 ++- source/PlayState.hx | 21 +++++---- source/TitleState.hx | 77 +++++++++++++++++++------------- source/VideoState.hx | 99 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+), 42 deletions(-) create mode 100644 source/VideoState.hx diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 88174cacc..6e8fb60ef 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -96,8 +96,11 @@ class MainMenuState extends MusicBeatState // addMenuItem('options', function () startExitState(new OptionMenu())); #if CAN_OPEN_LINKS var hasPopupBlocker = #if web true #else false #end; - menuItems.createItem('kickstarter', selectDonate, hasPopupBlocker); - // menuItems.createItem('donate', selectDonate, hasPopupBlocker); + + if (VideoState.seenVideo) + menuItems.createItem('kickstarter', selectDonate, hasPopupBlocker); + else + menuItems.createItem('donate', selectDonate, hasPopupBlocker); #end menuItems.createItem('options', function() startExitState(new OptionsState())); // #if newgrounds diff --git a/source/PlayState.hx b/source/PlayState.hx index 43150ff2b..2774676f9 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -915,8 +915,8 @@ class PlayState extends MusicBeatState switch (curSong.toLowerCase()) { // REMOVE THIS LATER - case 'stress': - stressIntro(); + // case 'stress': + // stressIntro(); default: startCountdown(); @@ -1110,13 +1110,12 @@ class PlayState extends MusicBeatState add(bfCatchGf); bfCatchGf.visible = false; - var cutsceneSound:FlxSound = new FlxSound(); - if (PreferencesMenu.getPref('censor-naughty')) - cutsceneSound.loadEmbedded(Paths.sound('stressCutscene')); + tankCutscene.startSyncAudio = FlxG.sound.play(Paths.sound('stressCutscene')); else { - cutsceneSound.loadEmbedded(Paths.sound('song3censor')); + tankCutscene.startSyncAudio = FlxG.sound.play(Paths.sound('song3censor')); + // cutsceneSound.loadEmbedded(Paths.sound('song3censor')); var censor:FlxSprite = new FlxSprite(); censor.frames = Paths.getSparrowAtlas('cutsceneStuff/censor'); @@ -1173,7 +1172,7 @@ class PlayState extends MusicBeatState // new FlxTimer().start(0.01, function(tmr) cutsceneSound.play()); // cutsceneSound.play(); // cutsceneSound.play(); - tankCutscene.startSyncAudio = cutsceneSound; + // tankCutscene.startSyncAudio = cutsceneSound; // tankCutscene.animation.curAnim.curFrame FlxG.camera.zoom = defaultCamZoom * 1.15; @@ -2229,7 +2228,13 @@ class PlayState extends MusicBeatState transIn = FlxTransitionableState.defaultTransIn; transOut = FlxTransitionableState.defaultTransOut; - FlxG.switchState(new StoryMenuState()); + switch (PlayState.storyWeek) + { + case 7: + FlxG.switchState(new VideoState()); + default: + FlxG.switchState(new StoryMenuState()); + } // if () StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true; diff --git a/source/TitleState.hx b/source/TitleState.hx index c631c6f13..5ec71ff27 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -109,29 +109,35 @@ class TitleState extends MusicBeatState FlxG.switchState(new FreeplayState()); #elseif CHARTING FlxG.switchState(new ChartingState()); - #elseif web - if (!initialized) - { - video = new Video(); - FlxG.stage.addChild(video); + /* + #elseif web - var netConnection = new NetConnection(); - netConnection.connect(null); - netStream = new NetStream(netConnection); - netStream.client = {onMetaData: client_onMetaData}; - netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); - netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); - // netStream.addEventListener(NetStatusEvent.NET_STATUS) // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + if (!initialized) + { - overlay = new Sprite(); - overlay.graphics.beginFill(0, 0.5); - overlay.graphics.drawRect(0, 0, 1280, 720); - overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + video = new Video(); + FlxG.stage.addChild(video); - overlay.buttonMode = true; - FlxG.stage.addChild(overlay); - } + var netConnection = new NetConnection(); + netConnection.connect(null); + + netStream = new NetStream(netConnection); + netStream.client = {onMetaData: client_onMetaData}; + netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); + netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); + // netStream.addEventListener(NetStatusEvent.NET_STATUS) // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + overlay = new Sprite(); + overlay.graphics.beginFill(0, 0.5); + overlay.graphics.drawRect(0, 0, 1280, 720); + overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + + overlay.buttonMode = true; + // FlxG.stage.addChild(overlay); + + } + */ // netConnection.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); #else @@ -169,8 +175,8 @@ class TitleState extends MusicBeatState { if (event.info.code == 'NetStream.Play.Complete') { - netStream.dispose(); - FlxG.stage.removeChild(video); + // netStream.dispose(); + // FlxG.stage.removeChild(video); startIntro(); } @@ -182,7 +188,7 @@ class TitleState extends MusicBeatState { netStream.soundTransform.volume = 0.2; netStream.soundTransform.pan = -1; - netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); FlxG.stage.removeChild(overlay); } @@ -310,6 +316,9 @@ class TitleState extends MusicBeatState else initialized = true; + if (FlxG.sound.music != null) + FlxG.sound.music.onComplete = function() FlxG.switchState(new VideoState()); + // credGroup.add(credTextShit); } @@ -382,6 +391,9 @@ class TitleState extends MusicBeatState if (pressedEnter && !transitioning && skippedIntro) { + if (FlxG.sound.music != null) + FlxG.sound.music.onComplete = null; + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); NGio.unlockMedal(60960); // If it's Friday according to da clock @@ -427,17 +439,18 @@ class TitleState extends MusicBeatState { skipIntro(); } + /* + #if web + if (!initialized && controls.ACCEPT) + { + // netStream.dispose(); + // FlxG.stage.removeChild(video); - #if web - if (!initialized && controls.ACCEPT) - { - netStream.dispose(); - FlxG.stage.removeChild(video); - - startIntro(); - skipIntro(); - } - #end + startIntro(); + skipIntro(); + } + #end + */ // if (FlxG.keys.justPressed.SPACE) // swagShader.hasOutline = !swagShader.hasOutline; diff --git a/source/VideoState.hx b/source/VideoState.hx new file mode 100644 index 000000000..6fa93428c --- /dev/null +++ b/source/VideoState.hx @@ -0,0 +1,99 @@ +package; + +import flixel.FlxG; +import openfl.display.Sprite; +import openfl.events.AsyncErrorEvent; +import openfl.events.MouseEvent; +import openfl.events.NetStatusEvent; +import openfl.media.Video; +import openfl.net.NetConnection; +import openfl.net.NetStream; + +class VideoState extends MusicBeatState +{ + var video:Video; + var netStream:NetStream; + private var overlay:Sprite; + + public static var seenVideo:Bool = false; + + override function create() + { + super.create(); + + seenVideo = true; + + if (FlxG.sound.music != null) + FlxG.sound.music.stop(); + + video = new Video(); + FlxG.addChildBelowMouse(video); + + var netConnection = new NetConnection(); + netConnection.connect(null); + + netStream = new NetStream(netConnection); + netStream.client = {onMetaData: client_onMetaData}; + netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); + netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); + // netStream.addEventListener(NetStatusEvent.NET_STATUS); + netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + overlay = new Sprite(); + overlay.graphics.beginFill(0, 0.5); + overlay.graphics.drawRect(0, 0, 1280, 720); + overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + + overlay.buttonMode = true; + // FlxG.stage.addChild(overlay); + } + + override function update(elapsed:Float) + { + if (controls.ACCEPT) + finishVid(); + + super.update(elapsed); + } + + function finishVid():Void + { + netStream.dispose(); + FlxG.removeChild(video); + + FlxG.switchState(new TitleState()); + } + + private function client_onMetaData(metaData:Dynamic) + { + video.attachNetStream(netStream); + + video.width = video.videoWidth; + video.height = video.videoHeight; + // video. + } + + private function netStream_onAsyncError(event:AsyncErrorEvent):Void + { + trace("Error loading video"); + } + + private function netConnection_onNetStatus(event:NetStatusEvent):Void + { + if (event.info.code == 'NetStream.Play.Complete') + { + finishVid(); + } + + trace(event.toString()); + } + + private function overlay_onMouseDown(event:MouseEvent):Void + { + netStream.soundTransform.volume = 0.2; + netStream.soundTransform.pan = -1; + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + FlxG.stage.removeChild(overlay); + } +}