aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/gui_hof.h
blob: f48f6c88c99f0eec00537bdd4fd276f73021d64b (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
/* 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$
 *
 */

#ifndef KYRA_GUI_HOF_H
#define KYRA_GUI_HOF_H

#include "kyra/gui_v2.h"

namespace Kyra {

class KyraEngine_HoF;
class Screen_HoF;

class GUI_HoF : public GUI_v2 {
friend class KyraEngine_HoF;
public:
	GUI_HoF(KyraEngine_HoF *engine);

	int optionsButton(Button *button);
private:
	void getInput();

	Button _menuButtons[7];
	Button _scrollUpButton;
	Button _scrollDownButton;
	Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
	void initStaticData();

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

	Button *getButtonListData() { return _menuButtons; }

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

	int scrollUpButton(Button *button);
	int scrollDownButton(Button *button);
	Button::Callback _scrollUpFunctor;
	Button::Callback _scrollDownFunctor;
	Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
	Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }

	Button _sliderButtons[3][4];

	uint8 defaultColor1() const { return 0xCF; }
	uint8 defaultColor2() const { return 0xF8; }

	void renewHighlight(Menu &menu);

	void setupPalette();
	void restorePalette();

	void backUpPage1(uint8 *buffer);
	void restorePage1(const uint8 *buffer);

	void resetState(int item);

	KyraEngine_HoF *_vm;
	Screen_HoF *_screen;

	Menu *_currentMenu;
	bool _isLoadMenu;
	bool _isDeathMenu;
	bool _isSaveMenu;
	bool _isDeleteMenu;
	bool _isChoiceMenu;
	bool _isOptionsMenu;
	bool _madeSave;
	bool _loadedSave;
	bool _restartGame;
	bool _reloadTemporarySave;

	int _savegameOffset;

	void setupSavegameNames(Menu &menu, int num);

	// main menu
	int quitGame(Button *caller);
	int resumeGame(Button *caller);

	// options menu
	int gameOptions(Button *caller);
	int gameOptionsTalkie(Button *caller);
	int quitOptionsMenu(Button *caller);

	int toggleWalkspeed(Button *caller);
	int changeLanguage(Button *caller);
	int toggleText(Button *caller);

	void setupOptionsButtons();

	// audio menu
	int audioOptions(Button *caller);

	Button::Callback _sliderHandlerFunctor;
	int sliderHandler(Button *caller);

	void drawSliderBar(int slider, const uint8 *shape);

	static const int _sliderBarsPosition[];

	// load menu
	bool _noLoadProcess;
	int loadMenu(Button *caller);
	int clickLoadSlot(Button *caller);
	int cancelLoadMenu(Button *caller);

	// save menu
	bool _noSaveProcess;
	int _saveSlot;
	char _saveDescription[0x50];

	int saveMenu(Button *caller);
	int clickSaveSlot(Button *caller);
	int cancelSaveMenu(Button *caller);

	// delete menu
	int _slotToDelete;
	int deleteMenu(Button *caller);

	// savename menu
	bool _finishNameInput, _cancelNameInput;
	Common::KeyState _keyPressed;

	const char *nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize);
	int finishSavename(Button *caller);
	int cancelSavename(Button *caller);

	bool checkSavegameDescription(const char *buffer, int size);
	int getCharWidth(uint8 c);
	void checkTextfieldInput();
	void drawTextfieldBlock(int x, int y, uint8 c);

	// choice menu
	bool _choice;

	bool choiceDialog(int name, bool type);
	int choiceYes(Button *caller);
	int choiceNo(Button *caller);

	static const uint16 _menuStringsTalkie[];
	static const uint16 _menuStringsOther[];
};

} // end of namespace Kyra

#endif