in_mouse_amp finally working properly :)

forced to move to CMV for the indicator because I ran out of params...
This commit is contained in:
Bill Currie 2004-02-04 06:56:53 +00:00
parent 8a14e30896
commit c3d99b47a7
3 changed files with 68 additions and 25 deletions

View File

@ -41,7 +41,7 @@
Slider gamma_slider;
Slider viewsize_slider;
CvarRange mouse_amp_range;
RangeSlider mouse_amp_range;
Slider volume_slider;
Slider bgmvolume_slider;
@ -58,7 +58,7 @@ Slider bgmvolume_slider;
#define MIN_MOUSE_AMP 0
#define MAX_MOUSE_AMP 60
#define MOUSE_AMP_STEP 2
#define MOUSE_AMP_STEP 1
#define MIN_VOLUME 0
#define MAX_VOLUME 1.5
@ -415,7 +415,7 @@ MENU_control_options =
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
Menu_Draw (DRAW_control_options);
mouse_amp_range = [[CvarRange alloc] initWithBounds:[[Rect alloc] initWithComponents:70 :100 :240 :8] title:"Mouse amp:" cvar:"in_mouse_amp" min:MIN_MOUSE_AMP max:MAX_MOUSE_AMP step:MOUSE_AMP_STEP];
mouse_amp_range = [[RangeSlider alloc] initWithBounds:[[Rect alloc] initWithComponents:70 :100 :232 :8] title:"Mouse amp:" sliderWidth:14 * 8 :[[CvarRange alloc] initWithCvar:"in_mouse_amp" min:MIN_MOUSE_AMP max:MAX_MOUSE_AMP step:MOUSE_AMP_STEP]];
MENU_control_binding ();

View File

@ -6,15 +6,26 @@
@class Text;
@class Slider;
@interface CvarRange : Group
@interface CvarRange : Object
{
string name;
float min, max, step;
}
-(id)initWithCvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step;
-(void)inc;
-(void)dec;
-(float)value;
-(integer)percentage;
@end
@interface RangeSlider : Group
{
Text title;
Text value;
Slider slider;
string name;
float min, max, step;
CvarRange range;
}
-(id)initWithBounds:(Rect)aRect title:(string)_title cvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step;
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange)_range;
-(void)inc;
-(void)dec;
@end

View File

@ -35,24 +35,66 @@
@implementation CvarRange
-(void)update
-(id)initWithCvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step
{
local float val = cvar (name);
[slider setIndex: to_percentage(min, max, val)];
[value setText:ftos (val)];
name = str_new ();
str_copy (name, cvname);
min = _min;
max = _max;
step = _step;
return self;
}
-(id)initWithBounds:(Rect)aRect title:(string)_title cvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step
-(void)inc
{
local float val = cvar (name);
val = min_max_cnt (min, max, step, val, 1);
cvar_set (name, ftos (val));
}
-(void)dec
{
local float val = cvar (name);
val = min_max_cnt (min, max, step, val, 0);
cvar_set (name, ftos (val));
}
-(float)value
{
return cvar (name);
}
-(integer)percentage
{
return to_percentage(min, max, cvar (name));
}
@end
@implementation RangeSlider
-(void)update
{
[slider setIndex:[range percentage]];
[value setText:ftos ([range value])];
}
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange)_range
{
local Rect rect;
self = [super initWithBounds:aRect];
range = _range;
rect = [[Rect alloc] initWithComponents:0 :0 :strlen (_title) * 8 :8];
title = [[Text alloc] initWithBounds:rect text:_title];
rect.origin.x += rect.size.width + 8;
rect.size.width = ((_max - _min) / _step + 2) * 8 / 2;
rect.size.width = width;
if (rect.origin.x + rect.size.width > xlen)
rect.size.width = xlen - rect.origin.x;
slider = [[Slider alloc] initWithBounds:rect size:100];
rect.origin.x += rect.size.width + 8;
@ -63,12 +105,6 @@
[self addView:slider];
[self addView:value];
name = str_new ();
str_copy (name, cvname);
min = _min;
max = _max;
step = _step;
[self update];
return self;
@ -76,17 +112,13 @@
-(void)inc
{
local float val = cvar (name);
val = min_max_cnt (min, max, step, val, 1);
cvar_set (name, ftos (val));
[range inc];
[self update];
}
-(void)dec
{
local float val = cvar (name);
val = min_max_cnt (min, max, step, val, 0);
cvar_set (name, ftos (val));
[range dec];
[self update];
}