WINTERMUTE: Reduce the includes and visibility in BGame a bit.

This commit is contained in:
Einar Johan Trøan Sømåen 2012-07-09 09:45:56 +02:00
parent 3809d9a9ea
commit 2959065e49
7 changed files with 45 additions and 29 deletions

View File

@ -32,8 +32,8 @@
#include "engines/wintermute/utils/PathUtil.h"
#include "engines/wintermute/utils/StringUtil.h"
#include "engines/wintermute/math/MathUtil.h"
#include "engines/wintermute/Base/BRenderSDL.h"
#include "engines/wintermute/Base/BSurfaceSDL.h"
#include "engines/wintermute/Base/BRenderer.h"
#include "engines/wintermute/Base/BSurface.h"
#include "engines/wintermute/Base/BParser.h"
#include "engines/wintermute/Base/BGame.h"
#include "engines/wintermute/Base/BFileManager.h"
@ -165,7 +165,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i
textStr = Common::String(textStr.c_str(), (uint32)maxLength);
//text = text.substr(0, MaxLength); // TODO: Remove
CBRenderSDL *_renderer = (CBRenderSDL *)Game->_renderer;
CBRenderer *renderer = Game->_renderer;
// find cached surface, if exists
int minPriority = INT_MAX;
@ -221,14 +221,14 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i
CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight());
for (int i = 0; i < _layers.getSize(); i++) {
uint32 color = _layers[i]->_color;
uint32 origForceAlpha = _renderer->_forceAlphaColor;
if (_renderer->_forceAlphaColor != 0) {
color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(_renderer->_forceAlphaColor));
_renderer->_forceAlphaColor = 0;
uint32 origForceAlpha = renderer->_forceAlphaColor;
if (renderer->_forceAlphaColor != 0) {
color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor));
renderer->_forceAlphaColor = 0;
}
surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY);
_renderer->_forceAlphaColor = origForceAlpha;
renderer->_forceAlphaColor = origForceAlpha;
}
}
@ -270,7 +270,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex
heightOffset += (int)_lineHeight;
}
CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game);
CBSurface *retSurface = Game->_renderer->createSurface();
Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0));
retSurface->putSurface(*convertedSurface, true);
convertedSurface->free();

View File

@ -37,12 +37,12 @@
#include "engines/wintermute/Base/BParser.h"
#include "engines/wintermute/Base/BQuickMsg.h"
#include "engines/wintermute/Base/BRegistry.h"
#include "engines/wintermute/Base/BRenderSDL.h"
#include "engines/wintermute/Base/BRenderer.h"
#include "engines/wintermute/Base/BSound.h"
#include "engines/wintermute/Base/BSoundMgr.h"
#include "engines/wintermute/Base/BSprite.h"
#include "engines/wintermute/Base/BSubFrame.h"
#include "engines/wintermute/Base/BSurfaceSDL.h"
#include "engines/wintermute/Base/BSurface.h"
#include "engines/wintermute/Base/BTransitionMgr.h"
#include "engines/wintermute/Base/BViewport.h"
#include "engines/wintermute/Base/BStringTable.h"
@ -499,7 +499,7 @@ ERRORCODE CBGame::initialize1() {
//////////////////////////////////////////////////////////////////////
ERRORCODE CBGame::initialize2() { // we know whether we are going to be accelerated
_renderer = new CBRenderSDL(this);
_renderer = makeSDLRenderer(this);
if (_renderer == NULL) return STATUS_FAILED;
return STATUS_OK;
@ -3209,7 +3209,7 @@ ERRORCODE CBGame::SaveGame(int slot, const char *desc, bool quickSave) {
delete _saveLoadImage;
_saveLoadImage = NULL;
if (_saveImageName) {
_saveLoadImage = new CBSurfaceSDL(this);
_saveLoadImage = _renderer->createSurface();
if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) {
delete _saveLoadImage;
@ -3259,7 +3259,7 @@ ERRORCODE CBGame::loadGame(const char *filename) {
delete _saveLoadImage;
_saveLoadImage = NULL;
if (_loadImageName) {
_saveLoadImage = new CBSurfaceSDL(this);
_saveLoadImage = _renderer->createSurface();
if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) {
delete _saveLoadImage;

View File

@ -117,10 +117,10 @@ public:
char *_localSaveDir;
bool _saveDirChecked;
int _indicatorProgress;
protected:
bool _indicatorDisplay;
uint32 _indicatorColor;
int _indicatorProgress;
int _indicatorX;
int _indicatorY;
int _indicatorWidth;
@ -135,15 +135,15 @@ public:
int _saveImageY;
int _loadImageX;
int _loadImageY;
CBSurface *_saveLoadImage;
CBSurface *_saveLoadImage;
ERRORCODE displayIndicator();
bool _reportTextureFormat;
public:
int _thumbnailWidth;
int _thumbnailHeight;
bool _reportTextureFormat;
void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL);
ENGINE_LOG_CALLBACK _engineLogCallback;
void *_engineLogCallbackData;
@ -198,13 +198,16 @@ public:
CBArray<CBViewport *, CBViewport *> _viewportStack;
int _viewportSP;
bool _mouseLeftDown;
bool _mouseRightDown;
bool _mouseMidlleDown;
CBStringTable *_stringTable;
CBStringTable *_stringTable;
int _settingsResWidth;
int _settingsResHeight;
char *_settingsGameFile;
bool _suppressScriptErrors;
bool _mouseLeftDown;
protected:
bool _mouseRightDown;
bool _mouseMidlleDown;
bool _settingsRequireAcceleration;
bool _settingsAllowWindowed;
bool _settingsAllowAdvanced;
@ -213,13 +216,10 @@ public:
bool _settingsRequireSound;
bool _settingsAllowDesktopRes;
int _settingsTLMode;
char *_settingsGameFile;
CBFader *_fader;
bool _suppressScriptErrors;
virtual ERRORCODE invalidateDeviceObjects();
virtual ERRORCODE restoreDeviceObjects();
public:
virtual ERRORCODE ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name);
// scripting interface
virtual CScValue *scGetProperty(const char *name);
@ -256,7 +256,9 @@ public:
virtual bool handleKeypress(Common::Event *event, bool printable = false);
virtual void handleKeyRelease(Common::Event *event);
protected:
int _freezeLevel;
public:
ERRORCODE unfreeze();
ERRORCODE freeze(bool includingMusic = true);
ERRORCODE focusWindow(CUIWindow *window);
@ -265,11 +267,13 @@ public:
bool _loadInProgress;
CUIWindow *_focusedWindow;
bool _editorForceScripts;
protected:
static void afterLoadRegion(void *region, void *data);
static void afterLoadSubFrame(void *subframe, void *data);
static void afterLoadSound(void *sound, void *data);
static void afterLoadFont(void *font, void *data);
static void afterLoadScript(void *script, void *data);
public:
static void invalidateValues(void *value, void *data);
ERRORCODE loadSettings(const char *filename);

View File

@ -28,7 +28,6 @@
#include "engines/wintermute/dcgf.h"
#include "engines/wintermute/Base/BImage.h"
#include "engines/wintermute/Base/BSurfaceSDL.h"
#include "engines/wintermute/Base/BGame.h"
#include "engines/wintermute/Base/BFileManager.h"
#include "engines/wintermute/graphics/transparentSurface.h"

View File

@ -83,6 +83,10 @@ bool RenderTicket::operator==(RenderTicket &t) {
return true;
}
CBRenderer *makeSDLRenderer(CBGame *inGame) {
return new CBRenderSDL(inGame);
}
// TODO: Redo everything here.
//////////////////////////////////////////////////////////////////////////
@ -662,4 +666,8 @@ void CBRenderSDL::dumpData(const char *filename) {
#endif
}
CBSurface *CBRenderSDL::createSurface() {
return new CBSurfaceSDL(Game);
}
} // end of namespace WinterMute

View File

@ -99,6 +99,7 @@ public:
}
void drawSurface(CBSurfaceSDL *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY);
CBSurface *createSurface();
private:
void addDirtyRect(const Common::Rect &rect);
void drawTickets();

View File

@ -39,7 +39,7 @@ namespace WinterMute {
class CBImage;
class CBActiveRect;
class CBObject;
class CBSurface;
class CBRenderer: public CBBase {
public:
int _realWidth;
@ -89,6 +89,8 @@ public:
return 1.0f;
}
virtual CBSurface *createSurface() = 0;
ERRORCODE clipCursor();
ERRORCODE unclipCursor();
@ -119,6 +121,8 @@ public:
CBArray<CBActiveRect *, CBActiveRect *> _rectList;
};
CBRenderer *makeSDLRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp
} // end of namespace WinterMute
#endif