* Moved end intro and end game sequences code to gui.

* Rewrote all gui code to be run inside the main loop
* Added code to avoid crashes when a scene with no standard background is drawn

svn-id: r33260
This commit is contained in:
Nicola Mettifogo 2008-07-24 09:24:32 +00:00
parent 69dac1d4f2
commit 4936e5f7df
9 changed files with 881 additions and 544 deletions

View File

@ -37,18 +37,6 @@
namespace Parallaction {
// part completion messages
static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"};
static const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"};
static const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"};
static const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"};
// game completion messages
static const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"};
static const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"};
static const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"};
static const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"};
/*
intro callables data members
*/
@ -143,18 +131,6 @@ static uint16 _rightHandPositions[684] = {
0x00e0, 0x007b, 0x00e0, 0x0077
};
struct Credit {
const char *_role;
const char *_name;
} _credits[] = {
{"Music and Sound Effects", "MARCO CAPRELLI"},
{"PC Version", "RICCARDO BALLARINO"},
{"Project Manager", "LOVRANO CANEPA"},
{"Production", "BRUNO BOZ"},
{"Special Thanks to", "LUIGI BENEDICENTI - GILDA and DANILO"},
{"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"}
};
/*
game callables
*/
@ -376,39 +352,12 @@ void Parallaction_ns::_c_finito(void *parm) {
setPartComplete(_char);
cleanInventory();
cleanupGame();
_gfx->setPalette(_gfx->_palette);
uint id[4];
startEndPartSequence();
if (allPartsComplete()) {
id[0] = _gfx->createLabel(_menuFont, endMsg4[_language], 1);
id[1] = _gfx->createLabel(_menuFont, endMsg5[_language], 1);
id[2] = _gfx->createLabel(_menuFont, endMsg6[_language], 1);
id[3] = _gfx->createLabel(_menuFont, endMsg7[_language], 1);
} else {
id[0] = _gfx->createLabel(_menuFont, endMsg0[_language], 1);
id[1] = _gfx->createLabel(_menuFont, endMsg1[_language], 1);
id[2] = _gfx->createLabel(_menuFont, endMsg2[_language], 1);
id[3] = _gfx->createLabel(_menuFont, endMsg3[_language], 1);
}
_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 70);
_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 100);
_gfx->showLabel(id[2], CENTER_LABEL_HORIZONTAL, 130);
_gfx->showLabel(id[3], CENTER_LABEL_HORIZONTAL, 160);
_gfx->updateScreen();
_input->waitForButtonEvent(kMouseLeftUp);
_gfx->freeLabels();
if (allPartsComplete()) {
scheduleLocationSwitch("estgrotta.drki");
} else {
selectStartLocation();
}
cleanupGame();
return;
}
@ -475,43 +424,7 @@ void Parallaction_ns::_c_startIntro(void *parm) {
}
void Parallaction_ns::_c_endIntro(void *parm) {
debugC(1, kDebugExec, "endIntro()");
uint id[2];
for (uint16 _si = 0; _si < 6; _si++) {
id[0] = _gfx->createLabel(_menuFont, _credits[_si]._role, 1);
id[1] = _gfx->createLabel(_menuFont, _credits[_si]._name, 1);
_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 80);
_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 100);
_gfx->updateScreen();
_input->waitForButtonEvent(kMouseLeftUp, 5500);
_gfx->freeLabels();
}
debugC(1, kDebugExec, "endIntro(): done showing credits");
_soundMan->stopMusic();
if ((getFeatures() & GF_DEMO) == 0) {
id[0] = _gfx->createLabel(_menuFont, "CLICK MOUSE BUTTON TO START", 1);
_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 80);
_gfx->updateScreen();
_input->waitForButtonEvent(kMouseLeftUp);
_gfx->freeLabels();
_engineFlags &= ~kEngineBlockInput;
selectStartLocation();
cleanupGame();
} else {
_gfx->updateScreen();
_input->waitForButtonEvent(kMouseLeftUp);
}
return;
startCreditSequence();
}
void Parallaction_ns::_c_moveSheet(void *parm) {

View File

@ -352,29 +352,30 @@ void Gfx::clearScreen() {
}
void Gfx::beginFrame() {
_skipBackground = (_backgroundInfo.bg.pixels == 0); // don't render frame if background is missing
int32 oldBackgroundMode = _varBackgroundMode;
_varBackgroundMode = getVar("background_mode");
if (oldBackgroundMode != _varBackgroundMode) {
switch (_varBackgroundMode) {
case 1:
_bitmapMask.free();
break;
case 2:
_bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1);
byte *data = (byte*)_bitmapMask.pixels;
for (uint y = 0; y < _bitmapMask.h; y++) {
for (uint x = 0; x < _bitmapMask.w; x++) {
*data++ = _backgroundInfo.mask.getValue(x, y);
if (!_skipBackground) {
int32 oldBackgroundMode = _varBackgroundMode;
_varBackgroundMode = getVar("background_mode");
if (oldBackgroundMode != _varBackgroundMode) {
switch (_varBackgroundMode) {
case 1:
_bitmapMask.free();
break;
case 2:
_bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1);
byte *data = (byte*)_bitmapMask.pixels;
for (uint y = 0; y < _bitmapMask.h; y++) {
for (uint x = 0; x < _bitmapMask.w; x++) {
*data++ = _backgroundInfo.mask.getValue(x, y);
}
}
break;
}
break;
}
}
if (_vm->_screenWidth >= _backgroundInfo.width) {
if (_skipBackground || (_vm->_screenWidth >= _backgroundInfo.width)) {
_varScrollX = 0;
} else {
_varScrollX = getVar("scroll_x");
@ -399,24 +400,25 @@ int32 Gfx::getRenderMode(const char *type) {
void Gfx::updateScreen() {
// background may not cover the whole screen, so adjust bulk update size
uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width);
uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height);
if (!_skipBackground) {
// background may not cover the whole screen, so adjust bulk update size
uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width);
uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height);
byte *backgroundData = 0;
uint16 backgroundPitch = 0;
switch (_varBackgroundMode) {
case 1:
backgroundData = (byte*)_backgroundInfo.bg.getBasePtr(_varScrollX, 0);
backgroundPitch = _backgroundInfo.bg.pitch;
break;
case 2:
backgroundData = (byte*)_bitmapMask.getBasePtr(_varScrollX, 0);
backgroundPitch = _bitmapMask.pitch;
break;
byte *backgroundData = 0;
uint16 backgroundPitch = 0;
switch (_varBackgroundMode) {
case 1:
backgroundData = (byte*)_backgroundInfo.bg.getBasePtr(_varScrollX, 0);
backgroundPitch = _backgroundInfo.bg.pitch;
break;
case 2:
backgroundData = (byte*)_bitmapMask.getBasePtr(_varScrollX, 0);
backgroundPitch = _bitmapMask.pitch;
break;
}
g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
}
g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
_varRenderMode = _varAnimRenderMode;
@ -847,6 +849,8 @@ void Gfx::setBackground(uint type, const char* name, const char* mask, const cha
_palette.clone(_backgroundInfo.palette);
} else {
_disk->loadSlide(_backgroundInfo, name);
for (uint i = 0; i < 6; i++)
_backgroundInfo.ranges[i]._flags = 0; // disable palette cycling for slides
setPalette(_backgroundInfo.palette);
}

View File

@ -553,6 +553,8 @@ protected:
Parallaction* _vm;
bool _halfbrite;
bool _skipBackground;
Common::Point _hbCirclePos;
int _hbCircleRadius;

File diff suppressed because it is too large Load Diff

View File

@ -166,6 +166,7 @@ InputData* Input::updateInput() {
switch (_inputMode) {
case kInputModeComment:
case kInputModeDialogue:
case kInputModeMenu:
readInput();
break;

View File

@ -85,7 +85,8 @@ public:
kInputModeGame = 0,
kInputModeComment = 1,
kInputModeDialogue = 2,
kInputModeInventory = 3
kInputModeInventory = 3,
kInputModeMenu = 4
};

View File

@ -98,6 +98,8 @@ Parallaction::~Parallaction() {
freeCharacter();
destroyInventory();
cleanupGui();
delete _localFlagNames;
delete _gfx;
delete _soundMan;
@ -136,6 +138,8 @@ int Parallaction::init() {
_debugger = new Debugger(this);
_menuHelper = 0;
setupBalloonManager();
return 0;
@ -325,6 +329,7 @@ void Parallaction::runGame() {
if (_engineFlags & kEngineQuit)
return;
runGuiFrame();
runDialogueFrame();
runCommentFrame();

View File

@ -158,6 +158,7 @@ class Gfx;
class SoundMan;
class Input;
class DialogueManager;
class MenuInputHelper;
struct Location {
@ -416,11 +417,18 @@ public:
void exitDialogueMode();
void runDialogueFrame();
MenuInputHelper *_menuHelper;
void runGuiFrame();
void cleanupGui();
ZonePtr _commentZone;
void enterCommentMode(ZonePtr z);
void exitCommentMode();
void runCommentFrame();
void setInternLanguage(uint id);
uint getInternLanguage();
};
@ -485,6 +493,13 @@ public:
bool saveGame();
void switchBackground(const char* background, const char* mask);
void showSlide(const char *name);
void setArrowCursor();
// TODO: this should be private!!!!!!!
bool _inTestResult;
void cleanupGame();
bool allPartsComplete();
private:
LocationParser_ns *_locationParser;
@ -496,16 +511,13 @@ private:
Common::String genSaveFileName(uint slot, bool oldStyle = false);
Common::InSaveFile *getInSaveFile(uint slot);
Common::OutSaveFile *getOutSaveFile(uint slot);
bool allPartsComplete();
void setPartComplete(const Character& character);
private:
void changeLocation(char *location);
void changeCharacter(const char *name);
void runPendingZones();
void cleanupGame();
void setArrowCursor();
void setInventoryCursor(int pos);
@ -539,9 +551,6 @@ private:
ZonePtr _moveSarcExaZones[5];
AnimationPtr _rightHandAnim;
bool _inTestResult;
// common callables
void _c_play_boogie(void*);
void _c_startIntro(void*);
@ -586,15 +595,9 @@ protected:
void selectStartLocation();
void guiStart();
int guiSelectCharacter();
void guiSplash();
int guiNewGame();
uint16 guiChooseLanguage();
uint16 guiSelectGame();
int guiGetSelectedBlock(const Common::Point &p);
void showSlide(const char *name);
void startGui();
void startCreditSequence();
void startEndPartSequence();
};

View File

@ -240,17 +240,8 @@ int Parallaction_ns::go() {
_globalTable = _disk->loadTable("global");
guiStart();
startGui();
if (_engineFlags & kEngineQuit)
return 0;
changeLocation(_location._name);
if (_engineFlags & kEngineQuit)
return 0;
_input->_inputMode = Input::kInputModeGame;
while ((_engineFlags & kEngineQuit) == 0) {
runGame();
}