Allow builds without hxCodec if using hashlink

This commit is contained in:
EliteMasterEric 2024-01-12 21:52:28 -05:00
parent 9b400bf7a1
commit 3e8200ee9d
6 changed files with 48 additions and 23 deletions

View File

@ -105,7 +105,7 @@
<haxelib name="flixel-text-input" /> <!-- Improved text field rendering for HaxeUI -->
<haxelib name="polymod" /> <!-- Modding framework -->
<haxelib name="flxanimate" /> <!-- Texture atlas rendering -->
<haxelib name="hxCodec" /> <!-- Video playback -->
<haxelib name="hxCodec" if="desktop release" /> <!-- Video playback -->
<haxelib name="json2object" /> <!-- JSON parsing -->
<haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->

View File

@ -333,8 +333,12 @@ class Controls extends FlxActionSet
throw 'Invalid name: $name';
#end
return byName[name].inputs.map(function(input) return (input.device == KEYBOARD) ? input.inputID : null)
.filter(function(key) return key != null);
// TODO: Revert to `.map().filter()` once HashLink doesn't complain anymore.
var result:Array<FlxKey> = [];
for (input in byName[name].inputs) {
if (input.device == KEYBOARD) result.push(input.inputID);
}
return result;
}
public function getButtonsForAction(name:Action):Array<FlxGamepadInputID> {
@ -343,8 +347,11 @@ class Controls extends FlxActionSet
throw 'Invalid name: $name';
#end
return byName[name].inputs.map(function(input) return (input.device == GAMEPAD) ? input.inputID : null)
.filter(function(key) return key != null);
var result:Array<FlxGamepadInputID> = [];
for (input in byName[name].inputs) {
if (input.device == GAMEPAD) result.push(input.inputID);
}
return result;
}
public function getDialogueName(action:FlxActionDigital):String

View File

@ -8,7 +8,8 @@ import flixel.util.FlxColor;
import flixel.util.FlxTimer;
#if html5
import funkin.graphics.video.FlxVideo;
#else
#end
#if hxCodec
import hxcodec.flixel.FlxVideoSprite;
#end
@ -48,14 +49,20 @@ class VideoCutscene
#if html5
playVideoHTML5(filePath);
#else
#end
#if hxCodec
playVideoNative(filePath);
#end
}
public static function isPlaying():Bool
{
#if (html5 || hxCodec)
return vid != null;
#else
return false;
#end
}
#if html5
@ -82,7 +89,9 @@ class VideoCutscene
trace('ALERT: Video is null! Could not play cutscene!');
}
}
#else
#end
#if hxCodec
static var vid:FlxVideoSprite;
static function playVideoNative(filePath:String):Void
@ -118,15 +127,20 @@ class VideoCutscene
{
PlayState.instance.remove(vid);
}
#else
#end
#if hxCodec
if (vid != null)
{
vid.stop();
PlayState.instance.remove(vid);
}
#end
#if (html5 || hxCodec)
vid.destroy();
vid = null;
#end
PlayState.instance.camCutscene.visible = true;
PlayState.instance.camHUD.visible = true;
@ -148,9 +162,3 @@ class VideoCutscene
});
}
}
/*
trace('Video playback failed (${e})');
vid = null;
finishCutscene(0.5);
*/

View File

@ -5951,9 +5951,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
ChartEditorNoteSprite.noteFrameCollection = null;
// Stop the music.
welcomeMusic.destroy();
audioInstTrack.destroy();
audioVocalTrackGroup.destroy();
if (welcomeMusic != null) welcomeMusic.destroy();
if (audioInstTrack != null) audioInstTrack.destroy();
if (audioVocalTrackGroup != null) audioVocalTrackGroup.destroy();
}
function applyCanQuickSave():Void

View File

@ -242,8 +242,8 @@ class ChartEditorAudioHandler
snd.loadEmbedded(asset);
snd.autoDestroy = true;
FlxG.sound.list.add(snd);
snd.play(true);
snd.volume = volume;
snd.play();
}
public static function wipeInstrumentalData(state:ChartEditorState):Void

View File

@ -2,7 +2,8 @@ package funkin.ui.title;
#if html5
import funkin.graphics.video.FlxVideo;
#else
#end
#if hxCodec
import hxcodec.flixel.FlxVideoSprite;
#end
import funkin.ui.MusicBeatState;
@ -25,7 +26,9 @@ class AttractState extends MusicBeatState
#if html5
playVideoHTML5(ATTRACT_VIDEO_PATH);
#else
#end
#if hxCodec
playVideoNative(ATTRACT_VIDEO_PATH);
#end
}
@ -50,7 +53,9 @@ class AttractState extends MusicBeatState
trace('ALERT: Video is null! Could not play cutscene!');
}
}
#else
#end
#if hxCodec
var vid:FlxVideoSprite;
function playVideoNative(filePath:String):Void
@ -95,15 +100,20 @@ class AttractState extends MusicBeatState
{
remove(vid);
}
#else
#end
#if hxCodec
if (vid != null)
{
vid.stop();
remove(vid);
}
#end
#if (html5 || hxCodec)
vid.destroy();
vid = null;
#end
FlxG.switchState(new TitleState());
}