aboutsummaryrefslogtreecommitdiff
path: root/src/ui/menuframework/menuframework.hpp
blob: 61e246b737fb3464463c4bd27310ee1c575c67f5 (plain) (blame)
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
#ifndef BLRMENUFW_H
#define BLRMENUFW_H
#include "smelt.hpp"
#include "smbmfont.hpp"
typedef bool (*smHooki)(int);
class menuCtrlLCD
{
protected:
	static SMELT *sm;
private:
	smHooki keyPressedf;
	bool overlen;
	const char *tl,*tr;
	int scv,scd,maxw,skv,skd;
	char rt[64];
public:
	int id;
	bool enabled,selected;
	DWORD color;
	menuCtrlLCD *next,*last;
	smBMFont *fnt;
	menuCtrlLCD(int _id,int mw,smBMFont *font)
	{
		sm=smGetInterface(SMELT_APILEVEL);enabled=true;keyPressedf=NULL;
		color=0xFFFFFFFF;id=_id;maxw=mw;fnt=font;skv=skd=0;next=last=NULL;
	}
	virtual ~menuCtrlLCD(){sm->smRelease();}
	void render(float x,float y);
	void update();
	virtual void updateHook(){}
	void setText(const char *l,const char *r);
	void onKeyPressed(smHooki kpf){keyPressedf=kpf;}//parameter is the key pressed. The return value has no effect.
	void shake(int intv,int dur){skv=intv;skd=dur;}
	bool ikp(){if(keyPressedf)return keyPressedf(sm->smGetKey());else return false;}
};
class menuLCD
{
private:
	static SMELT *sm;
	float itemh,x,y;
	int maxw,rows,selected;
	menuCtrlLCD *ctrls;
	smBMFont *fnt;
public:
	menuLCD(float ih,int mw,int rowc,float _x,float _y,smBMFont *font)
	{
		ctrls=NULL;selected=0;sm=smGetInterface(SMELT_APILEVEL);
		maxw=mw;itemh=ih;rows=rowc;x=_x;y=_y;fnt=font;
	}
	~menuLCD(){menuCtrlLCD *c,*n;c=ctrls;while(c){n=c->next;delete c;c=n;}sm->smRelease();}
	void addCtrl(menuCtrlLCD *ctrl);
	menuCtrlLCD* getCtrl(int id);
	bool update();
	void render();
};
#endif