mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
SLUDGE: Move global variable brightnessLevel to GraphicsManager and refactor save&load
This commit is contained in:
parent
5ced495769
commit
da491601d4
@ -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) {
|
||||
|
@ -67,7 +67,6 @@ extern int numBIFNames, numUserFunc;
|
||||
extern Common::String *allUserFunc;
|
||||
extern Common::String *allBIFNames;
|
||||
|
||||
extern byte brightnessLevel;
|
||||
extern byte fadeMode;
|
||||
extern uint16 saveEncoding;
|
||||
|
||||
@ -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;
|
||||
|
@ -91,6 +91,8 @@ public:
|
||||
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 @@ public:
|
||||
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);
|
||||
|
||||
@ -173,6 +170,9 @@ public:
|
||||
bool skipThumbnail(Common::SeekableReadStream *stream);
|
||||
void showThumbnail(const Common::String &filename, int x, int y);
|
||||
|
||||
// Transition
|
||||
void setBrightnessLevel(int brightnessLevel);
|
||||
|
||||
private:
|
||||
SludgeEngine *_vm;
|
||||
|
||||
@ -227,6 +227,9 @@ private:
|
||||
// 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;
|
||||
}
|
||||
g_sludge->_gfxMan->loadBackdrop(ssgVersion, fp);
|
||||
|
||||
brightnessLevel = fp->readByte();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -22,16 +22,25 @@
|
||||
|
||||
#include "sludge/allfiles.h"
|
||||
#include "sludge/backdrop.h"
|
||||
#include "sludge/graphics.h"
|
||||
#include "sludge/newfatal.h"
|
||||
|
||||
namespace Sludge {
|
||||
|
||||
extern byte brightnessLevel;
|
||||
|
||||
extern float snapTexW, snapTexH;
|
||||
|
||||
byte fadeMode = 2;
|
||||
|
||||
void GraphicsManager::setBrightnessLevel(int brightnessLevel)
|
||||
{
|
||||
if (brightnessLevel < 0)
|
||||
_brightnessLevel = 0;
|
||||
else if (brightnessLevel > 255)
|
||||
_brightnessLevel = 255;
|
||||
else
|
||||
_brightnessLevel = brightnessLevel;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
// PROPER BRIGHTNESS FADING
|
||||
//----------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user