aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/gui_lol.h
blob: 8772dfe382c3061c7756b2c6175afb27e0331719 (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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#ifdef ENABLE_LOL

#ifndef KYRA_GUI_LOL_H
#define KYRA_GUI_LOL_H

#include "kyra/gui.h"

namespace Kyra {
#define GUI_LOL_MENU(menu, a, b, c, d, e, f, g, i) \
	do { \
		const ScreenDim *dim = _screen->getScreenDim(a); \
		menu.x = (dim->sx << 3); \
		menu.y = (dim->sy); \
		menu.width = (dim->w << 3); \
		menu.height = (dim->h); \
		if (_vm->gameFlags().use16ColorMode) { \
		menu.bkgdColor = 0xcc; \
		menu.color1 = 0xff; \
		menu.color2 = 0xdd; \
		} else { \
		menu.bkgdColor = 225; \
		menu.color1 = 223; \
		menu.color2 = 227; \
		} \
		menu.menuNameId = b; \
		menu.highlightedItem = c; \
		menu.numberOfItems = d; \
		menu.titleX = (dim->sx << 3) + (dim->w << 2); \
		menu.titleY = 6; \
		menu.textColor = _vm->gameFlags().use16ColorMode ? 0xe1 : 254; \
		menu.scrollUpButtonX = e; \
		menu.scrollUpButtonY = f; \
		menu.scrollDownButtonX = g; \
		menu.scrollDownButtonY = i; \
	} while (0)

	#define GUI_LOL_MENU_ITEM(item, a, b, c, d, e, f, g) \
	do { \
		item.enabled = 1; \
		item.itemId = a; \
		item.itemString = 0; \
		item.x = b; \
		item.y = c; \
		item.width = d; \
		item.height = e; \
		item.textColor =  _vm->gameFlags().use16ColorMode ? 0xc1 : 204;; \
		item.highlightColor = _vm->gameFlags().use16ColorMode ? 0xe1 : 254; \
		item.titleX = -1; \
		if (_vm->gameFlags().use16ColorMode) { \
		item.bkgdColor = 0xcc; \
		item.color1 = 0xff; \
		item.color2 = 0xdd; \
		} else { \
		item.bkgdColor = 225; \
		item.color1 = 223; \
		item.color2 = 227; \
		} \
		item.saveSlot = 0; \
		item.labelId = f; \
		item.labelString = 0; \
		item.labelX = 0; \
		item.labelY = 0; \
		item.keyCode = g; \
	} while (0)

class LoLEngine;
class Screen_LoL;

class GUI_LoL : public GUI {
	friend class LoLEngine;
public:
	GUI_LoL(LoLEngine *vm);

	void initStaticData();

	// button specific
	void processButton(Button *button);
	int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel);

	int redrawShadedButtonCallback(Button *button);
	int redrawButtonCallback(Button *button);

	int runMenu(Menu &menu);

	// utilities for thumbnail creation
	void createScreenThumbnail(Graphics::Surface &dst);

private:
	void backupPage0();
	void restorePage0();

	void setupSavegameNames(Menu &menu, int num);

	void printMenuText(const char *str, int x, int y, uint8 c0, uint8 c1, uint8 flags, Screen::FontId font=Screen::FID_9_FNT);
	int getMenuCenterStringX(const char *str, int x1, int x2);

	int getInput();

	int clickedMainMenu(Button *button);
	int clickedLoadMenu(Button *button);
	int clickedSaveMenu(Button *button);
	int clickedDeleteMenu(Button *button);
	int clickedOptionsMenu(Button *button);
	int clickedAudioMenu(Button *button);
	int clickedDeathMenu(Button *button);
	int clickedSavenameMenu(Button *button);
	int clickedChoiceMenu(Button *button);

	int scrollUp(Button *button);
	int scrollDown(Button *button);

	Button *getButtonListData() { return _menuButtons; }
	Button *getScrollUpButton() { return &_scrollUpButton; }
	Button *getScrollDownButton() { return &_scrollDownButton; }


	Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
	Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }

	uint8 defaultColor1() const { return 0xFE; }
	uint8 defaultColor2() const { return 0x00; }

	const char *getMenuTitle(const Menu &menu);
	const char *getMenuItemTitle(const MenuItem &menuItem);
	const char *getMenuItemLabel(const MenuItem &menuItem);

	Button _menuButtons[10];
	Button _scrollUpButton;
	Button _scrollDownButton;
	Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu;
	Menu *_currentMenu, *_lastMenu, *_newMenu;
	int _menuResult;
	char *_saveDescription;

	LoLEngine *_vm;
	Screen_LoL *_screen;

	bool _pressFlag;

	Button *_specialProcessButton;
	Button *_backUpButtonList;
	bool _buttonListChanged;
	uint16 _flagsModifier;
	uint8 _mouseClick;

	int _savegameOffset;
	int _sliderSfx;

	Button::Callback _scrollUpFunctor;
	Button::Callback _scrollDownFunctor;
};

} // End of namespace Kyra

#endif

#endif // ENABLE_LOL