mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-12-01 03:46:58 -05:00
Merge pull request #779 from FunkinCrew/cutscene-volume-math-fix
proper audio scaling for hxcodec / desktop
This commit is contained in:
commit
1937529c1f
5 changed files with 45 additions and 11 deletions
32
source/funkin/graphics/video/FunkinVideoSprite.hx
Normal file
32
source/funkin/graphics/video/FunkinVideoSprite.hx
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package funkin.graphics.video;
|
||||||
|
|
||||||
|
import hxcodec.flixel.FlxVideoSprite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not to be confused with FlxVideo, this is a hxcodec based video class
|
||||||
|
* We override it simply to correct/control our volume easier.
|
||||||
|
*/
|
||||||
|
class FunkinVideoSprite extends FlxVideoSprite
|
||||||
|
{
|
||||||
|
public var volume(default, set):Float = 1;
|
||||||
|
|
||||||
|
public function new(x:Float = 0, y:Float = 0)
|
||||||
|
{
|
||||||
|
super(x, y);
|
||||||
|
|
||||||
|
set_volume(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function update(elapsed:Float):Void
|
||||||
|
{
|
||||||
|
super.update(elapsed);
|
||||||
|
set_volume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_volume(value:Float):Float
|
||||||
|
{
|
||||||
|
volume = value;
|
||||||
|
bitmap.volume = Std.int((FlxG.sound.muted ? 0 : 1) * (FlxG.sound.logToLinear(FlxG.sound.volume) * 100) * volume);
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import flixel.util.FlxTimer;
|
||||||
import funkin.graphics.video.FlxVideo;
|
import funkin.graphics.video.FlxVideo;
|
||||||
#end
|
#end
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
import hxcodec.flixel.FlxVideoSprite;
|
import funkin.graphics.video.FunkinVideoSprite;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ class VideoCutscene
|
||||||
static var vid:FlxVideo;
|
static var vid:FlxVideo;
|
||||||
#end
|
#end
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
static var vid:FlxVideoSprite;
|
static var vid:FunkinVideoSprite;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +138,7 @@ class VideoCutscene
|
||||||
static function playVideoNative(filePath:String):Void
|
static function playVideoNative(filePath:String):Void
|
||||||
{
|
{
|
||||||
// Video displays OVER the FlxState.
|
// Video displays OVER the FlxState.
|
||||||
vid = new FlxVideoSprite(0, 0);
|
vid = new FunkinVideoSprite(0, 0);
|
||||||
|
|
||||||
if (vid != null)
|
if (vid != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ package funkin.ui.charSelect;
|
||||||
import funkin.graphics.video.FlxVideo;
|
import funkin.graphics.video.FlxVideo;
|
||||||
#end
|
#end
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
import hxcodec.flixel.FlxVideoSprite;
|
import funkin.graphics.video.FunkinVideoSprite;
|
||||||
#end
|
#end
|
||||||
import funkin.ui.MusicBeatSubState;
|
import funkin.ui.MusicBeatSubState;
|
||||||
import funkin.audio.FunkinSound;
|
import funkin.audio.FunkinSound;
|
||||||
|
@ -72,12 +72,12 @@ class IntroSubState extends MusicBeatSubState
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
var vid:FlxVideoSprite;
|
var vid:FunkinVideoSprite;
|
||||||
|
|
||||||
function playVideoNative(filePath:String):Void
|
function playVideoNative(filePath:String):Void
|
||||||
{
|
{
|
||||||
// Video displays OVER the FlxState.
|
// Video displays OVER the FlxState.
|
||||||
vid = new FlxVideoSprite(0, 0);
|
vid = new FunkinVideoSprite(0, 0);
|
||||||
|
|
||||||
vid.scrollFactor.set();
|
vid.scrollFactor.set();
|
||||||
|
|
||||||
|
|
|
@ -79,10 +79,12 @@ class FunkinSoundTray extends FlxSoundTray
|
||||||
y = MathUtil.coolLerp(y, lerpYPos, 0.1);
|
y = MathUtil.coolLerp(y, lerpYPos, 0.1);
|
||||||
alpha = MathUtil.coolLerp(alpha, alphaTarget, 0.25);
|
alpha = MathUtil.coolLerp(alpha, alphaTarget, 0.25);
|
||||||
|
|
||||||
|
var shouldHide = (FlxG.sound.muted == false && FlxG.sound.volume > 0);
|
||||||
|
|
||||||
// Animate sound tray thing
|
// Animate sound tray thing
|
||||||
if (_timer > 0)
|
if (_timer > 0)
|
||||||
{
|
{
|
||||||
_timer -= (MS / 1000);
|
if (shouldHide) _timer -= (MS / 1000);
|
||||||
alphaTarget = 1;
|
alphaTarget = 1;
|
||||||
}
|
}
|
||||||
else if (y >= -height)
|
else if (y >= -height)
|
||||||
|
@ -121,7 +123,7 @@ class FunkinSoundTray extends FlxSoundTray
|
||||||
active = true;
|
active = true;
|
||||||
var globalVolume:Int = Math.round(FlxG.sound.logToLinear(FlxG.sound.volume) * 10);
|
var globalVolume:Int = Math.round(FlxG.sound.logToLinear(FlxG.sound.volume) * 10);
|
||||||
|
|
||||||
if (FlxG.sound.muted)
|
if (FlxG.sound.muted || FlxG.sound.volume == 0)
|
||||||
{
|
{
|
||||||
globalVolume = 0;
|
globalVolume = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ package funkin.ui.title;
|
||||||
import funkin.graphics.video.FlxVideo;
|
import funkin.graphics.video.FlxVideo;
|
||||||
#end
|
#end
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
import hxcodec.flixel.FlxVideoSprite;
|
import funkin.graphics.video.FunkinVideoSprite;
|
||||||
#end
|
#end
|
||||||
import funkin.ui.MusicBeatState;
|
import funkin.ui.MusicBeatState;
|
||||||
|
|
||||||
|
@ -62,12 +62,12 @@ class AttractState extends MusicBeatState
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if hxCodec
|
#if hxCodec
|
||||||
var vid:FlxVideoSprite;
|
var vid:FunkinVideoSprite;
|
||||||
|
|
||||||
function playVideoNative(filePath:String):Void
|
function playVideoNative(filePath:String):Void
|
||||||
{
|
{
|
||||||
// Video displays OVER the FlxState.
|
// Video displays OVER the FlxState.
|
||||||
vid = new FlxVideoSprite(0, 0);
|
vid = new FunkinVideoSprite(0, 0);
|
||||||
|
|
||||||
if (vid != null)
|
if (vid != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue