2010-11-24 05:43:16 +00:00
|
|
|
#include "cvar.h"
|
|
|
|
|
|
|
|
#include "options_util.h"
|
|
|
|
#include "CvarRange.h"
|
|
|
|
|
|
|
|
@implementation CvarRange
|
|
|
|
|
|
|
|
-(id)initWithCvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step
|
|
|
|
{
|
|
|
|
self = [super initWithCvar: cvname];
|
|
|
|
|
|
|
|
min = _min;
|
|
|
|
max = _max;
|
|
|
|
step = _step;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)inc
|
|
|
|
{
|
|
|
|
local float val = Cvar_GetFloat (name);
|
|
|
|
val = min_max_cnt (min, max, step, val, 1);
|
|
|
|
Cvar_SetFloat (name, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)dec
|
|
|
|
{
|
|
|
|
local float val = Cvar_GetFloat (name);
|
|
|
|
val = min_max_cnt (min, max, step, val, 0);
|
|
|
|
Cvar_SetFloat (name, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
-(float)value
|
|
|
|
{
|
|
|
|
return Cvar_GetFloat (name);
|
|
|
|
}
|
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
-(int)percentage
|
2010-11-24 05:43:16 +00:00
|
|
|
{
|
|
|
|
return to_percentage(min, max, Cvar_GetFloat (name));
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|