1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-11-29 15:56:06 +00:00

fix min, max

This commit is contained in:
lemz 2024-06-22 15:38:04 +02:00 committed by EliteMasterEric
parent 437cc68ba7
commit 0fe726cefa
2 changed files with 18 additions and 54 deletions

View file

@ -42,50 +42,6 @@ class NoteKind implements INoteScriptedClass
return noteKind; return noteKind;
} }
/**
* Retrieve the value of the param with the given name
* If there exists no param with the given name then `null` is returned
* @param name Name of the param
* @return Null<Dynamic>
*/
public function getParam(name:String):Null<Dynamic>
{
for (param in params)
{
if (param.name == name)
{
return param.data.value;
}
}
return null;
}
/**
* Set the value of the param with the given name
* @param name Name of the param
* @param value New value
*/
public function setParam(name:String, value:Dynamic):Void
{
for (param in params)
{
if (param.name == name)
{
if (param.type == NoteKindParamType.INT || param.type == NoteKindParamType.FLOAT)
{
param.data.value = FlxMath.bound(value, param.data.min, param.data.max);
}
else
{
param.data.value = value;
}
break;
}
}
}
/** /**
* Retrieve all notes of this kind * Retrieve all notes of this kind
* @return Array<NoteSprite> * @return Array<NoteSprite>
@ -131,14 +87,14 @@ typedef NoteKindParamData =
/** /**
* If `min` is null, there is no minimum * If `min` is null, there is no minimum
*/ */
var min:Null<Float>; ?min:Null<Float>,
/** /**
* If `max` is null, there is no maximum * If `max` is null, there is no maximum
*/ */
var max:Null<Float>; ?max:Null<Float>,
var value:Dynamic; defaultValue:Dynamic
} }
/** /**
@ -146,8 +102,8 @@ typedef NoteKindParamData =
*/ */
typedef NoteKindParam = typedef NoteKindParam =
{ {
var name:String; name:String,
var description:String; description:String,
var type:NoteKindParamType; type:NoteKindParamType,
var data:NoteKindParamData; data:NoteKindParamData
} }

View file

@ -82,13 +82,21 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
paramLabel.horizontalAlign = "right"; paramLabel.horizontalAlign = "right";
var paramStepper:NumberStepper = new NumberStepper(); var paramStepper:NumberStepper = new NumberStepper();
paramStepper.min = param.data.min; paramStepper.value = param.data.defaultValue;
paramStepper.max = param.data.max;
paramStepper.value = param.data.value;
paramStepper.precision = 1; paramStepper.precision = 1;
paramStepper.step = 0.1; paramStepper.step = 0.1;
paramStepper.percentWidth = 100; paramStepper.percentWidth = 100;
// this check should be unnecessary but for some reason even when min or max is null it will set it to 0
if (param.data.min != null)
{
paramStepper.min = param.data.min;
}
if (param.data.max != null)
{
paramStepper.max = param.data.max;
}
addNoteKindParam(paramLabel, paramStepper); addNoteKindParam(paramLabel, paramStepper);
} }
} }