File: menu.h

package info (click to toggle)
enemylines3 1.2-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,380 kB
  • ctags: 1,444
  • sloc: cpp: 16,323; makefile: 74; sh: 52
file content (83 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __el3__menu_h
#define __el3__menu_h

#include <iostream>
#include <vector>

#include "coordinate.h"

class Menuitem;

typedef void (*menufun)(Menuitem *);


typedef enum E_Menuid {
	MI_LAST=0,
	MI_UNHANDLED=-1,
	MI_SUB=-2,
	MI_POP=-3,
	MI_INACTIVE=-4,
	MI_NONE=-5
};

class Menuitem {
public:
	std::vector <Menuitem> items;
	Menuitem *parent;
	std::string text;
	int id;
	menufun fun;

	void init() {
		fun=NULL;
		parent=NULL;
		id=MI_NONE;
		text="";
	}

	Menuitem() {init();};
	Menuitem(std::string s,int i) {init(); text=s; id=i;}
	Menuitem(menufun f,int i) {init(); fun=f; id=i;}
};

class Menu {
	Menuitem baseitem;
	Menuitem *current;
	Menuitem *addcurrent;
	int selected;
	void handle(int id);
	int scale;
	C3 offset;
	unsigned int font,font_selected;
public:

	Menu();
	Menu(C3 os);

	bool isactive() { return current!=NULL; }

	void reset();

	

	void add(Menuitem i);
	void sub();
	void parent();

	void select(int x,int y);

	void select(int s);
	void move_select(int c);

	void draw();
	int get(); 
	Menuitem *get_item();
	int click(int x,int y);

	void pop();

	int handle_event(SDL_Event event);

};

#endif