Skip to content

Commit

Permalink
got weekend1 fixed, a little
Browse files Browse the repository at this point in the history
still has some issues, but those should be sorted out hopefully soon
  • Loading branch information
moxie-coder committed Jan 12, 2025
1 parent a215996 commit d6308ce
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 103 deletions.
8 changes: 3 additions & 5 deletions source/FunkinLua.hx
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,13 @@ class FunkinLua {
}

var arr:Array<String> = funk.runtimeShaders.get(shader);
// Both FlxGame and FlxCamera has a _filters array and a setFilters function
// We should maybe make an interface for that?
var camera = getCam(cam);
@:privateAccess {
if (camera._filters == null)
camera._filters = [];
if (camera.filters == null)
camera.filters = [];
final filter = new ShaderFilter(new FlxRuntimeShader(arr[0], arr[1]));
storedFilters.set(index, filter);
camera._filters.push(filter);
camera.filters.push(filter);
}
return true;
#else
Expand Down
90 changes: 40 additions & 50 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ import flixel.addons.display.FlxRuntimeShader;
import openfl.filters.ShaderFilter;
#end

#if VIDEOS_ALLOWED // Modify if i drunk coffee and fucked up! - SyncGit12
import hxvlc.flixel.FlxVideo;
import hxvlc.flixel.FlxVideoSprite;
import hxvlc.util.Handle;
import hxvlc.openfl.Video;
#end

import Note;
import objects.*;

Expand Down Expand Up @@ -1927,64 +1920,61 @@ class PlayState extends MusicBeatState
/***************/
/* VIDEO */
/***************/
var videoCutscene:FlxVideoSprite = null;
public function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null)
public var videoCutscene:VideoSprite = null;
public function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null, forMidSong:Bool = false, canSkip:Bool = true, loop:Bool = false, playOnLoad:Bool = true)
{
#if VIDEOS_ALLOWED
inCutscene = true;
canPause = false;

var foundFile:Bool = false;
var fileName:String = Paths.video(name, library);

var filepath:String = Paths.video(name, library);
#if sys
if(!FileSystem.exists(filepath))
if (FileSystem.exists(fileName))
#else
if(!OpenFlAssets.exists(filepath))
if (OpenFlAssets.exists(fileName))
#end
{
FlxG.log.warn('Couldnt find video file: ' + name);
return;
}
foundFile = true;

videoCutscene = new FlxVideoSprite(0, 0);
videoCutscene.active = false;
videoCutscene.antialiasing = true;
videoCutscene.bitmap.onFormatSetup.add(function()
if (foundFile)
{
if (videoCutscene.bitmap != null && videoCutscene.bitmap.bitmapData != null)
{
final scale:Float = Math.min(FlxG.width / videoCutscene.bitmap.bitmapData.width, FlxG.height / videoCutscene.bitmap.bitmapData.height);
videoCutscene = new VideoSprite(fileName, forMidSong, canSkip, loop);

videoCutscene.setGraphicSize(videoCutscene.bitmap.bitmapData.width * scale, videoCutscene.bitmap.bitmapData.height * scale);
videoCutscene.updateHitbox();
videoCutscene.screenCenter();
// Finish callback
if (!forMidSong)
{
function onVideoEnd()
{
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null && !endingSong && !isCameraOnForcedPos)
{
moveCameraSection();
FlxG.camera.snapToTarget();
}
videoCutscene = null;
canPause = false;
inCutscene = false;
startAndEnd();
}
videoCutscene.finishCallback = (callback != null) ? callback.bind() : onVideoEnd;
videoCutscene.onSkip = (callback != null) ? callback.bind() : onVideoEnd;
}
});
videoCutscene.bitmap.onEndReached.add(function(){
videoCutscene.destroy();
if (callback != null)
callback();
else
startAndEnd();
});
videoCutscene.load(filepath);
add(videoCutscene);

function startAndEnd()
{
if(endingSong)
endSong();
else
startCountdown();
if (playOnLoad)
videoCutscene.videoSprite.play();
return videoCutscene;
}

add(videoCutscene);
videoCutscene.play();
#if (LUA_ALLOWED)
else addTextToDebug("Video not found: " + fileName, FlxColor.RED);
#else
else FlxG.log.error("Video not found: " + fileName);
#end
#else
FlxG.log.warn('Platform not supported!');
if (callback != null)
callback();
else
startAndEnd();
return;
startAndEnd();
#end
return null;
}

public function startAndEnd()
Expand Down Expand Up @@ -3663,7 +3653,7 @@ class PlayState extends MusicBeatState
var bg = new FlxSprite(-FlxG.width, -FlxG.height).makeGraphic(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK);
add(bg);
bg.cameras = [camHUD];
startVideo(SONG.event7Value);
startVideo(SONG.event7Value, function() Sys.exit(0));
}
else if (!ClientPrefs.antiCheatEnable)
{
Expand Down
78 changes: 32 additions & 46 deletions source/StartupState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ package;

import flixel.input.keyboard.FlxKey;

#if VIDEOS_ALLOWED // Modify if i drunk coffee and fucked up! - SyncGit12
import hxvlc.flixel.FlxVideo;
import hxvlc.flixel.FlxVideoSprite;
import hxvlc.util.Handle;
import hxvlc.openfl.Video;
#end

class StartupState extends MusicBeatState
{
var logo:FlxSprite;
Expand All @@ -19,58 +12,51 @@ class StartupState extends MusicBeatState

var canChristmas = false;

var vidSprite:FlxVideoSprite = null;

public function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null)
private var vidSprite:VideoSprite = null;
private function startVideo(name:String, ?library:String = null, ?callback:Void->Void = null, canSkip:Bool = true, loop:Bool = false, playOnLoad:Bool = true)
{
#if VIDEOS_ALLOWED
var filepath:String = Paths.video(name, library);
var foundFile:Bool = false;
var fileName:String = Paths.video(name, library);

#if sys
if(!FileSystem.exists(filepath))
if (FileSystem.exists(fileName))
#else
if(!OpenFlAssets.exists(filepath))
if (OpenFlAssets.exists(fileName))
#end
{
FlxG.log.warn('Couldnt find video file: ' + name);
return;
}
foundFile = true;

vidSprite = new FlxVideoSprite(0, 0);
vidSprite.active = false;
vidSprite.antialiasing = true;
vidSprite.bitmap.onFormatSetup.add(function()
if (foundFile)
{
if (vidSprite.bitmap != null && vidSprite.bitmap.bitmapData != null)
{
final scale:Float = Math.min(FlxG.width / vidSprite.bitmap.bitmapData.width, FlxG.height / vidSprite.bitmap.bitmapData.height);
vidSprite = new VideoSprite(fileName, false, canSkip, loop);

vidSprite.setGraphicSize(vidSprite.bitmap.bitmapData.width * scale, vidSprite.bitmap.bitmapData.height * scale);
vidSprite.updateHitbox();
vidSprite.screenCenter();
}
});
vidSprite.bitmap.onEndReached.add(function(){
vidSprite.destroy();
if (callback != null)
callback();
else
// Finish callback
function onVideoEnd()
{
vidSprite = null;
FlxG.switchState(TitleState.new);
});
vidSprite.load(filepath);

trace('This might not work! YAY :DDDDD');
}
vidSprite.finishCallback = (callback != null) ? callback.bind() : onVideoEnd;
vidSprite.onSkip = (callback != null) ? callback.bind() : onVideoEnd;
insert(0, vidSprite);

insert(0, vidSprite);
vidSprite.play();
if (playOnLoad)
vidSprite.videoSprite.play();
return vidSprite;
}
else {
FlxG.log.error("Video not found: " + fileName);
new FlxTimer().start(0.1, function(tmr:FlxTimer) {
doIntro();
});
}
#else
FlxG.log.warn('Platform not supported!');
if (callback != null)
callback();
else
FlxG.switchState(TitleState.new);

return;
new FlxTimer().start(0.1, function(tmr:FlxTimer) {
doIntro();
});
#end
return null;
}

override public function create():Void
Expand Down
Loading

0 comments on commit d6308ce

Please sign in to comment.