mirror of
https://github.com/MapMakersAndProgrammers/TankiOnline2.0DemoClient.git
synced 2025-10-26 01:49:11 -07:00
41 lines
1.1 KiB
ActionScript
41 lines
1.1 KiB
ActionScript
package alternativa.osgi.service.console.variables
|
|
{
|
|
public class ConsoleVarFloat extends ConsoleVar
|
|
{
|
|
public var value:Number;
|
|
|
|
private var minValue:Number;
|
|
|
|
private var maxValue:Number;
|
|
|
|
public function ConsoleVarFloat(consoleVarName:String, initialValue:Number, minValue:Number, maxValue:Number, changeListener:Function = null)
|
|
{
|
|
super(consoleVarName,changeListener);
|
|
this.value = initialValue;
|
|
this.minValue = minValue;
|
|
this.maxValue = maxValue;
|
|
}
|
|
|
|
override protected function acceptInput(value:String) : String
|
|
{
|
|
var f:Number = Number(Number(value));
|
|
if(isNaN(f))
|
|
{
|
|
return "Incorrect number";
|
|
}
|
|
if(f < this.minValue || f > this.maxValue)
|
|
{
|
|
return "Value is out of bounds [" + this.minValue + ", " + this.maxValue + "]";
|
|
}
|
|
this.value = f;
|
|
return null;
|
|
}
|
|
|
|
override public function toString() : String
|
|
{
|
|
return this.value.toString();
|
|
}
|
|
}
|
|
}
|
|
|