summaryrefslogtreecommitdiff
path: root/src/menu.h
blob: 1f610b24e072db6b391431271f7c14e36cc46790 (plain)
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
// Menu.h

#pragma once

#include <unordered_map>
#include "def.h"

/////////////////////////////////////////////////////////////////////////////

class CMenu
{
public:
	CMenu();
	~CMenu();

	bool	Create(CPixmap *pPixmap, CSound *pSound,
				   POINT pos, Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
				   std::unordered_map<Sint32, const char *> &texts,
				   Sint32 perso);
	void	Update(Sint32 nb, Sint32 *pButtons, Sint32 *pErrors,
				   std::unordered_map<Sint32, const char *> &texts);
	void	Delete();
	void	Draw();
	Sint32		GetSel();
	Sint32		GetRank();
	bool	IsError();
	bool	IsExist();
	void	Message();

	bool	TreatEvent(const SDL_Event &event);

protected:
	Sint32		Detect(POINT pos);
	bool	MouseDown(POINT pos);
	bool	MouseMove(POINT pos);
	bool	MouseUp(POINT pos);

protected:
	CPixmap*	m_pPixmap;
	CDecor*		m_pDecor;
	CSound*		m_pSound;
	POINT		m_pos;			// coin sup/gauche
	POINT		m_dim;			// dimensions
	Sint32			m_nbButtons;
	POINT		m_nbCel;
	Sint32			m_perso;
	Sint32			m_buttons[MAXBUTTON];
	Sint32			m_errors[MAXBUTTON];
	std::unordered_map<Sint32, const char *> m_texts;
	Uint32		m_messages[MAXBUTTON];
	Sint32			m_selRank;
};

/////////////////////////////////////////////////////////////////////////////