1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef SWORD1_MENU_H
24 #define SWORD1_MENU_H
25 
26 #include "sword1/sworddefs.h"
27 #include "sword1/object.h"
28 
29 namespace Sword1 {
30 
31 class Screen;
32 class Mouse;
33 class ResMan;
34 
35 #define MENU_TOP 0
36 #define MENU_BOT 1
37 
38 struct Subject {
39 	uint32 subjectRes;
40 	uint32 frameNo;
41 };
42 
43 struct MenuObject {
44 	int32 textDesc;
45 	uint32 bigIconRes;
46 	uint32 bigIconFrame;
47 	uint32 luggageIconRes;
48 	uint32 useScript;
49 };
50 
51 class MenuIcon {
52 public:
53 	MenuIcon(uint8 menuType, uint8 menuPos, uint32 resId, uint32 frame, Screen *screen);
54 	bool wasClicked(uint16 mouseX, uint16 mouseY);
55 	void setSelect(bool pSel);
56 	void draw(const byte *fadeMask = NULL, int8 fadeStatus = 0);
57 
58 private:
59 	uint8 _menuType, _menuPos;
60 	uint32 _resId, _frame;
61 	bool _selected;
62 	Screen *_screen;
63 };
64 
65 class Menu {
66 public:
67 	Menu(Screen *pScreen, Mouse *pMouse);
68 	~Menu();
69 	void fnChooser(Object *compact);
70 	void fnEndChooser();
71 	void fnAddSubject(int32 sub);
72 	void cfnReleaseMenu();
73 	int logicChooser(Object *compact);
74 	void engine();
75 	void refresh(uint8 menuType);
76 	void fnStartMenu();
77 	void fnEndMenu();
78 	void checkTopMenu();
79 	static const MenuObject _objectDefs[TOTAL_pockets + 1];
80 
81 private:
82 	void buildSubjects();
83 	void buildMenu();
84 	void showMenu(uint8 menuType);
85 	byte _subjectBarStatus;
86 	byte _objectBarStatus;
87 	int8 _fadeSubject;
88 	int8 _fadeObject;
89 	void refreshMenus();
90 	uint8 checkMenuClick(uint8 menuType);
91 	//- lower menu, speech subjects:
92 	MenuIcon *_subjects[16];
93 	uint32 _subjectBar[16];
94 	//- top menu, items
95 	MenuIcon *_objects[TOTAL_pockets];
96 	uint32 _menuList[TOTAL_pockets];
97 	uint32 _inMenu;
98 
99 	Screen *_screen;
100 	Mouse *_mouse;
101 	static const Subject _subjectList[TOTAL_subjects];
102 
103 	static const byte _fadeEffectTop[64];
104 	static const byte _fadeEffectBottom[64];
105 };
106 
107 } // End of namespace Sword1
108 
109 #endif //BSMENU_H
110