2007-07-29 14:24:31 +00:00
|
|
|
/* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/stdafx.h"
|
2007-08-09 19:26:20 +00:00
|
|
|
#include "common/system.h"
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
|
|
|
#include "parallaction/sound.h"
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
enum MenuOptions {
|
|
|
|
kMenuPart0 = 0,
|
|
|
|
kMenuPart1 = 1,
|
|
|
|
kMenuPart2 = 2,
|
|
|
|
kMenuPart3 = 3,
|
|
|
|
kMenuPart4 = 4,
|
|
|
|
kMenuLoadGame = 5,
|
|
|
|
kMenuQuit = 6
|
|
|
|
};
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
int Parallaction_br::init() {
|
|
|
|
|
|
|
|
// Detect game
|
|
|
|
if (!detectGame()) {
|
|
|
|
GUIErrorMessage("No valid games were found in the specified directory.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_screenWidth = 640;
|
|
|
|
_screenHeight = 400;
|
|
|
|
|
|
|
|
if (getGameType() == GType_BRA) {
|
|
|
|
if (getPlatform() == Common::kPlatformPC) {
|
|
|
|
_disk = new DosDisk_br(this);
|
|
|
|
} else
|
|
|
|
error("unsupported platform for Big Red Adventure");
|
|
|
|
} else
|
|
|
|
error("unknown game type");
|
|
|
|
|
|
|
|
_soundMan = new DummySoundMan(this);
|
|
|
|
|
2007-07-29 16:29:41 +00:00
|
|
|
initResources();
|
2007-08-11 17:25:57 +00:00
|
|
|
initFonts();
|
2007-08-11 21:08:08 +00:00
|
|
|
initCursors();
|
2007-07-29 16:29:41 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
_part = -1;
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
Parallaction::init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
Parallaction_br::~Parallaction_br() {
|
|
|
|
freeFonts();
|
2007-08-11 21:08:08 +00:00
|
|
|
|
|
|
|
_dinoCursor->free();
|
|
|
|
_dougCursor->free();
|
|
|
|
_donnaCursor->free();
|
|
|
|
|
|
|
|
delete _dinoCursor;
|
|
|
|
delete _dougCursor;
|
|
|
|
delete _donnaCursor;
|
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
}
|
|
|
|
|
2007-07-29 18:49:24 +00:00
|
|
|
void Parallaction_br::callFunction(uint index, void* parm) {
|
|
|
|
assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure
|
|
|
|
|
|
|
|
(this->*_callables[index])(parm);
|
|
|
|
}
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
int Parallaction_br::go() {
|
2007-08-12 12:24:59 +00:00
|
|
|
splash("dyna");
|
|
|
|
splash("core");
|
2007-08-12 12:51:10 +00:00
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
// TODO: load progress value from special save game
|
2007-08-12 12:51:10 +00:00
|
|
|
_progress = 3;
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
while ((_engineFlags & kEngineQuit) == 0) {
|
|
|
|
|
|
|
|
// initCharacter();
|
|
|
|
|
|
|
|
int option = showMenu();
|
|
|
|
switch (option) {
|
|
|
|
case kMenuQuit:
|
|
|
|
_engineFlags |= kEngineQuit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kMenuLoadGame:
|
|
|
|
warning("loadgame not yet implemented");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
_part = option;
|
|
|
|
initPart();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
runGame();
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
freePart();
|
|
|
|
// freeLocation();
|
|
|
|
// freeCharacter();
|
|
|
|
|
|
|
|
}
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-11 14:18:00 +00:00
|
|
|
void Parallaction_br::splash(const char *name) {
|
|
|
|
|
|
|
|
BackgroundInfo *info;
|
|
|
|
|
|
|
|
_gfx->clearScreen(Gfx::kBitFront);
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-08-11 14:18:00 +00:00
|
|
|
info = _disk->loadSlide(name);
|
|
|
|
_gfx->setPalette(info->palette);
|
|
|
|
_gfx->flatBlitCnv(&info->bg, (640 - info->width) >> 1, (400 - info->height) >> 1, Gfx::kBitFront);
|
2007-08-09 19:26:20 +00:00
|
|
|
_gfx->updateScreen();
|
|
|
|
_system->delayMillis(600);
|
|
|
|
|
|
|
|
Palette pal;
|
|
|
|
for (uint i = 0; i < 64; i++) {
|
2007-08-11 14:18:00 +00:00
|
|
|
info->palette.fadeTo(pal, 1);
|
|
|
|
_gfx->setPalette(info->palette);
|
2007-08-09 19:26:20 +00:00
|
|
|
_gfx->updateScreen();
|
2007-08-11 14:18:00 +00:00
|
|
|
_system->delayMillis(20);
|
2007-08-09 19:26:20 +00:00
|
|
|
}
|
2007-08-11 14:18:00 +00:00
|
|
|
info->bg.free();
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-08-11 14:18:00 +00:00
|
|
|
delete info;
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-08-11 14:18:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-11 19:08:32 +00:00
|
|
|
#define MENUITEMS_X 250
|
|
|
|
#define MENUITEMS_Y 200
|
|
|
|
|
|
|
|
#define MENUITEM_WIDTH 190
|
|
|
|
#define MENUITEM_HEIGHT 18
|
|
|
|
|
|
|
|
void Parallaction_br::renderMenuItem(Graphics::Surface &surf, const char *text) {
|
|
|
|
surf.create(MENUITEM_WIDTH, MENUITEM_HEIGHT, 1);
|
|
|
|
_menuFont->setColor(0);
|
|
|
|
_menuFont->drawString((byte*)surf.getBasePtr(5, 2), MENUITEM_WIDTH, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::invertMenuItem(Graphics::Surface &surf) {
|
|
|
|
for (int i = 0; i < surf.w * surf.h; i++)
|
|
|
|
((byte*)surf.pixels)[i] ^= 0xD;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Parallaction_br::showMenu() {
|
|
|
|
// TODO: filter menu entries according to progress in game
|
|
|
|
|
|
|
|
_gfx->clearScreen(Gfx::kBitFront);
|
|
|
|
|
|
|
|
BackgroundInfo *info;
|
|
|
|
|
|
|
|
Graphics::Surface _menuItems[7];
|
|
|
|
|
2007-08-11 19:35:27 +00:00
|
|
|
const char *menuStrings[7] = {
|
2007-08-11 19:08:32 +00:00
|
|
|
"SEE INTRO",
|
|
|
|
"NEW GAME",
|
|
|
|
"SAVED GAME",
|
|
|
|
"EXIT TO DOS",
|
|
|
|
"PART 2",
|
|
|
|
"PART 3",
|
|
|
|
"PART 4"
|
|
|
|
};
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
MenuOptions options[7] = {
|
|
|
|
kMenuPart0,
|
|
|
|
kMenuPart1,
|
|
|
|
kMenuLoadGame,
|
|
|
|
kMenuQuit,
|
|
|
|
kMenuPart2,
|
|
|
|
kMenuPart3,
|
|
|
|
kMenuPart4
|
|
|
|
};
|
|
|
|
|
2007-08-11 19:08:32 +00:00
|
|
|
info = _disk->loadSlide("tbra");
|
|
|
|
_gfx->setPalette(info->palette);
|
|
|
|
_gfx->flatBlitCnv(&info->bg, 20, 50, Gfx::kBitFront);
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
int availItems = 4 + _progress;
|
|
|
|
|
|
|
|
for (int i = 0; i < availItems; i++)
|
2007-08-11 19:08:32 +00:00
|
|
|
renderMenuItem(_menuItems[i], menuStrings[i]);
|
|
|
|
|
|
|
|
int selectedItem = -1, oldSelectedItem = -2;
|
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
setMousePointer(0);
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
while (true) {
|
|
|
|
|
|
|
|
if ((_mouseButtons == kMouseLeftUp) && selectedItem > 0)
|
|
|
|
break;
|
2007-08-11 19:08:32 +00:00
|
|
|
|
|
|
|
updateInput();
|
|
|
|
|
|
|
|
if ((_mousePos.x > MENUITEMS_X) && (_mousePos.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (_mousePos.y > MENUITEMS_Y)) {
|
|
|
|
selectedItem = (_mousePos.y - MENUITEMS_Y) / MENUITEM_HEIGHT;
|
2007-08-12 12:24:59 +00:00
|
|
|
|
|
|
|
if (!(selectedItem < availItems))
|
|
|
|
selectedItem = -1;
|
2007-08-11 19:08:32 +00:00
|
|
|
} else
|
|
|
|
selectedItem = -1;
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
|
2007-08-11 19:08:32 +00:00
|
|
|
if (selectedItem != oldSelectedItem) {
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
if (selectedItem >= 0 && selectedItem < availItems)
|
2007-08-11 19:08:32 +00:00
|
|
|
invertMenuItem(_menuItems[selectedItem]);
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
if (oldSelectedItem >= 0 && oldSelectedItem < availItems)
|
2007-08-11 19:08:32 +00:00
|
|
|
invertMenuItem(_menuItems[oldSelectedItem]);
|
|
|
|
|
|
|
|
Common::Rect r(MENUITEM_WIDTH, MENUITEM_HEIGHT);
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
for (int i = 0; i < availItems; i++) {
|
2007-08-11 19:08:32 +00:00
|
|
|
r.moveTo(MENUITEMS_X, MENUITEMS_Y + i * 20);
|
|
|
|
_gfx->copyRect(Gfx::kBitFront, r, (byte*)_menuItems[i].pixels, _menuItems[i].pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldSelectedItem = selectedItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gfx->updateScreen();
|
|
|
|
_system->delayMillis(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
_system->showMouse(false);
|
|
|
|
|
|
|
|
info->bg.free();
|
|
|
|
delete info;
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
for (int i = 0; i < availItems; i++)
|
2007-08-11 19:08:32 +00:00
|
|
|
_menuItems[i].free();
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
return options[selectedItem];
|
2007-08-11 19:08:32 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
|
|
|
|
void Parallaction_br::initFonts() {
|
|
|
|
|
|
|
|
// TODO: find out which font is used for labels
|
|
|
|
|
|
|
|
_menuFont = _disk->loadFont("russia");
|
|
|
|
_dialogueFont = _disk->loadFont("comic");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::freeFonts() {
|
|
|
|
|
|
|
|
delete _menuFont;
|
|
|
|
delete _dialogueFont;
|
|
|
|
|
|
|
|
return;
|
2007-08-11 20:44:22 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
void Parallaction_br::initCursors() {
|
|
|
|
|
|
|
|
_dinoCursor = _disk->loadPointer("pointer1");
|
|
|
|
_dougCursor = _disk->loadPointer("pointer2");
|
|
|
|
_donnaCursor = _disk->loadPointer("pointer3");
|
2007-08-11 20:44:22 +00:00
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
_mouseArrow = _donnaCursor;
|
2007-08-11 20:44:22 +00:00
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::setMousePointer(int16 index) {
|
|
|
|
|
|
|
|
_system->setMouseCursor((byte*)_mouseArrow->pixels, _mouseArrow->w, _mouseArrow->h, 0, 0, 0);
|
|
|
|
_system->showMouse(true);
|
2007-08-11 20:44:22 +00:00
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
}
|
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
void Parallaction_br::initPart() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::freePart() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
} // namespace Parallaction
|