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 #include "bbvs/dialogs.h"
24 #include "common/events.h"
25 #include "gui/widget.h"
26 #include "engines/advancedDetector.h"
27 
28 namespace GUI {
29 class CommandSender;
30 }
31 
32 namespace Bbvs {
33 
34 struct MenuButton {
35 	const char *label;
36 	uint32 cmd;
37 };
38 
39 static const MenuButton kMenuButtons[] = {
40 	// Main menu
41 	{"New Game", kCmdNewGame},
42 	{"Continue", kCmdContinue},
43 	{"Options", kCmdOptions},
44 	{"Mini Games", kCmdMiniGames},
45 	{"Quit", kCmdQuit},
46 	// Options
47 	{"Uninstall", kCmdUninstall},
48 	{"Credits", kCmdCredits},
49 	{"Opening", kCmdOpening},
50 	{"Chicks 'n' Stuff", kCmdChicksNStuff},
51 	{"Back ..", kCmdBack},
52 	// Minigames
53 	{"Hock-A-Loogie", kCmdHockALoogie},
54 	{"Bug Justice", kCmdBugJustice},
55 	{"Court Chaos", kCmdCourtChaos},
56 	{"Air Guitar", kCmdAirGuitar},
57 	{"Back ..", kCmdBack}
58 };
59 
60 static const MenuButton kMenuButtonsRu[] = {
61 	// Main menu
62 	{"\xD0\x9D\xD0\xBE\xD0\xB2\xD0\xB0\xD1\x8F \xD0\xB8\xD0\xB3\xD1\x80\xD0\xB0", kCmdNewGame},
63 	{"\xD0\x9F\xD1\x80\xD0\xBE\xD0\xB4\xD0\xBE\xD0\xBB\xD0\xB6\xD0\xB8\xD1\x82\xD1\x8C", kCmdContinue},
64 	{"\xD0\x95\xD1\x89\xD0\xB5 ..", kCmdOptions},
65 	{"\xD0\x9C\xD0\xB8\xD0\xBD\xD0\xB8 \xD0\x98\xD0\xB3\xD1\x80\xD1\x8B", kCmdMiniGames},
66 	{"\xD0\x92\xD1\x8B\xD1\x85\xD0\xBE\xD0\xB4", kCmdQuit},
67 	// Options
68 	{"\xD0\x94\xD0\xB5\xD0\xB8\xD0\xBD\xD1\x81\xD1\x82\xD0\xB0\xD0\xBB\xD0\xBB\xD1\x8F\xD1\x86\xD0\xB8\xD1\x8F", kCmdUninstall},
69 	{"\xD0\x90\xD0\xB2\xD1\x82\xD0\xBE\xD1\x80\xD1\x8B", kCmdCredits},
70 	{"\xD0\x9F\xD1\x80\xD0\xBE\xD0\xBB\xD0\xBE\xD0\xB3", kCmdOpening},
71 	{"\xD0\xA0\xD0\xB5\xD0\xBA\xD0\xBB\xD0\xB0\xD0\xBC\xD0\xB0", kCmdChicksNStuff},
72 	{"\xD0\x9D\xD0\xB0\xD0\xB7\xD0\xB0\xD0\xB4 ..", kCmdBack},
73 	// Minigames
74 	{"\xD0\xA1\xD0\xBD\xD0\xB0\xD0\xB9\xD0\xBF\xD0\xB5\xD1\x80", kCmdHockALoogie},
75 	{"\xD0\x96\xD1\x83\xD0\xBA\xD0\xBE\xD0\xB6\xD0\xB0\xD1\x80\xD0\xBA\xD0\xB0", kCmdBugJustice},
76 	{"\xD0\x9F\xD1\x82\xD0\xB5\xD0\xBD\xD0\xB8\xD1\x81", kCmdCourtChaos},
77 	{"\xD0\x96\xD0\xB8\xD0\xB2\xD0\xBE\xD0\xB9 \xD0\x97\xD0\xB2\xD1\x83\xD0\xBA", kCmdAirGuitar},
78 	{"\xD0\x9D\xD0\xB0\xD0\xB7\xD0\xB0\xD0\xB4 ..", kCmdBack}
79 };
80 
MainMenu(BbvsEngine * vm)81 MainMenu::MainMenu(BbvsEngine *vm) : Dialog(0, 0, 1, 1), _vm(vm) {
82 	init();
83 }
84 
~MainMenu()85 MainMenu::~MainMenu() {
86 }
87 
init()88 void MainMenu::init() {
89 	_buttons[0] = new GUI::ButtonWidget(this, 0, 0, 1, 1, Common::U32String());
90 	_buttons[1] = new GUI::ButtonWidget(this, 0, 0, 1, 1, Common::U32String());
91 	_buttons[2] = new GUI::ButtonWidget(this, 0, 0, 1, 1, Common::U32String());
92 	_buttons[3] = new GUI::ButtonWidget(this, 0, 0, 1, 1, Common::U32String());
93 	_buttons[4] = new GUI::ButtonWidget(this, 0, 0, 1, 1, Common::U32String());
94 	gotoMenuScreen(kMainMenuScr);
95 }
96 
reflowLayout()97 void MainMenu::reflowLayout() {
98 	const int screenW = _vm->_system->getOverlayWidth();
99 	const int screenH = _vm->_system->getOverlayHeight();
100 
101 	const int buttonWidth = screenW * 70 / 320;
102 	const int buttonHeight = screenH * 14 / 240;
103 	const int buttonPadding = screenW * 3 / 320;
104 
105 	_w = 2 * buttonWidth  + buttonPadding;
106 	_h = 3 * buttonHeight + 3 * buttonPadding;
107 	_x = (screenW - _w) / 2;
108 	_y = screenH - _h - 2;
109 
110 	int x = 0, y = 0;
111 
112 	x = 0;
113 	y = 0;
114 	_buttons[0]->resize(x, y, buttonWidth, buttonHeight);
115 	x += buttonWidth + buttonPadding;
116 	_buttons[1]->resize(x, y, buttonWidth, buttonHeight);
117 
118 	x = 0;
119 	y += buttonHeight + buttonPadding;
120 	_buttons[2]->resize(x, y, buttonWidth, buttonHeight);
121 	x += buttonWidth + buttonPadding;
122 	_buttons[3]->resize(x, y, buttonWidth, buttonHeight);
123 
124 	x = (_w - buttonWidth) / 2; // Center the last button
125 	y += buttonHeight + buttonPadding;
126 	_buttons[4]->resize(x, y, buttonWidth, buttonHeight);
127 
128 	GUI::Dialog::reflowLayout();
129 
130 }
131 
handleCommand(GUI::CommandSender * sender,uint32 command,uint32 data)132 void MainMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 data) {
133 	switch (command) {
134 	// Main menu
135 	case kCmdNewGame:
136 		close();
137 		_vm->newGame();
138 		break;
139 	case kCmdContinue:
140 		close();
141 		_vm->continueGameFromQuickSave();
142 		break;
143 	case kCmdOptions:
144 		gotoMenuScreen(kOptionsMenuScr);
145 		break;
146 	case kCmdMiniGames:
147 		gotoMenuScreen(kMiniGamesMenuScr);
148 		break;
149 	case kCmdQuit:
150 		close();
151 		_vm->quitGame();
152 		break;
153 	// Options menu
154 	case kCmdUninstall:
155 		break;
156 	case kCmdCredits:
157 		gotoScene(45);
158 		break;
159 	case kCmdOpening:
160 		gotoScene(43);
161 		break;
162 	case kCmdChicksNStuff:
163 		gotoScene(41);
164 		break;
165 	// Minigames menu
166 	case kCmdHockALoogie:
167 		gotoScene(27);
168 		break;
169 	case kCmdBugJustice:
170 		gotoScene(29);
171 		break;
172 	case kCmdCourtChaos:
173 		gotoScene(28);
174 		break;
175 	case kCmdAirGuitar:
176 		gotoScene(30);
177 		break;
178 	case kCmdBack:
179 		gotoMenuScreen(kMainMenuScr);
180 		break;
181 	default:
182 		Dialog::handleCommand(sender, command, data);
183 	}
184 }
185 
gotoMenuScreen(int screen)186 void MainMenu::gotoMenuScreen(int screen) {
187 	for (int i = 0; i < 5; ++i) {
188 		const MenuButton *btn;
189 
190 		if (_vm->_gameDescription->language == Common::RU_RUS) {
191 			btn = &kMenuButtonsRu[screen * 5 + i];
192 		} else {
193 			btn = &kMenuButtons[screen * 5 + i];
194 		}
195 		_buttons[i]->setLabel(Common::U32String(btn->label, Common::kUtf8));
196 		_buttons[i]->setCmd(btn->cmd);
197 		_buttons[i]->setEnabled(btn->cmd != 0);
198 	}
199 	// Enable the "Continue" button if a savegame at slot 0 exists
200 	if (screen == kMainMenuScr)
201 		_buttons[1]->setEnabled(canContinue());
202 }
203 
canContinue()204 bool MainMenu::canContinue() {
205 	return _vm->existsSavegame(0);
206 }
207 
gotoScene(int sceneNum)208 void MainMenu::gotoScene(int sceneNum) {
209 	close();
210 	_vm->setNewSceneNum(sceneNum);
211 }
212 
213 } // End of namespace Hugo
214