From 6052081fecfbb2d2f853802ca8eb8aa0210c54b1 Mon Sep 17 00:00:00 2001 From: HackDev <80620538+Hackx2@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:17:12 +0100 Subject: [PATCH] lll --- Project.xml | 12 ++--- TODO.md | 2 +- source/funkin/backend/handlers/VidHandler.hx | 50 +++++++++++++++++++ .../funkin/game/states/VideoHandlerState.hx | 3 -- source/funkin/game/videos/TemplateVideo.hx | 30 +---------- source/funkin/game/videos/import.hx | 15 ++---- 6 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 source/funkin/backend/handlers/VidHandler.hx delete mode 100644 source/funkin/game/states/VideoHandlerState.hx diff --git a/Project.xml b/Project.xml index fb41629..a4feb1a 100644 --- a/Project.xml +++ b/Project.xml @@ -44,7 +44,7 @@ - + @@ -56,12 +56,10 @@ -
- - - - -
+ + + + diff --git a/TODO.md b/TODO.md index 728a018..e2298e8 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,7 @@ # ```TODO``` * ~~finish Init State.~~ -* Finsh Video Handler State +* ~~Finsh Video Handler State~~ * OLD: * Might add winning icons (only if i can get the icons for them :3) diff --git a/source/funkin/backend/handlers/VidHandler.hx b/source/funkin/backend/handlers/VidHandler.hx new file mode 100644 index 0000000..ac58f81 --- /dev/null +++ b/source/funkin/backend/handlers/VidHandler.hx @@ -0,0 +1,50 @@ +package funkin.backend.handlers; + +// TODO: umm make video states easier :3 +#if VIDEOS_ALLOWED +#if (hxCodec >= "2.6.1") + import hxcodec.VideoHandler as MP4Handler; +#elseif (hxCodec == "2.6.0") + import VideoHandler as MP4Handler; +#else + import vlc.MP4Handler; +#end +using StringTools; + +class VidHandler extends MusicBeatState{ + static var video:MP4Handler; + + override function create() + { + super.create(); + } + public static function startVideo(videoName:String) { + if(FlxG.sound.music != null) + FlxG.sound.music.fadeOut(1, 0, function(_) FlxG.sound.music.stop()); + if (funkin.game.Main.fpsVar != null) + funkin.game.Main.fpsVar.visible = false; + FlxG.mouse.visible = false; + video = new MP4Handler(); + video.playVideo(Paths.video(videoName)); + trace(videoName); + video.finishCallback = function() + { + if (funkin.game.Main.fpsVar != null) + funkin.game.Main.fpsVar.visible = ClientPrefs.data.showFPS; + FlxG.sound.playMusic(Paths.music('freakyMenu'), 0); + FlxG.sound.music.fadeIn(4, 0, 0.7); + FlxG.mouse.visible = true; + MusicBeatState.switchState(new MainMenuState()); + return; + } + } + override function update(elapsed:Float) + { + super.update(elapsed); + if ((FlxG.keys.justPressed.ANY && !controls.ACCEPT) && video != null) + { + video.finishVideo(); + } + } +} +#end \ No newline at end of file diff --git a/source/funkin/game/states/VideoHandlerState.hx b/source/funkin/game/states/VideoHandlerState.hx deleted file mode 100644 index e113e8e..0000000 --- a/source/funkin/game/states/VideoHandlerState.hx +++ /dev/null @@ -1,3 +0,0 @@ -package funkin.game.states; - -// TODO: umm make video states easier :3 \ No newline at end of file diff --git a/source/funkin/game/videos/TemplateVideo.hx b/source/funkin/game/videos/TemplateVideo.hx index caa5d46..e813500 100644 --- a/source/funkin/game/videos/TemplateVideo.hx +++ b/source/funkin/game/videos/TemplateVideo.hx @@ -1,39 +1,13 @@ package funkin.game.videos; #if VIDEOS_ALLOWED -class TemplateVideo extends MusicBeatState +class TemplateVideo extends VidHandler { - var video:MP4Handler; - override function create() { super.create(); - FlxG.sound.music.fadeOut(1, 0, function(_) FlxG.sound.music.stop()); - if (funkin.game.Main.fpsVar != null) - funkin.game.Main.fpsVar.visible = false; - FlxG.mouse.visible = false; - video = new MP4Handler(); - video.playVideo(Paths.video('VIDEOPATHEHERE')); // ripped from the game - video.finishCallback = function() - { - if (funkin.game.Main.fpsVar != null) - funkin.game.Main.fpsVar.visible = ClientPrefs.data.showFPS; - FlxG.sound.playMusic(Paths.music('freakyMenu'), 0); - FlxG.sound.music.fadeIn(4, 0, 0.7); - FlxG.mouse.visible = true; - MusicBeatState.switchState(new MainMenuState()); - return; - } - } - - override function update(elapsed:Float) - { - super.update(elapsed); - if ((FlxG.keys.justPressed.ANY && !controls.ACCEPT) && video != null) - { - video.finishVideo(); - } + VidHandler.startVideo('HEWWO'); } } #end diff --git a/source/funkin/game/videos/import.hx b/source/funkin/game/videos/import.hx index 8ad8cc2..80f679d 100644 --- a/source/funkin/game/videos/import.hx +++ b/source/funkin/game/videos/import.hx @@ -1,14 +1,7 @@ package funkin.game.videos; +#if !macro + import funkin.backend.handlers.VidHandler; -#if VIDEOS_ALLOWED -#if (hxCodec >= "2.6.1") -import hxcodec.VideoHandler as MP4Handler; -#elseif (hxCodec == "2.6.0") -import VideoHandler as MP4Handler; -#else -import vlc.MP4Handler; -#end -#end - -using StringTools; \ No newline at end of file + using StringTools; +#end \ No newline at end of file