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
|
|
|
}
|
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
-(void)setBase:(int)b
|
2010-11-24 05:43:16 +00:00
|
|
|
{
|
|
|
|
if (b >= [views count])
|
|
|
|
b = [views count] - 1;
|
|
|
|
if (b < 0)
|
|
|
|
b = 0;
|
|
|
|
current = base = b;
|
|
|
|
}
|
|
|
|
|
2011-03-25 07:46:32 +00:00
|
|
|
- (int) keyEvent:(int)key unicode:(int)unicode down:(int)down
|
2010-11-24 05:43:16 +00:00
|
|
|
{
|
2011-03-25 09:26:10 +00:00
|
|
|
View *cur = [views objectAtIndex: current];
|
|
|
|
int ret = [cur keyEvent: key unicode: unicode down: down];
|
|
|
|
if (!ret) {
|
|
|
|
switch (key) {
|
|
|
|
case QFK_DOWN:
|
2021-11-08 02:20:04 +00:00
|
|
|
//case QFM_WHEEL_DOWN:
|
2011-03-25 09:26:10 +00:00
|
|
|
[self next];
|
|
|
|
return 1;
|
|
|
|
case QFK_UP:
|
2021-11-08 02:20:04 +00:00
|
|
|
//case QFM_WHEEL_UP:
|
2011-03-25 09:26:10 +00:00
|
|
|
[self prev];
|
|
|
|
return 1;
|
|
|
|
}
|
2010-11-24 05:43:16 +00:00
|
|
|
}
|
2011-03-25 09:26:10 +00:00
|
|
|
return ret;
|
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
|