2010-11-24 05:43:16 +00:00
|
|
|
#include "key.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
#include "gui/Text.h"
|
|
|
|
#include "CvarToggleView.h"
|
2010-12-16 11:01:49 +00:00
|
|
|
#include "CvarToggle.h"
|
2010-11-24 05:43:16 +00:00
|
|
|
|
|
|
|
@implementation CvarToggleView
|
|
|
|
|
|
|
|
-(void)update
|
|
|
|
{
|
|
|
|
[value setText:[toggle value] ? "On" : "Off"];
|
|
|
|
}
|
|
|
|
|
2011-01-09 10:41:24 +00:00
|
|
|
-(id)initWithBounds:(Rect)aRect title:(string)_title :(CvarToggle [])_toggle
|
2010-11-24 05:43:16 +00:00
|
|
|
{
|
|
|
|
local Rect rect;
|
|
|
|
|
|
|
|
self = [super initWithBounds:aRect];
|
|
|
|
|
|
|
|
toggle = _toggle;
|
|
|
|
|
|
|
|
rect = makeRect (0, 0, strlen (_title) * 8, 8);
|
|
|
|
title = [[Text alloc] initWithBounds:rect text:_title];
|
|
|
|
|
|
|
|
rect.size.width = 3 * 8;
|
|
|
|
rect.origin.x = xlen - rect.size.width;
|
|
|
|
value = [[Text alloc] initWithBounds:rect];
|
|
|
|
|
|
|
|
[self addView:title];
|
|
|
|
[self addView:value];
|
|
|
|
|
|
|
|
[self update];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)toggle
|
|
|
|
{
|
|
|
|
[toggle toggle];
|
|
|
|
[self update];
|
|
|
|
S_LocalSound ("misc/menu3.wav");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (integer) keyEvent:(integer)key unicode:(integer)unicode down:(integer)down
|
|
|
|
{
|
|
|
|
switch (key) {
|
|
|
|
case QFK_RETURN:
|
|
|
|
case QFM_BUTTON1:
|
|
|
|
[self toggle];
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|