mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-09 00:04:42 +00:00
Added a forceUpdate option, and improved efficiency of other setters.
This commit is contained in:
parent
17bf3289b5
commit
abebfd8300
|
@ -23,10 +23,18 @@ class WaveformSprite extends MeshRender
|
||||||
*/
|
*/
|
||||||
var isWaveformDirty:Bool = true;
|
var isWaveformDirty:Bool = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, force the waveform to redraw every frame.
|
||||||
|
* Useful if the waveform's clipRect is constantly changing.
|
||||||
|
*/
|
||||||
|
public var forceUpdate:Bool = false;
|
||||||
|
|
||||||
public var waveformData:WaveformData;
|
public var waveformData:WaveformData;
|
||||||
|
|
||||||
function set_waveformData(value:WaveformData):WaveformData
|
function set_waveformData(value:WaveformData):WaveformData
|
||||||
{
|
{
|
||||||
|
if (waveformData == value) return value;
|
||||||
|
|
||||||
waveformData = value;
|
waveformData = value;
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return waveformData;
|
return waveformData;
|
||||||
|
@ -39,6 +47,8 @@ class WaveformSprite extends MeshRender
|
||||||
|
|
||||||
function set_waveformColor(value:FlxColor):FlxColor
|
function set_waveformColor(value:FlxColor):FlxColor
|
||||||
{
|
{
|
||||||
|
if (waveformColor == value) return value;
|
||||||
|
|
||||||
waveformColor = value;
|
waveformColor = value;
|
||||||
// We don't need to dirty the waveform geometry, just rebuild the texture.
|
// We don't need to dirty the waveform geometry, just rebuild the texture.
|
||||||
rebuildGraphic();
|
rebuildGraphic();
|
||||||
|
@ -49,6 +59,8 @@ class WaveformSprite extends MeshRender
|
||||||
|
|
||||||
function set_orientation(value:WaveformOrientation):WaveformOrientation
|
function set_orientation(value:WaveformOrientation):WaveformOrientation
|
||||||
{
|
{
|
||||||
|
if (orientation == value) return value;
|
||||||
|
|
||||||
orientation = value;
|
orientation = value;
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return orientation;
|
return orientation;
|
||||||
|
@ -61,6 +73,8 @@ class WaveformSprite extends MeshRender
|
||||||
|
|
||||||
function set_time(value:Float)
|
function set_time(value:Float)
|
||||||
{
|
{
|
||||||
|
if (time == value) return value;
|
||||||
|
|
||||||
time = value;
|
time = value;
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return time;
|
return time;
|
||||||
|
@ -74,6 +88,8 @@ class WaveformSprite extends MeshRender
|
||||||
|
|
||||||
function set_duration(value:Float)
|
function set_duration(value:Float)
|
||||||
{
|
{
|
||||||
|
if (duration == value) return value;
|
||||||
|
|
||||||
duration = value;
|
duration = value;
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return duration;
|
return duration;
|
||||||
|
@ -84,6 +100,8 @@ class WaveformSprite extends MeshRender
|
||||||
*/
|
*/
|
||||||
override function set_height(value:Float):Float
|
override function set_height(value:Float):Float
|
||||||
{
|
{
|
||||||
|
if (height == value) return super.set_height(value);
|
||||||
|
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return super.set_height(value);
|
return super.set_height(value);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +111,8 @@ class WaveformSprite extends MeshRender
|
||||||
*/
|
*/
|
||||||
override function set_width(value:Float):Float
|
override function set_width(value:Float):Float
|
||||||
{
|
{
|
||||||
|
if (width == value) return super.set_width(value);
|
||||||
|
|
||||||
isWaveformDirty = true;
|
isWaveformDirty = true;
|
||||||
return super.set_width(value);
|
return super.set_width(value);
|
||||||
}
|
}
|
||||||
|
@ -108,13 +128,15 @@ class WaveformSprite extends MeshRender
|
||||||
this.orientation = orientation ?? DEFAULT_ORIENTATION;
|
this.orientation = orientation ?? DEFAULT_ORIENTATION;
|
||||||
this.time = 0.0;
|
this.time = 0.0;
|
||||||
this.duration = duration ?? DEFAULT_DURATION;
|
this.duration = duration ?? DEFAULT_DURATION;
|
||||||
|
|
||||||
|
this.forceUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function update(elapsed:Float)
|
public override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
if (isWaveformDirty)
|
if (forceUpdate || isWaveformDirty)
|
||||||
{
|
{
|
||||||
// Recalculate the waveform vertices.
|
// Recalculate the waveform vertices.
|
||||||
drawWaveform();
|
drawWaveform();
|
||||||
|
|
Loading…
Reference in a new issue