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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
|
/* 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.
*
*/
#include "mohawk/riven_stacks/aspit.h"
#include "mohawk/riven.h"
#include "mohawk/riven_card.h"
#include "mohawk/riven_graphics.h"
#include "mohawk/riven_inventory.h"
#include "mohawk/riven_sound.h"
#include "mohawk/riven_video.h"
#include "common/translation.h"
#include "graphics/fonts/ttf.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "gui/message.h"
namespace Mohawk {
namespace RivenStacks {
ASpit::ASpit(MohawkEngine_Riven *vm) :
RivenStack(vm, kStackAspit) {
REGISTER_COMMAND(ASpit, xastartupbtnhide);
REGISTER_COMMAND(ASpit, xasetupcomplete);
REGISTER_COMMAND(ASpit, xaatrusopenbook);
REGISTER_COMMAND(ASpit, xaatrusbookback);
REGISTER_COMMAND(ASpit, xaatrusbookprevpage);
REGISTER_COMMAND(ASpit, xaatrusbooknextpage);
REGISTER_COMMAND(ASpit, xacathopenbook);
REGISTER_COMMAND(ASpit, xacathbookback);
REGISTER_COMMAND(ASpit, xacathbookprevpage);
REGISTER_COMMAND(ASpit, xacathbooknextpage);
REGISTER_COMMAND(ASpit, xtrapbookback);
REGISTER_COMMAND(ASpit, xatrapbookclose);
REGISTER_COMMAND(ASpit, xatrapbookopen);
REGISTER_COMMAND(ASpit, xarestoregame);
REGISTER_COMMAND(ASpit, xadisablemenureturn);
REGISTER_COMMAND(ASpit, xaenablemenureturn);
REGISTER_COMMAND(ASpit, xalaunchbrowser);
REGISTER_COMMAND(ASpit, xadisablemenuintro);
REGISTER_COMMAND(ASpit, xaenablemenuintro);
REGISTER_COMMAND(ASpit, xademoquit);
REGISTER_COMMAND(ASpit, xaexittomain);
REGISTER_COMMAND(ASpit, xaSaveGame);
REGISTER_COMMAND(ASpit, xaResumeGame);
REGISTER_COMMAND(ASpit, xaOptions);
REGISTER_COMMAND(ASpit, xaNewGame);
}
struct MenuItemText {
int language;
const char *items[7];
} static const menuItems[] = {
{ Common::EN_ANY, { "SETUP", "START NEW GAME", "START SAVED GAME", "SAVE GAME", "RESUME", "OPTIONS", "QUIT" } },
{ Common::DE_DEU, { "SETUP", "SPIELEN", "SPIELSTAND LADEN", "SPIEL SPEICHERN", "FORTSETZEN", "OPTIONEN", "BEENDEN" } },
{ Common::ES_ESP, { "IMAGEN", "IR A RIVEN", "CARGAR JUEGO", "GUARDAR JUEGO", "CONTINUAR", "OPCIONES", "SALIR" } },
{ Common::FR_FRA, { "CONFIG", "NOUVELLE PARTIE", "CHARGER", "ENREGISTRER", "REPRENDRE", "OPTIONS", "QUITTER" } },
{ Common::IT_ITA, { "CONF.", "GIOCA", "CARICA GIOCO", "SALVA IL GIOCO", "SEGUITARE", "OPZIONI", "ESCI" } },
{ Common::RU_RUS, { "УСТАНОВКИ", "СТАРТ", "ПРОДОЛЖИТЬ ИГРУ", "СОХРАНИТЬ ИГРУ", "ПРОДОЛЖИТЬ", "ОПЦИИ", "ВЫЙТИ" } },
{ Common::JA_JPN, { "セットアップ", "RIVENを演奏する", "保存したゲームを開始する", "ゲームを保存する", "持続する", "オプション","やめる" } },
{ Common::PL_POL, { "USTAWIENIA", "GRAJ W RIVEN", "ZAŁADUJ GRĘ", "ZAPISZ GRĘ", "POWRÓT", "OPCJE", "WYJŚCIE" } },
{ -1, { 0 } }
};
void ASpit::xastartupbtnhide(const ArgumentArray &args) {
// The original game hides the start/setup buttons depending on an ini entry.
// It's safe to ignore this command.
if (!_vm->isGameVariant(GF_25TH))
return;
int lang = -1;
for (int i = 0; menuItems[i].language != -1; i++) {
if (menuItems[i].language == _vm->getLanguage()) {
lang = i;
break;
}
}
if (lang == -1) {
warning("Unsupported menu language, falling back to English");
lang = 0;
}
struct MenuItem {
uint16 blstId;
bool requiresStartedGame;
};
MenuItem items[] = {
{ 22, false }, // Setup
{ 16, false }, // New game
{ 23, false }, // Load game
{ 24, true }, // Save game
{ 25, true }, // Resume
{ 26, false }, // Options
{ 27, false } // Quit
};
for (uint i = 0; i < ARRAYSIZE(items); i++) {
RivenHotspot *hotspot = _vm->getCard()->getHotspotByBlstId(items[i].blstId);
if (!hotspot) {
warning("Missing hotspot %d", items[i].blstId);
continue;
}
bool enabled = !items[i].requiresStartedGame || _vm->isGameStarted();
hotspot->enable(enabled);
Common::U32String str = Common::convertUtf8ToUtf32(menuItems[lang].items[i]);
Common::Rect hotspotRect = hotspot->getRect();
uint8 greyLevel = enabled ? 164 : 96;
_vm->_gfx->drawText(str, hotspotRect, greyLevel);
}
}
void ASpit::xasetupcomplete(const ArgumentArray &args) {
// The original game sets an ini entry to disable the setup button and use the
// start button only. It's safe to ignore this part of the command.
uint16 menuCardId = getCardStackId(0xE2E);
RivenScriptPtr goToMenuScript = _vm->_scriptMan->createScriptFromData(1, kRivenCommandChangeCard, 1, menuCardId);
_vm->_scriptMan->runScript(goToMenuScript, false);
}
void ASpit::xaatrusopenbook(const ArgumentArray &args) {
// Get the variable
uint32 &page = _vm->_vars["aatrusbook"];
// Set hotspots depending on the page
RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook");
RivenHotspot *nextPage = _vm->getCard()->getHotspotByName("nextpage");
RivenHotspot *prevPage = _vm->getCard()->getHotspotByName("prevpage");
if (page == 1) {
prevPage->enable(false);
nextPage->enable(false);
openBook->enable(true);
} else {
prevPage->enable(true);
nextPage->enable(true);
openBook->enable(false);
}
// Draw the image of the page
_vm->getCard()->drawPicture(page);
}
void ASpit::xaatrusbookback(const ArgumentArray &args) {
_vm->_inventory->backFromItemScript();
}
void ASpit::xaatrusbookprevpage(const ArgumentArray &args) {
// Get the page variable
uint32 &page = _vm->_vars["aatrusbook"];
// Keep turning pages while the mouse is pressed
while (keepTurningPages()) {
// Check for the first page
if (page == 1)
return;
// Update the page number
page--;
pageTurn(kRivenTransitionWipeRight);
_vm->getCard()->drawPicture(page);
_vm->doFrame();
waitForPageTurnSound();
}
}
void ASpit::xaatrusbooknextpage(const ArgumentArray &args) {
// Get the page variable
uint32 &page = _vm->_vars["aatrusbook"];
// Keep turning pages while the mouse is pressed
while (keepTurningPages()) {
// Check for the last page
if ((_vm->isGameVariant(GF_DEMO) && page == 6) || page == 10)
return;
// Update the page number
page++;
pageTurn(kRivenTransitionWipeLeft);
_vm->getCard()->drawPicture(page);
_vm->doFrame();
// Wait until the previous page turn sound completes
waitForPageTurnSound();
}
}
void ASpit::xacathopenbook(const ArgumentArray &args) {
// Get the variable
uint32 page = _vm->_vars["acathbook"];
// Set hotspots depending on the page
RivenHotspot *openBook = _vm->getCard()->getHotspotByName("openBook");
RivenHotspot *nextPage = _vm->getCard()->getHotspotByName("nextpage");
RivenHotspot *prevPage = _vm->getCard()->getHotspotByName("prevpage");
if (page == 1) {
prevPage->enable(false);
nextPage->enable(false);
openBook->enable(true);
} else {
prevPage->enable(true);
nextPage->enable(true);
openBook->enable(false);
}
cathBookDrawPage(page);
}
void ASpit::cathBookDrawPage(uint32 page) {// Draw the image of the page
_vm->getCard()->drawPicture(page);
// Draw the white page edges
if (page > 1 && page < 5)
_vm->getCard()->drawPicture(50);
else if (page > 5)
_vm->getCard()->drawPicture(51);
if (page == 28) {
cathBookDrawTelescopeCombination();
}
}
void ASpit::cathBookDrawTelescopeCombination() {// Draw the telescope combination
// The images for the numbers are tBMP's 13 through 17.
// The start point is at (156, 247)
uint32 teleCombo = _vm->_vars["tcorrectorder"];
static const uint16 kNumberWidth = 32;
static const uint16 kNumberHeight = 25;
static const uint16 kDstX = 156;
static const uint16 kDstY = 247;
for (byte i = 0; i < 5; i++) {
uint16 offset = (getComboDigit(teleCombo, i) - 1) * kNumberWidth;
Common::Rect srcRect = Common::Rect(offset, 0, offset + kNumberWidth, kNumberHeight);
Common::Rect dstRect = Common::Rect(i * kNumberWidth + kDstX, kDstY, (i + 1) * kNumberWidth + kDstX, kDstY + kNumberHeight);
_vm->_gfx->drawImageRect(i + 13, srcRect, dstRect);
}
}
void ASpit::xacathbookback(const ArgumentArray &args) {
_vm->_inventory->backFromItemScript();
}
void ASpit::xacathbookprevpage(const ArgumentArray &args) {
// Get the variable
uint32 &page = _vm->_vars["acathbook"];
// Keep turning pages while the mouse is pressed
while (keepTurningPages()) {
// Check for the first page
if (page == 1)
return;
// Update the page number
page--;
pageTurn(kRivenTransitionWipeDown);
cathBookDrawPage(page);
_vm->doFrame();
waitForPageTurnSound();
}
}
void ASpit::xacathbooknextpage(const ArgumentArray &args) {
// Get the variable
uint32 &page = _vm->_vars["acathbook"];
// Keep turning pages while the mouse is pressed
while (keepTurningPages()) {
// Check for the last page
if (page == 49)
return;
// Update the page number
page++;
pageTurn(kRivenTransitionWipeUp);
cathBookDrawPage(page);
_vm->doFrame();
waitForPageTurnSound();
}
}
void ASpit::xtrapbookback(const ArgumentArray &args) {
// Return to where we were before entering the book
_vm->_vars["atrap"] = 0;
_vm->_inventory->backFromItemScript();
}
void ASpit::xatrapbookclose(const ArgumentArray &args) {
// Close the trap book
_vm->_vars["atrap"] = 0;
pageTurn(kRivenTransitionWipeRight);
// Stop the flyby movie to prevent a glitch where the book does not actually
// close because the movie continues to draw over the closed book picture.
// This glitch also happened in the original engine with transitions disabled.
RivenVideo *flyby = _vm->_video->getSlot(1);
flyby->close();
_vm->getCard()->enter(false);
}
void ASpit::xatrapbookopen(const ArgumentArray &args) {
// Open the trap book
_vm->_vars["atrap"] = 1;
pageTurn(kRivenTransitionWipeLeft);
_vm->getCard()->enter(false);
}
void ASpit::xarestoregame(const ArgumentArray &args) {
if (!showConfirmationDialog(_("Are you sure you want to load a saved game? All unsaved progress will be lost."),
_("Load game"), _("Cancel"))) {
return;
}
// Launch the load game dialog
_vm->loadGameDialog();
}
void ASpit::xaSaveGame(const ArgumentArray &args) {
_vm->saveGameDialog();
}
void ASpit::xaResumeGame(const ArgumentArray &args) {
_vm->resumeFromMainMenu();
}
void ASpit::xaOptions(const ArgumentArray &args) {
_vm->runOptionsDialog();
}
void ASpit::xaNewGame(const ArgumentArray &args) {
if (!showConfirmationDialog(_("Are you sure you want to start a new game? All unsaved progress will be lost."),
_("New game"), _("Cancel"))) {
return;
}
_vm->startNewGame();
RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(2,
kRivenCommandTransition, 1, kRivenTransitionBlend,
kRivenCommandChangeCard, 1, 2);
script->addCommand(RivenCommandPtr(new RivenStackChangeCommand(_vm, 0, 0x6E9A, false, false)));
script += _vm->_scriptMan->createScriptFromData(1,
kRivenCommandStopSound, 1, 2);
_vm->_scriptMan->runScript(script, false);
}
bool ASpit::showConfirmationDialog(const char *message, const char *confirmButton, const char *cancelButton) {
if (!_vm->isGameStarted()) {
return true;
}
GUI::MessageDialog dialog(message, confirmButton, cancelButton);
return dialog.runModal() !=0;
}
void ASpit::xadisablemenureturn(const ArgumentArray &args) {
// This function would normally enable the Windows menu item for
// returning to the main menu. Ctrl+r will do this instead.
// The original also had this shortcut.
}
void ASpit::xaenablemenureturn(const ArgumentArray &args) {
// This function would normally enable the Windows menu item for
// returning to the main menu. Ctrl+r will do this instead.
// The original also had this shortcut.
}
void ASpit::xalaunchbrowser(const ArgumentArray &args) {
// Well, we can't launch a browser for obvious reasons ;)
// The original text is as follows (for reference):
// If you have an auto-dial configured connection to the Internet,
// please select YES below.
//
// America Online and CompuServe users may experience difficulty. If
// you find that you are unable to connect, please quit the Riven
// Demo, launch your browser and type in the following URL:
//
// www.redorb.com/buyriven
//
// Would you like to attempt to make the connection?
//
// [YES] [NO]
GUI::MessageDialog dialog(_("At this point, the Riven Demo would\n"
"ask if you would like to open a web browser\n"
"to bring you to the Red Orb store to buy\n"
"the game. ScummVM cannot do that and\n"
"the site no longer exists."));
dialog.runModal();
}
void ASpit::xadisablemenuintro(const ArgumentArray &args) {
// This function would normally enable the Windows menu item for
// playing the intro. Ctrl+p will play the intro movies instead.
// The original also had this shortcut.
_vm->_inventory->forceHidden(true);
}
void ASpit::xaenablemenuintro(const ArgumentArray &args) {
// This function would normally enable the Windows menu item for
// playing the intro. Ctrl+p will play the intro movies instead.
// The original also had this shortcut.
// Show the "exit" button here
_vm->_inventory->forceHidden(false);
}
void ASpit::xademoquit(const ArgumentArray &args) {
if (!showConfirmationDialog(_("Are you sure you want to quit? All unsaved progress will be lost."), _("Quit"),
_("Cancel"))) {
return;
}
// Exactly as it says on the tin. In the demo, this function quits.
_vm->setGameEnded();
}
void ASpit::xaexittomain(const ArgumentArray &args) {
// One could potentially implement this function, but there would be no
// point. This function is only used in the demo's aspit card 9 update
// screen script. However, card 9 is not accessible from the game without
// jumping to the card and there's nothing going on in the card so it
// never gets called. There's also no card 9 in the full game, so the
// functionality of this card was likely removed before release. The
// demo executable references some other external commands relating to
// setting and getting the volume, as well as drawing the volume. I'd
// venture to guess that this would have been some sort of options card
// replaced with the Windows/Mac API in the final product.
//
// Yeah, this function is just dummied and holds a big comment ;)
}
} // End of namespace RivenStacks
} // End of namespace Mohawk
|