2010-11-24 05:43:16 +00:00
|
|
|
#include "key.h"
|
|
|
|
#include "sound.h"
|
|
|
|
|
|
|
|
#include "Array.h"
|
|
|
|
|
|
|
|
#include "options_util.h"
|
|
|
|
#include "MenuGroup.h"
|
|
|
|
|
|
|
|
@implementation MenuGroup
|
|
|
|
-(id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
current = base = 0;
|
2011-02-14 14:08:18 +00:00
|
|
|
return self;
|
2010-11-24 05:43:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setBase:(integer)b
|
|
|
|
{
|
|
|
|
if (b >= [views count])
|
|
|
|
b = [views count] - 1;
|
|
|
|
if (b < 0)
|
|
|
|
b = 0;
|
|
|
|
current = base = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (integer) keyEvent:(integer)key unicode:(integer)unicode down:(integer)down
|
|
|
|
{
|
|
|
|
switch (key) {
|
|
|
|
case QFK_DOWN:
|
|
|
|
case QFM_WHEEL_DOWN:
|
|
|
|
[self next];
|
|
|
|
return 1;
|
|
|
|
case QFK_UP:
|
|
|
|
case QFM_WHEEL_UP:
|
|
|
|
[self prev];
|
|
|
|
return 1;
|
|
|
|
default:
|
2010-12-12 01:27:51 +00:00
|
|
|
return [[views objectAtIndex: current]
|
|
|
|
keyEvent: key
|
|
|
|
unicode: unicode
|
|
|
|
down: down];
|
2010-11-24 05:43:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) next
|
|
|
|
{
|
|
|
|
if (++current >= [views count])
|
|
|
|
current = base;
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) prev
|
|
|
|
{
|
|
|
|
if (--current < base)
|
|
|
|
current = [views count] - 1;
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) draw
|
|
|
|
{
|
2011-02-14 14:08:18 +00:00
|
|
|
local View *cur;
|
2010-11-24 05:43:16 +00:00
|
|
|
|
|
|
|
[super draw];
|
2011-01-09 10:41:24 +00:00
|
|
|
cur = [views objectAtIndex:current];
|
2010-11-24 05:43:16 +00:00
|
|
|
opt_cursor (cur.xabs - 8, cur.yabs);
|
|
|
|
}
|
|
|
|
@end
|