Unified
Split
Showing
with
102 additions
and 82 deletions.
- +21 −0 engines/sludge/backdrop.cpp
- +8 −13 engines/sludge/builtin.cpp
- +4 −0 engines/sludge/graphics.cpp
- +14 −6 engines/sludge/graphics.h
- +3 −20 engines/sludge/loadsave.cpp
- +1 −2 engines/sludge/sludger.cpp
- +20 −30 engines/sludge/speech.cpp
- +4 −2 engines/sludge/speech.h
- +16 −7 engines/sludge/thumbnail.cpp
- +11 −2 engines/sludge/transition.cpp
| @@ -504,6 +504,27 @@ void GraphicsManager::saveHSI(Common::WriteStream *stream) { | ||
| Image::writePNG(*stream, _backdropSurface); | ||
| } | ||
|
|
||
| void GraphicsManager::saveBackdrop(Common::WriteStream *stream) { | ||
| stream->writeUint16BE(_cameraX); | ||
| stream->writeUint16BE(_cameraY); | ||
| stream->writeFloatLE(_cameraZoom); | ||
| stream->writeByte(_brightnessLevel); | ||
| saveHSI(stream); | ||
| } | ||
|
|
||
| void GraphicsManager::loadBackdrop(int ssgVersion, Common::SeekableReadStream *stream) { | ||
| _cameraX = stream->readUint16BE(); | ||
| _cameraY = stream->readUint16BE(); | ||
| if (ssgVersion >= VERSION(2, 0)) { | ||
| _cameraZoom = stream->readFloatLE(); | ||
| } else { | ||
| _cameraZoom = 1.0; | ||
| } | ||
|
|
||
| _brightnessLevel = stream->readByte(); | ||
|
|
||
| loadHSI(stream, 0, 0, true); | ||
| } | ||
|
|
||
| bool GraphicsManager::getRGBIntoStack(uint x, uint y, StackHandler *sH) { | ||
| if (x >= _sceneWidth || y >= _sceneHeight) { | ||
| @@ -54,11 +54,9 @@ | ||
|
|
||
| namespace Sludge { | ||
|
|
||
| int speechMode = 0; | ||
|
|
||
| Variable *launchResult = NULL; | ||
|
|
||
| extern int lastFramesPerSecond, thumbWidth, thumbHeight; | ||
| extern int lastFramesPerSecond; | ||
| extern bool allowAnyFilename; | ||
| extern VariableStack *noStack; | ||
| extern StatusStuff *nowStatus; | ||
| @@ -67,7 +65,6 @@ extern int numBIFNames, numUserFunc; | ||
| extern Common::String *allUserFunc; | ||
| extern Common::String *allBIFNames; | ||
|
|
||
| extern byte brightnessLevel; | ||
| extern byte fadeMode; | ||
| extern uint16 saveEncoding; | ||
|
|
||
| @@ -1281,13 +1278,15 @@ builtIn(setLightMap) { | ||
|
|
||
| builtIn(setSpeechMode) { | ||
| UNUSEDALL | ||
| int speechMode; | ||
| if (!getValueType(speechMode, SVT_INT, fun->stack->thisVar)) | ||
| return BR_ERROR; | ||
| trimStack(fun->stack); | ||
| if (speechMode < 0 || speechMode > 2) { | ||
| fatal("Valid parameters are be SPEECHANDTEXT, SPEECHONLY or TEXTONLY"); | ||
| return BR_ERROR; | ||
| } | ||
| g_sludge->_speechMan->setSpeechMode(speechMode); | ||
| return BR_CONTINUE; | ||
| } | ||
|
|
||
| @@ -1971,17 +1970,12 @@ builtIn(setFontSpacing) { | ||
|
|
||
| builtIn(transitionLevel) { | ||
| UNUSEDALL | ||
| int number; | ||
| if (!getValueType(number, SVT_INT, fun->stack->thisVar)) | ||
| int brightnessLevel; | ||
| if (!getValueType(brightnessLevel, SVT_INT, fun->stack->thisVar)) | ||
| return BR_ERROR; | ||
| trimStack(fun->stack); | ||
|
|
||
| if (number < 0) | ||
| brightnessLevel = 0; | ||
| else if (number > 255) | ||
| brightnessLevel = 255; | ||
| else | ||
| brightnessLevel = number; | ||
| g_sludge->_gfxMan->setBrightnessLevel(brightnessLevel); | ||
|
|
||
| setVariable(fun->reg, SVT_INT, 1); | ||
| return BR_CONTINUE; | ||
| @@ -2460,13 +2454,14 @@ builtIn(showThumbnail) { | ||
|
|
||
| builtIn(setThumbnailSize) { | ||
| UNUSEDALL | ||
| int thumbHeight, thumbWidth; | ||
| if (!getValueType(thumbHeight, SVT_INT, fun->stack->thisVar)) | ||
| return BR_ERROR; | ||
| trimStack(fun->stack); | ||
| if (!getValueType(thumbWidth, SVT_INT, fun->stack->thisVar)) | ||
| return BR_ERROR; | ||
| trimStack(fun->stack); | ||
| if (!g_sludge->_gfxMan->checkSizeValide(thumbWidth, thumbHeight)) { | ||
| if (!g_sludge->_gfxMan->setThumbnailSize(thumbWidth, thumbHeight)) { | ||
| Common::String buff = Common::String::format("%i x %i", thumbWidth, thumbWidth); | ||
| fatal("Invalid thumbnail size", buff); | ||
| return BR_ERROR; | ||
| @@ -83,6 +83,10 @@ void GraphicsManager::init() { | ||
| _currentBurnR = 0; | ||
| _currentBurnG = 0; | ||
| _currentBurnB = 0; | ||
|
|
||
| // Thumbnail | ||
| _thumbWidth = 0; | ||
| _thumbHeight = 0; | ||
| } | ||
|
|
||
| void GraphicsManager::kill() { | ||
| @@ -91,6 +91,8 @@ class GraphicsManager { | ||
| void drawVerticalLine(uint, uint, uint); | ||
| void hardScroll(int distance); | ||
| bool getRGBIntoStack(uint x, uint y, StackHandler *sH); | ||
| void saveBackdrop(Common::WriteStream *stream); // To game save | ||
| void loadBackdrop(int ssgVersion, Common::SeekableReadStream *streamn); // From game save | ||
|
|
||
| // Lightmap | ||
| int _lightMapMode; | ||
| @@ -109,11 +111,6 @@ class GraphicsManager { | ||
| int getCamX() { return _cameraX; } | ||
| int getCamY() { return _cameraY; } | ||
| float getCamZoom() { return _cameraZoom; } | ||
| void setCamera(int camerX, int camerY, float camerZ) { | ||
| _cameraX = camerX; | ||
| _cameraY = camerY; | ||
| _cameraZoom = camerZ; | ||
| } | ||
| void aimCamera(int cameraX, int cameraY); | ||
| void zoomCamera(int z); | ||
|
|
||
| @@ -167,11 +164,15 @@ class GraphicsManager { | ||
| void saveColors(Common::WriteStream *stream); | ||
| void loadColors(Common::SeekableReadStream *stream); | ||
|
|
||
| // Thumb nail | ||
| // Thumbnail | ||
| bool setThumbnailSize(int thumbWidth, int thumbHeight); | ||
| bool saveThumbnail(Common::WriteStream *stream); | ||
| bool skipThumbnail(Common::SeekableReadStream *stream); | ||
| void showThumbnail(const Common::String &filename, int x, int y); | ||
|
|
||
| // Transition | ||
| void setBrightnessLevel(int brightnessLevel); | ||
|
|
||
| private: | ||
| SludgeEngine *_vm; | ||
|
|
||
| @@ -222,6 +223,13 @@ class GraphicsManager { | ||
| // Colors | ||
| uint _currentBlankColour; | ||
| byte _currentBurnR, _currentBurnG, _currentBurnB; | ||
|
|
||
| // Thumbnail | ||
| int _thumbWidth; | ||
| int _thumbHeight; | ||
|
|
||
| // Transition | ||
| byte _brightnessLevel; | ||
| }; | ||
|
|
||
| } // End of namespace Sludge | ||
| @@ -60,7 +60,6 @@ extern int numGlobals; // In sludger.cpp | ||
| extern Variable *globalVars; // In sludger.cpp | ||
| extern Floor *currentFloor; // In floor.cpp | ||
| extern FILETIME fileTime; // In sludger.cpp | ||
| extern byte brightnessLevel; // " " " | ||
| extern byte fadeMode; // In transition.cpp | ||
| extern bool allowAnyFilename; | ||
| extern uint16 saveEncoding; // in savedata.cpp | ||
| @@ -363,12 +362,7 @@ bool saveGame(const Common::String &fname) { | ||
| g_sludge->_txtMan->saveFont(fp); | ||
|
|
||
| // Save backdrop | ||
| fp->writeUint16BE(g_sludge->_gfxMan->getCamX()); | ||
| fp->writeUint16BE(g_sludge->_gfxMan->getCamY()); | ||
| fp->writeFloatLE(g_sludge->_gfxMan->getCamZoom()); | ||
|
|
||
| fp->writeByte(brightnessLevel); | ||
| g_sludge->_gfxMan->saveHSI(fp); | ||
| g_sludge->_gfxMan->saveBackdrop(fp); | ||
|
|
||
| // Save event handlers | ||
| g_sludge->_evtMan->saveHandlers(fp); | ||
| @@ -504,19 +498,10 @@ bool loadGame(const Common::String &fname) { | ||
|
|
||
| g_sludge->_regionMan->kill(); | ||
|
|
||
| int camerX = fp->readUint16BE(); | ||
| int camerY = fp->readUint16BE(); | ||
| float camerZ; | ||
| if (ssgVersion >= VERSION(2, 0)) { | ||
| camerZ = fp->readFloatLE(); | ||
| } else { | ||
| camerZ = 1.0; | ||
| } | ||
|
|
||
| brightnessLevel = fp->readByte(); | ||
| g_sludge->_gfxMan->loadBackdrop(ssgVersion, fp); | ||
|
|
||
| g_sludge->_gfxMan->loadHSI(fp, 0, 0, true); | ||
| g_sludge->_evtMan->loadHandlers(fp); | ||
|
|
||
| g_sludge->_regionMan->loadRegions(fp); | ||
|
|
||
| if (!g_sludge->_cursorMan->loadCursor(fp)) { | ||
| @@ -598,8 +583,6 @@ bool loadGame(const Common::String &fname) { | ||
|
|
||
| delete fp; | ||
|
|
||
| g_sludge->_gfxMan->setCamera(camerX, camerY, camerZ); | ||
|
|
||
| clearStackLib(); | ||
| return true; | ||
| } | ||
| @@ -79,7 +79,7 @@ Variable *globalVars; | ||
| int numGlobals = 0; | ||
|
|
||
| extern Variable *launchResult; | ||
| extern int lastFramesPerSecond, thumbWidth, thumbHeight; | ||
| extern int lastFramesPerSecond; | ||
|
|
||
| extern bool allowAnyFilename; | ||
| extern byte fadeMode; | ||
| @@ -167,7 +167,6 @@ void initSludge() { | ||
| launchResult = nullptr; | ||
|
|
||
| lastFramesPerSecond = -1; | ||
| thumbWidth = thumbHeight = 0; | ||
| allowAnyFilename = true; | ||
| noStack = nullptr; | ||
| numBIFNames = numUserFunc = 0; | ||
| @@ -45,7 +45,7 @@ void SpeechManager::init() { | ||
| _speech = new SpeechStruct; | ||
| if (checkNew(_speech)) { | ||
| _speech->currentTalker = NULL; | ||
| _speech->allSpeech = NULL; | ||
| _speech->allSpeech.clear(); | ||
| _speech->speechY = 0; | ||
| _speech->lastFile = -1; | ||
| } | ||
| @@ -65,12 +65,12 @@ void SpeechManager::kill() { | ||
| _speech->currentTalker = nullptr; | ||
| } | ||
|
|
||
| SpeechLine *killMe; | ||
| while (_speech->allSpeech) { | ||
| killMe = _speech->allSpeech; | ||
| _speech->allSpeech = _speech->allSpeech->next; | ||
| for (SpeechLineList::iterator it = _speech->allSpeech.begin(); it != _speech->allSpeech.end(); ++it) { | ||
| SpeechLine *killMe = *it; | ||
| delete killMe; | ||
| killMe = nullptr; | ||
| } | ||
| _speech->allSpeech.clear(); | ||
| } | ||
|
|
||
| void SpeechManager::setObjFontColour(ObjectType *t) { | ||
| @@ -82,14 +82,16 @@ void SpeechManager::addSpeechLine(const Common::String &theLine, int x, int &off | ||
| int halfWidth = (g_sludge->_txtMan->stringWidth(theLine) >> 1) / cameraZoom; | ||
| int xx1 = x - (halfWidth); | ||
| int xx2 = x + (halfWidth); | ||
|
|
||
| // Create new speech line | ||
| SpeechLine *newLine = new SpeechLine; | ||
| checkNew(newLine); | ||
|
|
||
| newLine->next = _speech->allSpeech; | ||
| newLine->textLine.clear(); | ||
| newLine->textLine = theLine; | ||
| newLine->x = xx1; | ||
| _speech->allSpeech = newLine; | ||
| _speech->allSpeech.push_front(newLine); | ||
|
|
||
| // Calculate offset | ||
| if ((xx1 < 5) && (offset < (5 - xx1))) { | ||
| offset = 5 - xx1; | ||
| } else if ((xx2 >= ((float) g_system->getWidth() / cameraZoom) - 5) | ||
| @@ -99,7 +101,7 @@ void SpeechManager::addSpeechLine(const Common::String &theLine, int x, int &off | ||
| } | ||
|
|
||
| int SpeechManager::isThereAnySpeechGoingOn() { | ||
| return _speech->allSpeech ? _speech->lookWhosTalking : -1; | ||
| return _speech->allSpeech.empty() ? -1 : _speech->lookWhosTalking; | ||
| } | ||
|
|
||
| int SpeechManager::getLastSpeechSound() { | ||
| @@ -158,10 +160,8 @@ int SpeechManager::wrapSpeechXY(const Common::String &theText, int x, int y, int | ||
| + (float) (g_system->getHeight() - fontHeight / 3) / cameraZoom; | ||
|
|
||
| if (offset) { | ||
| SpeechLine *viewLine = _speech->allSpeech; | ||
| while (viewLine) { | ||
| viewLine->x += offset; | ||
| viewLine = viewLine->next; | ||
| for (SpeechLineList::iterator it = _speech->allSpeech.begin(); it != _speech->allSpeech.end(); ++it) { | ||
| (*it)->x += offset; | ||
| } | ||
| } | ||
| return speechTime; | ||
| @@ -214,19 +214,14 @@ void SpeechManager::display() { | ||
| float cameraZoom = g_sludge->_gfxMan->getCamZoom(); | ||
| int fontHeight = g_sludge->_txtMan->getFontHeight(); | ||
| int viewY = _speech->speechY; | ||
| SpeechLine *viewLine = _speech->allSpeech; | ||
| while (viewLine) { | ||
| g_sludge->_txtMan->pasteString(viewLine->textLine, viewLine->x, viewY, _speech->talkCol); | ||
| for (SpeechLineList::iterator it = _speech->allSpeech.begin(); it != _speech->allSpeech.end(); ++it) { | ||
| g_sludge->_txtMan->pasteString((*it)->textLine, (*it)->x, viewY, _speech->talkCol); | ||
| viewY -= fontHeight / cameraZoom; | ||
| viewLine = viewLine->next; | ||
| } | ||
| } | ||
|
|
||
| void SpeechManager::save(Common::WriteStream *stream) { | ||
| stream->writeByte(_speechMode); | ||
|
|
||
| SpeechLine *viewLine = _speech->allSpeech; | ||
|
|
||
| stream->writeByte(_speech->talkCol.originalRed); | ||
| stream->writeByte(_speech->talkCol.originalGreen); | ||
| stream->writeByte(_speech->talkCol.originalBlue); | ||
| @@ -246,11 +241,10 @@ void SpeechManager::save(Common::WriteStream *stream) { | ||
| } | ||
|
|
||
| // Write what's being said | ||
| while (viewLine) { | ||
| for (SpeechLineList::iterator it = _speech->allSpeech.begin(); it != _speech->allSpeech.end(); ++it) { | ||
| stream->writeByte(1); | ||
| writeString(viewLine->textLine, stream); | ||
| stream->writeUint16BE(viewLine->x); | ||
| viewLine = viewLine->next; | ||
| writeString((*it)->textLine, stream); | ||
| stream->writeUint16BE((*it)->x); | ||
| } | ||
| stream->writeByte(0); | ||
| } | ||
| @@ -280,18 +274,14 @@ bool SpeechManager::load(Common::SeekableReadStream *stream) { | ||
| } | ||
|
|
||
| // Read what's being said | ||
| SpeechLine **viewLine = &_speech->allSpeech; | ||
| SpeechLine *newOne; | ||
| _speech->lastFile = -1; | ||
| while (stream->readByte()) { | ||
| newOne = new SpeechLine; | ||
| SpeechLine *newOne = new SpeechLine; | ||
| if (!checkNew(newOne)) | ||
| return false; | ||
| newOne->textLine = readString(stream); | ||
| newOne->x = stream->readUint16BE(); | ||
| newOne->next = NULL; | ||
| (*viewLine) = newOne; | ||
| viewLine = &(newOne->next); | ||
| _speech->allSpeech.push_back(newOne); | ||
| } | ||
| return true; | ||
| } | ||
| @@ -30,13 +30,14 @@ struct ObjectType; | ||
|
|
||
| struct SpeechLine { | ||
| Common::String textLine; | ||
| SpeechLine *next; | ||
| int x; | ||
| }; | ||
|
|
||
| typedef Common::List<SpeechLine *> SpeechLineList; | ||
|
|
||
| struct SpeechStruct { | ||
| OnScreenPerson *currentTalker; | ||
| SpeechLine *allSpeech; | ||
| SpeechLineList allSpeech; | ||
| int speechY, lastFile, lookWhosTalking; | ||
| SpritePalette talkCol; | ||
| }; | ||
| @@ -60,6 +61,7 @@ class SpeechManager { | ||
| void setObjFontColour(ObjectType *t); | ||
| void setSpeechSpeed(float speed) { _speechSpeed = speed; } | ||
| float getSpeechSpeed() { return _speechSpeed; } | ||
| void setSpeechMode(int speechMode) { _speechMode = speechMode; } | ||
|
|
||
| // load & save | ||
| void save(Common::WriteStream *stream); | ||
Oops, something went wrong.