mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
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:
parent
8a14e30896
commit
c3d99b47a7
3 changed files with 68 additions and 25 deletions
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
Slider gamma_slider;
|
Slider gamma_slider;
|
||||||
Slider viewsize_slider;
|
Slider viewsize_slider;
|
||||||
CvarRange mouse_amp_range;
|
RangeSlider mouse_amp_range;
|
||||||
Slider volume_slider;
|
Slider volume_slider;
|
||||||
Slider bgmvolume_slider;
|
Slider bgmvolume_slider;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ Slider bgmvolume_slider;
|
||||||
|
|
||||||
#define MIN_MOUSE_AMP 0
|
#define MIN_MOUSE_AMP 0
|
||||||
#define MAX_MOUSE_AMP 60
|
#define MAX_MOUSE_AMP 60
|
||||||
#define MOUSE_AMP_STEP 2
|
#define MOUSE_AMP_STEP 1
|
||||||
|
|
||||||
#define MIN_VOLUME 0
|
#define MIN_VOLUME 0
|
||||||
#define MAX_VOLUME 1.5
|
#define MAX_VOLUME 1.5
|
||||||
|
@ -415,7 +415,7 @@ MENU_control_options =
|
||||||
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||||
|
|
||||||
Menu_Draw (DRAW_control_options);
|
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 ();
|
MENU_control_binding ();
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,26 @@
|
||||||
@class Text;
|
@class Text;
|
||||||
@class Slider;
|
@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 title;
|
||||||
Text value;
|
Text value;
|
||||||
Slider slider;
|
Slider slider;
|
||||||
string name;
|
CvarRange range;
|
||||||
float min, max, step;
|
|
||||||
}
|
}
|
||||||
-(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)inc;
|
||||||
-(void)dec;
|
-(void)dec;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -35,24 +35,66 @@
|
||||||
|
|
||||||
@implementation CvarRange
|
@implementation CvarRange
|
||||||
|
|
||||||
-(void)update
|
-(id)initWithCvar:(string)cvname min:(float)_min max:(float)_max step:(float)_step
|
||||||
{
|
{
|
||||||
local float val = cvar (name);
|
name = str_new ();
|
||||||
[slider setIndex: to_percentage(min, max, val)];
|
str_copy (name, cvname);
|
||||||
[value setText:ftos (val)];
|
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;
|
local Rect rect;
|
||||||
|
|
||||||
self = [super initWithBounds:aRect];
|
self = [super initWithBounds:aRect];
|
||||||
|
|
||||||
|
range = _range;
|
||||||
|
|
||||||
rect = [[Rect alloc] initWithComponents:0 :0 :strlen (_title) * 8 :8];
|
rect = [[Rect alloc] initWithComponents:0 :0 :strlen (_title) * 8 :8];
|
||||||
title = [[Text alloc] initWithBounds:rect text:_title];
|
title = [[Text alloc] initWithBounds:rect text:_title];
|
||||||
|
|
||||||
rect.origin.x += rect.size.width + 8;
|
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];
|
slider = [[Slider alloc] initWithBounds:rect size:100];
|
||||||
|
|
||||||
rect.origin.x += rect.size.width + 8;
|
rect.origin.x += rect.size.width + 8;
|
||||||
|
@ -63,12 +105,6 @@
|
||||||
[self addView:slider];
|
[self addView:slider];
|
||||||
[self addView:value];
|
[self addView:value];
|
||||||
|
|
||||||
name = str_new ();
|
|
||||||
str_copy (name, cvname);
|
|
||||||
min = _min;
|
|
||||||
max = _max;
|
|
||||||
step = _step;
|
|
||||||
|
|
||||||
[self update];
|
[self update];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -76,17 +112,13 @@
|
||||||
|
|
||||||
-(void)inc
|
-(void)inc
|
||||||
{
|
{
|
||||||
local float val = cvar (name);
|
[range inc];
|
||||||
val = min_max_cnt (min, max, step, val, 1);
|
|
||||||
cvar_set (name, ftos (val));
|
|
||||||
[self update];
|
[self update];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)dec
|
-(void)dec
|
||||||
{
|
{
|
||||||
local float val = cvar (name);
|
[range dec];
|
||||||
val = min_max_cnt (min, max, step, val, 0);
|
|
||||||
cvar_set (name, ftos (val));
|
|
||||||
[self update];
|
[self update];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue