aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-06 13:13:25 +0000
committerEugene Sandulenko2010-10-12 22:35:55 +0000
commit47904bc7b2992189bb554833f00a79ff0fea9fb8 (patch)
tree1cec51758c6741b970bd064fafee77607b9f884f /engines
parentca17def625154e5f758b797e4fc48c76b0566320 (diff)
downloadscummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.gz
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.bz2
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.zip
SWORD25: Mass-astyle.
svn-id: r53222
Diffstat (limited to 'engines')
-rw-r--r--engines/sword25/fmv/movieplayer.cpp6
-rw-r--r--engines/sword25/fmv/movieplayer.h32
-rw-r--r--engines/sword25/fmv/theora_decoder.cpp18
-rw-r--r--[-rwxr-xr-x]engines/sword25/fmv/theora_decoder.h26
-rw-r--r--engines/sword25/gfx/animation.cpp361
-rw-r--r--engines/sword25/gfx/animation.h148
-rw-r--r--engines/sword25/gfx/animationdescription.cpp8
-rw-r--r--engines/sword25/gfx/animationdescription.h70
-rw-r--r--engines/sword25/gfx/animationresource.cpp170
-rw-r--r--engines/sword25/gfx/animationresource.h58
-rw-r--r--engines/sword25/gfx/animationtemplate.cpp116
-rw-r--r--engines/sword25/gfx/animationtemplate.h74
-rw-r--r--engines/sword25/gfx/animationtemplateregistry.cpp20
-rw-r--r--engines/sword25/gfx/animationtemplateregistry.h16
-rw-r--r--engines/sword25/gfx/bitmap.cpp70
-rw-r--r--engines/sword25/gfx/bitmap.h139
-rw-r--r--engines/sword25/gfx/bitmapresource.cpp13
-rw-r--r--engines/sword25/gfx/bitmapresource.h191
-rw-r--r--engines/sword25/gfx/dynamicbitmap.cpp66
-rw-r--r--engines/sword25/gfx/dynamicbitmap.h25
-rw-r--r--engines/sword25/gfx/fontresource.cpp90
-rw-r--r--engines/sword25/gfx/fontresource.h76
-rw-r--r--engines/sword25/gfx/framecounter.cpp11
-rw-r--r--engines/sword25/gfx/framecounter.h12
-rw-r--r--engines/sword25/gfx/graphicengine.cpp84
-rw-r--r--engines/sword25/gfx/graphicengine.h162
-rw-r--r--engines/sword25/gfx/graphicengine_script.cpp721
-rw-r--r--engines/sword25/gfx/image/b25sloader.cpp61
-rw-r--r--engines/sword25/gfx/image/b25sloader.h20
-rw-r--r--engines/sword25/gfx/image/image.h176
-rw-r--r--engines/sword25/gfx/image/imageloader.cpp64
-rw-r--r--engines/sword25/gfx/image/imageloader.h342
-rw-r--r--engines/sword25/gfx/image/imageloader_ids.h17
-rw-r--r--engines/sword25/gfx/image/pngloader.cpp187
-rw-r--r--engines/sword25/gfx/image/pngloader.h44
-rw-r--r--engines/sword25/gfx/image/vectorimage.cpp376
-rw-r--r--engines/sword25/gfx/image/vectorimage.h169
-rw-r--r--engines/sword25/gfx/image/vectorimagerenderer.cpp90
-rw-r--r--engines/sword25/gfx/image/vectorimagerenderer.h19
-rw-r--r--engines/sword25/gfx/opengl/glimage.cpp85
-rw-r--r--engines/sword25/gfx/opengl/glimage.h81
-rw-r--r--engines/sword25/gfx/opengl/glvectorimageblit.cpp54
-rw-r--r--engines/sword25/gfx/opengl/openglgfx.cpp207
-rw-r--r--engines/sword25/gfx/opengl/openglgfx.h50
-rw-r--r--engines/sword25/gfx/opengl/swimage.cpp43
-rw-r--r--engines/sword25/gfx/opengl/swimage.h65
-rw-r--r--engines/sword25/gfx/panel.cpp32
-rw-r--r--engines/sword25/gfx/panel.h22
-rw-r--r--engines/sword25/gfx/renderobject.cpp179
-rw-r--r--engines/sword25/gfx/renderobject.h444
-rw-r--r--engines/sword25/gfx/renderobjectmanager.cpp34
-rw-r--r--engines/sword25/gfx/renderobjectmanager.h73
-rw-r--r--engines/sword25/gfx/renderobjectptr.cpp4
-rw-r--r--engines/sword25/gfx/renderobjectptr.h19
-rw-r--r--engines/sword25/gfx/renderobjectregistry.cpp8
-rw-r--r--engines/sword25/gfx/renderobjectregistry.h8
-rw-r--r--engines/sword25/gfx/rootrenderobject.h16
-rw-r--r--engines/sword25/gfx/screenshot.cpp75
-rw-r--r--engines/sword25/gfx/screenshot.h11
-rw-r--r--engines/sword25/gfx/staticbitmap.cpp93
-rw-r--r--engines/sword25/gfx/staticbitmap.h33
-rw-r--r--engines/sword25/gfx/text.cpp164
-rw-r--r--engines/sword25/gfx/text.h116
-rw-r--r--engines/sword25/gfx/timedrenderobject.cpp8
-rw-r--r--engines/sword25/gfx/timedrenderobject.h15
-rw-r--r--engines/sword25/input/inputengine.cpp2
-rw-r--r--engines/sword25/input/inputengine.h120
-rw-r--r--engines/sword25/input/inputengine_script.cpp84
-rw-r--r--engines/sword25/input/scummvminput.cpp67
-rw-r--r--engines/sword25/input/scummvminput.h38
-rw-r--r--engines/sword25/kernel/bs_stdint.h2
-rw-r--r--engines/sword25/kernel/callbackregistry.cpp4
-rw-r--r--engines/sword25/kernel/callbackregistry.h24
-rw-r--r--engines/sword25/kernel/common.h6
-rw-r--r--engines/sword25/kernel/filesystemutil.cpp4
-rw-r--r--engines/sword25/kernel/filesystemutil.h34
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.cpp12
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.h12
-rw-r--r--engines/sword25/kernel/kernel.cpp146
-rw-r--r--engines/sword25/kernel/kernel.h144
-rw-r--r--engines/sword25/kernel/kernel_script.cpp28
-rw-r--r--engines/sword25/kernel/log.cpp28
-rw-r--r--engines/sword25/kernel/log.h79
-rw-r--r--engines/sword25/kernel/memleaks.cpp62
-rw-r--r--engines/sword25/kernel/memleaks.h13
-rw-r--r--engines/sword25/kernel/memlog_off.h10
-rw-r--r--engines/sword25/kernel/memlog_on.h10
-rw-r--r--engines/sword25/kernel/objectregistry.h16
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.cpp4
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.h12
-rw-r--r--engines/sword25/kernel/persistable.h6
-rw-r--r--engines/sword25/kernel/persistenceblock.h28
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp155
-rw-r--r--engines/sword25/kernel/persistenceservice.h20
-rw-r--r--engines/sword25/kernel/resmanager.cpp41
-rw-r--r--engines/sword25/kernel/resmanager.h63
-rw-r--r--engines/sword25/kernel/resource.cpp6
-rw-r--r--engines/sword25/kernel/resource.h40
-rw-r--r--engines/sword25/kernel/resservice.h31
-rw-r--r--engines/sword25/kernel/scummvmwindow.cpp258
-rw-r--r--engines/sword25/kernel/scummvmwindow.h14
-rw-r--r--engines/sword25/kernel/service.h16
-rw-r--r--engines/sword25/kernel/service_ids.h6
-rw-r--r--engines/sword25/kernel/string.h19
-rw-r--r--engines/sword25/kernel/window.cpp6
-rw-r--r--engines/sword25/kernel/window.h28
-rw-r--r--engines/sword25/math/geometry.cpp2
-rw-r--r--engines/sword25/math/geometry.h2
-rw-r--r--engines/sword25/math/geometry_script.cpp140
-rw-r--r--engines/sword25/math/line.h100
-rw-r--r--engines/sword25/math/polygon.cpp60
-rw-r--r--engines/sword25/math/polygon.h82
-rw-r--r--engines/sword25/math/rect.h46
-rw-r--r--engines/sword25/math/region.cpp38
-rw-r--r--engines/sword25/math/region.h76
-rw-r--r--engines/sword25/math/regionregistry.cpp4
-rw-r--r--engines/sword25/math/regionregistry.h4
-rw-r--r--engines/sword25/math/vertex.cpp8
-rw-r--r--engines/sword25/math/vertex.h76
-rw-r--r--engines/sword25/math/walkregion.cpp53
-rw-r--r--engines/sword25/math/walkregion.h34
-rw-r--r--engines/sword25/package/packagemanager.cpp2
-rw-r--r--engines/sword25/package/packagemanager.h90
-rw-r--r--engines/sword25/package/packagemanager_script.cpp16
-rw-r--r--engines/sword25/package/scummvmpackagemanager.cpp48
-rw-r--r--engines/sword25/package/scummvmpackagemanager.h14
-rw-r--r--engines/sword25/script/lua_extensions.cpp2
-rw-r--r--engines/sword25/script/luabindhelper.cpp166
-rw-r--r--engines/sword25/script/luabindhelper.h50
-rw-r--r--engines/sword25/script/luacallback.cpp17
-rw-r--r--engines/sword25/script/luacallback.h10
-rw-r--r--engines/sword25/script/luascript.cpp421
-rw-r--r--engines/sword25/script/luascript.h26
-rw-r--r--engines/sword25/script/script.h18
-rw-r--r--engines/sword25/sfx/fmodexchannel.cpp120
-rw-r--r--engines/sword25/sfx/fmodexchannel.h29
-rw-r--r--engines/sword25/sfx/fmodexexception.h20
-rw-r--r--engines/sword25/sfx/fmodexresource.cpp70
-rw-r--r--engines/sword25/sfx/fmodexresource.h15
-rw-r--r--engines/sword25/sfx/fmodexsound.cpp530
-rw-r--r--engines/sword25/sfx/fmodexsound.h120
-rw-r--r--engines/sword25/sfx/soundengine.cpp5
-rw-r--r--engines/sword25/sfx/soundengine.h126
-rw-r--r--engines/sword25/sfx/soundengine_script.cpp159
-rw-r--r--engines/sword25/sword25.cpp21
-rw-r--r--engines/sword25/sword25.h2
146 files changed, 5110 insertions, 5697 deletions
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp
index a031fc8283..ea22cfd3db 100644
--- a/engines/sword25/fmv/movieplayer.cpp
+++ b/engines/sword25/fmv/movieplayer.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -38,7 +38,9 @@ namespace Sword25 {
#define BS_LOG_PREFIX "MOVIEPLAYER"
-BS_Service *BS_OggTheora_CreateObject(BS_Kernel *pKernel) { return new BS_MoviePlayer(pKernel); }
+BS_Service *BS_OggTheora_CreateObject(BS_Kernel *pKernel) {
+ return new BS_MoviePlayer(pKernel);
+}
BS_MoviePlayer::BS_MoviePlayer(BS_Kernel *pKernel) : BS_Service(pKernel) {
if (!_RegisterScriptBindings())
diff --git a/engines/sword25/fmv/movieplayer.h b/engines/sword25/fmv/movieplayer.h
index be841c51a9..08d0012388 100644
--- a/engines/sword25/fmv/movieplayer.h
+++ b/engines/sword25/fmv/movieplayer.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -67,16 +67,16 @@ public:
* This method loads a movie file and prepares it for playback.
* There can be oly one movie file loaded at a time. If you already have loaded a
* movie file, it will be unloaded and, if necessary, stopped playing.
- * @param Filename The filename of the movie file to be loaded
- * @param Z Z indicates the position of the film on the main graphics layer
- * @return Returns false if an error occured while loading, otherwise true.
+ * @param Filename The filename of the movie file to be loaded
+ * @param Z Z indicates the position of the film on the main graphics layer
+ * @return Returns false if an error occured while loading, otherwise true.
*/
bool LoadMovie(const Common::String &Filename, unsigned int Z);
/**
* Unloads the currently loaded movie file.
- * @return Returns false if an error occurred while unloading, otherwise true.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @return Returns false if an error occurred while unloading, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
bool UnloadMovie();
@@ -85,8 +85,8 @@ public:
*
* The film will be keeping the aspect ratio of the screen.
* If the film was previously paused with Pause(), then the film will resume playing.
- * @return Returns false if an error occurred while starting, otherwise true.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @return Returns false if an error occurred while starting, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
bool Play();
@@ -94,8 +94,8 @@ public:
* Pauses movie playback.
*
* A paused movie can later be resumed by calling the Play() method again.
- * @return Returns false if an error occurred while pausing, otherwise true.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @return Returns false if an error occurred while pausing, otherwise true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
bool Pause();
@@ -111,7 +111,7 @@ public:
/**
* Returns whether the movie playback is paused.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
bool IsPaused();
@@ -120,21 +120,21 @@ public:
*
* When a movie is loaded, the scaling factor is automatically selected so that the film
* takes the maximum screen space, without the film being distorted.
- * @return Returns the scaling factor of the film.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @return Returns the scaling factor of the film.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
float GetScaleFactor();
/**
* Sets the factor by which the loaded film is to be scaled.
- * @param ScaleFactor The desired scale factor.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @param ScaleFactor The desired scale factor.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
void SetScaleFactor(float ScaleFactor);
/**
* Returns the current playing position in seconds.
- * @remark This method can only be called when IsMovieLoaded() returns true.
+ * @remark This method can only be called when IsMovieLoaded() returns true.
*/
double GetTime();
diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp
index b6647559d2..133adb3007 100644
--- a/engines/sword25/fmv/theora_decoder.cpp
+++ b/engines/sword25/fmv/theora_decoder.cpp
@@ -64,11 +64,11 @@ TheoraDecoder::~TheoraDecoder() {
}
void TheoraDecoder::queuePage(ogg_page *page) {
- if (_theoraPacket)
- ogg_stream_pagein(&_theoraOut, page);
+ if (_theoraPacket)
+ ogg_stream_pagein(&_theoraOut, page);
- if (_vorbisPacket)
- ogg_stream_pagein(&_vorbisOut, page);
+ if (_vorbisPacket)
+ ogg_stream_pagein(&_vorbisOut, page);
}
int TheoraDecoder::bufferData() {
@@ -203,7 +203,7 @@ bool TheoraDecoder::load(Common::SeekableReadStream &stream) {
if (_theoraInfo.pic_width != _theoraInfo.frame_width || _theoraInfo.pic_height != _theoraInfo.frame_height)
debug(1, " Frame content is %dx%d with offset (%d,%d).",
- _theoraInfo.frame_width, _theoraInfo.frame_height, _theoraInfo.pic_x, _theoraInfo.pic_y);
+ _theoraInfo.frame_width, _theoraInfo.frame_height, _theoraInfo.pic_x, _theoraInfo.pic_y);
th_decode_ctl(_theoraDecode, TH_DECCTL_GET_PPLEVEL_MAX, &_ppLevelMax, sizeof(_ppLevelMax));
_ppLevel = _ppLevelMax;
@@ -222,7 +222,7 @@ bool TheoraDecoder::load(Common::SeekableReadStream &stream) {
vorbis_synthesis_init(&_vorbisDSP, &_vorbisInfo);
vorbis_block_init(&_vorbisDSP, &_vorbisBlock);
debug(3, "Ogg logical stream %lx is Vorbis %d channel %ld Hz audio.",
- _vorbisOut.serialno, _vorbisInfo.channels, _vorbisInfo.rate);
+ _vorbisOut.serialno, _vorbisInfo.channels, _vorbisInfo.rate);
} else {
// tear down the partial vorbis setup
vorbis_info_clear(&_vorbisInfo);
@@ -307,7 +307,7 @@ Graphics::Surface *TheoraDecoder::decodeNextFrame() {
_audiobufGranulePos = _vorbisDSP.granulepos - ret + i;
else
_audiobufGranulePos += i;
- } else {
+ } else {
// no pending audio; is there a pending packet to decode?
if (ogg_stream_packetout(&_vorbisOut, &_oggPacket) > 0) {
@@ -367,7 +367,7 @@ Graphics::Surface *TheoraDecoder::decodeNextFrame() {
// are we at or past time for this video frame?
if (_stateFlag && _videobufReady) {
th_ycbcr_buffer yuv;
-
+
th_decode_ycbcr_out(_theoraDecode, yuv);
// TODO: YUV->RGB
@@ -388,7 +388,7 @@ Graphics::Surface *TheoraDecoder::decodeNextFrame() {
// if our buffers either don't exist or are ready to go,
// we can begin playback
if ((!_theoraPacket || _videobufReady) &&
- (!_vorbisPacket || _audiobufReady))
+ (!_vorbisPacket || _audiobufReady))
_stateFlag = true;
// same if we've run out of input
diff --git a/engines/sword25/fmv/theora_decoder.h b/engines/sword25/fmv/theora_decoder.h
index b6cf4567fc..690763e940 100755..100644
--- a/engines/sword25/fmv/theora_decoder.h
+++ b/engines/sword25/fmv/theora_decoder.h
@@ -34,7 +34,7 @@
#include <vorbis/codec.h>
namespace Common {
- class SeekableReadStream;
+class SeekableReadStream;
}
namespace Sword25 {
@@ -65,16 +65,28 @@ public:
*/
Graphics::Surface *decodeNextFrame();
- bool isVideoLoaded() const { return _fileStream != 0; }
- uint16 getWidth() const { return _surface->w; }
- uint16 getHeight() const { return _surface->h; }
- uint32 getFrameCount() const { return _frameCount; }
- Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 0, 0, 0); }
+ bool isVideoLoaded() const {
+ return _fileStream != 0;
+ }
+ uint16 getWidth() const {
+ return _surface->w;
+ }
+ uint16 getHeight() const {
+ return _surface->h;
+ }
+ uint32 getFrameCount() const {
+ return _frameCount;
+ }
+ Graphics::PixelFormat getPixelFormat() const {
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 0, 0, 0);
+ }
uint32 getElapsedTime() const;
protected:
- Common::Rational getFrameRate() const { return _frameRate; }
+ Common::Rational getFrameRate() const {
+ return _frameRate;
+ }
private:
void queuePage(ogg_page *page);
diff --git a/engines/sword25/gfx/animation.cpp b/engines/sword25/gfx/animation.cpp
index deeca40df7..f906f05828 100644
--- a/engines/sword25/gfx/animation.cpp
+++ b/engines/sword25/gfx/animation.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -57,9 +57,8 @@ namespace Sword25 {
// Konstruktion / Destruktion
// --------------------------
-BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String & FileName) :
- BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION)
-{
+BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &FileName) :
+ BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION) {
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
if (!m_InitSuccess) return;
@@ -69,16 +68,15 @@ BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const
m_InitSuccess = false;
InitializeAnimationResource(FileName);
-
+
// Erfolg signalisieren.
m_InitSuccess = true;
}
// -----------------------------------------------------------------------------
-BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate & Template) :
- BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION)
-{
+BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate &Template) :
+ BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION) {
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
if (!m_InitSuccess) return;
@@ -95,9 +93,8 @@ BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const
// -----------------------------------------------------------------------------
-BS_Animation::BS_Animation(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
- BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION, Handle)
-{
+BS_Animation::BS_Animation(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
+ BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION, Handle) {
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
if (!m_InitSuccess) return;
@@ -109,14 +106,12 @@ BS_Animation::BS_Animation(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr
// -----------------------------------------------------------------------------
-void BS_Animation::InitializeAnimationResource(const Common::String &FileName)
-{
+void BS_Animation::InitializeAnimationResource(const Common::String &FileName) {
// Die Resource wird für die gesamte Lebensdauer des Animations-Objektes gelockt.
- BS_Resource * ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
+ BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
if (ResourcePtr && ResourcePtr->GetType() == BS_Resource::TYPE_ANIMATION)
m_AnimationResourcePtr = static_cast<BS_AnimationResource *>(ResourcePtr);
- else
- {
+ else {
BS_LOG_ERRORLN("The resource \"%s\" could not be requested. The Animation can't be created.", FileName.c_str());
return;
}
@@ -127,8 +122,7 @@ void BS_Animation::InitializeAnimationResource(const Common::String &FileName)
// -----------------------------------------------------------------------------
-void BS_Animation::InitMembers()
-{
+void BS_Animation::InitMembers() {
m_CurrentFrame = 0;
m_CurrentFrameTime = 0;
m_Direction = FORWARD;
@@ -146,17 +140,15 @@ void BS_Animation::InitMembers()
// -----------------------------------------------------------------------------
-BS_Animation::~BS_Animation()
-{
- if (GetAnimationDescription())
- {
+BS_Animation::~BS_Animation() {
+ if (GetAnimationDescription()) {
Stop();
GetAnimationDescription()->Unlock();
}
// Delete Callbacks
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_DeleteCallbacks.begin();
- for (; it != m_DeleteCallbacks.end(); it++) ((*it).Callback)((*it).Data);
+ for (; it != m_DeleteCallbacks.end(); it++)((*it).Callback)((*it).Data);
}
@@ -164,8 +156,7 @@ BS_Animation::~BS_Animation()
// Steuermethoden
// -----------------------------------------------------------------------------
-void BS_Animation::Play()
-{
+void BS_Animation::Play() {
// Wenn die Animation zuvor komplett durchgelaufen ist, wird sie wieder von Anfang abgespielt
if (m_Finished) Stop();
@@ -175,16 +166,14 @@ void BS_Animation::Play()
// -----------------------------------------------------------------------------
-void BS_Animation::Pause()
-{
+void BS_Animation::Pause() {
m_Running = false;
UnlockAllFrames();
}
// -----------------------------------------------------------------------------
-void BS_Animation::Stop()
-{
+void BS_Animation::Stop() {
m_CurrentFrame = 0;
m_CurrentFrameTime = 0;
m_Direction = FORWARD;
@@ -193,15 +182,13 @@ void BS_Animation::Stop()
// -----------------------------------------------------------------------------
-void BS_Animation::SetFrame(unsigned int Nr)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::SetFrame(unsigned int Nr) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- if (Nr >= animationDescriptionPtr->GetFrameCount())
- {
+ if (Nr >= animationDescriptionPtr->GetFrameCount()) {
BS_LOG_ERRORLN("Tried to set animation to illegal frame (%d). Value must be between 0 and %d.",
- Nr, animationDescriptionPtr->GetFrameCount());
+ Nr, animationDescriptionPtr->GetFrameCount());
return;
}
@@ -215,37 +202,33 @@ void BS_Animation::SetFrame(unsigned int Nr)
// Rendern
// -----------------------------------------------------------------------------
-bool BS_Animation::DoRender()
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::DoRender() {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
BS_ASSERT(m_CurrentFrame < animationDescriptionPtr->GetFrameCount());
// Bitmap des aktuellen Frames holen
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(m_CurrentFrame).FileName);
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(m_CurrentFrame).FileName);
BS_ASSERT(pResource);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource * pBitmapResource = static_cast<BS_BitmapResource*>(pResource);
+ BS_BitmapResource *pBitmapResource = static_cast<BS_BitmapResource *>(pResource);
// Framebufferobjekt holen
- BS_GraphicEngine * pGfx = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
+ BS_GraphicEngine *pGfx = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(pGfx);
// Bitmap zeichnen
bool Result;
- if (IsScalingAllowed() && (m_Width != pBitmapResource->GetWidth() || m_Height != pBitmapResource->GetHeight()))
- {
+ if (IsScalingAllowed() && (m_Width != pBitmapResource->GetWidth() || m_Height != pBitmapResource->GetHeight())) {
Result = pBitmapResource->Blit(m_AbsoluteX, m_AbsoluteY,
- (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, m_Width, m_Height);
- }
- else
- {
+ (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, m_Width, m_Height);
+ } else {
Result = pBitmapResource->Blit(m_AbsoluteX, m_AbsoluteY,
- (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, -1, -1);
+ (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, -1, -1);
}
// Resource freigeben
@@ -258,15 +241,13 @@ bool BS_Animation::DoRender()
// Frame Notifikation
// -----------------------------------------------------------------------------
-void BS_Animation::FrameNotification(int TimeElapsed)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::FrameNotification(int TimeElapsed) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
BS_ASSERT(TimeElapsed >= 0);
// Nur wenn die Animation läuft wird sie auch weiterbewegt
- if (m_Running)
- {
+ if (m_Running) {
int OldFrame = m_CurrentFrame;
// Gesamte vergangene Zeit bestimmen (inkl. Restzeit des aktuellen Frames)
@@ -280,8 +261,7 @@ void BS_Animation::FrameNotification(int TimeElapsed)
// Neuen Frame bestimmen (je nach aktuellener Abspielrichtung wird addiert oder subtrahiert)
int TmpCurFrame = m_CurrentFrame;
- switch (m_Direction)
- {
+ switch (m_Direction) {
case FORWARD:
TmpCurFrame += SkipFrames;
break;
@@ -292,20 +272,16 @@ void BS_Animation::FrameNotification(int TimeElapsed)
default:
BS_ASSERT(0);
- }
+ }
// Überläufe behandeln
- if (TmpCurFrame < 0)
- {
+ if (TmpCurFrame < 0) {
// Loop-Point Callbacks
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_LoopPointCallbacks.begin();
- while (it != m_LoopPointCallbacks.end())
- {
- if (((*it).Callback)((*it).Data) == false)
- {
+ while (it != m_LoopPointCallbacks.end()) {
+ if (((*it).Callback)((*it).Data) == false) {
it = m_LoopPointCallbacks.erase(it);
- }
- else
+ } else
it++;
}
@@ -313,21 +289,17 @@ void BS_Animation::FrameNotification(int TimeElapsed)
BS_ASSERT(animationDescriptionPtr->GetAnimationType() == AT_JOJO);
TmpCurFrame = - TmpCurFrame;
m_Direction = FORWARD;
- }
- else if (static_cast<unsigned int>(TmpCurFrame) >= animationDescriptionPtr->GetFrameCount())
- {
+ } else if (static_cast<unsigned int>(TmpCurFrame) >= animationDescriptionPtr->GetFrameCount()) {
// Loop-Point Callbacks
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_LoopPointCallbacks.begin();
- while (it != m_LoopPointCallbacks.end())
- {
+ while (it != m_LoopPointCallbacks.end()) {
if (((*it).Callback)((*it).Data) == false)
it = m_LoopPointCallbacks.erase(it);
else
it++;
}
- switch (animationDescriptionPtr->GetAnimationType())
- {
+ switch (animationDescriptionPtr->GetAnimationType()) {
case AT_ONESHOT:
TmpCurFrame = animationDescriptionPtr->GetFrameCount() - 1;
m_Finished = true;
@@ -348,16 +320,13 @@ void BS_Animation::FrameNotification(int TimeElapsed)
}
}
- if (m_CurrentFrame != TmpCurFrame)
- {
+ if (m_CurrentFrame != TmpCurFrame) {
ForceRefresh();
-
- if (animationDescriptionPtr->GetFrame(m_CurrentFrame).Action != "")
- {
+
+ if (animationDescriptionPtr->GetFrame(m_CurrentFrame).Action != "") {
// Action Callbacks
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_ActionCallbacks.begin();
- while (it != m_ActionCallbacks.end())
- {
+ while (it != m_ActionCallbacks.end()) {
if (((*it).Callback)((*it).Data) == false)
it = m_ActionCallbacks.erase(it);
else
@@ -378,23 +347,22 @@ void BS_Animation::FrameNotification(int TimeElapsed)
// -----------------------------------------------------------------------------
-void BS_Animation::ComputeCurrentCharacteristics()
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::ComputeCurrentCharacteristics() {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- const BS_AnimationResource::Frame & CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
+ const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
BS_ASSERT(pResource);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource* pBitmap = static_cast<BS_BitmapResource *>(pResource);
+ BS_BitmapResource *pBitmap = static_cast<BS_BitmapResource *>(pResource);
// Größe des Bitmaps auf die Animation übertragen
m_Width = static_cast<int>(pBitmap->GetWidth() * m_ScaleFactorX);
m_Height = static_cast<int>(pBitmap->GetHeight() * m_ScaleFactorY);
// Position anhand des Hotspots berechnen und setzen
- int PosX = m_RelX + ComputeXModifier();
+ int PosX = m_RelX + ComputeXModifier();
int PosY = m_RelY + ComputeYModifier();
BS_RenderObject::SetPos(PosX, PosY);
@@ -404,16 +372,12 @@ void BS_Animation::ComputeCurrentCharacteristics()
// -----------------------------------------------------------------------------
-bool BS_Animation::LockAllFrames()
-{
- if (!m_FramesLocked)
- {
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::LockAllFrames() {
+ if (!m_FramesLocked) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i)
- {
- if (!BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName))
- {
+ for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i) {
+ if (!BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName)) {
BS_LOG_ERRORLN("Could not lock all animation frames.");
return false;
}
@@ -427,17 +391,13 @@ bool BS_Animation::LockAllFrames()
// -----------------------------------------------------------------------------
-bool BS_Animation::UnlockAllFrames()
-{
- if (m_FramesLocked)
- {
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::UnlockAllFrames() {
+ if (m_FramesLocked) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i)
- {
- BS_Resource* pResource;
- if (!(pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName)))
- {
+ for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i) {
+ BS_Resource *pResource;
+ if (!(pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName))) {
BS_LOG_ERRORLN("Could not unlock all animation frames.");
return false;
}
@@ -457,54 +417,48 @@ bool BS_Animation::UnlockAllFrames()
// Getter
// -----------------------------------------------------------------------------
-BS_Animation::ANIMATION_TYPES BS_Animation::GetAnimationType() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+BS_Animation::ANIMATION_TYPES BS_Animation::GetAnimationType() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->GetAnimationType();
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetFPS() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+int BS_Animation::GetFPS() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->GetFPS();
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetFrameCount() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+int BS_Animation::GetFrameCount() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->GetFrameCount();
}
// -----------------------------------------------------------------------------
-bool BS_Animation::IsScalingAllowed() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::IsScalingAllowed() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->IsScalingAllowed();
}
// -----------------------------------------------------------------------------
-bool BS_Animation::IsAlphaAllowed() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::IsAlphaAllowed() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->IsAlphaAllowed();
}
// -----------------------------------------------------------------------------
-bool BS_Animation::IsColorModulationAllowed() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+bool BS_Animation::IsColorModulationAllowed() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->IsColorModulationAllowed();
}
@@ -513,8 +467,7 @@ bool BS_Animation::IsColorModulationAllowed() const
// Positionieren
// -----------------------------------------------------------------------------
-void BS_Animation::SetPos(int RelX, int RelY)
-{
+void BS_Animation::SetPos(int RelX, int RelY) {
m_RelX = RelX;
m_RelY = RelY;
@@ -523,8 +476,7 @@ void BS_Animation::SetPos(int RelX, int RelY)
// -----------------------------------------------------------------------------
-void BS_Animation::SetX(int RelX)
-{
+void BS_Animation::SetX(int RelX) {
m_RelX = RelX;
ComputeCurrentCharacteristics();
@@ -532,8 +484,7 @@ void BS_Animation::SetX(int RelX)
// -----------------------------------------------------------------------------
-void BS_Animation::SetY(int RelY)
-{
+void BS_Animation::SetY(int RelY) {
m_RelY = RelY;
ComputeCurrentCharacteristics();
@@ -543,19 +494,16 @@ void BS_Animation::SetY(int RelY)
// Darstellungsart festlegen
// -----------------------------------------------------------------------------
-void BS_Animation::SetAlpha(int Alpha)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::SetAlpha(int Alpha) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- if (!animationDescriptionPtr->IsAlphaAllowed())
- {
+ if (!animationDescriptionPtr->IsAlphaAllowed()) {
BS_LOG_WARNINGLN("Tried to set alpha value on an animation that does not support alpha. Call was ignored.");
return;
}
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -563,19 +511,16 @@ void BS_Animation::SetAlpha(int Alpha)
// -----------------------------------------------------------------------------
-void BS_Animation::SetModulationColor(unsigned int ModulationColor)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::SetModulationColor(unsigned int ModulationColor) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- if (!animationDescriptionPtr->IsColorModulationAllowed())
- {
+ if (!animationDescriptionPtr->IsColorModulationAllowed()) {
BS_LOG_WARNINGLN("Tried to set modulation color on an animation that does not support color modulation. Call was ignored");
return;
}
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -583,26 +528,22 @@ void BS_Animation::SetModulationColor(unsigned int ModulationColor)
// -----------------------------------------------------------------------------
-void BS_Animation::SetScaleFactor(float ScaleFactor)
-{
+void BS_Animation::SetScaleFactor(float ScaleFactor) {
SetScaleFactorX(ScaleFactor);
SetScaleFactorY(ScaleFactor);
}
// -----------------------------------------------------------------------------
-void BS_Animation::SetScaleFactorX(float ScaleFactorX)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::SetScaleFactorX(float ScaleFactorX) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- if (!animationDescriptionPtr->IsScalingAllowed())
- {
+ if (!animationDescriptionPtr->IsScalingAllowed()) {
BS_LOG_WARNINGLN("Tried to set x scale factor on an animation that does not support scaling. Call was ignored");
return;
}
- if (ScaleFactorX != m_ScaleFactorX)
- {
+ if (ScaleFactorX != m_ScaleFactorX) {
m_ScaleFactorX = ScaleFactorX;
if (m_ScaleFactorX <= 0.0f) m_ScaleFactorX = 0.001f;
ForceRefresh();
@@ -612,18 +553,15 @@ void BS_Animation::SetScaleFactorX(float ScaleFactorX)
// -----------------------------------------------------------------------------
-void BS_Animation::SetScaleFactorY(float ScaleFactorY)
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+void BS_Animation::SetScaleFactorY(float ScaleFactorY) {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- if (!animationDescriptionPtr->IsScalingAllowed())
- {
+ if (!animationDescriptionPtr->IsScalingAllowed()) {
BS_LOG_WARNINGLN("Tried to set y scale factor on an animation that does not support scaling. Call was ignored");
return;
}
- if (ScaleFactorY != m_ScaleFactorY)
- {
+ if (ScaleFactorY != m_ScaleFactorY) {
m_ScaleFactorY = ScaleFactorY;
if (m_ScaleFactorY <= 0.0f) m_ScaleFactorY = 0.001f;
ForceRefresh();
@@ -633,56 +571,50 @@ void BS_Animation::SetScaleFactorY(float ScaleFactorY)
// -----------------------------------------------------------------------------
-const Common::String & BS_Animation::GetCurrentAction() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+const Common::String &BS_Animation::GetCurrentAction() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
return animationDescriptionPtr->GetFrame(m_CurrentFrame).Action;
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetX() const
-{
+int BS_Animation::GetX() const {
return m_RelX;
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetY() const
-{
+int BS_Animation::GetY() const {
return m_RelY;
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetAbsoluteX() const
-{
+int BS_Animation::GetAbsoluteX() const {
return m_AbsoluteX + (m_RelX - m_X);
}
// -----------------------------------------------------------------------------
-int BS_Animation::GetAbsoluteY() const
-{
+int BS_Animation::GetAbsoluteY() const {
return m_AbsoluteY + (m_RelY - m_Y);
}
// -----------------------------------------------------------------------------
-int BS_Animation::ComputeXModifier() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+int BS_Animation::ComputeXModifier() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- const BS_AnimationResource::Frame & CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
+ const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
BS_ASSERT(pResource);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource* pBitmap = static_cast<BS_BitmapResource *>(pResource);
+ BS_BitmapResource *pBitmap = static_cast<BS_BitmapResource *>(pResource);
int Result = CurFrame.FlipV ? - static_cast<int>((pBitmap->GetWidth() - 1 - CurFrame.HotspotX) * m_ScaleFactorX) :
- - static_cast<int>(CurFrame.HotspotX * m_ScaleFactorX);
+ - static_cast<int>(CurFrame.HotspotX * m_ScaleFactorX);
pBitmap->Release();
@@ -691,19 +623,18 @@ int BS_Animation::ComputeXModifier() const
// -----------------------------------------------------------------------------
-int BS_Animation::ComputeYModifier() const
-{
- BS_AnimationDescription * animationDescriptionPtr = GetAnimationDescription();
+int BS_Animation::ComputeYModifier() const {
+ BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
BS_ASSERT(animationDescriptionPtr);
- const BS_AnimationResource::Frame & CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
+ const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(CurFrame.FileName);
BS_ASSERT(pResource);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource* pBitmap = static_cast<BS_BitmapResource *>(pResource);
+ BS_BitmapResource *pBitmap = static_cast<BS_BitmapResource *>(pResource);
int Result = CurFrame.FlipH ? - static_cast<int>((pBitmap->GetHeight() - 1 - CurFrame.HotspotY) * m_ScaleFactorY) :
- - static_cast<int>(CurFrame.HotspotY * m_ScaleFactorY);
+ - static_cast<int>(CurFrame.HotspotY * m_ScaleFactorY);
pBitmap->Release();
@@ -712,8 +643,7 @@ int BS_Animation::ComputeYModifier() const
// -----------------------------------------------------------------------------
-void BS_Animation::RegisterActionCallback(ANIMATION_CALLBACK Callback, unsigned int Data)
-{
+void BS_Animation::RegisterActionCallback(ANIMATION_CALLBACK Callback, unsigned int Data) {
ANIMATION_CALLBACK_DATA CD;
CD.Callback = Callback;
CD.Data = Data;
@@ -722,8 +652,7 @@ void BS_Animation::RegisterActionCallback(ANIMATION_CALLBACK Callback, unsigned
// -----------------------------------------------------------------------------
-void BS_Animation::RegisterLoopPointCallback(ANIMATION_CALLBACK Callback, unsigned int Data)
-{
+void BS_Animation::RegisterLoopPointCallback(ANIMATION_CALLBACK Callback, unsigned int Data) {
ANIMATION_CALLBACK_DATA CD;
CD.Callback = Callback;
CD.Data = Data;
@@ -732,8 +661,7 @@ void BS_Animation::RegisterLoopPointCallback(ANIMATION_CALLBACK Callback, unsign
// -----------------------------------------------------------------------------
-void BS_Animation::RegisterDeleteCallback(ANIMATION_CALLBACK Callback, unsigned int Data)
-{
+void BS_Animation::RegisterDeleteCallback(ANIMATION_CALLBACK Callback, unsigned int Data) {
ANIMATION_CALLBACK_DATA CD;
CD.Callback = Callback;
CD.Data = Data;
@@ -744,15 +672,13 @@ void BS_Animation::RegisterDeleteCallback(ANIMATION_CALLBACK Callback, unsigned
// Persistenz
// -----------------------------------------------------------------------------
-void BS_Animation::PersistCallbackVector(BS_OutputPersistenceBlock & Writer, const Common::Array<ANIMATION_CALLBACK_DATA> & Vector)
-{
+void BS_Animation::PersistCallbackVector(BS_OutputPersistenceBlock &Writer, const Common::Array<ANIMATION_CALLBACK_DATA> & Vector) {
// Anzahl an Callbacks persistieren.
Writer.Write(Vector.size());
-
+
// Alle Callbacks einzeln persistieren.
Common::Array<ANIMATION_CALLBACK_DATA>::const_iterator It = Vector.begin();
- while (It != Vector.end())
- {
+ while (It != Vector.end()) {
Writer.Write(BS_CallbackRegistry::GetInstance().ResolveCallbackPointer(It->Callback));
Writer.Write(It->Data);
@@ -762,8 +688,7 @@ void BS_Animation::PersistCallbackVector(BS_OutputPersistenceBlock & Writer, con
// -----------------------------------------------------------------------------
-void BS_Animation::UnpersistCallbackVector(BS_InputPersistenceBlock & Reader, Common::Array<ANIMATION_CALLBACK_DATA> & Vector)
-{
+void BS_Animation::UnpersistCallbackVector(BS_InputPersistenceBlock &Reader, Common::Array<ANIMATION_CALLBACK_DATA> & Vector) {
// Callbackvector leeren.
Vector.resize(0);
@@ -772,14 +697,13 @@ void BS_Animation::UnpersistCallbackVector(BS_InputPersistenceBlock & Reader, Co
Reader.Read(CallbackCount);
// Alle Callbacks einzeln wieder herstellen.
- for (unsigned int i = 0; i < CallbackCount; ++i)
- {
+ for (unsigned int i = 0; i < CallbackCount; ++i) {
ANIMATION_CALLBACK_DATA CallbackData;
Common::String CallbackFunctionName;
Reader.Read(CallbackFunctionName);
CallbackData.Callback = reinterpret_cast<ANIMATION_CALLBACK>(BS_CallbackRegistry::GetInstance().ResolveCallbackFunction(CallbackFunctionName));
-
+
Reader.Read(CallbackData.Data);
Vector.push_back(CallbackData);
@@ -788,8 +712,7 @@ void BS_Animation::UnpersistCallbackVector(BS_InputPersistenceBlock & Reader, Co
// -----------------------------------------------------------------------------
-bool BS_Animation::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_Animation::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_RenderObject::Persist(Writer);
@@ -806,20 +729,15 @@ bool BS_Animation::Persist(BS_OutputPersistenceBlock & Writer)
Writer.Write(static_cast<unsigned int>(m_Direction));
// Je nach Animationstyp entweder das Template oder die Ressource speichern.
- if (m_AnimationResourcePtr)
- {
+ if (m_AnimationResourcePtr) {
unsigned int Marker = 0;
Writer.Write(Marker);
Writer.Write(m_AnimationResourcePtr->GetFileName());
- }
- else if (m_AnimationTemplateHandle)
- {
+ } else if (m_AnimationTemplateHandle) {
unsigned int Marker = 1;
Writer.Write(Marker);
Writer.Write(m_AnimationTemplateHandle);
- }
- else
- {
+ } else {
BS_ASSERT(false);
}
@@ -837,8 +755,7 @@ bool BS_Animation::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_Animation::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_Animation::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_RenderObject::Unpersist(Reader);
@@ -859,18 +776,13 @@ bool BS_Animation::Unpersist(BS_InputPersistenceBlock & Reader)
// Animationstyp einlesen.
unsigned int Marker;
Reader.Read(Marker);
- if (Marker == 0)
- {
+ if (Marker == 0) {
Common::String ResourceFilename;
Reader.Read(ResourceFilename);
InitializeAnimationResource(ResourceFilename);
- }
- else if (Marker == 1)
- {
+ } else if (Marker == 1) {
Reader.Read(m_AnimationTemplateHandle);
- }
- else
- {
+ } else {
BS_ASSERT(false);
}
@@ -888,8 +800,7 @@ bool BS_Animation::Unpersist(BS_InputPersistenceBlock & Reader)
// -----------------------------------------------------------------------------
-BS_AnimationDescription * BS_Animation::GetAnimationDescription() const
-{
+BS_AnimationDescription *BS_Animation::GetAnimationDescription() const {
if (m_AnimationResourcePtr) return m_AnimationResourcePtr;
else return BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(m_AnimationTemplateHandle);
}
diff --git a/engines/sword25/gfx/animation.h b/engines/sword25/gfx/animation.h
index 9faf17d7a3..93f450dce0 100644
--- a/engines/sword25/gfx/animation.h
+++ b/engines/sword25/gfx/animation.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,23 +53,21 @@ class BS_AnimationTemplate;
class BS_AnimationDescription;
class BS_InputPersistenceBlock;
-class BS_Animation : public BS_TimedRenderObject
-{
-friend class BS_RenderObject;
+class BS_Animation : public BS_TimedRenderObject {
+ friend class BS_RenderObject;
private:
- BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String & FileName);
- BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate & Template);
- BS_Animation(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
+ BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &FileName);
+ BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate &Template);
+ BS_Animation(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
public:
- enum ANIMATION_TYPES
- {
+ enum ANIMATION_TYPES {
AT_ONESHOT,
AT_LOOP,
AT_JOJO
};
-
+
virtual ~BS_Animation();
void Play();
@@ -80,44 +78,44 @@ public:
virtual void SetPos(int X, int Y);
virtual void SetX(int X);
virtual void SetY(int Y);
-
+
virtual int GetX() const;
virtual int GetY() const;
virtual int GetAbsoluteX() const;
virtual int GetAbsoluteY() const;
/**
- @brief Setzt den Alphawert der Animation.
- @param Alpha der neue Alphawert der Animation (0 = keine Deckung, 255 = volle Deckung).
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
+ @brief Setzt den Alphawert der Animation.
+ @param Alpha der neue Alphawert der Animation (0 = keine Deckung, 255 = volle Deckung).
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
*/
void SetAlpha(int Alpha);
/**
- @brief Setzt die Modulationfarbe der Animation.
- @param Color eine 24-Bit Farbe, die die Modulationsfarbe der Animation festlegt.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
+ @brief Setzt die Modulationfarbe der Animation.
+ @param Color eine 24-Bit Farbe, die die Modulationsfarbe der Animation festlegt.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
*/
void SetModulationColor(unsigned int ModulationColor);
/**
- @brief Setzt den Skalierungsfaktor der Animation.
- @param ScaleFactor der Faktor um den die Animation in beide Richtungen gestreckt werden soll.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor der Animation.
+ @param ScaleFactor der Faktor um den die Animation in beide Richtungen gestreckt werden soll.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactor(float ScaleFactor);
/**
- @brief Setzt den Skalierungsfaktor der Animation auf der X-Achse.
- @param ScaleFactor der Faktor um den die Animation in Richtungen der X-Achse gestreckt werden soll.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor der Animation auf der X-Achse.
+ @param ScaleFactor der Faktor um den die Animation in Richtungen der X-Achse gestreckt werden soll.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactorX(float ScaleFactorX);
/**
- @brief Setzt den Skalierungsfaktor der Animation auf der Y-Achse.
- @param ScaleFactor der Faktor um den die Animation in Richtungen der Y-Achse gestreckt werden soll.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor der Animation auf der Y-Achse.
+ @param ScaleFactor der Faktor um den die Animation in Richtungen der Y-Achse gestreckt werden soll.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactorY(float ScaleFactorY);
@@ -125,28 +123,36 @@ public:
@brief Gibt den Skalierungsfakter der Animation auf der X-Achse zurück.
@remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
- float GetScaleFactorX() const { return m_ScaleFactorX; }
+ float GetScaleFactorX() const {
+ return m_ScaleFactorX;
+ }
/**
@brief Gibt den Skalierungsfakter der Animation auf der Y-Achse zurück.
@remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
- float GetScaleFactorY() const { return m_ScaleFactorY; }
-
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ float GetScaleFactorY() const {
+ return m_ScaleFactorY;
+ }
+
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
virtual void FrameNotification(int TimeElapsed);
-
- ANIMATION_TYPES GetAnimationType() const;
- int GetFPS() const;
- int GetFrameCount() const;
- bool IsScalingAllowed() const;
- bool IsAlphaAllowed() const;
- bool IsColorModulationAllowed() const;
- unsigned int GetCurrentFrame() const { return m_CurrentFrame; }
- const Common::String & GetCurrentAction() const ;
- bool IsRunning() const { return m_Running; }
+
+ ANIMATION_TYPES GetAnimationType() const;
+ int GetFPS() const;
+ int GetFrameCount() const;
+ bool IsScalingAllowed() const;
+ bool IsAlphaAllowed() const;
+ bool IsColorModulationAllowed() const;
+ unsigned int GetCurrentFrame() const {
+ return m_CurrentFrame;
+ }
+ const Common::String &GetCurrentAction() const ;
+ bool IsRunning() const {
+ return m_Running;
+ }
typedef bool (*ANIMATION_CALLBACK)(unsigned int);
@@ -158,68 +164,66 @@ protected:
virtual bool DoRender();
private:
- enum DIRECTION
- {
+ enum DIRECTION {
FORWARD,
BACKWARD
};
- int m_RelX;
- int m_RelY;
- float m_ScaleFactorX;
- float m_ScaleFactorY;
- unsigned int m_ModulationColor;
- unsigned int m_CurrentFrame;
- int m_CurrentFrameTime;
- bool m_Running;
- bool m_Finished;
- DIRECTION m_Direction;
- BS_AnimationResource * m_AnimationResourcePtr;
- unsigned int m_AnimationTemplateHandle;
- bool m_FramesLocked;
-
- struct ANIMATION_CALLBACK_DATA
- {
- ANIMATION_CALLBACK Callback;
- unsigned int Data;
+ int m_RelX;
+ int m_RelY;
+ float m_ScaleFactorX;
+ float m_ScaleFactorY;
+ unsigned int m_ModulationColor;
+ unsigned int m_CurrentFrame;
+ int m_CurrentFrameTime;
+ bool m_Running;
+ bool m_Finished;
+ DIRECTION m_Direction;
+ BS_AnimationResource *m_AnimationResourcePtr;
+ unsigned int m_AnimationTemplateHandle;
+ bool m_FramesLocked;
+
+ struct ANIMATION_CALLBACK_DATA {
+ ANIMATION_CALLBACK Callback;
+ unsigned int Data;
};
Common::Array<ANIMATION_CALLBACK_DATA> m_LoopPointCallbacks;
Common::Array<ANIMATION_CALLBACK_DATA> m_ActionCallbacks;
Common::Array<ANIMATION_CALLBACK_DATA> m_DeleteCallbacks;
/**
- @brief Lockt alle Frames.
- @return Gibt false zurück, falls nicht alle Frames gelockt werden konnten.
+ @brief Lockt alle Frames.
+ @return Gibt false zurück, falls nicht alle Frames gelockt werden konnten.
*/
bool LockAllFrames();
/**
- @brief Unlockt alle Frames.
- @return Gibt false zurück, falls nicht alles Frames freigegeben werden konnten.
+ @brief Unlockt alle Frames.
+ @return Gibt false zurück, falls nicht alles Frames freigegeben werden konnten.
*/
bool UnlockAllFrames();
/**
- @brief Diese Methode aktualisiert die Parameter (Größe, Position) der Animation anhand des aktuellen Frames.
+ @brief Diese Methode aktualisiert die Parameter (Größe, Position) der Animation anhand des aktuellen Frames.
- Diese Methode muss bei jedem Framewechsel aufgerufen werden damit der RenderObject-Manager immer aktuelle Daten hat.
+ Diese Methode muss bei jedem Framewechsel aufgerufen werden damit der RenderObject-Manager immer aktuelle Daten hat.
*/
void ComputeCurrentCharacteristics();
/**
- @brief Berechnet den Abstand zwischen dem linken Rand und dem Hotspot auf X-Achse in der aktuellen Darstellung.
+ @brief Berechnet den Abstand zwischen dem linken Rand und dem Hotspot auf X-Achse in der aktuellen Darstellung.
*/
int ComputeXModifier() const;
/**
- @brief Berechnet den Abstand zwischen dem linken Rand und dem Hotspot auf X-Achse in der aktuellen Darstellung.
+ @brief Berechnet den Abstand zwischen dem linken Rand und dem Hotspot auf X-Achse in der aktuellen Darstellung.
*/
int ComputeYModifier() const;
void InitMembers();
- void PersistCallbackVector(BS_OutputPersistenceBlock & Writer, const Common::Array<ANIMATION_CALLBACK_DATA> & Vector);
- void UnpersistCallbackVector(BS_InputPersistenceBlock & Reader, Common::Array<ANIMATION_CALLBACK_DATA> & Vector);
- BS_AnimationDescription * GetAnimationDescription() const;
+ void PersistCallbackVector(BS_OutputPersistenceBlock &Writer, const Common::Array<ANIMATION_CALLBACK_DATA> & Vector);
+ void UnpersistCallbackVector(BS_InputPersistenceBlock &Reader, Common::Array<ANIMATION_CALLBACK_DATA> & Vector);
+ BS_AnimationDescription *GetAnimationDescription() const;
void InitializeAnimationResource(const Common::String &FileName);
};
diff --git a/engines/sword25/gfx/animationdescription.cpp b/engines/sword25/gfx/animationdescription.cpp
index 405a5c2938..f8ed9b893c 100644
--- a/engines/sword25/gfx/animationdescription.cpp
+++ b/engines/sword25/gfx/animationdescription.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -46,8 +46,7 @@ namespace Sword25 {
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_AnimationDescription::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_AnimationDescription::Persist(BS_OutputPersistenceBlock &Writer) {
Writer.Write(static_cast<unsigned int>(m_AnimationType));
Writer.Write(m_FPS);
Writer.Write(m_MillisPerFrame);
@@ -60,8 +59,7 @@ bool BS_AnimationDescription::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_AnimationDescription::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_AnimationDescription::Unpersist(BS_InputPersistenceBlock &Reader) {
unsigned int AnimationType;
Reader.Read(AnimationType);
m_AnimationType = static_cast<BS_Animation::ANIMATION_TYPES>(AnimationType);
diff --git a/engines/sword25/gfx/animationdescription.h b/engines/sword25/gfx/animationdescription.h
index e6cb578d2d..e4c861d4e0 100644
--- a/engines/sword25/gfx/animationdescription.h
+++ b/engines/sword25/gfx/animationdescription.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,8 +49,7 @@ namespace Sword25 {
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_AnimationDescription : public BS_Persistable
-{
+class BS_AnimationDescription : public BS_Persistable {
protected:
BS_AnimationDescription() :
m_AnimationType(BS_Animation::AT_LOOP),
@@ -62,46 +61,57 @@ protected:
{};
public:
- struct Frame
- {
+ struct Frame {
// Die Hotspot-Angabe bezieht sich auf das ungeflippte Bild!!
- int HotspotX;
- int HotspotY;
- bool FlipV;
- bool FlipH;
- Common::String FileName;
- Common::String Action;
+ int HotspotX;
+ int HotspotY;
+ bool FlipV;
+ bool FlipH;
+ Common::String FileName;
+ Common::String Action;
};
// -----------------------------------------------------------------------------
// Abstrakte Methoden
// -----------------------------------------------------------------------------
-
- virtual const Frame & GetFrame(unsigned int Index) const = 0;
- virtual unsigned int GetFrameCount() const = 0;
- virtual void Unlock() = 0;
+
+ virtual const Frame &GetFrame(unsigned int Index) const = 0;
+ virtual unsigned int GetFrameCount() const = 0;
+ virtual void Unlock() = 0;
// -----------------------------------------------------------------------------
// Getter Methoden
// -----------------------------------------------------------------------------
-
- BS_Animation::ANIMATION_TYPES GetAnimationType() const { return m_AnimationType; }
- int GetFPS() const { return m_FPS; }
- int GetMillisPerFrame() const { return m_MillisPerFrame; }
- bool IsScalingAllowed() const { return m_ScalingAllowed; }
- bool IsAlphaAllowed() const { return m_AlphaAllowed; }
- bool IsColorModulationAllowed() const { return m_ColorModulationAllowed; }
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ BS_Animation::ANIMATION_TYPES GetAnimationType() const {
+ return m_AnimationType;
+ }
+ int GetFPS() const {
+ return m_FPS;
+ }
+ int GetMillisPerFrame() const {
+ return m_MillisPerFrame;
+ }
+ bool IsScalingAllowed() const {
+ return m_ScalingAllowed;
+ }
+ bool IsAlphaAllowed() const {
+ return m_AlphaAllowed;
+ }
+ bool IsColorModulationAllowed() const {
+ return m_ColorModulationAllowed;
+ }
+
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
- BS_Animation::ANIMATION_TYPES m_AnimationType;
- int m_FPS;
- int m_MillisPerFrame;
- bool m_ScalingAllowed;
- bool m_AlphaAllowed;
- bool m_ColorModulationAllowed;
+ BS_Animation::ANIMATION_TYPES m_AnimationType;
+ int m_FPS;
+ int m_MillisPerFrame;
+ bool m_ScalingAllowed;
+ bool m_AlphaAllowed;
+ bool m_ColorModulationAllowed;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp
index 5de3d90ff2..a0a7f25057 100644
--- a/engines/sword25/gfx/animationresource.cpp
+++ b/engines/sword25/gfx/animationresource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,34 +54,31 @@ namespace Sword25 {
// Constants
// -----------------------------------------------------------------------------
-namespace
-{
- const int DEFAULT_FPS = 10;
- const int MIN_FPS = 1;
- const int MAX_FPS = 200;
+namespace {
+const int DEFAULT_FPS = 10;
+const int MIN_FPS = 1;
+const int MAX_FPS = 200;
}
// -----------------------------------------------------------------------------
// Construction / Destruction
// -----------------------------------------------------------------------------
-BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
+BS_AnimationResource::BS_AnimationResource(const Common::String &FileName) :
BS_Resource(FileName, BS_Resource::TYPE_ANIMATION),
- m_Valid(false)
-{
+ m_Valid(false) {
// Pointer auf den Package-Manager bekommen
- BS_PackageManager* PackagePtr = BS_Kernel::GetInstance()->GetPackage();
+ BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
BS_ASSERT(PackagePtr);
// Animations-XML laden
TiXmlDocument Doc;
{
- // Die Daten werden zunächst über den Package-Manager gelesen und dann in einen um ein Byte größeren Buffer kopiert und
+ // Die Daten werden zunächst über den Package-Manager gelesen und dann in einen um ein Byte größeren Buffer kopiert und
// NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
unsigned int FileSize;
- char * LoadBuffer = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
- if (!LoadBuffer)
- {
+ char *LoadBuffer = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
+ if (!LoadBuffer) {
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
return;
}
@@ -94,27 +91,24 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
// Datei parsen
Doc.Parse(&WorkBuffer[0]);
free(WorkBuffer);
- if (Doc.Error())
- {
+ if (Doc.Error()) {
BS_LOG_ERRORLN("The following TinyXML-Error occured while parsing \"%s\": %s", GetFileName().c_str(), Doc.ErrorDesc());
return;
}
}
// Wurzelknoten des Animations-Tags finden, prüfen und Attribute auslesen.
- TiXmlElement* pElement;
+ TiXmlElement *pElement;
{
- TiXmlNode* pNode = Doc.FirstChild("animation");
- if (!pNode || pNode->Type() != TiXmlNode::ELEMENT)
- {
+ TiXmlNode *pNode = Doc.FirstChild("animation");
+ if (!pNode || pNode->Type() != TiXmlNode::ELEMENT) {
BS_LOG_ERRORLN("No <animation> tag found in \"%s\".", GetFileName().c_str());
return;
}
pElement = pNode->ToElement();
// Animation-Tag parsen
- if (!ParseAnimationTag(*pElement, m_FPS, m_AnimationType))
- {
+ if (!ParseAnimationTag(*pElement, m_FPS, m_AnimationType)) {
BS_LOG_ERRORLN("An error occurred while parsing <animation> tag in \"%s\".", GetFileName().c_str());
return;
}
@@ -131,17 +125,15 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
}
// Nacheinander alle Frames-Informationen erstellen.
- TiXmlElement* pFrameElement = pElement->FirstChild("frame")->ToElement();
- while (pFrameElement)
- {
+ TiXmlElement *pFrameElement = pElement->FirstChild("frame")->ToElement();
+ while (pFrameElement) {
Frame CurFrame;
-
- if (!ParseFrameTag(*pFrameElement, CurFrame, *PackagePtr))
- {
+
+ if (!ParseFrameTag(*pFrameElement, CurFrame, *PackagePtr)) {
BS_LOG_ERRORLN("An error occurred in \"%s\" while parsing <frame> tag.", GetFileName().c_str());
return;
}
-
+
m_Frames.push_back(CurFrame);
pFrameElement = pFrameElement->NextSiblingElement("frame");
}
@@ -150,54 +142,46 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
PackagePtr->ChangeDirectory(OldDirectory);
// Sicherstellen, dass die Animation mindestens einen Frame besitzt
- if (m_Frames.empty())
- {
+ if (m_Frames.empty()) {
BS_LOG_ERRORLN("\"%s\" does not have any frames.", GetFileName().c_str());
return;
}
// Alle Frame-Dateien werden vorgecached
- if (!PrecacheAllFrames())
- {
+ if (!PrecacheAllFrames()) {
BS_LOG_ERRORLN("Could not precache all frames of \"%s\".", GetFileName().c_str());
return;
}
// Feststellen, ob die Animation skalierbar ist
- if (!ComputeFeatures())
- {
- BS_LOG_ERRORLN("Could not determine the features of \"%s\".", GetFileName().c_str());
- return;
- }
+ if (!ComputeFeatures()) {
+ BS_LOG_ERRORLN("Could not determine the features of \"%s\".", GetFileName().c_str());
+ return;
+ }
- m_Valid = true;
+ m_Valid = true;
}
// -----------------------------------------------------------------------------
// Dokument-Parsermethoden
// -----------------------------------------------------------------------------
-bool BS_AnimationResource::ParseAnimationTag(TiXmlElement& AnimationTag, int& FPS, BS_Animation::ANIMATION_TYPES & AnimationType)
-{
+bool BS_AnimationResource::ParseAnimationTag(TiXmlElement &AnimationTag, int &FPS, BS_Animation::ANIMATION_TYPES &AnimationType) {
// FPS einlesen
- const char* FPSString;
- if (FPSString = AnimationTag.Attribute("fps"))
- {
+ const char *FPSString;
+ if (FPSString = AnimationTag.Attribute("fps")) {
int TempFPS;
- if (!BS_String::ToInt(Common::String(FPSString), TempFPS) || TempFPS < MIN_FPS || TempFPS > MAX_FPS)
- {
+ if (!BS_String::ToInt(Common::String(FPSString), TempFPS) || TempFPS < MIN_FPS || TempFPS > MAX_FPS) {
BS_LOG_WARNINGLN("Illegal fps value (\"%s\") in <animation> tag in \"%s\". Assuming default (\"%d\"). "
- "The fps value has to be between %d and %d.",
- FPSString, GetFileName().c_str(), DEFAULT_FPS, MIN_FPS, MAX_FPS);
- }
- else
+ "The fps value has to be between %d and %d.",
+ FPSString, GetFileName().c_str(), DEFAULT_FPS, MIN_FPS, MAX_FPS);
+ } else
FPS = TempFPS;
}
// Loop-Typ einlesen
- const char* LoopTypeString;
- if (LoopTypeString = AnimationTag.Attribute("type"))
- {
+ const char *LoopTypeString;
+ if (LoopTypeString = AnimationTag.Attribute("type")) {
if (strcmp(LoopTypeString, "oneshot") == 0)
AnimationType = BS_Animation::AT_ONESHOT;
else if (strcmp(LoopTypeString, "loop") == 0)
@@ -206,7 +190,7 @@ bool BS_AnimationResource::ParseAnimationTag(TiXmlElement& AnimationTag, int& FP
AnimationType = BS_Animation::AT_JOJO;
else
BS_LOG_WARNINGLN("Illegal type value (\"%s\") in <animation> tag in \"%s\". Assuming default (\"loop\").",
- LoopTypeString, GetFileName().c_str());
+ LoopTypeString, GetFileName().c_str());
}
return true;
@@ -214,68 +198,59 @@ bool BS_AnimationResource::ParseAnimationTag(TiXmlElement& AnimationTag, int& FP
// -----------------------------------------------------------------------------
-bool BS_AnimationResource::ParseFrameTag(TiXmlElement& FrameTag, Frame& Frame_, BS_PackageManager& PackageManager)
-{
- const char* FileString = FrameTag.Attribute("file");
- if (!FileString)
- {
+bool BS_AnimationResource::ParseFrameTag(TiXmlElement &FrameTag, Frame &Frame_, BS_PackageManager &PackageManager) {
+ const char *FileString = FrameTag.Attribute("file");
+ if (!FileString) {
BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", GetFileName().c_str());
return false;
}
Frame_.FileName = PackageManager.GetAbsolutePath(FileString);
- if (Frame_.FileName == "")
- {
+ if (Frame_.FileName == "") {
BS_LOG_ERRORLN("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".", GetFileName().c_str(), FileString);
return false;
}
- const char* ActionString = FrameTag.Attribute("action");
+ const char *ActionString = FrameTag.Attribute("action");
if (ActionString)
Frame_.Action = ActionString;
- const char* HotspotxString = FrameTag.Attribute("hotspotx");
- const char* HotspotyString = FrameTag.Attribute("hotspoty");
+ const char *HotspotxString = FrameTag.Attribute("hotspotx");
+ const char *HotspotyString = FrameTag.Attribute("hotspoty");
if ((!HotspotxString && HotspotyString) ||
- (HotspotxString && !HotspotyString))
+ (HotspotxString && !HotspotyString))
BS_LOG_WARNINGLN("%s attribute occurred without %s attribute in <frame> tag in \"%s\". Assuming default (\"0\").",
- HotspotxString ? "hotspotx" : "hotspoty",
- !HotspotyString ? "hotspoty" : "hotspotx",
- GetFileName().c_str());
+ HotspotxString ? "hotspotx" : "hotspoty",
+ !HotspotyString ? "hotspoty" : "hotspotx",
+ GetFileName().c_str());
Frame_.HotspotX = 0;
if (HotspotxString && !BS_String::ToInt(Common::String(HotspotxString), Frame_.HotspotX))
BS_LOG_WARNINGLN("Illegal hotspotx value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").",
- HotspotxString,GetFileName().c_str(), Frame_.HotspotX);
+ HotspotxString, GetFileName().c_str(), Frame_.HotspotX);
Frame_.HotspotY = 0;
if (HotspotyString && !BS_String::ToInt(Common::String(HotspotyString), Frame_.HotspotY))
BS_LOG_WARNINGLN("Illegal hotspoty value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").",
- HotspotyString, GetFileName().c_str(), Frame_.HotspotY);
+ HotspotyString, GetFileName().c_str(), Frame_.HotspotY);
- const char* FlipVString = FrameTag.Attribute("flipv");
- if (FlipVString)
- {
- if (!BS_String::ToBool(Common::String(FlipVString), Frame_.FlipV))
- {
+ const char *FlipVString = FrameTag.Attribute("flipv");
+ if (FlipVString) {
+ if (!BS_String::ToBool(Common::String(FlipVString), Frame_.FlipV)) {
BS_LOG_WARNINGLN("Illegal flipv value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").",
- FlipVString, GetFileName().c_str());
+ FlipVString, GetFileName().c_str());
Frame_.FlipV = false;
}
- }
- else
+ } else
Frame_.FlipV = false;
- const char* FlipHString = FrameTag.Attribute("fliph");
- if (FlipHString)
- {
- if (!BS_String::ToBool(FlipHString, Frame_.FlipH))
- {
+ const char *FlipHString = FrameTag.Attribute("fliph");
+ if (FlipHString) {
+ if (!BS_String::ToBool(FlipHString, Frame_.FlipH)) {
BS_LOG_WARNINGLN("Illegal fliph value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").",
- FlipHString, GetFileName().c_str());
+ FlipHString, GetFileName().c_str());
Frame_.FlipH = false;
}
- }
- else
+ } else
Frame_.FlipH = false;
return true;
@@ -283,19 +258,15 @@ bool BS_AnimationResource::ParseFrameTag(TiXmlElement& FrameTag, Frame& Frame_,
// -----------------------------------------------------------------------------
-BS_AnimationResource::~BS_AnimationResource()
-{
+BS_AnimationResource::~BS_AnimationResource() {
}
// -----------------------------------------------------------------------------
-bool BS_AnimationResource::PrecacheAllFrames() const
-{
+bool BS_AnimationResource::PrecacheAllFrames() const {
Common::Array<Frame>::const_iterator Iter = m_Frames.begin();
- for (; Iter != m_Frames.end(); ++Iter)
- {
- if (!BS_Kernel::GetInstance()->GetResourceManager()->PrecacheResource((*Iter).FileName))
- {
+ for (; Iter != m_Frames.end(); ++Iter) {
+ if (!BS_Kernel::GetInstance()->GetResourceManager()->PrecacheResource((*Iter).FileName)) {
BS_LOG_ERRORLN("Could not precache \"%s\".", (*Iter).FileName.c_str());
return false;
}
@@ -306,8 +277,7 @@ bool BS_AnimationResource::PrecacheAllFrames() const
// -----------------------------------------------------------------------------
-bool BS_AnimationResource::ComputeFeatures()
-{
+bool BS_AnimationResource::ComputeFeatures() {
BS_ASSERT(m_Frames.size());
// Alle Features werden als vorhanden angenommen
@@ -317,11 +287,9 @@ bool BS_AnimationResource::ComputeFeatures()
// Alle Frame durchgehen und alle Features deaktivieren, die auch nur von einem Frame nicht unterstützt werden.
Common::Array<Frame>::const_iterator Iter = m_Frames.begin();
- for (; Iter != m_Frames.end(); ++Iter)
- {
- BS_BitmapResource* pBitmap;
- if (!(pBitmap = static_cast<BS_BitmapResource*> (BS_Kernel::GetInstance()->GetResourceManager()->RequestResource((*Iter).FileName))))
- {
+ for (; Iter != m_Frames.end(); ++Iter) {
+ BS_BitmapResource *pBitmap;
+ if (!(pBitmap = static_cast<BS_BitmapResource *>(BS_Kernel::GetInstance()->GetResourceManager()->RequestResource((*Iter).FileName)))) {
BS_LOG_ERRORLN("Could not request \"%s\".", (*Iter).FileName.c_str());
return false;
}
diff --git a/engines/sword25/gfx/animationresource.h b/engines/sword25/gfx/animationresource.h
index 1eff3edcc8..f67963e6f8 100644
--- a/engines/sword25/gfx/animationresource.h
+++ b/engines/sword25/gfx/animationresource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -63,34 +63,54 @@ class BS_PackageManager;
// Class Definition
// -----------------------------------------------------------------------------
-class BS_AnimationResource : public BS_Resource, public BS_AnimationDescription
-{
+class BS_AnimationResource : public BS_Resource, public BS_AnimationDescription {
public:
- BS_AnimationResource(const Common::String & FileName);
+ BS_AnimationResource(const Common::String &FileName);
virtual ~BS_AnimationResource();
- virtual const Frame & GetFrame(unsigned int Index) const { BS_ASSERT(Index < m_Frames.size()); return m_Frames[Index]; }
- virtual unsigned int GetFrameCount() const { return m_Frames.size(); }
- virtual void Unlock() { Release(); }
-
- BS_Animation::ANIMATION_TYPES GetAnimationType() const { return m_AnimationType; }
- int GetFPS() const { return m_FPS; }
- int GetMillisPerFrame() const { return m_MillisPerFrame; }
- bool IsScalingAllowed() const { return m_ScalingAllowed; }
- bool IsAlphaAllowed() const { return m_AlphaAllowed; }
- bool IsColorModulationAllowed() const { return m_ColorModulationAllowed; }
- bool IsValid() const { return m_Valid; }
+ virtual const Frame &GetFrame(unsigned int Index) const {
+ BS_ASSERT(Index < m_Frames.size());
+ return m_Frames[Index];
+ }
+ virtual unsigned int GetFrameCount() const {
+ return m_Frames.size();
+ }
+ virtual void Unlock() {
+ Release();
+ }
+
+ BS_Animation::ANIMATION_TYPES GetAnimationType() const {
+ return m_AnimationType;
+ }
+ int GetFPS() const {
+ return m_FPS;
+ }
+ int GetMillisPerFrame() const {
+ return m_MillisPerFrame;
+ }
+ bool IsScalingAllowed() const {
+ return m_ScalingAllowed;
+ }
+ bool IsAlphaAllowed() const {
+ return m_AlphaAllowed;
+ }
+ bool IsColorModulationAllowed() const {
+ return m_ColorModulationAllowed;
+ }
+ bool IsValid() const {
+ return m_Valid;
+ }
private:
- bool m_Valid;
+ bool m_Valid;
- Common::Array<Frame> m_Frames;
+ Common::Array<Frame> m_Frames;
//@{
/** @name Dokument-Parser Methoden */
- bool ParseAnimationTag(TiXmlElement& AnimationTag, int& FPS, BS_Animation::ANIMATION_TYPES & AnimationType);
- bool ParseFrameTag(TiXmlElement& FrameTag, Frame& Frame, BS_PackageManager& PackageManager);
+ bool ParseAnimationTag(TiXmlElement &AnimationTag, int &FPS, BS_Animation::ANIMATION_TYPES &AnimationType);
+ bool ParseFrameTag(TiXmlElement &FrameTag, Frame &Frame, BS_PackageManager &PackageManager);
//@}
diff --git a/engines/sword25/gfx/animationtemplate.cpp b/engines/sword25/gfx/animationtemplate.cpp
index 03afec36b7..dede871ece 100644
--- a/engines/sword25/gfx/animationtemplate.cpp
+++ b/engines/sword25/gfx/animationtemplate.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,16 +53,12 @@ namespace Sword25 {
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-unsigned int BS_AnimationTemplate::Create(const Common::String & SourceAnimation)
-{
- BS_AnimationTemplate * AnimationTemplatePtr = new BS_AnimationTemplate(SourceAnimation);
+unsigned int BS_AnimationTemplate::Create(const Common::String &SourceAnimation) {
+ BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(SourceAnimation);
- if (AnimationTemplatePtr->IsValid())
- {
+ if (AnimationTemplatePtr->IsValid()) {
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
- }
- else
- {
+ } else {
delete AnimationTemplatePtr;
return 0;
}
@@ -70,16 +66,12 @@ unsigned int BS_AnimationTemplate::Create(const Common::String & SourceAnimation
// -----------------------------------------------------------------------------
-unsigned int BS_AnimationTemplate::Create(const BS_AnimationTemplate & Other)
-{
- BS_AnimationTemplate * AnimationTemplatePtr = new BS_AnimationTemplate(Other);
+unsigned int BS_AnimationTemplate::Create(const BS_AnimationTemplate &Other) {
+ BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Other);
- if (AnimationTemplatePtr->IsValid())
- {
+ if (AnimationTemplatePtr->IsValid()) {
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
- }
- else
- {
+ } else {
delete AnimationTemplatePtr;
return 0;
}
@@ -87,16 +79,12 @@ unsigned int BS_AnimationTemplate::Create(const BS_AnimationTemplate & Other)
// -----------------------------------------------------------------------------
-unsigned int BS_AnimationTemplate::Create(BS_InputPersistenceBlock & Reader, unsigned int Handle)
-{
- BS_AnimationTemplate * AnimationTemplatePtr = new BS_AnimationTemplate(Reader, Handle);
+unsigned int BS_AnimationTemplate::Create(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
+ BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Reader, Handle);
- if (AnimationTemplatePtr->IsValid())
- {
+ if (AnimationTemplatePtr->IsValid()) {
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
- }
- else
- {
+ } else {
delete AnimationTemplatePtr;
return 0;
}
@@ -104,8 +92,7 @@ unsigned int BS_AnimationTemplate::Create(BS_InputPersistenceBlock & Reader, uns
// -----------------------------------------------------------------------------
-BS_AnimationTemplate::BS_AnimationTemplate(const Common::String & SourceAnimation)
-{
+BS_AnimationTemplate::BS_AnimationTemplate(const Common::String &SourceAnimation) {
// Objekt registrieren.
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this);
@@ -120,8 +107,7 @@ BS_AnimationTemplate::BS_AnimationTemplate(const Common::String & SourceAnimatio
// -----------------------------------------------------------------------------
-BS_AnimationTemplate::BS_AnimationTemplate(const BS_AnimationTemplate & Other)
-{
+BS_AnimationTemplate::BS_AnimationTemplate(const BS_AnimationTemplate &Other) {
// Objekt registrieren.
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this);
@@ -147,23 +133,20 @@ BS_AnimationTemplate::BS_AnimationTemplate(const BS_AnimationTemplate & Other)
// -----------------------------------------------------------------------------
-BS_AnimationTemplate::BS_AnimationTemplate(BS_InputPersistenceBlock & Reader, unsigned int Handle)
-{
+BS_AnimationTemplate::BS_AnimationTemplate(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
// Objekt registrieren.
- BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this, Handle);
+ BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this, Handle);
// Objekt laden.
- m_Valid = Unpersist(Reader);
+ m_Valid = Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-BS_AnimationResource * BS_AnimationTemplate::RequestSourceAnimation(const Common::String & SourceAnimation) const
-{
- BS_ResourceManager * RMPtr = BS_Kernel::GetInstance()->GetResourceManager();
- BS_Resource * ResourcePtr;
- if (NULL == (ResourcePtr = RMPtr->RequestResource(SourceAnimation)) || ResourcePtr->GetType() != BS_Resource::TYPE_ANIMATION)
- {
+BS_AnimationResource *BS_AnimationTemplate::RequestSourceAnimation(const Common::String &SourceAnimation) const {
+ BS_ResourceManager *RMPtr = BS_Kernel::GetInstance()->GetResourceManager();
+ BS_Resource *ResourcePtr;
+ if (NULL == (ResourcePtr = RMPtr->RequestResource(SourceAnimation)) || ResourcePtr->GetType() != BS_Resource::TYPE_ANIMATION) {
BS_LOG_ERRORLN("The resource \"%s\" could not be requested or is has an invalid type. The animation template can't be created.", SourceAnimation.c_str());
return 0;
}
@@ -172,11 +155,9 @@ BS_AnimationResource * BS_AnimationTemplate::RequestSourceAnimation(const Common
// -----------------------------------------------------------------------------
-BS_AnimationTemplate::~BS_AnimationTemplate()
-{
+BS_AnimationTemplate::~BS_AnimationTemplate() {
// Animations-Resource freigeben
- if (m_SourceAnimationPtr)
- {
+ if (m_SourceAnimationPtr) {
m_SourceAnimationPtr->Release();
}
@@ -186,64 +167,52 @@ BS_AnimationTemplate::~BS_AnimationTemplate()
// -----------------------------------------------------------------------------
-void BS_AnimationTemplate::AddFrame(int Index)
-{
- if (ValidateSourceIndex(Index))
- {
+void BS_AnimationTemplate::AddFrame(int Index) {
+ if (ValidateSourceIndex(Index)) {
m_Frames.push_back(m_SourceAnimationPtr->GetFrame(Index));
}
}
// -----------------------------------------------------------------------------
-void BS_AnimationTemplate::SetFrame(int DestIndex, int SrcIndex)
-{
- if (ValidateDestIndex(DestIndex) && ValidateSourceIndex(SrcIndex))
- {
+void BS_AnimationTemplate::SetFrame(int DestIndex, int SrcIndex) {
+ if (ValidateDestIndex(DestIndex) && ValidateSourceIndex(SrcIndex)) {
m_Frames[DestIndex] = m_SourceAnimationPtr->GetFrame(SrcIndex);
}
}
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplate::ValidateSourceIndex(unsigned int Index) const
-{
- if (Index > m_SourceAnimationPtr->GetFrameCount())
- {
+bool BS_AnimationTemplate::ValidateSourceIndex(unsigned int Index) const {
+ if (Index > m_SourceAnimationPtr->GetFrameCount()) {
BS_LOG_WARNINGLN("Tried to insert a frame (\"%d\") that does not exist in the source animation (\"%s\"). Ignoring call.",
- Index, m_SourceAnimationPtr->GetFileName().c_str());
+ Index, m_SourceAnimationPtr->GetFileName().c_str());
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplate::ValidateDestIndex(unsigned int Index) const
-{
- if (Index > m_Frames.size())
- {
+bool BS_AnimationTemplate::ValidateDestIndex(unsigned int Index) const {
+ if (Index > m_Frames.size()) {
BS_LOG_WARNINGLN("Tried to change a nonexistent frame (\"%d\") in a template animation. Ignoring call.",
- Index);
+ Index);
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-void BS_AnimationTemplate::SetFPS(int FPS)
-{
+void BS_AnimationTemplate::SetFPS(int FPS) {
m_FPS = FPS;
m_MillisPerFrame = 1000000 / m_FPS;
}
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Parent persistieren.
@@ -254,8 +223,7 @@ bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock & Writer)
// Frames einzeln persistieren.
Common::Array<const Frame>::const_iterator Iter = m_Frames.begin();
- while (Iter != m_Frames.end())
- {
+ while (Iter != m_Frames.end()) {
Writer.Write(Iter->HotspotX);
Writer.Write(Iter->HotspotY);
Writer.Write(Iter->FlipV);
@@ -274,8 +242,7 @@ bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplate::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_AnimationTemplate::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// Parent wieder herstellen.
@@ -286,8 +253,7 @@ bool BS_AnimationTemplate::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(FrameCount);
// Frames einzeln wieder herstellen.
- for (unsigned int i = 0; i < FrameCount; ++i)
- {
+ for (unsigned int i = 0; i < FrameCount; ++i) {
Frame frame;
Reader.Read(frame.HotspotX);
Reader.Read(frame.HotspotY);
diff --git a/engines/sword25/gfx/animationtemplate.h b/engines/sword25/gfx/animationtemplate.h
index 389353431e..48c20b9910 100644
--- a/engines/sword25/gfx/animationtemplate.h
+++ b/engines/sword25/gfx/animationtemplate.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -59,65 +59,75 @@ class BS_AnimationResource;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_AnimationTemplate : public BS_AnimationDescription
-{
+class BS_AnimationTemplate : public BS_AnimationDescription {
public:
- static unsigned int Create(const Common::String & SourceAnimation);
- static unsigned int Create(const BS_AnimationTemplate & Other);
- static unsigned int Create(BS_InputPersistenceBlock & Reader, unsigned int Handle);
- BS_AnimationTemplate * ResolveHandle(unsigned int Handle) const;
+ static unsigned int Create(const Common::String &SourceAnimation);
+ static unsigned int Create(const BS_AnimationTemplate &Other);
+ static unsigned int Create(BS_InputPersistenceBlock &Reader, unsigned int Handle);
+ BS_AnimationTemplate *ResolveHandle(unsigned int Handle) const;
private:
- BS_AnimationTemplate(const Common::String & SourceAnimation);
- BS_AnimationTemplate(const BS_AnimationTemplate & Other);
- BS_AnimationTemplate(BS_InputPersistenceBlock & Reader, unsigned int Handle);
+ BS_AnimationTemplate(const Common::String &SourceAnimation);
+ BS_AnimationTemplate(const BS_AnimationTemplate &Other);
+ BS_AnimationTemplate(BS_InputPersistenceBlock &Reader, unsigned int Handle);
public:
~BS_AnimationTemplate();
- virtual const Frame & GetFrame(unsigned int Index) const { BS_ASSERT(Index < m_Frames.size()); return m_Frames[Index]; }
- virtual unsigned int GetFrameCount() const { return m_Frames.size(); }
- virtual void Unlock() { delete this; }
-
- bool IsValid() const { return m_Valid; }
+ virtual const Frame &GetFrame(unsigned int Index) const {
+ BS_ASSERT(Index < m_Frames.size());
+ return m_Frames[Index];
+ }
+ virtual unsigned int GetFrameCount() const {
+ return m_Frames.size();
+ }
+ virtual void Unlock() {
+ delete this;
+ }
+
+ bool IsValid() const {
+ return m_Valid;
+ }
/**
- @brief Fügt einen neuen Frame zur Animation hinzu.
+ @brief Fügt einen neuen Frame zur Animation hinzu.
- Der Frame wird an das Ende der Animation angehängt.
+ Der Frame wird an das Ende der Animation angehängt.
- @param Index der Index des Frames in der Quellanimation
+ @param Index der Index des Frames in der Quellanimation
*/
void AddFrame(int Index);
/**
- @brief Ändert einen bereits in der Animation vorhandenen Frame.
- @param DestIndex der Index des Frames der überschrieben werden soll
- @param SrcIndex der Index des einzufügenden Frames in der Quellanimation
+ @brief Ändert einen bereits in der Animation vorhandenen Frame.
+ @param DestIndex der Index des Frames der überschrieben werden soll
+ @param SrcIndex der Index des einzufügenden Frames in der Quellanimation
*/
void SetFrame(int DestIndex, int SrcIndex);
/**
- @brief Setzt den Animationstyp.
- @param Type der Typ der Animation. Muss aus den enum BS_Animation::ANIMATION_TYPES sein.
+ @brief Setzt den Animationstyp.
+ @param Type der Typ der Animation. Muss aus den enum BS_Animation::ANIMATION_TYPES sein.
*/
- void SetAnimationType(BS_Animation::ANIMATION_TYPES Type) { m_AnimationType = Type; }
+ void SetAnimationType(BS_Animation::ANIMATION_TYPES Type) {
+ m_AnimationType = Type;
+ }
/**
- @brief Setzt die Abspielgeschwindigkeit.
- @param FPS die Abspielgeschwindigkeit in Frames pro Sekunde.
+ @brief Setzt die Abspielgeschwindigkeit.
+ @param FPS die Abspielgeschwindigkeit in Frames pro Sekunde.
*/
void SetFPS(int FPS);
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
- Common::Array<const Frame> m_Frames;
- BS_AnimationResource * m_SourceAnimationPtr;
- bool m_Valid;
+ Common::Array<const Frame> m_Frames;
+ BS_AnimationResource *m_SourceAnimationPtr;
+ bool m_Valid;
- BS_AnimationResource * RequestSourceAnimation(const Common::String & SourceAnimation) const;
+ BS_AnimationResource *RequestSourceAnimation(const Common::String &SourceAnimation) const;
bool ValidateSourceIndex(unsigned int Index) const;
bool ValidateDestIndex(unsigned int Index) const;
};
diff --git a/engines/sword25/gfx/animationtemplateregistry.cpp b/engines/sword25/gfx/animationtemplateregistry.cpp
index 1913a7cf8b..32195e8166 100644
--- a/engines/sword25/gfx/animationtemplateregistry.cpp
+++ b/engines/sword25/gfx/animationtemplateregistry.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -57,22 +57,19 @@ std::auto_ptr<BS_AnimationTemplateRegistry> BS_AnimationTemplateRegistry::m_Inst
// -----------------------------------------------------------------------------
-void BS_AnimationTemplateRegistry::LogErrorLn(const char * Message) const
-{
+void BS_AnimationTemplateRegistry::LogErrorLn(const char *Message) const {
BS_LOG_ERRORLN(Message);
}
// -----------------------------------------------------------------------------
-void BS_AnimationTemplateRegistry::LogWarningLn(const char * Message) const
-{
+void BS_AnimationTemplateRegistry::LogWarningLn(const char *Message) const {
BS_LOG_WARNINGLN(Message);
}
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Das nächste zu vergebene Handle schreiben.
@@ -83,8 +80,7 @@ bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock & Writer)
// Alle BS_AnimationTemplates persistieren.
HANDLE2PTR_MAP::const_iterator Iter = m_Handle2PtrMap.begin();
- while (Iter != m_Handle2PtrMap.end())
- {
+ while (Iter != m_Handle2PtrMap.end()) {
// Handle persistieren.
Writer.Write(Iter->first);
@@ -99,8 +95,7 @@ bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_AnimationTemplateRegistry::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_AnimationTemplateRegistry::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// Das nächste zu vergebene Handle wieder herstellen.
@@ -114,8 +109,7 @@ bool BS_AnimationTemplateRegistry::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(AnimationTemplateCount);
// Alle gespeicherten BS_AnimationTemplates wieder herstellen.
- for (unsigned int i = 0; i < AnimationTemplateCount; ++i)
- {
+ for (unsigned int i = 0; i < AnimationTemplateCount; ++i) {
// Handle lesen.
unsigned int Handle;
Reader.Read(Handle);
diff --git a/engines/sword25/gfx/animationtemplateregistry.h b/engines/sword25/gfx/animationtemplateregistry.h
index efa26326ed..8769e457f3 100644
--- a/engines/sword25/gfx/animationtemplateregistry.h
+++ b/engines/sword25/gfx/animationtemplateregistry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -59,21 +59,19 @@ class BS_AnimationTemplate;
// Klassendeklaration
// -----------------------------------------------------------------------------
-class BS_AnimationTemplateRegistry : public BS_ObjectRegistry<BS_AnimationTemplate>, public BS_Persistable
-{
+class BS_AnimationTemplateRegistry : public BS_ObjectRegistry<BS_AnimationTemplate>, public BS_Persistable {
public:
- static BS_AnimationTemplateRegistry & GetInstance()
- {
+ static BS_AnimationTemplateRegistry &GetInstance() {
if (!m_InstancePtr.get()) m_InstancePtr.reset(new BS_AnimationTemplateRegistry);
return *m_InstancePtr.get();
}
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
- virtual void LogErrorLn(const char * Message) const;
- virtual void LogWarningLn(const char * Message) const;
+ virtual void LogErrorLn(const char *Message) const;
+ virtual void LogWarningLn(const char *Message) const;
static std::auto_ptr<BS_AnimationTemplateRegistry> m_InstancePtr;
};
diff --git a/engines/sword25/gfx/bitmap.cpp b/engines/sword25/gfx/bitmap.cpp
index 5dd553ef8c..534e28d78e 100644
--- a/engines/sword25/gfx/bitmap.cpp
+++ b/engines/sword25/gfx/bitmap.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,41 +58,35 @@ BS_Bitmap::BS_Bitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, TYPES Type,
m_ScaleFactorX(1.0f),
m_ScaleFactorY(1.0f),
m_FlipH(false),
- m_FlipV(false)
-{
+ m_FlipV(false) {
}
// -----------------------------------------------------------------------------
-BS_Bitmap::~BS_Bitmap()
-{
+BS_Bitmap::~BS_Bitmap() {
}
// -----------------------------------------------------------------------------
// Darstellungsart festlegen
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetAlpha(int Alpha)
-{
- if (!IsAlphaAllowed())
- {
+void BS_Bitmap::SetAlpha(int Alpha) {
+ if (!IsAlphaAllowed()) {
BS_LOG_WARNINGLN("Tried to set alpha value on a bitmap that does not support alpha blending. Call was ignored.");
return;
}
- if (Alpha < 0 || Alpha > 255)
- {
+ if (Alpha < 0 || Alpha > 255) {
int OldAlpha = Alpha;
if (Alpha < 0) Alpha = 0;
if (Alpha > 255) Alpha = 255;
BS_LOG_WARNINGLN("Tried to set an invalid alpha value (%d) on a bitmap. Value was changed to %d.", OldAlpha, Alpha);
-
+
return;
}
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -100,17 +94,14 @@ void BS_Bitmap::SetAlpha(int Alpha)
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetModulationColor(unsigned int ModulationColor)
-{
- if (!IsColorModulationAllowed())
- {
+void BS_Bitmap::SetModulationColor(unsigned int ModulationColor) {
+ if (!IsColorModulationAllowed()) {
BS_LOG_WARNINGLN("Tried to set modulation color of a bitmap that does not support color modulation. Call was ignored.");
return;
}
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -118,30 +109,25 @@ void BS_Bitmap::SetModulationColor(unsigned int ModulationColor)
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetScaleFactor(float ScaleFactor)
-{
+void BS_Bitmap::SetScaleFactor(float ScaleFactor) {
SetScaleFactorX(ScaleFactor);
SetScaleFactorY(ScaleFactor);
}
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetScaleFactorX(float ScaleFactorX)
-{
- if (!IsScalingAllowed())
- {
+void BS_Bitmap::SetScaleFactorX(float ScaleFactorX) {
+ if (!IsScalingAllowed()) {
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
return;
}
- if (ScaleFactorX < 0)
- {
+ if (ScaleFactorX < 0) {
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored.");
return;
}
- if (ScaleFactorX != m_ScaleFactorX)
- {
+ if (ScaleFactorX != m_ScaleFactorX) {
m_ScaleFactorX = ScaleFactorX;
m_Width = static_cast<int>(m_OriginalWidth * m_ScaleFactorX);
if (m_ScaleFactorX <= 0.0f) m_ScaleFactorX = 0.001f;
@@ -151,22 +137,18 @@ void BS_Bitmap::SetScaleFactorX(float ScaleFactorX)
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetScaleFactorY(float ScaleFactorY)
-{
- if (!IsScalingAllowed())
- {
+void BS_Bitmap::SetScaleFactorY(float ScaleFactorY) {
+ if (!IsScalingAllowed()) {
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
return;
}
- if (ScaleFactorY < 0)
- {
+ if (ScaleFactorY < 0) {
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored.");
return;
}
- if (ScaleFactorY != m_ScaleFactorY)
- {
+ if (ScaleFactorY != m_ScaleFactorY) {
m_ScaleFactorY = ScaleFactorY;
m_Height = static_cast<int>(m_OriginalHeight * ScaleFactorY);
if (m_ScaleFactorY <= 0.0f) m_ScaleFactorY = 0.001f;
@@ -176,16 +158,14 @@ void BS_Bitmap::SetScaleFactorY(float ScaleFactorY)
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetFlipH(bool FlipH)
-{
+void BS_Bitmap::SetFlipH(bool FlipH) {
m_FlipH = FlipH;
ForceRefresh();
}
// -----------------------------------------------------------------------------
-void BS_Bitmap::SetFlipV(bool FlipV)
-{
+void BS_Bitmap::SetFlipV(bool FlipV) {
m_FlipV = FlipV;
ForceRefresh();
}
@@ -194,8 +174,7 @@ void BS_Bitmap::SetFlipV(bool FlipV)
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_Bitmap::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_Bitmap::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_RenderObject::Persist(Writer);
@@ -212,8 +191,7 @@ bool BS_Bitmap::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_Bitmap::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_Bitmap::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_RenderObject::Unpersist(Reader);
diff --git a/engines/sword25/gfx/bitmap.h b/engines/sword25/gfx/bitmap.h
index c0e490ee47..00d9308ec5 100644
--- a/engines/sword25/gfx/bitmap.h
+++ b/engines/sword25/gfx/bitmap.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,8 +48,7 @@ namespace Sword25 {
// Klassendeklaration
// -----------------------------------------------------------------------------
-class BS_Bitmap : public BS_RenderObject
-{
+class BS_Bitmap : public BS_RenderObject {
protected:
BS_Bitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, TYPES Type, unsigned int Handle = 0);
@@ -58,127 +57,139 @@ public:
virtual ~BS_Bitmap();
/**
- @brief Setzt den Alphawert des Bitmaps.
- @param Alpha der neue Alphawert der Bitmaps (0 = keine Deckung, 255 = volle Deckung).
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
+ @brief Setzt den Alphawert des Bitmaps.
+ @param Alpha der neue Alphawert der Bitmaps (0 = keine Deckung, 255 = volle Deckung).
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
*/
void SetAlpha(int Alpha);
/**
- @brief Setzt die Modulationfarbe der Bitmaps.
- @param Color eine 24-Bit Farbe, die die Modulationsfarbe des Bitmaps festlegt.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
+ @brief Setzt die Modulationfarbe der Bitmaps.
+ @param Color eine 24-Bit Farbe, die die Modulationsfarbe des Bitmaps festlegt.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
*/
void SetModulationColor(unsigned int ModulationColor);
/**
- @brief Setzt den Skalierungsfaktor des Bitmaps.
- @param ScaleFactor der Faktor um den das Bitmap in beide Richtungen gestreckt werden soll.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor des Bitmaps.
+ @param ScaleFactor der Faktor um den das Bitmap in beide Richtungen gestreckt werden soll.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactor(float ScaleFactor);
/**
- @brief Setzt den Skalierungsfaktor der Bitmap auf der X-Achse.
- @param ScaleFactor der Faktor um den die Bitmap in Richtungen der X-Achse gestreckt werden soll. Dieser Wert muss positiv sein.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor der Bitmap auf der X-Achse.
+ @param ScaleFactor der Faktor um den die Bitmap in Richtungen der X-Achse gestreckt werden soll. Dieser Wert muss positiv sein.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactorX(float ScaleFactorX);
/**
- @brief Setzt den Skalierungsfaktor der Bitmap auf der Y-Achse.
- @param ScaleFactor der Faktor um den die Bitmap in Richtungen der Y-Achse gestreckt werden soll. Dieser Wert muss positiv sein.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Setzt den Skalierungsfaktor der Bitmap auf der Y-Achse.
+ @param ScaleFactor der Faktor um den die Bitmap in Richtungen der Y-Achse gestreckt werden soll. Dieser Wert muss positiv sein.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
void SetScaleFactorY(float ScaleFactorY);
/**
- @brief Legt fest, ob das Bild an der X-Achse gespiegelt werden soll.
+ @brief Legt fest, ob das Bild an der X-Achse gespiegelt werden soll.
*/
void SetFlipH(bool FlipH);
/**
- @brief Legt fest, ob das Bild an der Y-Achse gespiegelt werden soll.
+ @brief Legt fest, ob das Bild an der Y-Achse gespiegelt werden soll.
*/
void SetFlipV(bool FlipV);
/**
- @brief Gibt den aktuellen Alphawert des Bildes zurück.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
+ @brief Gibt den aktuellen Alphawert des Bildes zurück.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
*/
- int GetAlpha() { return m_ModulationColor >> 24; }
+ int GetAlpha() {
+ return m_ModulationColor >> 24;
+ }
/**
- @brief Gibt die aktuelle 24bit RGB Modulationsfarde des Bildes zurück.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
+ @brief Gibt die aktuelle 24bit RGB Modulationsfarde des Bildes zurück.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsColorModulationAllowed() true zurückgibt.
*/
- int GetModulationColor() { return m_ModulationColor & 0x00ffffff; }
+ int GetModulationColor() {
+ return m_ModulationColor & 0x00ffffff;
+ }
/**
- @brief Gibt den Skalierungsfakter des Bitmaps auf der X-Achse zurück.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Gibt den Skalierungsfakter des Bitmaps auf der X-Achse zurück.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
- float GetScaleFactorX() const { return m_ScaleFactorX; }
+ float GetScaleFactorX() const {
+ return m_ScaleFactorX;
+ }
/**
- @brief Gibt den Skalierungsfakter des Bitmaps auf der Y-Achse zurück.
- @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
+ @brief Gibt den Skalierungsfakter des Bitmaps auf der Y-Achse zurück.
+ @remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsScalingAllowed() true zurückgibt.
*/
- float GetScaleFactorY() const { return m_ScaleFactorY; }
+ float GetScaleFactorY() const {
+ return m_ScaleFactorY;
+ }
/**
- @brief Gibt zurück, ob das Bild an der X-Achse gespiegelt angezeigt wird.
+ @brief Gibt zurück, ob das Bild an der X-Achse gespiegelt angezeigt wird.
*/
- bool IsFlipH() { return m_FlipH; }
+ bool IsFlipH() {
+ return m_FlipH;
+ }
/**
- @brief Gibt zurück, ob das Bild an der Y-Achse gespiegelt angezeigt wird.
+ @brief Gibt zurück, ob das Bild an der Y-Achse gespiegelt angezeigt wird.
*/
- bool IsFlipV() { return m_FlipV; }
+ bool IsFlipV() {
+ return m_FlipV;
+ }
// -----------------------------------------------------------------------------
// Die folgenden Methoden müssen alle BS_Bitmap-Klassen implementieren
// -----------------------------------------------------------------------------
/**
- @brief Liest einen Pixel des Bildes.
- @param X die X-Koordinate des Pixels.
- @param Y die Y-Koordinate des Pixels
- @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
- @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
- eher dafür gedacht einzelne Pixel des Bildes auszulesen.
+ @brief Liest einen Pixel des Bildes.
+ @param X die X-Koordinate des Pixels.
+ @param Y die Y-Koordinate des Pixels
+ @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
+ @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
+ eher dafür gedacht einzelne Pixel des Bildes auszulesen.
*/
virtual unsigned int GetPixel(int X, int Y) const = 0;
/**
- @brief Füllt den Inhalt des Bildes mit Pixeldaten.
- @param Pixeldata ein Vector der die Pixeldaten enthält. Sie müssen in dem Farbformat des Bildes vorliegen und es müssen genügend Daten
- vorhanden sein, um das ganze Bild zu füllen.
+ @brief Füllt den Inhalt des Bildes mit Pixeldaten.
+ @param Pixeldata ein Vector der die Pixeldaten enthält. Sie müssen in dem Farbformat des Bildes vorliegen und es müssen genügend Daten
+ vorhanden sein, um das ganze Bild zu füllen.
@param Offset der Offset in Byte im Pixeldata-Vector an dem sich der erste zu schreibende Pixel befindet.<br>
- Der Standardwert ist 0.
- @param Stride der Abstand in Byte zwischen dem Zeilenende und dem Beginn einer neuen Zeile im Pixeldata-Vector.<br>
- Der Standardwert ist 0.
- @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist.
- @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt.
+ Der Standardwert ist 0.
+ @param Stride der Abstand in Byte zwischen dem Zeilenende und dem Beginn einer neuen Zeile im Pixeldata-Vector.<br>
+ Der Standardwert ist 0.
+ @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist.
+ @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt.
*/
- virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0) = 0;
+ virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0) = 0;
- virtual bool IsScalingAllowed() const = 0;
- virtual bool IsAlphaAllowed() const = 0;
- virtual bool IsColorModulationAllowed() const = 0;
- virtual bool IsSetContentAllowed() const = 0;
+ virtual bool IsScalingAllowed() const = 0;
+ virtual bool IsAlphaAllowed() const = 0;
+ virtual bool IsColorModulationAllowed() const = 0;
+ virtual bool IsSetContentAllowed() const = 0;
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
- bool m_FlipH;
- bool m_FlipV;
- float m_ScaleFactorX;
- float m_ScaleFactorY;
- unsigned int m_ModulationColor;
- int m_OriginalWidth;
- int m_OriginalHeight;
+ bool m_FlipH;
+ bool m_FlipV;
+ float m_ScaleFactorX;
+ float m_ScaleFactorY;
+ unsigned int m_ModulationColor;
+ int m_OriginalWidth;
+ int m_OriginalHeight;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/bitmapresource.cpp b/engines/sword25/gfx/bitmapresource.cpp
index 6113db96c9..4a8c96880d 100644
--- a/engines/sword25/gfx/bitmapresource.cpp
+++ b/engines/sword25/gfx/bitmapresource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -47,23 +47,20 @@ namespace Sword25 {
// Konstruktion / Destruktion
// --------------------------
-BS_BitmapResource::BS_BitmapResource(const Common::String & Filename, BS_Image * pImage) :
+BS_BitmapResource::BS_BitmapResource(const Common::String &Filename, BS_Image *pImage) :
m_Valid(false),
m_pImage(pImage),
- BS_Resource(Filename, BS_Resource::TYPE_BITMAP)
-{
+ BS_Resource(Filename, BS_Resource::TYPE_BITMAP) {
m_Valid = m_pImage != 0;
}
-BS_BitmapResource::~BS_BitmapResource()
-{
+BS_BitmapResource::~BS_BitmapResource() {
delete m_pImage;
}
// -----------------------------------------------------------------------------
-unsigned int BS_BitmapResource::GetPixel(int X, int Y) const
-{
+unsigned int BS_BitmapResource::GetPixel(int X, int Y) const {
BS_ASSERT(X >= 0 && X < m_pImage->GetWidth());
BS_ASSERT(Y >= 0 && Y < m_pImage->GetHeight());
diff --git a/engines/sword25/gfx/bitmapresource.h b/engines/sword25/gfx/bitmapresource.h
index 4e6e305bed..112ee379cd 100644
--- a/engines/sword25/gfx/bitmapresource.h
+++ b/engines/sword25/gfx/bitmapresource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,14 +48,12 @@ namespace Sword25 {
class BS_Rect;
-class BS_BitmapResource : public BS_Resource
-{
+class BS_BitmapResource : public BS_Resource {
public:
/**
- @brief Die möglichen Flippingparameter für die Blit-Methode.
+ @brief Die möglichen Flippingparameter für die Blit-Methode.
*/
- enum FLIP_FLAGS
- {
+ enum FLIP_FLAGS {
/// Das Bild wird nicht gespiegelt.
FLIP_NONE = 0,
/// Das Bild wird an der horizontalen Achse gespiegelt.
@@ -68,92 +66,102 @@ public:
FLIP_VH = FLIP_H | FLIP_V
};
- BS_BitmapResource(const Common::String & Filename, BS_Image * pImage);
+ BS_BitmapResource(const Common::String &Filename, BS_Image *pImage);
virtual ~BS_BitmapResource();
/**
- @brief Gibt zurück, ob das Objekt einen gültigen Zustand hat.
+ @brief Gibt zurück, ob das Objekt einen gültigen Zustand hat.
*/
- bool IsValid() const { return m_Valid; }
+ bool IsValid() const {
+ return m_Valid;
+ }
/**
- @brief Gibt die Breite des Bitmaps zurück.
+ @brief Gibt die Breite des Bitmaps zurück.
*/
- int GetWidth() const { BS_ASSERT(m_pImage); return m_pImage->GetWidth(); }
+ int GetWidth() const {
+ BS_ASSERT(m_pImage);
+ return m_pImage->GetWidth();
+ }
/**
- @brief Gibt die Höhe des Bitmaps zurück.
+ @brief Gibt die Höhe des Bitmaps zurück.
*/
- int GetHeight() const { BS_ASSERT(m_pImage); return m_pImage->GetHeight(); }
+ int GetHeight() const {
+ BS_ASSERT(m_pImage);
+ return m_pImage->GetHeight();
+ }
/**
- @brief Rendert das Bild in den Framebuffer.
- @param PosX die Position auf der X-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
- Der Standardwert ist 0.
- @param PosY die Position auf der Y-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
- Der Standardwert ist 0.
- @param Flipping gibt an, wie das Bild gespiegelt werden soll.<br>
- Der Standardwert ist BS_Image::FLIP_NONE (keine Spiegelung)
- @param pSrcPartRect Pointer auf ein BS_Rect, welches den Ausschnitt des Quellbildes spezifiziert, der gerendert
- werden soll oder NULL, falls das gesamte Bild gerendert werden soll.<br>
- Dieser Ausschnitt bezieht sich auf das ungespiegelte und unskalierte Bild.<br>
- Der Standardwert ist NULL.
- @param Color ein ARGB Farbwert, der die Parameter für die Farbmodulation und fürs Alphablending festlegt.<br>
- Die Alpha-Komponente der Farbe bestimmt den Alphablending Parameter (0 = keine Deckung, 255 = volle Deckung).<br>
- Die Farbkomponenten geben die Farbe für die Farbmodulation an.<br>
- Der Standardwert is BS_ARGB(255, 255, 255, 255) (volle Deckung, keine Farbmodulation).
- Zum Erzeugen des Farbwertes können die Makros BS_RGB und BS_ARGB benutzt werden.
- @param Width gibt die Ausgabebreite des Bildausschnittes an.
- Falls diese von der Breite des Bildausschnittes abweicht wird
- das Bild entsprechend Skaliert.<br>
- Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
- Der Standardwert ist -1.
- @param Width gibt die Ausgabehöhe des Bildausschnittes an.
- Falls diese von der Höhe des Bildauschnittes abweicht, wird
- das Bild entsprechend Skaliert.<br>
- Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
- Der Standardwert ist -1.
- @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
- @remark Er werden nicht alle Blitting-Operationen von allen BS_Image-Klassen unterstützt.<br>
- Mehr Informationen gibt es in der Klassenbeschreibung von BS_Image und durch folgende Methoden:
- - IsBlitTarget()
- - IsScalingAllowed()
- - IsFillingAllowed()
- - IsAlphaAllowed()
- - IsColorModulationAllowed()
+ @brief Rendert das Bild in den Framebuffer.
+ @param PosX die Position auf der X-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
+ Der Standardwert ist 0.
+ @param PosY die Position auf der Y-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
+ Der Standardwert ist 0.
+ @param Flipping gibt an, wie das Bild gespiegelt werden soll.<br>
+ Der Standardwert ist BS_Image::FLIP_NONE (keine Spiegelung)
+ @param pSrcPartRect Pointer auf ein BS_Rect, welches den Ausschnitt des Quellbildes spezifiziert, der gerendert
+ werden soll oder NULL, falls das gesamte Bild gerendert werden soll.<br>
+ Dieser Ausschnitt bezieht sich auf das ungespiegelte und unskalierte Bild.<br>
+ Der Standardwert ist NULL.
+ @param Color ein ARGB Farbwert, der die Parameter für die Farbmodulation und fürs Alphablending festlegt.<br>
+ Die Alpha-Komponente der Farbe bestimmt den Alphablending Parameter (0 = keine Deckung, 255 = volle Deckung).<br>
+ Die Farbkomponenten geben die Farbe für die Farbmodulation an.<br>
+ Der Standardwert is BS_ARGB(255, 255, 255, 255) (volle Deckung, keine Farbmodulation).
+ Zum Erzeugen des Farbwertes können die Makros BS_RGB und BS_ARGB benutzt werden.
+ @param Width gibt die Ausgabebreite des Bildausschnittes an.
+ Falls diese von der Breite des Bildausschnittes abweicht wird
+ das Bild entsprechend Skaliert.<br>
+ Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
+ Der Standardwert ist -1.
+ @param Width gibt die Ausgabehöhe des Bildausschnittes an.
+ Falls diese von der Höhe des Bildauschnittes abweicht, wird
+ das Bild entsprechend Skaliert.<br>
+ Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
+ Der Standardwert ist -1.
+ @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
+ @remark Er werden nicht alle Blitting-Operationen von allen BS_Image-Klassen unterstützt.<br>
+ Mehr Informationen gibt es in der Klassenbeschreibung von BS_Image und durch folgende Methoden:
+ - IsBlitTarget()
+ - IsScalingAllowed()
+ - IsFillingAllowed()
+ - IsAlphaAllowed()
+ - IsColorModulationAllowed()
*/
- bool Blit(int PosX = 0, int PosY = 0,
- int Flipping = FLIP_NONE,
- BS_Rect* pSrcPartRect = NULL,
- unsigned int Color = BS_ARGB(255, 255, 255, 255),
- int Width = -1, int Height = -1)
- {
+ bool Blit(int PosX = 0, int PosY = 0,
+ int Flipping = FLIP_NONE,
+ BS_Rect *pSrcPartRect = NULL,
+ unsigned int Color = BS_ARGB(255, 255, 255, 255),
+ int Width = -1, int Height = -1) {
BS_ASSERT(m_pImage);
return m_pImage->Blit(PosX, PosY, Flipping, pSrcPartRect, Color, Width, Height);
}
/**
- @brief Füllt einen Rechteckigen Bereich des Bildes mit einer Farbe.
- @param pFillRect Pointer auf ein BS_Rect, welches den Ausschnitt des Bildes spezifiziert, der gefüllt
- werden soll oder NULL, falls das gesamte Bild gefüllt werden soll.<br>
- Der Standardwert ist NULL.
- @param Color der 32 Bit Farbwert mit dem der Bildbereich gefüllt werden soll.
- @remark Ein Aufruf dieser Methode ist nur gestattet, wenn IsFillingAllowed() true zurückgibt.
- @remark Es ist möglich über die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem Alphawert ungleich
- 255 angibt.
- @remark Unabhängig vom Farbformat des Bildes muss ein 32 Bit Farbwert angegeben werden. Zur Erzeugung, können die Makros
- BS_RGB und BS_ARGB benutzt werden.
- @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
+ @brief Füllt einen Rechteckigen Bereich des Bildes mit einer Farbe.
+ @param pFillRect Pointer auf ein BS_Rect, welches den Ausschnitt des Bildes spezifiziert, der gefüllt
+ werden soll oder NULL, falls das gesamte Bild gefüllt werden soll.<br>
+ Der Standardwert ist NULL.
+ @param Color der 32 Bit Farbwert mit dem der Bildbereich gefüllt werden soll.
+ @remark Ein Aufruf dieser Methode ist nur gestattet, wenn IsFillingAllowed() true zurückgibt.
+ @remark Es ist möglich über die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem Alphawert ungleich
+ 255 angibt.
+ @remark Unabhängig vom Farbformat des Bildes muss ein 32 Bit Farbwert angegeben werden. Zur Erzeugung, können die Makros
+ BS_RGB und BS_ARGB benutzt werden.
+ @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
*/
- bool Fill(const BS_Rect* pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0)) { BS_ASSERT(m_pImage); return m_pImage->Fill(pFillRect, Color); }
+ bool Fill(const BS_Rect *pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0)) {
+ BS_ASSERT(m_pImage);
+ return m_pImage->Fill(pFillRect, Color);
+ }
/**
- @brief Liest einen Pixel des Bildes.
- @param X die X-Koordinate des Pixels.
- @param Y die Y-Koordinate des Pixels
- @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
- @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
- eher dafür gedacht einzelne Pixel des Bildes auszulesen.
+ @brief Liest einen Pixel des Bildes.
+ @param X die X-Koordinate des Pixels.
+ @param Y die Y-Koordinate des Pixels
+ @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
+ @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
+ eher dafür gedacht einzelne Pixel des Bildes auszulesen.
*/
unsigned int GetPixel(int X, int Y) const;
@@ -161,34 +169,49 @@ public:
/** @name Auskunfts-Methoden */
/**
- @brief Überprüft, ob das BS_Image ein Zielbild für einen Blit-Aufruf sein kann.
- @return Gibt false zurück, falls ein Blit-Aufruf mit diesem Objekt als Ziel nicht gestattet ist.
+ @brief Überprüft, ob das BS_Image ein Zielbild für einen Blit-Aufruf sein kann.
+ @return Gibt false zurück, falls ein Blit-Aufruf mit diesem Objekt als Ziel nicht gestattet ist.
*/
- bool IsBlitTarget() { BS_ASSERT(m_pImage); return m_pImage->IsBlitTarget(); }
+ bool IsBlitTarget() {
+ BS_ASSERT(m_pImage);
+ return m_pImage->IsBlitTarget();
+ }
/**
- @brief Gibt true zurück, falls das BS_Image bei einem Aufruf von Blit() skaliert dargestellt werden kann.
+ @brief Gibt true zurück, falls das BS_Image bei einem Aufruf von Blit() skaliert dargestellt werden kann.
*/
- bool IsScalingAllowed() { BS_ASSERT(m_pImage); return m_pImage->IsScalingAllowed(); }
+ bool IsScalingAllowed() {
+ BS_ASSERT(m_pImage);
+ return m_pImage->IsScalingAllowed();
+ }
/**
- @brief Gibt true zurück, wenn das BS_Image mit einem Aufruf von Fill() gefüllt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image mit einem Aufruf von Fill() gefüllt werden kann.
*/
- bool IsFillingAllowed() { BS_ASSERT(m_pImage); return m_pImage->IsFillingAllowed(); }
+ bool IsFillingAllowed() {
+ BS_ASSERT(m_pImage);
+ return m_pImage->IsFillingAllowed();
+ }
/**
- @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit einem Alphawert dargestellt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit einem Alphawert dargestellt werden kann.
*/
- bool IsAlphaAllowed() { BS_ASSERT(m_pImage); return m_pImage->IsAlphaAllowed(); }
+ bool IsAlphaAllowed() {
+ BS_ASSERT(m_pImage);
+ return m_pImage->IsAlphaAllowed();
+ }
/**
- @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit Farbmodulation dargestellt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit Farbmodulation dargestellt werden kann.
*/
- bool IsColorModulationAllowed() { BS_ASSERT(m_pImage); return m_pImage->IsColorModulationAllowed(); }
+ bool IsColorModulationAllowed() {
+ BS_ASSERT(m_pImage);
+ return m_pImage->IsColorModulationAllowed();
+ }
private:
- BS_Image * m_pImage;
- bool m_Valid;
+ BS_Image *m_pImage;
+ bool m_Valid;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp
index 9e5f2bb2f9..22a0d3d1dd 100644
--- a/engines/sword25/gfx/dynamicbitmap.cpp
+++ b/engines/sword25/gfx/dynamicbitmap.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -56,8 +56,7 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
BS_DynamicBitmap::BS_DynamicBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Width, unsigned int Height) :
- BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP)
-{
+ BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP) {
// Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
if (!m_InitSuccess) return;
@@ -66,16 +65,14 @@ BS_DynamicBitmap::BS_DynamicBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr
// -----------------------------------------------------------------------------
-BS_DynamicBitmap::BS_DynamicBitmap(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
- BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP, Handle)
-{
+BS_DynamicBitmap::BS_DynamicBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
+ BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP, Handle) {
m_InitSuccess = Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::CreateGLImage(unsigned int Width, unsigned int Height)
-{
+bool BS_DynamicBitmap::CreateGLImage(unsigned int Width, unsigned int Height) {
// GLImage mit den gewünschten Maßen erstellen
bool Result;
m_Image.reset(new BS_GLImage(Width, Height, Result));
@@ -88,14 +85,12 @@ bool BS_DynamicBitmap::CreateGLImage(unsigned int Width, unsigned int Height)
// -----------------------------------------------------------------------------
-BS_DynamicBitmap::~BS_DynamicBitmap()
-{
+BS_DynamicBitmap::~BS_DynamicBitmap() {
}
// -----------------------------------------------------------------------------
-unsigned int BS_DynamicBitmap::GetPixel(int X, int Y) const
-{
+unsigned int BS_DynamicBitmap::GetPixel(int X, int Y) const {
BS_ASSERT(X >= 0 && X < m_Width);
BS_ASSERT(Y >= 0 && Y < m_Height);
@@ -104,27 +99,23 @@ unsigned int BS_DynamicBitmap::GetPixel(int X, int Y) const
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::DoRender()
-{
+bool BS_DynamicBitmap::DoRender() {
// Framebufferobjekt holen
- BS_GraphicEngine * pGfx = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
+ BS_GraphicEngine *pGfx = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(pGfx);
// Bitmap zeichnen
bool Result;
- if (m_ScaleFactorX == 1.0f && m_ScaleFactorY == 1.0f)
- {
+ if (m_ScaleFactorX == 1.0f && m_ScaleFactorY == 1.0f) {
Result = m_Image->Blit(m_AbsoluteX, m_AbsoluteY,
- (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, -1, -1);
- }
- else
- {
+ (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, -1, -1);
+ } else {
Result = m_Image->Blit(m_AbsoluteX, m_AbsoluteY,
- (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, m_Width, m_Height);
+ (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, m_Width, m_Height);
}
return Result;
@@ -132,8 +123,7 @@ bool BS_DynamicBitmap::DoRender()
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride)
-{
+bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
return m_Image->SetContent(Pixeldata, Offset, Stride);
}
@@ -141,29 +131,25 @@ bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, un
// Auskunftsmethoden
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::IsScalingAllowed() const
-{
+bool BS_DynamicBitmap::IsScalingAllowed() const {
return m_Image->IsScalingAllowed();
}
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::IsAlphaAllowed() const
-{
+bool BS_DynamicBitmap::IsAlphaAllowed() const {
return m_Image->IsAlphaAllowed();
}
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::IsColorModulationAllowed() const
-{
+bool BS_DynamicBitmap::IsColorModulationAllowed() const {
return m_Image->IsColorModulationAllowed();
}
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::IsSetContentAllowed() const
-{
+bool BS_DynamicBitmap::IsSetContentAllowed() const {
return true;
}
@@ -171,12 +157,11 @@ bool BS_DynamicBitmap::IsSetContentAllowed() const
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_Bitmap::Persist(Writer);
-
+
// Bilddaten werden nicht gespeichert. Dies ist auch nicht weiter von bedeutung, da BS_DynamicBitmap nur vom Videoplayer benutzt wird.
// Während ein Video abläuft kann niemals gespeichert werden. BS_DynamicBitmap kann nur der Vollständigkeit halber persistiert werden.
BS_LOG_WARNINGLN("Persisting a BS_DynamicBitmap. Bitmap content is not persisted.");
@@ -186,8 +171,7 @@ bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock & Writer)
return Result;
}
-bool BS_DynamicBitmap::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_DynamicBitmap::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_Bitmap::Unpersist(Reader);
diff --git a/engines/sword25/gfx/dynamicbitmap.h b/engines/sword25/gfx/dynamicbitmap.h
index 0449f9984d..04d1ce5c7a 100644
--- a/engines/sword25/gfx/dynamicbitmap.h
+++ b/engines/sword25/gfx/dynamicbitmap.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,31 +54,30 @@ namespace Sword25 {
// Klassendeklaration
// -----------------------------------------------------------------------------
-class BS_DynamicBitmap : public BS_Bitmap
-{
-friend class BS_RenderObject;
+class BS_DynamicBitmap : public BS_Bitmap {
+ friend class BS_RenderObject;
public:
virtual ~BS_DynamicBitmap();
virtual unsigned int GetPixel(int X, int Y) const;
- virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
+ virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
- virtual bool IsScalingAllowed() const;
- virtual bool IsAlphaAllowed() const;
- virtual bool IsColorModulationAllowed() const;
- virtual bool IsSetContentAllowed() const;
+ virtual bool IsScalingAllowed() const;
+ virtual bool IsAlphaAllowed() const;
+ virtual bool IsColorModulationAllowed() const;
+ virtual bool IsSetContentAllowed() const;
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
- virtual bool DoRender();
+ virtual bool DoRender();
private:
BS_DynamicBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Width, unsigned int Height);
- BS_DynamicBitmap(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
+ BS_DynamicBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
bool CreateGLImage(unsigned int Width, unsigned int Height);
diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp
index 9dbb0a0646..b9cbb6a7ba 100644
--- a/engines/sword25/gfx/fontresource.cpp
+++ b/engines/sword25/gfx/fontresource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -60,31 +60,27 @@ static const unsigned int DEFAULT_GAPWIDTH = 1;
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_FontResource::BS_FontResource(BS_Kernel* pKernel, const Common::String& FileName) :
+BS_FontResource::BS_FontResource(BS_Kernel *pKernel, const Common::String &FileName) :
_pKernel(pKernel),
_Valid(false),
- BS_Resource(FileName, BS_Resource::TYPE_FONT)
-{
+ BS_Resource(FileName, BS_Resource::TYPE_FONT) {
// XML Fontdatei parsen
TiXmlDocument Doc;
- if (!_ParseXMLDocument(FileName, Doc))
- {
+ if (!_ParseXMLDocument(FileName, Doc)) {
BS_LOG_ERRORLN("The following TinyXML-Error occured while parsing \"%s\": %s", GetFileName().c_str(), Doc.ErrorDesc());
return;
}
// Font-Tag finden
- TiXmlElement* pElement = Doc.FirstChildElement("font");
- if (!pElement)
- {
+ TiXmlElement *pElement = Doc.FirstChildElement("font");
+ if (!pElement) {
BS_LOG_ERRORLN("No <font> tag found in \"%s\".", GetFileName().c_str());
return;
}
// Font-Tag parsen
Common::String BitmapFileName;
- if (!_ParseFontTag(*pElement, BitmapFileName, _LineHeight, _GapWidth))
- {
+ if (!_ParseFontTag(*pElement, BitmapFileName, _LineHeight, _GapWidth)) {
BS_LOG_ERRORLN("An error occurred while parsing <font> tag in \"%s\".", GetFileName().c_str());
return;
}
@@ -93,43 +89,38 @@ BS_FontResource::BS_FontResource(BS_Kernel* pKernel, const Common::String& FileN
{
// Pointer auf den Package-Manager bekommen
BS_ASSERT(_pKernel);
- BS_PackageManager* pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
+ BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
BS_ASSERT(pPackage);
// Absoluten, eindeutigen Pfad bestimmen
_BitmapFileName = pPackage->GetAbsolutePath(BitmapFileName);
- if (_BitmapFileName == "")
- {
+ if (_BitmapFileName == "") {
BS_LOG_ERRORLN("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.",
- _BitmapFileName.c_str(), GetFileName().c_str());
+ _BitmapFileName.c_str(), GetFileName().c_str());
return;
}
// Bitmapdatei cachen
- if (!_pKernel->GetResourceManager()->PrecacheResource(_BitmapFileName))
- {
+ if (!_pKernel->GetResourceManager()->PrecacheResource(_BitmapFileName)) {
BS_LOG_ERRORLN("Could not precache \"%s\".", _BitmapFileName.c_str());
return;
}
}
-
+
// Das Erste Character-Tag finden
pElement = pElement->FirstChildElement("character");
- if (!pElement)
- {
+ if (!pElement) {
BS_LOG_ERRORLN("No <character> tag found in \"%s\".", GetFileName().c_str());
return;
}
// Alle Character-Tags parsen
- while (pElement)
- {
- int CharCode;
+ while (pElement) {
+ int CharCode;
BS_Rect CharRect;
// Aktuelles Character-Tag parsen
- if (!_ParseCharacterTag(*pElement, CharCode, CharRect))
- {
+ if (!_ParseCharacterTag(*pElement, CharCode, CharRect)) {
BS_LOG_ERRORLN("An error occured while parsing a <character> tag in \"%s\".", GetFileName().c_str());
return;
}
@@ -148,19 +139,17 @@ BS_FontResource::BS_FontResource(BS_Kernel* pKernel, const Common::String& FileN
// -----------------------------------------------------------------------------
-bool BS_FontResource::_ParseXMLDocument(const Common::String & FileName, TiXmlDocument & Doc) const
-{
+bool BS_FontResource::_ParseXMLDocument(const Common::String &FileName, TiXmlDocument &Doc) const {
// Pointer auf den Package-Manager bekommen
BS_ASSERT(_pKernel);
- BS_PackageManager* pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
+ BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
BS_ASSERT(pPackage);
// Die Daten werden zunächst über den Package-Manager gelesen und dann in einen um ein Byte größeren Buffer kopiert
// und NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
unsigned int FileSize;
- char * LoadBuffer = (char*) pPackage->GetFile(GetFileName(), &FileSize);
- if (!LoadBuffer)
- {
+ char *LoadBuffer = (char *) pPackage->GetFile(GetFileName(), &FileSize);
+ if (!LoadBuffer) {
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
return false;
}
@@ -182,33 +171,29 @@ bool BS_FontResource::_ParseXMLDocument(const Common::String & FileName, TiXmlDo
// -----------------------------------------------------------------------------
-bool BS_FontResource::_ParseFontTag(TiXmlElement & Tag, Common::String & BitmapFileName, int & Lineheight, int & GapWidth) const
-{
+bool BS_FontResource::_ParseFontTag(TiXmlElement &Tag, Common::String &BitmapFileName, int &Lineheight, int &GapWidth) const {
// Bitmap Attribut auslesen
- const char * BitmapString = Tag.Attribute("bitmap");
- if (!BitmapString)
- {
+ const char *BitmapString = Tag.Attribute("bitmap");
+ if (!BitmapString) {
BS_LOG_ERRORLN("<font> tag without bitmap attribute occurred in \"%s\".", GetFileName().c_str());
return false;
}
BitmapFileName = BitmapString;
// Lineheight Attribut auslesen
- const char * LineheightString = Tag.Attribute("lineheight");
- if (!LineheightString || !BS_String::ToInt(Common::String(LineheightString), Lineheight) || Lineheight < 0)
- {
+ const char *LineheightString = Tag.Attribute("lineheight");
+ if (!LineheightString || !BS_String::ToInt(Common::String(LineheightString), Lineheight) || Lineheight < 0) {
BS_LOG_WARNINGLN("Illegal or missing lineheight attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
- GetFileName().c_str(), DEFAULT_LINEHEIGHT);
+ GetFileName().c_str(), DEFAULT_LINEHEIGHT);
Lineheight = DEFAULT_LINEHEIGHT;
}
// Gap Attribut auslesen
- const char * GapString = Tag.Attribute("gap");
- if (!GapString || !BS_String::ToInt(Common::String(GapString), GapWidth) || GapWidth < 0)
- {
+ const char *GapString = Tag.Attribute("gap");
+ if (!GapString || !BS_String::ToInt(Common::String(GapString), GapWidth) || GapWidth < 0) {
BS_LOG_WARNINGLN("Illegal or missing gap attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
- GetFileName().c_str(), DEFAULT_GAPWIDTH);
+ GetFileName().c_str(), DEFAULT_GAPWIDTH);
GapWidth = DEFAULT_GAPWIDTH;
}
@@ -217,12 +202,10 @@ bool BS_FontResource::_ParseFontTag(TiXmlElement & Tag, Common::String & BitmapF
// -----------------------------------------------------------------------------
-bool BS_FontResource::_ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect & Rect) const
-{
+bool BS_FontResource::_ParseCharacterTag(TiXmlElement &Tag, int &Code, BS_Rect &Rect) const {
// Code Attribut auslesen
- const char * CodeString = Tag.Attribute("code");
- if (!CodeString || !BS_String::ToInt(Common::String(CodeString), Code) || Code < 0 || Code >= 256)
- {
+ const char *CodeString = Tag.Attribute("code");
+ if (!CodeString || !BS_String::ToInt(Common::String(CodeString), Code) || Code < 0 || Code >= 256) {
BS_LOG_ERRORLN("Illegal or missing code attribute in <character> tag in \"%s\".", GetFileName().c_str());
return false;
}
@@ -238,7 +221,7 @@ bool BS_FontResource::_ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect
Rect.left = tmp;
// Right Attribut auslesen
- const char * RightString = Tag.Attribute("right");
+ const char *RightString = Tag.Attribute("right");
if (!RightString || !BS_String::ToInt(RightString, tmp) || tmp < 0) {
BS_LOG_ERRORLN("Illegal or missing right attribute in <character> tag in \"%s\".", GetFileName().c_str());
return false;
@@ -246,7 +229,7 @@ bool BS_FontResource::_ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect
Rect.right = tmp;
// Top Attribut auslesen
- const char * TopString = Tag.Attribute("top");
+ const char *TopString = Tag.Attribute("top");
if (!TopString || !BS_String::ToInt(TopString, tmp) || tmp < 0) {
BS_LOG_ERRORLN("Illegal or missing top attribute in <character> tag in \"%s\".", GetFileName().c_str());
return false;
@@ -254,9 +237,8 @@ bool BS_FontResource::_ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect
Rect.top = tmp;
// Bottom Attribut auslesen
- const char * BottomString = Tag.Attribute("bottom");
- if (!BottomString || !BS_String::ToInt(BottomString, tmp) || tmp < 0)
- {
+ const char *BottomString = Tag.Attribute("bottom");
+ if (!BottomString || !BS_String::ToInt(BottomString, tmp) || tmp < 0) {
BS_LOG_ERRORLN("Illegal or missing bottom attribute in <character> tag in \"%s\".", GetFileName().c_str());
return false;
}
diff --git a/engines/sword25/gfx/fontresource.h b/engines/sword25/gfx/fontresource.h
index fbaa368170..d26c79c575 100644
--- a/engines/sword25/gfx/fontresource.h
+++ b/engines/sword25/gfx/fontresource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,65 +58,75 @@ class BS_Kernel;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FontResource : public BS_Resource
-{
+class BS_FontResource : public BS_Resource {
public:
/**
- @brief Erzeugt eine neues Exemplar von BS_FontResource
- @param pKernel ein Pointer auf den Kernel
- @param FileName der Dateiname der zu ladenen Resource
- @remark Wenn der Konstruktor erfolgreich ausgeführt werden konnte gibt die Methode IsValid true zurück.
+ @brief Erzeugt eine neues Exemplar von BS_FontResource
+ @param pKernel ein Pointer auf den Kernel
+ @param FileName der Dateiname der zu ladenen Resource
+ @remark Wenn der Konstruktor erfolgreich ausgeführt werden konnte gibt die Methode IsValid true zurück.
*/
- BS_FontResource(BS_Kernel * pKernel, const Common::String & FileName);
+ BS_FontResource(BS_Kernel *pKernel, const Common::String &FileName);
/**
- @brief Gibt true zurück, wenn das Objekt korrekt initialisiert wurde.
+ @brief Gibt true zurück, wenn das Objekt korrekt initialisiert wurde.
- Diese Methode kann dazu benutzt werden um festzustellen, ob der Konstruktor erfolgreich ausgeführt wurde.
+ Diese Methode kann dazu benutzt werden um festzustellen, ob der Konstruktor erfolgreich ausgeführt wurde.
*/
- bool IsValid() const { return _Valid; }
+ bool IsValid() const {
+ return _Valid;
+ }
/**
- @brief Gibt die Zeilenhöhe des Fonts in Pixeln zurück.
+ @brief Gibt die Zeilenhöhe des Fonts in Pixeln zurück.
- Die Zeilenhöhe ist der Wert, der zur Y-Koordinate addiert wird, wenn ein Zeilenumbruch auftritt.
+ Die Zeilenhöhe ist der Wert, der zur Y-Koordinate addiert wird, wenn ein Zeilenumbruch auftritt.
*/
- int GetLineHeight() const { return _LineHeight; }
+ int GetLineHeight() const {
+ return _LineHeight;
+ }
/**
- @brief Gibt den Buchstabenabstand der Fonts in Pixeln zurück.
+ @brief Gibt den Buchstabenabstand der Fonts in Pixeln zurück.
- Der Buchstabenabstand ist der Wert, der zwischen zwei Buchstaben freigelassen wird.
+ Der Buchstabenabstand ist der Wert, der zwischen zwei Buchstaben freigelassen wird.
*/
- int GetGapWidth() const { return _GapWidth; }
+ int GetGapWidth() const {
+ return _GapWidth;
+ }
/**
- @brief Gibt das Bounding-Rect eines Zeichens auf der Charactermap zurück.
- @param Character der ASCII-Code des Zeichens
- @return Das Bounding-Rect des übergebenen Zeichens auf der Charactermap.
+ @brief Gibt das Bounding-Rect eines Zeichens auf der Charactermap zurück.
+ @param Character der ASCII-Code des Zeichens
+ @return Das Bounding-Rect des übergebenen Zeichens auf der Charactermap.
*/
- const BS_Rect & GetCharacterRect(int Character) const { BS_ASSERT(Character >= 0 && Character < 256); return _CharacterRects[Character]; }
+ const BS_Rect &GetCharacterRect(int Character) const {
+ BS_ASSERT(Character >= 0 && Character < 256);
+ return _CharacterRects[Character];
+ }
/**
- @brief Gibt den Dateinamen der Charactermap zurück.
+ @brief Gibt den Dateinamen der Charactermap zurück.
*/
- const Common::String & GetCharactermapFileName() const { return _BitmapFileName; }
+ const Common::String &GetCharactermapFileName() const {
+ return _BitmapFileName;
+ }
private:
- BS_Kernel * _pKernel;
- bool _Valid;
- Common::String _BitmapFileName;
- int _LineHeight;
- int _GapWidth;
- BS_Rect _CharacterRects[256];
+ BS_Kernel *_pKernel;
+ bool _Valid;
+ Common::String _BitmapFileName;
+ int _LineHeight;
+ int _GapWidth;
+ BS_Rect _CharacterRects[256];
// -----------------------------------------------------------------------------
// Hilfsmethoden
// -----------------------------------------------------------------------------
-
- bool _ParseXMLDocument(const Common::String & FileName, TiXmlDocument & Doc) const;
- bool _ParseFontTag(TiXmlElement & Tag, Common::String & BitmapFileName, int & LineHeight, int & GapWidth) const;
- bool _ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect & Rect) const;
+
+ bool _ParseXMLDocument(const Common::String &FileName, TiXmlDocument &Doc) const;
+ bool _ParseFontTag(TiXmlElement &Tag, Common::String &BitmapFileName, int &LineHeight, int &GapWidth) const;
+ bool _ParseCharacterTag(TiXmlElement &Tag, int &Code, BS_Rect &Rect) const;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/framecounter.cpp b/engines/sword25/gfx/framecounter.cpp
index c2e6ab772d..82d4d313a6 100644
--- a/engines/sword25/gfx/framecounter.cpp
+++ b/engines/sword25/gfx/framecounter.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -38,14 +38,13 @@
namespace Sword25 {
BS_Framecounter::BS_Framecounter(int UpdateFrequency) :
- m_FPS(0),
- m_FPSCount(0),
- m_LastUpdateTime(-1) {
+ m_FPS(0),
+ m_FPSCount(0),
+ m_LastUpdateTime(-1) {
SetUpdateFrequency(UpdateFrequency);
}
-void BS_Framecounter::Update()
-{
+void BS_Framecounter::Update() {
// Aktuellen Systemtimerstand auslesen
uint64_t Timer = g_system->getMillis() * 1000;
diff --git a/engines/sword25/gfx/framecounter.h b/engines/sword25/gfx/framecounter.h
index 89612f94be..f4381eb1f2 100644
--- a/engines/sword25/gfx/framecounter.h
+++ b/engines/sword25/gfx/framecounter.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,14 +53,14 @@ private:
public:
/**
* Creates a new BS_Framecounter object
- * @param UpdateFrequency Specifies how often the frame counter should be updated in a sceond.
+ * @param UpdateFrequency Specifies how often the frame counter should be updated in a sceond.
* The default value is 10.
*/
BS_Framecounter(int UpdateFrequency = DEFAULT_UPDATE_FREQUENCY);
/**
* Determines how often the frame counter should be updated in a second.
- * @param UpdateFrequency Specifies how often the frame counter should be updated in a second.
+ * @param UpdateFrequency Specifies how often the frame counter should be updated in a second.
*/
inline void SetUpdateFrequency(int UpdateFrequency);
@@ -72,10 +72,12 @@ public:
/**
* Returns the current FPS value.
*/
- int GetFPS() const { return m_FPS; }
+ int GetFPS() const {
+ return m_FPS;
+ }
private:
- int m_FPS;
+ int m_FPS;
int m_FPSCount;
int64_t m_LastUpdateTime;
uint64_t m_UpdateDelay;
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index c35fba4159..075bf9757a 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,20 +58,19 @@ namespace Sword25 {
using namespace std;
using namespace Lua;
-static const unsigned int FRAMETIME_SAMPLE_COUNT = 5; // Anzahl der Framezeiten über die, die Framezeit gemittelt wird
+static const unsigned int FRAMETIME_SAMPLE_COUNT = 5; // Anzahl der Framezeiten über die, die Framezeit gemittelt wird
-BS_GraphicEngine::BS_GraphicEngine(BS_Kernel * pKernel) :
+BS_GraphicEngine::BS_GraphicEngine(BS_Kernel *pKernel) :
m_Width(0),
m_Height(0),
m_BitDepth(0),
m_Windowed(0),
- m_LastTimeStamp((uint64)-1), // max. BS_INT64 um beim ersten Aufruf von _UpdateLastFrameDuration() einen Reset zu erzwingen
+ m_LastTimeStamp((uint64) - 1), // max. BS_INT64 um beim ersten Aufruf von _UpdateLastFrameDuration() einen Reset zu erzwingen
m_LastFrameDuration(0),
m_TimerActive(true),
m_FrameTimeSampleSlot(0),
m_RepaintedPixels(0),
- BS_ResourceService(pKernel)
-{
+ BS_ResourceService(pKernel) {
for (int i = 0; i < FRAMETIME_SAMPLE_COUNT; i++)
m_FrameTimeSamples[i] = 0;
@@ -83,8 +82,7 @@ BS_GraphicEngine::BS_GraphicEngine(BS_Kernel * pKernel) :
// -----------------------------------------------------------------------------
-void BS_GraphicEngine::UpdateLastFrameDuration()
-{
+void BS_GraphicEngine::UpdateLastFrameDuration() {
// Aktuelle Zeit holen
uint64_t CurrentTime = BS_Kernel::GetInstance()->GetMicroTicks();
@@ -106,58 +104,50 @@ void BS_GraphicEngine::UpdateLastFrameDuration()
// -----------------------------------------------------------------------------
-namespace
-{
- bool DoSaveScreenshot(BS_GraphicEngine & GraphicEngine, const Common::String & Filename, bool Thumbnail)
- {
- unsigned int Width;
- unsigned int Height;
- Common::Array<unsigned int> Data;
- if (!GraphicEngine.GetScreenshot(Width, Height, Data))
- {
- BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
- return false;
- }
-
- unsigned int test = Data.size();
-
- if (Thumbnail)
- return BS_Screenshot::SaveThumbnailToFile(Width, Height, Data, Filename);
- else
- return BS_Screenshot::SaveToFile(Width, Height, Data, Filename);
+namespace {
+bool DoSaveScreenshot(BS_GraphicEngine &GraphicEngine, const Common::String &Filename, bool Thumbnail) {
+ unsigned int Width;
+ unsigned int Height;
+ Common::Array<unsigned int> Data;
+ if (!GraphicEngine.GetScreenshot(Width, Height, Data)) {
+ BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
+ return false;
}
+
+ unsigned int test = Data.size();
+
+ if (Thumbnail)
+ return BS_Screenshot::SaveThumbnailToFile(Width, Height, Data, Filename);
+ else
+ return BS_Screenshot::SaveToFile(Width, Height, Data, Filename);
+}
}
// -----------------------------------------------------------------------------
-bool BS_GraphicEngine::SaveScreenshot(const Common::String & Filename)
-{
+bool BS_GraphicEngine::SaveScreenshot(const Common::String &Filename) {
return DoSaveScreenshot(*this, Filename, false);
}
// -----------------------------------------------------------------------------
-bool BS_GraphicEngine::SaveThumbnailScreenshot( const Common::String & Filename )
-{
+bool BS_GraphicEngine::SaveThumbnailScreenshot(const Common::String &Filename) {
return DoSaveScreenshot(*this, Filename, true);
}
// -----------------------------------------------------------------------------
-void BS_GraphicEngine::ARGBColorToLuaColor(lua_State * L, unsigned int Color)
-{
- lua_Number Components[4] =
- {
- (Color >> 16) & 0xff, // Rot
- (Color >> 8) & 0xff, // Grün
- Color & 0xff, // Blau
- Color >> 24, // Alpha
+void BS_GraphicEngine::ARGBColorToLuaColor(lua_State *L, unsigned int Color) {
+ lua_Number Components[4] = {
+ (Color >> 16) & 0xff, // Rot
+ (Color >> 8) & 0xff, // Grün
+ Color & 0xff, // Blau
+ Color >> 24, // Alpha
};
lua_newtable(L);
- for (unsigned int i = 1; i <= 4; i++)
- {
+ for (unsigned int i = 1; i <= 4; i++) {
lua_pushnumber(L, i);
lua_pushnumber(L, Components[i - 1]);
lua_settable(L, -3);
@@ -166,8 +156,7 @@ void BS_GraphicEngine::ARGBColorToLuaColor(lua_State * L, unsigned int Color)
// -----------------------------------------------------------------------------
-unsigned int BS_GraphicEngine::LuaColorToARGBColor(lua_State * L, int StackIndex)
-{
+unsigned int BS_GraphicEngine::LuaColorToARGBColor(lua_State *L, int StackIndex) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@@ -199,8 +188,7 @@ unsigned int BS_GraphicEngine::LuaColorToARGBColor(lua_State * L, int StackIndex
// Alpha Farbkomponente auslesen
unsigned int Alpha = 0xff;
- if (n == 4)
- {
+ if (n == 4) {
lua_rawgeti(L, StackIndex, 4);
Alpha = static_cast<unsigned int>(lua_tonumber(L, -1));
if (!lua_isnumber(L, -1) || Alpha >= 256) luaL_argcheck(L, 0, StackIndex, "alpha color component must be an integer between 0 and 255");
@@ -216,16 +204,14 @@ unsigned int BS_GraphicEngine::LuaColorToARGBColor(lua_State * L, int StackIndex
// -----------------------------------------------------------------------------
-bool BS_GraphicEngine::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_GraphicEngine::Persist(BS_OutputPersistenceBlock &Writer) {
Writer.Write(m_TimerActive);
return true;
}
// -----------------------------------------------------------------------------
-bool BS_GraphicEngine::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_GraphicEngine::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(m_TimerActive);
return Reader.IsGood();
}
diff --git a/engines/sword25/gfx/graphicengine.h b/engines/sword25/gfx/graphicengine.h
index 3ebe591923..82559e1a48 100644
--- a/engines/sword25/gfx/graphicengine.h
+++ b/engines/sword25/gfx/graphicengine.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -65,15 +65,15 @@ class BS_Screenshot;
typedef unsigned int BS_COLOR;
// Makros
-#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B))
-#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B))
+#define BS_RGB(R,G,B) (0xFF000000 | ((R) << 16) | ((G) << 8) | (B))
+#define BS_ARGB(A,R,G,B) (((A) << 24) | ((R) << 16) | ((G) << 8) | (B))
/**
- @brief Dies ist das Graphik-Engine Interface, dass alle Methoden und Klassen enthält, die eine Graphik-Engine implementieren muss.
+ @brief Dies ist das Graphik-Engine Interface, dass alle Methoden und Klassen enthält, die eine Graphik-Engine implementieren muss.
- Hier sind nur wenige Rumpffunktionen realisiert, wie z.B. das Abfragen der Parameter des Ausgabepuffers.
- Die Hauptfunktionen muss eine Implementation dieses Inferfaces stellen.<br>
- Die bisher einzige Implementation ist BS_DDrawGfx.
+ Hier sind nur wenige Rumpffunktionen realisiert, wie z.B. das Abfragen der Parameter des Ausgabepuffers.
+ Die Hauptfunktionen muss eine Implementation dieses Inferfaces stellen.<br>
+ Die bisher einzige Implementation ist BS_DDrawGfx.
*/
class BS_GraphicEngine : public BS_ResourceService, public BS_Persistable {
@@ -82,7 +82,7 @@ public:
// -----
// Colour formats
- //
+ //
/**
* The colour format used by the engine
*/
@@ -124,33 +124,33 @@ public:
*/
CF_ARGB32,
/**
- 32-bit colour format (A8B8G8R8) (little endian)
+ 32-bit colour format (A8B8G8R8) (little endian)
*/
CF_ABGR32
};
-
+
// Interface
// ---------
/**
* Initialises the graphics engine and sets the screen mode. Returns true if initialisation failed.
* Notes: This method should be called immediately after the initialisation of all services.
- *
- * @param Height The height of the output buffer in pixels. The default value is 600
- * @param BitDepth The bit depth of the desired output buffer in bits. The default value is 16
- * @param BackbufferCount The number of back buffers to be created. The default value is 2
- * @param Windowed Indicates whether the engine is to run in windowed mode.
+ *
+ * @param Height The height of the output buffer in pixels. The default value is 600
+ * @param BitDepth The bit depth of the desired output buffer in bits. The default value is 16
+ * @param BackbufferCount The number of back buffers to be created. The default value is 2
+ * @param Windowed Indicates whether the engine is to run in windowed mode.
*/
- virtual bool Init(int Width = 800, int Height = 600, int BitDepth = 16, int BackbufferCount = 2, bool Windowed = false) = 0;
+ virtual bool Init(int Width = 800, int Height = 600, int BitDepth = 16, int BackbufferCount = 2, bool Windowed = false) = 0;
/**
* Begins rendering a new frame.
* Notes: This method must be called at the beginning of the main loop, before any rendering methods are used.
* Notes: Implementations of this method must call _UpdateLastFrameDuration()
- * @param UpdateAll Specifies whether the renderer should redraw everything on the next frame.
+ * @param UpdateAll Specifies whether the renderer should redraw everything on the next frame.
* This feature can be useful if the renderer with Dirty Rectangles works, but sometimes the client may
*/
- virtual bool StartFrame(bool UpdateAll = false) = 0;
+ virtual bool StartFrame(bool UpdateAll = false) = 0;
/**
* Ends the rendering of a frame and draws it on the screen.
@@ -158,7 +158,7 @@ public:
* This method must be at the end of the main loop. After this call, no further Render method may be called.
* This should only be called once for a given previous call to #StartFrame.
*/
- virtual bool EndFrame() = 0;
+ virtual bool EndFrame() = 0;
// Debug methods
@@ -168,17 +168,17 @@ public:
* This method must be called between calls to StartFrame() and EndFrame(), and is intended only for debugging
* purposes. The line will only appear for a single frame. If the line is to be shown permanently, it must be
* called for every frame.
- * @param Start The starting point of the line
- * @param End The ending point of the line
- * @param Color The colour of the line. The default is BS_RGB (255,255,255) (White)
+ * @param Start The starting point of the line
+ * @param End The ending point of the line
+ * @param Color The colour of the line. The default is BS_RGB (255,255,255) (White)
*/
- virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
+ virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color = BS_RGB(255, 255, 255)) = 0;
/**
* Creates a screenshot of the current frame buffer and writes it to a graphic file in PNG format.
- * Returns true if the screenshot was saved successfully.
+ * Returns true if the screenshot was saved successfully.
* Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
- * @param Filename The filename for the screenshot
+ * @param Filename The filename for the screenshot
*/
bool SaveScreenshot(const Common::String &Filename);
@@ -187,7 +187,7 @@ public:
* the interface boards the the image as a 16th of it's original size.
* Notes: This method should only be called after a call to EndFrame(), and before the next call to StartFrame().
* The frame buffer must have a resolution of 800x600.
- * @param Filename The filename for the screenshot
+ * @param Filename The filename for the screenshot
*/
bool SaveThumbnailScreenshot(const Common::String &Filename);
@@ -195,91 +195,117 @@ public:
* Reads the current contents of the frame buffer
* Notes: This method is for creating screenshots. It is not very optimised. It should only be called
* after a call to EndFrame(), and before the next call to StartFrame().
- * @param Width Returns the width of the frame buffer
- * @param Height Returns the height of the frame buffer
- * @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
+ * @param Width Returns the width of the frame buffer
+ * @param Height Returns the height of the frame buffer
+ * @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
*/
virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> &Data) = 0;
-
+
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0;
/**
* Specifies the time (in microseconds) since the last frame has passed
*/
- int GetLastFrameDurationMicro() { if (m_TimerActive) return m_LastFrameDuration; else return 0; }
+ int GetLastFrameDurationMicro() {
+ if (m_TimerActive) return m_LastFrameDuration;
+ else return 0;
+ }
/**
* Specifies the time (in microseconds) the previous frame took
*/
- float GetLastFrameDuration() { if (m_TimerActive) return static_cast<float>(m_LastFrameDuration) / 1000000.0f; else return 0; }
+ float GetLastFrameDuration() {
+ if (m_TimerActive) return static_cast<float>(m_LastFrameDuration) / 1000000.0f;
+ else return 0;
+ }
- void StopMainTimer() { m_TimerActive = false; }
- void ResumeMainTimer() { m_TimerActive = true; }
- float GetSecondaryFrameDuration() { return static_cast<float>(m_LastFrameDuration) / 1000000.0f; }
+ void StopMainTimer() {
+ m_TimerActive = false;
+ }
+ void ResumeMainTimer() {
+ m_TimerActive = true;
+ }
+ float GetSecondaryFrameDuration() {
+ return static_cast<float>(m_LastFrameDuration) / 1000000.0f;
+ }
// Accessor methods
/**
* Returns the width of the output buffer in pixels
*/
- int GetDisplayWidth() { return m_Width; }
+ int GetDisplayWidth() {
+ return m_Width;
+ }
/**
* Returns the height of the output buffer in pixels
*/
- int GetDisplayHeight() { return m_Height; }
+ int GetDisplayHeight() {
+ return m_Height;
+ }
/**
* Returns the bounding box of the output buffer: (0, 0, Width, Height)
*/
- BS_Rect& GetDisplayRect() { return m_ScreenRect; }
+ BS_Rect &GetDisplayRect() {
+ return m_ScreenRect;
+ }
/**
* Returns the bit depth of the output buffer
*/
- int GetBitDepth() { return m_BitDepth; }
+ int GetBitDepth() {
+ return m_BitDepth;
+ }
/**
* Determines whether the frame buffer change is to be synchronised with Vsync. This is turned on by default.
* Notes: In windowed mode, this setting has no effect.
- * @param Vsync Indicates whether the frame buffer changes are to be synchronised with Vsync.
+ * @param Vsync Indicates whether the frame buffer changes are to be synchronised with Vsync.
*/
- virtual void SetVsync(bool Vsync) = 0;
+ virtual void SetVsync(bool Vsync) = 0;
/**
* Returns true if V-Sync is on.
* Notes: In windowed mode, this setting has no effect.
*/
- virtual bool GetVsync() const = 0;
+ virtual bool GetVsync() const = 0;
/**
* Returns true if the engine is running in Windowed mode.
*/
- bool IsWindowed() { return m_Windowed; }
+ bool IsWindowed() {
+ return m_Windowed;
+ }
/**
* Fills a rectangular area of the frame buffer with a colour.
* Notes: It is possible to create transparent rectangles by passing a colour with an Alpha value of 255.
- * @param FillRectPtr Pointer to a BS_Rect, which specifies the section of the frame buffer to be filled.
- * If the rectangle falls partly off-screen, then it is automatically trimmed.
+ * @param FillRectPtr Pointer to a BS_Rect, which specifies the section of the frame buffer to be filled.
+ * If the rectangle falls partly off-screen, then it is automatically trimmed.
* If a NULL value is passed, then the entire image is to be filled.
- * @param Color The 32-bit colour with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black)
- @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
+ * @param Color The 32-bit colour with which the area is to be filled. The default is BS_RGB(0, 0, 0) (black)
+ @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
*/
- virtual bool Fill(const BS_Rect * FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
+ virtual bool Fill(const BS_Rect *FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
// Debugging Methods
- int GetFPSCount() const { return m_FPSCounter.GetFPS(); }
- int GetRepaintedPixels() const { return m_RepaintedPixels; }
+ int GetFPSCount() const {
+ return m_FPSCounter.GetFPS();
+ }
+ int GetRepaintedPixels() const {
+ return m_RepaintedPixels;
+ }
// Access methods
/**
* Returns the size of a pixel entry in bytes for a particular colour format
- * @param ColorFormat The desired colour format. The parameter must be of type COLOR_FORMATS
- * @return Returns the size of a pixel in bytes. If the colour format is unknown, -1 is returned.
+ * @param ColorFormat The desired colour format. The parameter must be of type COLOR_FORMATS
+ * @return Returns the size of a pixel in bytes. If the colour format is unknown, -1 is returned.
*/
static int GetPixelSize(BS_GraphicEngine::COLOR_FORMATS ColorFormat) {
switch (ColorFormat) {
@@ -297,16 +323,16 @@ public:
return -1;
}
-
+
/**
* Calculates the length of an image line in bytes, depending on a given colour format.
- * @param ColorFormat The colour format
- * @param Width The width of the line in pixels
- * @return Reflects the length of the line in bytes. If the colour format is
+ * @param ColorFormat The colour format
+ * @param Width The width of the line in pixels
+ * @return Reflects the length of the line in bytes. If the colour format is
* unknown, -1 is returned
*/
static int CalcPitch(BS_GraphicEngine::COLOR_FORMATS ColorFormat, int Width) {
- switch (ColorFormat){
+ switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
case BS_GraphicEngine::CF_RGB15:
return Width * 2;
@@ -337,21 +363,21 @@ public:
protected:
// Constructor
// -----------
- BS_GraphicEngine(BS_Kernel* pKernel);
+ BS_GraphicEngine(BS_Kernel *pKernel);
// Display Variables
// -----------------
- int m_Width;
- int m_Height;
+ int m_Width;
+ int m_Height;
BS_Rect m_ScreenRect;
- int m_BitDepth;
- bool m_Windowed;
+ int m_BitDepth;
+ bool m_Windowed;
// Debugging Variables
// -------------------
BS_Framecounter m_FPSCounter;
- unsigned int m_RepaintedPixels;
+ unsigned int m_RepaintedPixels;
/**
* Calculates the time since the last frame beginning has passed.
@@ -363,11 +389,11 @@ private:
// LastFrameDuration Variables
// ---------------------------
- uint64 m_LastTimeStamp;
- unsigned int m_LastFrameDuration;
- bool m_TimerActive;
- Common::Array<unsigned int> m_FrameTimeSamples;
- unsigned int m_FrameTimeSampleSlot;
+ uint64 m_LastTimeStamp;
+ unsigned int m_LastFrameDuration;
+ bool m_TimerActive;
+ Common::Array<unsigned int> m_FrameTimeSamples;
+ unsigned int m_FrameTimeSampleSlot;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/graphicengine_script.cpp b/engines/sword25/gfx/graphicengine_script.cpp
index 74a008d1fc..d009916f32 100644
--- a/engines/sword25/gfx/graphicengine_script.cpp
+++ b/engines/sword25/gfx/graphicengine_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -68,40 +68,35 @@ static bool AnimationDeleteCallback(unsigned int Data);
static bool AnimationActionCallback(unsigned int Data);
static bool AnimationLoopPointCallback(unsigned int Data);
-namespace
-{
- // -------------------------------------------------------------------------
+namespace {
+// -------------------------------------------------------------------------
- class ActionCallback : public BS_LuaCallback
- {
- public:
- ActionCallback(lua_State * L) : BS_LuaCallback(L) {};
+class ActionCallback : public BS_LuaCallback {
+public:
+ ActionCallback(lua_State *L) : BS_LuaCallback(L) {};
- Common::String Action;
+ Common::String Action;
- protected:
- virtual int PreFunctionInvokation(lua_State * L)
- {
- lua_pushstring(L, Action.c_str());
- return 1;
- }
- };
+protected:
+ virtual int PreFunctionInvokation(lua_State *L) {
+ lua_pushstring(L, Action.c_str());
+ return 1;
+ }
+};
- std::auto_ptr<BS_LuaCallback> LoopPointCallbackPtr;
- std::auto_ptr<ActionCallback> ActionCallbackPtr;
+std::auto_ptr<BS_LuaCallback> LoopPointCallbackPtr;
+std::auto_ptr<ActionCallback> ActionCallbackPtr;
- // -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
- struct CallbackfunctionRegisterer
- {
- CallbackfunctionRegisterer()
- {
- BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaLoopPointCB", (void (*)(int))AnimationLoopPointCallback);
- BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaActionCB", (void (*)(int))AnimationActionCallback);
- BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaDeleteCB", (void (*)(int))AnimationDeleteCallback);
- }
- };
- static CallbackfunctionRegisterer Instance;
+struct CallbackfunctionRegisterer {
+ CallbackfunctionRegisterer() {
+ BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaLoopPointCB", (void ( *)(int))AnimationLoopPointCallback);
+ BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaActionCB", (void ( *)(int))AnimationActionCallback);
+ BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaDeleteCB", (void ( *)(int))AnimationDeleteCallback);
+ }
+};
+static CallbackfunctionRegisterer Instance;
}
// -----------------------------------------------------------------------------
@@ -115,24 +110,20 @@ namespace
#define TEXT_CLASS_NAME "Gfx.Text"
#define ANIMATION_CLASS_NAME "Gfx.Animation"
#define ANIMATION_TEMPLATE_CLASS_NAME "Gfx.AnimationTemplate"
-static const char * GFX_LIBRARY_NAME = "Gfx";
+static const char *GFX_LIBRARY_NAME = "Gfx";
// -----------------------------------------------------------------------------
// Wie luaL_checkudata, nur ohne dass kein Fehler erzeugt wird.
-static void * my_checkudata (lua_State *L, int ud, const char *tname)
-{
+static void *my_checkudata(lua_State *L, int ud, const char *tname) {
int top = lua_gettop(L);
- void * p = lua_touserdata(L, ud);
- if (p != NULL) /* value is a userdata? */
- {
- if (lua_getmetatable(L, ud)) /* does it have a metatable? */
- {
+ void *p = lua_touserdata(L, ud);
+ if (p != NULL) { /* value is a userdata? */
+ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
BS_LuaBindhelper::GetMetatable(L, tname);
- if (lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
- {
+ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
lua_settop(L, top);
return p;
}
@@ -145,27 +136,22 @@ static void * my_checkudata (lua_State *L, int ud, const char *tname)
// -----------------------------------------------------------------------------
-static void NewUintUserData(lua_State * L, unsigned int Value)
-{
- void * UserData = lua_newuserdata(L, sizeof(Value));
+static void NewUintUserData(lua_State *L, unsigned int Value) {
+ void *UserData = lua_newuserdata(L, sizeof(Value));
memcpy(UserData, &Value, sizeof(Value));
}
// -----------------------------------------------------------------------------
-static BS_AnimationTemplate * CheckAnimationTemplate(lua_State * L, int idx = 1)
-{
+static BS_AnimationTemplate *CheckAnimationTemplate(lua_State *L, int idx = 1) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.AnimationTemplate
unsigned int AnimationTemplateHandle;
- if ((AnimationTemplateHandle = *reinterpret_cast<unsigned int *>(my_checkudata(L, idx, ANIMATION_TEMPLATE_CLASS_NAME))) != 0)
- {
- BS_AnimationTemplate * AnimationTemplatePtr = BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(AnimationTemplateHandle);
+ if ((AnimationTemplateHandle = *reinterpret_cast<unsigned int *>(my_checkudata(L, idx, ANIMATION_TEMPLATE_CLASS_NAME))) != 0) {
+ BS_AnimationTemplate *AnimationTemplatePtr = BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(AnimationTemplateHandle);
if (!AnimationTemplatePtr)
luaL_error(L, "The animation template with the handle %d does no longer exist.", AnimationTemplateHandle);
return AnimationTemplatePtr;
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, idx, "'" ANIMATION_TEMPLATE_CLASS_NAME "' expected");
return 0;
}
@@ -174,20 +160,16 @@ static BS_AnimationTemplate * CheckAnimationTemplate(lua_State * L, int idx = 1)
// -----------------------------------------------------------------------------
-static int NewAnimationTemplate(lua_State * L)
-{
+static int NewAnimationTemplate(lua_State *L) {
unsigned int AnimationTemplateHandle = BS_AnimationTemplate::Create(luaL_checkstring(L, 1));
- BS_AnimationTemplate * AnimationTemplatePtr = BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(AnimationTemplateHandle);
- if (AnimationTemplatePtr && AnimationTemplatePtr->IsValid())
- {
+ BS_AnimationTemplate *AnimationTemplatePtr = BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(AnimationTemplateHandle);
+ if (AnimationTemplatePtr && AnimationTemplatePtr->IsValid()) {
NewUintUserData(L, AnimationTemplateHandle);
//luaL_getmetatable(L, ANIMATION_TEMPLATE_CLASS_NAME);
BS_LuaBindhelper::GetMetatable(L, ANIMATION_TEMPLATE_CLASS_NAME);
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
- }
- else
- {
+ } else {
lua_pushnil(L);
}
@@ -196,85 +178,69 @@ static int NewAnimationTemplate(lua_State * L)
// -----------------------------------------------------------------------------
-static int AT_AddFrame(lua_State * L)
-{
- BS_AnimationTemplate * pAT = CheckAnimationTemplate(L);
+static int AT_AddFrame(lua_State *L) {
+ BS_AnimationTemplate *pAT = CheckAnimationTemplate(L);
pAT->AddFrame(static_cast<int>(luaL_checknumber(L, 2)));
return 0;
}
// -----------------------------------------------------------------------------
-static int AT_SetFrame(lua_State * L)
-{
- BS_AnimationTemplate * pAT = CheckAnimationTemplate(L);
+static int AT_SetFrame(lua_State *L) {
+ BS_AnimationTemplate *pAT = CheckAnimationTemplate(L);
pAT->SetFrame(static_cast<int>(luaL_checknumber(L, 2)), static_cast<int>(luaL_checknumber(L, 3)));
return 0;
}
// -----------------------------------------------------------------------------
-static bool AnimationTypeStringToNumber(const char * TypeString, BS_Animation::ANIMATION_TYPES & Result)
-{
- if (strcmp(TypeString, "jojo") == 0)
- {
+static bool AnimationTypeStringToNumber(const char *TypeString, BS_Animation::ANIMATION_TYPES &Result) {
+ if (strcmp(TypeString, "jojo") == 0) {
Result = BS_Animation::AT_JOJO;
return true;
- }
- else if (strcmp(TypeString, "loop") == 0)
- {
+ } else if (strcmp(TypeString, "loop") == 0) {
Result = BS_Animation::AT_LOOP;
return true;
- }
- else if (strcmp(TypeString, "oneshot") == 0)
- {
+ } else if (strcmp(TypeString, "oneshot") == 0) {
Result = BS_Animation::AT_ONESHOT;
return true;
- }
- else
+ } else
return false;
}
// -----------------------------------------------------------------------------
-static int AT_SetAnimationType(lua_State * L)
-{
- BS_AnimationTemplate * pAT = CheckAnimationTemplate(L);
+static int AT_SetAnimationType(lua_State *L) {
+ BS_AnimationTemplate *pAT = CheckAnimationTemplate(L);
BS_Animation::ANIMATION_TYPES AnimationType;
- if (AnimationTypeStringToNumber(luaL_checkstring(L, 2), AnimationType))
- {
+ if (AnimationTypeStringToNumber(luaL_checkstring(L, 2), AnimationType)) {
pAT->SetAnimationType(AnimationType);
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 2, "Invalid animation type");
}
-
+
return 0;
}
// -----------------------------------------------------------------------------
-static int AT_SetFPS(lua_State * L)
-{
- BS_AnimationTemplate * pAT = CheckAnimationTemplate(L);
+static int AT_SetFPS(lua_State *L) {
+ BS_AnimationTemplate *pAT = CheckAnimationTemplate(L);
pAT->SetFPS(static_cast<int>(luaL_checknumber(L, 2)));
return 0;
}
// -----------------------------------------------------------------------------
-static int AT_Finalize(lua_State * L)
-{
- BS_AnimationTemplate * pAT = CheckAnimationTemplate(L);
+static int AT_Finalize(lua_State *L) {
+ BS_AnimationTemplate *pAT = CheckAnimationTemplate(L);
delete pAT;
return 0;
}
// -----------------------------------------------------------------------------
-static const luaL_reg ANIMATION_TEMPLATE_METHODS[] =
-{
+static const luaL_reg ANIMATION_TEMPLATE_METHODS[] = {
{"AddFrame", AT_AddFrame},
{"SetFrame", AT_SetFrame},
{"SetAnimationType", AT_SetAnimationType},
@@ -285,47 +251,44 @@ static const luaL_reg ANIMATION_TEMPLATE_METHODS[] =
// -----------------------------------------------------------------------------
-static BS_GraphicEngine * GetGE()
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static BS_GraphicEngine *GetGE() {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_GraphicEngine * pGE = static_cast<BS_GraphicEngine *>(pKernel->GetService("gfx"));
+ BS_GraphicEngine *pGE = static_cast<BS_GraphicEngine *>(pKernel->GetService("gfx"));
BS_ASSERT(pGE);
return pGE;
}
// -----------------------------------------------------------------------------
-static int Init(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
-
- switch (lua_gettop(L))
- {
- case 0:
- lua_pushbooleancpp(L, pGE->Init());
- break;
- case 1:
- lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1))));
- break;
- case 2:
- lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L,1)), static_cast<int>(luaL_checknumber(L, 2))));
- break;
- case 3:
- lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L,1)), static_cast<int>(luaL_checknumber(L, 2)),
- static_cast<int>(luaL_checknumber(L, 3))));
- break;
- case 4:
- lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L,1)), static_cast<int>(luaL_checknumber(L, 2)),
- static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4))));
- break;
- default:
- lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L,1)), static_cast<int>(luaL_checknumber(L, 2)),
- static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4)),
- lua_tobooleancpp(L, 5)));
+static int Init(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
+
+ switch (lua_gettop(L)) {
+ case 0:
+ lua_pushbooleancpp(L, pGE->Init());
+ break;
+ case 1:
+ lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1))));
+ break;
+ case 2:
+ lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2))));
+ break;
+ case 3:
+ lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
+ static_cast<int>(luaL_checknumber(L, 3))));
+ break;
+ case 4:
+ lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
+ static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4))));
+ break;
+ default:
+ lua_pushbooleancpp(L, pGE->Init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
+ static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4)),
+ lua_tobooleancpp(L, 5)));
}
-
+
#ifdef DEBUG
int __startStackDepth = lua_gettop(L);
#endif
@@ -345,7 +308,7 @@ static int Init(lua_State * L)
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
- lua_pushstring(L, "MainPanel");
+ lua_pushstring(L, "MainPanel");
lua_insert(L, -2);
lua_settable(L, -3);
@@ -360,9 +323,8 @@ static int Init(lua_State * L)
// -----------------------------------------------------------------------------
-static int StartFrame(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int StartFrame(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
if (lua_gettop(L) == 0)
lua_pushbooleancpp(L, pGE->StartFrame());
@@ -374,9 +336,8 @@ static int StartFrame(lua_State * L)
// -----------------------------------------------------------------------------
-static int EndFrame(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int EndFrame(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushbooleancpp(L, pGE->EndFrame());
@@ -385,9 +346,8 @@ static int EndFrame(lua_State * L)
// -----------------------------------------------------------------------------
-static int DrawDebugLine(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int DrawDebugLine(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
BS_Vertex Start;
BS_Vertex End;
@@ -400,9 +360,8 @@ static int DrawDebugLine(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetDisplayWidth(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetDisplayWidth(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetDisplayWidth());
@@ -411,9 +370,8 @@ static int GetDisplayWidth(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetDisplayHeight(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetDisplayHeight(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetDisplayHeight());
@@ -422,9 +380,8 @@ static int GetDisplayHeight(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetBitDepth(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetBitDepth(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetBitDepth());
@@ -433,9 +390,8 @@ static int GetBitDepth(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetVsync(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int SetVsync(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
pGE->SetVsync(lua_tobooleancpp(L, 1));
@@ -444,9 +400,8 @@ static int SetVsync(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsVsync(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int IsVsync(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushbooleancpp(L, pGE->GetVsync());
@@ -455,9 +410,8 @@ static int IsVsync(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsWindowed(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int IsWindowed(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushbooleancpp(L, pGE->IsWindowed());
@@ -466,9 +420,8 @@ static int IsWindowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetFPSCount(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetFPSCount(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetFPSCount());
@@ -477,9 +430,8 @@ static int GetFPSCount(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetLastFrameDuration(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetLastFrameDuration(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetLastFrameDuration());
@@ -488,27 +440,24 @@ static int GetLastFrameDuration(lua_State * L)
// -----------------------------------------------------------------------------
-static int StopMainTimer(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int StopMainTimer(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
pGE->StopMainTimer();
return 0;
}
// -----------------------------------------------------------------------------
-static int ResumeMainTimer(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int ResumeMainTimer(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
pGE->ResumeMainTimer();
return 0;
}
// -----------------------------------------------------------------------------
-static int GetSecondaryFrameDuration(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetSecondaryFrameDuration(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, pGE->GetSecondaryFrameDuration());
@@ -517,35 +466,31 @@ static int GetSecondaryFrameDuration(lua_State * L)
// -----------------------------------------------------------------------------
-static int SaveScreenshot(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int SaveScreenshot(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushbooleancpp(L, pGE->SaveScreenshot(luaL_checkstring(L, 1)));
return 1;
}
// -----------------------------------------------------------------------------
-static int SaveThumbnailScreenshot(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int SaveThumbnailScreenshot(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushbooleancpp(L, pGE->SaveThumbnailScreenshot(luaL_checkstring(L, 1)));
return 1;
}
// -----------------------------------------------------------------------------
-static int GetRepaintedPixels(lua_State * L)
-{
- BS_GraphicEngine * pGE = GetGE();
+static int GetRepaintedPixels(lua_State *L) {
+ BS_GraphicEngine *pGE = GetGE();
lua_pushnumber(L, static_cast<lua_Number>(pGE->GetRepaintedPixels()));
return 1;
}
// -----------------------------------------------------------------------------
-static const luaL_reg GFX_FUNCTIONS[] =
-{
+static const luaL_reg GFX_FUNCTIONS[] = {
{"Init", Init},
{"StartFrame", StartFrame},
{"EndFrame", EndFrame},
@@ -570,26 +515,21 @@ static const luaL_reg GFX_FUNCTIONS[] =
// -----------------------------------------------------------------------------
-static BS_RenderObjectPtr<BS_RenderObject> CheckRenderObject(lua_State * L, bool ErrorIfRemoved = true)
-{
+static BS_RenderObjectPtr<BS_RenderObject> CheckRenderObject(lua_State *L, bool ErrorIfRemoved = true) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable einer Klasse haben, die von Gfx.RenderObject "erbt".
- unsigned int * UserDataPtr;
+ unsigned int *UserDataPtr;
if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, BITMAP_CLASS_NAME)) != 0 ||
- (UserDataPtr = (unsigned int *) my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0 ||
- (UserDataPtr = (unsigned int *) my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0 ||
- (UserDataPtr = (unsigned int *) my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0)
- {
+ (UserDataPtr = (unsigned int *) my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0 ||
+ (UserDataPtr = (unsigned int *) my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0 ||
+ (UserDataPtr = (unsigned int *) my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr(* UserDataPtr);
if (ROPtr.IsValid())
return ROPtr;
- else
- {
+ else {
if (ErrorIfRemoved)
luaL_error(L, "The renderobject with the handle %d does no longer exist.", * UserDataPtr);
}
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 1, "'" RENDEROBJECT_CLASS_NAME "' expected");
}
@@ -598,8 +538,7 @@ static BS_RenderObjectPtr<BS_RenderObject> CheckRenderObject(lua_State * L, bool
// -----------------------------------------------------------------------------
-static int RO_SetPos(lua_State * L)
-{
+static int RO_SetPos(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
BS_Vertex Pos;
@@ -610,8 +549,7 @@ static int RO_SetPos(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_SetX(lua_State * L)
-{
+static int RO_SetX(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr->SetX(static_cast<int>(luaL_checknumber(L, 2)));
@@ -620,8 +558,7 @@ static int RO_SetX(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_SetY(lua_State * L)
-{
+static int RO_SetY(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr->SetY(static_cast<int>(luaL_checknumber(L, 2)));
@@ -630,8 +567,7 @@ static int RO_SetY(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_SetZ(lua_State * L)
-{
+static int RO_SetZ(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr->SetZ(static_cast<int>(luaL_checknumber(L, 2)));
@@ -640,8 +576,7 @@ static int RO_SetZ(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_SetVisible(lua_State * L)
-{
+static int RO_SetVisible(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr->SetVisible(lua_tobooleancpp(L, 2));
@@ -650,8 +585,7 @@ static int RO_SetVisible(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_GetX(lua_State * L)
-{
+static int RO_GetX(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetX());
@@ -661,8 +595,7 @@ static int RO_GetX(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_GetY(lua_State * L)
-{
+static int RO_GetY(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetY());
@@ -672,8 +605,7 @@ static int RO_GetY(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_GetZ(lua_State * L)
-{
+static int RO_GetZ(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetZ());
@@ -683,8 +615,7 @@ static int RO_GetZ(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_GetAbsoluteX(lua_State * L)
-{
+static int RO_GetAbsoluteX(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetAbsoluteX());
@@ -694,66 +625,59 @@ static int RO_GetAbsoluteX(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_GetAbsoluteY(lua_State * L)
-{
+static int RO_GetAbsoluteY(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetAbsoluteY());
-
+
return 1;
}
// -----------------------------------------------------------------------------
-static int RO_GetWidth(lua_State * L)
-{
+static int RO_GetWidth(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetWidth());
-
+
return 1;
}
// -----------------------------------------------------------------------------
-static int RO_GetHeight(lua_State * L)
-{
+static int RO_GetHeight(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushnumber(L, ROPtr->GetHeight());
-
+
return 1;
}
// -----------------------------------------------------------------------------
-static int RO_IsVisible(lua_State * L)
-{
+static int RO_IsVisible(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
lua_pushbooleancpp(L, ROPtr->IsVisible());
-
+
return 1;
}
// -----------------------------------------------------------------------------
-static int RO_AddPanel(lua_State * L)
-{
+static int RO_AddPanel(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
BS_RenderObjectPtr<BS_Panel> PanelPtr = ROPtr->AddPanel(static_cast<int>(luaL_checknumber(L, 2)),
- static_cast<int>(luaL_checknumber(L, 3)),
- BS_GraphicEngine::LuaColorToARGBColor(L, 4));
- if (PanelPtr.IsValid())
- {
+ static_cast<int>(luaL_checknumber(L, 3)),
+ BS_GraphicEngine::LuaColorToARGBColor(L, 4));
+ if (PanelPtr.IsValid()) {
NewUintUserData(L, PanelPtr->GetHandle());
// luaL_getmetatable(L, PANEL_CLASS_NAME);
BS_LuaBindhelper::GetMetatable(L, PANEL_CLASS_NAME);
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
- }
- else
+ } else
lua_pushnil(L);
return 1;
@@ -761,20 +685,17 @@ static int RO_AddPanel(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_AddBitmap(lua_State * L)
-{
+static int RO_AddBitmap(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
BS_RenderObjectPtr<BS_Bitmap> BitmaPtr = ROPtr->AddBitmap(luaL_checkstring(L, 2));
- if (BitmaPtr.IsValid())
- {
+ if (BitmaPtr.IsValid()) {
NewUintUserData(L, BitmaPtr->GetHandle());
// luaL_getmetatable(L, BITMAP_CLASS_NAME);
BS_LuaBindhelper::GetMetatable(L, BITMAP_CLASS_NAME);
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
- }
- else
+ } else
lua_pushnil(L);
return 1;
@@ -782,8 +703,7 @@ static int RO_AddBitmap(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_AddText(lua_State * L)
-{
+static int RO_AddText(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
@@ -791,15 +711,13 @@ static int RO_AddText(lua_State * L)
if (lua_gettop(L) >= 3) TextPtr = ROPtr->AddText(luaL_checkstring(L, 2), luaL_checkstring(L, 3));
else TextPtr = ROPtr->AddText(luaL_checkstring(L, 2));
- if (TextPtr.IsValid())
- {
+ if (TextPtr.IsValid()) {
NewUintUserData(L, TextPtr->GetHandle());
// luaL_getmetatable(L, TEXT_CLASS_NAME);
BS_LuaBindhelper::GetMetatable(L, TEXT_CLASS_NAME);
BS_ASSERT(!lua_isnil(L, -1));
lua_setmetatable(L, -2);
- }
- else
+ } else
lua_pushnil(L);
return 1;
@@ -807,8 +725,7 @@ static int RO_AddText(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_AddAnimation(lua_State * L)
-{
+static int RO_AddAnimation(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
@@ -818,8 +735,7 @@ static int RO_AddAnimation(lua_State * L)
else
AnimationPtr = ROPtr->AddAnimation(luaL_checkstring(L, 2));
- if (AnimationPtr.IsValid())
- {
+ if (AnimationPtr.IsValid()) {
NewUintUserData(L, AnimationPtr->GetHandle());
// luaL_getmetatable(L, ANIMATION_CLASS_NAME);
BS_LuaBindhelper::GetMetatable(L, ANIMATION_CLASS_NAME);
@@ -830,8 +746,7 @@ static int RO_AddAnimation(lua_State * L)
AnimationPtr->RegisterDeleteCallback(AnimationDeleteCallback, AnimationPtr->GetHandle());
AnimationPtr->RegisterLoopPointCallback(AnimationLoopPointCallback, AnimationPtr->GetHandle());
AnimationPtr->RegisterActionCallback(AnimationActionCallback, AnimationPtr->GetHandle());
- }
- else
+ } else
lua_pushnil(L);
return 1;
@@ -839,8 +754,7 @@ static int RO_AddAnimation(lua_State * L)
// -----------------------------------------------------------------------------
-static int RO_Remove(lua_State * L)
-{
+static int RO_Remove(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
ROPtr.Erase();
return 0;
@@ -848,8 +762,7 @@ static int RO_Remove(lua_State * L)
// -----------------------------------------------------------------------------
-static const luaL_reg RENDEROBJECT_METHODS[] =
-{
+static const luaL_reg RENDEROBJECT_METHODS[] = {
{"AddAnimation", RO_AddAnimation},
{"AddText", RO_AddText},
{"AddBitmap", RO_AddBitmap},
@@ -872,22 +785,16 @@ static const luaL_reg RENDEROBJECT_METHODS[] =
// -----------------------------------------------------------------------------
-static BS_RenderObjectPtr<BS_Panel> CheckPanel(lua_State * L)
-{
+static BS_RenderObjectPtr<BS_Panel> CheckPanel(lua_State *L) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Panel
- unsigned int * UserDataPtr;
- if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0)
- {
+ unsigned int *UserDataPtr;
+ if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr(*UserDataPtr);
- if (ROPtr.IsValid())
- {
+ if (ROPtr.IsValid()) {
return ROPtr->ToPanel();
- }
- else
+ } else
luaL_error(L, "The panel with the handle %d does no longer exist.", *UserDataPtr);
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 1, "'" PANEL_CLASS_NAME "' expected");
}
@@ -896,19 +803,17 @@ static BS_RenderObjectPtr<BS_Panel> CheckPanel(lua_State * L)
// -----------------------------------------------------------------------------
-static int P_GetColor(lua_State * L)
-{
+static int P_GetColor(lua_State *L) {
BS_RenderObjectPtr<BS_Panel> PanelPtr = CheckPanel(L);
BS_ASSERT(PanelPtr.IsValid());
BS_GraphicEngine::ARGBColorToLuaColor(L, PanelPtr->GetColor());
-
+
return 1;
}
// -----------------------------------------------------------------------------
-static int P_SetColor(lua_State * L)
-{
+static int P_SetColor(lua_State *L) {
BS_RenderObjectPtr<BS_Panel> PanelPtr = CheckPanel(L);
BS_ASSERT(PanelPtr.IsValid());
PanelPtr->SetColor(BS_GraphicEngine::LuaColorToARGBColor(L, 2));
@@ -917,8 +822,7 @@ static int P_SetColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int P_Remove(lua_State * L)
-{
+static int P_Remove(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr.Erase();
@@ -927,8 +831,7 @@ static int P_Remove(lua_State * L)
// -----------------------------------------------------------------------------
-static const luaL_reg PANEL_METHODS[] =
-{
+static const luaL_reg PANEL_METHODS[] = {
{"GetColor", P_GetColor},
{"SetColor", P_SetColor},
{"Remove", P_Remove},
@@ -937,22 +840,16 @@ static const luaL_reg PANEL_METHODS[] =
// -----------------------------------------------------------------------------
-static BS_RenderObjectPtr<BS_Bitmap> CheckBitmap(lua_State * L)
-{
+static BS_RenderObjectPtr<BS_Bitmap> CheckBitmap(lua_State *L) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Bitmap
- unsigned int * UserDataPtr;
- if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, BITMAP_CLASS_NAME)) != 0)
- {
+ unsigned int *UserDataPtr;
+ if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, BITMAP_CLASS_NAME)) != 0) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr(*UserDataPtr);
- if (ROPtr.IsValid())
- {
+ if (ROPtr.IsValid()) {
return ROPtr->ToBitmap();
- }
- else
+ } else
luaL_error(L, "The bitmap with the handle %d does no longer exist.", *UserDataPtr);
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 1, "'" BITMAP_CLASS_NAME "' expected");
}
@@ -961,8 +858,7 @@ static BS_RenderObjectPtr<BS_Bitmap> CheckBitmap(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetAlpha(lua_State * L)
-{
+static int B_SetAlpha(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetAlpha(static_cast<unsigned int>(luaL_checknumber(L, 2)));
@@ -971,8 +867,7 @@ static int B_SetAlpha(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetTintColor(lua_State * L)
-{
+static int B_SetTintColor(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetModulationColor(BS_GraphicEngine::LuaColorToARGBColor(L, 2));
@@ -981,8 +876,7 @@ static int B_SetTintColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetScaleFactor(lua_State * L)
-{
+static int B_SetScaleFactor(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetScaleFactor(static_cast<float>(luaL_checknumber(L, 2)));
@@ -991,8 +885,7 @@ static int B_SetScaleFactor(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetScaleFactorX(lua_State * L)
-{
+static int B_SetScaleFactorX(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetScaleFactorX(static_cast<float>(luaL_checknumber(L, 2)));
@@ -1001,8 +894,7 @@ static int B_SetScaleFactorX(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetScaleFactorY(lua_State * L)
-{
+static int B_SetScaleFactorY(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetScaleFactorY(static_cast<float>(luaL_checknumber(L, 2)));
@@ -1011,8 +903,7 @@ static int B_SetScaleFactorY(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetFlipH(lua_State * L)
-{
+static int B_SetFlipH(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetFlipH(lua_tobooleancpp(L, 2));
@@ -1021,8 +912,7 @@ static int B_SetFlipH(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_SetFlipV(lua_State * L)
-{
+static int B_SetFlipV(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BitmapPtr->SetFlipV(lua_tobooleancpp(L, 2));
@@ -1031,8 +921,7 @@ static int B_SetFlipV(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_GetAlpha(lua_State * L)
-{
+static int B_GetAlpha(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushnumber(L, BitmapPtr->GetAlpha());
@@ -1041,8 +930,7 @@ static int B_GetAlpha(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_GetTintColor(lua_State * L)
-{
+static int B_GetTintColor(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BS_GraphicEngine::ARGBColorToLuaColor(L, BitmapPtr->GetModulationColor());
@@ -1051,8 +939,7 @@ static int B_GetTintColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_GetScaleFactorX(lua_State * L)
-{
+static int B_GetScaleFactorX(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushnumber(L, BitmapPtr->GetScaleFactorX());
@@ -1061,8 +948,7 @@ static int B_GetScaleFactorX(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_GetScaleFactorY(lua_State * L)
-{
+static int B_GetScaleFactorY(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushnumber(L, BitmapPtr->GetScaleFactorY());
@@ -1071,8 +957,7 @@ static int B_GetScaleFactorY(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_IsFlipH(lua_State * L)
-{
+static int B_IsFlipH(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushbooleancpp(L, BitmapPtr->IsFlipH());
@@ -1081,8 +966,7 @@ static int B_IsFlipH(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_IsFlipV(lua_State * L)
-{
+static int B_IsFlipV(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushbooleancpp(L, BitmapPtr->IsFlipV());
@@ -1091,8 +975,7 @@ static int B_IsFlipV(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_GetPixel(lua_State * L)
-{
+static int B_GetPixel(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
BS_Vertex Pos;
@@ -1103,8 +986,7 @@ static int B_GetPixel(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_IsScalingAllowed(lua_State * L)
-{
+static int B_IsScalingAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushbooleancpp(L, BitmapPtr->IsScalingAllowed());
@@ -1113,8 +995,7 @@ static int B_IsScalingAllowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_IsAlphaAllowed(lua_State * L)
-{
+static int B_IsAlphaAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushbooleancpp(L, BitmapPtr->IsAlphaAllowed());
@@ -1123,8 +1004,7 @@ static int B_IsAlphaAllowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int B_IsTintingAllowed(lua_State * L)
-{
+static int B_IsTintingAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr = CheckBitmap(L);
BS_ASSERT(BitmapPtr.IsValid());
lua_pushbooleancpp(L, BitmapPtr->IsColorModulationAllowed());
@@ -1132,8 +1012,7 @@ static int B_IsTintingAllowed(lua_State * L)
}
// -----------------------------------------------------------------------------
-static int B_Remove(lua_State * L)
-{
+static int B_Remove(lua_State *L) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr = CheckRenderObject(L);
BS_ASSERT(ROPtr.IsValid());
ROPtr.Erase();
@@ -1142,8 +1021,7 @@ static int B_Remove(lua_State * L)
// -----------------------------------------------------------------------------
-static const luaL_reg BITMAP_METHODS[] =
-{
+static const luaL_reg BITMAP_METHODS[] = {
{"SetAlpha", B_SetAlpha},
{"SetTintColor", B_SetTintColor},
{"SetScaleFactor", B_SetScaleFactor},
@@ -1167,22 +1045,17 @@ static const luaL_reg BITMAP_METHODS[] =
// -----------------------------------------------------------------------------
-static BS_RenderObjectPtr<BS_Animation> CheckAnimation(lua_State * L)
-{
+static BS_RenderObjectPtr<BS_Animation> CheckAnimation(lua_State *L) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Animation
- unsigned int * UserDataPtr;
- if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0)
- {
+ unsigned int *UserDataPtr;
+ if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr(*UserDataPtr);
if (ROPtr.IsValid())
return ROPtr->ToAnimation();
- else
- {
+ else {
luaL_error(L, "The animation with the handle %d does no longer exist.", *UserDataPtr);
}
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 1, "'" ANIMATION_CLASS_NAME "' expected");
}
@@ -1191,8 +1064,7 @@ static BS_RenderObjectPtr<BS_Animation> CheckAnimation(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_Play(lua_State * L)
-{
+static int A_Play(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->Play();
@@ -1201,8 +1073,7 @@ static int A_Play(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_Pause(lua_State * L)
-{
+static int A_Pause(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->Pause();
@@ -1211,8 +1082,7 @@ static int A_Pause(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_Stop(lua_State * L)
-{
+static int A_Stop(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->Stop();
@@ -1221,8 +1091,7 @@ static int A_Stop(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_SetFrame(lua_State * L)
-{
+static int A_SetFrame(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetFrame(static_cast<unsigned int>(luaL_checknumber(L, 2)));
@@ -1231,8 +1100,7 @@ static int A_SetFrame(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_SetAlpha(lua_State * L)
-{
+static int A_SetAlpha(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetAlpha(static_cast<int>(luaL_checknumber(L, 2)));
@@ -1240,8 +1108,7 @@ static int A_SetAlpha(lua_State * L)
}
// -----------------------------------------------------------------------------
-static int A_SetTintColor(lua_State * L)
-{
+static int A_SetTintColor(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetModulationColor(BS_GraphicEngine::LuaColorToARGBColor(L, 2));
@@ -1250,8 +1117,7 @@ static int A_SetTintColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_SetScaleFactor(lua_State * L)
-{
+static int A_SetScaleFactor(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetScaleFactor(static_cast<float>(luaL_checknumber(L, 2)));
@@ -1260,8 +1126,7 @@ static int A_SetScaleFactor(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_SetScaleFactorX(lua_State * L)
-{
+static int A_SetScaleFactorX(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetScaleFactorX(static_cast<float>(luaL_checknumber(L, 2)));
@@ -1270,8 +1135,7 @@ static int A_SetScaleFactorX(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_SetScaleFactorY(lua_State * L)
-{
+static int A_SetScaleFactorY(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr->SetScaleFactorY(static_cast<float>(luaL_checknumber(L, 2)));
@@ -1280,8 +1144,7 @@ static int A_SetScaleFactorY(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetScaleFactorX(lua_State * L)
-{
+static int A_GetScaleFactorX(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushnumber(L, AnimationPtr->GetScaleFactorX());
@@ -1290,8 +1153,7 @@ static int A_GetScaleFactorX(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetScaleFactorY(lua_State * L)
-{
+static int A_GetScaleFactorY(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushnumber(L, AnimationPtr->GetScaleFactorY());
@@ -1300,31 +1162,28 @@ static int A_GetScaleFactorY(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetAnimationType(lua_State * L)
-{
+static int A_GetAnimationType(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
- switch (AnimationPtr->GetAnimationType())
- {
- case BS_Animation::AT_JOJO:
- lua_pushstring(L, "jojo");
- break;
- case BS_Animation::AT_LOOP:
- lua_pushstring(L, "loop");
- break;
- case BS_Animation::AT_ONESHOT:
- lua_pushstring(L, "oneshot");
- break;
- default:
- BS_ASSERT(false);
+ switch (AnimationPtr->GetAnimationType()) {
+ case BS_Animation::AT_JOJO:
+ lua_pushstring(L, "jojo");
+ break;
+ case BS_Animation::AT_LOOP:
+ lua_pushstring(L, "loop");
+ break;
+ case BS_Animation::AT_ONESHOT:
+ lua_pushstring(L, "oneshot");
+ break;
+ default:
+ BS_ASSERT(false);
}
return 1;
}
// -----------------------------------------------------------------------------
-static int A_GetFPS(lua_State * L)
-{
+static int A_GetFPS(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushnumber(L, AnimationPtr->GetFPS());
@@ -1334,8 +1193,7 @@ static int A_GetFPS(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetFrameCount(lua_State * L)
-{
+static int A_GetFrameCount(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushnumber(L, AnimationPtr->GetFrameCount());
@@ -1344,8 +1202,7 @@ static int A_GetFrameCount(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_IsScalingAllowed(lua_State * L)
-{
+static int A_IsScalingAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushbooleancpp(L, AnimationPtr->IsScalingAllowed());
@@ -1354,8 +1211,7 @@ static int A_IsScalingAllowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_IsAlphaAllowed(lua_State * L)
-{
+static int A_IsAlphaAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushbooleancpp(L, AnimationPtr->IsAlphaAllowed());
@@ -1364,8 +1220,7 @@ static int A_IsAlphaAllowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_IsTintingAllowed(lua_State * L)
-{
+static int A_IsTintingAllowed(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushbooleancpp(L, AnimationPtr->IsColorModulationAllowed());
@@ -1374,8 +1229,7 @@ static int A_IsTintingAllowed(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetCurrentFrame(lua_State * L)
-{
+static int A_GetCurrentFrame(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushnumber(L, AnimationPtr->GetCurrentFrame());
@@ -1384,8 +1238,7 @@ static int A_GetCurrentFrame(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_GetCurrentAction(lua_State * L)
-{
+static int A_GetCurrentAction(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushstring(L, AnimationPtr->GetCurrentAction().c_str());
@@ -1394,8 +1247,7 @@ static int A_GetCurrentAction(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_IsPlaying(lua_State * L)
-{
+static int A_IsPlaying(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
lua_pushbooleancpp(L, AnimationPtr->IsRunning());
@@ -1404,9 +1256,8 @@ static int A_IsPlaying(lua_State * L)
// -----------------------------------------------------------------------------
-static bool AnimationLoopPointCallback(unsigned int Handle)
-{
- lua_State * L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
+static bool AnimationLoopPointCallback(unsigned int Handle) {
+ lua_State *L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
LoopPointCallbackPtr->InvokeCallbackFunctions(L, Handle);
return true;
@@ -1414,8 +1265,7 @@ static bool AnimationLoopPointCallback(unsigned int Handle)
// -----------------------------------------------------------------------------
-static int A_RegisterLoopPointCallback(lua_State * L)
-{
+static int A_RegisterLoopPointCallback(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
luaL_checktype(L, 2, LUA_TFUNCTION);
@@ -1428,8 +1278,7 @@ static int A_RegisterLoopPointCallback(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_UnregisterLoopPointCallback(lua_State * L)
-{
+static int A_UnregisterLoopPointCallback(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
luaL_checktype(L, 2, LUA_TFUNCTION);
@@ -1442,13 +1291,11 @@ static int A_UnregisterLoopPointCallback(lua_State * L)
// -----------------------------------------------------------------------------
-static bool AnimationActionCallback(unsigned int Handle)
-{
+static bool AnimationActionCallback(unsigned int Handle) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr(Handle);
- if (AnimationPtr.IsValid())
- {
+ if (AnimationPtr.IsValid()) {
ActionCallbackPtr->Action = AnimationPtr->GetCurrentAction();
- lua_State * L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
+ lua_State *L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
ActionCallbackPtr->InvokeCallbackFunctions(L, AnimationPtr->GetHandle());
}
@@ -1457,8 +1304,7 @@ static bool AnimationActionCallback(unsigned int Handle)
// -----------------------------------------------------------------------------
-static int A_RegisterActionCallback(lua_State * L)
-{
+static int A_RegisterActionCallback(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
luaL_checktype(L, 2, LUA_TFUNCTION);
@@ -1471,8 +1317,7 @@ static int A_RegisterActionCallback(lua_State * L)
// -----------------------------------------------------------------------------
-static int A_UnregisterActionCallback(lua_State * L)
-{
+static int A_UnregisterActionCallback(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
luaL_checktype(L, 2, LUA_TFUNCTION);
@@ -1485,9 +1330,8 @@ static int A_UnregisterActionCallback(lua_State * L)
// -----------------------------------------------------------------------------
-static bool AnimationDeleteCallback(unsigned int Handle)
-{
- lua_State * L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
+static bool AnimationDeleteCallback(unsigned int Handle) {
+ lua_State *L = static_cast<lua_State *>(BS_Kernel::GetInstance()->GetScript()->GetScriptObject());
LoopPointCallbackPtr->RemoveAllObjectCallbacks(L, Handle);
return true;
@@ -1495,8 +1339,7 @@ static bool AnimationDeleteCallback(unsigned int Handle)
// -----------------------------------------------------------------------------
-static int A_Remove(lua_State * L)
-{
+static int A_Remove(lua_State *L) {
BS_RenderObjectPtr<BS_Animation> AnimationPtr = CheckAnimation(L);
BS_ASSERT(AnimationPtr.IsValid());
AnimationPtr.Erase();
@@ -1505,8 +1348,7 @@ static int A_Remove(lua_State * L)
// -----------------------------------------------------------------------------
-static const luaL_reg ANIMATION_METHODS[] =
-{
+static const luaL_reg ANIMATION_METHODS[] = {
{"Play", A_Play},
{"Pause", A_Pause},
{"Stop", A_Stop},
@@ -1537,20 +1379,16 @@ static const luaL_reg ANIMATION_METHODS[] =
// -----------------------------------------------------------------------------
-static BS_RenderObjectPtr<BS_Text> CheckText(lua_State * L)
-{
+static BS_RenderObjectPtr<BS_Text> CheckText(lua_State *L) {
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Text
- unsigned int * UserDataPtr;
- if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0)
- {
+ unsigned int *UserDataPtr;
+ if ((UserDataPtr = (unsigned int *) my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0) {
BS_RenderObjectPtr<BS_RenderObject> ROPtr(*UserDataPtr);
if (ROPtr.IsValid())
return ROPtr->ToText();
else
luaL_error(L, "The text with the handle %d does no longer exist.", *UserDataPtr);
- }
- else
- {
+ } else {
luaL_argcheck(L, 0, 1, "'" TEXT_CLASS_NAME "' expected");
}
@@ -1559,8 +1397,7 @@ static BS_RenderObjectPtr<BS_Text> CheckText(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetFont(lua_State * L)
-{
+static int T_SetFont(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetFont(luaL_checkstring(L, 2));
@@ -1569,8 +1406,7 @@ static int T_SetFont(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetText(lua_State * L)
-{
+static int T_SetText(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetText(luaL_checkstring(L, 2));
@@ -1579,8 +1415,7 @@ static int T_SetText(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetAlpha(lua_State * L)
-{
+static int T_SetAlpha(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetAlpha(static_cast<int>(luaL_checknumber(L, 2)));
@@ -1589,8 +1424,7 @@ static int T_SetAlpha(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetColor(lua_State * L)
-{
+static int T_SetColor(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetColor(BS_GraphicEngine::LuaColorToARGBColor(L, 2));
@@ -1599,8 +1433,7 @@ static int T_SetColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetAutoWrap(lua_State * L)
-{
+static int T_SetAutoWrap(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetAutoWrap(lua_tobooleancpp(L, 2));
@@ -1609,8 +1442,7 @@ static int T_SetAutoWrap(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_SetAutoWrapThreshold(lua_State * L)
-{
+static int T_SetAutoWrapThreshold(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr->SetAutoWrapThreshold(static_cast<unsigned int>(luaL_checknumber(L, 2)));
@@ -1619,8 +1451,7 @@ static int T_SetAutoWrapThreshold(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_GetText(lua_State * L)
-{
+static int T_GetText(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushstring(L, TextPtr->GetText().c_str());
@@ -1629,8 +1460,7 @@ static int T_GetText(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_GetFont(lua_State * L)
-{
+static int T_GetFont(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushstring(L, TextPtr->GetFont().c_str());
@@ -1639,8 +1469,7 @@ static int T_GetFont(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_GetAlpha(lua_State * L)
-{
+static int T_GetAlpha(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushnumber(L, TextPtr->GetAlpha());
@@ -1649,8 +1478,7 @@ static int T_GetAlpha(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_GetColor(lua_State * L)
-{
+static int T_GetColor(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushnumber(L, TextPtr->GetColor());
@@ -1659,8 +1487,7 @@ static int T_GetColor(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_IsAutoWrap(lua_State * L)
-{
+static int T_IsAutoWrap(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushbooleancpp(L, TextPtr->IsAutoWrapActive());
@@ -1669,8 +1496,7 @@ static int T_IsAutoWrap(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_GetAutoWrapThreshold(lua_State * L)
-{
+static int T_GetAutoWrapThreshold(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
lua_pushnumber(L, TextPtr->GetAutoWrapThreshold());
@@ -1679,8 +1505,7 @@ static int T_GetAutoWrapThreshold(lua_State * L)
// -----------------------------------------------------------------------------
-static int T_Remove(lua_State * L)
-{
+static int T_Remove(lua_State *L) {
BS_RenderObjectPtr<BS_Text> TextPtr = CheckText(L);
BS_ASSERT(TextPtr.IsValid());
TextPtr.Erase();
@@ -1689,8 +1514,7 @@ static int T_Remove(lua_State * L)
// -----------------------------------------------------------------------------
-static const luaL_reg TEXT_METHODS[] =
-{
+static const luaL_reg TEXT_METHODS[] = {
{"SetFont", T_SetFont},
{"SetText", T_SetText},
{"SetAlpha", T_SetAlpha},
@@ -1709,13 +1533,12 @@ static const luaL_reg TEXT_METHODS[] =
// -----------------------------------------------------------------------------
-bool BS_GraphicEngine::RegisterScriptBindings()
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+bool BS_GraphicEngine::RegisterScriptBindings() {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
- lua_State * L = static_cast<lua_State *>(pScript->GetScriptObject());
+ lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
if (!BS_LuaBindhelper::AddMethodsToClass(L, BITMAP_CLASS_NAME, RENDEROBJECT_METHODS)) return false;
diff --git a/engines/sword25/gfx/image/b25sloader.cpp b/engines/sword25/gfx/image/b25sloader.cpp
index ea1e933edd..e45a4cddcb 100644
--- a/engines/sword25/gfx/image/b25sloader.cpp
+++ b/engines/sword25/gfx/image/b25sloader.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,38 +50,33 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
-namespace
-{
- unsigned int FindEmbeddedPNG(const char * FileDataPtr, unsigned int FileSize)
- {
- // Einen Stringstream mit dem Anfang der Datei intialisieren. 512 Byte sollten hierfür genügen.
- istringstream StringStream(string(FileDataPtr, FileDataPtr + min(static_cast<unsigned int>(512), FileSize)));
-
- // Headerinformationen der Spielstandes einlesen.
- string Marker, VersionID;
- unsigned int CompressedGamedataSize, UncompressedGamedataSize;
- StringStream >> Marker >> VersionID >> CompressedGamedataSize >> UncompressedGamedataSize;
- if (!StringStream.good()) return 0;
-
- // Testen, ob wir tatsächlich einen Spielstand haben.
- if (Marker == "BS25SAVEGAME")
- {
- // Offset zum PNG innerhalb des Spielstandes berechnen und zurückgeben.
- return static_cast<unsigned int>(StringStream.tellg()) + CompressedGamedataSize + 1;
- }
-
- return 0;
+namespace {
+unsigned int FindEmbeddedPNG(const char *FileDataPtr, unsigned int FileSize) {
+ // Einen Stringstream mit dem Anfang der Datei intialisieren. 512 Byte sollten hierfür genügen.
+ istringstream StringStream(string(FileDataPtr, FileDataPtr + min(static_cast<unsigned int>(512), FileSize)));
+
+ // Headerinformationen der Spielstandes einlesen.
+ string Marker, VersionID;
+ unsigned int CompressedGamedataSize, UncompressedGamedataSize;
+ StringStream >> Marker >> VersionID >> CompressedGamedataSize >> UncompressedGamedataSize;
+ if (!StringStream.good()) return 0;
+
+ // Testen, ob wir tatsächlich einen Spielstand haben.
+ if (Marker == "BS25SAVEGAME") {
+ // Offset zum PNG innerhalb des Spielstandes berechnen und zurückgeben.
+ return static_cast<unsigned int>(StringStream.tellg()) + CompressedGamedataSize + 1;
}
+
+ return 0;
+}
}
// -----------------------------------------------------------------------------
-bool BS_B25SLoader::IsCorrectImageFormat(const char * FileDataPtr, unsigned int FileSize)
-{
+bool BS_B25SLoader::IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
- if (PNGOffset > 0)
- {
+ if (PNGOffset > 0) {
return BS_PNGLoader::DoIsCorrectImageFormat(FileDataPtr + PNGOffset, FileSize - PNGOffset);
}
@@ -90,13 +85,11 @@ bool BS_B25SLoader::IsCorrectImageFormat(const char * FileDataPtr, unsigned int
// -----------------------------------------------------------------------------
-bool BS_B25SLoader::DecodeImage(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
- int & Width, int & Height, int & Pitch)
-{
+bool BS_B25SLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
+ int &Width, int &Height, int &Pitch) {
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
- if (PNGOffset > 0)
- {
+ if (PNGOffset > 0) {
return BS_PNGLoader::DoDecodeImage(FileDataPtr + PNGOffset, FileSize - PNGOffset, ColorFormat, UncompressedDataPtr, Width, Height, Pitch);
}
@@ -105,12 +98,10 @@ bool BS_B25SLoader::DecodeImage(const char * FileDataPtr, unsigned int FileSize,
// -----------------------------------------------------------------------------
-bool BS_B25SLoader::ImageProperties(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height)
-{
+bool BS_B25SLoader::ImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height) {
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
- if (PNGOffset > 0)
- {
+ if (PNGOffset > 0) {
return BS_PNGLoader::DoImageProperties(FileDataPtr + PNGOffset, FileSize - PNGOffset, ColorFormat, Width, Height);
}
diff --git a/engines/sword25/gfx/image/b25sloader.h b/engines/sword25/gfx/image/b25sloader.h
index be28b646c8..4a2cf3b841 100644
--- a/engines/sword25/gfx/image/b25sloader.h
+++ b/engines/sword25/gfx/image/b25sloader.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,21 +48,19 @@ namespace Sword25 {
// Klassendeklaration
// -----------------------------------------------------------------------------
-class BS_B25SLoader : public BS_ImageLoader
-{
+class BS_B25SLoader : public BS_ImageLoader {
public:
- static BS_ImageLoader * CreateInstance()
- {
- #include "sword25/kernel/memlog_off.h"
+ static BS_ImageLoader *CreateInstance() {
+#include "sword25/kernel/memlog_off.h"
return static_cast<BS_ImageLoader *>(new BS_B25SLoader());
- #include "sword25/kernel/memlog_on.h"
+#include "sword25/kernel/memlog_on.h"
}
protected:
- virtual bool IsCorrectImageFormat(const char * FileDataPtr, unsigned int FileSize);
- virtual bool DecodeImage(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
- int & Width, int & Height, int & Pitch);
- virtual bool ImageProperties(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height);
+ virtual bool IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize);
+ virtual bool DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
+ int &Width, int &Height, int &Pitch);
+ virtual bool ImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height);
};
diff --git a/engines/sword25/gfx/image/image.h b/engines/sword25/gfx/image/image.h
index 2f9d49f695..1489af97b3 100644
--- a/engines/sword25/gfx/image/image.h
+++ b/engines/sword25/gfx/image/image.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,10 +33,10 @@
*/
/*
- BS_Image
- --------
+ BS_Image
+ --------
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_IMAGE_H
@@ -52,17 +52,15 @@
namespace Sword25 {
-class BS_Image
-{
+class BS_Image {
public:
virtual ~BS_Image() {};
// Enums
/**
- @brief Die möglichen Flippingparameter für die Blit-Methode.
+ @brief Die möglichen Flippingparameter für die Blit-Methode.
*/
- enum FLIP_FLAGS
- {
+ enum FLIP_FLAGS {
/// Das Bild wird nicht gespiegelt.
FLIP_NONE = 0,
/// Das Bild wird an der horizontalen Achse gespiegelt.
@@ -74,22 +72,22 @@ public:
/// Das Bild wird an der horizontalen und vertikalen Achse gespiegelt.
FLIP_VH = FLIP_H | FLIP_V
};
-
+
//@{
/** @name Accessor-Methoden */
/**
- @brief Gibt die Breite des Bildes in Pixeln zurück
+ @brief Gibt die Breite des Bildes in Pixeln zurück
*/
virtual int GetWidth() const = 0;
/**
- @brief Gibt die Höhe des Bildes in Pixeln zurück
+ @brief Gibt die Höhe des Bildes in Pixeln zurück
*/
virtual int GetHeight() const = 0;
/**
- @brief Gibt das Farbformat des Bildes zurück
+ @brief Gibt das Farbformat des Bildes zurück
*/
virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const = 0;
@@ -99,83 +97,83 @@ public:
/** @name Render-Methoden */
/**
- @brief Rendert das Bild in den Framebuffer.
- @param pDest ein Pointer auf das Zielbild. In den meisten Fällen ist dies der Framebuffer.
- @param PosX die Position auf der X-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
- Der Standardwert ist 0.
- @param PosY die Position auf der Y-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
- Der Standardwert ist 0.
- @param Flipping gibt an, wie das Bild gespiegelt werden soll.<br>
- Der Standardwert ist BS_Image::FLIP_NONE (keine Spiegelung)
- @param pSrcPartRect Pointer auf ein BS_Rect, welches den Ausschnitt des Quellbildes spezifiziert, der gerendert
- werden soll oder NULL, falls das gesamte Bild gerendert werden soll.<br>
- Dieser Ausschnitt bezieht sich auf das ungespiegelte und unskalierte Bild.<br>
- Der Standardwert ist NULL.
- @param Color ein ARGB Farbwert, der die Parameter für die Farbmodulation und fürs Alphablending festlegt.<br>
- Die Alpha-Komponente der Farbe bestimmt den Alphablending Parameter (0 = keine Deckung, 255 = volle Deckung).<br>
- Die Farbkomponenten geben die Farbe für die Farbmodulation an.<br>
- Der Standardwert is BS_ARGB(255, 255, 255, 255) (volle Deckung, keine Farbmodulation).
- Zum Erzeugen des Farbwertes können die Makros BS_RGB und BS_ARGB benutzt werden.
- @param Width gibt die Ausgabebreite des Bildausschnittes an.
- Falls diese von der Breite des Bildausschnittes abweicht wird
- das Bild entsprechend Skaliert.<br>
- Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
- Der Standardwert ist -1.
- @param Width gibt die Ausgabehöhe des Bildausschnittes an.
- Falls diese von der Höhe des Bildauschnittes abweicht, wird
- das Bild entsprechend Skaliert.<br>
- Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
- Der Standardwert ist -1.
- @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
- @remark Er werden nicht alle Blitting-Operationen von allen BS_Image-Klassen unterstützt.<br>
- Mehr Informationen gibt es in der Klassenbeschreibung von BS_Image und durch folgende Methoden:
- - IsBlitTarget()
- - IsScalingAllowed()
- - IsFillingAllowed()
- - IsAlphaAllowed()
- - IsColorModulationAllowed()
- - IsSetContentAllowed()
+ @brief Rendert das Bild in den Framebuffer.
+ @param pDest ein Pointer auf das Zielbild. In den meisten Fällen ist dies der Framebuffer.
+ @param PosX die Position auf der X-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
+ Der Standardwert ist 0.
+ @param PosY die Position auf der Y-Achse im Zielbild in Pixeln, an der das Bild gerendert werden soll.<br>
+ Der Standardwert ist 0.
+ @param Flipping gibt an, wie das Bild gespiegelt werden soll.<br>
+ Der Standardwert ist BS_Image::FLIP_NONE (keine Spiegelung)
+ @param pSrcPartRect Pointer auf ein BS_Rect, welches den Ausschnitt des Quellbildes spezifiziert, der gerendert
+ werden soll oder NULL, falls das gesamte Bild gerendert werden soll.<br>
+ Dieser Ausschnitt bezieht sich auf das ungespiegelte und unskalierte Bild.<br>
+ Der Standardwert ist NULL.
+ @param Color ein ARGB Farbwert, der die Parameter für die Farbmodulation und fürs Alphablending festlegt.<br>
+ Die Alpha-Komponente der Farbe bestimmt den Alphablending Parameter (0 = keine Deckung, 255 = volle Deckung).<br>
+ Die Farbkomponenten geben die Farbe für die Farbmodulation an.<br>
+ Der Standardwert is BS_ARGB(255, 255, 255, 255) (volle Deckung, keine Farbmodulation).
+ Zum Erzeugen des Farbwertes können die Makros BS_RGB und BS_ARGB benutzt werden.
+ @param Width gibt die Ausgabebreite des Bildausschnittes an.
+ Falls diese von der Breite des Bildausschnittes abweicht wird
+ das Bild entsprechend Skaliert.<br>
+ Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
+ Der Standardwert ist -1.
+ @param Width gibt die Ausgabehöhe des Bildausschnittes an.
+ Falls diese von der Höhe des Bildauschnittes abweicht, wird
+ das Bild entsprechend Skaliert.<br>
+ Der Wert -1 gibt an, dass das Bild nicht Skaliert werden soll.<br>
+ Der Standardwert ist -1.
+ @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
+ @remark Er werden nicht alle Blitting-Operationen von allen BS_Image-Klassen unterstützt.<br>
+ Mehr Informationen gibt es in der Klassenbeschreibung von BS_Image und durch folgende Methoden:
+ - IsBlitTarget()
+ - IsScalingAllowed()
+ - IsFillingAllowed()
+ - IsAlphaAllowed()
+ - IsColorModulationAllowed()
+ - IsSetContentAllowed()
*/
- virtual bool Blit(int PosX = 0, int PosY = 0,
- int Flipping = FLIP_NONE,
- BS_Rect* pPartRect = NULL,
- unsigned int Color = BS_ARGB(255, 255, 255, 255),
- int Width = -1, int Height = -1) = 0;
+ virtual bool Blit(int PosX = 0, int PosY = 0,
+ int Flipping = FLIP_NONE,
+ BS_Rect *pPartRect = NULL,
+ unsigned int Color = BS_ARGB(255, 255, 255, 255),
+ int Width = -1, int Height = -1) = 0;
/**
- @brief Füllt einen Rechteckigen Bereich des Bildes mit einer Farbe.
- @param pFillRect Pointer auf ein BS_Rect, welches den Ausschnitt des Bildes spezifiziert, der gefüllt
- werden soll oder NULL, falls das gesamte Bild gefüllt werden soll.<br>
- Der Standardwert ist NULL.
- @param Color der 32 Bit Farbwert mit dem der Bildbereich gefüllt werden soll.
- @remark Es ist möglich über die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem Alphawert ungleich
- 255 angibt.
- @remark Unabhängig vom Farbformat des Bildes muss ein 32 Bit Farbwert angegeben werden. Zur Erzeugung, können die Makros
- BS_RGB und BS_ARGB benutzt werden.
- @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
+ @brief Füllt einen Rechteckigen Bereich des Bildes mit einer Farbe.
+ @param pFillRect Pointer auf ein BS_Rect, welches den Ausschnitt des Bildes spezifiziert, der gefüllt
+ werden soll oder NULL, falls das gesamte Bild gefüllt werden soll.<br>
+ Der Standardwert ist NULL.
+ @param Color der 32 Bit Farbwert mit dem der Bildbereich gefüllt werden soll.
+ @remark Es ist möglich über die Methode transparente Rechtecke darzustellen, indem man eine Farbe mit einem Alphawert ungleich
+ 255 angibt.
+ @remark Unabhängig vom Farbformat des Bildes muss ein 32 Bit Farbwert angegeben werden. Zur Erzeugung, können die Makros
+ BS_RGB und BS_ARGB benutzt werden.
+ @remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
*/
- virtual bool Fill(const BS_Rect* pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
+ virtual bool Fill(const BS_Rect *pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0)) = 0;
/**
- @brief Füllt den Inhalt des Bildes mit Pixeldaten.
- @param Pixeldata ein Vector der die Pixeldaten enthält. Sie müssen in dem Farbformat des Bildes vorliegen und es müssen genügend Daten
- vorhanden sein, um das ganze Bild zu füllen.
- @param Offset der Offset in Byte im Pixeldata-Vector an dem sich der erste zu schreibende Pixel befindet.<br>
- Der Standardwert ist 0.
- @param Stride der Abstand in Byte zwischen dem Zeilenende und dem Beginn einer neuen Zeile im Pixeldata-Vector.<br>
- Der Standardwert ist 0.
- @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist.
- @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt.
+ @brief Füllt den Inhalt des Bildes mit Pixeldaten.
+ @param Pixeldata ein Vector der die Pixeldaten enthält. Sie müssen in dem Farbformat des Bildes vorliegen und es müssen genügend Daten
+ vorhanden sein, um das ganze Bild zu füllen.
+ @param Offset der Offset in Byte im Pixeldata-Vector an dem sich der erste zu schreibende Pixel befindet.<br>
+ Der Standardwert ist 0.
+ @param Stride der Abstand in Byte zwischen dem Zeilenende und dem Beginn einer neuen Zeile im Pixeldata-Vector.<br>
+ Der Standardwert ist 0.
+ @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist.
+ @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt.
*/
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) = 0;
/**
- @brief Liest einen Pixel des Bildes.
- @param X die X-Koordinate des Pixels.
- @param Y die Y-Koordinate des Pixels
- @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
- @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
- eher dafür gedacht einzelne Pixel des Bildes auszulesen.
+ @brief Liest einen Pixel des Bildes.
+ @param X die X-Koordinate des Pixels.
+ @param Y die Y-Koordinate des Pixels
+ @return Gibt den 32-Bit Farbwert des Pixels an der übergebenen Koordinate zurück.
+ @remark Diese Methode sollte auf keine Fall benutzt werden um größere Teile des Bildes zu lesen, da sie sehr langsam ist. Sie ist
+ eher dafür gedacht einzelne Pixel des Bildes auszulesen.
*/
virtual unsigned int GetPixel(int X, int Y) = 0;
@@ -183,39 +181,39 @@ public:
/** @name Auskunfts-Methoden */
/**
- @brief Überprüft, ob an dem BS_Image Blit() aufgerufen werden darf.
- @return Gibt false zurück, falls ein Blit()-Aufruf an diesem Objekt nicht gestattet ist.
+ @brief Überprüft, ob an dem BS_Image Blit() aufgerufen werden darf.
+ @return Gibt false zurück, falls ein Blit()-Aufruf an diesem Objekt nicht gestattet ist.
*/
virtual bool IsBlitSource() const = 0;
/**
- @brief Überprüft, ob das BS_Image ein Zielbild für einen Blit-Aufruf sein kann.
- @return Gibt false zurück, falls ein Blit-Aufruf mit diesem Objekt als Ziel nicht gestattet ist.
+ @brief Überprüft, ob das BS_Image ein Zielbild für einen Blit-Aufruf sein kann.
+ @return Gibt false zurück, falls ein Blit-Aufruf mit diesem Objekt als Ziel nicht gestattet ist.
*/
virtual bool IsBlitTarget() const = 0;
/**
- @brief Gibt true zurück, falls das BS_Image bei einem Aufruf von Blit() skaliert dargestellt werden kann.
+ @brief Gibt true zurück, falls das BS_Image bei einem Aufruf von Blit() skaliert dargestellt werden kann.
*/
virtual bool IsScalingAllowed() const = 0;
/**
- @brief Gibt true zurück, wenn das BS_Image mit einem Aufruf von Fill() gefüllt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image mit einem Aufruf von Fill() gefüllt werden kann.
*/
virtual bool IsFillingAllowed() const = 0;
/**
- @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit einem Alphawert dargestellt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit einem Alphawert dargestellt werden kann.
*/
virtual bool IsAlphaAllowed() const = 0;
/**
- @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit Farbmodulation dargestellt werden kann.
+ @brief Gibt true zurück, wenn das BS_Image bei einem Aufruf von Blit() mit Farbmodulation dargestellt werden kann.
*/
virtual bool IsColorModulationAllowed() const = 0;
/**
- @brief Gibt true zurück, wenn der Inhalt des BS_Image durch eine Aufruf von SetContent() ausgetauscht werden kann.
+ @brief Gibt true zurück, wenn der Inhalt des BS_Image durch eine Aufruf von SetContent() ausgetauscht werden kann.
*/
virtual bool IsSetContentAllowed() const = 0;
diff --git a/engines/sword25/gfx/image/imageloader.cpp b/engines/sword25/gfx/image/imageloader.cpp
index 1bf7508ee5..02eea59f56 100644
--- a/engines/sword25/gfx/image/imageloader.cpp
+++ b/engines/sword25/gfx/image/imageloader.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -40,31 +40,29 @@ namespace Sword25 {
#define BS_LOG_PREFIX "IMAGELOADER"
// Statische Elemente der Klasse BS_ImageLoader intialisieren.
-std::list<BS_ImageLoader*> BS_ImageLoader::_ImageLoaderList;
+std::list<BS_ImageLoader *> BS_ImageLoader::_ImageLoaderList;
bool BS_ImageLoader::_ImageLoaderListInitialized = false;
// Lade Methode
// ------------
-bool BS_ImageLoader::LoadImage(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS ColorFormat,
- char*& pUncompressedData,
- int& Width, int& Height,
- int& Pitch)
-{
+bool BS_ImageLoader::LoadImage(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS ColorFormat,
+ char*& pUncompressedData,
+ int &Width, int &Height,
+ int &Pitch) {
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
if (!_ImageLoaderListInitialized)
_InitializeLoaderList();
// Passenden BS_ImageLoader finden und Bild dekodieren
- BS_ImageLoader* pLoader = _FindSuitableImageLoader(pFileData, FileSize);
- if (pLoader)
- {
+ BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
+ if (pLoader) {
return pLoader->DecodeImage(pFileData, FileSize,
- ColorFormat,
- pUncompressedData,
- Width, Height,
- Pitch);
+ ColorFormat,
+ pUncompressedData,
+ Width, Height,
+ Pitch);
}
return false;
@@ -73,21 +71,19 @@ bool BS_ImageLoader::LoadImage(const char* pFileData, unsigned int FileSize,
// Info Methode
// ------------
-bool BS_ImageLoader::ExtractImageProperties(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS& ColorFormat,
- int& Width, int& Height)
-{
+bool BS_ImageLoader::ExtractImageProperties(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS &ColorFormat,
+ int &Width, int &Height) {
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
if (!_ImageLoaderListInitialized)
_InitializeLoaderList();
// Passenden BS_ImageLoader finden und Bildeigenschaften auslesen.
- BS_ImageLoader* pLoader = _FindSuitableImageLoader(pFileData, FileSize);
- if (pLoader)
- {
+ BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
+ if (pLoader) {
return pLoader->ImageProperties(pFileData, FileSize,
- ColorFormat,
- Width, Height);
+ ColorFormat,
+ Width, Height);
}
return false;
@@ -96,8 +92,7 @@ bool BS_ImageLoader::ExtractImageProperties(const char* pFileData, unsigned int
// Verwaltungs Methoden
// --------------------
-void BS_ImageLoader::_InitializeLoaderList()
-{
+void BS_ImageLoader::_InitializeLoaderList() {
// Von jedem BS_ImageLoader wird eine Instanz erzeugt, diese fügen sich selbständig in die BS_ImageLoader-Liste ein.
for (int i = 0; i < BS_IMAGELOADER_COUNT; i++)
BS_IMAGELOADER_IDS[i]();
@@ -109,24 +104,19 @@ void BS_ImageLoader::_InitializeLoaderList()
atexit(BS_ImageLoader::_DeinitializeLoaderList);
}
-void BS_ImageLoader::_DeinitializeLoaderList()
-{
- while (!_ImageLoaderList.empty())
- {
+void BS_ImageLoader::_DeinitializeLoaderList() {
+ while (!_ImageLoaderList.empty()) {
delete _ImageLoaderList.back();
_ImageLoaderList.pop_back();
}
}
-BS_ImageLoader* BS_ImageLoader::_FindSuitableImageLoader(const char* pFileData, unsigned int FileSize)
-{
+BS_ImageLoader *BS_ImageLoader::_FindSuitableImageLoader(const char *pFileData, unsigned int FileSize) {
// Alle BS_ImageLoader-Objekte durchgehen, bis eins gefunden wurde, dass das Bild laden kann
- std::list<BS_ImageLoader*>::iterator Iter = _ImageLoaderList.begin();
- for (; Iter != _ImageLoaderList.end(); ++Iter)
- {
+ std::list<BS_ImageLoader *>::iterator Iter = _ImageLoaderList.begin();
+ for (; Iter != _ImageLoaderList.end(); ++Iter) {
// Falls ein geeigneter BS-ImageLoader gefunden wurde, wird er zurückgegeben.
- if ((*Iter)->IsCorrectImageFormat(pFileData, FileSize))
- {
+ if ((*Iter)->IsCorrectImageFormat(pFileData, FileSize)) {
return (*Iter);
}
}
diff --git a/engines/sword25/gfx/image/imageloader.h b/engines/sword25/gfx/image/imageloader.h
index 15c4e20606..204a56b144 100644
--- a/engines/sword25/gfx/image/imageloader.h
+++ b/engines/sword25/gfx/image/imageloader.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,10 +33,10 @@
*/
/*
- BS_ImageLoader
- --------------
+ BS_ImageLoader
+ --------------
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_IMAGELOADER_H
@@ -55,90 +55,88 @@
namespace Sword25 {
/**
- @brief Über die statischen Methoden dieser Klasse werden alle unterstützten Bildformate geladen.
-
- Zum Laden von Bildern wird die #LoadImage-Methode benutzt.
-
- Außerdem stellt diese Klasse das Interface da, das alle Klassen implementieren müssen, die Bildformate einlesen.<br>
- Zur Unterstützung eines neuen Bildformates muss folgendermaßen vorgegangen werden:
- - Erzeugen einer neuen von #BS_ImageLoader abgeleiteten Klasse, die die Methoden #IsCorrectImageFormat und #DecodeImage impelementiert.
- - Die Klasse muss eine statische Methode haben, die eine Instanz von ihr erzeugt und einen Pointer darauf zurückgibt.
- - Diese Methode muss in der Liste in der Datei imageloader_ids.h eingetragen werden.
- - Die Klasse muss JEDES Eingabebild seines Bildformates in die folgenden Farbformate konvertieren können:
- - BS_GraphicEngine::CF_RGB16
- - BS_GraphicEngine::CF_RGB15
- - BS_GraphicEngine::CF_RGB16_INTERLEAVED
- - BS_GraphicEngine::CF_RGB15_INTERLEAVED
- - BS_GraphicEngine::CF_ARGB32
- - BS_GraphicEngine::CF_BGRA32
- - Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten
- Farbformate konvertieren.
+ @brief Über die statischen Methoden dieser Klasse werden alle unterstützten Bildformate geladen.
+
+ Zum Laden von Bildern wird die #LoadImage-Methode benutzt.
+
+ Außerdem stellt diese Klasse das Interface da, das alle Klassen implementieren müssen, die Bildformate einlesen.<br>
+ Zur Unterstützung eines neuen Bildformates muss folgendermaßen vorgegangen werden:
+ - Erzeugen einer neuen von #BS_ImageLoader abgeleiteten Klasse, die die Methoden #IsCorrectImageFormat und #DecodeImage impelementiert.
+ - Die Klasse muss eine statische Methode haben, die eine Instanz von ihr erzeugt und einen Pointer darauf zurückgibt.
+ - Diese Methode muss in der Liste in der Datei imageloader_ids.h eingetragen werden.
+ - Die Klasse muss JEDES Eingabebild seines Bildformates in die folgenden Farbformate konvertieren können:
+ - BS_GraphicEngine::CF_RGB16
+ - BS_GraphicEngine::CF_RGB15
+ - BS_GraphicEngine::CF_RGB16_INTERLEAVED
+ - BS_GraphicEngine::CF_RGB15_INTERLEAVED
+ - BS_GraphicEngine::CF_ARGB32
+ - BS_GraphicEngine::CF_BGRA32
+ - Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten
+ Farbformate konvertieren.
*/
-class BS_ImageLoader
-{
+class BS_ImageLoader {
public:
//@{
/** @name Lade Methoden */
/**
- @brief Lädt eine Bilddatei.
-
- Diese Methode kann sämtliche unterstütztem Bildformate lesen. Die Methode erkennt selbstständing um welches Dateiformat es sich
- bei der vorliegenden Datei handelt.<br>
- Bisher wird nur PNG unterstützt.
-
- @param pFileData ein Pointer auf die Bilddaten.
- @param FileSize die Größe der Bilddaten in Byte.
- @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
- Folgende Farbformate werden unterstützt:
- - BS_GraphicEngine::CF_RGB16
- - BS_GraphicEngine::CF_RGB15
- - BS_GraphicEngine::CF_RGB16_INTERLEAVED
- - BS_GraphicEngine::CF_RGB15_INTERLEAVED
- - BS_GraphicEngine::CF_ARGB32
- @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
- @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
- @param Height gibt nach erfolgreichen Laden die Höhe des geladenen Bildes an.
- @param Pitch gibt nach erfolgreichen Laden die Länge einer Bildzeile in Byte an.
- @return Gibt false zurück, falls das Laden fehlgeschlagen ist.
- @remark Die Größe der Ausgabedaten in Bytes kann wie folgt berechnet werden: Pitch * Height.
- @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
+ @brief Lädt eine Bilddatei.
+
+ Diese Methode kann sämtliche unterstütztem Bildformate lesen. Die Methode erkennt selbstständing um welches Dateiformat es sich
+ bei der vorliegenden Datei handelt.<br>
+ Bisher wird nur PNG unterstützt.
+
+ @param pFileData ein Pointer auf die Bilddaten.
+ @param FileSize die Größe der Bilddaten in Byte.
+ @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
+ Folgende Farbformate werden unterstützt:
+ - BS_GraphicEngine::CF_RGB16
+ - BS_GraphicEngine::CF_RGB15
+ - BS_GraphicEngine::CF_RGB16_INTERLEAVED
+ - BS_GraphicEngine::CF_RGB15_INTERLEAVED
+ - BS_GraphicEngine::CF_ARGB32
+ @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
+ @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
+ @param Height gibt nach erfolgreichen Laden die Höhe des geladenen Bildes an.
+ @param Pitch gibt nach erfolgreichen Laden die Länge einer Bildzeile in Byte an.
+ @return Gibt false zurück, falls das Laden fehlgeschlagen ist.
+ @remark Die Größe der Ausgabedaten in Bytes kann wie folgt berechnet werden: Pitch * Height.
+ @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
*/
- static bool LoadImage(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS ColorFormat,
- char*& pUncompressedData,
- int& Width, int& Height,
- int& Pitch);
+ static bool LoadImage(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS ColorFormat,
+ char*& pUncompressedData,
+ int &Width, int &Height,
+ int &Pitch);
/**
- @brief Liest die Bildeigenschaften eines Bildes aus.
-
- @param pFileData ein Pointer auf die Bilddaten.
- @param FileSize die Größe des Bilddaten in Byte.
- @param ColorFormat enthält nach einem erfolgreichem Aufruf das Farbformat des Bildes.
- @param Width enthält nach einem erfolgreichem Aufruf die Breite des Bildes in Pixeln.
- @param Height enthält nach einem erfolgreichem Aufruf die Höhe des Bildes in Pixeln.
- @return Gibt false zurück, wenn die Bildeigenschaften nicht ausgelesen werden konnten.
- @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
+ @brief Liest die Bildeigenschaften eines Bildes aus.
+
+ @param pFileData ein Pointer auf die Bilddaten.
+ @param FileSize die Größe des Bilddaten in Byte.
+ @param ColorFormat enthält nach einem erfolgreichem Aufruf das Farbformat des Bildes.
+ @param Width enthält nach einem erfolgreichem Aufruf die Breite des Bildes in Pixeln.
+ @param Height enthält nach einem erfolgreichem Aufruf die Höhe des Bildes in Pixeln.
+ @return Gibt false zurück, wenn die Bildeigenschaften nicht ausgelesen werden konnten.
+ @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
*/
- static bool ExtractImageProperties(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS& ColorFormat,
- int& Width, int& Height);
+ static bool ExtractImageProperties(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS &ColorFormat,
+ int &Width, int &Height);
//@}
protected:
// Protected Konstruktor, damit Instanzen dieser Klasse nur von BS_ImageLoader-Objekten erstellt werden können
/**
- @brief Der Standardkonstruktor.
+ @brief Der Standardkonstruktor.
- Dieser Konstruktor registriert alle Instanzen von #BS_ImageLoader-Klassen in einer Liste.<br>
- Diese Liste enthält jeweils eine Instanz jedes #BS_ImageLoader und wird benutzt um beliebige Bilddateien einem Loader zuzuordnen.
- @remark Dieser Konstruktor ist protected damit nur #BS_ImageLoader-Objekte diese Klasse instanziieren können.
+ Dieser Konstruktor registriert alle Instanzen von #BS_ImageLoader-Klassen in einer Liste.<br>
+ Diese Liste enthält jeweils eine Instanz jedes #BS_ImageLoader und wird benutzt um beliebige Bilddateien einem Loader zuzuordnen.
+ @remark Dieser Konstruktor ist protected damit nur #BS_ImageLoader-Objekte diese Klasse instanziieren können.
*/
- BS_ImageLoader()
- {
+ BS_ImageLoader() {
// Klasse registrieren
_ImageLoaderList.push_front(this);
}
@@ -147,54 +145,54 @@ protected:
/** @name Abstrakte Methoden */
/**
- @brief Gibt an, ob der #BS_ImageLoader ein Bild lesen kann.
- @param pFileData ein Pointer auf die kompletten Daten des Bildes.
- @param FileSize die Größe der Daten in Byte.
- @return Gibt true zurück, wenn der #BS_ImageLoader das Bild lesen kann, ansonsten false.
- @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
+ @brief Gibt an, ob der #BS_ImageLoader ein Bild lesen kann.
+ @param pFileData ein Pointer auf die kompletten Daten des Bildes.
+ @param FileSize die Größe der Daten in Byte.
+ @return Gibt true zurück, wenn der #BS_ImageLoader das Bild lesen kann, ansonsten false.
+ @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
*/
- virtual bool IsCorrectImageFormat(const char* pFileData, unsigned int FileSize) = 0;
+ virtual bool IsCorrectImageFormat(const char *pFileData, unsigned int FileSize) = 0;
/**
- @brief Lädt eine Bilddatei.
- @param pFileData ein Pointer auf die Bilddaten.
- @param FileSize die Größe der Bilddaten in Byte.
- @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
- Folgende Farbformate werden unterstützt:
- - BS_GraphicEngine::CF_RGB16
- - BS_GraphicEngine::CF_RGB15
- - BS_GraphicEngine::CF_RGB16_INTERLEAVED
- - BS_GraphicEngine::CF_RGB15_INTERLEAVED
- - BS_GraphicEngine::CF_ARGB32
- @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
- @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
- @param Height gibt nach erfolgreichen Laden die Höhe des geladenen Bildes an.
- @param Pitch gibt nach erfolgreichen Laden die Länge einer Bildzeile in Byte an.
- @return Gibt false zurück, falls das Laden fehlgeschlagen ist.
- @remark Die Größe der Ausgabedaten in Bytes kann wie folgt berechnet werden: Pitch * Height.
- @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
- @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
+ @brief Lädt eine Bilddatei.
+ @param pFileData ein Pointer auf die Bilddaten.
+ @param FileSize die Größe der Bilddaten in Byte.
+ @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
+ Folgende Farbformate werden unterstützt:
+ - BS_GraphicEngine::CF_RGB16
+ - BS_GraphicEngine::CF_RGB15
+ - BS_GraphicEngine::CF_RGB16_INTERLEAVED
+ - BS_GraphicEngine::CF_RGB15_INTERLEAVED
+ - BS_GraphicEngine::CF_ARGB32
+ @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
+ @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
+ @param Height gibt nach erfolgreichen Laden die Höhe des geladenen Bildes an.
+ @param Pitch gibt nach erfolgreichen Laden die Länge einer Bildzeile in Byte an.
+ @return Gibt false zurück, falls das Laden fehlgeschlagen ist.
+ @remark Die Größe der Ausgabedaten in Bytes kann wie folgt berechnet werden: Pitch * Height.
+ @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
+ @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
*/
- virtual bool DecodeImage(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS ColorFormat,
- char*& pUncompressedData,
- int& Width, int& Height,
- int& Pitch) = 0;
+ virtual bool DecodeImage(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS ColorFormat,
+ char*& pUncompressedData,
+ int &Width, int &Height,
+ int &Pitch) = 0;
/**
- @brief Liest die Bildeigenschaften aus.
- @param pFileData ein Pointer auf die Bilddaten.
- @param FileSize die Größe des Bilddaten in Byte.
- @param ColorFormat enthält nach einem erfolgreichem Aufruf das Farbformat des Bildes.
- @param Width enthält nach einem erfolgreichem Aufruf die Breite des Bildes in Pixeln.
- @param Height enthält nach einem erfolgreichem Aufruf die Höhe des Bildes in Pixeln.
- @return Gibt false zurück, wenn die Bildeigenschaften nicht ausgelesen werden konnten.
- @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
- @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
+ @brief Liest die Bildeigenschaften aus.
+ @param pFileData ein Pointer auf die Bilddaten.
+ @param FileSize die Größe des Bilddaten in Byte.
+ @param ColorFormat enthält nach einem erfolgreichem Aufruf das Farbformat des Bildes.
+ @param Width enthält nach einem erfolgreichem Aufruf die Breite des Bildes in Pixeln.
+ @param Height enthält nach einem erfolgreichem Aufruf die Höhe des Bildes in Pixeln.
+ @return Gibt false zurück, wenn die Bildeigenschaften nicht ausgelesen werden konnten.
+ @remark Es darf nicht vergessen werden, die Ausgabedaten nach erfolgter Benutzung mit delete freizugeben.
+ @remark Diese Methode muss von allen BS_ImageLoader Klassen implementiert werden.
*/
- virtual bool ImageProperties(const char* pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS& ColorFormat,
- int& Width, int& Height) = 0;
+ virtual bool ImageProperties(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS &ColorFormat,
+ int &Width, int &Height) = 0;
//@}
@@ -202,69 +200,62 @@ protected:
/** @name Konvertierungsmethoden */
/**
- @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16 Farbformat.
- @param pSrcData ein Pointer auf die Quelldaten.
- @param pDestData ein Pointer auf den Zielpuffern.
- @param Width die Anzahl der Pixel in der Bildzeile.
- @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
- Es sind mindestens Width * 2 Byte notwendig.
+ @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16 Farbformat.
+ @param pSrcData ein Pointer auf die Quelldaten.
+ @param pDestData ein Pointer auf den Zielpuffern.
+ @param Width die Anzahl der Pixel in der Bildzeile.
+ @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
+ Es sind mindestens Width * 2 Byte notwendig.
*/
- static void RowARGB32ToRGB16(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
- {
- for (unsigned int i = 0; i < Width; i++)
- {
- ((uint16_t*)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3);
+ static void RowARGB32ToRGB16(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
+ for (unsigned int i = 0; i < Width; i++) {
+ ((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3);
pSrcData += 4;
}
}
-
+
/**
- @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15 Farbformat.
- @param pSrcData ein Pointer auf die Quelldaten.
- @param pDestData ein Pointer auf den Zielpuffern.
- @param Width die Anzahl der Pixel in der Bildzeile.
- @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
- Es sind mindestens Width * 2 Byte notwendig.
+ @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15 Farbformat.
+ @param pSrcData ein Pointer auf die Quelldaten.
+ @param pDestData ein Pointer auf den Zielpuffern.
+ @param Width die Anzahl der Pixel in der Bildzeile.
+ @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
+ Es sind mindestens Width * 2 Byte notwendig.
*/
- static void RowARGB32ToRGB15(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
- {
- for (unsigned int i = 0; i < Width; i++)
- {
- ((uint16_t*)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3);
+ static void RowARGB32ToRGB15(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
+ for (unsigned int i = 0; i < Width; i++) {
+ ((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3);
pSrcData += 4;
}
}
/**
- @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16_INTERLEAVED Farbformat.
- @param pSrcData ein Pointer auf die Quelldaten.
- @param pDestData ein Pointer auf den Zielpuffern.
- @param Width die Anzahl der Pixel in der Bildzeile.
- @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.<br>
- Es sind mindestens ((Width + 3) / 4) * 12 Byte notwendig.
+ @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16_INTERLEAVED Farbformat.
+ @param pSrcData ein Pointer auf die Quelldaten.
+ @param pDestData ein Pointer auf den Zielpuffern.
+ @param Width die Anzahl der Pixel in der Bildzeile.
+ @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.<br>
+ Es sind mindestens ((Width + 3) / 4) * 12 Byte notwendig.
*/
- static void RowARGB32ToRGB16_INTERLEAVED(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
- {
+ static void RowARGB32ToRGB16_INTERLEAVED(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
unsigned int BlockFillCount = 0;
unsigned int AlphaBlock = 0;
- for (unsigned int i = 0; i < Width; i++)
- {
+ for (unsigned int i = 0; i < Width; i++) {
// Alphawert in den Alphablock schreiben
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
-
+
// Füllstand der Pixelblockes aktualisieren
BlockFillCount++;
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
- if (BlockFillCount == 4 || i == (Width - 1))
- {
+ if (BlockFillCount == 4 || i == (Width - 1)) {
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
// "left aligned" sind.
AlphaBlock >>= (4 - BlockFillCount) * 8;
// Alphablock schreiben
- *((unsigned int*)pDestData) = AlphaBlock;
+ *((unsigned int *)pDestData) = AlphaBlock;
pDestData += 4;
// Pixel konvertieren und schreiben
@@ -283,35 +274,32 @@ protected:
}
/**
- @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15_INTERLEAVED Farbformat.
- @param pSrcData ein Pointer auf die Quelldaten.
- @param pDestData ein Pointer auf den Zielpuffern.
- @param Width die Anzahl der Pixel in der Bildzeile.
- @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
- Es sind mindestens (Width / 4 + Width % 4) * 3 Byte notwendig.
+ @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15_INTERLEAVED Farbformat.
+ @param pSrcData ein Pointer auf die Quelldaten.
+ @param pDestData ein Pointer auf den Zielpuffern.
+ @param Width die Anzahl der Pixel in der Bildzeile.
+ @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
+ Es sind mindestens (Width / 4 + Width % 4) * 3 Byte notwendig.
*/
- static void RowARGB32ToRGB15_INTERLEAVED(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
- {
+ static void RowARGB32ToRGB15_INTERLEAVED(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
unsigned int BlockFillCount = 0;
unsigned int AlphaBlock = 0;
- for (unsigned int i = 0; i < Width; i++)
- {
+ for (unsigned int i = 0; i < Width; i++) {
// Alphawert in den Alphablock schreiben
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
-
+
// Füllstand der Pixelblockes aktualisieren
BlockFillCount++;
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
- if (BlockFillCount == 4 || i == (Width - 1))
- {
+ if (BlockFillCount == 4 || i == (Width - 1)) {
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
// "left aligned" sind.
AlphaBlock >>= (4 - BlockFillCount) * 8;
// Alphablock schreiben
- *((unsigned int*)pDestData) = AlphaBlock;
+ *((unsigned int *)pDestData) = AlphaBlock;
pDestData += 4;
// Pixel konvertieren und schreiben
@@ -330,15 +318,13 @@ protected:
}
/**
- @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_BGRA32 Farbformat.
- @param pSrcData ein Pointer auf die Quelldaten.
- @param pDestData ein Pointer auf den Zielpuffern.
- @param Width die Anzahl der Pixel in der Bildzeile.
+ @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_BGRA32 Farbformat.
+ @param pSrcData ein Pointer auf die Quelldaten.
+ @param pDestData ein Pointer auf den Zielpuffern.
+ @param Width die Anzahl der Pixel in der Bildzeile.
*/
- static void RowARGB32ToABGR32(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
- {
- for (unsigned int i = 0; i < Width; ++i)
- {
+ static void RowARGB32ToABGR32(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
+ for (unsigned int i = 0; i < Width; ++i) {
*pDestData++ = pSrcData[2];
*pDestData++ = pSrcData[1];
*pDestData++ = pSrcData[0];
@@ -351,25 +337,25 @@ protected:
private:
/**
- @brief Erzeugt je eine Instanz aller BS_ImageLoader Klassen und fügt diese in eine interne Liste ein. Diese werden dann beim
- Laden von Bildern benutzt.
- @remark Die Klassen müssen in der Datei imageloader_ids.h eingetragen sein, damit sie an dieser Stelle berücksichtigt werden.
+ @brief Erzeugt je eine Instanz aller BS_ImageLoader Klassen und fügt diese in eine interne Liste ein. Diese werden dann beim
+ Laden von Bildern benutzt.
+ @remark Die Klassen müssen in der Datei imageloader_ids.h eingetragen sein, damit sie an dieser Stelle berücksichtigt werden.
*/
static void _InitializeLoaderList();
/**
- @brief Zerstört alle Instanzen von BS_ImageLoader Klassen, die in dieser Klasse registriert sind.
+ @brief Zerstört alle Instanzen von BS_ImageLoader Klassen, die in dieser Klasse registriert sind.
*/
static void _DeinitializeLoaderList();
/**
- @brief Sucht zu Bilddaten ein BS_ImageLoader Objekt, dass die Bilddaten dekodieren kann.
- @return Gibt einen Pointer auf ein passendes BS_ImageLoader Objekt zurück, oder NULL, wenn kein passendes Objekt gefunden wurde.
+ @brief Sucht zu Bilddaten ein BS_ImageLoader Objekt, dass die Bilddaten dekodieren kann.
+ @return Gibt einen Pointer auf ein passendes BS_ImageLoader Objekt zurück, oder NULL, wenn kein passendes Objekt gefunden wurde.
*/
- static BS_ImageLoader* _FindSuitableImageLoader(const char* pFileData, unsigned int FileSize);
+ static BS_ImageLoader *_FindSuitableImageLoader(const char *pFileData, unsigned int FileSize);
- static std::list<BS_ImageLoader*> _ImageLoaderList; // Die Liste aller BS_ImageLoader-Objekte
- static bool _ImageLoaderListInitialized; // Gibt an, ob die Liste schon intialisiert wurde
+ static std::list<BS_ImageLoader *> _ImageLoaderList; // Die Liste aller BS_ImageLoader-Objekte
+ static bool _ImageLoaderListInitialized; // Gibt an, ob die Liste schon intialisiert wurde
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/imageloader_ids.h b/engines/sword25/gfx/image/imageloader_ids.h
index 74c5c3429a..bde6293f50 100644
--- a/engines/sword25/gfx/image/imageloader_ids.h
+++ b/engines/sword25/gfx/image/imageloader_ids.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,12 +33,12 @@
*/
/*
- imageloader_ids.h
- -----------------
- In dieser Datei sind alle ImageLoader verzeichnet.
- JEDER neuer ImageLoader muss hier eingetragen werden, ansonsten wird er beim Laden eines Bildes nicht berücksichtigt.
+ imageloader_ids.h
+ -----------------
+ In dieser Datei sind alle ImageLoader verzeichnet.
+ JEDER neuer ImageLoader muss hier eingetragen werden, ansonsten wird er beim Laden eines Bildes nicht berücksichtigt.
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#include "sword25/gfx/image/imageloader.h"
@@ -51,9 +51,8 @@ namespace Sword25 {
// Die Tabelle enthält Pointer auf statische Member-Funktionen innerhalb der Klassen, die eine Instanz der Klasse
// erzeugen
-typedef BS_ImageLoader* (*BS_IMAGELOADER_NEW)();
-const BS_IMAGELOADER_NEW BS_IMAGELOADER_IDS[] =
-{
+typedef BS_ImageLoader*(*BS_IMAGELOADER_NEW)();
+const BS_IMAGELOADER_NEW BS_IMAGELOADER_IDS[] = {
BS_PNGLoader::CreateInstance,
BS_B25SLoader::CreateInstance,
};
diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index 693874314f..1c896a7675 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,66 +48,58 @@ namespace Sword25 {
// Konstruktor / Destruktor
// -----------------------------------------------------------------------------
-BS_PNGLoader::BS_PNGLoader()
-{
+BS_PNGLoader::BS_PNGLoader() {
}
// -----------------------------------------------------------------------------
// Laden
// -----------------------------------------------------------------------------
-static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
- memcpy(data, (char*)png_ptr->io_ptr, length);
- png_ptr->io_ptr = (void*)((png_size_t)png_ptr->io_ptr + length);
+static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
+ memcpy(data, (char *)png_ptr->io_ptr, length);
+ png_ptr->io_ptr = (void *)((png_size_t)png_ptr->io_ptr + length);
}
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
- int & Width, int & Height, int & Pitch)
-{
+bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
+ int &Width, int &Height, int &Pitch) {
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
- png_bytep RawDataBuffer = NULL;
- png_bytep* pRowPtr = NULL;
+ png_bytep RawDataBuffer = NULL;
+ png_bytep *pRowPtr = NULL;
- int BitDepth;
- int ColorType;
- int InterlaceType;
- int i;
+ int BitDepth;
+ int ColorType;
+ int InterlaceType;
+ int i;
// Zielfarbformat überprüfen
if (ColorFormat != BS_GraphicEngine::CF_RGB16 &&
- ColorFormat != BS_GraphicEngine::CF_RGB15 &&
- ColorFormat != BS_GraphicEngine::CF_RGB16_INTERLEAVED &&
- ColorFormat != BS_GraphicEngine::CF_RGB15_INTERLEAVED &&
- ColorFormat != BS_GraphicEngine::CF_ARGB32 &&
- ColorFormat != BS_GraphicEngine::CF_ABGR32)
- {
+ ColorFormat != BS_GraphicEngine::CF_RGB15 &&
+ ColorFormat != BS_GraphicEngine::CF_RGB16_INTERLEAVED &&
+ ColorFormat != BS_GraphicEngine::CF_RGB15_INTERLEAVED &&
+ ColorFormat != BS_GraphicEngine::CF_ARGB32 &&
+ ColorFormat != BS_GraphicEngine::CF_ABGR32) {
BS_LOG_ERRORLN("Illegal or unsupported color format.");
return false;
}
- try
- {
+ try {
// PNG Signatur überprüfen
- if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8))
- {
+ if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) {
throw(0);
}
// Die beiden PNG Strukturen erstellen
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr)
- {
+ if (!png_ptr) {
BS_LOG_ERRORLN("Could not create libpng read struct.");
throw(0);
}
info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- {
+ if (!info_ptr) {
BS_LOG_ERRORLN("Could not create libpng info struct.");
throw(0);
}
@@ -116,13 +108,13 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
if (setjmp(png_jmpbuf(png_ptr))) throw(0);
// Alternative Lesefunktion benutzen
- png_set_read_fn(png_ptr, (void*)FileDataPtr, png_user_read_data);
+ png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
// PNG Informationen auslesen
- png_get_IHDR(png_ptr, info_ptr, (unsigned long*)&Width, (unsigned long*)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
+ png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
// Pitch des Ausgabebildes berechnen
Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
@@ -130,8 +122,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
// Speicher für die endgültigen Bilddaten reservieren
// Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
UncompressedDataPtr = new char[Pitch * Height];
- if (!UncompressedDataPtr)
- {
+ if (!UncompressedDataPtr) {
BS_LOG_ERRORLN("Could not allocate memory for output image.");
throw(0);
}
@@ -146,7 +137,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr);
if (ColorType == PNG_COLOR_TYPE_GRAY ||
- ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
+ ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
png_set_bgr(png_ptr);
@@ -156,62 +147,58 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
// Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen
png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, (unsigned long*)&Width, (unsigned long*)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
+ png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
// PNGs ohne Interlacing werden Zeilenweise eingelesen
- if (InterlaceType == PNG_INTERLACE_NONE)
- {
+ if (InterlaceType == PNG_INTERLACE_NONE) {
// Speicher für eine Bildzeile reservieren
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
- if (!RawDataBuffer)
- {
+ if (!RawDataBuffer) {
BS_LOG_ERRORLN("Could not allocate memory for row buffer.");
throw(0);
}
// Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
- for (i = 0; i < Height; i++)
- {
+ for (i = 0; i < Height; i++) {
// Zeile einlesen
png_read_row(png_ptr, RawDataBuffer, NULL);
// Zeile konvertieren
- switch (ColorFormat)
- {
+ switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
- RowARGB32ToRGB16((unsigned char*)RawDataBuffer,
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16((unsigned char *)RawDataBuffer,
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB15:
- RowARGB32ToRGB15((unsigned char*)RawDataBuffer,
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15((unsigned char *)RawDataBuffer,
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
- RowARGB32ToRGB16_INTERLEAVED((unsigned char*)RawDataBuffer,
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16_INTERLEAVED((unsigned char *)RawDataBuffer,
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
- RowARGB32ToRGB15_INTERLEAVED((unsigned char*)RawDataBuffer,
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15_INTERLEAVED((unsigned char *)RawDataBuffer,
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_ARGB32:
memcpy(&UncompressedDataPtr[i * Pitch],
- RawDataBuffer,
- Pitch);
+ RawDataBuffer,
+ Pitch);
break;
case BS_GraphicEngine::CF_ABGR32:
- RowARGB32ToABGR32((unsigned char*)RawDataBuffer,
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToABGR32((unsigned char *)RawDataBuffer,
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
default:
@@ -220,20 +207,17 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
}
}
// PNGs mit Interlacing werden an einem Stück eingelesen
- else
- {
+ else {
// Speicher für das komplette Bild reservieren
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height];
- if (!RawDataBuffer)
- {
+ if (!RawDataBuffer) {
BS_LOG_ERRORLN("Could not allocate memory for raw image buffer.");
throw(0);
}
// Speicher für die Rowpointer reservieren
pRowPtr = new png_bytep[Height];
- if (!pRowPtr)
- {
+ if (!pRowPtr) {
BS_LOG_ERRORLN("Could not allocate memory for row pointers.");
throw(0);
}
@@ -246,41 +230,40 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
png_read_image(png_ptr, pRowPtr);
// Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
- switch (ColorFormat)
- {
+ switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
for (i = 0; i < Height; i++)
- RowARGB32ToRGB16((unsigned char*)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB15:
for (i = 0; i < Height; i++)
- RowARGB32ToRGB15((unsigned char*)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
for (i = 0; i < Height; i++)
- RowARGB32ToRGB16_INTERLEAVED((unsigned char*)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
for (i = 0; i < Height; i++)
- RowARGB32ToRGB15_INTERLEAVED((unsigned char*)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char*)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (unsigned char *)&UncompressedDataPtr[i * Pitch],
+ Width);
break;
case BS_GraphicEngine::CF_ARGB32:
for (i = 0; i < Height; i++)
memcpy(&UncompressedDataPtr[i * Pitch],
- &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)],
- Pitch);
+ &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)],
+ Pitch);
break;
}
}
@@ -296,8 +279,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
delete[] RawDataBuffer;
}
- catch(int)
- {
+ catch (int) {
delete[] pRowPtr;
delete[] RawDataBuffer;
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
@@ -313,40 +295,35 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::DecodeImage(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
- int & Width, int & Height, int & Pitch)
-{
+bool BS_PNGLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
+ int &Width, int &Height, int &Pitch) {
return DoDecodeImage(FileDataPtr, FileSize, ColorFormat, UncompressedDataPtr, Width, Height, Pitch);
}
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::DoImageProperties(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height)
-{
+bool BS_PNGLoader::DoImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height) {
// PNG Signatur überprüfen
if (!DoIsCorrectImageFormat(FileDataPtr, FileSize)) return false;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
- try
- {
+ try {
// Die beiden PNG Strukturen erstellen
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr)
- {
+ if (!png_ptr) {
BS_LOG_ERRORLN("Could not create libpng read struct.");
throw(0);
}
info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- {
+ if (!info_ptr) {
BS_LOG_ERRORLN("Could not create libpng info struct.");
throw(0);
}
// Alternative Lesefunktion benutzen
- png_set_read_fn(png_ptr, (void*)FileDataPtr, png_user_read_data);
+ png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
@@ -354,7 +331,7 @@ bool BS_PNGLoader::DoImageProperties(const char * FileDataPtr, unsigned int File
// PNG Informationen auslesen
int BitDepth;
int ColorType;
- png_get_IHDR(png_ptr, info_ptr, (unsigned long*)&Width, (unsigned long*)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
+ png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
// PNG-ColorType in BS ColorFormat konvertieren.
if (ColorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
@@ -366,8 +343,7 @@ bool BS_PNGLoader::DoImageProperties(const char * FileDataPtr, unsigned int File
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
}
- catch (int)
- {
+ catch (int) {
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
@@ -381,8 +357,7 @@ bool BS_PNGLoader::DoImageProperties(const char * FileDataPtr, unsigned int File
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::ImageProperties(const char* FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height)
-{
+bool BS_PNGLoader::ImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height) {
return DoImageProperties(FileDataPtr, FileSize, ColorFormat, Width, Height);
}
@@ -390,18 +365,16 @@ bool BS_PNGLoader::ImageProperties(const char* FileDataPtr, unsigned int FileSiz
// Header überprüfen
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::DoIsCorrectImageFormat(const char * FileDataPtr, unsigned int FileSize)
-{
+bool BS_PNGLoader::DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
if (FileSize > 8)
- return png_check_sig((unsigned char*)FileDataPtr, 8) ? true : false;
+ return png_check_sig((unsigned char *)FileDataPtr, 8) ? true : false;
else
return false;
}
// -----------------------------------------------------------------------------
-bool BS_PNGLoader::IsCorrectImageFormat(const char* FileDataPtr, unsigned int FileSize)
-{
+bool BS_PNGLoader::IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
return DoIsCorrectImageFormat(FileDataPtr, FileSize);
}
diff --git a/engines/sword25/gfx/image/pngloader.h b/engines/sword25/gfx/image/pngloader.h
index a4ce28fbe5..85d12a7a94 100644
--- a/engines/sword25/gfx/image/pngloader.h
+++ b/engines/sword25/gfx/image/pngloader.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,11 +33,11 @@
*/
/*
- BS_PNGLoader
- ------------
- BS_ImageLoader-Klasse zum Laden von PNG-Dateien
+ BS_PNGLoader
+ ------------
+ BS_ImageLoader-Klasse zum Laden von PNG-Dateien
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_PNGLOADER2_H
@@ -50,32 +50,30 @@
namespace Sword25 {
// Klassendefinition
-class BS_PNGLoader : public BS_ImageLoader
-{
+class BS_PNGLoader : public BS_ImageLoader {
public:
- static BS_ImageLoader* CreateInstance()
- {
- #include "sword25/kernel/memlog_off.h"
- return (BS_ImageLoader*) new BS_PNGLoader();
- #include "sword25/kernel/memlog_on.h"
+ static BS_ImageLoader *CreateInstance() {
+#include "sword25/kernel/memlog_off.h"
+ return (BS_ImageLoader *) new BS_PNGLoader();
+#include "sword25/kernel/memlog_on.h"
}
// Alle virtuellen Methoden von BS_ImageLoader sind hier als static-Methode implementiert, damit sie von BS_B25SLoader aufgerufen werden können.
// Die virtuellen Methoden rufen diese Methoden auf.
- static bool DoIsCorrectImageFormat(const char * FileDataPtr, unsigned int FileSize);
- static bool DoDecodeImage(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
- int & Width, int & Height, int & Pitch);
- static bool DoImageProperties(const char * FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height);
+ static bool DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize);
+ static bool DoDecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
+ int &Width, int &Height, int &Pitch);
+ static bool DoImageProperties(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height);
protected:
BS_PNGLoader();
- bool DecodeImage(const char * pFileData, unsigned int FileSize,
- BS_GraphicEngine::COLOR_FORMATS ColorFormat,
- char * & pUncompressedData,
- int & Width, int & Height,
- int & Pitch);
- bool IsCorrectImageFormat(const char * FileDataPtr, unsigned int FileSize);
- bool ImageProperties(const char * FileDatePtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS & ColorFormat, int & Width, int & Height);
+ bool DecodeImage(const char *pFileData, unsigned int FileSize,
+ BS_GraphicEngine::COLOR_FORMATS ColorFormat,
+ char * & pUncompressedData,
+ int &Width, int &Height,
+ int &Pitch);
+ bool IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize);
+ bool ImageProperties(const char *FileDatePtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS &ColorFormat, int &Width, int &Height);
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index 5c7a5231a8..a8c84ee6b3 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -68,111 +68,94 @@ typedef int16_t s32;
// Diese Klasse ist speziell dafür ausgestattet.
// -----------------------------------------------------------------------------
-class BS_VectorImage::SWFBitStream
-{
+class BS_VectorImage::SWFBitStream {
public:
- SWFBitStream(const unsigned char * pData, unsigned int DataSize) :
- m_Pos(pData), m_End(pData + DataSize), m_WordMask(0)
- {}
-
- inline u32 GetBits(unsigned int BitCount)
- {
- if (BitCount == 0 || BitCount > 32)
- {
- throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time"));
- }
-
- u32 value = 0;
- while (BitCount)
- {
- if (m_WordMask == 0) FlushByte();
-
- value <<= 1;
- value |= ((m_Word & m_WordMask) != 0) ? 1 : 0;
- m_WordMask >>= 1;
-
- --BitCount;
- }
-
- return value;
- }
-
- inline s32 GetSignedBits(unsigned int BitCount)
- {
- // Bits einlesen
- u32 Temp = GetBits(BitCount);
-
- // Falls das Sign-Bit gesetzt ist, den Rest des Rückgabewertes mit 1-Bits auffüllen (Sign Extension)
- if (Temp & 1 << (BitCount - 1))
- return (0xffffffff << BitCount) | Temp;
- else
- return Temp;
- }
-
- inline u32 GetU32()
- {
- u32 Byte1 = GetU8();
- u32 Byte2 = GetU8();
- u32 Byte3 = GetU8();
- u32 Byte4 = GetU8();
-
- return Byte1 | (Byte2 << 8) | (Byte3 << 16) | (Byte4 << 24);
- }
-
- inline u16 GetU16()
- {
- u32 Byte1 = GetU8();
- u32 Byte2 = GetU8();
-
- return Byte1 | (Byte2 << 8);
- }
-
- inline u8 GetU8()
- {
- FlushByte();
- u8 Value = m_Word;
- m_WordMask = 0;
- FlushByte();
-
- return Value;
- }
-
- inline void FlushByte()
- {
- if (m_WordMask != 128)
- {
- if (m_Pos >= m_End)
- {
- throw(runtime_error("Attempted to read past end of file"));
- }
- else
- {
- m_Word = *m_Pos++;
- m_WordMask = 128;
- }
- }
- }
-
- inline void SkipBytes(unsigned int SkipLength)
- {
- FlushByte();
- if (m_Pos + SkipLength >= m_End)
- {
- throw(runtime_error("Attempted to read past end of file"));
- }
- else
- {
- m_Pos += SkipLength;
- m_Word = *(m_Pos - 1);
- }
- }
+ SWFBitStream(const unsigned char *pData, unsigned int DataSize) :
+ m_Pos(pData), m_End(pData + DataSize), m_WordMask(0)
+ {}
+
+ inline u32 GetBits(unsigned int BitCount) {
+ if (BitCount == 0 || BitCount > 32) {
+ throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time"));
+ }
+
+ u32 value = 0;
+ while (BitCount) {
+ if (m_WordMask == 0) FlushByte();
+
+ value <<= 1;
+ value |= ((m_Word & m_WordMask) != 0) ? 1 : 0;
+ m_WordMask >>= 1;
+
+ --BitCount;
+ }
+
+ return value;
+ }
+
+ inline s32 GetSignedBits(unsigned int BitCount) {
+ // Bits einlesen
+ u32 Temp = GetBits(BitCount);
+
+ // Falls das Sign-Bit gesetzt ist, den Rest des Rückgabewertes mit 1-Bits auffüllen (Sign Extension)
+ if (Temp & 1 << (BitCount - 1))
+ return (0xffffffff << BitCount) | Temp;
+ else
+ return Temp;
+ }
+
+ inline u32 GetU32() {
+ u32 Byte1 = GetU8();
+ u32 Byte2 = GetU8();
+ u32 Byte3 = GetU8();
+ u32 Byte4 = GetU8();
+
+ return Byte1 | (Byte2 << 8) | (Byte3 << 16) | (Byte4 << 24);
+ }
+
+ inline u16 GetU16() {
+ u32 Byte1 = GetU8();
+ u32 Byte2 = GetU8();
+
+ return Byte1 | (Byte2 << 8);
+ }
+
+ inline u8 GetU8() {
+ FlushByte();
+ u8 Value = m_Word;
+ m_WordMask = 0;
+ FlushByte();
+
+ return Value;
+ }
+
+ inline void FlushByte() {
+ if (m_WordMask != 128) {
+ if (m_Pos >= m_End) {
+ throw(runtime_error("Attempted to read past end of file"));
+ } else {
+ m_Word = *m_Pos++;
+ m_WordMask = 128;
+ }
+ }
+ }
+
+ inline void SkipBytes(unsigned int SkipLength) {
+ FlushByte();
+ if (m_Pos + SkipLength >= m_End) {
+ throw(runtime_error("Attempted to read past end of file"));
+ } else {
+ m_Pos += SkipLength;
+ m_Word = *(m_Pos - 1);
+ }
+ }
private:
- const unsigned char * m_Pos;
- const unsigned char * m_End;
+ const unsigned char *m_Pos;
+ const unsigned char *m_End;
- u8 m_Word;
- unsigned int m_WordMask;
+ u8 m_Word;
+ unsigned int m_WordMask;
};
@@ -180,69 +163,66 @@ private:
// Konstanten und Hilfsfunktionen
// -----------------------------------------------------------------------------
-namespace
-{
- // -----------------------------------------------------------------------------
- // Konstanten
- // -----------------------------------------------------------------------------
+namespace {
+// -----------------------------------------------------------------------------
+// Konstanten
+// -----------------------------------------------------------------------------
- const u32 MAX_ACCEPTED_FLASH_VERSION = 3; // Die höchste Flash-Dateiversion, die vom Lader akzeptiert wird
+const u32 MAX_ACCEPTED_FLASH_VERSION = 3; // Die höchste Flash-Dateiversion, die vom Lader akzeptiert wird
- // -----------------------------------------------------------------------------
- // Konvertiert SWF-Rechteckdaten in einem Bitstrom in BS_Rect-Objekte
- // -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// Konvertiert SWF-Rechteckdaten in einem Bitstrom in BS_Rect-Objekte
+// -----------------------------------------------------------------------------
- BS_Rect FlashRectToBSRect(BS_VectorImage::SWFBitStream & bs)
- {
- bs.FlushByte();
+BS_Rect FlashRectToBSRect(BS_VectorImage::SWFBitStream &bs) {
+ bs.FlushByte();
- // Feststellen mit wie vielen Bits die einzelnen Komponenten kodiert sind
- u32 BitsPerValue = bs.GetBits(5);
+ // Feststellen mit wie vielen Bits die einzelnen Komponenten kodiert sind
+ u32 BitsPerValue = bs.GetBits(5);
- // Die einzelnen Komponenten einlesen
- s32 XMin = bs.GetSignedBits(BitsPerValue);
- s32 XMax = bs.GetSignedBits(BitsPerValue);
- s32 YMin = bs.GetSignedBits(BitsPerValue);
- s32 YMax = bs.GetSignedBits(BitsPerValue);
+ // Die einzelnen Komponenten einlesen
+ s32 XMin = bs.GetSignedBits(BitsPerValue);
+ s32 XMax = bs.GetSignedBits(BitsPerValue);
+ s32 YMin = bs.GetSignedBits(BitsPerValue);
+ s32 YMax = bs.GetSignedBits(BitsPerValue);
- return BS_Rect(XMin, YMin, XMax + 1, YMax + 1);
- }
+ return BS_Rect(XMin, YMin, XMax + 1, YMax + 1);
+}
- // -----------------------------------------------------------------------------
- // Konvertiert SWF-Farben in AntiGrain Farben
- // -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// Konvertiert SWF-Farben in AntiGrain Farben
+// -----------------------------------------------------------------------------
- agg::rgba8 FlashColorToAGGRGBA8(unsigned int FlashColor)
- {
- agg::rgba8 ResultColor((FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff, FlashColor >> 24);
- ResultColor.premultiply();
- return ResultColor;
- }
+agg::rgba8 FlashColorToAGGRGBA8(unsigned int FlashColor) {
+ agg::rgba8 ResultColor((FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff, FlashColor >> 24);
+ ResultColor.premultiply();
+ return ResultColor;
+}
- // -----------------------------------------------------------------------------
- // Berechnet die Bounding-Box eines BS_VectorImageElement
- // -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// Berechnet die Bounding-Box eines BS_VectorImageElement
+// -----------------------------------------------------------------------------
+
+struct CBBGetId {
+ CBBGetId(const BS_VectorImageElement &VectorImageElement_) : VectorImageElement(VectorImageElement_) {}
+ unsigned operator [](unsigned i) const {
+ return VectorImageElement.GetPathInfo(i).GetID();
+ }
+ const BS_VectorImageElement &VectorImageElement;
+};
- struct CBBGetId
- {
- CBBGetId(const BS_VectorImageElement & VectorImageElement_) : VectorImageElement(VectorImageElement_) {}
- unsigned operator [] (unsigned i) const { return VectorImageElement.GetPathInfo(i).GetID(); }
- const BS_VectorImageElement & VectorImageElement;
- };
+BS_Rect CalculateBoundingBox(const BS_VectorImageElement &VectorImageElement) {
+ agg::path_storage Path = VectorImageElement.GetPaths();
+ CBBGetId IdSource(VectorImageElement);
- BS_Rect CalculateBoundingBox(const BS_VectorImageElement & VectorImageElement)
- {
- agg::path_storage Path = VectorImageElement.GetPaths();
- CBBGetId IdSource(VectorImageElement);
+ double x1, x2, y1, y2;
+ agg::bounding_rect(Path, IdSource, 0, VectorImageElement.GetPathCount(), &x1, &y1, &x2, &y2);
- double x1, x2, y1, y2;
- agg::bounding_rect(Path, IdSource, 0, VectorImageElement.GetPathCount(), &x1, &y1, &x2, &y2);
-
- return BS_Rect(static_cast<int>(x1), static_cast<int>(y1), static_cast<int>(x2) + 1, static_cast<int>(y2) + 1);
- }
+ return BS_Rect(static_cast<int>(x1), static_cast<int>(y1), static_cast<int>(x2) + 1, static_cast<int>(y2) + 1);
+}
}
@@ -250,41 +230,36 @@ namespace
// Konstruktion
// -----------------------------------------------------------------------------
-BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int FileSize, bool & Success)
-{
+BS_VectorImage::BS_VectorImage(const unsigned char *pFileData, unsigned int FileSize, bool &Success) {
Success = false;
// Bitstream-Objekt erzeugen
// Im Folgenden werden die Dateidaten aus diesem ausgelesen.
SWFBitStream bs(pFileData, FileSize);
- try
- {
+ try {
// SWF-Signatur überprüfen
u32 Signature[3];
Signature[0] = bs.GetU8();
Signature[1] = bs.GetU8();
Signature[2] = bs.GetU8();
if (Signature[0] != 'F' ||
- Signature[1] != 'W' ||
- Signature[2] != 'S')
- {
+ Signature[1] != 'W' ||
+ Signature[2] != 'S') {
BS_LOG_ERRORLN("File is not a valid SWF-file");
return;
}
// Versionsangabe überprüfen
u32 Version = bs.GetU8();
- if (Version > MAX_ACCEPTED_FLASH_VERSION)
- {
+ if (Version > MAX_ACCEPTED_FLASH_VERSION) {
BS_LOG_ERRORLN("File is of version %d. Highest accepted version is %d.", Version, MAX_ACCEPTED_FLASH_VERSION);
return;
}
// Dateigröße auslesen und mit der tatsächlichen Größe vergleichen
u32 StoredFileSize = bs.GetU32();
- if (StoredFileSize != FileSize)
- {
+ if (StoredFileSize != FileSize) {
BS_LOG_ERRORLN("File is not a valid SWF-file");
return;
}
@@ -299,8 +274,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
// Tags parsen
// Da wir uns nur für das erste DefineShape-Tag interessieren
bool KeepParsing = true;
- while (KeepParsing)
- {
+ while (KeepParsing) {
// Tags beginnen immer an Bytegrenzen
bs.FlushByte();
@@ -310,8 +284,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
u32 TagLength = TagTypeAndLength & 0x3f;
if (TagLength == 0x3f) TagLength = bs.GetU32();
- switch (TagType)
- {
+ switch (TagType) {
case 2:
// DefineShape
Success = ParseDefineShape(2, bs);
@@ -330,8 +303,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
}
}
- catch (runtime_error & e)
- {
+ catch (runtime_error &e) {
// Fehler loggen und Funktion verlassen
// Success ist somit "false" und signalisiert dem Programmierer, dass die Konstruktion fehlgeschlagen ist.
BS_LOG_ERRORLN("The following exception occured while parsing a SWF-file: %s", e.what());
@@ -345,8 +317,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
// -----------------------------------------------------------------------------
-bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
-{
+bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs) {
u32 ShapeID = bs.GetU16();
// Bounding Box auslesen
@@ -368,13 +339,11 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
// ------------------
bool EndOfShapeDiscovered = false;
- while (!EndOfShapeDiscovered)
- {
+ while (!EndOfShapeDiscovered) {
u32 TypeFlag = bs.GetBits(1);
// Non-Edge Record
- if (TypeFlag == 0)
- {
+ if (TypeFlag == 0) {
// Feststellen welche Parameter gesetzt werden
u32 StateNewStyles = bs.GetBits(1);
u32 StateLineStyle = bs.GetBits(1);
@@ -386,43 +355,37 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
if (!StateNewStyles && !StateLineStyle && !StateFillStyle0 && !StateFillStyle1 && !StateMoveTo)
EndOfShapeDiscovered = true;
// Parameter dekodieren
- else
- {
+ else {
s32 MoveDeltaX = 0;
s32 MoveDeltaY = 0;
- if (StateMoveTo)
- {
+ if (StateMoveTo) {
u32 MoveToBits = bs.GetBits(5);
MoveDeltaX = bs.GetSignedBits(MoveToBits);
MoveDeltaY = bs.GetSignedBits(MoveToBits);
}
- if (StateFillStyle0)
- {
+ if (StateFillStyle0) {
if (NumFillBits > 0)
FillStyle0 = bs.GetBits(NumFillBits);
else
FillStyle0 = 0;
}
- if (StateFillStyle1)
- {
+ if (StateFillStyle1) {
if (NumFillBits > 0)
FillStyle1 = bs.GetBits(NumFillBits);
else
FillStyle1 = 0;
}
- if (StateLineStyle)
- {
+ if (StateLineStyle) {
if (NumLineBits)
LineStyle = bs.GetBits(NumLineBits);
else
NumLineBits = 0;
}
- if (StateNewStyles)
- {
+ if (StateNewStyles) {
// An dieser Stelle werden in Flash die alten Style-Definitionen verworfen und mit den neuen überschrieben.
// Es wird ein neues Element begonnen.
m_Elements.resize(m_Elements.size() + 1);
@@ -430,8 +393,7 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
}
// Ein neuen Pfad erzeugen, es sei denn, es wurden nur neue Styles definiert
- if (StateLineStyle || StateFillStyle0 || StateFillStyle1 || StateMoveTo)
- {
+ if (StateLineStyle || StateFillStyle0 || StateFillStyle1 || StateMoveTo) {
// Letzte Zeichenposition merken, beim Aufruf von start_new_path() wird die Zeichenpostionen auf 0, 0 zurückgesetzt
double LastX = m_Elements.back().m_Paths.last_x();
double LastY = m_Elements.back().m_Paths.last_y();
@@ -449,14 +411,12 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
}
}
// Edge Record
- else
- {
+ else {
u32 EdgeFlag = bs.GetBits(1);
u32 NumBits = bs.GetBits(4) + 2;
// Curved edge
- if (EdgeFlag == 0)
- {
+ if (EdgeFlag == 0) {
s32 ControlDeltaX = bs.GetSignedBits(NumBits);
s32 ControlDeltaY = bs.GetSignedBits(NumBits);
s32 AnchorDeltaX = bs.GetSignedBits(NumBits);
@@ -469,19 +429,15 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY);
}
// Staight edge
- else
- {
+ else {
s32 DeltaX = 0;
s32 DeltaY = 0;
u32 GeneralLineFlag = bs.GetBits(1);
- if (GeneralLineFlag)
- {
+ if (GeneralLineFlag) {
DeltaX = bs.GetSignedBits(NumBits);
DeltaY = bs.GetSignedBits(NumBits);
- }
- else
- {
+ } else {
u32 VertLineFlag = bs.GetBits(1);
if (VertLineFlag)
DeltaY = bs.GetSignedBits(NumBits);
@@ -504,8 +460,7 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
// -----------------------------------------------------------------------------
-bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsigned int & NumFillBits, unsigned int & NumLineBits)
-{
+bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream &bs, unsigned int &NumFillBits, unsigned int &NumLineBits) {
bs.FlushByte();
// Fillstyles parsen
@@ -518,15 +473,12 @@ bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsi
// Alle Fillstyles einlesen, falls ein Fillstyle mit Typ != 0 gefunden wird, wird das Parsen abgebrochen.
// Es wird nur "solid fill" (Typ 0) unterstützt.
m_Elements.back().m_FillStyles.reserve(FillStyleCount);
- for (unsigned int i = 0; i < FillStyleCount; ++i)
- {
+ for (unsigned int i = 0; i < FillStyleCount; ++i) {
u8 Type = bs.GetU8();
u32 Color;
- if (ShapeType == 3)
- {
+ if (ShapeType == 3) {
Color = (bs.GetU8() << 16) | (bs.GetU8() << 8) | bs.GetU8() | (bs.GetU8() << 24);
- }
- else
+ } else
Color = bs.GetBits(24) | (0xff << 24);
if (Type != 0) return false;
@@ -542,8 +494,7 @@ bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsi
// Alle Linestyles einlesen
m_Elements.back().m_LineStyles.reserve(LineStyleCount);
- for (unsigned int i = 0; i < LineStyleCount; ++i)
- {
+ for (unsigned int i = 0; i < LineStyleCount; ++i) {
double Width = bs.GetU16();
u32 Color;
if (ShapeType == 3)
@@ -564,8 +515,7 @@ bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsi
// -----------------------------------------------------------------------------
-bool BS_VectorImage::Fill(const BS_Rect* pFillRect, unsigned int Color)
-{
+bool BS_VectorImage::Fill(const BS_Rect *pFillRect, unsigned int Color) {
BS_LOG_ERRORLN("Fill() is not supported.");
return false;
}
@@ -573,16 +523,14 @@ bool BS_VectorImage::Fill(const BS_Rect* pFillRect, unsigned int Color)
// -----------------------------------------------------------------------------
-unsigned int BS_VectorImage::GetPixel(int X, int Y)
-{
+unsigned int BS_VectorImage::GetPixel(int X, int Y) {
BS_LOG_ERRORLN("GetPixel() is not supported. Returning black.");
return 0;
}
// -----------------------------------------------------------------------------
-bool BS_VectorImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride)
-{
+bool BS_VectorImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
BS_LOG_ERRORLN("SetContent() is not supported.");
return 0;
}
diff --git a/engines/sword25/gfx/image/vectorimage.h b/engines/sword25/gfx/image/vectorimage.h
index 85685121f2..f791a36f03 100644
--- a/engines/sword25/gfx/image/vectorimage.h
+++ b/engines/sword25/gfx/image/vectorimage.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,22 +53,29 @@ namespace Sword25 {
class BS_VectorImage;
/**
- @brief Pfadinformationen zu BS_VectorImageElement Objekten
+ @brief Pfadinformationen zu BS_VectorImageElement Objekten
- Jedes BS_VectorImageElement besteht aus Kantenzügen, oder auch Pfaden. Jeder dieser Pfad hat Eigenschaften, die in Objekten diesen Typs
- gespeichert werden.
+ Jedes BS_VectorImageElement besteht aus Kantenzügen, oder auch Pfaden. Jeder dieser Pfad hat Eigenschaften, die in Objekten diesen Typs
+ gespeichert werden.
*/
-class BS_VectorPathInfo
-{
+class BS_VectorPathInfo {
public:
BS_VectorPathInfo(unsigned int ID, unsigned int LineStyle, unsigned int FillStyle0, unsigned int FillStyle1) :
- m_ID(ID), m_LineStyle(LineStyle), m_FillStyle0(FillStyle0), m_FillStyle1(FillStyle1) {};
+ m_ID(ID), m_LineStyle(LineStyle), m_FillStyle0(FillStyle0), m_FillStyle1(FillStyle1) {};
- unsigned int GetID() const { return m_ID; }
- unsigned int GetLineStyle() const { return m_LineStyle; }
- unsigned int GetFillStyle0() const { return m_FillStyle0; }
- unsigned int GetFillStyle1() const { return m_FillStyle1; }
+ unsigned int GetID() const {
+ return m_ID;
+ }
+ unsigned int GetLineStyle() const {
+ return m_LineStyle;
+ }
+ unsigned int GetFillStyle0() const {
+ return m_FillStyle0;
+ }
+ unsigned int GetFillStyle1() const {
+ return m_FillStyle1;
+ }
private:
unsigned int m_ID;
@@ -79,106 +86,136 @@ private:
/**
- @brief Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil der Graphik definieren.
- Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild.
+ @brief Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil der Graphik definieren.
+ Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild.
*/
-class BS_VectorImageElement
-{
-friend BS_VectorImage;
+class BS_VectorImageElement {
+ friend BS_VectorImage;
public:
- const agg::path_storage & GetPaths() const { return m_Paths; }
- unsigned int GetPathCount() const { return m_PathInfos.size(); }
- const BS_VectorPathInfo & GetPathInfo(unsigned int PathNr) const { BS_ASSERT(PathNr < GetPathCount()); return m_PathInfos[PathNr]; }
+ const agg::path_storage &GetPaths() const {
+ return m_Paths;
+ }
+ unsigned int GetPathCount() const {
+ return m_PathInfos.size();
+ }
+ const BS_VectorPathInfo &GetPathInfo(unsigned int PathNr) const {
+ BS_ASSERT(PathNr < GetPathCount());
+ return m_PathInfos[PathNr];
+ }
- double GetLineStyleWidth(unsigned int LineStyle) const
- {
+ double GetLineStyleWidth(unsigned int LineStyle) const {
BS_ASSERT(LineStyle < m_LineStyles.size());
return m_LineStyles[LineStyle].Width;
}
- unsigned int GetLineStyleCount() const { return m_LineStyles.size(); }
+ unsigned int GetLineStyleCount() const {
+ return m_LineStyles.size();
+ }
- const agg::rgba8 & GetLineStyleColor(unsigned int LineStyle) const
- {
+ const agg::rgba8 &GetLineStyleColor(unsigned int LineStyle) const {
BS_ASSERT(LineStyle < m_LineStyles.size());
return m_LineStyles[LineStyle].Color;
}
- unsigned int GetFillStyleCount() const { return m_FillStyles.size(); }
+ unsigned int GetFillStyleCount() const {
+ return m_FillStyles.size();
+ }
- const agg::rgba8 & GetFillStyleColor(unsigned int FillStyle) const
- {
+ const agg::rgba8 &GetFillStyleColor(unsigned int FillStyle) const {
BS_ASSERT(FillStyle < m_FillStyles.size());
return m_FillStyles[FillStyle];
}
- const BS_Rect & GetBoundingBox() const { return m_BoundingBox; }
+ const BS_Rect &GetBoundingBox() const {
+ return m_BoundingBox;
+ }
private:
- struct LineStyleType
- {
- LineStyleType(double Width_, const agg::rgba8 & Color_) : Width(Width_), Color(Color_) {};
- double Width;
- agg::rgba8 Color;
+ struct LineStyleType {
+ LineStyleType(double Width_, const agg::rgba8 &Color_) : Width(Width_), Color(Color_) {};
+ double Width;
+ agg::rgba8 Color;
};
- agg::path_storage m_Paths;
- Common::Array<BS_VectorPathInfo> m_PathInfos;
- Common::Array<LineStyleType> m_LineStyles;
- Common::Array<agg::rgba8> m_FillStyles;
- BS_Rect m_BoundingBox;
+ agg::path_storage m_Paths;
+ Common::Array<BS_VectorPathInfo> m_PathInfos;
+ Common::Array<LineStyleType> m_LineStyles;
+ Common::Array<agg::rgba8> m_FillStyles;
+ BS_Rect m_BoundingBox;
};
/**
- @brief Eine Vektorgraphik
+ @brief Eine Vektorgraphik
- Objekte dieser Klasse enthalten die Informationen eines SWF-Shapes.
+ Objekte dieser Klasse enthalten die Informationen eines SWF-Shapes.
*/
-class BS_VectorImage : public BS_Image
-{
+class BS_VectorImage : public BS_Image {
public:
- BS_VectorImage(const unsigned char * pFileData, unsigned int FileSize, bool & Success);
+ BS_VectorImage(const unsigned char *pFileData, unsigned int FileSize, bool &Success);
- unsigned int GetElementCount() const { return m_Elements.size(); }
- const BS_VectorImageElement & GetElement(unsigned int ElementNr) const
- {
+ unsigned int GetElementCount() const {
+ return m_Elements.size();
+ }
+ const BS_VectorImageElement &GetElement(unsigned int ElementNr) const {
BS_ASSERT(ElementNr < m_Elements.size());
return m_Elements[ElementNr];
}
- const BS_Rect & GetBoundingBox() const { return m_BoundingBox; }
+ const BS_Rect &GetBoundingBox() const {
+ return m_BoundingBox;
+ }
//
// Die abstrakten Methoden von BS_Image
//
- virtual int GetWidth() const { return m_BoundingBox.GetWidth(); }
- virtual int GetHeight() const { return m_BoundingBox.GetHeight(); }
- virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
- virtual bool Fill(const BS_Rect* pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0));
+ virtual int GetWidth() const {
+ return m_BoundingBox.GetWidth();
+ }
+ virtual int GetHeight() const {
+ return m_BoundingBox.GetHeight();
+ }
+ virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const {
+ return BS_GraphicEngine::CF_ARGB32;
+ }
+ virtual bool Fill(const BS_Rect *pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0));
virtual unsigned int GetPixel(int X, int Y);
- virtual bool IsBlitSource() const { return true; }
- virtual bool IsBlitTarget() const { return false; }
- virtual bool IsScalingAllowed() const { return true; }
- virtual bool IsFillingAllowed() const { return false; }
- virtual bool IsAlphaAllowed() const { return true; }
- virtual bool IsColorModulationAllowed() const { return true; }
- virtual bool IsSetContentAllowed() const { return false; }
+ virtual bool IsBlitSource() const {
+ return true;
+ }
+ virtual bool IsBlitTarget() const {
+ return false;
+ }
+ virtual bool IsScalingAllowed() const {
+ return true;
+ }
+ virtual bool IsFillingAllowed() const {
+ return false;
+ }
+ virtual bool IsAlphaAllowed() const {
+ return true;
+ }
+ virtual bool IsColorModulationAllowed() const {
+ return true;
+ }
+ virtual bool IsSetContentAllowed() const {
+ return false;
+ }
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
virtual bool Blit(int PosX = 0, int PosY = 0,
- int Flipping = FLIP_NONE,
- BS_Rect* pPartRect = NULL,
- unsigned int Color = BS_ARGB(255, 255, 255, 255),
- int Width = -1, int Height = -1);
+ int Flipping = FLIP_NONE,
+ BS_Rect *pPartRect = NULL,
+ unsigned int Color = BS_ARGB(255, 255, 255, 255),
+ int Width = -1, int Height = -1);
class SWFBitStream;
private:
- bool ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs);
- bool ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsigned int & NumFillBits, unsigned int & NumLineBits);
+ bool ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs);
+ bool ParseStyles(unsigned int ShapeType, SWFBitStream &bs, unsigned int &NumFillBits, unsigned int &NumLineBits);
- Common::Array<BS_VectorImageElement> m_Elements;
- BS_Rect m_BoundingBox;
+ Common::Array<BS_VectorImageElement> m_Elements;
+ BS_Rect m_BoundingBox;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp
index fa776578e3..0c7f93c130 100644
--- a/engines/sword25/gfx/image/vectorimagerenderer.cpp
+++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,10 +49,9 @@ namespace Sword25 {
// CompoundShape
// -----------------------------------------------------------------------------
-class CompoundShape
-{
+class CompoundShape {
public:
- CompoundShape(const BS_VectorImageElement & VectorImageElement) :
+ CompoundShape(const BS_VectorImageElement &VectorImageElement) :
m_ImageElement(VectorImageElement),
m_Path(VectorImageElement.GetPaths()),
m_Affine(),
@@ -60,29 +59,28 @@ public:
m_Trans(m_Curve, m_Affine)
{}
- unsigned operator [] (unsigned i) const
- {
+ unsigned operator [](unsigned i) const {
return m_ImageElement.GetPathInfo(i).GetID();
}
- unsigned paths() const { return m_ImageElement.GetPathCount(); }
+ unsigned paths() const {
+ return m_ImageElement.GetPathCount();
+ }
- void rewind(unsigned path_id)
- {
+ void rewind(unsigned path_id) {
m_Trans.rewind(path_id);
}
- unsigned vertex(double* x, double* y)
- {
+ unsigned vertex(double *x, double *y) {
return m_Trans.vertex(x, y);
}
private:
- const BS_VectorImageElement & m_ImageElement;
- agg::path_storage m_Path;
- agg::trans_affine m_Affine;
- agg::conv_curve<agg::path_storage> m_Curve;
- agg::conv_transform< agg::conv_curve<agg::path_storage> > m_Trans;
+ const BS_VectorImageElement &m_ImageElement;
+ agg::path_storage m_Path;
+ agg::trans_affine m_Affine;
+ agg::conv_curve<agg::path_storage> m_Curve;
+ agg::conv_transform< agg::conv_curve<agg::path_storage> > m_Trans;
};
@@ -90,29 +88,25 @@ private:
// StyleHandler
// -----------------------------------------------------------------------------
-class StyleHandler
-{
+class StyleHandler {
public:
- StyleHandler(const BS_VectorImageElement & VectorImageElement) : m_ImageElement(VectorImageElement) {}
+ StyleHandler(const BS_VectorImageElement &VectorImageElement) : m_ImageElement(VectorImageElement) {}
- bool is_solid(unsigned int style) const
- {
+ bool is_solid(unsigned int style) const {
return true;
}
- const agg::rgba8 & color(unsigned style) const
- {
+ const agg::rgba8 &color(unsigned style) const {
return m_ImageElement.GetFillStyleColor(style);
}
- void generate_span(agg::rgba8 * span, int x, int y, unsigned len, unsigned style)
- {
+ void generate_span(agg::rgba8 *span, int x, int y, unsigned len, unsigned style) {
// Wird nicht benutzt
return;
}
private:
- const BS_VectorImageElement & m_ImageElement;
+ const BS_VectorImageElement &m_ImageElement;
};
@@ -121,21 +115,19 @@ private:
// -----------------------------------------------------------------------------
BS_VectorImageRenderer::BS_VectorImageRenderer() :
- PixelFormat(rbuf)
-{
+ PixelFormat(rbuf) {
}
// -----------------------------------------------------------------------------
-bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
- float ScaleFactorX, float ScaleFactorY,
- unsigned int & Width, unsigned int & Height,
- Common::Array<char> & ImageData,
- float LineScaleFactor,
- bool NoAlphaShapes)
-{
+bool BS_VectorImageRenderer::Render(const BS_VectorImage &VectorImage,
+ float ScaleFactorX, float ScaleFactorY,
+ unsigned int &Width, unsigned int &Height,
+ Common::Array<char> & ImageData,
+ float LineScaleFactor,
+ bool NoAlphaShapes) {
Width = static_cast<unsigned int>(VectorImage.GetWidth() * ScaleFactorX);
Height = static_cast<unsigned int>(VectorImage.GetHeight() * ScaleFactorY);
@@ -151,9 +143,8 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
Scale = agg::trans_affine_translation(- VectorImage.GetBoundingBox().left, - VectorImage.GetBoundingBox().top);
Scale *= agg::trans_affine_scaling(ScaleFactorX, ScaleFactorY);
- for (unsigned int element = 0; element < VectorImage.GetElementCount(); ++element)
- {
- const BS_VectorImageElement & CurImageElement = VectorImage.GetElement(element);
+ for (unsigned int element = 0; element < VectorImage.GetElementCount(); ++element) {
+ const BS_VectorImageElement &CurImageElement = VectorImage.GetElement(element);
CompoundShape ImageCompoundShape(CurImageElement);
StyleHandler ImageStyleHandler(CurImageElement);
@@ -164,19 +155,16 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
//----------------------
CompoundRasterizer.clip_box(0, 0, Width, Height);
CompoundRasterizer.reset();
- for(unsigned int i = 0; i < CurImageElement.GetPathCount(); ++i)
- {
+ for (unsigned int i = 0; i < CurImageElement.GetPathCount(); ++i) {
unsigned int FillStyle0 = CurImageElement.GetPathInfo(i).GetFillStyle0();
unsigned int FillStyle1 = CurImageElement.GetPathInfo(i).GetFillStyle1();
- if (NoAlphaShapes)
- {
+ if (NoAlphaShapes) {
if (FillStyle0 != 0 && CurImageElement.GetFillStyleColor(FillStyle0 - 1).a != 255) FillStyle0 = 0;
if (FillStyle1 != 0 && CurImageElement.GetFillStyleColor(FillStyle1 - 1).a != 255) FillStyle1 = 0;
}
- if(FillStyle0 != 0 || FillStyle1 != 0)
- {
+ if (FillStyle0 != 0 || FillStyle1 != 0) {
CompoundRasterizer.styles(FillStyle0 - 1, FillStyle1 - 1);
CompoundRasterizer.add_path(Shape, CurImageElement.GetPathInfo(i).GetID());
}
@@ -189,13 +177,11 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
Rasterizer.clip_box(0, 0, Width, Height);
Stroke.line_join(agg::round_join);
Stroke.line_cap(agg::round_cap);
- for(unsigned int i = 0; i < CurImageElement.GetPathCount(); ++i)
- {
+ for (unsigned int i = 0; i < CurImageElement.GetPathCount(); ++i) {
Rasterizer.reset();
-
+
unsigned int CurrentLineStyle = CurImageElement.GetPathInfo(i).GetLineStyle();
- if (CurrentLineStyle != 0)
- {
+ if (CurrentLineStyle != 0) {
Stroke.width(ScaleFactorX * CurImageElement.GetLineStyleWidth(CurrentLineStyle - 1) * LineScaleFactor);
Rasterizer.add_path(Stroke, CurImageElement.GetPathInfo(i).GetID());
ScanlineRenderer.color(CurImageElement.GetLineStyleColor(CurrentLineStyle - 1));
@@ -203,9 +189,9 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
// Die SWF-Frames enthalten zum Teil Reste von grünen Linien, die wohl von Bernd als Umriss benutzt wurden.
// Damit diese Reste nicht störend auffallen werden grüne Linien schlichtweg ignoriert.
if (!(CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).a == 255 &&
- CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).r == 0 &&
- CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).g == 255 &&
- CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).b == 0))
+ CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).r == 0 &&
+ CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).g == 255 &&
+ CurImageElement.GetLineStyleColor(CurrentLineStyle - 1).b == 0))
agg::render_scanlines(Rasterizer, Scanline, ScanlineRenderer);
}
}
diff --git a/engines/sword25/gfx/image/vectorimagerenderer.h b/engines/sword25/gfx/image/vectorimagerenderer.h
index 2712728b1f..ed073abb56 100644
--- a/engines/sword25/gfx/image/vectorimagerenderer.h
+++ b/engines/sword25/gfx/image/vectorimagerenderer.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,20 +58,19 @@ class BS_VectorImage;
/**
- @brief Rendert BS_VectorImage Objekte
+ @brief Rendert BS_VectorImage Objekte
*/
-class BS_VectorImageRenderer
-{
+class BS_VectorImageRenderer {
public:
BS_VectorImageRenderer();
- bool Render(const BS_VectorImage & VectorImage,
- float ScaleFactorX, float ScaleFactorY,
- unsigned int & Width, unsigned int & Height,
- Common::Array<char> & ImageData,
- float LineScaleFactor = 1.0f,
- bool NoAlphaShapes = false);
+ bool Render(const BS_VectorImage &VectorImage,
+ float ScaleFactorX, float ScaleFactorY,
+ unsigned int &Width, unsigned int &Height,
+ Common::Array<char> & ImageData,
+ float LineScaleFactor = 1.0f,
+ bool NoAlphaShapes = false);
private:
typedef agg::pixfmt_rgba32_pre PixelFormatType;
diff --git a/engines/sword25/gfx/opengl/glimage.cpp b/engines/sword25/gfx/opengl/glimage.cpp
index 54d660aa7f..1434a93e4e 100644
--- a/engines/sword25/gfx/opengl/glimage.cpp
+++ b/engines/sword25/gfx/opengl/glimage.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,21 +50,19 @@ namespace Sword25 {
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
-BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
+BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :
m_Sprite(0),
m_Width(0),
- m_Height(0)
-{
+ m_Height(0) {
Result = false;
- BS_PackageManager * pPackage = static_cast<BS_PackageManager*>(BS_Kernel::GetInstance()->GetService("package"));
+ BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->GetService("package"));
BS_ASSERT(pPackage);
// Datei laden
- char* pFileData;
+ char *pFileData;
unsigned int FileSize;
- if (!(pFileData = (char*) pPackage->GetFile(Filename, &FileSize)))
- {
+ if (!(pFileData = (char *) pPackage->GetFile(Filename, &FileSize))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", Filename.c_str());
return;
}
@@ -72,16 +70,14 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
// Bildeigenschaften bestimmen
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
int Pitch;
- if (!BS_ImageLoader::ExtractImageProperties(pFileData, FileSize, ColorFormat, m_Width, m_Height))
- {
+ if (!BS_ImageLoader::ExtractImageProperties(pFileData, FileSize, ColorFormat, m_Width, m_Height)) {
BS_LOG_ERRORLN("Could not read image properties.");
return;
}
// Das Bild dekomprimieren
- char * pUncompressedData;
- if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch))
- {
+ char *pUncompressedData;
+ if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) {
BS_LOG_ERRORLN("Could not decode image.");
return;
}
@@ -91,11 +87,10 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
// GLS-Sprite mit den Bilddaten erstellen
GLS_Result GLSResult = GLS_NewSprite(m_Width, m_Height,
- (ColorFormat == BS_GraphicEngine::CF_ARGB32) ? GLS_True : GLS_False,
- pUncompressedData,
- &m_Sprite);
- if (Result != GLS_OK)
- {
+ (ColorFormat == BS_GraphicEngine::CF_ARGB32) ? GLS_True : GLS_False,
+ pUncompressedData,
+ &m_Sprite);
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
return;
}
@@ -109,20 +104,18 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
// -----------------------------------------------------------------------------
-BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool & Result) :
+BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool &Result) :
m_Sprite(0),
m_Width(Width),
- m_Height(Height)
-{
+ m_Height(Height) {
Result = false;
// GLS-Sprite mit den Bilddaten erstellen
GLS_Result GLSResult = GLS_NewSprite(m_Width, m_Height,
- GLS_True,
- 0,
- &m_Sprite);
- if (GLSResult != GLS_OK)
- {
+ GLS_True,
+ 0,
+ &m_Sprite);
+ if (GLSResult != GLS_OK) {
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
return;
}
@@ -133,34 +126,29 @@ BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool & Result) :
// -----------------------------------------------------------------------------
-BS_GLImage::~BS_GLImage()
-{
+BS_GLImage::~BS_GLImage() {
if (m_Sprite) GLS_DeleteSprite(m_Sprite);
}
// -----------------------------------------------------------------------------
-bool BS_GLImage::Fill(const BS_Rect* pFillRect, unsigned int Color)
-{
+bool BS_GLImage::Fill(const BS_Rect *pFillRect, unsigned int Color) {
BS_LOG_ERRORLN("Fill() is not supported.");
return false;
}
// -----------------------------------------------------------------------------
-bool BS_GLImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride)
-{
+bool BS_GLImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
// Überprüfen, ob PixelData ausreichend viele Pixel enthält um ein Bild der Größe Width * Height zu erzeugen
- if (Pixeldata.size() < static_cast<unsigned int>(m_Width * m_Height * 4))
- {
+ if (Pixeldata.size() < static_cast<unsigned int>(m_Width * m_Height * 4)) {
BS_LOG_ERRORLN("PixelData vector is too small to define a 32 bit %dx%d image.", m_Width, m_Height);
return false;
}
// GLS-Sprite mit den Bilddaten füllen
GLS_Result GLSResult = GLS_SetSpriteData(m_Sprite, m_Width, m_Height, &Pixeldata[Offset], Stride / 4);
- if (GLSResult != GLS_OK)
- {
+ if (GLSResult != GLS_OK) {
BS_LOG_ERRORLN("CGLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(GLSResult));
return false;
}
@@ -170,8 +158,7 @@ bool BS_GLImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned
// -----------------------------------------------------------------------------
-unsigned int BS_GLImage::GetPixel(int X, int Y)
-{
+unsigned int BS_GLImage::GetPixel(int X, int Y) {
BS_LOG_ERRORLN("GetPixel() is not supported. Returning black.");
return 0;
}
@@ -179,15 +166,13 @@ unsigned int BS_GLImage::GetPixel(int X, int Y)
// -----------------------------------------------------------------------------
bool BS_GLImage::Blit(int PosX, int PosY,
- int Flipping,
- BS_Rect* pPartRect,
- unsigned int Color,
- int Width, int Height)
-{
+ int Flipping,
+ BS_Rect *pPartRect,
+ unsigned int Color,
+ int Width, int Height) {
// BS_Rect nach GLS_Rect konvertieren
GLS_Rect SubImage;
- if (pPartRect)
- {
+ if (pPartRect) {
SubImage.x1 = pPartRect->left;
SubImage.y1 = pPartRect->top;
SubImage.x2 = pPartRect->right;
@@ -214,11 +199,11 @@ bool BS_GLImage::Blit(int PosX, int PosY,
// Die Bedeutung von FLIP_V und FLIP_H ist vertauscht. Allerdings glaubt der Rest der Engine auch daran, daher war es einfacher diesen Fehler
// weiterzuführen. Bei Gelegenheit ist dieses aber zu ändern.
GLS_Result Result = GLS_Blit(m_Sprite,
- PosX, PosY,
- pPartRect ? &SubImage : 0, &GLSColor,
- (Flipping & BS_Image::FLIP_V) ? GLS_True : GLS_False,
- (Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
- ScaleX, ScaleY);
+ PosX, PosY,
+ pPartRect ? &SubImage : 0, &GLSColor,
+ (Flipping & BS_Image::FLIP_V) ? GLS_True : GLS_False,
+ (Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
+ ScaleX, ScaleY);
if (Result != GLS_OK) BS_LOG_ERRORLN("GLS_Blit() failed. Reason: %s", GLS_ResultString(Result));
return Result == GLS_OK;
diff --git a/engines/sword25/gfx/opengl/glimage.h b/engines/sword25/gfx/opengl/glimage.h
index ae94473778..c5a7480874 100644
--- a/engines/sword25/gfx/opengl/glimage.h
+++ b/engines/sword25/gfx/opengl/glimage.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -51,52 +51,71 @@ namespace Sword25 {
// FORWARD DECLARATION
// -----------------------------------------------------------------------------
-typedef void * GLS_Sprite;
+typedef void *GLS_Sprite;
// -----------------------------------------------------------------------------
// CLASS DEFINITION
// -----------------------------------------------------------------------------
-class BS_GLImage : public BS_Image
-{
+class BS_GLImage : public BS_Image {
public:
- BS_GLImage(const Common::String & Filename, bool & Result);
+ BS_GLImage(const Common::String &Filename, bool &Result);
/**
- @brief Erzeugt ein leeres BS_GLImage
+ @brief Erzeugt ein leeres BS_GLImage
- @param Width die Breite des zu erzeugenden Bildes.
- @param Height die Höhe des zu erzeugenden Bildes
- @param Result gibt dem Aufrufer bekannt, ob der Konstruktor erfolgreich ausgeführt wurde. Wenn es nach dem Aufruf false enthalten sollte,
- dürfen keine Methoden am Objekt aufgerufen werden und das Objekt ist sofort zu zerstören.
+ @param Width die Breite des zu erzeugenden Bildes.
+ @param Height die Höhe des zu erzeugenden Bildes
+ @param Result gibt dem Aufrufer bekannt, ob der Konstruktor erfolgreich ausgeführt wurde. Wenn es nach dem Aufruf false enthalten sollte,
+ dürfen keine Methoden am Objekt aufgerufen werden und das Objekt ist sofort zu zerstören.
*/
- BS_GLImage(unsigned int Width, unsigned int Height, bool & Result);
+ BS_GLImage(unsigned int Width, unsigned int Height, bool &Result);
virtual ~BS_GLImage();
- virtual int GetWidth() const { return m_Width; }
- virtual int GetHeight() const { return m_Height; }
- virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
-
- virtual bool Blit(int PosX = 0, int PosY = 0,
- int Flipping = BS_Image::FLIP_NONE,
- BS_Rect* pPartRect = NULL,
- unsigned int Color = BS_ARGB(255, 255, 255, 255),
- int Width = -1, int Height = -1);
- virtual bool Fill(const BS_Rect* pFillRect, unsigned int Color);
+ virtual int GetWidth() const {
+ return m_Width;
+ }
+ virtual int GetHeight() const {
+ return m_Height;
+ }
+ virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const {
+ return BS_GraphicEngine::CF_ARGB32;
+ }
+
+ virtual bool Blit(int PosX = 0, int PosY = 0,
+ int Flipping = BS_Image::FLIP_NONE,
+ BS_Rect *pPartRect = NULL,
+ unsigned int Color = BS_ARGB(255, 255, 255, 255),
+ int Width = -1, int Height = -1);
+ virtual bool Fill(const BS_Rect *pFillRect, unsigned int Color);
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0);
virtual unsigned int GetPixel(int X, int Y);
- virtual bool IsBlitSource() const { return true; }
- virtual bool IsBlitTarget() const { return false; }
- virtual bool IsScalingAllowed() const { return true; }
- virtual bool IsFillingAllowed() const { return false; }
- virtual bool IsAlphaAllowed() const { return true; }
- virtual bool IsColorModulationAllowed() const { return true; }
- virtual bool IsSetContentAllowed() const { return true; }
+ virtual bool IsBlitSource() const {
+ return true;
+ }
+ virtual bool IsBlitTarget() const {
+ return false;
+ }
+ virtual bool IsScalingAllowed() const {
+ return true;
+ }
+ virtual bool IsFillingAllowed() const {
+ return false;
+ }
+ virtual bool IsAlphaAllowed() const {
+ return true;
+ }
+ virtual bool IsColorModulationAllowed() const {
+ return true;
+ }
+ virtual bool IsSetContentAllowed() const {
+ return true;
+ }
private:
- GLS_Sprite m_Sprite;
- int m_Width;
- int m_Height;
+ GLS_Sprite m_Sprite;
+ int m_Width;
+ int m_Height;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/opengl/glvectorimageblit.cpp b/engines/sword25/gfx/opengl/glvectorimageblit.cpp
index 262153f59e..9368e921e1 100644
--- a/engines/sword25/gfx/opengl/glvectorimageblit.cpp
+++ b/engines/sword25/gfx/opengl/glvectorimageblit.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,64 +50,56 @@ using namespace std;
// -----------------------------------------------------------------------------
-namespace
-{
- const float LINE_SCALE_FACTOR = 1.0f;
+namespace {
+const float LINE_SCALE_FACTOR = 1.0f;
}
// -----------------------------------------------------------------------------
bool BS_VectorImage::Blit(int PosX, int PosY,
- int Flipping,
- BS_Rect* pPartRect,
- unsigned int Color,
- int Width, int Height)
-{
+ int Flipping,
+ BS_Rect *pPartRect,
+ unsigned int Color,
+ int Width, int Height) {
static BS_VectorImageRenderer VectorImageRenderer;
static vector<char> PixelData;
static GLS_Sprite Sprite = 0;
- static BS_VectorImage * OldThis = 0;
- static int OldWidth;
- static int OldHeight;
- static GLS_Rect OldSubImage;
+ static BS_VectorImage *OldThis = 0;
+ static int OldWidth;
+ static int OldHeight;
+ static GLS_Rect OldSubImage;
// Falls Breite oder Höhe 0 sind, muss nichts dargestellt werden.
if (Width == 0 || Height == 0) return true;
// Sprite erstellen, falls es noch nicht erstellt wurde
- if (Sprite == 0)
- {
+ if (Sprite == 0) {
GLS_Result Result = GLS_NewSprite(512, 512, GLS_True, 0, &Sprite);
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(Result));
return false;
}
}
// Feststellen, ob das alte Bild im Cache nicht wiederbenutzt werden kann und neu Berechnet werden muss
- if (!(OldThis == this && OldWidth == Width && OldHeight == Height && Sprite != 0))
- {
+ if (!(OldThis == this && OldWidth == Width && OldHeight == Height && Sprite != 0)) {
float ScaleFactorX = (Width == - 1) ? 1 : static_cast<float>(Width) / static_cast<float>(GetWidth());
- float ScaleFactorY = (Height == - 1) ? 1: static_cast<float>(Height) / static_cast<float>(GetHeight());
+ float ScaleFactorY = (Height == - 1) ? 1 : static_cast<float>(Height) / static_cast<float>(GetHeight());
unsigned int RenderedWidth;
unsigned int RenderedHeight;
- if (!VectorImageRenderer.Render(*this, ScaleFactorX, ScaleFactorY, RenderedWidth, RenderedHeight, PixelData, LINE_SCALE_FACTOR))
- {
+ if (!VectorImageRenderer.Render(*this, ScaleFactorX, ScaleFactorY, RenderedWidth, RenderedHeight, PixelData, LINE_SCALE_FACTOR)) {
BS_LOG_ERRORLN("Call to BS_VectorImageRenderer::Render() failed.");
return false;
}
- if (RenderedWidth > 512 || RenderedHeight > 512)
- {
+ if (RenderedWidth > 512 || RenderedHeight > 512) {
BS_LOG_WARNINGLN("Currently the maximum size for scaled vector images is 512x512.");
return true;
}
GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, &PixelData[0], 0);
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Call to GLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(Result));
return false;
}
@@ -140,11 +132,11 @@ bool BS_VectorImage::Blit(int PosX, int PosY,
// Die Bedeutung von FLIP_V und FLIP_H ist vertauscht. Allerdings glaubt der Rest der Engine auch daran, daher war es einfacher diesen Fehler
// weiterzuführen. Bei Gelegenheit ist dieses aber zu ändern.
GLS_Result Result = GLS_Blit(Sprite,
- PosX, PosY,
- &OldSubImage, &GLSColor,
- (Flipping & BS_Image::FLIP_V) ? GLS_True : GLS_False,
- (Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
- 1.0f, 1.0f);
+ PosX, PosY,
+ &OldSubImage, &GLSColor,
+ (Flipping & BS_Image::FLIP_V) ? GLS_True : GLS_False,
+ (Flipping & BS_Image::FLIP_H) ? GLS_True : GLS_False,
+ 1.0f, 1.0f);
if (Result != GLS_OK) BS_LOG_ERRORLN("GLS_Blit() failed. Reason: %s", GLS_ResultString(Result));
return Result == GLS_OK;
diff --git a/engines/sword25/gfx/opengl/openglgfx.cpp b/engines/sword25/gfx/opengl/openglgfx.cpp
index 7d97828213..612e1c209e 100644
--- a/engines/sword25/gfx/opengl/openglgfx.cpp
+++ b/engines/sword25/gfx/opengl/openglgfx.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -68,16 +68,15 @@ using namespace std;
// CONSTANTS
// -----------------------------------------------------------------------------
-namespace
-{
- const unsigned int BIT_DEPTH = 32;
- const unsigned int BACKBUFFER_COUNT = 1;
- const Common::String PNG_EXTENSION(".png");
- const Common::String PNG_S_EXTENSION("_s.png");
- const Common::String ANI_EXTENSION("_ani.xml");
- const Common::String FNT_EXTENSION("_fnt.xml");
- const Common::String SWF_EXTENSION(".swf");
- const Common::String B25S_EXTENSION(".b25s");
+namespace {
+const unsigned int BIT_DEPTH = 32;
+const unsigned int BACKBUFFER_COUNT = 1;
+const Common::String PNG_EXTENSION(".png");
+const Common::String PNG_S_EXTENSION("_s.png");
+const Common::String ANI_EXTENSION("_ani.xml");
+const Common::String FNT_EXTENSION("_fnt.xml");
+const Common::String SWF_EXTENSION(".swf");
+const Common::String B25S_EXTENSION(".b25s");
}
@@ -85,23 +84,20 @@ namespace
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
-BS_OpenGLGfx::BS_OpenGLGfx(BS_Kernel * pKernel) :
+BS_OpenGLGfx::BS_OpenGLGfx(BS_Kernel *pKernel) :
BS_GraphicEngine(pKernel),
- m_GLspritesInitialized(false)
-{
+ m_GLspritesInitialized(false) {
}
// -----------------------------------------------------------------------------
-BS_OpenGLGfx::~BS_OpenGLGfx()
-{
+BS_OpenGLGfx::~BS_OpenGLGfx() {
if (m_GLspritesInitialized) GLS_Quit();
}
// -----------------------------------------------------------------------------
-BS_Service * BS_OpenGLGfx_CreateObject(BS_Kernel* pKernel)
-{
+BS_Service *BS_OpenGLGfx_CreateObject(BS_Kernel *pKernel) {
return new BS_OpenGLGfx(pKernel);
}
@@ -110,18 +106,15 @@ BS_Service * BS_OpenGLGfx_CreateObject(BS_Kernel* pKernel)
// INTERFACE
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount, bool Windowed)
-{
+bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount, bool Windowed) {
// Warnung ausgeben, wenn eine nicht unterstützte Bittiefe gewählt wurde.
- if (BitDepth != BIT_DEPTH)
- {
+ if (BitDepth != BIT_DEPTH) {
BS_LOG_WARNINGLN("Can't use a bit depth of %d (not supported). Falling back to %d.", BitDepth, BIT_DEPTH);
m_BitDepth = BIT_DEPTH;
}
// Warnung ausgeben, wenn nicht genau ein Backbuffer gewählt wurde.
- if (BackbufferCount != BACKBUFFER_COUNT)
- {
+ if (BackbufferCount != BACKBUFFER_COUNT) {
BS_LOG_WARNINGLN("Can't use %d backbuffers (not supported). Falling back to %d.", BackbufferCount, BACKBUFFER_COUNT);
BackbufferCount = BACKBUFFER_COUNT;
}
@@ -139,8 +132,7 @@ bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount
// GLsprites initialisieren
HWND hwnd = reinterpret_cast<HWND>(BS_Kernel::GetInstance()->GetWindow()->GetWindowHandle());
GLS_Result Result = GLS_InitExternalWindow(Width, Height, Windowed ? GLS_False : GLS_True, hwnd);
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Could not initialize GLsprites. Reason: %s", GLS_ResultString(Result));
return false;
}
@@ -153,7 +145,7 @@ bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount
m_RenderObjectManagerPtr.reset(new BS_RenderObjectManager(Width, Height, BackbufferCount + 1));
// Hauptpanel erstellen
- m_MainPanelPtr = m_RenderObjectManagerPtr->GetTreeRoot()->AddPanel(Width, Height, BS_ARGB(0,0,0,0));
+ m_MainPanelPtr = m_RenderObjectManagerPtr->GetTreeRoot()->AddPanel(Width, Height, BS_ARGB(0, 0, 0, 0));
if (!m_MainPanelPtr.IsValid()) return false;
m_MainPanelPtr->SetVisible(true);
@@ -162,8 +154,7 @@ bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::StartFrame(bool UpdateAll)
-{
+bool BS_OpenGLGfx::StartFrame(bool UpdateAll) {
// Berechnen, wie viel Zeit seit dem letzten Frame vergangen ist.
// Dieser Wert kann über GetLastFrameDuration() von Modulen abgefragt werden, die zeitabhängig arbeiten.
UpdateLastFrameDuration();
@@ -173,8 +164,7 @@ bool BS_OpenGLGfx::StartFrame(bool UpdateAll)
// GLsprites bescheidgeben
GLS_Result Result = GLS_StartFrame();
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Call to GLS_StartFrame() failed. Reason: %s", GLS_ResultString(Result));
return false;
}
@@ -184,23 +174,20 @@ bool BS_OpenGLGfx::StartFrame(bool UpdateAll)
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::EndFrame()
-{
+bool BS_OpenGLGfx::EndFrame() {
// Scene zeichnen
m_RenderObjectManagerPtr->Render();
// Debug-Lines zeichnen
- if (!m_DebugLines.empty())
- {
+ if (!m_DebugLines.empty()) {
glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINES);
Common::Array<DebugLine>::const_iterator iter = m_DebugLines.begin();
- for (; iter != m_DebugLines.end(); ++iter)
- {
- const unsigned int & Color = (*iter).Color;
- const BS_Vertex & Start = (*iter).Start;
- const BS_Vertex & End = (*iter).End;
+ for (; iter != m_DebugLines.end(); ++iter) {
+ const unsigned int &Color = (*iter).Color;
+ const BS_Vertex &Start = (*iter).Start;
+ const BS_Vertex &End = (*iter).End;
glColor4ub((Color >> 16) & 0xff, (Color >> 8) & 0xff, Color & 0xff, Color >> 24);
glVertex2d(Start.X, Start.Y);
@@ -215,8 +202,7 @@ bool BS_OpenGLGfx::EndFrame()
// Flippen
GLS_Result Result = GLS_EndFrame();
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_ERRORLN("Call to GLS_EndFrame() failed. Reason: %s", GLS_ResultString(Result));
return false;
}
@@ -229,27 +215,23 @@ bool BS_OpenGLGfx::EndFrame()
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Panel> BS_OpenGLGfx::GetMainPanel()
-{
+BS_RenderObjectPtr<BS_Panel> BS_OpenGLGfx::GetMainPanel() {
return m_MainPanelPtr;
}
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::SetVsync(bool Vsync)
-{
+void BS_OpenGLGfx::SetVsync(bool Vsync) {
GLS_Result Result = GLS_SetVSync(Vsync ? GLS_True : GLS_False);
if (Result != GLS_OK) BS_LOG_WARNINGLN("Could not set vsync status. Reason: %s", GLS_ResultString(Result));
}
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::GetVsync() const
-{
+bool BS_OpenGLGfx::GetVsync() const {
GLS_Bool Status;
GLS_Result Result = GLS_IsVsync(&Status);
- if (Result != GLS_OK)
- {
+ if (Result != GLS_OK) {
BS_LOG_WARNINGLN("Could not get vsync status. Returning false. Reason: %s", GLS_ResultString(Result));
return false;
}
@@ -259,12 +241,10 @@ bool BS_OpenGLGfx::GetVsync() const
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::Fill(const BS_Rect* FillRectPtr, unsigned int Color)
-{
+bool BS_OpenGLGfx::Fill(const BS_Rect *FillRectPtr, unsigned int Color) {
BS_Rect Rect;
- if (!FillRectPtr)
- {
+ if (!FillRectPtr) {
Rect.left = 0;
Rect.top = 0;
Rect.right = m_Width;
@@ -273,12 +253,12 @@ bool BS_OpenGLGfx::Fill(const BS_Rect* FillRectPtr, unsigned int Color)
}
glBegin(GL_QUADS);
- glColor4ub((Color >> 16) & 0xff, (Color >> 8) & 0xff, Color & 0xff, Color >> 24);
+ glColor4ub((Color >> 16) & 0xff, (Color >> 8) & 0xff, Color & 0xff, Color >> 24);
- glVertex2i(FillRectPtr->left, FillRectPtr->top);
- glVertex2i(FillRectPtr->right, FillRectPtr->top);
- glVertex2i(FillRectPtr->right, FillRectPtr->bottom);
- glVertex2i(FillRectPtr->left, FillRectPtr->bottom);
+ glVertex2i(FillRectPtr->left, FillRectPtr->top);
+ glVertex2i(FillRectPtr->right, FillRectPtr->top);
+ glVertex2i(FillRectPtr->right, FillRectPtr->bottom);
+ glVertex2i(FillRectPtr->left, FillRectPtr->bottom);
glEnd();
return glGetError() == 0;
@@ -286,8 +266,7 @@ bool BS_OpenGLGfx::Fill(const BS_Rect* FillRectPtr, unsigned int Color)
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::GetScreenshot(unsigned int & Width, unsigned int & Height, vector<unsigned int> & Data)
-{
+bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, vector<unsigned int> & Data) {
if (!ReadFramebufferContents(m_Width, m_Height, Data)) return false;
// Die Größe des Framebuffers zurückgeben.
@@ -303,15 +282,13 @@ bool BS_OpenGLGfx::GetScreenshot(unsigned int & Width, unsigned int & Height, ve
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data)
-{
+bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data) {
Data.resize(Width * Height);
glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Data[0]);
if (glGetError() == 0)
return true;
- else
- {
+ else {
Data.clear();
return false;
}
@@ -319,11 +296,9 @@ bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Heig
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::ReverseRGBAComponentOrder(vector<unsigned int> & Data)
-{
+void BS_OpenGLGfx::ReverseRGBAComponentOrder(vector<unsigned int> & Data) {
vector<unsigned int>::iterator It = Data.begin();
- while (It != Data.end())
- {
+ while (It != Data.end()) {
unsigned int Pixel = *It;
*It = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16);
++It;
@@ -332,12 +307,10 @@ void BS_OpenGLGfx::ReverseRGBAComponentOrder(vector<unsigned int> & Data)
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, vector<unsigned int> & Data)
-{
+void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, vector<unsigned int> & Data) {
vector<unsigned int> LineBuffer(Width);
- for (unsigned int Y = 0; Y < Height / 2; ++Y)
- {
+ for (unsigned int Y = 0; Y < Height / 2; ++Y) {
vector<unsigned int>::iterator Line1It = Data.begin() + Y * Width;
vector<unsigned int>::iterator Line2It = Data.begin() + (Height - 1 - Y) * Width;
copy(Line1It, Line1It + Width, LineBuffer.begin());
@@ -350,8 +323,7 @@ void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height
// RESOURCE MANAGING
// -----------------------------------------------------------------------------
-static bool DoesStringEndWith(const Common::String & String, const std::string & OtherString)
-{
+static bool DoesStringEndWith(const Common::String &String, const std::string &OtherString) {
Common::String::size_type StringPos = String.rfind(OtherString);
if (StringPos == Common::String::npos) return false;
@@ -360,24 +332,20 @@ static bool DoesStringEndWith(const Common::String & String, const std::string &
// -----------------------------------------------------------------------------
-BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
-{
+BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) {
BS_ASSERT(CanLoadResource(FileName));
// Bild für den Softwarebuffer laden
- if (DoesStringEndWith(FileName, PNG_S_EXTENSION))
- {
+ if (DoesStringEndWith(FileName, PNG_S_EXTENSION)) {
bool Result;
- BS_SWImage * pImage = new BS_SWImage(FileName, Result);
- if (!Result)
- {
+ BS_SWImage *pImage = new BS_SWImage(FileName, Result);
+ if (!Result) {
delete pImage;
return 0;
}
- BS_BitmapResource * pResource = new BS_BitmapResource(FileName, pImage);
- if (!pResource->IsValid())
- {
+ BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
+ if (!pResource->IsValid()) {
delete pResource;
return 0;
}
@@ -386,19 +354,16 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
}
// Sprite-Bild laden
- if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION))
- {
+ if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION)) {
bool Result;
- BS_GLImage * pImage = new BS_GLImage(FileName, Result);
- if (!Result)
- {
+ BS_GLImage *pImage = new BS_GLImage(FileName, Result);
+ if (!Result) {
delete pImage;
return 0;
}
- BS_BitmapResource * pResource = new BS_BitmapResource(FileName, pImage);
- if (!pResource->IsValid())
- {
+ BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
+ if (!pResource->IsValid()) {
delete pResource;
return 0;
}
@@ -408,33 +373,29 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
// Vectorgraphik laden
- if (DoesStringEndWith(FileName, SWF_EXTENSION))
- {
+ if (DoesStringEndWith(FileName, SWF_EXTENSION)) {
// Pointer auf Package-Manager holen
- BS_PackageManager * pPackage = BS_Kernel::GetInstance()->GetPackage();
+ BS_PackageManager *pPackage = BS_Kernel::GetInstance()->GetPackage();
BS_ASSERT(pPackage);
// Datei laden
- unsigned char* pFileData;
+ unsigned char *pFileData;
unsigned int FileSize;
- if (!(pFileData = static_cast<unsigned char*>(pPackage->GetFile(FileName, &FileSize))))
- {
+ if (!(pFileData = static_cast<unsigned char *>(pPackage->GetFile(FileName, &FileSize)))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", FileName.c_str());
return 0;
}
bool Result;
- BS_VectorImage * pImage = new BS_VectorImage(pFileData, FileSize, Result);
- if (!Result)
- {
+ BS_VectorImage *pImage = new BS_VectorImage(pFileData, FileSize, Result);
+ if (!Result) {
delete pImage;
delete [] pFileData;
return 0;
}
- BS_BitmapResource * pResource = new BS_BitmapResource(FileName, pImage);
- if (!pResource->IsValid())
- {
+ BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
+ if (!pResource->IsValid()) {
delete pResource;
delete [] pFileData;
return 0;
@@ -445,26 +406,22 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
}
// Animation laden
- if (DoesStringEndWith(FileName, ANI_EXTENSION))
- {
- BS_AnimationResource * pResource = new BS_AnimationResource(FileName);
+ if (DoesStringEndWith(FileName, ANI_EXTENSION)) {
+ BS_AnimationResource *pResource = new BS_AnimationResource(FileName);
if (pResource->IsValid())
return pResource;
- else
- {
+ else {
delete pResource;
return 0;
}
}
// Font laden
- if (DoesStringEndWith(FileName, FNT_EXTENSION))
- {
- BS_FontResource * pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName);
+ if (DoesStringEndWith(FileName, FNT_EXTENSION)) {
+ BS_FontResource *pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName);
if (pResource->IsValid())
return pResource;
- else
- {
+ else {
delete pResource;
return 0;
}
@@ -476,13 +433,12 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::CanLoadResource(const Common::String& FileName)
-{
+bool BS_OpenGLGfx::CanLoadResource(const Common::String &FileName) {
return DoesStringEndWith(FileName, PNG_EXTENSION) ||
- DoesStringEndWith(FileName, ANI_EXTENSION) ||
- DoesStringEndWith(FileName, FNT_EXTENSION) ||
- DoesStringEndWith(FileName, SWF_EXTENSION) ||
- DoesStringEndWith(FileName, B25S_EXTENSION);
+ DoesStringEndWith(FileName, ANI_EXTENSION) ||
+ DoesStringEndWith(FileName, FNT_EXTENSION) ||
+ DoesStringEndWith(FileName, SWF_EXTENSION) ||
+ DoesStringEndWith(FileName, B25S_EXTENSION);
}
@@ -490,8 +446,7 @@ bool BS_OpenGLGfx::CanLoadResource(const Common::String& FileName)
// DEBUGGING
// -----------------------------------------------------------------------------
-void BS_OpenGLGfx::DrawDebugLine(const BS_Vertex & Start, const BS_Vertex & End, unsigned int Color)
-{
+void BS_OpenGLGfx::DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color) {
m_DebugLines.push_back(DebugLine(Start, End, Color));
}
@@ -499,8 +454,7 @@ void BS_OpenGLGfx::DrawDebugLine(const BS_Vertex & Start, const BS_Vertex & End,
// PERSISTENZ
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_OpenGLGfx::Persist(BS_OutputPersistenceBlock &Writer) {
bool result = true;
result &= BS_GraphicEngine::Persist(Writer);
@@ -511,8 +465,7 @@ bool BS_OpenGLGfx::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_OpenGLGfx::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_OpenGLGfx::Unpersist(BS_InputPersistenceBlock &Reader) {
bool result = true;
result &= BS_GraphicEngine::Unpersist(Reader);
diff --git a/engines/sword25/gfx/opengl/openglgfx.h b/engines/sword25/gfx/opengl/openglgfx.h
index df0d81cb04..5a7ca8a85e 100644
--- a/engines/sword25/gfx/opengl/openglgfx.h
+++ b/engines/sword25/gfx/opengl/openglgfx.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -67,58 +67,56 @@ class BS_RenderObjectManager;
// CLASS DECLARATION
// -----------------------------------------------------------------------------
-class BS_OpenGLGfx : public BS_GraphicEngine
-{
+class BS_OpenGLGfx : public BS_GraphicEngine {
public:
- BS_OpenGLGfx(BS_Kernel* pKernel);
+ BS_OpenGLGfx(BS_Kernel *pKernel);
virtual ~BS_OpenGLGfx();
// Interface
// ---------
- virtual bool Init(int Width, int Height, int BitDepth, int BackbufferCount, bool Windowed);
- virtual bool StartFrame(bool UpdateAll);
- virtual bool EndFrame();
+ virtual bool Init(int Width, int Height, int BitDepth, int BackbufferCount, bool Windowed);
+ virtual bool StartFrame(bool UpdateAll);
+ virtual bool EndFrame();
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel();
- virtual void SetVsync(bool Vsync);
- virtual bool GetVsync() const;
+ virtual void SetVsync(bool Vsync);
+ virtual bool GetVsync() const;
- virtual bool Fill(const BS_Rect* FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0));
- virtual bool GetScreenshot(unsigned int & Width, unsigned int & Height, Common::Array<unsigned int> & Data);
+ virtual bool Fill(const BS_Rect *FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0));
+ virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> & Data);
// Resource-Managing Methoden
// --------------------------
- virtual BS_Resource* LoadResource(const Common::String& FileName);
- virtual bool CanLoadResource(const Common::String& FileName);
+ virtual BS_Resource *LoadResource(const Common::String &FileName);
+ virtual bool CanLoadResource(const Common::String &FileName);
// Debugging Methoden
// ------------------
- virtual void DrawDebugLine(const BS_Vertex & Start, const BS_Vertex & End, unsigned int Color);
- static const char * GetGLSResultString(GLS_Result Result);
+ virtual void DrawDebugLine(const BS_Vertex &Start, const BS_Vertex &End, unsigned int Color);
+ static const char *GetGLSResultString(GLS_Result Result);
// Persistenz Methoden
// -------------------
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
- bool m_GLspritesInitialized;
+ bool m_GLspritesInitialized;
BS_RenderObjectPtr<BS_Panel> m_MainPanelPtr;
- std::auto_ptr<BS_RenderObjectManager> m_RenderObjectManagerPtr;
+ std::auto_ptr<BS_RenderObjectManager> m_RenderObjectManagerPtr;
- struct DebugLine
- {
- DebugLine(const BS_Vertex & _Start, const BS_Vertex & _End, unsigned int _Color) :
+ struct DebugLine {
+ DebugLine(const BS_Vertex &_Start, const BS_Vertex &_End, unsigned int _Color) :
Start(_Start),
End(_End),
Color(_Color) {};
-
- BS_Vertex Start;
- BS_Vertex End;
- unsigned int Color;
+
+ BS_Vertex Start;
+ BS_Vertex End;
+ unsigned int Color;
};
Common::Array<DebugLine> m_DebugLines;
diff --git a/engines/sword25/gfx/opengl/swimage.cpp b/engines/sword25/gfx/opengl/swimage.cpp
index 1429572767..5eebf44b10 100644
--- a/engines/sword25/gfx/opengl/swimage.cpp
+++ b/engines/sword25/gfx/opengl/swimage.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,21 +50,19 @@ namespace Sword25 {
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
-BS_SWImage::BS_SWImage(const Common::String & Filename, bool & Result) :
+BS_SWImage::BS_SWImage(const Common::String &Filename, bool &Result) :
_ImageDataPtr(0),
m_Width(0),
- m_Height(0)
-{
+ m_Height(0) {
Result = false;
- BS_PackageManager * pPackage = static_cast<BS_PackageManager*>(BS_Kernel::GetInstance()->GetService("package"));
+ BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->GetService("package"));
BS_ASSERT(pPackage);
// Datei laden
- char* pFileData;
+ char *pFileData;
unsigned int FileSize;
- if (!(pFileData = (char*) pPackage->GetFile(Filename, &FileSize)))
- {
+ if (!(pFileData = (char *) pPackage->GetFile(Filename, &FileSize))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", Filename.c_str());
return;
}
@@ -72,16 +70,14 @@ BS_SWImage::BS_SWImage(const Common::String & Filename, bool & Result) :
// Bildeigenschaften bestimmen
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
int Pitch;
- if (!BS_ImageLoader::ExtractImageProperties(pFileData, FileSize, ColorFormat, m_Width, m_Height))
- {
+ if (!BS_ImageLoader::ExtractImageProperties(pFileData, FileSize, ColorFormat, m_Width, m_Height)) {
BS_LOG_ERRORLN("Could not read image properties.");
return;
}
// Das Bild dekomprimieren
- char * pUncompressedData;
- if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch))
- {
+ char *pUncompressedData;
+ if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) {
BS_LOG_ERRORLN("Could not decode image.");
return;
}
@@ -97,8 +93,7 @@ BS_SWImage::BS_SWImage(const Common::String & Filename, bool & Result) :
// -----------------------------------------------------------------------------
-BS_SWImage::~BS_SWImage()
-{
+BS_SWImage::~BS_SWImage() {
delete [] _ImageDataPtr;
}
@@ -106,35 +101,31 @@ BS_SWImage::~BS_SWImage()
// -----------------------------------------------------------------------------
bool BS_SWImage::Blit(int PosX, int PosY,
- int Flipping,
- BS_Rect* pPartRect,
- unsigned int Color,
- int Width, int Height)
-{
+ int Flipping,
+ BS_Rect *pPartRect,
+ unsigned int Color,
+ int Width, int Height) {
BS_LOG_ERRORLN("Blit() is not supported.");
return false;
}
// -----------------------------------------------------------------------------
-bool BS_SWImage::Fill(const BS_Rect* pFillRect, unsigned int Color)
-{
+bool BS_SWImage::Fill(const BS_Rect *pFillRect, unsigned int Color) {
BS_LOG_ERRORLN("Fill() is not supported.");
return false;
}
// -----------------------------------------------------------------------------
-bool BS_SWImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride)
-{
+bool BS_SWImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
BS_LOG_ERRORLN("SetContent() is not supported.");
return false;
}
// -----------------------------------------------------------------------------
-unsigned int BS_SWImage::GetPixel(int X, int Y)
-{
+unsigned int BS_SWImage::GetPixel(int X, int Y) {
BS_ASSERT(X >= 0 && X < m_Width);
BS_ASSERT(Y >= 0 && Y < m_Height);
diff --git a/engines/sword25/gfx/opengl/swimage.h b/engines/sword25/gfx/opengl/swimage.h
index bbab7c3833..870cbeb830 100644
--- a/engines/sword25/gfx/opengl/swimage.h
+++ b/engines/sword25/gfx/opengl/swimage.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,36 +50,55 @@ namespace Sword25 {
// CLASS DEFINITION
// -----------------------------------------------------------------------------
-class BS_SWImage : public BS_Image
-{
+class BS_SWImage : public BS_Image {
public:
- BS_SWImage(const Common::String & Filename, bool & Result);
+ BS_SWImage(const Common::String &Filename, bool &Result);
virtual ~BS_SWImage();
- virtual int GetWidth() const { return m_Width; }
- virtual int GetHeight() const { return m_Height; }
- virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
-
- virtual bool Blit(int PosX = 0, int PosY = 0,
- int Flipping = BS_Image::FLIP_NONE,
- BS_Rect* pPartRect = NULL,
- unsigned int Color = BS_ARGB(255, 255, 255, 255),
- int Width = -1, int Height = -1);
- virtual bool Fill(const BS_Rect* FillRectPtr, unsigned int Color);
+ virtual int GetWidth() const {
+ return m_Width;
+ }
+ virtual int GetHeight() const {
+ return m_Height;
+ }
+ virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const {
+ return BS_GraphicEngine::CF_ARGB32;
+ }
+
+ virtual bool Blit(int PosX = 0, int PosY = 0,
+ int Flipping = BS_Image::FLIP_NONE,
+ BS_Rect *pPartRect = NULL,
+ unsigned int Color = BS_ARGB(255, 255, 255, 255),
+ int Width = -1, int Height = -1);
+ virtual bool Fill(const BS_Rect *FillRectPtr, unsigned int Color);
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
virtual unsigned int GetPixel(int X, int Y);
- virtual bool IsBlitSource() const { return false; }
- virtual bool IsBlitTarget() const { return false; }
- virtual bool IsScalingAllowed() const { return false; }
- virtual bool IsFillingAllowed() const { return false; }
- virtual bool IsAlphaAllowed() const { return false; }
- virtual bool IsColorModulationAllowed() const { return false; }
- virtual bool IsSetContentAllowed() const { return false; }
+ virtual bool IsBlitSource() const {
+ return false;
+ }
+ virtual bool IsBlitTarget() const {
+ return false;
+ }
+ virtual bool IsScalingAllowed() const {
+ return false;
+ }
+ virtual bool IsFillingAllowed() const {
+ return false;
+ }
+ virtual bool IsAlphaAllowed() const {
+ return false;
+ }
+ virtual bool IsColorModulationAllowed() const {
+ return false;
+ }
+ virtual bool IsSetContentAllowed() const {
+ return false;
+ }
private:
- unsigned int * _ImageDataPtr;
+ unsigned int *_ImageDataPtr;
- int m_Width;
+ int m_Width;
int m_Height;
};
diff --git a/engines/sword25/gfx/panel.cpp b/engines/sword25/gfx/panel.cpp
index 335c853bd1..54d0dbc372 100644
--- a/engines/sword25/gfx/panel.cpp
+++ b/engines/sword25/gfx/panel.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -55,21 +55,18 @@ namespace Sword25 {
BS_Panel::BS_Panel(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, int Width, int Height, unsigned int Color) :
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL),
- m_Color(Color)
-{
+ m_Color(Color) {
m_InitSuccess = false;
m_Width = Width;
m_Height = Height;
- if (m_Width < 0)
- {
+ if (m_Width < 0) {
BS_LOG_ERRORLN("Tried to initialise a panel with an invalid width (%d).", m_Width);
return;
}
- if (m_Height < 0)
- {
+ if (m_Height < 0) {
BS_LOG_ERRORLN("Tried to initialise a panel with an invalid height (%d).", m_Height);
return;
}
@@ -79,28 +76,25 @@ BS_Panel::BS_Panel(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, int Width, int
// -----------------------------------------------------------------------------
-BS_Panel::BS_Panel(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
- BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL, Handle)
-{
+BS_Panel::BS_Panel(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
+ BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL, Handle) {
m_InitSuccess = Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-
-BS_Panel::~BS_Panel()
-{
+
+BS_Panel::~BS_Panel() {
}
// -----------------------------------------------------------------------------
// Rendern
// -----------------------------------------------------------------------------
-bool BS_Panel::DoRender()
-{
+bool BS_Panel::DoRender() {
// Falls der Alphawert 0 ist, ist das Panel komplett durchsichtig und es muss nichts gezeichnet werden.
if (m_Color >> 24 == 0) return true;
- BS_GraphicEngine * GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
+ BS_GraphicEngine *GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(GfxPtr);
return GfxPtr->Fill(&m_BBox, m_Color);
@@ -110,8 +104,7 @@ bool BS_Panel::DoRender()
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_Panel::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_Panel::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_RenderObject::Persist(Writer);
@@ -124,8 +117,7 @@ bool BS_Panel::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_Panel::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_Panel::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_RenderObject::Unpersist(Reader);
diff --git a/engines/sword25/gfx/panel.h b/engines/sword25/gfx/panel.h
index 930e5bd0c6..ca37c2703c 100644
--- a/engines/sword25/gfx/panel.h
+++ b/engines/sword25/gfx/panel.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,22 +48,26 @@ namespace Sword25 {
// Class Definition
// -----------------------------------------------------------------------------
-class BS_Panel : public BS_RenderObject
-{
-friend class BS_RenderObject;
+class BS_Panel : public BS_RenderObject {
+ friend class BS_RenderObject;
private:
BS_Panel(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, int Width, int Height, unsigned int Color);
- BS_Panel(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
+ BS_Panel(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
public:
virtual ~BS_Panel();
- unsigned int GetColor() const { return m_Color; }
- void SetColor(unsigned int Color) { m_Color = Color; ForceRefresh(); }
+ unsigned int GetColor() const {
+ return m_Color;
+ }
+ void SetColor(unsigned int Color) {
+ m_Color = Color;
+ ForceRefresh();
+ }
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
virtual bool DoRender();
diff --git a/engines/sword25/gfx/renderobject.cpp b/engines/sword25/gfx/renderobject.cpp
index 12b7c5dfca..af70a4a047 100644
--- a/engines/sword25/gfx/renderobject.cpp
+++ b/engines/sword25/gfx/renderobject.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -70,8 +70,7 @@ BS_RenderObject::BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
m_Type(Type),
m_InitSuccess(false),
m_RefreshForced(true),
- m_Handle(0)
-{
+ m_Handle(0) {
// Renderobject registrieren, abhängig vom Handle-Parameter entweder mit beliebigem oder vorgegebenen Handle.
if (Handle == 0)
m_Handle = BS_RenderObjectRegistry::GetInstance().RegisterObject(this);
@@ -83,15 +82,11 @@ BS_RenderObject::BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
// Dieses Objekt zu den Kindern der Elternobjektes hinzufügen, falls nicht Wurzel (ParentPtr ungültig) und dem
// selben RenderObjektManager zuweisen.
- if (m_ParentPtr.IsValid())
- {
+ if (m_ParentPtr.IsValid()) {
m_ManagerPtr = m_ParentPtr->GetManager();
m_ParentPtr->AddObject(this);
- }
- else
- {
- if (GetType() != TYPE_ROOT)
- {
+ } else {
+ if (GetType() != TYPE_ROOT) {
BS_LOG_ERRORLN("Tried to create a non-root render object and has no parent. All non-root render objects have to have a parent.");
return;
}
@@ -102,11 +97,10 @@ BS_RenderObject::BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
m_InitSuccess = true;
}
-BS_RenderObject::~BS_RenderObject()
-{
+BS_RenderObject::~BS_RenderObject() {
// Objekt aus dem Elternobjekt entfernen.
if (m_ParentPtr.IsValid()) m_ParentPtr->DetatchChildren(this);
-
+
DeleteAllChildren();
// Objekt deregistrieren.
@@ -115,8 +109,7 @@ BS_RenderObject::~BS_RenderObject()
// Rendern
// -------
-bool BS_RenderObject::Render()
-{
+bool BS_RenderObject::Render() {
// Objektänderungen validieren
ValidateObject();
@@ -124,8 +117,7 @@ bool BS_RenderObject::Render()
if (!m_Visible) return true;
// Falls notwendig, wird die Renderreihenfolge der Kinderobjekte aktualisiert.
- if (m_ChildChanged)
- {
+ if (m_ChildChanged) {
SortRenderObjects();
m_ChildChanged = false;
}
@@ -144,8 +136,7 @@ bool BS_RenderObject::Render()
// Objektverwaltung
// ----------------
-void BS_RenderObject::ValidateObject()
-{
+void BS_RenderObject::ValidateObject() {
// Die Veränderungen in den Objektvariablen aufheben
m_OldBBox = m_BBox;
m_OldVisible = m_Visible;
@@ -155,27 +146,25 @@ void BS_RenderObject::ValidateObject()
m_RefreshForced = false;
}
-bool BS_RenderObject::UpdateObjectState()
-{
+bool BS_RenderObject::UpdateObjectState() {
// Falls sich das Objekt verändert hat, muss der interne Zustand neu berechnet werden und evtl. Update-Regions für den nächsten Frame
// registriert werden.
if ((CalcBoundingBox() != m_OldBBox) ||
- (m_Visible != m_OldVisible) ||
- (m_X != m_OldX) ||
- (m_Y != m_OldY) ||
- (m_Z != m_OldZ) ||
- m_RefreshForced)
- {
+ (m_Visible != m_OldVisible) ||
+ (m_X != m_OldX) ||
+ (m_Y != m_OldY) ||
+ (m_Z != m_OldZ) ||
+ m_RefreshForced) {
// Renderrang des Objektes neu bestimmen, da sich dieser verändert haben könnte
if (m_ParentPtr.IsValid()) m_ParentPtr->SignalChildChange();
-
+
// Die Bounding-Box neu berechnen und Update-Regions registrieren.
UpdateBoxes();
-
+
// Änderungen Validieren
ValidateObject();
}
-
+
// Dann muss der Objektstatus der Kinder aktualisiert werden.
RENDEROBJECT_ITER it = m_Children.begin();
for (; it != m_Children.end(); ++it)
@@ -184,14 +173,12 @@ bool BS_RenderObject::UpdateObjectState()
return true;
}
-void BS_RenderObject::UpdateBoxes()
-{
+void BS_RenderObject::UpdateBoxes() {
// Bounding-Box aktualisieren
m_BBox = CalcBoundingBox();
}
-BS_Rect BS_RenderObject::CalcBoundingBox() const
-{
+BS_Rect BS_RenderObject::CalcBoundingBox() const {
// Die Bounding-Box mit der Objektgröße initialisieren.
BS_Rect BBox(0, 0, m_Width, m_Height);
@@ -204,22 +191,19 @@ BS_Rect BS_RenderObject::CalcBoundingBox() const
return BBox;
}
-void BS_RenderObject::CalcAbsolutePos(int& X, int& Y) const
-{
+void BS_RenderObject::CalcAbsolutePos(int &X, int &Y) const {
X = CalcAbsoluteX();
Y = CalcAbsoluteY();
}
-int BS_RenderObject::CalcAbsoluteX() const
-{
+int BS_RenderObject::CalcAbsoluteX() const {
if (m_ParentPtr.IsValid())
return m_ParentPtr->GetAbsoluteX() + m_X;
else
return m_X;
}
-int BS_RenderObject::CalcAbsoluteY() const
-{
+int BS_RenderObject::CalcAbsoluteY() const {
if (m_ParentPtr.IsValid())
return m_ParentPtr->GetAbsoluteY() + m_Y;
else
@@ -229,41 +213,35 @@ int BS_RenderObject::CalcAbsoluteY() const
// Baumverwaltung
// --------------
-void BS_RenderObject::DeleteAllChildren()
-{
+void BS_RenderObject::DeleteAllChildren() {
// Es ist nicht notwendig die Liste zu iterieren, da jedes Kind für sich DetatchChildren an diesem Objekt aufruft und sich somit
// selber entfernt. Daher muss immer nur ein beliebiges Element (hier das letzte) gelöscht werden, bis die Liste leer ist.
- while (!m_Children.empty())
- {
+ while (!m_Children.empty()) {
BS_RenderObjectPtr<BS_RenderObject> CurPtr = m_Children.back();
CurPtr.Erase();
}
}
-bool BS_RenderObject::AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject)
-{
- if (!pObject.IsValid())
- {
+bool BS_RenderObject::AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject) {
+ if (!pObject.IsValid()) {
BS_LOG_ERRORLN("Tried to add a null object to a renderobject.");
return false;
}
// Objekt in die Kinderliste einfügen.
m_Children.push_back(pObject);
-
+
// Sicherstellen, dass vor dem nächsten Rendern die Renderreihenfolge aktualisiert wird.
if (m_ParentPtr.IsValid()) m_ParentPtr->SignalChildChange();
return true;
}
-bool BS_RenderObject::DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObject)
-{
+bool BS_RenderObject::DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObject) {
// Kinderliste durchgehen und Objekt entfernen falls vorhanden
RENDEROBJECT_ITER it = m_Children.begin();
for (; it != m_Children.end(); ++it)
- if (*it == pObject)
- {
+ if (*it == pObject) {
m_Children.erase(it);
return true;
}
@@ -272,13 +250,11 @@ bool BS_RenderObject::DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObjec
return false;
}
-void BS_RenderObject::SortRenderObjects()
-{
+void BS_RenderObject::SortRenderObjects() {
std::sort(m_Children.begin(), m_Children.end(), Greater);
}
-void BS_RenderObject::UpdateAbsolutePos()
-{
+void BS_RenderObject::UpdateAbsolutePos() {
CalcAbsolutePos(m_AbsoluteX, m_AbsoluteY);
RENDEROBJECT_ITER it = m_Children.begin();
@@ -289,42 +265,36 @@ void BS_RenderObject::UpdateAbsolutePos()
// Get-Methoden
// ------------
-bool BS_RenderObject::GetObjectIntersection(BS_RenderObjectPtr<BS_RenderObject> pObject, BS_Rect& Result)
-{
+bool BS_RenderObject::GetObjectIntersection(BS_RenderObjectPtr<BS_RenderObject> pObject, BS_Rect &Result) {
return m_BBox.Intersect(pObject->GetBBox(), Result);
}
// Set-Methoden
// ------------
-void BS_RenderObject::SetPos(int X, int Y)
-{
- m_X = X;
+void BS_RenderObject::SetPos(int X, int Y) {
+ m_X = X;
m_Y = Y;
UpdateAbsolutePos();
}
-void BS_RenderObject::SetX(int X)
-{
+void BS_RenderObject::SetX(int X) {
m_X = X;
UpdateAbsolutePos();
}
-void BS_RenderObject::SetY(int Y)
-{
+void BS_RenderObject::SetY(int Y) {
m_Y = Y;
UpdateAbsolutePos();
}
-void BS_RenderObject::SetZ(int Z)
-{
+void BS_RenderObject::SetZ(int Z) {
if (Z < 0)
BS_LOG_ERRORLN("Tried to set a negative Z value (%d).", Z);
else
m_Z = Z;
}
-void BS_RenderObject::SetVisible(bool Visible)
-{
+void BS_RenderObject::SetVisible(bool Visible) {
m_Visible = Visible;
}
@@ -332,13 +302,11 @@ void BS_RenderObject::SetVisible(bool Visible)
// Objekterzeuger
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::String& Filename)
-{
+BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::String &Filename) {
BS_RenderObjectPtr<BS_Animation> AniPtr(new BS_Animation(this, Filename));
if (AniPtr.IsValid() && AniPtr->GetInitSuccess())
return AniPtr;
- else
- {
+ else {
if (AniPtr.IsValid()) AniPtr.Erase();
return BS_RenderObjectPtr<BS_Animation>();
}
@@ -347,13 +315,11 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::Str
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate & AnimationTemplate)
-{
- BS_Animation * AniPtr = new BS_Animation(this, AnimationTemplate);
+BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate &AnimationTemplate) {
+ BS_Animation *AniPtr = new BS_Animation(this, AnimationTemplate);
if (AniPtr && AniPtr->GetInitSuccess())
return AniPtr;
- else
- {
+ else {
delete AniPtr;
return BS_RenderObjectPtr<BS_Animation>();
}
@@ -361,13 +327,11 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_Animatio
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String& Filename)
-{
+BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &Filename) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_StaticBitmap(this, Filename));
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr);
- else
- {
+ else {
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
return BS_RenderObjectPtr<BS_Bitmap>();
}
@@ -375,13 +339,11 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String& F
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Width, unsigned int Height)
-{
+BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Width, unsigned int Height) {
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_DynamicBitmap(this, Width, Height));
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BitmapPtr;
- else
- {
+ else {
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
return BS_RenderObjectPtr<BS_Bitmap>();
}
@@ -389,13 +351,11 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Wid
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, unsigned int Color)
-{
+BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, unsigned int Color) {
BS_RenderObjectPtr<BS_Panel> PanelPtr(new BS_Panel(this, Width, Height, Color));
if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess())
return PanelPtr;
- else
- {
+ else {
if (PanelPtr.IsValid()) PanelPtr.Erase();
return BS_RenderObjectPtr<BS_Panel>();
}
@@ -403,16 +363,12 @@ BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, un
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String & Font, const std::string & Text)
-{
+BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String &Font, const std::string &Text) {
BS_RenderObjectPtr<BS_Text> TextPtr(new BS_Text(this));
- if (TextPtr.IsValid() && TextPtr->GetInitSuccess() && TextPtr->SetFont(Font))
- {
+ if (TextPtr.IsValid() && TextPtr->GetInitSuccess() && TextPtr->SetFont(Font)) {
TextPtr->SetText(Text);
return TextPtr;
- }
- else
- {
+ } else {
if (TextPtr.IsValid()) TextPtr.Erase();
return BS_RenderObjectPtr<BS_Text>();
}
@@ -421,8 +377,7 @@ BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String & Font
// Persistenz-Methoden
// -------------------
-bool BS_RenderObject::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_RenderObject::Persist(BS_OutputPersistenceBlock &Writer) {
// Typ und Handle werden als erstes gespeichert, damit beim Laden ein Objekt vom richtigen Typ mit dem richtigen Handle erzeugt werden kann.
Writer.Write(static_cast<unsigned int>(m_Type));
Writer.Write(m_Handle);
@@ -458,8 +413,7 @@ bool BS_RenderObject::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_RenderObject::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_RenderObject::Unpersist(BS_InputPersistenceBlock &Reader) {
// Typ und Handle wurden schon von RecreatePersistedRenderObject() ausgelesen. Jetzt werden die restlichen Objekteigenschaften ausgelesen.
Reader.Read(m_X);
Reader.Read(m_Y);
@@ -496,8 +450,7 @@ bool BS_RenderObject::Unpersist(BS_InputPersistenceBlock & Reader)
// -----------------------------------------------------------------------------
-bool BS_RenderObject::PersistChildren(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_RenderObject::PersistChildren(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Kinderanzahl speichern.
@@ -505,8 +458,7 @@ bool BS_RenderObject::PersistChildren(BS_OutputPersistenceBlock & Writer)
// Rekursiv alle Kinder speichern.
RENDEROBJECT_LIST::iterator It = m_Children.begin();
- while (It != m_Children.end())
- {
+ while (It != m_Children.end()) {
Result &= (*It)->Persist(Writer);
++It;
}
@@ -516,8 +468,7 @@ bool BS_RenderObject::PersistChildren(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_RenderObject::UnpersistChildren(BS_InputPersistenceBlock & Reader)
-{
+bool BS_RenderObject::UnpersistChildren(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// Kinderanzahl einlesen.
@@ -526,8 +477,7 @@ bool BS_RenderObject::UnpersistChildren(BS_InputPersistenceBlock & Reader)
if (!Reader.IsGood()) return false;
// Alle Kinder rekursiv wieder herstellen.
- for (unsigned int i = 0; i < ChildrenCount; ++i)
- {
+ for (unsigned int i = 0; i < ChildrenCount; ++i) {
if (!RecreatePersistedRenderObject(Reader).IsValid()) return false;
}
@@ -536,8 +486,7 @@ bool BS_RenderObject::UnpersistChildren(BS_InputPersistenceBlock & Reader)
// -----------------------------------------------------------------------------
-BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObject(BS_InputPersistenceBlock & Reader)
-{
+BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObject(BS_InputPersistenceBlock &Reader) {
BS_RenderObjectPtr<BS_RenderObject> Result;
// Typ und Handle auslesen.
@@ -547,8 +496,7 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
Reader.Read(Handle);
if (!Reader.IsGood()) return Result;
- switch (Type)
- {
+ switch (Type) {
case TYPE_PANEL:
Result = new BS_Panel(Reader, this, Handle);
break;
@@ -578,8 +526,7 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
// Hilfs-Methoden
// --------------
-bool BS_RenderObject::Greater(const BS_RenderObjectPtr<BS_RenderObject> lhs, const BS_RenderObjectPtr<BS_RenderObject> rhs)
-{
+bool BS_RenderObject::Greater(const BS_RenderObjectPtr<BS_RenderObject> lhs, const BS_RenderObjectPtr<BS_RenderObject> rhs) {
// Das Objekt mit dem kleinem Z-Wert müssen zuerst gerendert werden.
if (lhs->m_Z != rhs->m_Z)
return lhs->m_Z < rhs->m_Z;
diff --git a/engines/sword25/gfx/renderobject.h b/engines/sword25/gfx/renderobject.h
index 545a6bf8db..9424303505 100644
--- a/engines/sword25/gfx/renderobject.h
+++ b/engines/sword25/gfx/renderobject.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,13 +33,13 @@
*/
/*
- BS_RenderObject
- ---------------
- Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden.
- Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
- Alle BS_RenderObject Instanzen werden von einem BS_RenderObjectManager in einem Baum verwaltet.
+ BS_RenderObject
+ ---------------
+ Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt. Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden.
+ Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
+ Alle BS_RenderObject Instanzen werden von einem BS_RenderObjectManager in einem Baum verwaltet.
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_RENDEROBJECT_H
@@ -69,19 +69,17 @@ class BS_Text;
// Klassendefinition
/**
- @brief Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt.
-
- Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden.
- Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
- Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet.
+ @brief Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt.
+
+ Alle anderen sichtbaren Objekte müssen von ihr abgeleitet werden.
+ Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
+ Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet.
*/
-class BS_RenderObject
-{
+class BS_RenderObject {
public:
// Konstanten
// ----------
- enum TYPES
- {
+ enum TYPES {
/// Das Wurzelobjekt. Siehe BS_RenderObjectManager
TYPE_ROOT,
/// Ein Image. Siehe BS_Bitmap.
@@ -102,111 +100,111 @@ public:
/**
@brief Erzeugt ein Bitmap als Kinderobjekt des Renderobjektes.
- @param FileName der Dateiname der Quellbilddatei
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @param FileName der Dateiname der Quellbilddatei
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
BS_RenderObjectPtr<BS_Bitmap> AddBitmap(const Common::String &FileName);
/**
- @brief Erzeugt ein veränderbares Bitmap als Kinderobjekt des Renderobjektes.
- @param Width die Breite des Bitmaps
- @param Height die Höhe des Bitmaps
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @brief Erzeugt ein veränderbares Bitmap als Kinderobjekt des Renderobjektes.
+ @param Width die Breite des Bitmaps
+ @param Height die Höhe des Bitmaps
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
BS_RenderObjectPtr<BS_Bitmap> AddDynamicBitmap(unsigned int Width, unsigned int Height);
/**
@brief Erzeugt eine Animation auf Basis einer Animationsdatei als Kinderobjekt des Renderobjektes.
- @param FileName der Dateiname der Quelldatei
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @param FileName der Dateiname der Quelldatei
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
BS_RenderObjectPtr<BS_Animation> AddAnimation(const Common::String &FileName);
/**
- @brief Erzeugt eine Animation auf Basis eines Animationstemplate als Kinderobjekt des Renderobjektes.
- @param pAnimationTemplate ein Pointer auf das Animationstemplate
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
- @remark Das Renderobjekt übernimmt die Verwaltung des Animationstemplate.
+ @brief Erzeugt eine Animation auf Basis eines Animationstemplate als Kinderobjekt des Renderobjektes.
+ @param pAnimationTemplate ein Pointer auf das Animationstemplate
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @remark Das Renderobjekt übernimmt die Verwaltung des Animationstemplate.
*/
BS_RenderObjectPtr<BS_Animation> AddAnimation(const BS_AnimationTemplate &AnimationTemplate);
/**
@brief Erzeugt ein neues Farbpanel als Kinderobjekt des Renderobjektes.
- @param Width die Breite des Panels
- @param Height die Höhe des Panels
- @param Color die Farbe des Panels.<br>
- Der Standardwert ist Schwarz (BS_RGB(0, 0, 0)).
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @param Width die Breite des Panels
+ @param Height die Höhe des Panels
+ @param Color die Farbe des Panels.<br>
+ Der Standardwert ist Schwarz (BS_RGB(0, 0, 0)).
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
-
+
BS_RenderObjectPtr<BS_Panel> AddPanel(int Width, int Height, unsigned int Color = 0xff000000);
/**
@brief Erzeugt ein Textobjekt als Kinderobjekt des Renderobjektes.
- @param Font der Dateiname des zu verwendenen Fonts
- @param Text der anzuzeigende Text.<br>
- Der Standardwert ist "".
- @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
- Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @param Font der Dateiname des zu verwendenen Fonts
+ @param Text der anzuzeigende Text.<br>
+ Der Standardwert ist "".
+ @return Gibt einen BS_RenderObjectPtr auf das erzeugte Objekt zurück.<br>
+ Falls ein Fehler aufgetreten ist wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
BS_RenderObjectPtr<BS_Text> AddText(const Common::String &Font, const Common::String &Text = "");
// Cast-Methoden
// -------------
/**
- @brief Castet das Objekt zu einem BS_Bitmap-Objekt wenn zulässig.
- @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
- Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @brief Castet das Objekt zu einem BS_Bitmap-Objekt wenn zulässig.
+ @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
+ Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
- BS_RenderObjectPtr<BS_Bitmap> ToBitmap()
- {
- if (m_Type == TYPE_STATICBITMAP || m_Type == TYPE_DYNAMICBITMAP) return BS_RenderObjectPtr<BS_Bitmap>(this); else return BS_RenderObjectPtr<BS_Bitmap>();
+ BS_RenderObjectPtr<BS_Bitmap> ToBitmap() {
+ if (m_Type == TYPE_STATICBITMAP || m_Type == TYPE_DYNAMICBITMAP) return BS_RenderObjectPtr<BS_Bitmap>(this);
+ else return BS_RenderObjectPtr<BS_Bitmap>();
}
/**
- @brief Castet das Objekt zu einem BS_Animation-Objekt wenn zulässig.
- @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
- Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @brief Castet das Objekt zu einem BS_Animation-Objekt wenn zulässig.
+ @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
+ Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
- BS_RenderObjectPtr<BS_Animation> ToAnimation()
- {
- if (m_Type == TYPE_ANIMATION) return BS_RenderObjectPtr<BS_Animation>(this); else return BS_RenderObjectPtr<BS_Animation>();
+ BS_RenderObjectPtr<BS_Animation> ToAnimation() {
+ if (m_Type == TYPE_ANIMATION) return BS_RenderObjectPtr<BS_Animation>(this);
+ else return BS_RenderObjectPtr<BS_Animation>();
}
/**
- @brief Castet das Objekt zu einem BS_Panel-Objekt wenn zulässig.
- @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
- Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @brief Castet das Objekt zu einem BS_Panel-Objekt wenn zulässig.
+ @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
+ Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
- BS_RenderObjectPtr<BS_Panel> ToPanel()
- {
- if (m_Type == TYPE_PANEL) return BS_RenderObjectPtr<BS_Panel>(this); else return BS_RenderObjectPtr<BS_Panel>();
+ BS_RenderObjectPtr<BS_Panel> ToPanel() {
+ if (m_Type == TYPE_PANEL) return BS_RenderObjectPtr<BS_Panel>(this);
+ else return BS_RenderObjectPtr<BS_Panel>();
}
/**
- @brief Castet das Object zu einem BS_Text-Objekt wenn zulässig.
- @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
- Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
+ @brief Castet das Object zu einem BS_Text-Objekt wenn zulässig.
+ @return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
+ Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
*/
- BS_RenderObjectPtr<BS_Text> ToText()
- {
- if (m_Type == TYPE_TEXT) return BS_RenderObjectPtr<BS_Text>(this); else return BS_RenderObjectPtr<BS_Text>();
+ BS_RenderObjectPtr<BS_Text> ToText() {
+ if (m_Type == TYPE_TEXT) return BS_RenderObjectPtr<BS_Text>(this);
+ else return BS_RenderObjectPtr<BS_Text>();
}
// Konstruktor / Desktruktor
// -------------------------
/**
- @brief Erzeugt ein neues BS_RenderObject.
- @param pKernel ein Pointer auf den Kernel
- @param pParent ein Pointer auf das Elternobjekt des neuen Objektes im Objektbaum.<br>
- Der Pointer darf nicht NULL sein.
- @param Type der Objekttyp<br>
- Der Typ BS_RenderObject::TYPE_ROOT ist nicht zulässig. Wurzelknoten müssen mit dem alternativen Konstruktor erzeugt
- werden.
- @param Handle das Handle, welches dem Objekt zugewiesen werden soll.<br>
- Dieser Parameter erzwingt ein bestimmtes Handle für das neue Objekt, oder wählt automatisch ein Handle, wenn der Parameter 0 ist.
- Ist das gewünschte Handle bereits vergeben, gibt GetInitSuccess() false zurück.<br>
- Der Standardwert ist 0.
- @remark Nach dem Aufruf des Konstruktors kann über die Methode GetInitSuccess() abgefragt werden, ob die Konstruktion erfolgreich war.<br>
- Es ist nicht notwendig alle BS_RenderObject Instanzen einzeln zu löschen. Dieses geschiet automatisch beim Löschen eines
- Vorfahren oder beim Löschen des zuständigen BS_RenderObjectManager.
+ @brief Erzeugt ein neues BS_RenderObject.
+ @param pKernel ein Pointer auf den Kernel
+ @param pParent ein Pointer auf das Elternobjekt des neuen Objektes im Objektbaum.<br>
+ Der Pointer darf nicht NULL sein.
+ @param Type der Objekttyp<br>
+ Der Typ BS_RenderObject::TYPE_ROOT ist nicht zulässig. Wurzelknoten müssen mit dem alternativen Konstruktor erzeugt
+ werden.
+ @param Handle das Handle, welches dem Objekt zugewiesen werden soll.<br>
+ Dieser Parameter erzwingt ein bestimmtes Handle für das neue Objekt, oder wählt automatisch ein Handle, wenn der Parameter 0 ist.
+ Ist das gewünschte Handle bereits vergeben, gibt GetInitSuccess() false zurück.<br>
+ Der Standardwert ist 0.
+ @remark Nach dem Aufruf des Konstruktors kann über die Methode GetInitSuccess() abgefragt werden, ob die Konstruktion erfolgreich war.<br>
+ Es ist nicht notwendig alle BS_RenderObject Instanzen einzeln zu löschen. Dieses geschiet automatisch beim Löschen eines
+ Vorfahren oder beim Löschen des zuständigen BS_RenderObjectManager.
*/
BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle = 0);
virtual ~BS_RenderObject();
@@ -214,119 +212,145 @@ public:
// Interface
// ---------
/**
- @brief Rendert des Objekt und alle seine Unterobjekte.
- @return Gibt false zurück, falls beim Rendern ein Fehler aufgetreten ist.
- @remark Vor jedem Aufruf dieser Methode muss ein Aufruf von UpdateObjectState() erfolgt sein.
- Dieses kann entweder direkt geschehen oder durch den Aufruf von UpdateObjectState() an einem Vorfahren-Objekt.<br>
- Diese Methode darf nur von BS_RenderObjectManager aufgerufen werden.
+ @brief Rendert des Objekt und alle seine Unterobjekte.
+ @return Gibt false zurück, falls beim Rendern ein Fehler aufgetreten ist.
+ @remark Vor jedem Aufruf dieser Methode muss ein Aufruf von UpdateObjectState() erfolgt sein.
+ Dieses kann entweder direkt geschehen oder durch den Aufruf von UpdateObjectState() an einem Vorfahren-Objekt.<br>
+ Diese Methode darf nur von BS_RenderObjectManager aufgerufen werden.
*/
- bool Render();
+ bool Render();
/**
- @brief Bereitet das Objekt und alle seine Unterobjekte auf einen Rendervorgang vor.
- Hierbei werden alle Dirty-Rectangles berechnet und die Renderreihenfolge aktualisiert.
- @return Gibt false zurück, falls ein Fehler aufgetreten ist.
- @remark Diese Methode darf nur von BS_RenderObjectManager aufgerufen werden.
+ @brief Bereitet das Objekt und alle seine Unterobjekte auf einen Rendervorgang vor.
+ Hierbei werden alle Dirty-Rectangles berechnet und die Renderreihenfolge aktualisiert.
+ @return Gibt false zurück, falls ein Fehler aufgetreten ist.
+ @remark Diese Methode darf nur von BS_RenderObjectManager aufgerufen werden.
*/
- bool UpdateObjectState();
+ bool UpdateObjectState();
/**
- @brief Löscht alle Kinderobjekte.
+ @brief Löscht alle Kinderobjekte.
*/
void DeleteAllChildren();
// Accessor-Methoden
// -----------------
/**
- @brief Setzt die Position des Objektes.
- @param X die neue X-Koordinate des Objektes relativ zum Elternobjekt.
- @param Y die neue Y-Koordinate des Objektes relativ zum Elternobjekt.
+ @brief Setzt die Position des Objektes.
+ @param X die neue X-Koordinate des Objektes relativ zum Elternobjekt.
+ @param Y die neue Y-Koordinate des Objektes relativ zum Elternobjekt.
*/
virtual void SetPos(int X, int Y);
/**
- @brief Setzt die Position des Objektes auf der X-Achse.
- @param X die neue X-Koordinate des Objektes relativ zum Elternobjekt.
+ @brief Setzt die Position des Objektes auf der X-Achse.
+ @param X die neue X-Koordinate des Objektes relativ zum Elternobjekt.
*/
virtual void SetX(int X);
/**
- @brief Setzt die Position des Objektes auf der Y-Achse.
- @param Y die neue Y-Koordinate des Objektes relativ zum Elternobjekt.
+ @brief Setzt die Position des Objektes auf der Y-Achse.
+ @param Y die neue Y-Koordinate des Objektes relativ zum Elternobjekt.
*/
virtual void SetY(int Y);
/**
- @brief Setzt den Z-Wert des Objektes.
- @param Z der neue Z-Wert des Objektes relativ zum Elternobjekt<br>
- Negative Z-Werte sind nicht zulässig.
- @remark Der Z-Wert legt die Renderreihenfolge der Objekte fest. Objekte mit niedrigem Z-Wert werden vor Objekten mit höherem
- Z-Wert gezeichnet. Je höher der Z-Wert desto weiter "vorne" liegt ein Objekt also.<br>
- Wie alle andere Attribute ist auch dieses relativ zum Elternobjekt, ein Kinderobjekt kann also nie unter seinem
- Elternobjekt liegen, auch wenn es einen Z-Wert von 0 hat.
+ @brief Setzt den Z-Wert des Objektes.
+ @param Z der neue Z-Wert des Objektes relativ zum Elternobjekt<br>
+ Negative Z-Werte sind nicht zulässig.
+ @remark Der Z-Wert legt die Renderreihenfolge der Objekte fest. Objekte mit niedrigem Z-Wert werden vor Objekten mit höherem
+ Z-Wert gezeichnet. Je höher der Z-Wert desto weiter "vorne" liegt ein Objekt also.<br>
+ Wie alle andere Attribute ist auch dieses relativ zum Elternobjekt, ein Kinderobjekt kann also nie unter seinem
+ Elternobjekt liegen, auch wenn es einen Z-Wert von 0 hat.
*/
virtual void SetZ(int Z);
/**
- @brief Setzt die Sichtbarkeit eine Objektes.
- @param Visible der neue Sichtbarkeits-Zustand des Objektes<br>
- true entspricht sichtbar, false entspricht unsichtbar.
+ @brief Setzt die Sichtbarkeit eine Objektes.
+ @param Visible der neue Sichtbarkeits-Zustand des Objektes<br>
+ true entspricht sichtbar, false entspricht unsichtbar.
*/
virtual void SetVisible(bool Visible);
/**
- @brief Gibt die Position des Objektes auf der X-Achse relativ zum Elternobjekt zurück.
+ @brief Gibt die Position des Objektes auf der X-Achse relativ zum Elternobjekt zurück.
*/
- virtual int GetX() const { return m_X; }
+ virtual int GetX() const {
+ return m_X;
+ }
/**
- @brief Gibt die Position des Objektes auf der Y-Achse relativ zum Elternobjekt zurück.
+ @brief Gibt die Position des Objektes auf der Y-Achse relativ zum Elternobjekt zurück.
*/
- virtual int GetY() const { return m_Y; }
+ virtual int GetY() const {
+ return m_Y;
+ }
/**
- @brief Gibt die absolute Position des Objektes auf der X-Achse zurück.
+ @brief Gibt die absolute Position des Objektes auf der X-Achse zurück.
*/
- virtual int GetAbsoluteX() const { return m_AbsoluteX; }
+ virtual int GetAbsoluteX() const {
+ return m_AbsoluteX;
+ }
/**
- @brief Gibt die absolute Position des Objektes auf der Y-Achse zurück.
+ @brief Gibt die absolute Position des Objektes auf der Y-Achse zurück.
*/
- virtual int GetAbsoluteY() const { return m_AbsoluteY; }
+ virtual int GetAbsoluteY() const {
+ return m_AbsoluteY;
+ }
/**
- @brief Gibt den Z-Wert des Objektes relativ zum Elternobjekt zurück.
- @remark Der Z-Wert legt die Renderreihenfolge der Objekte fest. Objekte mit niedrigem Z-Wert werden vor Objekten mit höherem
- Z-Wert gezeichnet. Je höher der Z-Wert desto weiter "vorne" liegt ein Objekt also.<br>
- Wie alle andere Attribute ist auch dieses relativ zum Elternobjekt, ein Kinderobjekt kann also nie unter seinem
- Elternobjekt liegen, auch wenn es einen Z-Wert von 0 hat.
+ @brief Gibt den Z-Wert des Objektes relativ zum Elternobjekt zurück.
+ @remark Der Z-Wert legt die Renderreihenfolge der Objekte fest. Objekte mit niedrigem Z-Wert werden vor Objekten mit höherem
+ Z-Wert gezeichnet. Je höher der Z-Wert desto weiter "vorne" liegt ein Objekt also.<br>
+ Wie alle andere Attribute ist auch dieses relativ zum Elternobjekt, ein Kinderobjekt kann also nie unter seinem
+ Elternobjekt liegen, auch wenn es einen Z-Wert von 0 hat.
*/
- int GetZ() const { return m_Z; }
+ int GetZ() const {
+ return m_Z;
+ }
/**
- @brief Gibt die Breite des Objektes zurück.
+ @brief Gibt die Breite des Objektes zurück.
*/
- int GetWidth() const { return m_Width; }
+ int GetWidth() const {
+ return m_Width;
+ }
/**
- @brief Gibt die Höhe des Objektes zurück.
+ @brief Gibt die Höhe des Objektes zurück.
*/
- int GetHeight() const { return m_Height; }
+ int GetHeight() const {
+ return m_Height;
+ }
/**
- @brief Gibt den Sichtbarkeitszustand des Objektes zurück.
- @return Gibt den Sichtbarkeitszustand des Objektes zurück.<br>
- true entspricht sichtbar, false entspricht unsichtbar.
+ @brief Gibt den Sichtbarkeitszustand des Objektes zurück.
+ @return Gibt den Sichtbarkeitszustand des Objektes zurück.<br>
+ true entspricht sichtbar, false entspricht unsichtbar.
*/
- bool IsVisible() const { return m_Visible; }
+ bool IsVisible() const {
+ return m_Visible;
+ }
/**
- @brief Gibt den Typ des Objektes zurück.
+ @brief Gibt den Typ des Objektes zurück.
*/
- TYPES GetType() const { return m_Type; }
+ TYPES GetType() const {
+ return m_Type;
+ }
/**
- @brief Gibt zurück, ob das Objekt erfolgreich initialisiert wurde.
- @remark Hässlicher Workaround um das Problem, dass Konstruktoren keine Rückgabewerte haben.
+ @brief Gibt zurück, ob das Objekt erfolgreich initialisiert wurde.
+ @remark Hässlicher Workaround um das Problem, dass Konstruktoren keine Rückgabewerte haben.
*/
- bool GetInitSuccess() const { return m_InitSuccess; }
+ bool GetInitSuccess() const {
+ return m_InitSuccess;
+ }
/**
- @brief Gibt die Bounding-Box des Objektes zurück.
- @remark Diese Angabe erfolgt ausnahmsweise in Bildschirmkoordianten und nicht relativ zum Elternobjekt.
+ @brief Gibt die Bounding-Box des Objektes zurück.
+ @remark Diese Angabe erfolgt ausnahmsweise in Bildschirmkoordianten und nicht relativ zum Elternobjekt.
*/
- const BS_Rect& GetBBox() const { return m_BBox; }
+ const BS_Rect &GetBBox() const {
+ return m_BBox;
+ }
/**
- @brief Stellt sicher, dass das Objekt im nächsten Frame neu gezeichnet wird.
+ @brief Stellt sicher, dass das Objekt im nächsten Frame neu gezeichnet wird.
*/
- void ForceRefresh() { m_RefreshForced = true; };
+ void ForceRefresh() {
+ m_RefreshForced = true;
+ };
/**
- @brief Gibt das Handle des Objekte zurück.
+ @brief Gibt das Handle des Objekte zurück.
*/
- unsigned int GetHandle() const { return m_Handle; }
+ unsigned int GetHandle() const {
+ return m_Handle;
+ }
// Persistenz-Methoden
// -------------------
@@ -341,28 +365,28 @@ public:
protected:
// Typen
// -----
- typedef Common::List<BS_RenderObjectPtr<BS_RenderObject> > RENDEROBJECT_LIST;
- typedef Common::List<BS_RenderObjectPtr<BS_RenderObject> >::iterator RENDEROBJECT_ITER;
-
- int m_X; ///< Die X-Position des Objektes relativ zum Eltern-Objekt
- int m_Y; ///< Die Y-Position des Objektes relativ zum Eltern-Objekt
- int m_AbsoluteX; ///< Die absolute X-Position des Objektes
- int m_AbsoluteY; ///< Die absolute Y-Position des Objektes
- int m_Z; ///< Der Z-Wert des Objektes relativ zum Eltern-Objekt
- int m_Width; ///< Die Breite des Objektes
- int m_Height; ///< Die Höhe des Objektes
- bool m_Visible; ///< Ist true, wenn das Objekt sichtbar ist
- bool m_ChildChanged; ///< Ist true, wenn sich ein Kinderobjekt verändert hat
- TYPES m_Type; ///< Der Objekttyp
- bool m_InitSuccess; ///< Ist true, wenn Objekt erfolgreich intialisiert werden konnte
- BS_Rect m_BBox; ///< Die Bounding-Box des Objektes in Bildschirmkoordinaten
+ typedef Common::List<BS_RenderObjectPtr<BS_RenderObject> > RENDEROBJECT_LIST;
+ typedef Common::List<BS_RenderObjectPtr<BS_RenderObject> >::iterator RENDEROBJECT_ITER;
+
+ int m_X; ///< Die X-Position des Objektes relativ zum Eltern-Objekt
+ int m_Y; ///< Die Y-Position des Objektes relativ zum Eltern-Objekt
+ int m_AbsoluteX; ///< Die absolute X-Position des Objektes
+ int m_AbsoluteY; ///< Die absolute Y-Position des Objektes
+ int m_Z; ///< Der Z-Wert des Objektes relativ zum Eltern-Objekt
+ int m_Width; ///< Die Breite des Objektes
+ int m_Height; ///< Die Höhe des Objektes
+ bool m_Visible; ///< Ist true, wenn das Objekt sichtbar ist
+ bool m_ChildChanged; ///< Ist true, wenn sich ein Kinderobjekt verändert hat
+ TYPES m_Type; ///< Der Objekttyp
+ bool m_InitSuccess; ///< Ist true, wenn Objekt erfolgreich intialisiert werden konnte
+ BS_Rect m_BBox; ///< Die Bounding-Box des Objektes in Bildschirmkoordinaten
// Kopien der Variablen, die für die Errechnung des Dirty-Rects und zur Bestimmung der Objektveränderung notwendig sind
- BS_Rect m_OldBBox;
- int m_OldX;
- int m_OldY;
- int m_OldZ;
- bool m_OldVisible;
+ BS_Rect m_OldBBox;
+ int m_OldX;
+ int m_OldY;
+ int m_OldZ;
+ bool m_OldVisible;
/// Ein Pointer auf den BS_RenderObjektManager, der das Objekt verwaltet.
BS_RenderObjectManager *m_ManagerPtr;
@@ -370,13 +394,13 @@ protected:
// Render-Methode
// --------------
/**
- @brief Einschubmethode, die den tatsächlichen Redervorgang durchführt.
+ @brief Einschubmethode, die den tatsächlichen Redervorgang durchführt.
- Diese Methode wird von Render() aufgerufen um das Objekt darzustellen.
- Diese Methode sollte von allen Klassen implementiert werden, die von BS_RederObject erben, um das Zeichnen umzusetzen.
+ Diese Methode wird von Render() aufgerufen um das Objekt darzustellen.
+ Diese Methode sollte von allen Klassen implementiert werden, die von BS_RederObject erben, um das Zeichnen umzusetzen.
- @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
- @remark
+ @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
+ @remark
*/
virtual bool DoRender() = 0; // { return true; };
@@ -393,27 +417,29 @@ protected:
// / | \.
// / | \.
// Background Interface Maus
- // / \ / | \.
+ // / \ / | \.
// / \ / | \.
// George Tür Icn1 Icn2 Icn3
- //
+ //
// Wenn jetzt das Interface mit SetVisible() ausgeblendet würde, verschwinden auch die Icons, die sich im Interface
// befinden.
// Wenn der Hintergrund bewegt wird (Scrolling), bewegen sich auch die darauf befindlichen Gegenstände und Personen.
/// Ein Pointer auf das Elternobjekt.
- BS_RenderObjectPtr<BS_RenderObject> m_ParentPtr;
+ BS_RenderObjectPtr<BS_RenderObject> m_ParentPtr;
/// Die Liste der Kinderobjekte nach der Renderreihenfolge geordnet
- RENDEROBJECT_LIST m_Children;
+ RENDEROBJECT_LIST m_Children;
/**
- @brief Gibt einen Pointer auf den BS_RenderObjektManager zurück, der das Objekt verwaltet.
+ @brief Gibt einen Pointer auf den BS_RenderObjektManager zurück, der das Objekt verwaltet.
*/
- BS_RenderObjectManager* GetManager() const { return m_ManagerPtr; }
+ BS_RenderObjectManager *GetManager() const {
+ return m_ManagerPtr;
+ }
/**
- @brief Fügt dem Objekt ein neues Kinderobjekt hinzu.
- @param pObject ein Pointer auf das einzufügende Objekt
- @return Gibt false zurück, falls das Objekt nicht eingefügt werden konnte.
+ @brief Fügt dem Objekt ein neues Kinderobjekt hinzu.
+ @param pObject ein Pointer auf das einzufügende Objekt
+ @return Gibt false zurück, falls das Objekt nicht eingefügt werden konnte.
*/
bool AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject);
@@ -424,67 +450,69 @@ private:
unsigned int m_Handle;
/**
- @brief Entfernt ein Objekt aus der Kinderliste.
- @param pObject ein Pointer auf das zu entfernende Objekt
- @return Gibt false zurück, falls das zu entfernende Objekt nicht in der Liste gefunden werden konnte.
+ @brief Entfernt ein Objekt aus der Kinderliste.
+ @param pObject ein Pointer auf das zu entfernende Objekt
+ @return Gibt false zurück, falls das zu entfernende Objekt nicht in der Liste gefunden werden konnte.
*/
- bool DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObject);
+ bool DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObject);
/**
- @brief Berechnet die Bounding-Box und registriert das Dirty-Rect beim BS_RenderObjectManager.
+ @brief Berechnet die Bounding-Box und registriert das Dirty-Rect beim BS_RenderObjectManager.
*/
- void UpdateBoxes();
+ void UpdateBoxes();
/**
- @brief Berechnet die Bounding-Box des Objektes.
- @return Gibt die Bounding-Box des Objektes in Bildschirmkoordinaten zurück.
+ @brief Berechnet die Bounding-Box des Objektes.
+ @return Gibt die Bounding-Box des Objektes in Bildschirmkoordinaten zurück.
*/
BS_Rect CalcBoundingBox() const;
/**
- @brief Berechnet das Dirty-Rectangle des Objektes.
- @return Gibt das Dirty-Rectangle des Objektes in Bildschirmkoordinaten zurück.
+ @brief Berechnet das Dirty-Rectangle des Objektes.
+ @return Gibt das Dirty-Rectangle des Objektes in Bildschirmkoordinaten zurück.
*/
BS_Rect CalcDirtyRect() const;
/**
- @brief Berechnet die absolute Position des Objektes.
+ @brief Berechnet die absolute Position des Objektes.
*/
void CalcAbsolutePos(int &X, int &Y) const;
/**
- @brief Berechnet die absolute Position des Objektes auf der X-Achse.
+ @brief Berechnet die absolute Position des Objektes auf der X-Achse.
*/
int CalcAbsoluteX() const;
/**
- @brief Berechnet die absolute Position des Objektes.
+ @brief Berechnet die absolute Position des Objektes.
*/
int CalcAbsoluteY() const;
/**
- @brief Sortiert alle Kinderobjekte nach ihrem Renderang.
+ @brief Sortiert alle Kinderobjekte nach ihrem Renderang.
*/
void SortRenderObjects();
/**
- @brief Validiert den Zustand eines Objektes nachdem die durch die Veränderung verursachten Folgen abgearbeitet wurden.
+ @brief Validiert den Zustand eines Objektes nachdem die durch die Veränderung verursachten Folgen abgearbeitet wurden.
*/
- void ValidateObject();
+ void ValidateObject();
/**
- @brief Berechnet die absolute Position des Objektes und aller seiner Kinderobjekte neu.
+ @brief Berechnet die absolute Position des Objektes und aller seiner Kinderobjekte neu.
- Diese Methode muss aufgerufen werden, wann immer sich die Position des Objektes verändert. Damit die Kinderobjekte immer die
- richtige absolute Position haben.
+ Diese Methode muss aufgerufen werden, wann immer sich die Position des Objektes verändert. Damit die Kinderobjekte immer die
+ richtige absolute Position haben.
*/
void UpdateAbsolutePos();
/**
- @brief Teilt dem Objekt mit, dass sich eines seiner Kinderobjekte dahingehend verändert hat, die eine erneute Bestimmung der
- Rendereihenfolge verlangt.
+ @brief Teilt dem Objekt mit, dass sich eines seiner Kinderobjekte dahingehend verändert hat, die eine erneute Bestimmung der
+ Rendereihenfolge verlangt.
*/
- void SignalChildChange() { m_ChildChanged = true; }
+ void SignalChildChange() {
+ m_ChildChanged = true;
+ }
/**
- @brief Berechnet des Schnittrechteck der Bounding-Box des Objektes mit einem anderen Objekt.
- @param pObjekt ein Pointer auf das Objekt mit dem geschnitten werden soll
- @param Result das Ergebnisrechteck
- @return Gibt false zurück, falls sich die Objekte gar nicht schneiden.
+ @brief Berechnet des Schnittrechteck der Bounding-Box des Objektes mit einem anderen Objekt.
+ @param pObjekt ein Pointer auf das Objekt mit dem geschnitten werden soll
+ @param Result das Ergebnisrechteck
+ @return Gibt false zurück, falls sich die Objekte gar nicht schneiden.
*/
- bool GetObjectIntersection(BS_RenderObjectPtr<BS_RenderObject> pObject, BS_Rect& Result);
+ bool GetObjectIntersection(BS_RenderObjectPtr<BS_RenderObject> pObject, BS_Rect &Result);
/**
- @brief Vergleichsoperator der auf Objektpointern basiert statt auf Objekten.
- @remark Diese Methode wird fürs Sortieren der Kinderliste nach der Rendereihenfolge benutzt.
+ @brief Vergleichsoperator der auf Objektpointern basiert statt auf Objekten.
+ @remark Diese Methode wird fürs Sortieren der Kinderliste nach der Rendereihenfolge benutzt.
*/
static bool Greater(const BS_RenderObjectPtr<BS_RenderObject> lhs, const BS_RenderObjectPtr<BS_RenderObject> rhs);
};
diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp
index a77e71b110..10b717c460 100644
--- a/engines/sword25/gfx/renderobjectmanager.cpp
+++ b/engines/sword25/gfx/renderobjectmanager.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -57,16 +57,14 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) :
- m_FrameStarted(false)
-{
+ m_FrameStarted(false) {
// Wurzel des BS_RenderObject-Baumes erzeugen.
m_RootPtr = new BS_RootRenderObject(this, Width, Height);
}
// -----------------------------------------------------------------------------
-BS_RenderObjectManager::~BS_RenderObjectManager()
-{
+BS_RenderObjectManager::~BS_RenderObjectManager() {
// Die Wurzel des Baumes löschen, damit werden alle BS_RenderObjects mitgelöscht.
m_RootPtr.Erase();
}
@@ -75,8 +73,7 @@ BS_RenderObjectManager::~BS_RenderObjectManager()
// Interface
// -----------------------------------------------------------------------------
-void BS_RenderObjectManager::StartFrame()
-{
+void BS_RenderObjectManager::StartFrame() {
m_FrameStarted = true;
// Verstrichene Zeit bestimmen
@@ -90,8 +87,7 @@ void BS_RenderObjectManager::StartFrame()
// -----------------------------------------------------------------------------
-bool BS_RenderObjectManager::Render()
-{
+bool BS_RenderObjectManager::Render() {
// Den Objekt-Status des Wurzelobjektes aktualisieren. Dadurch werden rekursiv alle Baumelemente aktualisiert.
// Beim aktualisieren des Objekt-Status werden auch die Update-Rects gefunden, so dass feststeht, was neu gezeichnet
// werden muss.
@@ -105,25 +101,22 @@ bool BS_RenderObjectManager::Render()
// -----------------------------------------------------------------------------
-void BS_RenderObjectManager::AttatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> RenderObjectPtr)
-{
+void BS_RenderObjectManager::AttatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> RenderObjectPtr) {
m_TimedRenderObjects.push_back(RenderObjectPtr);
}
// -----------------------------------------------------------------------------
-void BS_RenderObjectManager::DetatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> RenderObjectPtr)
-{
+void BS_RenderObjectManager::DetatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> RenderObjectPtr) {
RenderObjectList::iterator Iter = find(m_TimedRenderObjects.begin(), m_TimedRenderObjects.end(), RenderObjectPtr);
- if (Iter != m_TimedRenderObjects.end()) m_TimedRenderObjects.erase(Iter);
+ if (Iter != m_TimedRenderObjects.end()) m_TimedRenderObjects.erase(Iter);
}
// -----------------------------------------------------------------------------
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
// Alle Kinder des Wurzelknotens speichern. Dadurch werden alle BS_RenderObjects gespeichert rekursiv gespeichert.
@@ -134,8 +127,7 @@ bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock & Writer)
// Referenzen auf die TimedRenderObjects persistieren.
Writer.Write(m_TimedRenderObjects.size());
RenderObjectList::const_iterator Iter = m_TimedRenderObjects.begin();
- while (Iter != m_TimedRenderObjects.end())
- {
+ while (Iter != m_TimedRenderObjects.end()) {
Writer.Write((*Iter)->GetHandle());
++Iter;
}
@@ -148,8 +140,7 @@ bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_RenderObjectManager::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_RenderObjectManager::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
// Alle Kinder des Wurzelknotens löschen. Damit werden alle BS_RenderObjects gelöscht.
@@ -166,8 +157,7 @@ bool BS_RenderObjectManager::Unpersist(BS_InputPersistenceBlock & Reader)
// Referenzen auf die TimedRenderObjects wieder herstellen.
unsigned int TimedObjectCount;
Reader.Read(TimedObjectCount);
- for (unsigned int i = 0; i < TimedObjectCount; ++i)
- {
+ for (unsigned int i = 0; i < TimedObjectCount; ++i) {
unsigned int Handle;
Reader.Read(Handle);
m_TimedRenderObjects.push_back(Handle);
diff --git a/engines/sword25/gfx/renderobjectmanager.h b/engines/sword25/gfx/renderobjectmanager.h
index f7ba5a71b5..9cd857f8b4 100644
--- a/engines/sword25/gfx/renderobjectmanager.h
+++ b/engines/sword25/gfx/renderobjectmanager.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,13 +33,13 @@
*/
/*
- BS_RenderObjectManager
- ----------------------
- Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig.
-
- Sie sorgt z.B. dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden.
+ BS_RenderObjectManager
+ ----------------------
+ Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig.
+
+ Sie sorgt z.B. dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden.
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_RENDEROBJECTMANAGER_H
@@ -63,59 +63,60 @@ class BS_RenderObject;
class BS_TimedRenderObject;
/**
- @brief Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig.
-
- Sie sorgt dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden und ermöglicht den Zugriff auf die
- BS_RenderObjects über einen String.
+ @brief Diese Klasse ist für die Verwaltung von BS_RenderObjects zuständig.
+
+ Sie sorgt dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden und ermöglicht den Zugriff auf die
+ BS_RenderObjects über einen String.
*/
-class BS_RenderObjectManager : public BS_Persistable
-{
+class BS_RenderObjectManager : public BS_Persistable {
public:
/**
- @brief Erzeugt ein neues BS_RenderObjectManager-Objekt.
- @param Width die horizontale Bildschirmauflösung in Pixeln
- @param Height die vertikale Bildschirmauflösung in Pixeln
- @param Die Anzahl an Framebuffern, die eingesetzt wird (Backbuffer + Primary).
+ @brief Erzeugt ein neues BS_RenderObjectManager-Objekt.
+ @param Width die horizontale Bildschirmauflösung in Pixeln
+ @param Height die vertikale Bildschirmauflösung in Pixeln
+ @param Die Anzahl an Framebuffern, die eingesetzt wird (Backbuffer + Primary).
*/
BS_RenderObjectManager(int Width, int Height, int FramebufferCount);
virtual ~BS_RenderObjectManager();
-
+
// Interface
// ---------
/**
- @brief Initialisiert den Manager für einen neuen Frame.
- @remark Alle Veränderungen an Objekten müssen nach einem Aufruf dieser Methode geschehen, damit sichergestellt ist, dass diese
- visuell umgesetzt werden.<br>
- Mit dem Aufruf dieser Methode werden die Rückgabewerte von GetUpdateRects() und GetUpdateRectCount() auf ihre Startwerte
- zurückgesetzt. Wenn man also mit diesen Werten arbeiten möchten, muss man dies nach einem Aufruf von Render() und vor
- einem Aufruf von StartFrame() tun.
+ @brief Initialisiert den Manager für einen neuen Frame.
+ @remark Alle Veränderungen an Objekten müssen nach einem Aufruf dieser Methode geschehen, damit sichergestellt ist, dass diese
+ visuell umgesetzt werden.<br>
+ Mit dem Aufruf dieser Methode werden die Rückgabewerte von GetUpdateRects() und GetUpdateRectCount() auf ihre Startwerte
+ zurückgesetzt. Wenn man also mit diesen Werten arbeiten möchten, muss man dies nach einem Aufruf von Render() und vor
+ einem Aufruf von StartFrame() tun.
*/
void StartFrame();
/**
- @brief Rendert alle Objekte die sich während des letzten Aufrufes von Render() verändert haben.
- @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
+ @brief Rendert alle Objekte die sich während des letzten Aufrufes von Render() verändert haben.
+ @return Gibt false zurück, falls das Rendern fehlgeschlagen ist.
*/
bool Render();
/**
- @brief Gibt einen Pointer auf die Wurzel des Objektbaumes zurück.
+ @brief Gibt einen Pointer auf die Wurzel des Objektbaumes zurück.
*/
- BS_RenderObjectPtr<BS_RenderObject> GetTreeRoot() { return m_RootPtr; }
+ BS_RenderObjectPtr<BS_RenderObject> GetTreeRoot() {
+ return m_RootPtr;
+ }
/**
- @brief Fügt ein BS_TimedRenderObject in die Liste der zeitabhängigen Render-Objekte.
+ @brief Fügt ein BS_TimedRenderObject in die Liste der zeitabhängigen Render-Objekte.
- Alle Objekte die sich in dieser Liste befinden werden vor jedem Frame über die seit dem letzten Frame
- vergangene Zeit informiert, so dass sich ihren Zustand zeitabhängig verändern können.
+ Alle Objekte die sich in dieser Liste befinden werden vor jedem Frame über die seit dem letzten Frame
+ vergangene Zeit informiert, so dass sich ihren Zustand zeitabhängig verändern können.
- @param RenderObject das einzufügende BS_TimedRenderObject
+ @param RenderObject das einzufügende BS_TimedRenderObject
*/
void AttatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> pRenderObject);
/**
- @brief Entfernt ein BS_TimedRenderObject aus der Liste für zeitabhängige Render-Objekte.
+ @brief Entfernt ein BS_TimedRenderObject aus der Liste für zeitabhängige Render-Objekte.
*/
void DetatchTimedRenderObject(BS_RenderObjectPtr<BS_TimedRenderObject> pRenderObject);
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
private:
bool m_FrameStarted;
@@ -126,7 +127,7 @@ private:
// ---------------------------
// Der Baum legt die hierachische Ordnung der BS_RenderObjects fest.
// Zu weiteren Informationen siehe: "renderobject.h"
- BS_RenderObjectPtr<BS_RenderObject> m_RootPtr; // Die Wurzel der Baumes
+ BS_RenderObjectPtr<BS_RenderObject> m_RootPtr; // Die Wurzel der Baumes
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/renderobjectptr.cpp b/engines/sword25/gfx/renderobjectptr.cpp
index f2eaa28d50..b32c185e47 100644
--- a/engines/sword25/gfx/renderobjectptr.cpp
+++ b/engines/sword25/gfx/renderobjectptr.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -35,7 +35,7 @@
namespace Sword25 {
-BS_RenderObjectPtr::BS_RenderObjectPtr(BS_RenderObject * RenderObjectPtr) {
+BS_RenderObjectPtr::BS_RenderObjectPtr(BS_RenderObject *RenderObjectPtr) {
m_Handle = RenderObjectPtr->GetHandle();
}
diff --git a/engines/sword25/gfx/renderobjectptr.h b/engines/sword25/gfx/renderobjectptr.h
index 89da5d28fc..9dc0cf3aba 100644
--- a/engines/sword25/gfx/renderobjectptr.h
+++ b/engines/sword25/gfx/renderobjectptr.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -55,8 +55,7 @@ class BS_RenderObject;
// -----------------------------------------------------------------------------
template<class T>
-class BS_RenderObjectPtr
-{
+class BS_RenderObjectPtr {
public:
BS_RenderObjectPtr() : m_Handle(0)
{}
@@ -64,25 +63,21 @@ public:
BS_RenderObjectPtr(unsigned int Handle) : m_Handle(Handle)
{}
- BS_RenderObjectPtr(BS_RenderObject * RenderObjectPtr);
+ BS_RenderObjectPtr(BS_RenderObject *RenderObjectPtr);
- T * operator->() const
- {
+ T *operator->() const {
return static_cast<T *>(BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle));
}
- bool operator==(const BS_RenderObjectPtr<T> & other)
- {
+ bool operator==(const BS_RenderObjectPtr<T> & other) {
return m_Handle == other.m_Handle;
}
- bool IsValid() const
- {
+ bool IsValid() const {
return BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle) != 0;
}
- void Erase()
- {
+ void Erase() {
delete static_cast<T *>(BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle));
m_Handle = 0;
}
diff --git a/engines/sword25/gfx/renderobjectregistry.cpp b/engines/sword25/gfx/renderobjectregistry.cpp
index ccfffc7999..4eecd54760 100644
--- a/engines/sword25/gfx/renderobjectregistry.cpp
+++ b/engines/sword25/gfx/renderobjectregistry.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,15 +54,13 @@ std::auto_ptr<BS_RenderObjectRegistry> BS_RenderObjectRegistry::m_InstancePtr;
// -----------------------------------------------------------------------------
-void BS_RenderObjectRegistry::LogErrorLn(const char * Message) const
-{
+void BS_RenderObjectRegistry::LogErrorLn(const char *Message) const {
BS_LOG_ERRORLN(Message);
}
// -----------------------------------------------------------------------------
-void BS_RenderObjectRegistry::LogWarningLn(const char * Message) const
-{
+void BS_RenderObjectRegistry::LogWarningLn(const char *Message) const {
BS_LOG_WARNINGLN(Message);
}
diff --git a/engines/sword25/gfx/renderobjectregistry.h b/engines/sword25/gfx/renderobjectregistry.h
index bf377e5b30..6aea5afab2 100644
--- a/engines/sword25/gfx/renderobjectregistry.h
+++ b/engines/sword25/gfx/renderobjectregistry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -60,7 +60,7 @@ class BS_RenderObject;
class BS_RenderObjectRegistry : public BS_ObjectRegistry<BS_RenderObject> {
public:
- static BS_RenderObjectRegistry & GetInstance() {
+ static BS_RenderObjectRegistry &GetInstance() {
if (!m_InstancePtr.get()) m_InstancePtr.reset(new BS_RenderObjectRegistry);
return *m_InstancePtr.get();
}
@@ -68,8 +68,8 @@ public:
virtual ~BS_RenderObjectRegistry() {}
private:
- virtual void LogErrorLn(const char * Message) const;
- virtual void LogWarningLn(const char * Message) const;
+ virtual void LogErrorLn(const char *Message) const;
+ virtual void LogWarningLn(const char *Message) const;
static std::auto_ptr<BS_RenderObjectRegistry> m_InstancePtr;
};
diff --git a/engines/sword25/gfx/rootrenderobject.h b/engines/sword25/gfx/rootrenderobject.h
index 6f5c1daaa4..bbb92a3dab 100644
--- a/engines/sword25/gfx/rootrenderobject.h
+++ b/engines/sword25/gfx/rootrenderobject.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,21 +50,21 @@ class BS_Kernel;
// Klassendefinition
class BS_RenderObjectManager;
-class BS_RootRenderObject : public BS_RenderObject
-{
-friend BS_RenderObjectManager;
+class BS_RootRenderObject : public BS_RenderObject {
+ friend BS_RenderObjectManager;
private:
- BS_RootRenderObject(BS_RenderObjectManager * ManagerPtr, int Width, int Height) :
- BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject>(), TYPE_ROOT)
- {
+ BS_RootRenderObject(BS_RenderObjectManager *ManagerPtr, int Width, int Height) :
+ BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject>(), TYPE_ROOT) {
m_ManagerPtr = ManagerPtr;
m_Width = Width;
m_Height = Height;
}
protected:
- virtual bool DoRender() { return true; }
+ virtual bool DoRender() {
+ return true;
+ }
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp
index 3e2f0f27b2..59e52e1ab4 100644
--- a/engines/sword25/gfx/screenshot.cpp
+++ b/engines/sword25/gfx/screenshot.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -47,21 +47,19 @@ using namespace std;
// -----------------------------------------------------------------------------
-struct RGB_PIXEL
-{
+struct RGB_PIXEL {
RGB_PIXEL(unsigned char _Red, unsigned char _Green, unsigned char _Blue) :
Red(_Red),
Green(_Green),
Blue(_Blue)
- {};
+ {};
unsigned char Red;
unsigned char Green;
unsigned char Blue;
};
-bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string & Filename)
-{
+bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) {
BS_ASSERT(Data.size() == Width * Height);
// Buffer für Bildschirminhalt in RGB reservieren
@@ -70,10 +68,8 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
// Framebufferdaten pixelweise von RGBA nach RGB konvertieren
vector<unsigned int>::const_iterator it = Data.begin();
- for (unsigned int y = 0; y < Height; y++)
- {
- for (unsigned int x = 0; x < Width; x++)
- {
+ for (unsigned int y = 0; y < Height; y++) {
+ for (unsigned int x = 0; x < Width; x++) {
unsigned int SrcPixel = *it++;
PixelBuffer.push_back(RGB_PIXEL((SrcPixel >> 16) & 0xff, (SrcPixel >> 8) & 0xff, SrcPixel & 0xff));
}
@@ -82,29 +78,25 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
BS_ASSERT(Data.size() == PixelBuffer.size());
// Variablen für die PNG-Erstellung
- FILE * OutFile = 0;
+ FILE *OutFile = 0;
png_structp png_ptr = 0;
png_infop info_ptr = 0;
- try
- {
+ try {
OutFile = fopen(Filename.c_str(), "wb");
- if (!OutFile)
- {
+ if (!OutFile) {
BS_LOG_ERRORLN("Could not create screenshot-file \"%s\".", Filename.c_str());
throw(0);
}
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr)
- {
+ if (!png_ptr) {
BS_LOG_ERRORLN("Could not create PNG write-struct.");
throw(0);
}
png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr)
- {
+ if (!info_ptr) {
BS_LOG_ERRORLN("Could not create PNG info-struct.");
throw(0);
}
@@ -115,20 +107,19 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
png_set_compression_buffer_size(png_ptr, (Width * Height * 3 * 110) / 100);
// PNG-Info Struktur initialisieren
- png_set_IHDR(png_ptr, info_ptr,
- Width, // Breite
- Height, // Höhe
- 8, // Bittiefe pro Kanal
- PNG_COLOR_TYPE_RGB, // Farbformat
- PNG_INTERLACE_NONE, // Interlacing-Typ
- PNG_COMPRESSION_TYPE_DEFAULT, // Kompressions-Typ
- PNG_FILTER_TYPE_DEFAULT); // Filter-Typ
+ png_set_IHDR(png_ptr, info_ptr,
+ Width, // Breite
+ Height, // Höhe
+ 8, // Bittiefe pro Kanal
+ PNG_COLOR_TYPE_RGB, // Farbformat
+ PNG_INTERLACE_NONE, // Interlacing-Typ
+ PNG_COMPRESSION_TYPE_DEFAULT, // Kompressions-Typ
+ PNG_FILTER_TYPE_DEFAULT); // Filter-Typ
// Rowpointer erstellen
vector<png_bytep> RowPointers;
RowPointers.reserve(Height);
- for (unsigned int i = 0; i < Height; i++)
- {
+ for (unsigned int i = 0; i < Height; i++) {
RowPointers.push_back((png_bytep)(&PixelBuffer[Width * i]));
}
png_set_rows(png_ptr, info_ptr, &RowPointers[0]);
@@ -142,11 +133,9 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
fclose(OutFile);
}
- catch (int)
- {
+ catch (int) {
// Wenn die Datei bereits erstellt wurde, Datei schließen und löschen.
- if (OutFile)
- {
+ if (OutFile) {
fclose(OutFile);
remove(Filename.c_str());
}
@@ -163,8 +152,7 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
// -----------------------------------------------------------------------------
-bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string & Filename)
-{
+bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) {
//
// Diese Methode nimmt ein Screenshot mit den Maßen von 800x600 und erzeugt einen Screenshot mit den Maßen von 200x125.
// Dabei werden je 50 Pixel oben und unten abgeschnitten (die Interface-Leisten im Spiel). Das verbleibende Bild von 800x500 wird auf
@@ -173,27 +161,23 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
//
// Die Ausgangsgröße muss 800x600 sein.
- if (Width != 800 || Height != 600)
- {
+ if (Width != 800 || Height != 600) {
BS_LOG_ERRORLN("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail.");
return false;
}
-
+
// Buffer für die Zieldaten erstellen (RGBA Bild mit den Maßen 200x125).
vector<unsigned int> ThumbnailData(200 * 125);
// Über das Zielbild iterieren und einen Pixel zur Zeit berechnen.
unsigned int x, y;
x = y = 0;
- for(vector<unsigned int>::iterator Iter = ThumbnailData.begin(); Iter != ThumbnailData.end(); ++Iter)
- {
+ for (vector<unsigned int>::iterator Iter = ThumbnailData.begin(); Iter != ThumbnailData.end(); ++Iter) {
// Durchschnitt über 4x4 Pixelblock im Quellbild bilden.
unsigned int Alpha, Red, Green, Blue;
Alpha = Red = Green = Blue = 0;
- for (unsigned int j = 0; j < 4; ++j)
- {
- for (unsigned int i = 0; i < 4; ++i)
- {
+ for (unsigned int j = 0; j < 4; ++j) {
+ for (unsigned int i = 0; i < 4; ++i) {
unsigned int Pixel = Data[((y * 4) + j + 50) * 800 + ((x * 4) + i)];
Alpha += (Pixel >> 24);
Red += (Pixel >> 16) & 0xff;
@@ -207,8 +191,7 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
// Mitzählen an welcher Stelle im Zielbild wir uns befinden.
++x;
- if (x == 200)
- {
+ if (x == 200) {
x = 0;
++y;
}
diff --git a/engines/sword25/gfx/screenshot.h b/engines/sword25/gfx/screenshot.h
index 9e9fef422b..10e176c1a4 100644
--- a/engines/sword25/gfx/screenshot.h
+++ b/engines/sword25/gfx/screenshot.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -32,7 +32,7 @@
*
*/
-#ifndef SWORD25_SCREENSHOT_H
+#ifndef SWORD25_SCREENSHOT_H
#define SWORD25_SCREENSHOT_H
// -----------------------------------------------------------------------------
@@ -51,11 +51,10 @@ namespace Sword25 {
// Class declaration
// -----------------------------------------------------------------------------
-class BS_Screenshot
-{
+class BS_Screenshot {
public:
- static bool SaveToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String & Filename);
- static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String & Filename);
+ static bool SaveToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename);
+ static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename);
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp
index 161d8f8f8f..f4ad8151dc 100644
--- a/engines/sword25/gfx/staticbitmap.cpp
+++ b/engines/sword25/gfx/staticbitmap.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,9 +54,8 @@ namespace Sword25 {
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_StaticBitmap::BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String& Filename) :
- BS_Bitmap(ParentPtr, TYPE_STATICBITMAP)
-{
+BS_StaticBitmap::BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &Filename) :
+ BS_Bitmap(ParentPtr, TYPE_STATICBITMAP) {
// Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
if (!m_InitSuccess) return;
@@ -65,30 +64,26 @@ BS_StaticBitmap::BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
// -----------------------------------------------------------------------------
-BS_StaticBitmap::BS_StaticBitmap(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
- BS_Bitmap(ParentPtr, TYPE_STATICBITMAP, Handle)
-{
+BS_StaticBitmap::BS_StaticBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
+ BS_Bitmap(ParentPtr, TYPE_STATICBITMAP, Handle) {
m_InitSuccess = Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::InitBitmapResource(const Common::String & Filename)
-{
+bool BS_StaticBitmap::InitBitmapResource(const Common::String &Filename) {
// Bild-Resource laden
- BS_Resource* ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(Filename);
- if (!ResourcePtr)
- {
+ BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(Filename);
+ if (!ResourcePtr) {
BS_LOG_ERRORLN("Could not request resource \"%s\".", Filename.c_str());
return false;
}
- if (ResourcePtr->GetType() != BS_Resource::TYPE_BITMAP)
- {
+ if (ResourcePtr->GetType() != BS_Resource::TYPE_BITMAP) {
BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", Filename.c_str());
return false;
}
- BS_BitmapResource * BitmapPtr = static_cast<BS_BitmapResource*>(ResourcePtr);
+ BS_BitmapResource *BitmapPtr = static_cast<BS_BitmapResource *>(ResourcePtr);
// Den eindeutigen Dateinamen zum späteren Referenzieren speichern
m_ResourceFilename = BitmapPtr->GetFileName();
@@ -105,39 +100,34 @@ bool BS_StaticBitmap::InitBitmapResource(const Common::String & Filename)
// -----------------------------------------------------------------------------
-BS_StaticBitmap::~BS_StaticBitmap()
-{
+BS_StaticBitmap::~BS_StaticBitmap() {
}
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::DoRender()
-{
+bool BS_StaticBitmap::DoRender() {
// Bitmap holen
- BS_Resource* ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
+ BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
BS_ASSERT(ResourcePtr);
BS_ASSERT(ResourcePtr->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource * BitmapResourcePtr = static_cast<BS_BitmapResource*>(ResourcePtr);
+ BS_BitmapResource *BitmapResourcePtr = static_cast<BS_BitmapResource *>(ResourcePtr);
// Framebufferobjekt holen
- BS_GraphicEngine * GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
+ BS_GraphicEngine *GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(GfxPtr);
// Bitmap zeichnen
bool Result;
- if (m_ScaleFactorX == 1.0f && m_ScaleFactorY == 1.0f)
- {
+ if (m_ScaleFactorX == 1.0f && m_ScaleFactorY == 1.0f) {
Result = BitmapResourcePtr->Blit(m_AbsoluteX, m_AbsoluteY,
- (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, -1, -1);
- }
- else
- {
+ (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, -1, -1);
+ } else {
Result = BitmapResourcePtr->Blit(m_AbsoluteX, m_AbsoluteY,
- (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
- (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
- 0, m_ModulationColor, m_Width, m_Height);
+ (m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
+ (m_FlipH ? BS_BitmapResource::FLIP_H : 0),
+ 0, m_ModulationColor, m_Width, m_Height);
}
// Resource freigeben
@@ -148,14 +138,13 @@ bool BS_StaticBitmap::DoRender()
// -----------------------------------------------------------------------------
-unsigned int BS_StaticBitmap::GetPixel(int X, int Y) const
-{
+unsigned int BS_StaticBitmap::GetPixel(int X, int Y) const {
BS_ASSERT(X >= 0 && X < m_Width);
BS_ASSERT(Y >= 0 && Y < m_Height);
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- BS_BitmapResource* pBitmapResource = static_cast<BS_BitmapResource*>(pResource);
+ BS_BitmapResource *pBitmapResource = static_cast<BS_BitmapResource *>(pResource);
unsigned int Result = pBitmapResource->GetPixel(X, Y);
pResource->Release();
return Result;
@@ -163,8 +152,7 @@ unsigned int BS_StaticBitmap::GetPixel(int X, int Y) const
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride)
-{
+bool BS_StaticBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) {
BS_LOG_ERRORLN("SetContent() ist not supported with this object.");
return false;
}
@@ -173,33 +161,30 @@ bool BS_StaticBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, uns
// Auskunftsmethoden
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::IsAlphaAllowed() const
-{
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
+bool BS_StaticBitmap::IsAlphaAllowed() const {
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- bool Result = static_cast<BS_BitmapResource*>(pResource)->IsAlphaAllowed();
+ bool Result = static_cast<BS_BitmapResource *>(pResource)->IsAlphaAllowed();
pResource->Release();
return Result;
}
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::IsColorModulationAllowed() const
-{
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
+bool BS_StaticBitmap::IsColorModulationAllowed() const {
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- bool Result = static_cast<BS_BitmapResource*>(pResource)->IsColorModulationAllowed();
+ bool Result = static_cast<BS_BitmapResource *>(pResource)->IsColorModulationAllowed();
pResource->Release();
return Result;
}
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::IsScalingAllowed() const
-{
- BS_Resource* pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
+bool BS_StaticBitmap::IsScalingAllowed() const {
+ BS_Resource *pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(m_ResourceFilename);
BS_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
- bool Result = static_cast<BS_BitmapResource*>(pResource)->IsScalingAllowed();
+ bool Result = static_cast<BS_BitmapResource *>(pResource)->IsScalingAllowed();
pResource->Release();
return Result;
}
@@ -208,8 +193,7 @@ bool BS_StaticBitmap::IsScalingAllowed() const
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_Bitmap::Persist(Writer);
@@ -220,8 +204,7 @@ bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock & Writer)
return Result;
}
-bool BS_StaticBitmap::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_StaticBitmap::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_Bitmap::Unpersist(Reader);
diff --git a/engines/sword25/gfx/staticbitmap.h b/engines/sword25/gfx/staticbitmap.h
index c204d8fb9d..816f2a2b20 100644
--- a/engines/sword25/gfx/staticbitmap.h
+++ b/engines/sword25/gfx/staticbitmap.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,39 +48,40 @@ namespace Sword25 {
// Klassendeklaration
// -----------------------------------------------------------------------------
-class BS_StaticBitmap : public BS_Bitmap
-{
-friend class BS_RenderObject;
+class BS_StaticBitmap : public BS_Bitmap {
+ friend class BS_RenderObject;
private:
/**
- @remark Filename muss absoluter Pfad sein
+ @remark Filename muss absoluter Pfad sein
*/
- BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String& Filename);
- BS_StaticBitmap(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
+ BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &Filename);
+ BS_StaticBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
public:
virtual ~BS_StaticBitmap();
virtual unsigned int GetPixel(int X, int Y) const;
- virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
+ virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
- virtual bool IsScalingAllowed() const;
- virtual bool IsAlphaAllowed() const;
- virtual bool IsColorModulationAllowed() const;
- virtual bool IsSetContentAllowed() const { return false; }
+ virtual bool IsScalingAllowed() const;
+ virtual bool IsAlphaAllowed() const;
+ virtual bool IsColorModulationAllowed() const;
+ virtual bool IsSetContentAllowed() const {
+ return false;
+ }
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
- virtual bool DoRender();
+ virtual bool DoRender();
private:
Common::String m_ResourceFilename;
- bool InitBitmapResource(const Common::String & Filename);
+ bool InitBitmapResource(const Common::String &Filename);
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp
index b1bf673fa5..eafd6d8152 100644
--- a/engines/sword25/gfx/text.cpp
+++ b/engines/sword25/gfx/text.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -56,9 +56,8 @@ namespace Sword25 {
// Konstanten
// -----------------------------------------------------------------------------
-namespace
-{
- const unsigned int AUTO_WRAP_THRESHOLD_DEFAULT = 300;
+namespace {
+const unsigned int AUTO_WRAP_THRESHOLD_DEFAULT = 300;
}
// -----------------------------------------------------------------------------
@@ -69,33 +68,27 @@ BS_Text::BS_Text(BS_RenderObjectPtr<BS_RenderObject> ParentPtr) :
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_TEXT),
m_ModulationColor(0xffffffff),
m_AutoWrap(false),
- m_AutoWrapThreshold(AUTO_WRAP_THRESHOLD_DEFAULT)
-{
-
+ m_AutoWrapThreshold(AUTO_WRAP_THRESHOLD_DEFAULT) {
+
}
// -----------------------------------------------------------------------------
-BS_Text::BS_Text(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
- BS_RenderObject(ParentPtr, TYPE_TEXT, Handle)
-{
+BS_Text::BS_Text(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
+ BS_RenderObject(ParentPtr, TYPE_TEXT, Handle) {
m_InitSuccess = Unpersist(Reader);
}
// -----------------------------------------------------------------------------
-bool BS_Text::SetFont(const Common::String & Font)
-{
+bool BS_Text::SetFont(const Common::String &Font) {
// Font precachen.
- if (GetResourceManager()->PrecacheResource(Font))
- {
+ if (GetResourceManager()->PrecacheResource(Font)) {
m_Font = Font;
UpdateFormat();
ForceRefresh();
return true;
- }
- else
- {
+ } else {
BS_LOG_ERRORLN("Could not precache font \"%s\". Font probably does not exist.", Font.c_str());
return false;
}
@@ -104,8 +97,7 @@ bool BS_Text::SetFont(const Common::String & Font)
// -----------------------------------------------------------------------------
-void BS_Text::SetText(const Common::String & Text)
-{
+void BS_Text::SetText(const Common::String &Text) {
m_Text = Text;
UpdateFormat();
ForceRefresh();
@@ -113,11 +105,9 @@ void BS_Text::SetText(const Common::String & Text)
// -----------------------------------------------------------------------------
-void BS_Text::SetColor(unsigned int ModulationColor)
-{
+void BS_Text::SetColor(unsigned int ModulationColor) {
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -125,12 +115,10 @@ void BS_Text::SetColor(unsigned int ModulationColor)
// -----------------------------------------------------------------------------
-void BS_Text::SetAlpha(int Alpha)
-{
+void BS_Text::SetAlpha(int Alpha) {
BS_ASSERT(Alpha >= 0 && Alpha < 256);
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
- if (NewModulationColor != m_ModulationColor)
- {
+ if (NewModulationColor != m_ModulationColor) {
m_ModulationColor = NewModulationColor;
ForceRefresh();
}
@@ -138,10 +126,8 @@ void BS_Text::SetAlpha(int Alpha)
// -----------------------------------------------------------------------------
-void BS_Text::SetAutoWrap(bool AutoWrap)
-{
- if (AutoWrap != m_AutoWrap)
- {
+void BS_Text::SetAutoWrap(bool AutoWrap) {
+ if (AutoWrap != m_AutoWrap) {
m_AutoWrap = AutoWrap;
UpdateFormat();
ForceRefresh();
@@ -150,10 +136,8 @@ void BS_Text::SetAutoWrap(bool AutoWrap)
// -----------------------------------------------------------------------------
-void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold)
-{
- if (AutoWrapThreshold != m_AutoWrapThreshold)
- {
+void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold) {
+ if (AutoWrapThreshold != m_AutoWrapThreshold) {
m_AutoWrapThreshold = AutoWrapThreshold;
UpdateFormat();
ForceRefresh();
@@ -162,39 +146,35 @@ void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold)
// -----------------------------------------------------------------------------
-bool BS_Text::DoRender()
-{
+bool BS_Text::DoRender() {
// Font-Resource locken.
- BS_FontResource * FontPtr = LockFontResource();
+ BS_FontResource *FontPtr = LockFontResource();
if (!FontPtr) return false;
// Charactermap-Resource locken.
- BS_ResourceManager * RMPtr = GetResourceManager();
- BS_BitmapResource * CharMapPtr;
+ BS_ResourceManager *RMPtr = GetResourceManager();
+ BS_BitmapResource *CharMapPtr;
{
- BS_Resource * pResource = RMPtr->RequestResource(FontPtr->GetCharactermapFileName());
- if (!pResource)
- {
+ BS_Resource *pResource = RMPtr->RequestResource(FontPtr->GetCharactermapFileName());
+ if (!pResource) {
BS_LOG_ERRORLN("Could not request resource \"%s\".", FontPtr->GetCharactermapFileName().c_str());
return false;
}
- if (pResource->GetType() != BS_Resource::TYPE_BITMAP)
- {
+ if (pResource->GetType() != BS_Resource::TYPE_BITMAP) {
BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", FontPtr->GetCharactermapFileName().c_str());
return false;
}
- CharMapPtr = static_cast<BS_BitmapResource*>(pResource);
+ CharMapPtr = static_cast<BS_BitmapResource *>(pResource);
}
// Framebufferobjekt holen.
- BS_GraphicEngine * GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
+ BS_GraphicEngine *GfxPtr = static_cast<BS_GraphicEngine *>(BS_Kernel::GetInstance()->GetService("gfx"));
BS_ASSERT(GfxPtr);
bool Result = true;
Common::Array<LINE>::iterator Iter = m_Lines.begin();
- for (; Iter != m_Lines.end(); ++Iter)
- {
+ for (; Iter != m_Lines.end(); ++Iter) {
// Feststellen, ob überhaupt Buchstaben der aktuellen Zeile vom Update betroffen sind.
BS_Rect CheckRect = (*Iter).BBox;
CheckRect.Move(m_AbsoluteX, m_AbsoluteY);
@@ -202,8 +182,7 @@ bool BS_Text::DoRender()
// Jeden Buchstaben einzeln Rendern.
int CurX = m_AbsoluteX + (*Iter).BBox.left;
int CurY = m_AbsoluteY + (*Iter).BBox.top;
- for (unsigned int i = 0; i < (*Iter).Text.size(); ++i)
- {
+ for (unsigned int i = 0; i < (*Iter).Text.size(); ++i) {
BS_Rect CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text.at(i));
BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight());
@@ -213,7 +192,7 @@ bool BS_Text::DoRender()
Result = CharMapPtr->Blit(RenderX, RenderY, BS_Image::FLIP_NONE, &RenderRect, m_ModulationColor);
if (!Result) break;
- CurX += CurRect.GetWidth() + FontPtr->GetGapWidth();
+ CurX += CurRect.GetWidth() + FontPtr->GetGapWidth();
}
}
@@ -228,34 +207,30 @@ bool BS_Text::DoRender()
// -----------------------------------------------------------------------------
-BS_ResourceManager * BS_Text::GetResourceManager()
-{
+BS_ResourceManager *BS_Text::GetResourceManager() {
// Pointer auf den Resource-Manager holen.
return BS_Kernel::GetInstance()->GetResourceManager();
}
// -----------------------------------------------------------------------------
-BS_FontResource * BS_Text::LockFontResource()
-{
- BS_ResourceManager * RMPtr = GetResourceManager();
+BS_FontResource *BS_Text::LockFontResource() {
+ BS_ResourceManager *RMPtr = GetResourceManager();
// Font-Resource locken.
- BS_FontResource * FontPtr;
+ BS_FontResource *FontPtr;
{
- BS_Resource * ResourcePtr = RMPtr->RequestResource(m_Font);
- if (!ResourcePtr)
- {
+ BS_Resource *ResourcePtr = RMPtr->RequestResource(m_Font);
+ if (!ResourcePtr) {
BS_LOG_ERRORLN("Could not request resource \"%s\".", m_Font.c_str());
return NULL;
}
- if (ResourcePtr->GetType() != BS_Resource::TYPE_FONT)
- {
+ if (ResourcePtr->GetType() != BS_Resource::TYPE_FONT) {
BS_LOG_ERRORLN("Requested resource \"%s\" is not a font.", m_Font.c_str());
return NULL;
}
- FontPtr = static_cast<BS_FontResource*>(ResourcePtr);
+ FontPtr = static_cast<BS_FontResource *>(ResourcePtr);
}
return FontPtr;
@@ -263,16 +238,14 @@ BS_FontResource * BS_Text::LockFontResource()
// -----------------------------------------------------------------------------
-void BS_Text::UpdateFormat()
-{
- BS_FontResource * FontPtr = LockFontResource();
+void BS_Text::UpdateFormat() {
+ BS_FontResource *FontPtr = LockFontResource();
BS_ASSERT(FontPtr);
UpdateMetrics(*FontPtr);
m_Lines.resize(1);
- if (m_AutoWrap && (unsigned int) m_Width >= m_AutoWrapThreshold && m_Text.size() >= 2)
- {
+ if (m_AutoWrap && (unsigned int) m_Width >= m_AutoWrapThreshold && m_Text.size() >= 2) {
m_Width = 0;
unsigned int CurLineWidth = 0;
unsigned int CurLineHeight = 0;
@@ -280,19 +253,17 @@ void BS_Text::UpdateFormat()
unsigned int TempLineWidth = 0;
unsigned int LastSpace = 0; // we need at least 1 space character to start a new line...
m_Lines[0].Text = "";
- for (unsigned int i = 0; i < m_Text.size(); ++i)
- {
+ for (unsigned int i = 0; i < m_Text.size(); ++i) {
unsigned int j;
TempLineWidth = 0;
LastSpace = 0;
- for (j = i; j < m_Text.size(); ++j)
- {
+ for (j = i; j < m_Text.size(); ++j) {
if ((unsigned char)m_Text[j] == ' ') LastSpace = j;
- const BS_Rect & CurCharRect = FontPtr->GetCharacterRect((unsigned char)m_Text[j]);
+ const BS_Rect &CurCharRect = FontPtr->GetCharacterRect((unsigned char)m_Text[j]);
TempLineWidth += CurCharRect.GetWidth();
TempLineWidth += FontPtr->GetGapWidth();
-
+
if ((TempLineWidth >= m_AutoWrapThreshold) && (LastSpace > 0))
break;
}
@@ -301,46 +272,41 @@ void BS_Text::UpdateFormat()
CurLineWidth = 0;
CurLineHeight = 0;
- for (j = i; j < LastSpace; ++j)
- {
+ for (j = i; j < LastSpace; ++j) {
m_Lines[CurLine].Text += m_Text[j];
- const BS_Rect & CurCharRect = FontPtr->GetCharacterRect((unsigned char)m_Text[j]);
+ const BS_Rect &CurCharRect = FontPtr->GetCharacterRect((unsigned char)m_Text[j]);
CurLineWidth += CurCharRect.GetWidth();
CurLineWidth += FontPtr->GetGapWidth();
if ((unsigned int) CurCharRect.GetHeight() > CurLineHeight) CurLineHeight = CurCharRect.GetHeight();
- }
+ }
m_Lines[CurLine].BBox.right = CurLineWidth;
m_Lines[CurLine].BBox.bottom = CurLineHeight;
if ((unsigned int) m_Width < CurLineWidth) m_Width = CurLineWidth;
-
- if(LastSpace < m_Text.size())
- {
+
+ if (LastSpace < m_Text.size()) {
++CurLine;
BS_ASSERT(CurLine == m_Lines.size());
m_Lines.resize(CurLine + 1);
- m_Lines[CurLine].Text = "";
- }
-
+ m_Lines[CurLine].Text = "";
+ }
+
i = LastSpace;
}
// Bounding-Box der einzelnen Zeilen relativ zur ersten festlegen (vor allem zentrieren).
m_Height = 0;
Common::Array<LINE>::iterator Iter = m_Lines.begin();
- for (; Iter != m_Lines.end(); ++Iter)
- {
- BS_Rect & BBox = (*Iter).BBox;
+ for (; Iter != m_Lines.end(); ++Iter) {
+ BS_Rect &BBox = (*Iter).BBox;
BBox.left = (m_Width - BBox.right) / 2;
BBox.right = BBox.left + BBox.right;
- BBox.top = (Iter - m_Lines.begin()) * FontPtr->GetLineHeight();
+ BBox.top = (Iter - m_Lines.begin()) * FontPtr->GetLineHeight();
BBox.bottom = BBox.top + BBox.bottom;
m_Height += BBox.GetHeight();
}
- }
- else
- {
+ } else {
// Keine automatische Formatierung, also wird der gesamte Text in nur eine Zeile kopiert.
m_Lines[0].Text = m_Text;
m_Lines[0].BBox = BS_Rect(0, 0, m_Width, m_Height);
@@ -351,14 +317,12 @@ void BS_Text::UpdateFormat()
// -----------------------------------------------------------------------------
-void BS_Text::UpdateMetrics(BS_FontResource & FontResource)
-{
+void BS_Text::UpdateMetrics(BS_FontResource &FontResource) {
m_Width = 0;
m_Height = 0;
- for (unsigned int i = 0; i < m_Text.size(); ++i)
- {
- const BS_Rect & CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i));
+ for (unsigned int i = 0; i < m_Text.size(); ++i) {
+ const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i));
m_Width += CurRect.GetWidth();
if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth();
if (m_Height < CurRect.GetHeight()) m_Height = CurRect.GetHeight();
@@ -369,8 +333,7 @@ void BS_Text::UpdateMetrics(BS_FontResource & FontResource)
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_Text::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_Text::Persist(BS_OutputPersistenceBlock &Writer) {
bool Result = true;
Result &= BS_RenderObject::Persist(Writer);
@@ -386,8 +349,7 @@ bool BS_Text::Persist(BS_OutputPersistenceBlock & Writer)
return Result;
}
-bool BS_Text::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_Text::Unpersist(BS_InputPersistenceBlock &Reader) {
bool Result = true;
Result &= BS_RenderObject::Unpersist(Reader);
diff --git a/engines/sword25/gfx/text.h b/engines/sword25/gfx/text.h
index 597eb00839..67295048d2 100644
--- a/engines/sword25/gfx/text.h
+++ b/engines/sword25/gfx/text.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -61,113 +61,123 @@ class BS_ResourceManager;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_Text : public BS_RenderObject
-{
-friend class BS_RenderObject;
+class BS_Text : public BS_RenderObject {
+ friend class BS_RenderObject;
public:
/**
- @brief Setzt den Font mit dem der Text dargestellt werden soll.
- @param Font der Dateiname der Fontdatei.
- @return Gibt false zurück, wenn der Font nicht gefunden wurde.
+ @brief Setzt den Font mit dem der Text dargestellt werden soll.
+ @param Font der Dateiname der Fontdatei.
+ @return Gibt false zurück, wenn der Font nicht gefunden wurde.
*/
- bool SetFont(const Common::String & Font);
+ bool SetFont(const Common::String &Font);
/**
- @brief Setzt den darzustellenden Text.
- @param Text der darzustellende Text
+ @brief Setzt den darzustellenden Text.
+ @param Text der darzustellende Text
*/
- void SetText(const Common::String & Text);
+ void SetText(const Common::String &Text);
/**
- @brief Setzt den Alphawert des Textes.
- @param Alpha der neue Alphawert des Textes (0 = keine Deckung, 255 = volle Deckung).
+ @brief Setzt den Alphawert des Textes.
+ @param Alpha der neue Alphawert des Textes (0 = keine Deckung, 255 = volle Deckung).
*/
void SetAlpha(int Alpha);
/**
- @brief Legt fest, ob der Text automatisch umgebrochen werden soll.
+ @brief Legt fest, ob der Text automatisch umgebrochen werden soll.
- Wenn dieses Attribut auf true gesetzt ist, wird der Text umgebrochen, sofern er länger als GetAutoWrapThreshold() ist.
+ Wenn dieses Attribut auf true gesetzt ist, wird der Text umgebrochen, sofern er länger als GetAutoWrapThreshold() ist.
- @param AutoWrap gibt an, ob der automatische Umbruch aktiviert oder deaktiviert werden soll.
- @remark Dieses Attribut wird mit dem Wert false initialisiert.
+ @param AutoWrap gibt an, ob der automatische Umbruch aktiviert oder deaktiviert werden soll.
+ @remark Dieses Attribut wird mit dem Wert false initialisiert.
*/
void SetAutoWrap(bool AutoWrap);
/**
- @brief Legt die Längengrenze des Textes in Pixeln fest, ab der ein automatischer Zeilenumbruch vorgenommen wird.
- @remark Dieses Attribut wird mit dem Wert 300 initialisiert.
- @remark Eine automatische Formatierung wird nur vorgenommen, wenn diese durch einen Aufruf von SetAutoWrap() aktiviert wurde.
+ @brief Legt die Längengrenze des Textes in Pixeln fest, ab der ein automatischer Zeilenumbruch vorgenommen wird.
+ @remark Dieses Attribut wird mit dem Wert 300 initialisiert.
+ @remark Eine automatische Formatierung wird nur vorgenommen, wenn diese durch einen Aufruf von SetAutoWrap() aktiviert wurde.
*/
void SetAutoWrapThreshold(unsigned int AutoWrapThreshold);
/**
- @brief Gibt den dargestellten Text zurück.
+ @brief Gibt den dargestellten Text zurück.
*/
- const Common::String & GetText() { return m_Text; }
+ const Common::String &GetText() {
+ return m_Text;
+ }
/**
@brief Gibt den Namen das momentan benutzten Fonts zurück.
*/
- const Common::String & GetFont() { return m_Font; }
+ const Common::String &GetFont() {
+ return m_Font;
+ }
/**
- @brief Setzt die Farbe des Textes.
- @param Color eine 24-Bit RGB Farbe, die die Farbe des Textes festlegt.
+ @brief Setzt die Farbe des Textes.
+ @param Color eine 24-Bit RGB Farbe, die die Farbe des Textes festlegt.
*/
void SetColor(unsigned int ModulationColor);
/**
- @brief Gibt den Alphawert des Textes zurück.
- @return Der Alphawert des Textes (0 = keine Deckung, 255 = volle Deckung).
+ @brief Gibt den Alphawert des Textes zurück.
+ @return Der Alphawert des Textes (0 = keine Deckung, 255 = volle Deckung).
*/
- int GetAlpha() const { return m_ModulationColor >> 24; }
+ int GetAlpha() const {
+ return m_ModulationColor >> 24;
+ }
/**
- @brief Gibt die Farbe des Textes zurück.
- @return Eine 24-Bit RGB Farbe, die die Farbe des Textes angibt.
+ @brief Gibt die Farbe des Textes zurück.
+ @return Eine 24-Bit RGB Farbe, die die Farbe des Textes angibt.
*/
- int GetColor() const { return m_ModulationColor & 0x00ffffff; }
+ int GetColor() const {
+ return m_ModulationColor & 0x00ffffff;
+ }
/**
- @brief Gibt zurück, ob die automatische Formatierung aktiviert ist.
+ @brief Gibt zurück, ob die automatische Formatierung aktiviert ist.
*/
- bool IsAutoWrapActive() const { return m_AutoWrap; }
+ bool IsAutoWrapActive() const {
+ return m_AutoWrap;
+ }
/**
- @brief Gibt die Längengrenze des Textes in Pixeln zurück, ab der eine automatische Formatierung vorgenommen wird.
+ @brief Gibt die Längengrenze des Textes in Pixeln zurück, ab der eine automatische Formatierung vorgenommen wird.
*/
- unsigned int GetAutoWrapThreshold() const { return m_AutoWrapThreshold; }
+ unsigned int GetAutoWrapThreshold() const {
+ return m_AutoWrapThreshold;
+ }
- virtual bool Persist(BS_OutputPersistenceBlock & Writer);
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader);
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer);
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
protected:
virtual bool DoRender();
private:
BS_Text(BS_RenderObjectPtr<BS_RenderObject> ParentPtr);
- BS_Text(BS_InputPersistenceBlock & Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
-
- unsigned int m_ModulationColor;
- Common::String m_Font;
- Common::String m_Text;
- bool m_AutoWrap;
- unsigned int m_AutoWrapThreshold;
-
- struct LINE
- {
- BS_Rect BBox;
- Common::String Text;
+ BS_Text(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
+
+ unsigned int m_ModulationColor;
+ Common::String m_Font;
+ Common::String m_Text;
+ bool m_AutoWrap;
+ unsigned int m_AutoWrapThreshold;
+
+ struct LINE {
+ BS_Rect BBox;
+ Common::String Text;
};
- Common::Array<LINE> m_Lines;
+ Common::Array<LINE> m_Lines;
void UpdateFormat();
- void UpdateMetrics(BS_FontResource & FontResource);
- BS_ResourceManager * GetResourceManager();
- BS_FontResource * LockFontResource();
+ void UpdateMetrics(BS_FontResource &FontResource);
+ BS_ResourceManager *GetResourceManager();
+ BS_FontResource *LockFontResource();
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/timedrenderobject.cpp b/engines/sword25/gfx/timedrenderobject.cpp
index 7adb3c5b7c..eff62c3135 100644
--- a/engines/sword25/gfx/timedrenderobject.cpp
+++ b/engines/sword25/gfx/timedrenderobject.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -43,14 +43,12 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
BS_TimedRenderObject::BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle) :
- BS_RenderObject(pParent, Type, Handle)
-{
+ BS_RenderObject(pParent, Type, Handle) {
BS_ASSERT(GetManager());
GetManager()->AttatchTimedRenderObject(this);
}
-BS_TimedRenderObject::~BS_TimedRenderObject()
-{
+BS_TimedRenderObject::~BS_TimedRenderObject() {
BS_ASSERT(GetManager());
GetManager()->DetatchTimedRenderObject(this);
}
diff --git a/engines/sword25/gfx/timedrenderobject.h b/engines/sword25/gfx/timedrenderobject.h
index f2aa4a638d..576ab64383 100644
--- a/engines/sword25/gfx/timedrenderobject.h
+++ b/engines/sword25/gfx/timedrenderobject.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,21 +54,20 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
/**
- @brief
+ @brief
*/
-class BS_TimedRenderObject : public BS_RenderObject
-{
+class BS_TimedRenderObject : public BS_RenderObject {
public:
BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle = 0);
~BS_TimedRenderObject();
/**
- @brief Teilt dem Objekt mit, dass ein neuer Frame begonnen wird.
+ @brief Teilt dem Objekt mit, dass ein neuer Frame begonnen wird.
- Diese Methode wird jeden Frame an jedem BS_TimedRenderObject aufgerufen um diesen zu ermöglichen
- ihren Zustand Zeitabhängig zu verändern (z.B. Animationen).<br>
- @param int TimeElapsed gibt an wie viel Zeit (in Microsekunden) seit dem letzten Frame vergangen ist.
+ Diese Methode wird jeden Frame an jedem BS_TimedRenderObject aufgerufen um diesen zu ermöglichen
+ ihren Zustand Zeitabhängig zu verändern (z.B. Animationen).<br>
+ @param int TimeElapsed gibt an wie viel Zeit (in Microsekunden) seit dem letzten Frame vergangen ist.
*/
virtual void FrameNotification(int TimeElapsed) = 0;
};
diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp
index 5b26bb81ba..7552118e54 100644
--- a/engines/sword25/input/inputengine.cpp
+++ b/engines/sword25/input/inputengine.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/input/inputengine.h b/engines/sword25/input/inputengine.h
index f88f67de38..c0f2b47bf5 100644
--- a/engines/sword25/input/inputengine.h
+++ b/engines/sword25/input/inputengine.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -57,15 +57,15 @@ namespace Sword25 {
class BS_InputEngine : public BS_Service, public BS_Persistable {
public:
- BS_InputEngine(BS_Kernel* pKernel);
- virtual ~BS_InputEngine(){};
+ BS_InputEngine(BS_Kernel *pKernel);
+ virtual ~BS_InputEngine() {};
// NOTE: These codes are registered in inputengine_script.cpp
// Any changes to these enums must also adjust the above file.
- enum KEY_CODES {
- KEY_BACKSPACE = 0x08,
- KEY_TAB = 0x09,
- KEY_CLEAR = 0x0C,
+ enum KEY_CODES {
+ KEY_BACKSPACE = 0x08,
+ KEY_TAB = 0x09,
+ KEY_CLEAR = 0x0C,
KEY_RETURN = 0x0D,
KEY_PAUSE = 0x13,
KEY_CAPSLOCK = 0x14,
@@ -79,45 +79,45 @@ public:
KEY_UP = 0x26,
KEY_RIGHT = 0x27,
KEY_DOWN = 0x28,
- KEY_PRINTSCREEN = 0x2C,
+ KEY_PRINTSCREEN = 0x2C,
KEY_INSERT = 0x2D,
KEY_DELETE = 0x2E,
- KEY_0 = 0x30,
- KEY_1 = 0x31,
- KEY_2 = 0x32,
- KEY_3 = 0x33,
- KEY_4 = 0x34,
- KEY_5 = 0x35,
- KEY_6 = 0x36,
- KEY_7 = 0x37,
- KEY_8 = 0x38,
- KEY_9 = 0x39,
- KEY_A = 0x41,
- KEY_B = 0x42,
- KEY_C = 0x43,
- KEY_D = 0x44,
- KEY_E = 0x45,
- KEY_F = 0x46,
- KEY_G = 0x47,
- KEY_H = 0x48,
- KEY_I = 0x49,
- KEY_J = 0x4A,
- KEY_K = 0x4B,
- KEY_L = 0x4C,
- KEY_M = 0x4D,
- KEY_N = 0x4E,
- KEY_O = 0x4F,
- KEY_P = 0x50,
- KEY_Q = 0x51,
- KEY_R = 0x52,
- KEY_S = 0x53,
- KEY_T = 0x54,
- KEY_U = 0x55,
- KEY_V = 0x56,
- KEY_W = 0x57,
- KEY_X = 0x58,
- KEY_Y = 0x59,
- KEY_Z = 0x5A,
+ KEY_0 = 0x30,
+ KEY_1 = 0x31,
+ KEY_2 = 0x32,
+ KEY_3 = 0x33,
+ KEY_4 = 0x34,
+ KEY_5 = 0x35,
+ KEY_6 = 0x36,
+ KEY_7 = 0x37,
+ KEY_8 = 0x38,
+ KEY_9 = 0x39,
+ KEY_A = 0x41,
+ KEY_B = 0x42,
+ KEY_C = 0x43,
+ KEY_D = 0x44,
+ KEY_E = 0x45,
+ KEY_F = 0x46,
+ KEY_G = 0x47,
+ KEY_H = 0x48,
+ KEY_I = 0x49,
+ KEY_J = 0x4A,
+ KEY_K = 0x4B,
+ KEY_L = 0x4C,
+ KEY_M = 0x4D,
+ KEY_N = 0x4E,
+ KEY_O = 0x4F,
+ KEY_P = 0x50,
+ KEY_Q = 0x51,
+ KEY_R = 0x52,
+ KEY_S = 0x53,
+ KEY_T = 0x54,
+ KEY_U = 0x55,
+ KEY_V = 0x56,
+ KEY_W = 0x57,
+ KEY_X = 0x58,
+ KEY_Y = 0x59,
+ KEY_Z = 0x5A,
KEY_NUMPAD0 = 0x60,
KEY_NUMPAD1 = 0x61,
KEY_NUMPAD2 = 0x62,
@@ -154,7 +154,7 @@ public:
KEY_RCONTROL = 0xA3
};
- // NOTE: These codes are registered in inputengine_script.cpp.
+ // NOTE: These codes are registered in inputengine_script.cpp.
// Any changes to these enums must also adjust the above file.
enum KEY_COMMANDS {
KEY_COMMAND_ENTER = 1,
@@ -171,16 +171,16 @@ public:
/// --------------------------------------------------------------
/// THESE METHODS MUST BE IMPLEMENTED BY THE INPUT ENGINE
/// --------------------------------------------------------------
-
+
/**
* Initialises the input engine
- * @return Returns a true on success, otherwise false.
+ * @return Returns a true on success, otherwise false.
*/
virtual bool Init() = 0;
/**
* Performs a "tick" of the input engine.
- *
+ *
* This method should be called once per frame. It can be used by implementations
* of the input engine that are not running in their own thread, or to perform
* additional administrative tasks that are needed.
@@ -240,8 +240,8 @@ public:
/**
* Returns true if a given key was pressed
- * @param KeyCode The key code to be checked
- * @return Returns true if the given key is done, otherwise false.
+ * @param KeyCode The key code to be checked
+ * @return Returns true if the given key is done, otherwise false.
*/
virtual bool IsKeyDown(unsigned int KeyCode) = 0;
@@ -251,7 +251,7 @@ public:
* The difference between IsKeyDown() is that this only returns true after the key
* has been released. This method facilitates the retrieval of keys, and reading
* strings that users type.
- * @param KeyCode The key code to be checked
+ * @param KeyCode The key code to be checked
*/
virtual bool WasKeyDown(unsigned int KeyCode) = 0;
@@ -261,19 +261,19 @@ public:
* Registers a callback function for keyboard input.
*
* The callbacks that are registered with this function will be called whenever an
- * input key is pressed. A letter entry is different from the query using the
- * methods IsKeyDown () and WasKeyDown () in the sense that are treated instead
- * of actual scan-coded letters. These were taken into account, among other things:
+ * input key is pressed. A letter entry is different from the query using the
+ * methods IsKeyDown () and WasKeyDown () in the sense that are treated instead
+ * of actual scan-coded letters. These were taken into account, among other things:
* the keyboard layout, the condition the Shift and Caps Lock keys and the repetition
* of longer holding the key.
* The input of strings by the user through use of callbacks should be implemented.
- * @return Returns true if the function was registered, otherwise false.
+ * @return Returns true if the function was registered, otherwise false.
*/
virtual bool RegisterCharacterCallback(CallbackPtr Callback) = 0;
/**
* De-registeres a previously registered callback function.
- * @return Returns true if the function could be de-registered, otherwise false.
+ * @return Returns true if the function could be de-registered, otherwise false.
*/
virtual bool UnregisterCharacterCallback(CallbackPtr Callback) = 0;
@@ -282,17 +282,17 @@ public:
/**
* Registers a callback function for the input of commands that can have influence on the string input
*
- * The callbacks that are registered with this function will be called whenever the input service
- * has a key that affects the character string input. This could be the following keys:
+ * The callbacks that are registered with this function will be called whenever the input service
+ * has a key that affects the character string input. This could be the following keys:
* Enter, End, Left, Right, ...
* The input of strings by the user through the use of callbacks should be implemented.
- * @return Returns true if the function was registered, otherwise false.
+ * @return Returns true if the function was registered, otherwise false.
*/
virtual bool RegisterCommandCallback(CallbackPtr Callback) = 0;
/**
* Un-register a callback function for the input of commands that can have an influence on the string input.
- * @return Returns true if the function could be de-registered, otherwise false.
+ * @return Returns true if the function could be de-registered, otherwise false.
*/
virtual bool UnregisterCommandCallback(CommandCallback Callback) = 0;
diff --git a/engines/sword25/input/inputengine_script.cpp b/engines/sword25/input/inputengine_script.cpp
index a7bd39481b..70c26e5282 100644
--- a/engines/sword25/input/inputengine_script.cpp
+++ b/engines/sword25/input/inputengine_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -61,45 +61,47 @@ static void TheCharacterCallback(int Character);
static void TheCommandCallback(int Command);
namespace {
- class CharacterCallbackClass : public BS_LuaCallback {
- public:
- CharacterCallbackClass(lua_State *L) : BS_LuaCallback(L) {};
-
- Common::String Character;
-
- protected:
- int PreFunctionInvokation(lua_State *L) {
- lua_pushstring(L, Character.c_str());
- return 1;
- }
- };
- Common::SharedPtr<CharacterCallbackClass> CharacterCallbackPtr;
-
- // -----------------------------------------------------------------------------
-
- class CommandCallbackClass : public BS_LuaCallback {
- public:
- CommandCallbackClass(lua_State *L) : BS_LuaCallback(L) { Command = BS_InputEngine::KEY_COMMAND_BACKSPACE; }
-
- BS_InputEngine::KEY_COMMANDS Command;
-
- protected:
- int PreFunctionInvokation(lua_State *L) {
- lua_pushnumber(L, Command);
- return 1;
- }
- };
- Common::SharedPtr<CommandCallbackClass> CommandCallbackPtr;
-
- // -------------------------------------------------------------------------
-
- struct CallbackfunctionRegisterer {
- CallbackfunctionRegisterer() {
- BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaCommandCB", TheCommandCallback);
- BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaCharacterCB", TheCharacterCallback);
- }
- };
- static CallbackfunctionRegisterer Instance;
+class CharacterCallbackClass : public BS_LuaCallback {
+public:
+ CharacterCallbackClass(lua_State *L) : BS_LuaCallback(L) {};
+
+ Common::String Character;
+
+protected:
+ int PreFunctionInvokation(lua_State *L) {
+ lua_pushstring(L, Character.c_str());
+ return 1;
+ }
+};
+Common::SharedPtr<CharacterCallbackClass> CharacterCallbackPtr;
+
+// -----------------------------------------------------------------------------
+
+class CommandCallbackClass : public BS_LuaCallback {
+public:
+ CommandCallbackClass(lua_State *L) : BS_LuaCallback(L) {
+ Command = BS_InputEngine::KEY_COMMAND_BACKSPACE;
+ }
+
+ BS_InputEngine::KEY_COMMANDS Command;
+
+protected:
+ int PreFunctionInvokation(lua_State *L) {
+ lua_pushnumber(L, Command);
+ return 1;
+ }
+};
+Common::SharedPtr<CommandCallbackClass> CommandCallbackPtr;
+
+// -------------------------------------------------------------------------
+
+struct CallbackfunctionRegisterer {
+ CallbackfunctionRegisterer() {
+ BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaCommandCB", TheCommandCallback);
+ BS_CallbackRegistry::GetInstance().RegisterCallbackFunction("LuaCharacterCB", TheCharacterCallback);
+ }
+};
+static CallbackfunctionRegisterer Instance;
}
// -----------------------------------------------------------------------------
@@ -313,7 +315,7 @@ static const luaL_reg PACKAGE_FUNCTIONS[] = {
"UnregisterCharacterCallback", UnregisterCharacterCallback,
"RegisterCommandCallback", RegisterCommandCallback,
"UnregisterCommandCallback", UnregisterCommandCallback,
- 0, 0,
+ 0, 0,
};
#define X(k) "KEY_" #k, BS_InputEngine::KEY_##k
diff --git a/engines/sword25/input/scummvminput.cpp b/engines/sword25/input/scummvminput.cpp
index 14c94bd226..76a7f0fe09 100644
--- a/engines/sword25/input/scummvminput.cpp
+++ b/engines/sword25/input/scummvminput.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,19 +54,19 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
ScummVMInput::ScummVMInput(BS_Kernel *pKernel) :
- m_CurrentState(0),
- m_LeftMouseDown(false),
- m_RightMouseDown(false),
- m_MouseX(0),
- m_MouseY(0),
- m_LeftDoubleClick(false),
- m_DoubleClickTime(DOUBLE_CLICK_TIME),
- m_DoubleClickRectWidth(DOUBLE_CLICK_RECT_SIZE),
- m_DoubleClickRectHeight(DOUBLE_CLICK_RECT_SIZE),
- m_LastLeftClickTime(0),
- m_LastLeftClickMouseX(0),
- m_LastLeftClickMouseY(0),
- BS_InputEngine(pKernel) {
+ m_CurrentState(0),
+ m_LeftMouseDown(false),
+ m_RightMouseDown(false),
+ m_MouseX(0),
+ m_MouseY(0),
+ m_LeftDoubleClick(false),
+ m_DoubleClickTime(DOUBLE_CLICK_TIME),
+ m_DoubleClickRectWidth(DOUBLE_CLICK_RECT_SIZE),
+ m_DoubleClickRectHeight(DOUBLE_CLICK_RECT_SIZE),
+ m_LastLeftClickTime(0),
+ m_LastLeftClickMouseX(0),
+ m_LastLeftClickMouseY(0),
+ BS_InputEngine(pKernel) {
memset(m_KeyboardState[0], 0, sizeof(m_KeyboardState[0]));
memset(m_KeyboardState[1], 0, sizeof(m_KeyboardState[1]));
m_LeftMouseState[0] = false;
@@ -80,7 +80,9 @@ ScummVMInput::~ScummVMInput() {
// -----------------------------------------------------------------------------
-BS_Service *ScummVMInput_CreateObject(BS_Kernel *pKernel) { return new ScummVMInput(pKernel); }
+BS_Service *ScummVMInput_CreateObject(BS_Kernel *pKernel) {
+ return new ScummVMInput(pKernel);
+}
// -----------------------------------------------------------------------------
@@ -102,18 +104,21 @@ void ScummVMInput::Update() {
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
m_LeftMouseDown = event.type == Common::EVENT_LBUTTONDOWN;
- m_MouseX = event.mouse.x; m_MouseY = event.mouse.y;
+ m_MouseX = event.mouse.x;
+ m_MouseY = event.mouse.y;
handleEvents = false;
break;
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
m_RightMouseDown = event.type == Common::EVENT_RBUTTONDOWN;
- m_MouseX = event.mouse.x; m_MouseY = event.mouse.y;
+ m_MouseX = event.mouse.x;
+ m_MouseY = event.mouse.y;
handleEvents = false;
break;
case Common::EVENT_MOUSEMOVE:
- m_MouseX = event.mouse.x; m_MouseY = event.mouse.y;
+ m_MouseX = event.mouse.x;
+ m_MouseY = event.mouse.y;
break;
case Common::EVENT_KEYDOWN:
@@ -162,8 +167,8 @@ void ScummVMInput::TestForLeftDoubleClick() {
// 1. The two clicks are close enough together
// 2. The mouse cursor hasn't moved much
if (Now - m_LastLeftClickTime <= m_DoubleClickTime &&
- ABS(m_MouseX - m_LastLeftClickMouseX) <= m_DoubleClickRectWidth / 2 &&
- ABS(m_MouseY - m_LastLeftClickMouseY) <= m_DoubleClickRectHeight / 2) {
+ ABS(m_MouseX - m_LastLeftClickMouseX) <= m_DoubleClickRectWidth / 2 &&
+ ABS(m_MouseY - m_LastLeftClickMouseY) <= m_DoubleClickRectHeight / 2) {
m_LeftDoubleClick = true;
// Reset the time and position of the last click, so that clicking is not
@@ -184,7 +189,7 @@ void ScummVMInput::TestForLeftDoubleClick() {
// -----------------------------------------------------------------------------
void AlterKeyboardState(int keycode, byte newState) {
-
+
}
// -----------------------------------------------------------------------------
@@ -208,7 +213,7 @@ bool ScummVMInput::WasRightMouseDown() {
// -----------------------------------------------------------------------------
int ScummVMInput::GetMouseX() {
- return m_MouseX;
+ return m_MouseX;
}
// -----------------------------------------------------------------------------
@@ -226,8 +231,8 @@ bool ScummVMInput::IsKeyDown(unsigned int KeyCode) {
// -----------------------------------------------------------------------------
bool ScummVMInput::WasKeyDown(unsigned int KeyCode) {
- return ((m_KeyboardState[m_CurrentState][KeyCode] & 0x80) == 0) &&
- ((m_KeyboardState[m_CurrentState ^ 1][KeyCode] & 0x80) != 0);
+ return ((m_KeyboardState[m_CurrentState][KeyCode] & 0x80) == 0) &&
+ ((m_KeyboardState[m_CurrentState ^ 1][KeyCode] & 0x80) != 0);
}
// -----------------------------------------------------------------------------
@@ -259,8 +264,8 @@ bool ScummVMInput::RegisterCharacterCallback(CharacterCallback Callback) {
// -----------------------------------------------------------------------------
bool ScummVMInput::UnregisterCharacterCallback(CharacterCallback Callback) {
- Common::List<CharacterCallback>::iterator CallbackIter = Common::find(m_CharacterCallbacks.begin(),
- m_CharacterCallbacks.end(), Callback);
+ Common::List<CharacterCallback>::iterator CallbackIter = Common::find(m_CharacterCallbacks.begin(),
+ m_CharacterCallbacks.end(), Callback);
if (CallbackIter != m_CharacterCallbacks.end()) {
m_CharacterCallbacks.erase(CallbackIter);
return true;
@@ -285,8 +290,8 @@ bool ScummVMInput::RegisterCommandCallback(CommandCallback Callback) {
// -----------------------------------------------------------------------------
bool ScummVMInput::UnregisterCommandCallback(CommandCallback Callback) {
- Common::List<CommandCallback>::iterator CallbackIter =
- Common::find(m_CommandCallbacks.begin(), m_CommandCallbacks.end(), Callback);
+ Common::List<CommandCallback>::iterator CallbackIter =
+ Common::find(m_CommandCallbacks.begin(), m_CommandCallbacks.end(), Callback);
if (CallbackIter != m_CommandCallbacks.end()) {
m_CommandCallbacks.erase(CallbackIter);
return true;
@@ -302,7 +307,7 @@ void ScummVMInput::ReportCharacter(unsigned char Character) {
Common::List<CharacterCallback>::const_iterator CallbackIter = m_CharacterCallbacks.begin();
while (CallbackIter != m_CharacterCallbacks.end()) {
// Iterator vor dem Aufruf erhöhen und im Folgendem auf einer Kopie arbeiten.
- // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks
+ // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks
// invalidiert wird.
Common::List<CharacterCallback>::const_iterator CurCallbackIter = CallbackIter;
++CallbackIter;
@@ -317,7 +322,7 @@ void ScummVMInput::ReportCommand(KEY_COMMANDS Command) {
Common::List<CommandCallback>::const_iterator CallbackIter = m_CommandCallbacks.begin();
while (CallbackIter != m_CommandCallbacks.end()) {
// Iterator vor dem Aufruf erhöhen und im Folgendem auf einer Kopie arbeiten.
- // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks
+ // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks
// invalidiert wird.
Common::List<CommandCallback>::const_iterator CurCallbackIter = CallbackIter;
++CallbackIter;
@@ -374,7 +379,7 @@ bool ScummVMInput::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(CallbackFunctionName);
m_CommandCallbacks.push_back(reinterpret_cast<CommandCallback>(
- BS_CallbackRegistry::GetInstance().ResolveCallbackFunction(CallbackFunctionName)));
+ BS_CallbackRegistry::GetInstance().ResolveCallbackFunction(CallbackFunctionName)));
}
// Character-Callbackliste leeren.
diff --git a/engines/sword25/input/scummvminput.h b/engines/sword25/input/scummvminput.h
index b38a54b757..b7f38df603 100644
--- a/engines/sword25/input/scummvminput.h
+++ b/engines/sword25/input/scummvminput.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -51,7 +51,7 @@ class ScummVMInput : public BS_InputEngine {
public:
ScummVMInput(BS_Kernel *pKernel);
virtual ~ScummVMInput();
-
+
virtual bool Init();
virtual void Update();
virtual bool IsLeftMouseDown();
@@ -79,23 +79,23 @@ private:
void TestForLeftDoubleClick();
void AlterKeyboardState(int keycode, byte newState);
- byte m_KeyboardState[2][256];
- bool m_LeftMouseState[2];
- bool m_RightMouseState[2];
- unsigned int m_CurrentState;
- int m_MouseX;
- int m_MouseY;
- bool m_LeftMouseDown;
- bool m_RightMouseDown;
- bool m_LeftDoubleClick;
- unsigned int m_DoubleClickTime;
- int m_DoubleClickRectWidth;
- int m_DoubleClickRectHeight;
- unsigned int m_LastLeftClickTime;
- int m_LastLeftClickMouseX;
- int m_LastLeftClickMouseY;
- Common::List<CommandCallback> m_CommandCallbacks;
- Common::List<CharacterCallback> m_CharacterCallbacks;
+ byte m_KeyboardState[2][256];
+ bool m_LeftMouseState[2];
+ bool m_RightMouseState[2];
+ unsigned int m_CurrentState;
+ int m_MouseX;
+ int m_MouseY;
+ bool m_LeftMouseDown;
+ bool m_RightMouseDown;
+ bool m_LeftDoubleClick;
+ unsigned int m_DoubleClickTime;
+ int m_DoubleClickRectWidth;
+ int m_DoubleClickRectHeight;
+ unsigned int m_LastLeftClickTime;
+ int m_LastLeftClickMouseX;
+ int m_LastLeftClickMouseY;
+ Common::List<CommandCallback> m_CommandCallbacks;
+ Common::List<CharacterCallback> m_CharacterCallbacks;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/bs_stdint.h b/engines/sword25/kernel/bs_stdint.h
index c39a219bc9..c1970bff3e 100644
--- a/engines/sword25/kernel/bs_stdint.h
+++ b/engines/sword25/kernel/bs_stdint.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/kernel/callbackregistry.cpp b/engines/sword25/kernel/callbackregistry.cpp
index b9b48ed18f..a530159cd7 100644
--- a/engines/sword25/kernel/callbackregistry.cpp
+++ b/engines/sword25/kernel/callbackregistry.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -76,7 +76,7 @@ bool BS_CallbackRegistry::RegisterCallbackFunction(const Common::String &Name, C
}
StoreCallbackFunction(Name, Ptr);
-
+
return true;
}
diff --git a/engines/sword25/kernel/callbackregistry.h b/engines/sword25/kernel/callbackregistry.h
index 72b8135e47..a4ebd03dba 100644
--- a/engines/sword25/kernel/callbackregistry.h
+++ b/engines/sword25/kernel/callbackregistry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,28 +52,30 @@ namespace Sword25 {
// Klassendeklaration
// -----------------------------------------------------------------------------
-typedef void (*CallbackPtr)(int Command);
+typedef void (*CallbackPtr)(int Command);
class BS_CallbackRegistry {
public:
- static BS_CallbackRegistry & GetInstance() {
+ static BS_CallbackRegistry &GetInstance() {
static BS_CallbackRegistry Instance;
return Instance;
}
- bool RegisterCallbackFunction(const Common::String &Name, CallbackPtr Ptr);
- CallbackPtr ResolveCallbackFunction(const Common::String &Name) const;
- Common::String ResolveCallbackPointer(CallbackPtr Ptr) const;
+ bool RegisterCallbackFunction(const Common::String &Name, CallbackPtr Ptr);
+ CallbackPtr ResolveCallbackFunction(const Common::String &Name) const;
+ Common::String ResolveCallbackPointer(CallbackPtr Ptr) const;
private:
typedef Common::HashMap<Common::String, CallbackPtr, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> NameToPtrMap;
NameToPtrMap m_NameToPtrMap;
struct CallbackPtr_EqualTo {
- bool operator()(CallbackPtr x, CallbackPtr y) const { return x == y; }
+ bool operator()(CallbackPtr x, CallbackPtr y) const {
+ return x == y;
+ }
};
struct CallbackPtr_Hash {
- uint operator()(CallbackPtr x) const {
+ uint operator()(CallbackPtr x) const {
return static_cast<uint>((int64)x % ((int64)1 << sizeof(uint)));
}
};
@@ -81,9 +83,9 @@ private:
typedef Common::HashMap<CallbackPtr, Common::String, CallbackPtr_Hash, CallbackPtr_EqualTo> PtrToNameMap;
PtrToNameMap m_PtrToNameMap;
- CallbackPtr FindPtrByName(const Common::String &Name) const;
- Common::String FindNameByPtr(CallbackPtr Ptr) const;
- void StoreCallbackFunction(const Common::String &Name, CallbackPtr Ptr);
+ CallbackPtr FindPtrByName(const Common::String &Name) const;
+ Common::String FindNameByPtr(CallbackPtr Ptr) const;
+ void StoreCallbackFunction(const Common::String &Name, CallbackPtr Ptr);
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/common.h b/engines/sword25/kernel/common.h
index 93231f1a95..4e272f2591 100644
--- a/engines/sword25/kernel/common.h
+++ b/engines/sword25/kernel/common.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -47,10 +47,10 @@
// Global constants
#if _DEBUG && !DEBUG
- #define DEBUG
+#define DEBUG
#endif
-#define BS_ACTIVATE_LOGGING // When defined, logging is activated
+#define BS_ACTIVATE_LOGGING // When defined, logging is activated
// Engine Includes
#include "sword25/kernel/memleaks.h"
diff --git a/engines/sword25/kernel/filesystemutil.cpp b/engines/sword25/kernel/filesystemutil.cpp
index 831efc6add..5eddc06bd0 100644
--- a/engines/sword25/kernel/filesystemutil.cpp
+++ b/engines/sword25/kernel/filesystemutil.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -78,7 +78,7 @@ public:
return "";
}
- // Return the path
+ // Return the path
return path;
}
diff --git a/engines/sword25/kernel/filesystemutil.h b/engines/sword25/kernel/filesystemutil.h
index 828ff31922..0fffa72d9f 100644
--- a/engines/sword25/kernel/filesystemutil.h
+++ b/engines/sword25/kernel/filesystemutil.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,8 +33,8 @@
*/
/*
- *
- * The class BS_FileSystemUtil represents a wrapper for file system specific
+ *
+ * The class BS_FileSystemUtil represents a wrapper for file system specific
* operations that do not have equivalents in the C/C++ libraries.
*
* Each supported platform must implement this interface, and the method
@@ -69,42 +69,42 @@ public:
* This function returns the name of the directory in which all user data is to be stored.
*
* These are for example Screenshots, game saves, configuration files, log files, ...
- * @return Returns the name of the directory for user data.
+ * @return Returns the name of the directory for user data.
*/
virtual Common::String GetUserdataDirectory() = 0;
/**
- * @return Returns the path seperator
+ * @return Returns the path seperator
*/
- virtual Common::String GetPathSeparator() = 0;
+ virtual Common::String GetPathSeparator() = 0;
/**
- * @param Filename The path to a file.
- * @return Returns the size of the specified file. If the size could not be
+ * @param Filename The path to a file.
+ * @return Returns the size of the specified file. If the size could not be
* determined, or the file does not exist, returns -1
*/
virtual int64 GetFileSize(const Common::String &Filename) = 0;
/**
- * @param Filename The path to a file.
- * @return Returns the timestamp of the specified file.
+ * @param Filename The path to a file.
+ * @return Returns the timestamp of the specified file.
*/
virtual TimeDate GetFileTime(const Common::String &Filename) = 0;
/**
- * @param Filename The path to a file.
- * @return Returns true if the file exists.
+ * @param Filename The path to a file.
+ * @return Returns true if the file exists.
*/
virtual bool FileExists(const Common::String &Filename) = 0;
/**
* This function creates a directory
- *
+ *
* If the parameter is "\b\c\d\e" is passed, and "\b\c" already exists, then folder 'd'
* will be created, and subdirectory 'e' under it.
- * @param DirectoryName The name of the directory to be created
- * @return Returns true if the folder(s) could be created, otherwise false.
+ * @param DirectoryName The name of the directory to be created
+ * @return Returns true if the folder(s) could be created, otherwise false.
*/
virtual bool CreateDirectory(const Common::String &DirectoryName) = 0;
/**
* Creates a list of filenames in a given directory.
- * @param Directory The directory to search
- * @return Returns a vector containing all of the found filenames
+ * @param Directory The directory to search
+ * @return Returns a vector containing all of the found filenames
*/
virtual Common::StringArray GetFilesInDirectory(const Common::String &Path) = 0;
};
diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp
index 6528d041ad..764cadd373 100644
--- a/engines/sword25/kernel/inputpersistenceblock.cpp
+++ b/engines/sword25/kernel/inputpersistenceblock.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -46,9 +46,9 @@ namespace Sword25 {
// Constructor / Destructor
// -----------------------------------------------------------------------------
-BS_InputPersistenceBlock::BS_InputPersistenceBlock(const void * Data, unsigned int DataLength) :
- m_Data(static_cast<const unsigned char *>(Data), DataLength),
- m_ErrorState(NONE) {
+BS_InputPersistenceBlock::BS_InputPersistenceBlock(const void *Data, unsigned int DataLength) :
+ m_Data(static_cast<const unsigned char *>(Data), DataLength),
+ m_ErrorState(NONE) {
m_Iter = m_Data.begin();
}
@@ -118,7 +118,7 @@ void BS_InputPersistenceBlock::Read(bool &Value) {
void BS_InputPersistenceBlock::Read(Common::String &Value) {
Value = "";
-
+
if (CheckMarker(STRING_MARKER)) {
unsigned int Size;
Read(Size);
@@ -146,7 +146,7 @@ void BS_InputPersistenceBlock::Read(Common::Array<unsigned char> &Value) {
// -----------------------------------------------------------------------------
-void BS_InputPersistenceBlock::RawRead(void * DestPtr, size_t Size) {
+void BS_InputPersistenceBlock::RawRead(void *DestPtr, size_t Size) {
if (CheckBlockSize(Size)) {
memcpy(DestPtr, &*m_Iter, Size);
m_Iter += Size;
diff --git a/engines/sword25/kernel/inputpersistenceblock.h b/engines/sword25/kernel/inputpersistenceblock.h
index 0e8e3bf5e6..0bd50bbeb1 100644
--- a/engines/sword25/kernel/inputpersistenceblock.h
+++ b/engines/sword25/kernel/inputpersistenceblock.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -32,7 +32,7 @@
*
*/
-#ifndef SWORD25_INPUTPERSISTENCEBLOCK_H
+#ifndef SWORD25_INPUTPERSISTENCEBLOCK_H
#define SWORD25_INPUTPERSISTENCEBLOCK_H
// -----------------------------------------------------------------------------
@@ -68,8 +68,12 @@ public:
void Read(Common::String &Value);
void Read(Common::Array<unsigned char> &Value);
- bool IsGood() const { return m_ErrorState == NONE; }
- ErrorState GetErrorState() const { return m_ErrorState; }
+ bool IsGood() const {
+ return m_ErrorState == NONE;
+ }
+ ErrorState GetErrorState() const {
+ return m_ErrorState;
+ }
private:
bool CheckMarker(unsigned char Marker);
diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp
index 8275db67f7..6348ca0f63 100644
--- a/engines/sword25/kernel/kernel.cpp
+++ b/engines/sword25/kernel/kernel.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,7 +54,7 @@ BS_Kernel::BS_Kernel() :
_Running(false),
_pResourceManager(NULL),
_InitSuccess(false) {
-
+
// Log that the kernel is beign created
BS_LOGLN("created.");
@@ -115,7 +115,7 @@ BS_Kernel::~BS_Kernel() {
delete _SuperclassList.back();
_SuperclassList.pop_back();
}
-
+
// Release the window object
delete _pWindow;
BS_LOGLN("Window destroyed.");
@@ -129,12 +129,11 @@ BS_Kernel::~BS_Kernel() {
// Service Methoden
// ----------------
-BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Identifier) :
+BS_Kernel::Superclass::Superclass(BS_Kernel *pKernel, const Common::String &Identifier) :
_pKernel(pKernel),
- _Identifier(Identifier),
- _ServiceCount(0),
- _ActiveService(NULL)
-{
+ _Identifier(Identifier),
+ _ServiceCount(0),
+ _ActiveService(NULL) {
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
_ServiceCount++;
@@ -147,15 +146,15 @@ BS_Kernel::Superclass::~Superclass() {
/**
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
- * @param SuperclassIdentifier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
- * 0 und GetServiceCount() - 1 sein.
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
*/
Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) {
if (Number > _ServiceCount) return NULL;
-
+
unsigned int CurServiceOrd = 0;
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) {
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
@@ -169,31 +168,27 @@ Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number)
}
/**
- * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
* Note: All services must be registered in service_ids.h, otherwise they cannot be created here
- * @param SuperclassIdentifier The name of the superclass of the service
- * z.B: "sfx", "gfx", "package" ...
- * @param ServiceIdentifier The name of the service
- * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
- BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier)
- {
- BS_Service* NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel);
-
- if (NewService)
- {
+ BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) {
+ BS_Service *NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel);
+
+ if (NewService) {
DisconnectService();
BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
_ActiveService = NewService;
_ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier;
return _ActiveService;
- }
- else
- {
+ } else {
BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
return NULL;
}
@@ -204,10 +199,10 @@ BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdent
}
/**
- * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
- * @param SuperclassIdentfier The name of the superclass which is to be disconnected
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
*/
bool BS_Kernel::Superclass::DisconnectService() {
if (_ActiveService) {
@@ -221,7 +216,7 @@ bool BS_Kernel::Superclass::DisconnectService() {
}
BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) {
- Common::Array<Superclass*>::iterator Iter;
+ Common::Array<Superclass *>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if ((*Iter)->GetIdentifier() == Identifier)
return *Iter;
@@ -241,32 +236,32 @@ unsigned int BS_Kernel::GetSuperclassCount() {
/**
* Returns the name of a superclass with the specified index.
* Note: The number of superclasses can be retrieved using GetSuperclassCount
- * @param Number The number of the superclass to return the identifier for.
+ * @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
Common::String BS_Kernel::GetSuperclassIdentifier(unsigned int Number) {
if (Number > _SuperclassList.size()) return NULL;
-
+
unsigned int CurSuperclassOrd = 0;
- Common::Array<Superclass*>::iterator Iter;
+ Common::Array<Superclass *>::iterator Iter;
for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) {
if (CurSuperclassOrd == Number)
return ((*Iter)->GetIdentifier());
-
+
CurSuperclassOrd++;
}
-
+
return Common::String("");
}
/**
* Returns the number of services registered with a given superclass
- * @param SuperclassIdentifier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
-unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentifier) {
+unsigned int BS_Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) {
Superclass *pSuperclass;
- if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier)))
+ if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier)))
return 0;
return pSuperclass->GetServiceCount();
@@ -276,29 +271,29 @@ unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentif
/**
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
- * @param SuperclassIdentifier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
- * 0 und GetServiceCount() - 1 sein.
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
*/
-Common::String BS_Kernel::GetServiceIdentifier(const Common::String & SuperclassIdentifier, unsigned int Number) {
- Superclass* pSuperclass;
+Common::String BS_Kernel::GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number) {
+ Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
- return (pSuperclass->GetServiceIdentifier(Number));
+ return (pSuperclass->GetServiceIdentifier(Number));
}
/**
- * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
* Note: All services must be registered in service_ids.h, otherwise they cannot be created here
- * @param SuperclassIdentifier The name of the superclass of the service
- * z.B: "sfx", "gfx", "package" ...
- * @param ServiceIdentifier The name of the service
- * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
-BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, const Common::String& ServiceIdentifier) {
+BS_Service *BS_Kernel::NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
@@ -309,12 +304,12 @@ BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, co
}
/**
- * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
- * @param SuperclassIdentfier The name of the superclass which is to be disconnected
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
*/
-bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) {
+bool BS_Kernel::DisconnectService(const Common::String &SuperclassIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false;
@@ -323,10 +318,10 @@ bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) {
/**
* Returns a pointer to the currently active service object of a superclass
- * @param SuperclassIdentfier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
-BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) {
+BS_Service *BS_Kernel::GetService(const Common::String &SuperclassIdentifier) {
Superclass *pSuperclass;
if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL;
@@ -336,11 +331,11 @@ BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) {
/**
* Returns the name of the currentl active service object of a superclass.
* If an error occurs, then an empty string is returned
- * @param SuperclassIdentfier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
-Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& SuperclassIdentifier) {
- Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier);
+Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier) {
+ Superclass *pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier);
if (!pSuperclass) return Common::String("");
return (pSuperclass->GetActiveServiceName());
@@ -350,8 +345,8 @@ Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& Super
/**
* Returns a random number
- * @param Min The minimum allowed value
- * @param Max The maximum allowed value
+ * @param Min The minimum allowed value
+ * @param Max The maximum allowed value
*/
int BS_Kernel::GetRandomNumber(int Min, int Max) {
BS_ASSERT(Min <= Max);
@@ -386,12 +381,9 @@ size_t BS_Kernel::GetUsedMemory() {
#ifdef SCUMMVM_DISABLED_CODE
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(pmc);
- if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
- {
+ if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
return pmc.WorkingSetSize;
- }
- else
- {
+ } else {
BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
return 0;
}
@@ -403,7 +395,7 @@ size_t BS_Kernel::GetUsedMemory() {
/**
* Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
*/
-BS_GraphicEngine * BS_Kernel::GetGfx() {
+BS_GraphicEngine *BS_Kernel::GetGfx() {
return static_cast<BS_GraphicEngine *>(GetService("gfx"));
}
@@ -412,7 +404,7 @@ BS_GraphicEngine * BS_Kernel::GetGfx() {
/**
* Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
*/
-BS_SoundEngine * BS_Kernel::GetSfx() {
+BS_SoundEngine *BS_Kernel::GetSfx() {
return static_cast<BS_SoundEngine *>(GetService("sfx"));
}
@@ -421,7 +413,7 @@ BS_SoundEngine * BS_Kernel::GetSfx() {
/**
* Returns a pointer to the active input service, or NULL if no input service is active
*/
-BS_InputEngine * BS_Kernel::GetInput() {
+BS_InputEngine *BS_Kernel::GetInput() {
return static_cast<BS_InputEngine *>(GetService("input"));
}
@@ -430,7 +422,7 @@ BS_InputEngine * BS_Kernel::GetInput() {
/**
* Returns a pointer to the active package manager, or NULL if no manager is active
*/
-BS_PackageManager * BS_Kernel::GetPackage() {
+BS_PackageManager *BS_Kernel::GetPackage() {
return static_cast<BS_PackageManager *>(GetService("package"));
}
@@ -439,7 +431,7 @@ BS_PackageManager * BS_Kernel::GetPackage() {
/**
* Returns a pointer to the script engine, or NULL if it is not active
*/
-BS_ScriptEngine * BS_Kernel::GetScript() {
+BS_ScriptEngine *BS_Kernel::GetScript() {
return static_cast<BS_ScriptEngine *>(GetService("script"));
}
@@ -448,7 +440,7 @@ BS_ScriptEngine * BS_Kernel::GetScript() {
/**
* Returns a pointer to the movie player, or NULL if it is not active
*/
-BS_MoviePlayer * BS_Kernel::GetFMV() {
+BS_MoviePlayer *BS_Kernel::GetFMV() {
return static_cast<BS_MoviePlayer *>(GetService("fmv"));
}
diff --git a/engines/sword25/kernel/kernel.h b/engines/sword25/kernel/kernel.h
index d09cf68ab6..b610c0caab 100644
--- a/engines/sword25/kernel/kernel.h
+++ b/engines/sword25/kernel/kernel.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -71,7 +71,7 @@ class BS_MoviePlayer;
/**
* This is the main engine class
*
- * This class creates and manages all other engine components such as sound engine, graphics engine ...
+ * This class creates and manages all other engine components such as sound engine, graphics engine ...
* It is not necessary to release all the items individually, this is performed by the Kernel class.
*/
class BS_Kernel {
@@ -82,42 +82,44 @@ public:
/**
* Returns a pointer to the window object
*/
- BS_Window *GetWindow() { return _pWindow; }
+ BS_Window *GetWindow() {
+ return _pWindow;
+ }
// Service Methods
// ---------------
/**
- * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
+ * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
* service could not be created
- * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
- * @param SuperclassIdentifier The name of the superclass of the service
- * z.B: "sfx", "gfx", "package" ...
- * @param ServiceIdentifier The name of the service
- * For the superclass "sfx" an example could be "Fmod" or "directsound"
+ * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
+ * @param SuperclassIdentifier The name of the superclass of the service
+ * z.B: "sfx", "gfx", "package" ...
+ * @param ServiceIdentifier The name of the service
+ * For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
BS_Service *NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier);
/**
- * Ends the current service of a superclass. Returns true on success, and false if the superclass
+ * Ends the current service of a superclass. Returns true on success, and false if the superclass
* does not exist or if not service was active
- * @param SuperclassIdentfier The name of the superclass which is to be disconnected
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass which is to be disconnected
+ * z.B: "sfx", "gfx", "package" ...
*/
bool DisconnectService(const Common::String &SuperclassIdentifier);
/**
* Returns a pointer to the currently active service object of a superclass
- * @param SuperclassIdentfier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
BS_Service *GetService(const Common::String &SuperclassIdentifier);
/**
* Returns the name of the currentl active service object of a superclass.
* If an error occurs, then an empty string is returned
- * @param SuperclassIdentfier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentfier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
Common::String GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier);
@@ -129,26 +131,26 @@ public:
/**
* Returns the name of a superclass with the specified index.
* Note: The number of superclasses can be retrieved using GetSuperclassCount
- * @param Number The number of the superclass to return the identifier for.
+ * @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
Common::String GetSuperclassIdentifier(unsigned int Number);
/**
* Returns the number of services registered with a given superclass
- * @param SuperclassIdentifier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
*/
- unsigned int GetServiceCount(const Common::String & SuperclassIdentifier);
+ unsigned int GetServiceCount(const Common::String &SuperclassIdentifier);
/**
* Gets the identifier of a service with a given superclass.
* The number of services in a superclass can be learned with GetServiceCount().
- * @param SuperclassIdentifier The name of the superclass
- * z.B: "sfx", "gfx", "package" ...
+ * @param SuperclassIdentifier The name of the superclass
+ * z.B: "sfx", "gfx", "package" ...
* @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
- * 0 und GetServiceCount() - 1 sein.
+ * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
+ * 0 und GetServiceCount() - 1 sein.
*/
Common::String GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number);
@@ -166,19 +168,23 @@ public:
/**
* Specifies whether the kernel was successfully initialised
*/
- bool GetInitSuccess() { return _InitSuccess; }
+ bool GetInitSuccess() {
+ return _InitSuccess;
+ }
/**
* Returns a pointer to the BS_ResourceManager
*/
- BS_ResourceManager *GetResourceManager() { return _pResourceManager; }
+ BS_ResourceManager *GetResourceManager() {
+ return _pResourceManager;
+ }
/**
* Returns how much memory is being used
*/
size_t GetUsedMemory();
/**
* Returns a random number
- * @param Min The minimum allowed value
- * @param Max The maximum allowed value
+ * @param Min The minimum allowed value
+ * @param Max The maximum allowed value
*/
int GetRandomNumber(int Min, int Max);
/**
@@ -208,14 +214,14 @@ public:
/**
* Pauses for the specified amount of time
- * @param Msecs The amount of time in milliseconds
+ * @param Msecs The amount of time in milliseconds
*/
void Sleep(unsigned int Msecs) const;
/**
* Returns the singleton instance for the kernel
*/
- static BS_Kernel *GetInstance() {
+ static BS_Kernel *GetInstance() {
if (!_Instance) _Instance = new BS_Kernel();
return _Instance;
}
@@ -238,13 +244,13 @@ public:
void Crash() const {
error("BS_Kernel::Crash");
}
-
+
private:
// -----------------------------------------------------------------------------
// Constructor / destructor
// Private singleton methods
// -----------------------------------------------------------------------------
-
+
BS_Kernel();
virtual ~BS_Kernel();
@@ -262,27 +268,35 @@ private:
Common::String _Identifier;
BS_Service *_ActiveService;
Common::String _ActiveServiceName;
-
+
public:
- Superclass (BS_Kernel *pKernel, const Common::String &Identifier);
+ Superclass(BS_Kernel *pKernel, const Common::String &Identifier);
~Superclass();
-
- unsigned int GetServiceCount() const { return _ServiceCount; }
- Common::String GetIdentifier() const { return _Identifier; }
- BS_Service *GetActiveService() const { return _ActiveService; }
- Common::String GetActiveServiceName() const { return _ActiveServiceName; }
+
+ unsigned int GetServiceCount() const {
+ return _ServiceCount;
+ }
+ Common::String GetIdentifier() const {
+ return _Identifier;
+ }
+ BS_Service *GetActiveService() const {
+ return _ActiveService;
+ }
+ Common::String GetActiveServiceName() const {
+ return _ActiveServiceName;
+ }
Common::String GetServiceIdentifier(unsigned int Number);
BS_Service *NewService(const Common::String &ServiceIdentifier);
bool DisconnectService();
};
-
- Common::Array<Superclass*> _SuperclassList;
- Common::Stack<Common::String> _ServiceCreationOrder;
+
+ Common::Array<Superclass *> _SuperclassList;
+ Common::Stack<Common::String> _ServiceCreationOrder;
Superclass *GetSuperclassByIdentifier(const Common::String &Identifier);
-
+
bool _InitSuccess; // Specifies whether the engine was set up correctly
- bool _Running; // Specifies whether the application should keep running on the next main loop iteration
-
+ bool _Running; // Specifies whether the application should keep running on the next main loop iteration
+
// Active window
// -------------
BS_Window *_pWindow;
@@ -296,22 +310,22 @@ private:
// ----------------------------------
enum _CPU_FEATURES_BITMASKS
{
- _MMX_BITMASK = (1 << 23),
- _SSE_BITMASK = (1 << 25),
- _SSE2_BITMASK = (1 << 26),
- _3DNOW_BITMASK = (1 << 30),
- _3DNOWEXT_BITMASK = (1 << 31)
+ _MMX_BITMASK = (1 << 23),
+ _SSE_BITMASK = (1 << 25),
+ _SSE2_BITMASK = (1 << 26),
+ _3DNOW_BITMASK = (1 << 30),
+ _3DNOWEXT_BITMASK = (1 << 31)
};
- bool _DetectCPU();
+ bool _DetectCPU();
- bool _MMXPresent;
- bool _SSEPresent;
- bool _SSE2Present;
- bool _3DNowPresent;
- bool _3DNowExtPresent;
- CPU_TYPES _CPUType;
- Common::String _CPUVendorID;
+ bool _MMXPresent;
+ bool _SSEPresent;
+ bool _SSE2Present;
+ bool _3DNowPresent;
+ bool _3DNowExtPresent;
+ CPU_TYPES _CPUType;
+ Common::String _CPUVendorID;
*/
// Resourcemanager
@@ -322,21 +336,21 @@ private:
};
/**
- * This is only a small class that manages the data of a service. It is a little ugly, I know,
+ * This is only a small class that manages the data of a service. It is a little ugly, I know,
* but with Common::String a simple struct could not be used.
*/
class BS_ServiceInfo {
public:
- BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String& ServiceIdentifier_,
- BS_Service* (*CreateMethod_)(BS_Kernel*)) {
+ BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String &ServiceIdentifier_,
+ BS_Service*(*CreateMethod_)(BS_Kernel *)) {
this->SuperclassIdentifier = SuperclassIdentifier_;
this->ServiceIdentifier = ServiceIdentifier_;
this->CreateMethod = CreateMethod_;
};
-
- Common::String SuperclassIdentifier;
- Common::String ServiceIdentifier;
- BS_Service* (*CreateMethod)(BS_Kernel *);
+
+ Common::String SuperclassIdentifier;
+ Common::String ServiceIdentifier;
+ BS_Service*(*CreateMethod)(BS_Kernel *);
};
template<class T>
diff --git a/engines/sword25/kernel/kernel_script.cpp b/engines/sword25/kernel/kernel_script.cpp
index f26a8a4f33..11caaf9d79 100644
--- a/engines/sword25/kernel/kernel_script.cpp
+++ b/engines/sword25/kernel/kernel_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -64,7 +64,7 @@ static int GetActiveServiceIdentifier(lua_State *L) {
BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- lua_pushstring(L, pKernel->GetActiveServiceIdentifier(luaL_checkstring(L,1)).c_str());
+ lua_pushstring(L, pKernel->GetActiveServiceIdentifier(luaL_checkstring(L, 1)).c_str());
return 1;
}
@@ -87,7 +87,7 @@ static int GetSuperclassIdentifier(lua_State *L) {
BS_ASSERT(pKernel);
lua_pushstring(L, pKernel->GetSuperclassIdentifier(
- static_cast<unsigned int>(luaL_checknumber(L,1))).c_str());
+ static_cast<unsigned int>(luaL_checknumber(L, 1))).c_str());
return 1;
}
@@ -109,8 +109,8 @@ static int GetServiceIdentifier(lua_State *L) {
BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- lua_pushstring(L, pKernel->GetServiceIdentifier(luaL_checkstring(L, 1),
- static_cast<unsigned int>(luaL_checknumber(L, 2))).c_str());
+ lua_pushstring(L, pKernel->GetServiceIdentifier(luaL_checkstring(L, 1),
+ static_cast<unsigned int>(luaL_checknumber(L, 2))).c_str());
return 1;
}
@@ -171,7 +171,7 @@ static int Crash(lua_State *L) {
static int ExecuteFile(lua_State *L) {
BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pSE = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pSE = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pSE);
lua_pushbooleancpp(L, pSE->ExecuteFile(luaL_checkstring(L, 1)));
@@ -231,7 +231,7 @@ static int GetUsedMemory(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * KERNEL_LIBRARY_NAME = "Kernel";
+static const char *KERNEL_LIBRARY_NAME = "Kernel";
static const luaL_reg KERNEL_FUNCTIONS[] = {
"DisconnectService", DisconnectService,
@@ -492,7 +492,7 @@ static int HasFocus(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * WINDOW_LIBRARY_NAME = "Window";
+static const char *WINDOW_LIBRARY_NAME = "Window";
static const luaL_reg WINDOW_FUNCTIONS[] = {
"IsVisible", IsVisible,
@@ -622,7 +622,7 @@ static int DumpLockedResources(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * RESOURCE_LIBRARY_NAME = "Resource";
+static const char *RESOURCE_LIBRARY_NAME = "Resource";
static const luaL_reg RESOURCE_FUNCTIONS[] = {
"PrecacheResource", PrecacheResource,
@@ -655,7 +655,7 @@ static int GetSlotCount(lua_State *L) {
static int IsSlotOccupied(lua_State *L) {
lua_pushbooleancpp(L, BS_PersistenceService::GetInstance().IsSlotOccupied(
- static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1));
+ static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1));
return 1;
}
@@ -670,7 +670,7 @@ static int GetSavegameDirectory(lua_State *L) {
static int IsSavegameCompatible(lua_State *L) {
lua_pushbooleancpp(L, BS_PersistenceService::GetInstance().IsSavegameCompatible(
- static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1));
+ static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1));
return 1;
}
@@ -678,7 +678,7 @@ static int IsSavegameCompatible(lua_State *L) {
static int GetSavegameDescription(lua_State *L) {
lua_pushstring(L, BS_PersistenceService::GetInstance().GetSavegameDescription(
- static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1).c_str());
+ static_cast<unsigned int>(luaL_checknumber(L, 1)) - 1).c_str());
return 1;
}
@@ -705,7 +705,7 @@ static int SaveGame(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * PERSISTENCE_LIBRARY_NAME = "Persistence";
+static const char *PERSISTENCE_LIBRARY_NAME = "Persistence";
static const luaL_reg PERSISTENCE_FUNCTIONS[] = {
"ReloadSlots", ReloadSlots,
@@ -723,7 +723,7 @@ static const luaL_reg PERSISTENCE_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
bool BS_Kernel::_RegisterScriptBindings() {
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(GetService("script"));
BS_ASSERT(pScript);
lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
diff --git a/engines/sword25/kernel/log.cpp b/engines/sword25/kernel/log.cpp
index 36a17115d3..07c57e9931 100644
--- a/engines/sword25/kernel/log.cpp
+++ b/engines/sword25/kernel/log.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -41,18 +41,18 @@ namespace Sword25 {
// Constants
static const char *BF_LOG_FILENAME = "log.txt";
-static const size_t LOG_BUFFERSIZE = 1024 * 16;
+static const size_t LOG_BUFFERSIZE = 1024 * 16;
// Logging will take place only when it's activated
#ifdef BS_ACTIVATE_LOGGING
-Common::WriteStream* BS_Log::_LogFile = NULL;
-bool BS_Log::_LineBegin = true;
-const char * BS_Log::_Prefix = NULL;
-const char * BS_Log::_File = NULL;
-int BS_Log::_Line = 0;
-bool BS_Log::_AutoNewline = false;
-Common::Array<BS_Log::LOG_LISTENER_CALLBACK> BS_Log::_LogListener;
+Common::WriteStream *BS_Log::_LogFile = NULL;
+bool BS_Log::_LineBegin = true;
+const char *BS_Log::_Prefix = NULL;
+const char *BS_Log::_File = NULL;
+int BS_Log::_Line = 0;
+bool BS_Log::_AutoNewline = false;
+Common::Array<BS_Log::LOG_LISTENER_CALLBACK> BS_Log::_LogListener;
bool BS_Log::_CreateLog() {
// Open the log file
@@ -109,7 +109,7 @@ void BS_Log::LogPrefix(const char *Prefix, const char *Format, ...) {
if (!NextLine || *(NextLine + strlen("\n")) == 0) {
_snprintf(ExtFormat, sizeof(ExtFormat), "%s%s", ExtFormat, Format);
if (NextLine) _LineBegin = true;
- break;
+ break;
} else {
strncat(ExtFormat, Format, (NextLine - Format) + strlen("\n"));
_snprintf(ExtFormat, sizeof(ExtFormat), "%s%s: ", ExtFormat, Prefix);
@@ -117,7 +117,7 @@ void BS_Log::LogPrefix(const char *Prefix, const char *Format, ...) {
Format = NextLine + strlen("\n");
}
-
+
// Create message
va_list ArgList;
va_start(ArgList, Format);
@@ -140,7 +140,7 @@ void BS_Log::LogDecorated(const char *Format, ...) {
char SecondaryPrefix[1024];
if (_File && _Line)
_snprintf(SecondaryPrefix, sizeof(SecondaryPrefix), "(file: %s, line: %d) - ", _File, _Line);
-
+
// Nachricht zeilenweise ausgeben und an jeden Zeilenanfang das Präfix setzen
char *MessageWalker = Message;
for (;;) {
@@ -183,7 +183,7 @@ void BS_Log::LogDecorated(const char *Format, ...) {
_FlushLog();
}
-int BS_Log::_WriteLog(const char * Message) {
+int BS_Log::_WriteLog(const char *Message) {
if (!_LogFile) if (!_CreateLog()) return false;
Common::Array<LOG_LISTENER_CALLBACK>::iterator Iter = _LogListener.begin();
@@ -207,7 +207,7 @@ void BS_Log_C(const char *Message) {
#else
-void BS_Log_C(const char* Message) {};
+void BS_Log_C(const char *Message) {};
#endif
diff --git a/engines/sword25/kernel/log.h b/engines/sword25/kernel/log.h
index 1c158cfa7b..1fe9ff4ed6 100644
--- a/engines/sword25/kernel/log.h
+++ b/engines/sword25/kernel/log.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -46,32 +46,41 @@ namespace Sword25 {
#ifdef BS_ACTIVATE_LOGGING
// Logging-Makros
-#define BS_LOG BS_Log::SetPrefix(BS_LOG_PREFIX ": "), BS_Log::LogDecorated
-#define BS_LOGLN BS_Log::SetPrefix(BS_LOG_PREFIX ": "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
-#define BS_LOG_WARNING BS_Log::SetPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::LogDecorated
-#define BS_LOG_WARNINGLN BS_Log::SetPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
-#define BS_LOG_ERROR BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::LogDecorated
-#define BS_LOG_ERRORLN BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
-#define BS_LOG_EXTERROR BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::SetFile(__FILE__), BS_Log::SetLine(__LINE__), BS_Log::LogDecorated
-#define BS_LOG_EXTERRORLN BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::SetFile(__FILE__), BS_Log::SetLine(__LINE__), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
+#define BS_LOG BS_Log::SetPrefix(BS_LOG_PREFIX ": "), BS_Log::LogDecorated
+#define BS_LOGLN BS_Log::SetPrefix(BS_LOG_PREFIX ": "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
+#define BS_LOG_WARNING BS_Log::SetPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::LogDecorated
+#define BS_LOG_WARNINGLN BS_Log::SetPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
+#define BS_LOG_ERROR BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::LogDecorated
+#define BS_LOG_ERRORLN BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
+#define BS_LOG_EXTERROR BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::SetFile(__FILE__), BS_Log::SetLine(__LINE__), BS_Log::LogDecorated
+#define BS_LOG_EXTERRORLN BS_Log::SetPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::SetFile(__FILE__), BS_Log::SetLine(__LINE__), BS_Log::SetAutoNewline(true), BS_Log::LogDecorated
// Die Version der Logging-Klasse mit aktiviertem Logging
-class BS_Log
-{
+class BS_Log {
public:
static void Clear();
- static void Log(const char* Format, ...);
- static void LogPrefix(const char* Prefix, const char* Format, ...);
- static void LogDecorated(const char* Format, ...);
+ static void Log(const char *Format, ...);
+ static void LogPrefix(const char *Prefix, const char *Format, ...);
+ static void LogDecorated(const char *Format, ...);
- static void SetPrefix(const char* Prefix) { _Prefix = Prefix; }
- static void SetFile(const char* File) { _File = File; }
- static void SetLine(int Line) { _Line = Line; }
- static void SetAutoNewline(bool AutoNewline) { _AutoNewline = AutoNewline; }
+ static void SetPrefix(const char *Prefix) {
+ _Prefix = Prefix;
+ }
+ static void SetFile(const char *File) {
+ _File = File;
+ }
+ static void SetLine(int Line) {
+ _Line = Line;
+ }
+ static void SetAutoNewline(bool AutoNewline) {
+ _AutoNewline = AutoNewline;
+ }
typedef void (*LOG_LISTENER_CALLBACK)(const char *);
- static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) { _LogListener.push_back(Callback); }
- static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) {
+ static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) {
+ _LogListener.push_back(Callback);
+ }
+ static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) {
Common::Array<LOG_LISTENER_CALLBACK>::iterator i;
for (i = _LogListener.begin(); i != _LogListener.end(); ++i) {
if (**i == Callback)
@@ -82,17 +91,17 @@ public:
static void _CloseLog();
private:
- static Common::WriteStream * _LogFile;
- static bool _LineBegin;
- static const char * _Prefix;
- static const char * _File;
- static int _Line;
- static bool _AutoNewline;
- static Common::Array<LOG_LISTENER_CALLBACK> _LogListener;
-
+ static Common::WriteStream *_LogFile;
+ static bool _LineBegin;
+ static const char *_Prefix;
+ static const char *_File;
+ static int _Line;
+ static bool _AutoNewline;
+ static Common::Array<LOG_LISTENER_CALLBACK> _LogListener;
+
static bool _CreateLog();
- static int _WriteLog(const char* Message);
+ static int _WriteLog(const char *Message);
static void _FlushLog();
};
@@ -112,16 +121,16 @@ private:
#define BS_LOG_EXTERROR
#define BS_LOG_EXTERRORLN
-// The version of the logging class with logging disabled
+// The version of the logging class with logging disabled
class BS_Log {
public:
// This version implements all the various methods as empty stubs
- static void Log(const char* Text, ...) {};
- static void LogPrefix(const char* Prefix, const char* Format, ...) {};
- static void LogDecorated(const char* Format, ...) {};
+ static void Log(const char *Text, ...) {};
+ static void LogPrefix(const char *Prefix, const char *Format, ...) {};
+ static void LogDecorated(const char *Format, ...) {};
- static void SetPrefix(const char* Prefix) {};
- static void SetFile(const char* File) {};
+ static void SetPrefix(const char *Prefix) {};
+ static void SetFile(const char *File) {};
static void SetLine(int Line) {};
static void SetAutoNewline(bool AutoNewline) {};
diff --git a/engines/sword25/kernel/memleaks.cpp b/engines/sword25/kernel/memleaks.cpp
index ca4dde0fc3..e6ba1df608 100644
--- a/engines/sword25/kernel/memleaks.cpp
+++ b/engines/sword25/kernel/memleaks.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,54 +53,47 @@
#include <stdio.h>
#include <string.h>
-typedef struct
-{
- unsigned int address;
- unsigned int size;
- std::string file;
- unsigned int line;
+typedef struct {
+ unsigned int address;
+ unsigned int size;
+ std::string file;
+ unsigned int line;
} ALLOC_INFO;
-static const char * MEMLEAK_LOG_FILE = "memory_leaks.txt";
+static const char *MEMLEAK_LOG_FILE = "memory_leaks.txt";
static const unsigned int BUCKET_COUNT = 1021;
std::vector< std::vector<ALLOC_INFO> > TrackData(BUCKET_COUNT);
static unsigned int TotalSize = 0;
// Diese Klasse stellt sicher, dass beim Programmende, das Memory-Leak Log geschrieben wird.
-static class LeakDumper
-{
+static class LeakDumper {
public:
- LeakDumper() : OutputFilename(BS_FileSystemUtil::GetInstance().GetUserdataDirectory() + "\\" + MEMLEAK_LOG_FILE)
- {
+ LeakDumper() : OutputFilename(BS_FileSystemUtil::GetInstance().GetUserdataDirectory() + "\\" + MEMLEAK_LOG_FILE) {
// Sicherstellen, dass das Ausgabeverzeichnis für die Datei existiert.
BS_FileSystemUtil::GetInstance().CreateDirectory(BS_FileSystemUtil::GetInstance().GetUserdataDirectory());
}
- ~LeakDumper()
- {
+ ~LeakDumper() {
DumpUnfreed(OutputFilename.c_str());
}
std::string OutputFilename;
} LeakDumperInstance;
-void DumpUnfreed(const char * OutputFilename)
-{
- FILE * Log = fopen(OutputFilename, "w");
+void DumpUnfreed(const char *OutputFilename) {
+ FILE *Log = fopen(OutputFilename, "w");
fputs("MEMORY LEAK REPORT:\n----------------------\n", Log);
std::vector< std::vector<ALLOC_INFO> >::iterator BucketIter = TrackData.begin();
- for (; BucketIter != TrackData.end(); ++BucketIter)
- {
+ for (; BucketIter != TrackData.end(); ++BucketIter) {
std::vector<ALLOC_INFO>::iterator Iter = (*BucketIter).begin();
- for (; Iter != (*BucketIter).end(); ++Iter)
- {
- ALLOC_INFO & CurItem = (*Iter);
+ for (; Iter != (*BucketIter).end(); ++Iter) {
+ ALLOC_INFO &CurItem = (*Iter);
fprintf(Log, "%-50s LINE:%d ADDRESS:0x%x SIZE:%d\n",
- CurItem.file.c_str(),
- CurItem.line,
- CurItem.address,
- CurItem.size);
+ CurItem.file.c_str(),
+ CurItem.line,
+ CurItem.address,
+ CurItem.size);
}
}
@@ -109,8 +102,7 @@ void DumpUnfreed(const char * OutputFilename)
fclose(Log);
}
-void AddTrack(unsigned int addr, unsigned int asize, const char *fname, unsigned int lnum)
-{
+void AddTrack(unsigned int addr, unsigned int asize, const char *fname, unsigned int lnum) {
std::vector<ALLOC_INFO> & CurBucket = TrackData[(addr >> 3) % BUCKET_COUNT];
ALLOC_INFO Info;
Info.address = addr;
@@ -122,18 +114,14 @@ void AddTrack(unsigned int addr, unsigned int asize, const char *fname, unsign
TotalSize += asize;
}
-void RemoveTrack(unsigned int addr)
-{
- if (addr != 0 && TrackData.size() == BUCKET_COUNT)
- {
+void RemoveTrack(unsigned int addr) {
+ if (addr != 0 && TrackData.size() == BUCKET_COUNT) {
std::vector<ALLOC_INFO> & CurBucket = TrackData[(addr >> 3) % BUCKET_COUNT];
std::vector<ALLOC_INFO>::iterator Iter = CurBucket.begin();
- for (; Iter != CurBucket.end(); ++Iter)
- {
- if ((*Iter).address == addr)
- {
+ for (; Iter != CurBucket.end(); ++Iter) {
+ if ((*Iter).address == addr) {
TotalSize -= (*Iter).size;
-
+
std::swap(*Iter, CurBucket.back());
CurBucket.pop_back();
return;
diff --git a/engines/sword25/kernel/memleaks.h b/engines/sword25/kernel/memleaks.h
index 4b2cde8bb6..aff61338f8 100644
--- a/engines/sword25/kernel/memleaks.h
+++ b/engines/sword25/kernel/memleaks.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -43,25 +43,22 @@
#include <malloc.h>
-void DumpUnfreed(const char * OutputFilename);
+void DumpUnfreed(const char *OutputFilename);
void AddTrack(unsigned int addr, unsigned int asize, const char *fname, unsigned int lnum);
void RemoveTrack(unsigned int addr);
-inline void * __cdecl operator new(unsigned int size, const char *file, int line)
-{
+inline void *__cdecl operator new(unsigned int size, const char *file, int line) {
void *ptr = malloc(size);
if (ptr) AddTrack((unsigned int)ptr, size, file, line);
return(ptr);
};
-inline void __cdecl operator delete(void *p)
-{
+inline void __cdecl operator delete(void *p) {
RemoveTrack((unsigned int)p);
free(p);
};
-inline void __cdecl operator delete[](void *p)
-{
+inline void __cdecl operator delete[](void *p) {
RemoveTrack((unsigned int)p);
free(p);
};
diff --git a/engines/sword25/kernel/memlog_off.h b/engines/sword25/kernel/memlog_off.h
index 7efe7da751..26bb8e2f8a 100644
--- a/engines/sword25/kernel/memlog_off.h
+++ b/engines/sword25/kernel/memlog_off.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -35,8 +35,8 @@
// Deaktivieren der Memory-Leak Detektion
#ifdef BS_MEMLOG
- #ifdef new
- #undef new
- #undef DEBUG_NEW
- #endif
+#ifdef new
+#undef new
+#undef DEBUG_NEW
+#endif
#endif
diff --git a/engines/sword25/kernel/memlog_on.h b/engines/sword25/kernel/memlog_on.h
index 5f851f8b53..ef5d150c47 100644
--- a/engines/sword25/kernel/memlog_on.h
+++ b/engines/sword25/kernel/memlog_on.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -35,8 +35,8 @@
// Aktivieren der Memory-Leak Detektion
#ifdef BS_MEMLOG
- #ifndef DEBUG_NEW
- #define DEBUG_NEW new(__FILE__, __LINE__)
- #endif
- #define new DEBUG_NEW
+#ifndef DEBUG_NEW
+#define DEBUG_NEW new(__FILE__, __LINE__)
+#endif
+#define new DEBUG_NEW
#endif
diff --git a/engines/sword25/kernel/objectregistry.h b/engines/sword25/kernel/objectregistry.h
index 52ff1d556c..befebfaedf 100644
--- a/engines/sword25/kernel/objectregistry.h
+++ b/engines/sword25/kernel/objectregistry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -150,20 +150,22 @@ public:
protected:
// FIXME: I'm not entirely sure my current hash function is legitimate
struct ClassPointer_EqualTo {
- bool operator()(const T *x, const T *y) const { return x == y; }
+ bool operator()(const T *x, const T *y) const {
+ return x == y;
+ }
};
struct ClassPointer_Hash {
- uint operator()(const T *x) const {
+ uint operator()(const T *x) const {
return static_cast<uint>((int64)x % ((int64)1 << sizeof(uint)));
}
};
- typedef Common::HashMap<unsigned int, T *> HANDLE2PTR_MAP;
+ typedef Common::HashMap<unsigned int, T *> HANDLE2PTR_MAP;
typedef Common::HashMap<T *, unsigned int, ClassPointer_Hash, ClassPointer_EqualTo> PTR2HANDLE_MAP;
- HANDLE2PTR_MAP m_Handle2PtrMap;
- PTR2HANDLE_MAP m_Ptr2HandleMap;
- unsigned int m_NextHandle;
+ HANDLE2PTR_MAP m_Handle2PtrMap;
+ PTR2HANDLE_MAP m_Ptr2HandleMap;
+ unsigned int m_NextHandle;
// -----------------------------------------------------------------------------
diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp
index 880f4be8d0..589e498408 100644
--- a/engines/sword25/kernel/outputpersistenceblock.cpp
+++ b/engines/sword25/kernel/outputpersistenceblock.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,7 +45,7 @@
// -----------------------------------------------------------------------------
namespace {
- const unsigned int INITIAL_BUFFER_SIZE = 1024 * 64;
+const unsigned int INITIAL_BUFFER_SIZE = 1024 * 64;
}
namespace Sword25 {
diff --git a/engines/sword25/kernel/outputpersistenceblock.h b/engines/sword25/kernel/outputpersistenceblock.h
index adc0105dd2..c13f86215d 100644
--- a/engines/sword25/kernel/outputpersistenceblock.h
+++ b/engines/sword25/kernel/outputpersistenceblock.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -32,7 +32,7 @@
*
*/
-#ifndef SWORD25_OUTPUTPERSISTENCEBLOCK_H
+#ifndef SWORD25_OUTPUTPERSISTENCEBLOCK_H
#define SWORD25_OUTPUTPERSISTENCEBLOCK_H
// -----------------------------------------------------------------------------
@@ -59,8 +59,12 @@ public:
void Write(const Common::String &String);
void Write(const void *BufferPtr, size_t Size);
- const void *GetData() const { return &m_Data[0]; }
- unsigned int GetDataSize() const { return m_Data.size(); }
+ const void *GetData() const {
+ return &m_Data[0];
+ }
+ unsigned int GetDataSize() const {
+ return m_Data.size();
+ }
private:
void WriteMarker(unsigned char Marker);
diff --git a/engines/sword25/kernel/persistable.h b/engines/sword25/kernel/persistable.h
index 5c1b973435..ff3bd9c098 100644
--- a/engines/sword25/kernel/persistable.h
+++ b/engines/sword25/kernel/persistable.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -44,8 +44,8 @@ class BS_Persistable {
public:
virtual ~BS_Persistable() {};
- virtual bool Persist(BS_OutputPersistenceBlock & Writer) = 0;
- virtual bool Unpersist(BS_InputPersistenceBlock & Reader) = 0;
+ virtual bool Persist(BS_OutputPersistenceBlock &Writer) = 0;
+ virtual bool Unpersist(BS_InputPersistenceBlock &Reader) = 0;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/persistenceblock.h b/engines/sword25/kernel/persistenceblock.h
index 1417d3df69..71cf2135da 100644
--- a/engines/sword25/kernel/persistenceblock.h
+++ b/engines/sword25/kernel/persistenceblock.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -32,7 +32,7 @@
*
*/
-#ifndef SWORD25_PERSISTENCEBLOCK_H
+#ifndef SWORD25_PERSISTENCEBLOCK_H
#define SWORD25_PERSISTENCEBLOCK_H
// -----------------------------------------------------------------------------
@@ -49,12 +49,20 @@ namespace Sword25 {
class BS_PersistenceBlock {
public:
- static unsigned int GetSInt32Size() { return sizeof(signed int) + sizeof(unsigned char); }
- static unsigned int GetUInt32Size() { return sizeof(unsigned int) + sizeof(unsigned char); }
- static unsigned int GetFloat32Size() { return sizeof(float) + sizeof(unsigned char); }
- static unsigned int GetBoolSize() { return sizeof(unsigned char) + sizeof(unsigned char); }
- static unsigned int GetStringSize(const Common::String &String) {
- return static_cast<unsigned int>(sizeof(unsigned int) + String.size() + sizeof(unsigned char));
+ static unsigned int GetSInt32Size() {
+ return sizeof(signed int) + sizeof(unsigned char);
+ }
+ static unsigned int GetUInt32Size() {
+ return sizeof(unsigned int) + sizeof(unsigned char);
+ }
+ static unsigned int GetFloat32Size() {
+ return sizeof(float) + sizeof(unsigned char);
+ }
+ static unsigned int GetBoolSize() {
+ return sizeof(unsigned char) + sizeof(unsigned char);
+ }
+ static unsigned int GetStringSize(const Common::String &String) {
+ return static_cast<unsigned int>(sizeof(unsigned int) + String.size() + sizeof(unsigned char));
}
protected:
@@ -90,7 +98,7 @@ protected:
private:
static bool IsBigEndian() {
unsigned int Dummy = 1;
- unsigned char * DummyPtr = reinterpret_cast<unsigned char *>(&Dummy);
+ unsigned char *DummyPtr = reinterpret_cast<unsigned char *>(&Dummy);
return DummyPtr[0] == 0;
}
@@ -103,7 +111,7 @@ private:
static void ReverseByteOrder(void *Ptr) {
// Reverses the byte order of the 32-bit word pointed to by Ptr
- unsigned char * CharPtr = static_cast<unsigned char *>(Ptr);
+ unsigned char *CharPtr = static_cast<unsigned char *>(Ptr);
Swap(CharPtr[0], CharPtr[3]);
Swap(CharPtr[1], CharPtr[2]);
}
diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp
index 54203b67dc..e3f3347799 100644
--- a/engines/sword25/kernel/persistenceservice.cpp
+++ b/engines/sword25/kernel/persistenceservice.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,61 +58,61 @@ using namespace std;
// -----------------------------------------------------------------------------
namespace Sword25 {
- const char * SAVEGAME_EXTENSION = ".b25s";
- const char * SAVEGAME_DIRECTORY = "saves";
- const char * FILE_MARKER = "BS25SAVEGAME";
- const unsigned int SLOT_COUNT = 18;
- const unsigned int FILE_COPY_BUFFER_SIZE = 1024 * 10;
- const char *VERSIONID = "1";
-
- // -------------------------------------------------------------------------
-
- Common::String GenerateSavegameFilename(unsigned int SlotID) {
- Common::String oss;
- oss += SlotID;
- oss += SAVEGAME_EXTENSION;
- return oss;
- }
+const char *SAVEGAME_EXTENSION = ".b25s";
+const char *SAVEGAME_DIRECTORY = "saves";
+const char *FILE_MARKER = "BS25SAVEGAME";
+const unsigned int SLOT_COUNT = 18;
+const unsigned int FILE_COPY_BUFFER_SIZE = 1024 * 10;
+const char *VERSIONID = "1";
+
+// -------------------------------------------------------------------------
+
+Common::String GenerateSavegameFilename(unsigned int SlotID) {
+ Common::String oss;
+ oss += SlotID;
+ oss += SAVEGAME_EXTENSION;
+ return oss;
+}
- // -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
- Common::String GenerateSavegamePath(unsigned int SlotID) {
- Common::String oss;
- oss = BS_PersistenceService::GetSavegameDirectory();
- oss += BS_FileSystemUtil::GetInstance().GetPathSeparator();
- oss += GenerateSavegameFilename(SlotID);
- return oss;
- }
-
- // -------------------------------------------------------------------------
-
- Common::String FormatTimestamp(TimeDate Time) {
- // In the original BS2.5 engine, this used a local object to show the date/time as as a string.
- // For now in ScummVM it's being hardcoded to 'dd-MON-yyyy hh:mm:ss'
- Common::String monthList[12] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
- char buffer[100];
- snprintf(buffer, 100, "%.2d-%s-%.4d %.2d:%.2d:%.2d",
- Time.tm_mday, monthList[Time.tm_mon].c_str(), Time.tm_year,
- Time.tm_hour, Time.tm_min, Time.tm_sec
- );
-
- return Common::String(buffer);
- }
+Common::String GenerateSavegamePath(unsigned int SlotID) {
+ Common::String oss;
+ oss = BS_PersistenceService::GetSavegameDirectory();
+ oss += BS_FileSystemUtil::GetInstance().GetPathSeparator();
+ oss += GenerateSavegameFilename(SlotID);
+ return oss;
+}
- // -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+
+Common::String FormatTimestamp(TimeDate Time) {
+ // In the original BS2.5 engine, this used a local object to show the date/time as as a string.
+ // For now in ScummVM it's being hardcoded to 'dd-MON-yyyy hh:mm:ss'
+ Common::String monthList[12] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+ char buffer[100];
+ snprintf(buffer, 100, "%.2d-%s-%.4d %.2d:%.2d:%.2d",
+ Time.tm_mday, monthList[Time.tm_mon].c_str(), Time.tm_year,
+ Time.tm_hour, Time.tm_min, Time.tm_sec
+ );
+
+ return Common::String(buffer);
+}
- Common::String LoadString(Common::InSaveFile *In, uint MaxSize = 999) {
- Common::String Result;
- char ch;
- while ((ch = (char)In->readByte()) != '\0') {
- Result += ch;
- if (Result.size() >= MaxSize) break;
- }
+// -------------------------------------------------------------------------
- return Result;
+Common::String LoadString(Common::InSaveFile *In, uint MaxSize = 999) {
+ Common::String Result;
+ char ch;
+ while ((ch = (char)In->readByte()) != '\0') {
+ Result += ch;
+ if (Result.size() >= MaxSize) break;
}
+
+ return Result;
+}
}
namespace Sword25 {
@@ -122,15 +122,17 @@ namespace Sword25 {
// -----------------------------------------------------------------------------
struct SavegameInformation {
- bool IsOccupied;
- bool IsCompatible;
- Common::String Description;
- Common::String Filename;
- unsigned int GamedataLength;
- unsigned int GamedataOffset;
- unsigned int GamedataUncompressedLength;
-
- SavegameInformation() { Clear(); }
+ bool IsOccupied;
+ bool IsCompatible;
+ Common::String Description;
+ Common::String Filename;
+ unsigned int GamedataLength;
+ unsigned int GamedataOffset;
+ unsigned int GamedataUncompressedLength;
+
+ SavegameInformation() {
+ Clear();
+ }
void Clear() {
IsOccupied = false;
@@ -163,7 +165,7 @@ struct BS_PersistenceService::Impl {
void ReadSlotSavegameInformation(unsigned int SlotID) {
// Aktuelle Slotinformationen in den Ausgangszustand versetzen, er wird im Folgenden neu gefüllt.
- SavegameInformation & CurSavegameInfo = m_SavegameInformations[SlotID];
+ SavegameInformation &CurSavegameInfo = m_SavegameInformations[SlotID];
CurSavegameInfo.Clear();
// Den Dateinamen für den Spielstand des Slots generieren.
@@ -207,7 +209,7 @@ struct BS_PersistenceService::Impl {
// Construction / Destruction
// -----------------------------------------------------------------------------
-BS_PersistenceService & BS_PersistenceService::GetInstance() {
+BS_PersistenceService &BS_PersistenceService::GetInstance() {
static BS_PersistenceService Instance;
return Instance;
}
@@ -246,16 +248,16 @@ Common::String BS_PersistenceService::GetSavegameDirectory() {
// -----------------------------------------------------------------------------
namespace {
- bool CheckSlotID(unsigned int SlotID) {
- // Überprüfen, ob die Slot-ID zulässig ist.
- if (SlotID >= SLOT_COUNT) {
- BS_LOG_ERRORLN("Tried to access an invalid slot (%d). Only slot ids from 0 to %d are allowed.", SlotID, SLOT_COUNT - 1);
- return false;
- } else {
- return true;
- }
+bool CheckSlotID(unsigned int SlotID) {
+ // Überprüfen, ob die Slot-ID zulässig ist.
+ if (SlotID >= SLOT_COUNT) {
+ BS_LOG_ERRORLN("Tried to access an invalid slot (%d). Only slot ids from 0 to %d are allowed.", SlotID, SLOT_COUNT - 1);
+ return false;
+ } else {
+ return true;
}
}
+}
// -----------------------------------------------------------------------------
@@ -304,7 +306,7 @@ bool BS_PersistenceService::SaveGame(unsigned int SlotID, const Common::String &
// Spielstanddatei öffnen und die Headerdaten schreiben.
Common::SaveFileManager *sfm = g_system->getSavefileManager();
- Common::OutSaveFile *File = sfm->openForSaving(Filename);
+ Common::OutSaveFile *File = sfm->openForSaving(Filename);
File->writeString(FILE_MARKER);
File->writeByte(' ');
@@ -330,7 +332,7 @@ bool BS_PersistenceService::SaveGame(unsigned int SlotID, const Common::String &
// Daten komprimieren.
uLongf CompressedLength = Writer.GetDataSize() + (Writer.GetDataSize() + 500) / 1000 + 12;
Bytef *CompressionBuffer = new Bytef[CompressedLength];
-
+
if (compress2(&CompressionBuffer[0], &CompressedLength, reinterpret_cast<const Bytef *>(Writer.GetData()), Writer.GetDataSize(), 6) != Z_OK) {
error("Unable to compress savegame data in savegame file \"%s\".", Filename.c_str());
}
@@ -353,7 +355,7 @@ bool BS_PersistenceService::SaveGame(unsigned int SlotID, const Common::String &
// Screenshotdatei an die Datei anfügen.
if (BS_FileSystemUtil::GetInstance().FileExists(ScreenshotFilename)) {
Common::File ScreenshotFile;
- if (!ScreenshotFile.open(ScreenshotFilename.c_str()))
+ if (!ScreenshotFile.open(ScreenshotFilename.c_str()))
error("Unable to load screenshot file");
byte *Buffer = new Byte[FILE_COPY_BUFFER_SIZE];
@@ -386,7 +388,7 @@ bool BS_PersistenceService::LoadGame(unsigned int SlotID) {
return false;
}
- SavegameInformation & CurSavegameInfo = m_impl->m_SavegameInformations[SlotID];
+ SavegameInformation &CurSavegameInfo = m_impl->m_SavegameInformations[SlotID];
// Überprüfen, ob der Slot belegt ist.
if (!CurSavegameInfo.IsOccupied) {
@@ -398,8 +400,7 @@ bool BS_PersistenceService::LoadGame(unsigned int SlotID) {
// Im Debug-Modus wird dieser Test übersprungen. Für das Testen ist es hinderlich auf die Einhaltung dieser strengen Bedingung zu bestehen,
// da sich die Versions-ID bei jeder Codeänderung mitändert.
#ifndef DEBUG
- if (!CurSavegameInfo.IsCompatible)
- {
+ if (!CurSavegameInfo.IsCompatible) {
BS_LOG_ERRORLN("Tried to load a savegame (%d) that is not compatible with this engine version.", SlotID);
return false;
}
@@ -408,7 +409,7 @@ bool BS_PersistenceService::LoadGame(unsigned int SlotID) {
byte *CompressedDataBuffer = new byte[CurSavegameInfo.GamedataLength];
byte *UncompressedDataBuffer = new Bytef[CurSavegameInfo.GamedataUncompressedLength];
- File = sfm->openForLoading(GenerateSavegamePath(SlotID));
+ File = sfm->openForLoading(GenerateSavegamePath(SlotID));
File->seek(CurSavegameInfo.GamedataOffset);
File->read(reinterpret_cast<char *>(&CompressedDataBuffer[0]), CurSavegameInfo.GamedataLength);
@@ -422,7 +423,7 @@ bool BS_PersistenceService::LoadGame(unsigned int SlotID) {
// Spieldaten dekomprimieren.
uLongf UncompressedBufferSize = CurSavegameInfo.GamedataUncompressedLength;
if (uncompress(reinterpret_cast<Bytef *>(&UncompressedDataBuffer[0]), &UncompressedBufferSize,
- reinterpret_cast<Bytef *>(&CompressedDataBuffer[0]), CurSavegameInfo.GamedataLength) != Z_OK) {
+ reinterpret_cast<Bytef *>(&CompressedDataBuffer[0]), CurSavegameInfo.GamedataLength) != Z_OK) {
BS_LOG_ERRORLN("Unable to decompress the gamedata from savegame file \"%s\".", CurSavegameInfo.Filename.c_str());
delete[] UncompressedDataBuffer;
delete[] CompressedDataBuffer;
diff --git a/engines/sword25/kernel/persistenceservice.h b/engines/sword25/kernel/persistenceservice.h
index 5fa3d320a5..15fb15c7ec 100644
--- a/engines/sword25/kernel/persistenceservice.h
+++ b/engines/sword25/kernel/persistenceservice.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -32,7 +32,7 @@
*
*/
-#ifndef SWORD25_PERSISTENCESERVICE_H
+#ifndef SWORD25_PERSISTENCESERVICE_H
#define SWORD25_PERSISTENCESERVICE_H
// -----------------------------------------------------------------------------
@@ -62,21 +62,21 @@ public:
// Interface
// -----------------------------------------------------------------------------
- static unsigned int GetSlotCount();
+ static unsigned int GetSlotCount();
static Common::String GetSavegameDirectory();
- void ReloadSlots();
- bool IsSlotOccupied(unsigned int SlotID);
- bool IsSavegameCompatible(unsigned int SlotID);
+ void ReloadSlots();
+ bool IsSlotOccupied(unsigned int SlotID);
+ bool IsSavegameCompatible(unsigned int SlotID);
Common::String &GetSavegameDescription(unsigned int SlotID);
Common::String &GetSavegameFilename(unsigned int SlotID);
-
- bool SaveGame(unsigned int SlotID, const Common::String & ScreenshotFilename);
- bool LoadGame(unsigned int SlotID);
+
+ bool SaveGame(unsigned int SlotID, const Common::String &ScreenshotFilename);
+ bool LoadGame(unsigned int SlotID);
private:
struct Impl;
- Impl * m_impl;
+ Impl *m_impl;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resmanager.cpp b/engines/sword25/kernel/resmanager.cpp
index d0a32965ce..1e232ca63b 100644
--- a/engines/sword25/kernel/resmanager.cpp
+++ b/engines/sword25/kernel/resmanager.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -53,7 +53,9 @@ BS_ResourceManager::~BS_ResourceManager() {
BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*Iter)->GetFileName().c_str());
// Set the lock count to zero
- while ((*Iter)->GetLockCount() > 0) { (*Iter)->Release(); };
+ while ((*Iter)->GetLockCount() > 0) {
+ (*Iter)->Release();
+ };
// Delete the resource
delete(*Iter);
@@ -63,7 +65,7 @@ BS_ResourceManager::~BS_ResourceManager() {
/**
* Returns a resource by it's ordinal index. Returns NULL if any error occurs
* Note: This method is not optimised for speed and should be used only for debugging purposes
- * @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
+ * @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
*/
BS_Resource *BS_ResourceManager::GetResourceByOrdinal(int Ord) const {
// Überprüfen ob der Index Ord innerhald der Listengrenzen liegt.
@@ -74,7 +76,7 @@ BS_Resource *BS_ResourceManager::GetResourceByOrdinal(int Ord) const {
// Liste durchlaufen und die Resource mit dem gewünschten Index zurückgeben.
int CurOrd = 0;
- Common::List<BS_Resource*>::const_iterator Iter = m_Resources.begin();
+ Common::List<BS_Resource *>::const_iterator Iter = m_Resources.begin();
for (; Iter != m_Resources.end(); ++Iter, ++CurOrd) {
if (CurOrd == Ord)
return (*Iter);
@@ -88,7 +90,7 @@ BS_Resource *BS_ResourceManager::GetResourceByOrdinal(int Ord) const {
/**
* Registers a RegisterResourceService. This method is the constructor of
* BS_ResourceService, and thus helps all resource services in the ResourceManager list
- * @param pService Which service
+ * @param pService Which service
*/
bool BS_ResourceManager::RegisterResourceService(BS_ResourceService *pService) {
if (!pService) {
@@ -109,7 +111,7 @@ void BS_ResourceManager::DeleteResourcesIfNecessary() {
if (m_KernelPtr->GetUsedMemory() < m_MaxMemoryUsage || m_Resources.empty()) return;
// Keep deleting resources until the memory usage of the process falls below the set maximum limit.
- // The list is processed backwards in order to first release those resources who have been
+ // The list is processed backwards in order to first release those resources who have been
// not been accessed for the longest
Common::List<BS_Resource *>::iterator Iter = m_Resources.end();
do {
@@ -137,7 +139,7 @@ void BS_ResourceManager::EmptyCache() {
/**
* Returns a requested resource. If any error occurs, returns NULL
- * @param FileName Filename of resource
+ * @param FileName Filename of resource
*/
BS_Resource *BS_ResourceManager::RequestResource(const Common::String &FileName) {
// Get the absolute path to the file
@@ -170,11 +172,11 @@ BS_Resource *BS_ResourceManager::RequestResource(const Common::String &FileName)
/**
* Loads a resource into the cache
- * @param FileName The filename of the resource to be cached
- * @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
+ * @param FileName The filename of the resource to be cached
+ * @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
* This is useful for files that may have changed in the interim
*/
-bool BS_ResourceManager::PrecacheResource(const Common::String& FileName, bool ForceReload) {
+bool BS_ResourceManager::PrecacheResource(const Common::String &FileName, bool ForceReload) {
// Get the absolute path to the file
Common::String UniqueFileName = GetUniqueFileName(FileName);
if (UniqueFileName == "")
@@ -202,7 +204,7 @@ bool BS_ResourceManager::PrecacheResource(const Common::String& FileName, bool F
/**
* Moves a resource to the top of the resource list
- * @param pResource The resource
+ * @param pResource The resource
*/
void BS_ResourceManager::MoveToFront(BS_Resource *pResource) {
// Erase the resource from it's current position
@@ -217,7 +219,7 @@ void BS_ResourceManager::MoveToFront(BS_Resource *pResource) {
* Loads a resource and updates the m_UsedMemory total
*
* The resource must not already be loaded
- * @param FileName The unique filename of the resource to be loaded
+ * @param FileName The unique filename of the resource to be loaded
*/
BS_Resource *BS_ResourceManager::LoadResource(const Common::String &FileName) {
// ResourceService finden, der die Resource laden kann.
@@ -252,7 +254,7 @@ BS_Resource *BS_ResourceManager::LoadResource(const Common::String &FileName) {
* Returns the full path of a given resource filename.
* It will return an empty string if a path could not be created.
*/
-Common::String BS_ResourceManager::GetUniqueFileName(const Common::String& FileName) const {
+Common::String BS_ResourceManager::GetUniqueFileName(const Common::String &FileName) const {
// Get a pointer to the package manager
BS_PackageManager *pPackage = (BS_PackageManager *)m_KernelPtr->GetService("package");
if (!pPackage) {
@@ -281,7 +283,7 @@ Common::List<BS_Resource *>::iterator BS_ResourceManager::DeleteResource(BS_Reso
Common::List<BS_Resource *>::iterator Result = m_Resources.erase(pResource->_Iterator);
// Delete the resource
- delete (pDummy);
+ delete(pDummy);
// Return the iterator
return Result;
@@ -289,17 +291,16 @@ Common::List<BS_Resource *>::iterator BS_ResourceManager::DeleteResource(BS_Reso
/**
* Returns a pointer to a loaded resource. If any error occurs, NULL will be returned.
- * @param UniqueFileName The absolute path and filename
+ * @param UniqueFileName The absolute path and filename
* Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
-BS_Resource * BS_ResourceManager::GetResource(const Common::String &UniqueFileName) const {
+BS_Resource *BS_ResourceManager::GetResource(const Common::String &UniqueFileName) const {
// Determine whether the resource is already loaded
const Common::List<BS_Resource *>& HashBucket = m_ResourceHashTable[
- BS_String::GetHash(UniqueFileName) % HASH_TABLE_BUCKETS];
+ BS_String::GetHash(UniqueFileName) % HASH_TABLE_BUCKETS];
{
- Common::List<BS_Resource*>::const_iterator Iter = HashBucket.begin();
- for (; Iter != HashBucket.end(); ++Iter)
- {
+ Common::List<BS_Resource *>::const_iterator Iter = HashBucket.begin();
+ for (; Iter != HashBucket.end(); ++Iter) {
// Wenn die Resource gefunden wurde wird sie zurückgegeben.
if ((*Iter)->GetFileName() == UniqueFileName)
return *Iter;
diff --git a/engines/sword25/kernel/resmanager.h b/engines/sword25/kernel/resmanager.h
index 511bf63d68..e642e54055 100644
--- a/engines/sword25/kernel/resmanager.h
+++ b/engines/sword25/kernel/resmanager.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -48,41 +48,43 @@ class BS_Resource;
class BS_Kernel;
class BS_ResourceManager {
-friend class BS_Kernel;
+ friend class BS_Kernel;
public:
/**
* Returns a requested resource. If any error occurs, returns NULL
- * @param FileName Filename of resource
+ * @param FileName Filename of resource
*/
BS_Resource *RequestResource(const Common::String &FileName);
/**
* Loads a resource into the cache
- * @param FileName The filename of the resource to be cached
- * @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
+ * @param FileName The filename of the resource to be cached
+ * @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
* This is useful for files that may have changed in the interim
*/
- bool PrecacheResource(const Common::String& FileName, bool ForceReload = false);
+ bool PrecacheResource(const Common::String &FileName, bool ForceReload = false);
/**
* Returns the number of loaded resources
*/
- int GetResourceCount() const { return static_cast<int>(m_Resources.size()); }
+ int GetResourceCount() const {
+ return static_cast<int>(m_Resources.size());
+ }
/**
* Returns a resource by it's ordinal index. Returns NULL if any error occurs
* Note: This method is not optimised for speed and should be used only for debugging purposes
- * @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
+ * @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
*/
BS_Resource *GetResourceByOrdinal(int Ord) const;
/**
* Registers a RegisterResourceService. This method is the constructor of
* BS_ResourceService, and thus helps all resource services in the ResourceManager list
- * @param pService Which service
+ * @param pService Which service
*/
- bool RegisterResourceService(BS_ResourceService* pService);
+ bool RegisterResourceService(BS_ResourceService *pService);
/**
* Releases all resources that are not locked.
@@ -92,7 +94,9 @@ public:
/**
* Returns the maximum memory the kernel has used
*/
- int GetMaxMemoryUsage() const { return m_MaxMemoryUsage; }
+ int GetMaxMemoryUsage() const {
+ return m_MaxMemoryUsage;
+ }
/**
* Specifies the maximum amount of memory the engine is allowed to use.
@@ -106,13 +110,17 @@ public:
* Specifies whether a warning is written to the log when a cache miss occurs.
* THe default value is "false".
*/
- bool IsLogCacheMiss() const { return m_LogCacheMiss; }
+ bool IsLogCacheMiss() const {
+ return m_LogCacheMiss;
+ }
/**
* Sets whether warnings are written to the log if a cache miss occurs.
- * @param Flag If "true", then future warnings will be logged
+ * @param Flag If "true", then future warnings will be logged
*/
- void SetLogCacheMiss(bool Flag) { m_LogCacheMiss = Flag; }
+ void SetLogCacheMiss(bool Flag) {
+ m_LogCacheMiss = Flag;
+ }
/**
* Writes the names of all currently locked resources to the log file
@@ -124,21 +132,20 @@ private:
* Creates a new resource manager
* Only the BS_Kernel class can generate copies this class. Thus, the constructor is private
*/
- BS_ResourceManager(BS_Kernel* pKernel) :
+ BS_ResourceManager(BS_Kernel *pKernel) :
m_KernelPtr(pKernel),
m_MaxMemoryUsage(100000000),
m_LogCacheMiss(false)
{};
virtual ~BS_ResourceManager();
-
- enum
- {
+
+ enum {
HASH_TABLE_BUCKETS = 256
};
/**
* Moves a resource to the top of the resource list
- * @param pResource The resource
+ * @param pResource The resource
*/
void MoveToFront(BS_Resource *pResource);
@@ -146,7 +153,7 @@ private:
* Loads a resource and updates the m_UsedMemory total
*
* The resource must not already be loaded
- * @param FileName The unique filename of the resource to be loaded
+ * @param FileName The unique filename of the resource to be loaded
*/
BS_Resource *LoadResource(const Common::String &FileName);
@@ -159,11 +166,11 @@ private:
/**
* Deletes a resource, removes it from the lists, and updates m_UsedMemory
*/
- Common::List<BS_Resource*>::iterator DeleteResource(BS_Resource *pResource);
+ Common::List<BS_Resource *>::iterator DeleteResource(BS_Resource *pResource);
/**
* Returns a pointer to a loaded resource. If any error occurs, NULL will be returned.
- * @param UniqueFileName The absolute path and filename
+ * @param UniqueFileName The absolute path and filename
* Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
BS_Resource *GetResource(const Common::String &UniqueFileName) const;
@@ -173,12 +180,12 @@ private:
*/
void DeleteResourcesIfNecessary();
- BS_Kernel * m_KernelPtr;
- unsigned int m_MaxMemoryUsage;
- Common::Array<BS_ResourceService *> m_ResourceServices;
- Common::List<BS_Resource *> m_Resources;
- Common::List<BS_Resource *> m_ResourceHashTable[HASH_TABLE_BUCKETS];
- bool m_LogCacheMiss;
+ BS_Kernel *m_KernelPtr;
+ unsigned int m_MaxMemoryUsage;
+ Common::Array<BS_ResourceService *> m_ResourceServices;
+ Common::List<BS_Resource *> m_Resources;
+ Common::List<BS_Resource *> m_ResourceHashTable[HASH_TABLE_BUCKETS];
+ bool m_LogCacheMiss;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resource.cpp b/engines/sword25/kernel/resource.cpp
index 9bb491b8b4..c33bfea268 100644
--- a/engines/sword25/kernel/resource.cpp
+++ b/engines/sword25/kernel/resource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -42,8 +42,8 @@ namespace Sword25 {
#define BS_LOG_PREFIX "RESOURCE"
BS_Resource::BS_Resource(const Common::String &FileName, RESOURCE_TYPES Type) :
- _Type(Type),
- _RefCount(0) {
+ _Type(Type),
+ _RefCount(0) {
BS_ASSERT(BS_Kernel::GetInstance()->GetService("package"));
_FileName = static_cast<BS_PackageManager *>(BS_Kernel::GetInstance()->GetService("package"))->GetAbsolutePath(FileName);
diff --git a/engines/sword25/kernel/resource.h b/engines/sword25/kernel/resource.h
index 4b0e8ccd21..4653eab149 100644
--- a/engines/sword25/kernel/resource.h
+++ b/engines/sword25/kernel/resource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,7 +45,7 @@ class BS_Kernel;
class BS_ResourceManager;
class BS_Resource {
-friend class BS_ResourceManager;
+ friend class BS_ResourceManager;
public:
enum RESOURCE_TYPES {
@@ -60,47 +60,57 @@ public:
/**
* Prevents the resource from being released.
- * @remarks This method allows a resource to be locked multiple times.
+ * @remarks This method allows a resource to be locked multiple times.
**/
- void AddReference() { ++_RefCount; }
+ void AddReference() {
+ ++_RefCount;
+ }
/**
* Cancels a previous lock
- * @remarks The resource can still be released more times than it was 'locked', although it is
+ * @remarks The resource can still be released more times than it was 'locked', although it is
* not recommended.
**/
void Release();
/**
* Returns the current lock count for the resource
- * @return The current lock count
+ * @return The current lock count
**/
- int GetLockCount() const { return _RefCount; }
+ int GetLockCount() const {
+ return _RefCount;
+ }
/**
* Returns the absolute path of the given resource
*/
- const Common::String &GetFileName() const { return _FileName; }
+ const Common::String &GetFileName() const {
+ return _FileName;
+ }
/**
* Returns the hash of the filename of a resource
*/
- unsigned int GetFileNameHash() const { return _FileNameHash; }
+ unsigned int GetFileNameHash() const {
+ return _FileNameHash;
+ }
/**
* Returns a resource's type
*/
- unsigned int GetType() const { return _Type; }
+ unsigned int GetType() const {
+ return _Type;
+ }
protected:
virtual ~BS_Resource() {};
private:
- Common::String _FileName; ///< The absolute filename
- unsigned int _FileNameHash; ///< The hash value of the filename
- unsigned int _RefCount; ///< The number of locks
- unsigned int _Type; ///< The type of the resource
- Common::List<BS_Resource *>::iterator _Iterator; ///< Points to the resource position in the LRU list
+ Common::String _FileName; ///< The absolute filename
+ unsigned int _FileNameHash; ///< The hash value of the filename
+ unsigned int _RefCount; ///< The number of locks
+ unsigned int _Type; ///< The type of the resource
+ Common::List<BS_Resource *>::iterator _Iterator; ///< Points to the resource position in the LRU list
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resservice.h b/engines/sword25/kernel/resservice.h
index 8804b5bbac..2197d283bf 100644
--- a/engines/sword25/kernel/resservice.h
+++ b/engines/sword25/kernel/resservice.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -47,9 +47,8 @@ class BS_Resource;
class BS_ResourceService : public BS_Service {
public:
- BS_ResourceService(BS_Kernel* pKernel) : BS_Service(pKernel)
- {
- BS_ResourceManager* pResource = pKernel->GetResourceManager();
+ BS_ResourceService(BS_Kernel *pKernel) : BS_Service(pKernel) {
+ BS_ResourceManager *pResource = pKernel->GetResourceManager();
pResource->RegisterResourceService(this);
}
@@ -58,25 +57,25 @@ public:
/**
* Loads a resource
- * @return Returns the resource if successful, otherwise NULL
+ * @return Returns the resource if successful, otherwise NULL
*/
virtual BS_Resource *LoadResource(const Common::String &FileName) = 0;
/**
* Checks whether the given name can be loaded by the resource service
- * @param FileName Dateiname
- * @return Returns true if the resource can be loaded.
+ * @param FileName Dateiname
+ * @return Returns true if the resource can be loaded.
*/
- virtual bool CanLoadResource(const Common::String& FileName) = 0;
+ virtual bool CanLoadResource(const Common::String &FileName) = 0;
protected:
// Alternative methods for classes BS_ResourceService
/**
* Compares two strings, with the second string allowed to contain '*' and '?' wildcards
- * @param String The first comparison string. This must not contain wildcards
- * @param Pattern The sceond comaprison string. Wildcards of '*' and '?' are allowed.
- * @return Returns true if the string matches the pattern, otherwise false.
+ * @param String The first comparison string. This must not contain wildcards
+ * @param Pattern The sceond comaprison string. Wildcards of '*' and '?' are allowed.
+ * @return Returns true if the string matches the pattern, otherwise false.
*/
bool _WildCardStringMatch(const Common::String &String, const Common::String &Pattern) {
return _WildCardStringMatchRecursion(String.c_str(), Pattern.c_str());
@@ -89,18 +88,20 @@ private:
if (*Pattern == '*') {
// Use a copy of the pattern pointer so as not to destroy the current state
const char *PatternCopy = Pattern;
- while (*PatternCopy == '*') { PatternCopy++; }
+ while (*PatternCopy == '*') {
+ PatternCopy++;
+ }
if (!*PatternCopy) return true;
}
// 2. The string is over, but the patern is not -> FALSE
if (!*String && *Pattern) return false;
// 3. The string is over, and the pattern is finished -> TRUE
if (!*String) return true;
-
+
// Recursive check 1:
// If the two current characters are the same, or pattern '?', then keep scanning
if (*String == *Pattern || *Pattern == '?') return _WildCardStringMatchRecursion(String + 1, Pattern + 1);
-
+
// Falls nicht, wird untersucht ob ein '*' vorliegt
if (*Pattern == '*') {
// Recursive check 2:
@@ -111,7 +112,7 @@ private:
// The recursion ends, therefore, keep returning to this place until a character
// in the string which corresponds to the '*' in pattern
}
-
+
// The match has failed
return false;
}
diff --git a/engines/sword25/kernel/scummvmwindow.cpp b/engines/sword25/kernel/scummvmwindow.cpp
index 56e3b14adb..2b4e820160 100644
--- a/engines/sword25/kernel/scummvmwindow.cpp
+++ b/engines/sword25/kernel/scummvmwindow.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,7 +45,7 @@ namespace Sword25 {
bool BS_ScummVMWindow::_ClassRegistered = false;
-// Constructor / Destructor
+// Constructor / Destructor
// ------------------------
BS_ScummVMWindow::BS_ScummVMWindow(int X, int Y, int Width, int Height, bool Visible) {
// Presume that init will fail
@@ -163,133 +163,133 @@ bool BS_ScummVMWindow::WaitForFocus() {
// Die WindowProc aller Fenster der Klasse
LRESULT CALLBACK BS_ScummVMWindow::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_PAINT:
- ValidateRect(hwnd, NULL);
- break;
-
- case WM_DESTROY:
- // Das Fenster wird zerstört
- PostQuitMessage(0);
- break;
-
- case WM_CLOSE:
- {
- BS_Window * WindowPtr = BS_Kernel::GetInstance()->GetWindow();
- if (WindowPtr) {
- WindowPtr->SetCloseWanted(true);
- }
- break;
- }
-
- case WM_KEYDOWN:
- {
- // Tastendrücke, die für das Inputmodul interessant sind, werden diesem gemeldet.
- BS_InputEngine * InputPtr = BS_Kernel::GetInstance()->GetInput();
-
- if (InputPtr)
- {
- switch (wParam)
- {
- case VK_RETURN:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_ENTER);
- break;
-
- case VK_LEFT:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_LEFT);
- break;
-
- case VK_RIGHT:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_RIGHT);
- break;
-
- case VK_HOME:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_HOME);
- break;
-
- case VK_END:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_END);
- break;
-
- case VK_BACK:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_BACKSPACE);
- break;
-
- case VK_TAB:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_TAB);
- break;
-
- case VK_INSERT:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_INSERT);
- break;
-
- case VK_DELETE:
- InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_DELETE);
- break;
- }
- }
- break;
- }
-
- case WM_KEYUP:
- case WM_SYSKEYUP:
- // Alle Tastendrücke werden ignoriert, damit Windows per DefWindowProc() nicht darauf
- // reagieren kann und damit unerwartete Seiteneffekte auslöst.
- // Zum Beispiel würden ALT und F10 Tastendrücke das "Menü" aktivieren und somit den Message-Loop zum Stillstand bringen.
- break;
-
- case WM_SYSCOMMAND:
- // Verhindern, dass der Bildschirmschoner aktiviert wird, während das Spiel läuft
- if (wParam != SC_SCREENSAVE) return DefWindowProc(hwnd,uMsg,wParam,lParam);
- break;
-
- case WM_CHAR:
- {
- unsigned char theChar = static_cast<unsigned char>(wParam & 0xff);
-
- // Alle Zeichen, die keine Steuerzeichen sind, werden als Buchstaben dem Input-Service mitgeteilt.
- if (theChar >= 32)
- {
- BS_InputEngine * InputPtr = BS_Kernel::GetInstance()->GetInput();
- if (InputPtr) InputPtr->ReportCharacter(theChar);
- }
- }
- break;
-
- case WM_SETCURSOR:
- {
- // Der Systemcursor wird in der Client-Area des Fensters nicht angezeigt, jedoch in der nicht Client-Area, damit der Benutzer das Fenster wie gewohnt
- // schließen und verschieben kann.
-
- // Koordinaten des Cursors in der Client-Area berechnen.
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwnd, &pt);
-
- // Feststellen, ob sich der Cursor in der Client-Area befindet.
- // Get client rect
- RECT rc;
- GetClientRect(hwnd, &rc);
-
- // See if cursor is in client area
- if(PtInRect(&rc, pt))
- // In der Client-Area keinen Cursor anzeigen.
- SetCursor(NULL);
- else
- // Ausserhalb der Client-Area den Cursor anzeigen.
- SetCursor(LoadCursor(NULL, IDC_ARROW));
-
- return TRUE;
- }
- break;
-
- default:
- // Um alle anderen Vorkommnisse kümmert sich Windows
- return DefWindowProc(hwnd,uMsg,wParam,lParam);
- }
-
- return 0;
+ switch(uMsg)
+ {
+ case WM_PAINT:
+ ValidateRect(hwnd, NULL);
+ break;
+
+ case WM_DESTROY:
+ // Das Fenster wird zerstört
+ PostQuitMessage(0);
+ break;
+
+ case WM_CLOSE:
+ {
+ BS_Window * WindowPtr = BS_Kernel::GetInstance()->GetWindow();
+ if (WindowPtr) {
+ WindowPtr->SetCloseWanted(true);
+ }
+ break;
+ }
+
+ case WM_KEYDOWN:
+ {
+ // Tastendrücke, die für das Inputmodul interessant sind, werden diesem gemeldet.
+ BS_InputEngine * InputPtr = BS_Kernel::GetInstance()->GetInput();
+
+ if (InputPtr)
+ {
+ switch (wParam)
+ {
+ case VK_RETURN:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_ENTER);
+ break;
+
+ case VK_LEFT:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_LEFT);
+ break;
+
+ case VK_RIGHT:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_RIGHT);
+ break;
+
+ case VK_HOME:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_HOME);
+ break;
+
+ case VK_END:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_END);
+ break;
+
+ case VK_BACK:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_BACKSPACE);
+ break;
+
+ case VK_TAB:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_TAB);
+ break;
+
+ case VK_INSERT:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_INSERT);
+ break;
+
+ case VK_DELETE:
+ InputPtr->ReportCommand(BS_InputEngine::KEY_COMMAND_DELETE);
+ break;
+ }
+ }
+ break;
+ }
+
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ // Alle Tastendrücke werden ignoriert, damit Windows per DefWindowProc() nicht darauf
+ // reagieren kann und damit unerwartete Seiteneffekte auslöst.
+ // Zum Beispiel würden ALT und F10 Tastendrücke das "Menü" aktivieren und somit den Message-Loop zum Stillstand bringen.
+ break;
+
+ case WM_SYSCOMMAND:
+ // Verhindern, dass der Bildschirmschoner aktiviert wird, während das Spiel läuft
+ if (wParam != SC_SCREENSAVE) return DefWindowProc(hwnd,uMsg,wParam,lParam);
+ break;
+
+ case WM_CHAR:
+ {
+ unsigned char theChar = static_cast<unsigned char>(wParam & 0xff);
+
+ // Alle Zeichen, die keine Steuerzeichen sind, werden als Buchstaben dem Input-Service mitgeteilt.
+ if (theChar >= 32)
+ {
+ BS_InputEngine * InputPtr = BS_Kernel::GetInstance()->GetInput();
+ if (InputPtr) InputPtr->ReportCharacter(theChar);
+ }
+ }
+ break;
+
+ case WM_SETCURSOR:
+ {
+ // Der Systemcursor wird in der Client-Area des Fensters nicht angezeigt, jedoch in der nicht Client-Area, damit der Benutzer das Fenster wie gewohnt
+ // schließen und verschieben kann.
+
+ // Koordinaten des Cursors in der Client-Area berechnen.
+ POINT pt;
+ GetCursorPos(&pt);
+ ScreenToClient(hwnd, &pt);
+
+ // Feststellen, ob sich der Cursor in der Client-Area befindet.
+ // Get client rect
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+
+ // See if cursor is in client area
+ if(PtInRect(&rc, pt))
+ // In der Client-Area keinen Cursor anzeigen.
+ SetCursor(NULL);
+ else
+ // Ausserhalb der Client-Area den Cursor anzeigen.
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+
+ return TRUE;
+ }
+ break;
+
+ default:
+ // Um alle anderen Vorkommnisse kümmert sich Windows
+ return DefWindowProc(hwnd,uMsg,wParam,lParam);
+ }
+
+ return 0;
}
*/
diff --git a/engines/sword25/kernel/scummvmwindow.h b/engines/sword25/kernel/scummvmwindow.h
index da223ae102..57d9a7e2f9 100644
--- a/engines/sword25/kernel/scummvmwindow.h
+++ b/engines/sword25/kernel/scummvmwindow.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,9 +33,9 @@
*/
/*
- BS_ScummVMWindow
- ----------------
- Implementation of the BS_Window Interfaces for ScummVM
+ BS_ScummVMWindow
+ ----------------
+ Implementation of the BS_Window Interfaces for ScummVM
*/
#ifndef SWORD25_SCUMMVMWINDOW_H
@@ -75,9 +75,9 @@ public:
private:
static bool _ClassRegistered;
- bool _WindowAlive;
- int _ClientXDelta;
- int _ClientYDelta;
+ bool _WindowAlive;
+ int _ClientXDelta;
+ int _ClientYDelta;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/service.h b/engines/sword25/kernel/service.h
index a42b5206bc..0afcb05f11 100644
--- a/engines/sword25/kernel/service.h
+++ b/engines/sword25/kernel/service.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -38,7 +38,7 @@
* This is the base class for all engine services.
* A serivce is an essential part of the engine, ex. the graphics system.
* This was intended to allow, for example, different plug in modules for
- * different kinds of hardware and/or systems.
+ * different kinds of hardware and/or systems.
* The services are created at runtime via the kernel method NewService and NEVER with new.
*
* Autor: Malte Thiesen
@@ -57,13 +57,15 @@ class BS_Kernel;
class BS_Service {
private:
- BS_Kernel * _pKernel;
-
+ BS_Kernel *_pKernel;
+
protected:
BS_Service(BS_Kernel *pKernel) : _pKernel(pKernel) {};
-
- BS_Kernel* GetKernel() const { return _pKernel; }
-
+
+ BS_Kernel *GetKernel() const {
+ return _pKernel;
+ }
+
public:
virtual ~BS_Service() {};
};
diff --git a/engines/sword25/kernel/service_ids.h b/engines/sword25/kernel/service_ids.h
index 7bb352d9e5..0529d53fbe 100644
--- a/engines/sword25/kernel/service_ids.h
+++ b/engines/sword25/kernel/service_ids.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -37,7 +37,7 @@
* -------------
* This file lists all the services.
* EVERY new service needs to be entered here, otherwise it cannot be instantiated
- * by pKernel->NewService(..)
+ * by pKernel->NewService(..)
*
* Autor: Malte Thiesen
*/
@@ -60,7 +60,7 @@ BS_Service *BS_OggTheora_CreateObject(BS_Kernel *pKernel);
// Services are recorded in this table
const BS_ServiceInfo BS_SERVICE_TABLE[] = {
// The first two parameters are the name of the superclass and service
- // The third parameter is the static method of the class that creates an object
+ // The third parameter is the static method of the class that creates an object
// of the class and returns it
// Example:
// BS_ServiceInfo("Superclass", "Service", CreateMethod)
diff --git a/engines/sword25/kernel/string.h b/engines/sword25/kernel/string.h
index feaf546c3e..7ff1d75f7b 100644
--- a/engines/sword25/kernel/string.h
+++ b/engines/sword25/kernel/string.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,7 +52,9 @@ inline bool ToInt(const Common::String &Str, int &Result) {
Common::String::const_iterator Iter = Str.begin();
// Skip whitespaces
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
+ while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
+ ++Iter;
+ }
if (Iter == Str.end()) return false;
// Read sign, if available
@@ -60,19 +62,22 @@ inline bool ToInt(const Common::String &Str, int &Result) {
if (*Iter == '-') {
IsNegative = true;
++Iter;
- }
- else if (*Iter == '+')
+ } else if (*Iter == '+')
++Iter;
// Skip whitespaces
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
- if (Iter ==Str.end()) return false;
+ while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
+ ++Iter;
+ }
+ if (Iter == Str.end()) return false;
// Convert string to integer
Result = 0;
while (Iter != Str.end()) {
if (*Iter < '0' || *Iter > '9') {
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
+ while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
+ ++Iter;
+ }
if (Iter != Str.end()) return false;
break;
}
diff --git a/engines/sword25/kernel/window.cpp b/engines/sword25/kernel/window.cpp
index ecafcfa829..b4936e8afc 100644
--- a/engines/sword25/kernel/window.cpp
+++ b/engines/sword25/kernel/window.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -42,7 +42,7 @@ namespace Sword25 {
// Erstellt ein Fenster des GUI des aktuellen Betriebssystems
BS_Window *BS_Window::CreateBSWindow(int X, int Y, int Width, int Height, bool Visible) {
// Fenster erstellen
- BS_Window *pWindow = (BS_Window*) new BS_ScummVMWindow(X, Y, Width, Height, Visible);
+ BS_Window *pWindow = (BS_Window *) new BS_ScummVMWindow(X, Y, Width, Height, Visible);
// Falls das Fenster erfolgreich initialisiert wurde, wird ein Pointer auf das Fensterobjekt
// zurückgegeben
@@ -54,7 +54,7 @@ BS_Window *BS_Window::CreateBSWindow(int X, int Y, int Width, int Height, bool V
return NULL;
}
-// Gibt True zurück wenn das Fenster WM_CLOSE empfangen hat -
+// Gibt True zurück wenn das Fenster WM_CLOSE empfangen hat -
// solange, bis RejectClose() aufgerufen wurde.
bool BS_Window::CloseWanted() {
bool result = _CloseWanted;
diff --git a/engines/sword25/kernel/window.h b/engines/sword25/kernel/window.h
index 18b3930dca..ae8709f157 100644
--- a/engines/sword25/kernel/window.h
+++ b/engines/sword25/kernel/window.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -63,7 +63,7 @@ protected:
bool _CloseWanted;
public:
- virtual ~BS_Window(){};
+ virtual ~BS_Window() {};
/**
* Returns the visibility of the window.
@@ -72,7 +72,7 @@ public:
/**
* Sets the visibility of the window
- * @param Visible Specifies whether the window should be visible or hidden
+ * @param Visible Specifies whether the window should be visible or hidden
*/
virtual void SetVisible(bool Visible) = 0;
/**
@@ -81,7 +81,7 @@ public:
virtual int GetX() = 0;
/**
* Sets the X position of the window
- * @paramX The new X position for the window, or -1 for centre aligned
+ * @paramX The new X position for the window, or -1 for centre aligned
*/
virtual void SetX(int X) = 0;
/**
@@ -90,7 +90,7 @@ public:
virtual int GetY() = 0;
/**
* Sets the Y position of the window
- * @param Y The new Y position for the window, or -1 for centre aligned
+ * @param Y The new Y position for the window, or -1 for centre aligned
*/
virtual void SetY(int X) = 0;
/**
@@ -123,7 +123,7 @@ public:
virtual Common::String GetTitle() = 0;
/**
* Sets the title of the window
- * @param Title The new window title
+ * @param Title The new window title
*/
virtual void SetTitle(const Common::String &Title) = 0;
/**
@@ -135,7 +135,7 @@ public:
* Pauses the applicaiton until the window has focus, or has been closed.
* Returns false if the window was closed.
*/
- virtual bool WaitForFocus() = 0;
+ virtual bool WaitForFocus() = 0;
/**
* Returns true if the window has focus, false otherwise.
*/
@@ -152,9 +152,9 @@ public:
* Specifies whether the window is wanted to be closed. This is used together with CloseWanted()
* to allow scripts to query when the main window should be closed, or the user is asking it to close
**/
- void SetCloseWanted(bool Wanted);
+ void SetCloseWanted(bool Wanted);
/**
- * Returns the previous value set in a call to SetCloseWanted.
+ * Returns the previous value set in a call to SetCloseWanted.
* Note that calling this also resets the value back to false, until such time as the SetCloseWanted()
* method is called again.
**/
@@ -163,11 +163,11 @@ public:
/**
* Creates a new window instance. Returns a pointer to the window, or NULL if the creation failed.
* Note: It is the responsibility of the client to free the pointer when done with it.
- * @param X The X position of the window, or -1 for centre horizontal alignment
- * @param Y The Y position of the window, or -1 for centre vertical alignment
- * @param Width The width of the window without the frame
- * @param Height The height of the window without the frame
- * @param Visible Specifies whether window should be visible
+ * @param X The X position of the window, or -1 for centre horizontal alignment
+ * @param Y The Y position of the window, or -1 for centre vertical alignment
+ * @param Width The width of the window without the frame
+ * @param Height The height of the window without the frame
+ * @param Visible Specifies whether window should be visible
*/
static BS_Window *CreateBSWindow(int X, int Y, int Width, int Height, bool Visible);
};
diff --git a/engines/sword25/math/geometry.cpp b/engines/sword25/math/geometry.cpp
index f6cab4ed80..de65017c32 100644
--- a/engines/sword25/math/geometry.cpp
+++ b/engines/sword25/math/geometry.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/math/geometry.h b/engines/sword25/math/geometry.h
index 20c7eb4b54..2ea02c8f35 100644
--- a/engines/sword25/math/geometry.h
+++ b/engines/sword25/math/geometry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp
index aaf4c4d604..ccc73d290a 100644
--- a/engines/sword25/math/geometry_script.cpp
+++ b/engines/sword25/math/geometry_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -67,11 +67,9 @@ namespace Sword25 {
static void *my_checkudata(lua_State *L, int ud, const char *tname) {
int top = lua_gettop(L);
- void * p = lua_touserdata(L, ud);
- if (p != NULL) /* value is a userdata? */
- {
- if (lua_getmetatable(L, ud)) /* does it have a metatable? */
- {
+ void *p = lua_touserdata(L, ud);
+ if (p != NULL) { /* value is a userdata? */
+ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
BS_LuaBindhelper::GetMetatable(L, tname);
/* does it have the correct mt? */
@@ -89,7 +87,7 @@ static void *my_checkudata(lua_State *L, int ud, const char *tname) {
// -----------------------------------------------------------------------------
static void NewUintUserData(lua_State *L, unsigned int Value) {
- void * UserData = lua_newuserdata(L, sizeof(Value));
+ void *UserData = lua_newuserdata(L, sizeof(Value));
memcpy(UserData, &Value, sizeof(Value));
}
@@ -157,8 +155,7 @@ static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
Vertecies.reserve(VertexCount);
// Create Vertecies
- for (int i = 0; i < VertexCount; i++)
- {
+ for (int i = 0; i < VertexCount; i++) {
// X Value
lua_rawgeti(L, -1, (i * 2) + 1);
int X = static_cast<int>(lua_tonumber(L, -1));
@@ -220,43 +217,43 @@ static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
int FirstElementType = lua_type(L, -1);
lua_pop(L, 1);
- switch(FirstElementType) {
- case LUA_TNUMBER: {
- BS_Polygon Polygon;
- TablePolygonToPolygon(L, Polygon);
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
- }
- break;
-
- case LUA_TTABLE: {
- lua_rawgeti(L, -1, 1);
- BS_Polygon Polygon;
- TablePolygonToPolygon(L, Polygon);
- lua_pop(L, 1);
+ switch (FirstElementType) {
+ case LUA_TNUMBER: {
+ BS_Polygon Polygon;
+ TablePolygonToPolygon(L, Polygon);
+ BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
+ }
+ break;
- int PolygonCount = luaL_getn(L, -1);
- if (PolygonCount == 1)
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
- else {
- Common::Array<BS_Polygon> Holes;
- Holes.reserve(PolygonCount - 1);
-
- for (int i = 2; i <= PolygonCount; i++) {
- lua_rawgeti(L, -1, i);
- Holes.resize(Holes.size() + 1);
- TablePolygonToPolygon(L, Holes.back());
- lua_pop(L, 1);
- }
- BS_ASSERT((int)Holes.size() == PolygonCount - 1);
-
- BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon, &Holes);
- }
+ case LUA_TTABLE: {
+ lua_rawgeti(L, -1, 1);
+ BS_Polygon Polygon;
+ TablePolygonToPolygon(L, Polygon);
+ lua_pop(L, 1);
+
+ int PolygonCount = luaL_getn(L, -1);
+ if (PolygonCount == 1)
+ BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon);
+ else {
+ Common::Array<BS_Polygon> Holes;
+ Holes.reserve(PolygonCount - 1);
+
+ for (int i = 2; i <= PolygonCount; i++) {
+ lua_rawgeti(L, -1, i);
+ Holes.resize(Holes.size() + 1);
+ TablePolygonToPolygon(L, Holes.back());
+ lua_pop(L, 1);
}
- break;
+ BS_ASSERT((int)Holes.size() == PolygonCount - 1);
- default:
- luaL_error(L, "Illegal region definition.");
- return 0;
+ BS_RegionRegistry::GetInstance().ResolveHandle(RegionHandle)->Init(Polygon, &Holes);
+ }
+ }
+ break;
+
+ default:
+ luaL_error(L, "Illegal region definition.");
+ return 0;
}
#ifdef DEBUG
@@ -268,8 +265,7 @@ static unsigned int TableRegionToRegion(lua_State *L, const char *ClassName) {
// -----------------------------------------------------------------------------
-static void NewUserdataRegion(lua_State *L, const char *ClassName)
-{
+static void NewUserdataRegion(lua_State *L, const char *ClassName) {
// Region due to the Lua code to create
// Any errors that occur will be intercepted to the luaL_error
unsigned int RegionHandle = TableRegionToRegion(L, ClassName);
@@ -308,11 +304,11 @@ static const luaL_reg GEO_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
-static BS_Region * CheckRegion(lua_State *L) {
+static BS_Region *CheckRegion(lua_State *L) {
// The first parameter must be of type 'userdata', and the Metatable class Geo.Region or Geo.WalkRegion
unsigned int *RegionHandlePtr;
if ((RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, REGION_CLASS_NAME))) != 0 ||
- (RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, WALKREGION_CLASS_NAME))) != 0) {
+ (RegionHandlePtr = reinterpret_cast<unsigned int *>(my_checkudata(L, 1, WALKREGION_CLASS_NAME))) != 0) {
return BS_RegionRegistry::GetInstance().ResolveHandle(*RegionHandlePtr);
} else {
luaL_argcheck(L, 0, 1, "'" REGION_CLASS_NAME "' expected");
@@ -325,7 +321,7 @@ static BS_Region * CheckRegion(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_IsValid(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushbooleancpp(L, pR->IsValid());
@@ -335,7 +331,7 @@ static int R_IsValid(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetX(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushnumber(L, pR->GetPosX());
@@ -345,7 +341,7 @@ static int R_GetX(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetY(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
lua_pushnumber(L, pR->GetPosY());
@@ -355,7 +351,7 @@ static int R_GetY(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetPos(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
BS_Vertex::VertexToLuaVertex(L, pR->GetPosition());
@@ -365,7 +361,7 @@ static int R_GetPos(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_IsPointInRegion(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
BS_Vertex Vertex;
@@ -377,7 +373,7 @@ static int R_IsPointInRegion(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetPos(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
BS_Vertex Vertex;
@@ -390,7 +386,7 @@ static int R_SetPos(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetX(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
pR->SetPosX(static_cast<int>(luaL_checknumber(L, 2)));
@@ -401,7 +397,7 @@ static int R_SetX(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_SetY(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
pR->SetPosY(static_cast<int>(luaL_checknumber(L, 2)));
@@ -432,24 +428,24 @@ static void DrawRegion(const BS_Region &Region, unsigned int Color, const BS_Ver
// -----------------------------------------------------------------------------
static int R_Draw(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
switch (lua_gettop(L)) {
- case 3: {
- BS_Vertex Offset;
- BS_Vertex::LuaVertexToVertex(L, 3, Offset);
- DrawRegion(*pR, BS_GraphicEngine::LuaColorToARGBColor(L, 2), Offset);
- }
- break;
+ case 3: {
+ BS_Vertex Offset;
+ BS_Vertex::LuaVertexToVertex(L, 3, Offset);
+ DrawRegion(*pR, BS_GraphicEngine::LuaColorToARGBColor(L, 2), Offset);
+ }
+ break;
- case 2:
- DrawRegion(*pR, BS_GraphicEngine::LuaColorToARGBColor(L, 2), BS_Vertex(0, 0));
- break;
+ case 2:
+ DrawRegion(*pR, BS_GraphicEngine::LuaColorToARGBColor(L, 2), BS_Vertex(0, 0));
+ break;
- default:
- DrawRegion(*pR, BS_RGB(255, 255, 255), BS_Vertex(0, 0));
- }
+ default:
+ DrawRegion(*pR, BS_RGB(255, 255, 255), BS_Vertex(0, 0));
+ }
return 0;
}
@@ -457,7 +453,7 @@ static int R_Draw(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_GetCentroid(lua_State *L) {
- BS_Region * RPtr = CheckRegion(L);
+ BS_Region *RPtr = CheckRegion(L);
BS_ASSERT(RPtr);
BS_Vertex::VertexToLuaVertex(L, RPtr->GetCentroid());
@@ -468,7 +464,7 @@ static int R_GetCentroid(lua_State *L) {
// -----------------------------------------------------------------------------
static int R_Delete(lua_State *L) {
- BS_Region * pR = CheckRegion(L);
+ BS_Region *pR = CheckRegion(L);
BS_ASSERT(pR);
delete pR;
return 0;
@@ -540,9 +536,9 @@ static const luaL_reg WALKREGION_METHODS[] = {
// -----------------------------------------------------------------------------
bool BS_Geometry::_RegisterScriptBindings() {
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
lua_State *L = static_cast< lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
diff --git a/engines/sword25/math/line.h b/engines/sword25/math/line.h
index 86bcbd6537..5e442045f1 100644
--- a/engines/sword25/math/line.h
+++ b/engines/sword25/math/line.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,15 +33,15 @@
*/
/*
- BS_Line
- -------
- This class contains only static methods, which have to do with straight line
- segments. There is no real straight line segment class. Calculations will be
- used with polygons, and it is important the process of starting and selecting
- endpoints of lines is dynamic. This would prhobit a polygon from a set
- being formed by fixed line segments
-
- Autor: Malte Thiesen
+ BS_Line
+ -------
+ This class contains only static methods, which have to do with straight line
+ segments. There is no real straight line segment class. Calculations will be
+ used with polygons, and it is important the process of starting and selecting
+ endpoints of lines is dynamic. This would prhobit a polygon from a set
+ being formed by fixed line segments
+
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_LINE_H
@@ -61,10 +61,10 @@ class BS_Line {
public:
/**
* Determines whether a piont is left of a line
- * @param a The start point of a line
- * @param b The end point of a line
- * @param c The test point
- * @return Returns true if the point is to the left of the line.
+ * @param a The start point of a line
+ * @param b The end point of a line
+ * @param c The test point
+ * @return Returns true if the point is to the left of the line.
* If the point is to the right of the line or on the line, false is returned.
*/
static bool IsVertexLeft(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
@@ -77,10 +77,10 @@ public:
/**
* Determines whether a piont is right of a line
- * @param a The start point of a line
- * @param b The end point of a line
- * @param c The test point
- * @return Returns true if the point is to the right of the line.
+ * @param a The start point of a line
+ * @param b The end point of a line
+ * @param c The test point
+ * @return Returns true if the point is to the right of the line.
* If the point is to the right of the line or on the line, false is returned.
*/
static bool IsVertexRight(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
@@ -93,10 +93,10 @@ public:
/**
* Determines whether a piont is on a line
- * @param a The start point of a line
- * @param b The end point of a line
- * @param c The test point
- * @return Returns true if the point is on the line, false otherwise.
+ * @param a The start point of a line
+ * @param b The end point of a line
+ * @param c The test point
+ * @return Returns true if the point is on the line, false otherwise.
*/
static bool IsVertexOn(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
return _TriangleArea2(a, b, c) == 0;
@@ -110,10 +110,10 @@ public:
/**
* Determines where a point is relative to a line.
- * @param a The start point of a line
- * @param b The end point of a line
- * @param c The test point
- * @return LEFT is returned if the point is to the left of the line.
+ * @param a The start point of a line
+ * @param b The end point of a line
+ * @param c The test point
+ * @return LEFT is returned if the point is to the left of the line.
* RIGHT is returned if the point is to the right of the line.
* ON is returned if the point is on the line.
*/
@@ -126,11 +126,11 @@ public:
/**
* Determines whether two lines intersect
- * @param a The start point of the first line
- * @param b The end point of the first line
- * @param c The start point of the second line
- * @param d The end point of the second line
- * @remark In cases where a line only touches the other, false is returned (improper intersection)
+ * @param a The start point of the first line
+ * @param b The end point of the first line
+ * @param c The start point of the second line
+ * @param d The end point of the second line
+ * @remark In cases where a line only touches the other, false is returned (improper intersection)
*/
static bool DoesIntersectProperly(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c, const BS_Vertex &d) {
VERTEX_CLASSIFICATION Class1 = ClassifyVertexToLine(a, b, c);
@@ -140,14 +140,14 @@ public:
if (Class1 == ON || Class2 == ON || Class3 == ON || Class4 == ON) return false;
- return ((Class1 == LEFT) ^ (Class2 == LEFT)) && ((Class3 == LEFT) ^ (Class4 == LEFT));
+ return ((Class1 == LEFT) ^(Class2 == LEFT)) && ((Class3 == LEFT) ^(Class4 == LEFT));
}
/**
* Determines whether a point is on a line segment
- * @param a The start point of a line
- * @param b The end point of a line
- * @param c The test point
+ * @param a The start point of a line
+ * @param b The end point of a line
+ * @param c The test point
*/
static bool IsOnLine(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
// The items must all be Collinear, otherwise don't bothering testing the point
@@ -156,14 +156,14 @@ public:
// If the line segment is not vertical, check on the x-axis, otherwise the y-axis
if (a.X != b.X) {
return ((a.X <= c.X) &&
- (c.X <= b.X)) ||
- ((a.X >= c.X) &&
- (c.X >= b.X));
+ (c.X <= b.X)) ||
+ ((a.X >= c.X) &&
+ (c.X >= b.X));
} else {
return ((a.Y <= c.Y) &&
- (c.Y <= b.Y)) ||
- ((a.Y >= c.Y) &&
- (c.Y >= b.Y));
+ (c.Y <= b.Y)) ||
+ ((a.Y >= c.Y) &&
+ (c.Y >= b.Y));
}
}
@@ -174,14 +174,14 @@ public:
// If the line segment is not vertical, check on the x-axis, otherwise the y-axis
if (a.X != b.X) {
return ((a.X < c.X) &&
- (c.X < b.X)) ||
- ((a.X > c.X) &&
- (c.X > b.X));
+ (c.X < b.X)) ||
+ ((a.X > c.X) &&
+ (c.X > b.X));
} else {
return ((a.Y < c.Y) &&
- (c.Y < b.Y)) ||
- ((a.Y > c.Y) &&
- (c.Y > b.Y));
+ (c.Y < b.Y)) ||
+ ((a.Y > c.Y) &&
+ (c.Y > b.Y));
}
}
@@ -189,13 +189,13 @@ private:
/**
* Return double the size of the triangle defined by the three passed points.
*
- * The result is positive if the points are arrange counterclockwise,
+ * The result is positive if the points are arrange counterclockwise,
* and negative if they are arranged counter-clockwise.
*/
static int _TriangleArea2(const BS_Vertex &a, const BS_Vertex &b, const BS_Vertex &c) {
return a.X * b.Y - a.Y * b.X +
- a.Y * c.X - a.X * c.Y +
- b.X * c.Y - c.X * b.Y;
+ a.Y * c.X - a.X * c.Y +
+ b.X * c.Y - c.X * b.Y;
}
};
diff --git a/engines/sword25/math/polygon.cpp b/engines/sword25/math/polygon.cpp
index 6d416ea080..a972596d29 100644
--- a/engines/sword25/math/polygon.cpp
+++ b/engines/sword25/math/polygon.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,7 +50,7 @@ namespace Sword25 {
BS_Polygon::BS_Polygon() : VertexCount(0), Vertecies(NULL) {
}
-BS_Polygon::BS_Polygon(int VertexCount, const BS_Vertex *Vertecies) : VertexCount(0), Vertecies(NULL) {
+BS_Polygon::BS_Polygon(int VertexCount, const BS_Vertex *Vertecies) : VertexCount(0), Vertecies(NULL) {
Init(VertexCount, Vertecies);
}
@@ -142,7 +142,7 @@ int BS_Polygon::FindLRVertexIndex() const {
for (int i = 1; i < VertexCount; i++) {
if (Vertecies[i].Y > MaxY ||
- (Vertecies[i].Y == MaxY && Vertecies[i].X > MaxX)) {
+ (Vertecies[i].Y == MaxY && Vertecies[i].X > MaxX)) {
MaxX = Vertecies[i].X;
MaxY = Vertecies[i].Y;
CurIndex = i;
@@ -151,7 +151,7 @@ int BS_Polygon::FindLRVertexIndex() const {
return CurIndex;
}
-
+
return -1;
}
@@ -231,7 +231,7 @@ void BS_Polygon::ReverseVertexOrder() {
int BS_Polygon::CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const {
return (V2.X - V1.X) * (V3.Y - V2.Y) -
- (V2.Y - V1.Y) * (V3.X - V2.X);
+ (V2.Y - V1.Y) * (V3.X - V2.X);
}
// Scalar Product
@@ -239,7 +239,7 @@ int BS_Polygon::CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_
int BS_Polygon::DotProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const {
return (V1.X - V2.X) * (V3.X - V2.X) +
- (V1.Y - V2.Y) * (V3.X - V2.Y);
+ (V1.Y - V2.Y) * (V3.X - V2.Y);
}
// Check for self-intersections
@@ -250,22 +250,22 @@ bool BS_Polygon::CheckForSelfIntersection() const {
/*
float AngleSum = 0.0f;
for (int i = 0; i < VertexCount; i++) {
- int j = (i + 1) % VertexCount;
- int k = (i + 2) % VertexCount;
-
- float Dot = DotProduct(Vertecies[i], Vertecies[j], Vertecies[k]);
-
- // Skalarproduct normalisieren
- float Length1 = sqrt((Vertecies[i].X - Vertecies[j].X) * (Vertecies[i].X - Vertecies[j].X) +
- (Vertecies[i].Y - Vertecies[j].Y) * (Vertecies[i].Y - Vertecies[j].Y));
- float Length2 = sqrt((Vertecies[k].X - Vertecies[j].X) * (Vertecies[k].X - Vertecies[j].X) +
- (Vertecies[k].Y - Vertecies[j].Y) * (Vertecies[k].Y - Vertecies[j].Y));
- float Norm = Length1 * Length2;
-
- if (Norm > 0.0f) {
- Dot /= Norm;
- AngleSum += acos(Dot);
- }
+ int j = (i + 1) % VertexCount;
+ int k = (i + 2) % VertexCount;
+
+ float Dot = DotProduct(Vertecies[i], Vertecies[j], Vertecies[k]);
+
+ // Skalarproduct normalisieren
+ float Length1 = sqrt((Vertecies[i].X - Vertecies[j].X) * (Vertecies[i].X - Vertecies[j].X) +
+ (Vertecies[i].Y - Vertecies[j].Y) * (Vertecies[i].Y - Vertecies[j].Y));
+ float Length2 = sqrt((Vertecies[k].X - Vertecies[j].X) * (Vertecies[k].X - Vertecies[j].X) +
+ (Vertecies[k].Y - Vertecies[j].Y) * (Vertecies[k].Y - Vertecies[j].Y));
+ float Norm = Length1 * Length2;
+
+ if (Norm > 0.0f) {
+ Dot /= Norm;
+ AngleSum += acos(Dot);
+ }
}
*/
@@ -299,7 +299,7 @@ bool BS_Polygon::IsLineInterior(const BS_Vertex &a, const BS_Vertex &b) const {
int j = (i + 1) % VertexCount;
const BS_Vertex &VS = Vertecies[i];
const BS_Vertex &VE = Vertecies[j];
-
+
// If the line intersects a line segment strictly (proper cross section) the line is not in the polygon
if (BS_Line::DoesIntersectProperly(a, b, VS, VE)) return false;
@@ -360,17 +360,17 @@ bool BS_Polygon::IsLineInCone(int StartVertexIndex, const BS_Vertex &EndVertex,
if (BS_Line::IsVertexLeftOn(PrevVertex, StartVertex, NextVertex)) {
if (IncludeEdges)
return BS_Line::IsVertexLeftOn(EndVertex, StartVertex, NextVertex) &&
- BS_Line::IsVertexLeftOn(StartVertex, EndVertex, PrevVertex);
+ BS_Line::IsVertexLeftOn(StartVertex, EndVertex, PrevVertex);
else
return BS_Line::IsVertexLeft(EndVertex, StartVertex, NextVertex) &&
- BS_Line::IsVertexLeft(StartVertex, EndVertex, PrevVertex);
+ BS_Line::IsVertexLeft(StartVertex, EndVertex, PrevVertex);
} else {
if (IncludeEdges)
return !(BS_Line::IsVertexLeft(EndVertex, StartVertex, PrevVertex) &&
- BS_Line::IsVertexLeft(StartVertex, EndVertex, NextVertex));
+ BS_Line::IsVertexLeft(StartVertex, EndVertex, NextVertex));
else
return !(BS_Line::IsVertexLeftOn(EndVertex, StartVertex, PrevVertex) &&
- BS_Line::IsVertexLeftOn(StartVertex, EndVertex, NextVertex));
+ BS_Line::IsVertexLeftOn(StartVertex, EndVertex, NextVertex));
}
}
@@ -399,15 +399,15 @@ bool BS_Polygon::IsPointInPolygon(const BS_Vertex &Point, bool EdgesBelongToPoly
if ((Term1 > 0) == (Term2 >= 0)) Rcross++;
}
- if ((EdgeStart.Y < Point.Y) != (EdgeEnd.Y < Point.Y)) {
+ if ((EdgeStart.Y < Point.Y) != (EdgeEnd.Y < Point.Y)) {
int Term1 = (EdgeStart.X - Point.X) * (EdgeEnd.Y - Point.Y) - (EdgeEnd.X - Point.X) * (EdgeStart.Y - Point.Y);
int Term2 = (EdgeEnd.Y - Point.Y) - (EdgeStart.Y - EdgeEnd.Y);
if ((Term1 < 0) == (Term2 <= 0)) Lcross++;
}
- }
+ }
// The point is on an adge, if the number of left and right intersections have the same even numbers
- if ((Rcross % 2 ) != (Lcross % 2 )) return EdgesBelongToPolygon;
+ if ((Rcross % 2) != (Lcross % 2)) return EdgesBelongToPolygon;
// The point is strictly inside the polygon if and only if the number of overlaps is odd
if ((Rcross % 2) == 1) return true;
diff --git a/engines/sword25/math/polygon.h b/engines/sword25/math/polygon.h
index d435c9746b..1621efb645 100644
--- a/engines/sword25/math/polygon.h
+++ b/engines/sword25/math/polygon.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,7 +49,7 @@ namespace Sword25 {
class BS_Vertex;
/**
- @brief Eine Polygonklasse.
+ @brief Eine Polygonklasse.
*/
class BS_Polygon : public BS_Persistable {
public:
@@ -72,9 +72,9 @@ public:
/**
* Creaes an object of type #BS_Polygon, and assigns Vertices to it
- * @param VertexCount The number of vertices being passed
- * @param Vertecies An array of BS_Vertex objects representing the vertices in the polygon.
- * @remark The Vertecies that define a polygon must not have any self-intersections.
+ * @param VertexCount The number of vertices being passed
+ * @param Vertecies An array of BS_Vertex objects representing the vertices in the polygon.
+ * @remark The Vertecies that define a polygon must not have any self-intersections.
* If the polygon does have self-intersections, then an empty polygon object is created.
*/
BS_Polygon(int VertexCount, const BS_Vertex *Vertecies);
@@ -90,9 +90,9 @@ public:
* The Vertices need to define a polygon must not have self-intersections.
* If a polygon already has verticies, this will re-initialise it with the new list.
*
- * @param VertexCount The number of vertices being passed
- * @param Vertecies An array of BS_Vertex objects representing the vertices in the polygon.
- * @return Returns false if the Vertecies have self-intersections. In this case,
+ * @param VertexCount The number of vertices being passed
+ * @param Vertecies An array of BS_Vertex objects representing the vertices in the polygon.
+ * @return Returns false if the Vertecies have self-intersections. In this case,
* the object is not initialised.
*/
bool Init(int VertexCount, const BS_Vertex *Vertecies);
@@ -100,51 +100,51 @@ public:
//
// ** Exploratory methods **
//
-
+
/**
* Checks whether the Vertecies of the polygon are arranged in a clockwise direction.
- * @return Returns true if the Vertecies of the polygon are arranged clockwise or co-planar.
+ * @return Returns true if the Vertecies of the polygon are arranged clockwise or co-planar.
* Returns false if the Vertecies of the polygon are arrange counter-clockwise.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
+ * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
*/
bool IsCW() const;
/**
* Checks whether the Vertices of the polygon are arranged in a counter-clockwise direction.
- * @return Returns true if the Vertecies of the polygon are arranged counter-clockwise.
+ * @return Returns true if the Vertecies of the polygon are arranged counter-clockwise.
* Returns false if the Vertecies of the polygon are arranged clockwise or co-planar.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
+ * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
*/
bool IsCCW() const;
/**
* Checks whether the polygon is convex.
- * @return Returns true if the polygon is convex. Returns false if the polygon is concave.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
+ * @return Returns true if the polygon is convex. Returns false if the polygon is concave.
+ * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
*/
bool IsConvex() const;
- /**
+ /**
* Checks whether the polygon is concave.
- * @return Returns true if the polygon is concave. Returns false if the polygon is convex.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
+ * @return Returns true if the polygon is concave. Returns false if the polygon is convex.
+ * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
*/
bool IsConcave() const;
/**
* Checks whether a point is inside the polygon
- * @param Vertex A Vertex with the co-ordinates of the point to be tested.
- * @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
- * @return Returns true if the point is inside the polygon, false if it is outside.
+ * @param Vertex A Vertex with the co-ordinates of the point to be tested.
+ * @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
+ * @return Returns true if the point is inside the polygon, false if it is outside.
*/
bool IsPointInPolygon(const BS_Vertex &Vertex, bool BorderBelongsToPolygon = true) const;
/**
* Checks whether a point is inside the polygon
- * @param X The X position of the point
- * @param Y The Y position of the point
- * @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
- * @return Returns true if the point is inside the polygon, false if it is outside.
+ * @param X The X position of the point
+ * @param Y The Y position of the point
+ * @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
+ * @return Returns true if the point is inside the polygon, false if it is outside.
*/
bool IsPointInPolygon(int X, int Y, bool BorderBelongsToPolygon = true) const;
@@ -181,7 +181,7 @@ public:
/**
* Moves the polygon.
- * @param Delta The vertex around the polygon to be moved.
+ * @param Delta The vertex around the polygon to be moved.
*/
void operator+=(const BS_Vertex &Delta);
@@ -201,7 +201,7 @@ private:
bool m_IsCW;
bool m_IsConvex;
BS_Vertex m_Centroid;
-
+
/**
* Computes the centroid of the polygon.
*/
@@ -209,24 +209,24 @@ private:
/**
* Determines how the Vertecies of the polygon are arranged.
- * @return Returns true if the Vertecies are arranged in a clockwise
+ * @return Returns true if the Vertecies are arranged in a clockwise
* direction, otherwise false.
*/
bool ComputeIsCW() const;
/**
* Determines whether the polygon is convex or concave.
- * @return Returns true if the polygon is convex, otherwise false.
+ * @return Returns true if the polygon is convex, otherwise false.
*/
bool ComputeIsConvex() const;
/**
* Calculates the cross product of three Vertecies
- * @param V1 The first Vertex
- * @param V2 The second Vertex
- * @param V3 The third Vertex
- * @return Returns the cross-product of the three vertecies
- * @todo This method would be better as a method of the BS_Vertex class
+ * @param V1 The first Vertex
+ * @param V2 The second Vertex
+ * @param V3 The third Vertex
+ * @return Returns the cross-product of the three vertecies
+ * @todo This method would be better as a method of the BS_Vertex class
*/
int CrossProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const;
@@ -235,17 +235,17 @@ private:
*
* The vectors are spanned by V2->V1 and V2->V3
*
- * @param V1 The first Vertex
- * @param V2 The second Vertex
- * @param V3 The third Vertex
- * @return Returns the dot product of the three Vertecies.
- * @todo This method would be better as a method of the BS_Vertex class
+ * @param V1 The first Vertex
+ * @param V2 The second Vertex
+ * @param V3 The third Vertex
+ * @return Returns the dot product of the three Vertecies.
+ * @todo This method would be better as a method of the BS_Vertex class
*/
int DotProduct(const BS_Vertex &V1, const BS_Vertex &V2, const BS_Vertex &V3) const;
/**
* Checks whether the polygon is self-intersecting
- * @return Returns true if the polygon is self-intersecting.
+ * @return Returns true if the polygon is self-intersecting.
* Returns false if the polygon is not self-intersecting.
*/
bool CheckForSelfIntersection() const;
@@ -253,7 +253,7 @@ private:
/**
* Find the vertex of the polygon that is located below the right-most point,
* and returns it's index in the vertex array.
- * @return Returns the index of the vertex at the bottom-right of the polygon.
+ * @return Returns the index of the vertex at the bottom-right of the polygon.
* Returns -1 if the vertex list is empty.
*/
int FindLRVertexIndex() const;
diff --git a/engines/sword25/math/rect.h b/engines/sword25/math/rect.h
index c2a42e85c4..e97feefe41 100644
--- a/engines/sword25/math/rect.h
+++ b/engines/sword25/math/rect.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,9 +54,13 @@ public:
BS_Rect(int16 w, int16 h) : Common::Rect(w, h) {}
BS_Rect(int16 x1, int16 y1, int16 x2, int16 y2) : Common::Rect(x1, y1, x2, y2) {}
- void Move(int DeltaX, int DeltaY) { translate(DeltaX, DeltaY); }
+ void Move(int DeltaX, int DeltaY) {
+ translate(DeltaX, DeltaY);
+ }
- bool DoesIntersect(const BS_Rect &Rect_) const { return intersects(Rect_); }
+ bool DoesIntersect(const BS_Rect &Rect_) const {
+ return intersects(Rect_);
+ }
bool Intersect(const BS_Rect &Rect_, BS_Rect &Result) const {
Result = Rect_;
@@ -70,23 +74,41 @@ public:
Result.extend(*this);
}
- int GetWidth() const { return width(); }
+ int GetWidth() const {
+ return width();
+ }
- int GetHeight() const { return height(); }
+ int GetHeight() const {
+ return height();
+ }
- int GetArea() const { return width() * height(); }
+ int GetArea() const {
+ return width() * height();
+ }
- bool operator==(const BS_Rect &rhs) const { return equals(rhs); }
+ bool operator==(const BS_Rect &rhs) const {
+ return equals(rhs);
+ }
- bool operator!= (const BS_Rect &rhs) const { return !equals(rhs); }
+ bool operator!= (const BS_Rect &rhs) const {
+ return !equals(rhs);
+ }
- bool IsValid() const { return isValidRect(); }
+ bool IsValid() const {
+ return isValidRect();
+ }
- bool IsPointInRect(const BS_Vertex &Vertex) const { return contains(Vertex.X, Vertex.Y); }
+ bool IsPointInRect(const BS_Vertex &Vertex) const {
+ return contains(Vertex.X, Vertex.Y);
+ }
- bool IsPointInRect(int X, int Y) const { return contains(X, Y); }
+ bool IsPointInRect(int X, int Y) const {
+ return contains(X, Y);
+ }
- bool ContainsRect(const BS_Rect &OtherRect) const { return contains(OtherRect); }
+ bool ContainsRect(const BS_Rect &OtherRect) const {
+ return contains(OtherRect);
+ }
};
} // End of namespace Sword25
diff --git a/engines/sword25/math/region.cpp b/engines/sword25/math/region.cpp
index bab5381990..b967d001c5 100644
--- a/engines/sword25/math/region.cpp
+++ b/engines/sword25/math/region.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -60,18 +60,18 @@ BS_Region::BS_Region(BS_InputPersistenceBlock &Reader, unsigned int Handle) : m_
// -----------------------------------------------------------------------------
unsigned int BS_Region::Create(REGION_TYPE Type) {
- BS_Region * RegionPtr = NULL;
+ BS_Region *RegionPtr = NULL;
switch (Type) {
- case RT_REGION:
- RegionPtr = new BS_Region();
- break;
+ case RT_REGION:
+ RegionPtr = new BS_Region();
+ break;
- case RT_WALKREGION:
- RegionPtr = new BS_WalkRegion();
- break;
+ case RT_WALKREGION:
+ RegionPtr = new BS_WalkRegion();
+ break;
- default:
- BS_ASSERT(true);
+ default:
+ BS_ASSERT(true);
}
return BS_RegionRegistry::GetInstance().ResolvePtr(RegionPtr);
@@ -79,7 +79,7 @@ unsigned int BS_Region::Create(REGION_TYPE Type) {
// -----------------------------------------------------------------------------
-unsigned int BS_Region::Create(BS_InputPersistenceBlock & Reader, unsigned int Handle) {
+unsigned int BS_Region::Create(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
// Read type
unsigned int Type;
Reader.Read(Type);
@@ -105,7 +105,7 @@ BS_Region::~BS_Region() {
// -----------------------------------------------------------------------------
-bool BS_Region::Init(const BS_Polygon& Contour, const Common::Array<BS_Polygon> *pHoles) {
+bool BS_Region::Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles) {
// Reset object state
m_Valid = false;
m_Position = BS_Vertex(0, 0);
@@ -125,7 +125,7 @@ bool BS_Region::Init(const BS_Polygon& Contour, const Common::Array<BS_Polygon>
// Place the hole polygons in the following positions
if (pHoles) {
- for (unsigned int i = 0; i< pHoles->size(); ++i) {
+ for (unsigned int i = 0; i < pHoles->size(); ++i) {
m_Polygons.push_back(BS_Polygon());
m_Polygons[i + 1].Init((*pHoles)[i].VertexCount, (*pHoles)[i].Vertecies);
m_Polygons[i + 1].EnsureCWOrder();
@@ -201,7 +201,7 @@ bool BS_Region::IsPointInRegion(int X, int Y) const {
if (m_Polygons[0].IsPointInPolygon(X, Y, true)) {
// Test whether the point is in a hole
for (unsigned int i = 1; i < m_Polygons.size(); i++) {
- if (m_Polygons[i].IsPointInPolygon(X,Y, false))
+ if (m_Polygons[i].IsPointInPolygon(X, Y, false))
return false;
}
@@ -233,7 +233,7 @@ BS_Vertex BS_Region::FindClosestRegionPoint(const BS_Vertex &Point) const {
}
}
- const BS_Polygon & Polygon = m_Polygons[PolygonIdx];
+ const BS_Polygon &Polygon = m_Polygons[PolygonIdx];
BS_ASSERT(Polygon.VertexCount > 1);
@@ -303,8 +303,8 @@ BS_Vertex BS_Region::FindClosestPointOnLine(const BS_Vertex &LineStart, const BS
float Vector2Length = sqrtf(Vector2X * Vector2X + Vector2Y * Vector2Y);
Vector2X /= Vector2Length;
Vector2Y /= Vector2Length;
- float Distance = sqrtf(static_cast<float>((LineStart.X - LineEnd.X) * (LineStart.X - LineEnd.X) +
- (LineStart.Y - LineEnd.Y) * (LineStart.Y - LineEnd.Y)));
+ float Distance = sqrtf(static_cast<float>((LineStart.X - LineEnd.X) * (LineStart.X - LineEnd.X) +
+ (LineStart.Y - LineEnd.Y) * (LineStart.Y - LineEnd.Y)));
float Dot = Vector1X * Vector2X + Vector1Y * Vector2Y;
if (Dot <= 0) return LineStart;
@@ -341,7 +341,7 @@ bool BS_Region::Persist(BS_OutputPersistenceBlock &Writer) {
Writer.Write(m_Valid);
Writer.Write(m_Position.X);
Writer.Write(m_Position.Y);
-
+
Writer.Write(m_Polygons.size());
Common::Array<BS_Polygon>::iterator It = m_Polygons.begin();
while (It != m_Polygons.end()) {
@@ -385,7 +385,7 @@ BS_Vertex BS_Region::GetCentroid() const {
if (m_Polygons.size() > 0)
return m_Polygons[0].GetCentroid();
return
- BS_Vertex();
+ BS_Vertex();
}
} // End of namespace Sword25
diff --git a/engines/sword25/math/region.h b/engines/sword25/math/region.h
index 577da94fac..e3718dd1c9 100644
--- a/engines/sword25/math/region.h
+++ b/engines/sword25/math/region.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -77,11 +77,11 @@ public:
/**
* Initialises a BS_Region object
- * @param Contour A polygon indicating the outline of the region
- * @param pHoles A pointer to an array of polygons representing the hole state in the region.
+ * @param Contour A polygon indicating the outline of the region
+ * @param pHoles A pointer to an array of polygons representing the hole state in the region.
* If the region has no holes, it must be passed as NULL. The default value is NULL.
- * @return Returns true if the initialisation was successful, otherwise false.
- * @remark If the region was already initialised, the old state will be deleted.
+ * @return Returns true if the initialisation was successful, otherwise false.
+ * @remark If the region was already initialised, the old state will be deleted.
*/
virtual bool Init(const BS_Polygon &Contour, const Common::Array<BS_Polygon> *pHoles = NULL);
@@ -91,65 +91,77 @@ public:
/**
* Specifies whether the object is in a valid state
- * @return Returns true if the object is in a valid state, otherwise false.
- * @remark Invalid objects can be made valid by calling Init with a valid state.
+ * @return Returns true if the object is in a valid state, otherwise false.
+ * @remark Invalid objects can be made valid by calling Init with a valid state.
*/
- bool IsValid() const { return m_Valid; }
+ bool IsValid() const {
+ return m_Valid;
+ }
/**
* Returns the position of the region
*/
- const BS_Vertex &GetPosition() const { return m_Position; }
+ const BS_Vertex &GetPosition() const {
+ return m_Position;
+ }
/**
* Returns the X position of the region
*/
- int GetPosX() const { return m_Position.X; }
+ int GetPosX() const {
+ return m_Position.X;
+ }
/**
* Returns the Y position of the region
*/
- int GetPosY() const { return m_Position.Y; }
+ int GetPosY() const {
+ return m_Position.Y;
+ }
/**
* Indicates whether a point is inside the region
- * @param Vertex A verex with the co-ordinates of the test point
- * @return Returns true if the point is within the region, otherwise false.
+ * @param Vertex A verex with the co-ordinates of the test point
+ * @return Returns true if the point is within the region, otherwise false.
*/
bool IsPointInRegion(const BS_Vertex &Vertex) const;
/**
* Indicates whether a point is inside the region
- * @param X The X position
- * @param Y The Y position
- * @return Returns true if the point is within the region, otherwise false.
+ * @param X The X position
+ * @param Y The Y position
+ * @return Returns true if the point is within the region, otherwise false.
*/
bool IsPointInRegion(int X, int Y) const;
/**
* Returns the countour of the region
*/
- const BS_Polygon &GetContour() const { return m_Polygons[0]; }
+ const BS_Polygon &GetContour() const {
+ return m_Polygons[0];
+ }
/**
* Returns the number of polygons in the hole region
*/
- int GetHoleCount() const { return static_cast<int>(m_Polygons.size() - 1); }
+ int GetHoleCount() const {
+ return static_cast<int>(m_Polygons.size() - 1);
+ }
/**
* Returns a specific hole polygon in the region
- * @param i The number of the hole to return.
+ * @param i The number of the hole to return.
* The index must be between 0 and GetHoleCount() - 1.
- * @return Returns the desired hole polygon
+ * @return Returns the desired hole polygon
*/
inline const BS_Polygon &GetHole(unsigned int i) const;
/**
* For a point outside the region, finds the closest point inside the region
- * @param Point The point that is outside the region
- * @return Returns the point within the region which is closest
- * @remark This method does not always work with pixel accuracy.
- * One should not therefore rely on the fact that there is really no point in
+ * @param Point The point that is outside the region
+ * @return Returns the point within the region which is closest
+ * @remark This method does not always work with pixel accuracy.
+ * One should not therefore rely on the fact that there is really no point in
* the region which is closer to the given point.
*/
BS_Vertex FindClosestRegionPoint(const BS_Vertex &Point) const;
@@ -167,20 +179,20 @@ public:
/**
* Sets the position of the region
- * @param X The new X psoition of the region
- * @param Y The new Y psoition of the region
+ * @param X The new X psoition of the region
+ * @param Y The new Y psoition of the region
*/
virtual void SetPos(int X, int Y);
/**
* Sets the X position of the region
- * @param X The new X position of the region
+ * @param X The new X position of the region
*/
void SetPosX(int X);
/**
* Sets the Y position of the region
- * @param Y The new Y position of the region
+ * @param Y The new Y position of the region
*/
void SetPosY(int Y);
@@ -211,10 +223,10 @@ protected:
/**
* Find the point on a line which is closest to another point
- * @param LineStart The start of the line
- * @param LineEnd The end of the line
- * @param Point The point to be compared against
- * @return Returns the point on the line which is cloest to the passed point.
+ * @param LineStart The start of the line
+ * @param LineEnd The end of the line
+ * @param Point The point to be compared against
+ * @return Returns the point on the line which is cloest to the passed point.
*/
BS_Vertex FindClosestPointOnLine(const BS_Vertex &LineStart, const BS_Vertex &LineEnd, const BS_Vertex Point) const;
};
diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp
index f29b92e8b7..b03d1c1152 100644
--- a/engines/sword25/math/regionregistry.cpp
+++ b/engines/sword25/math/regionregistry.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -110,7 +110,7 @@ bool BS_RegionRegistry::Unpersist(BS_InputPersistenceBlock &Reader) {
Reader.Read(RegionCount);
// Restore all the BS_Regions objects
- for (unsigned int i = 0; i < RegionCount; ++i) {
+ for (unsigned int i = 0; i < RegionCount; ++i) {
// Handle read
unsigned int Handle;
Reader.Read(Handle);
diff --git a/engines/sword25/math/regionregistry.h b/engines/sword25/math/regionregistry.h
index 3c4771df5f..9600dbbdc4 100644
--- a/engines/sword25/math/regionregistry.h
+++ b/engines/sword25/math/regionregistry.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -58,7 +58,7 @@ class BS_Region;
class BS_RegionRegistry : public BS_ObjectRegistry<BS_Region>, public BS_Persistable {
public:
- static BS_RegionRegistry & GetInstance() {
+ static BS_RegionRegistry &GetInstance() {
if (!m_InstancePtr.get()) m_InstancePtr = Common::SharedPtr<BS_RegionRegistry>(new BS_RegionRegistry());
return *m_InstancePtr.get();
}
diff --git a/engines/sword25/math/vertex.cpp b/engines/sword25/math/vertex.cpp
index ef49fd8139..575618dbb9 100644
--- a/engines/sword25/math/vertex.cpp
+++ b/engines/sword25/math/vertex.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -38,8 +38,8 @@ namespace Lua {
extern "C"
{
- #include "sword25/util/lua/lua.h"
- #include "sword25/util/lua/lauxlib.h"
+#include "sword25/util/lua/lua.h"
+#include "sword25/util/lua/lauxlib.h"
}
}
@@ -79,7 +79,7 @@ BS_Vertex &BS_Vertex::LuaVertexToVertex(lua_State *L, int StackIndex, BS_Vertex
// -----------------------------------------------------------------------------
-void BS_Vertex::VertexToLuaVertex(lua_State * L, const BS_Vertex &Vertex) {
+void BS_Vertex::VertexToLuaVertex(lua_State *L, const BS_Vertex &Vertex) {
// Create New Table
lua_newtable(L);
diff --git a/engines/sword25/math/vertex.h b/engines/sword25/math/vertex.h
index 65c179d654..b39de82fac 100644
--- a/engines/sword25/math/vertex.h
+++ b/engines/sword25/math/vertex.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -33,10 +33,10 @@
*/
/*
- BS_Vertex
- ---------
+ BS_Vertex
+ ---------
- Autor: Malte Thiesen
+ Autor: Malte Thiesen
*/
#ifndef SWORD25_VERTEX_H
@@ -63,7 +63,10 @@ namespace Sword25 {
class BS_Vertex {
public:
BS_Vertex() : X(0), Y(0) {};
- BS_Vertex(int X_, int Y_) { this->X = X_; this->Y = Y_; }
+ BS_Vertex(int X_, int Y_) {
+ this->X = X_;
+ this->Y = Y_;
+ }
int X;
int Y;
@@ -71,78 +74,93 @@ public:
/**
* Compares two Vertecies.
*/
- inline bool operator==(const BS_Vertex& rhs) const { if (X == rhs.X && Y == rhs.Y) return true; return false; }
+ inline bool operator==(const BS_Vertex &rhs) const {
+ if (X == rhs.X && Y == rhs.Y) return true;
+ return false;
+ }
/**
* Compares two Vertecies.
*/
- inline bool operator!=(const BS_Vertex& rhs) const { if (X != rhs.X || Y != rhs.Y) return true; return false; }
+ inline bool operator!=(const BS_Vertex &rhs) const {
+ if (X != rhs.X || Y != rhs.Y) return true;
+ return false;
+ }
/**
* Adds a vertex to vertex
*/
- inline void operator+=(const BS_Vertex& Delta) { X += Delta.X; Y += Delta.Y; }
+ inline void operator+=(const BS_Vertex &Delta) {
+ X += Delta.X;
+ Y += Delta.Y;
+ }
/**
* Subtracts a vertex from a vertex
*/
- inline void operator-=(const BS_Vertex& Delta) { X -= Delta.X; Y -= Delta.Y; }
+ inline void operator-=(const BS_Vertex &Delta) {
+ X -= Delta.X;
+ Y -= Delta.Y;
+ }
/**
* Adds two vertecies
*/
- inline BS_Vertex operator+(const BS_Vertex& Delta) const { return BS_Vertex(X + Delta.X, Y + Delta.Y); }
+ inline BS_Vertex operator+(const BS_Vertex &Delta) const {
+ return BS_Vertex(X + Delta.X, Y + Delta.Y);
+ }
/**
* Subtracts two vertecies
*/
- inline BS_Vertex operator-(const BS_Vertex& Delta) const { return BS_Vertex(X - Delta.X, Y - Delta.Y); }
+ inline BS_Vertex operator-(const BS_Vertex &Delta) const {
+ return BS_Vertex(X - Delta.X, Y - Delta.Y);
+ }
/**
* Calculates the square of the distance between two Vertecies.
- * @param Vertex The vertex for which the distance is to be calculated
- * @return Returns the square of the distance between itself and the passed vertex
- * @remark If only distances should be compared, this method should be used because
+ * @param Vertex The vertex for which the distance is to be calculated
+ * @return Returns the square of the distance between itself and the passed vertex
+ * @remark If only distances should be compared, this method should be used because
* it is faster than Distance()
*/
- inline int Distance2(const BS_Vertex& Vertex) const {
+ inline int Distance2(const BS_Vertex &Vertex) const {
return (X - Vertex.X) * (X - Vertex.X) + (Y - Vertex.Y) * (Y - Vertex.Y);
}
/**
* Calculates the square of the distance between two Vertecies.
- * @param Vertex The vertex for which the distance is to be calculated
- * @return Returns the square of the distance between itself and the passed vertex
- * @remark If only distances should be compared, Distance2() should be used, since it is faster.
+ * @param Vertex The vertex for which the distance is to be calculated
+ * @return Returns the square of the distance between itself and the passed vertex
+ * @remark If only distances should be compared, Distance2() should be used, since it is faster.
*/
- inline int Distance(const BS_Vertex& Vertex) const {
+ inline int Distance(const BS_Vertex &Vertex) const {
return (int)(sqrtf(static_cast<float>(Distance2(Vertex))) + 0.5);
}
/**
* Calculates the cross product of the vertex with another vertex. Here the Vertecies will be
* interpreted as vectors.
- * @param Vertex The second vertex
- * @return Returns the cross product of this vertex and the passed vertex.
+ * @param Vertex The second vertex
+ * @return Returns the cross product of this vertex and the passed vertex.
*/
- inline int ComputeCrossProduct(const BS_Vertex& Vertex) const {
+ inline int ComputeCrossProduct(const BS_Vertex &Vertex) const {
return X * Vertex.Y - Vertex.X * Y;
}
/**
* Returns the dot product of this vertex with another vertex. Here the Vertecies are interpreted as vectors.
- * @param Vertex The second vertex
- * @return Returns the dot product of this vertex and the passed vertex.
+ * @param Vertex The second vertex
+ * @return Returns the dot product of this vertex and the passed vertex.
*/
- inline int ComputeDotProduct(const BS_Vertex& Vertex) const
- {
+ inline int ComputeDotProduct(const BS_Vertex &Vertex) const {
return X * Vertex.X + Y * Vertex.Y;
}
/**
* Calculates the angle between this vertex and another vertex. Here the Vertecies are interpreted as vectors.
- * @param Vertex The second vertex
- * @return Returns the angle between this vertex and the passed vertex in radians.
+ * @param Vertex The second vertex
+ * @return Returns the angle between this vertex and the passed vertex in radians.
*/
- inline float ComputeAngle(const BS_Vertex& Vertex) const {
+ inline float ComputeAngle(const BS_Vertex &Vertex) const {
return atan2f(static_cast<float>(ComputeCrossProduct(Vertex)), static_cast<float>(ComputeDotProduct(Vertex)));
}
diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp
index 70b84da3b9..0ef2958521 100644
--- a/engines/sword25/math/walkregion.cpp
+++ b/engines/sword25/math/walkregion.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -59,7 +59,7 @@ BS_WalkRegion::BS_WalkRegion() {
// -----------------------------------------------------------------------------
BS_WalkRegion::BS_WalkRegion(BS_InputPersistenceBlock &Reader, unsigned int Handle) :
- BS_Region(Reader, Handle) {
+ BS_Region(Reader, Handle) {
m_Type = RT_WALKREGION;
Unpersist(Reader);
}
@@ -91,13 +91,12 @@ bool BS_WalkRegion::QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path
// If the start and finish are identical, no path can be found trivially
if (StartPoint == EndPoint) return true;
- // Ensure that the start and finish are valid and find new start points if either
+ // Ensure that the start and finish are valid and find new start points if either
// are outside the polygon
if (!CheckAndPrepareStartAndEnd(StartPoint, EndPoint)) return false;
// If between the start and point a line of sight exists, then it can be returned.
- if (IsLineOfSight(StartPoint, EndPoint))
- {
+ if (IsLineOfSight(StartPoint, EndPoint)) {
Path.push_back(StartPoint);
Path.push_back(EndPoint);
return true;
@@ -114,27 +113,27 @@ struct DijkstraNode {
typedef Container::const_iterator ConstIter;
DijkstraNode() : Cost(infinity), Chosen(false) {};
- ConstIter ParentIter;
- int Cost;
- bool Chosen;
+ ConstIter ParentIter;
+ int Cost;
+ bool Chosen;
};
-static void InitDijkstraNodes(DijkstraNode::Container &DijkstraNodes, const BS_Region &Region,
- const BS_Vertex &Start, const Common::Array<BS_Vertex> &Nodes) {
+static void InitDijkstraNodes(DijkstraNode::Container &DijkstraNodes, const BS_Region &Region,
+ const BS_Vertex &Start, const Common::Array<BS_Vertex> &Nodes) {
// Allocate sufficient space in the array
DijkstraNodes.resize(Nodes.size());
// Initialise all the nodes which are visible from the starting node
DijkstraNode::Iter DijkstraIter = DijkstraNodes.begin();
- for (Common::Array<BS_Vertex>::const_iterator NodesIter = Nodes.begin();
- NodesIter != Nodes.end(); NodesIter++, DijkstraIter++) {
+ for (Common::Array<BS_Vertex>::const_iterator NodesIter = Nodes.begin();
+ NodesIter != Nodes.end(); NodesIter++, DijkstraIter++) {
(*DijkstraIter).ParentIter = DijkstraNodes.end();
- if (Region.IsLineOfSight(*NodesIter, Start)) (*DijkstraIter).Cost = (*NodesIter).Distance(Start);
+ if (Region.IsLineOfSight(*NodesIter, Start))(*DijkstraIter).Cost = (*NodesIter).Distance(Start);
}
BS_ASSERT(DijkstraIter == DijkstraNodes.end());
}
-static DijkstraNode::Iter ChooseClosestNode(DijkstraNode::Container & Nodes) {
+static DijkstraNode::Iter ChooseClosestNode(DijkstraNode::Container &Nodes) {
DijkstraNode::Iter ClosestNodeInter = Nodes.end();
int MinCost = infinity;
@@ -149,8 +148,8 @@ static DijkstraNode::Iter ChooseClosestNode(DijkstraNode::Container & Nodes) {
}
static void RelaxNodes(DijkstraNode::Container &Nodes,
- const Common::Array< Common::Array<int> > &VisibilityMatrix,
- const DijkstraNode::ConstIter &CurNodeIter) {
+ const Common::Array< Common::Array<int> > &VisibilityMatrix,
+ const DijkstraNode::ConstIter &CurNodeIter) {
// All the successors of the current node that have not been chosen will be
// inserted into the boundary node list, and the cost will be updated if
// a shorter path has been found to them.
@@ -169,10 +168,10 @@ static void RelaxNodes(DijkstraNode::Container &Nodes,
}
static void RelaxEndPoint(const BS_Vertex &CurNodePos,
- const DijkstraNode::ConstIter &CurNodeIter,
- const BS_Vertex &EndPointPos,
- DijkstraNode &EndPoint,
- const BS_Region &Region) {
+ const DijkstraNode::ConstIter &CurNodeIter,
+ const BS_Vertex &EndPointPos,
+ DijkstraNode &EndPoint,
+ const BS_Region &Region) {
if (Region.IsLineOfSight(CurNodePos, EndPointPos)) {
int TotalCost = (*CurNodeIter).Cost + CurNodePos.Distance(EndPointPos);
if (TotalCost < EndPoint.Cost) {
@@ -262,7 +261,7 @@ void BS_WalkRegion::InitNodeVector() {
// -----------------------------------------------------------------------------
void BS_WalkRegion::ComputeVisibilityMatrix() {
- // Initialise visibility matrix
+ // Initialise visibility matrix
m_VisibilityMatrix = Common::Array< Common::Array <int> >();
for (uint idx = 0; idx < m_Nodes.size(); ++idx) {
Common::Array<int> arr;
@@ -271,10 +270,10 @@ void BS_WalkRegion::ComputeVisibilityMatrix() {
m_VisibilityMatrix.push_back(arr);
}
-
+
// Calculate visibility been vertecies
for (unsigned int j = 0; j < m_Nodes.size(); ++j) {
- for (unsigned int i = j; i < m_Nodes.size(); ++i) {
+ for (unsigned int i = j; i < m_Nodes.size(); ++i) {
if (IsLineOfSight(m_Nodes[i], m_Nodes[j])) {
// There is a line of sight, so save the distance between the two
int Distance = m_Nodes[i].Distance(m_Nodes[j]);
@@ -298,8 +297,8 @@ bool BS_WalkRegion::CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End)
// Check to make sure the point is really in the region. If not, stop with an error
if (!IsPointInRegion(NewStart)) {
BS_LOG_ERRORLN("Constructed startpoint ((%d,%d) from (%d,%d)) is not inside the region.",
- NewStart.X, NewStart.Y,
- Start.X, Start.Y);
+ NewStart.X, NewStart.Y,
+ Start.X, Start.Y);
return false;
}
@@ -314,8 +313,8 @@ bool BS_WalkRegion::CheckAndPrepareStartAndEnd(BS_Vertex &Start, BS_Vertex &End)
// Make sure that the determined point is really within the region
if (!IsPointInRegion(NewEnd)) {
BS_LOG_ERRORLN("Constructed endpoint ((%d,%d) from (%d,%d)) is not inside the region.",
- NewEnd.X, NewEnd.Y,
- End.X, End.Y);
+ NewEnd.X, NewEnd.Y,
+ End.X, End.Y);
return false;
}
diff --git a/engines/sword25/math/walkregion.h b/engines/sword25/math/walkregion.h
index 6b06c8ed30..f23044ecef 100644
--- a/engines/sword25/math/walkregion.h
+++ b/engines/sword25/math/walkregion.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -73,31 +73,35 @@ public:
* may lie outside the region. Int his case, the end is chosen as the cloest point to it
* that lies within the region.
*
- * @param X1 X Co-ordinate of the start point
- * @param Y1 Y Co-ordinate of the start point
- * @param X2 X Co-ordinate of the end point
- * @param Y2 Y Co-ordinate of the end point
- * @param Path An empty BS_Path that will be set to the resulting path
- * @return Returns false if the result is invalid, otherwise returns true.
+ * @param X1 X Co-ordinate of the start point
+ * @param Y1 Y Co-ordinate of the start point
+ * @param X2 X Co-ordinate of the end point
+ * @param Y2 Y Co-ordinate of the end point
+ * @param Path An empty BS_Path that will be set to the resulting path
+ * @return Returns false if the result is invalid, otherwise returns true.
*/
- bool QueryPath(int X1, int Y1, int X2, int Y2, BS_Path &Path) {
+ bool QueryPath(int X1, int Y1, int X2, int Y2, BS_Path &Path) {
return QueryPath(BS_Vertex(X1, Y1), BS_Vertex(X2, Y2), Path);
}
/**
* Get the shortest path between two points in the region.
*
- * @param StartPoint The start point
- * @param EndPoint The end point
- * @param Path An empty BS_Path that will be set to the resulting path
- * @return Returns false if the result is invalid, otherwise returns true.
+ * @param StartPoint The start point
+ * @param EndPoint The end point
+ * @param Path An empty BS_Path that will be set to the resulting path
+ * @return Returns false if the result is invalid, otherwise returns true.
*/
- bool QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path & Path);
+ bool QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path &Path);
virtual void SetPos(int X, int Y);
- const Common::Array<BS_Vertex> &GetNodes() const { return m_Nodes; }
- const Common::Array< Common::Array<int> > &GetVisibilityMatrix() const { return m_VisibilityMatrix; }
+ const Common::Array<BS_Vertex> &GetNodes() const {
+ return m_Nodes;
+ }
+ const Common::Array< Common::Array<int> > &GetVisibilityMatrix() const {
+ return m_VisibilityMatrix;
+ }
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp
index 2dc07cfae9..329061a6b3 100644
--- a/engines/sword25/package/packagemanager.cpp
+++ b/engines/sword25/package/packagemanager.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index 1d6c71074f..92eb82f6e9 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -70,37 +70,37 @@ namespace Sword25 {
*/
class BS_PackageManager : public BS_Service {
public:
- BS_PackageManager(BS_Kernel* pKernel);
+ BS_PackageManager(BS_Kernel *pKernel);
virtual ~BS_PackageManager() {};
enum FILE_TYPES {
- FT_DIRECTORY = (1<<0),
- FT_FILE = (1<<1)
+ FT_DIRECTORY = (1 << 0),
+ FT_FILE = (1 << 1)
};
/**
* File search class
- *
+ *
* These objects are created with BS_PackageManager::CreateSearch
*/
class FileSearch {
public:
- virtual ~FileSearch(){};
+ virtual ~FileSearch() {};
/**
* Returns the filename of the current file
- * @return Returns the filename of the current file
+ * @return Returns the filename of the current file
*/
virtual Common::String GetCurFileName() = 0;
/**
* Returns the type of the current file
- * @return Returns the type of the current file
+ * @return Returns the type of the current file
* This is either BS_PackageManager::FT_FILE or BS_PackageManager::FT_DIRECTORY.
*/
virtual unsigned int GetCurFileType() = 0;
/**
* Returns the size of the current file
- * @return Returns the size of the current file
+ * @return Returns the size of the current file
* For directories, this value is always 0
*/
virtual unsigned int GetCurFileSize() = 0;
@@ -108,79 +108,79 @@ public:
// Returns false if no more files are found.
/**
* Finds the next file.
- * @return Returns false if no other file fulfills the search criteria
+ * @return Returns false if no other file fulfills the search criteria
*/
virtual bool NextFile() = 0;
};
/**
* Mounts the contents of a package in the directory specified in the virtual directory tree.
- * @param FileName The filename of the package to mount
- * @param MountPosition The directory name under which the package should be mounted
- * @return Returns true if the mount was successful, otherwise false.
+ * @param FileName The filename of the package to mount
+ * @param MountPosition The directory name under which the package should be mounted
+ * @return Returns true if the mount was successful, otherwise false.
*/
virtual bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition) = 0;
/**
* Mounts the contents of a directory in the specified directory in the virtual directory tree.
- * @param The name of the directory to mount
- * @param MountPosition The directory name under which the package should be mounted
- * @return Returns true if the mount was successful, otherwise false.
+ * @param The name of the directory to mount
+ * @param MountPosition The directory name under which the package should be mounted
+ * @return Returns true if the mount was successful, otherwise false.
*/
virtual bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) = 0;
/**
* Downloads a file from the virtual directory tree
- * @param FileName The filename of the file to load
- * @param pFileSize Pointer to the variable that will contain the size of the loaded file. The deafult is NULL.
- * @return Specifies a pointer to the loaded data of the file
- * @remark The client must not forget to release the data of the file using BE_DELETE_A.
+ * @param FileName The filename of the file to load
+ * @param pFileSize Pointer to the variable that will contain the size of the loaded file. The deafult is NULL.
+ * @return Specifies a pointer to the loaded data of the file
+ * @remark The client must not forget to release the data of the file using BE_DELETE_A.
*/
virtual void *GetFile(const Common::String &FileName, unsigned int *pFileSize = NULL) = 0;
/**
* Returns the path to the current directory.
- * @return Returns a string containing the path to the current directory.
+ * @return Returns a string containing the path to the current directory.
* If the path could not be determined, an empty string is returned.
- * @remark For cutting path elements '\' is used rather than '/' elements.
+ * @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual Common::String GetCurrentDirectory() = 0;
+ virtual Common::String GetCurrentDirectory() = 0;
/**
* Changes the current directory.
- * @param Directory The path to the new directory. The path can be relative.
- * @return Returns true if the operation was successful, otherwise false.
- * @remark For cutting path elements '\' is used rather than '/' elements.
+ * @param Directory The path to the new directory. The path can be relative.
+ * @return Returns true if the operation was successful, otherwise false.
+ * @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual bool ChangeDirectory(const Common::String& Directory) = 0;
+ virtual bool ChangeDirectory(const Common::String &Directory) = 0;
/**
* Returns the absolute path to a file in the virtual directory tree.
- * @param FileName The filename of the file whose absolute path is to be determined.
+ * @param FileName The filename of the file whose absolute path is to be determined.
* These parameters may include both relative and absolute paths.
- * @return Returns an absolute path to the given file.
- * @remark For cutting path elements '\' is used rather than '/' elements.
+ * @return Returns an absolute path to the given file.
+ * @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual Common::String GetAbsolutePath(const Common::String& FileName) = 0;
+ virtual Common::String GetAbsolutePath(const Common::String &FileName) = 0;
/**
* Creates a BS_PackageManager::FileSearch object to search for files
- * @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
- * @param Path Specifies the directory that should be searched.
- * @param TypeFilter A combination of flags BS_PackageManager::FT_DIRECTORY and BS_PackageManager::FT_FILE.
- * These flags indicate whether to search for files, directories, or both.
+ * @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
+ * @param Path Specifies the directory that should be searched.
+ * @param TypeFilter A combination of flags BS_PackageManager::FT_DIRECTORY and BS_PackageManager::FT_FILE.
+ * These flags indicate whether to search for files, directories, or both.
* The default is BS_PackageManager::FT_DIRECTORY | BS_PackageManager::FT_FILE
- * @return Specifies a pointer to a BS_PackageManager::FileSearch object, or NULL if no file was found.
- * @remark Do not forget to delete the object after use.
+ * @return Specifies a pointer to a BS_PackageManager::FileSearch object, or NULL if no file was found.
+ * @remark Do not forget to delete the object after use.
*/
virtual FileSearch *CreateSearch(const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
/**
* Returns a file's size
- * @param FileName The filename
- * @return The file size. If an error occurs, then 0xffffffff is returned.
- * @remarks For files in packages, then uncompressed size is returned.
+ * @param FileName The filename
+ * @return The file size. If an error occurs, then 0xffffffff is returned.
+ * @remarks For files in packages, then uncompressed size is returned.
**/
virtual unsigned int GetFileSize(const Common::String &FileName) = 0;
/**
* Returns the type of a file.
- * @param FileName The filename
- * @return Returns the file type, either (BS_PackageManager::FT_DIRECTORY
+ * @param FileName The filename
+ * @return Returns the file type, either (BS_PackageManager::FT_DIRECTORY
* or BS_PackageManager::FT_FILE).
* If the file was not found, then 0 is returned.
*/
@@ -188,10 +188,10 @@ public:
/**
* Determines whether a file exists
- * @param FileName The filename
- * @return Returns true if the file exists, otherwise false.
+ * @param FileName The filename
+ * @return Returns true if the file exists, otherwise false.
*/
- virtual bool FileExists(const Common::String & FileName) = 0;
+ virtual bool FileExists(const Common::String &FileName) = 0;
private:
bool _RegisterScriptBindings();
diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp
index 48f869ed9e..803c346fdb 100644
--- a/engines/sword25/package/packagemanager_script.cpp
+++ b/engines/sword25/package/packagemanager_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,7 +50,7 @@ using namespace Lua;
// -----------------------------------------------------------------------------
static BS_PackageManager *GetPM() {
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
BS_PackageManager *pPM = static_cast<BS_PackageManager *>(pKernel->GetService("package"));
BS_ASSERT(pPM);
@@ -135,7 +135,7 @@ static void SplitSearchPath(const Common::String &Path, Common::String &Director
const char *lastSlash = sPath + strlen(sPath) - 1;
while ((lastSlash >= sPath) && (*lastSlash != '/')) --lastSlash;
- if (lastSlash >= sPath) {
+ if (lastSlash >= sPath) {
Directory = "";
Filter = Path;
} else {
@@ -162,7 +162,7 @@ static void DoSearch(lua_State *L, const Common::String &Path, unsigned int Type
// Suche durchführen und die Namen aller gefundenen Dateien in die Ergebnistabelle einfügen.
// Als Indizes werden fortlaufende Nummern verwandt.
unsigned int ResultNr = 1;
- BS_PackageManager::FileSearch * pFS = pPM->CreateSearch(Filter, Directory, Type);
+ BS_PackageManager::FileSearch *pFS = pPM->CreateSearch(Filter, Directory, Type);
if (pFS) {
do {
lua_pushnumber(L, ResultNr);
@@ -195,7 +195,7 @@ static int GetFileAsString(lua_State *L) {
BS_PackageManager *pPM = GetPM();
unsigned int FileSize;
- void * FileData = pPM->GetFile(luaL_checkstring(L, 1), &FileSize);
+ void *FileData = pPM->GetFile(luaL_checkstring(L, 1), &FileSize);
if (FileData) {
lua_pushlstring(L, static_cast<char *>(FileData), FileSize);
delete FileData;
@@ -214,7 +214,7 @@ static int FileExists(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * PACKAGE_LIBRARY_NAME = "Package";
+static const char *PACKAGE_LIBRARY_NAME = "Package";
static const luaL_reg PACKAGE_FUNCTIONS[] = {
"LoadPackage", LoadPackage,
@@ -234,9 +234,9 @@ static const luaL_reg PACKAGE_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
bool BS_PackageManager::_RegisterScriptBindings() {
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
diff --git a/engines/sword25/package/scummvmpackagemanager.cpp b/engines/sword25/package/scummvmpackagemanager.cpp
index fa2001dbed..43f16e1db6 100644
--- a/engines/sword25/package/scummvmpackagemanager.cpp
+++ b/engines/sword25/package/scummvmpackagemanager.cpp
@@ -94,12 +94,12 @@ static PathElementArray SeparatePath(const Common::String &Path, const Common::S
Common::String::const_iterator elementEnd = wholePath.begin() + nextseparatorPos;
if (elementEnd - elementBegin == 2 &&
- elementBegin[0] == NAVIGATION_CHARACTER &&
- elementBegin[1] == NAVIGATION_CHARACTER) {
+ elementBegin[0] == NAVIGATION_CHARACTER &&
+ elementBegin[1] == NAVIGATION_CHARACTER) {
// element is "..", therefore the previous path element should be removed
if (pathElements.size()) pathElements.pop_back();
} else if (elementEnd - elementBegin == 1 &&
- elementBegin[0] == NAVIGATION_CHARACTER) {
+ elementBegin[0] == NAVIGATION_CHARACTER) {
// element is ".", so we do nothing
} else {
// Normal elements get added to the list
@@ -114,7 +114,7 @@ static PathElementArray SeparatePath(const Common::String &Path, const Common::S
static Common::String NormalizePath(const Common::String &Path, const Common::String &CurrentDirectory) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(Path, CurrentDirectory);
+ PathElementArray pathElements = SeparatePath(Path, CurrentDirectory);
if (pathElements.size()) {
// The individual path elements are fitted together, separated by a directory
@@ -140,9 +140,9 @@ static Common::String NormalizePath(const Common::String &Path, const Common::St
// -----------------------------------------------------------------------------
BS_ScummVMPackageManager::BS_ScummVMPackageManager(BS_Kernel *KernelPtr) :
- BS_PackageManager(KernelPtr),
- _currentDirectory(PATH_SEPARATOR),
- _rootFolder(ConfMan.get("path")) {
+ BS_PackageManager(KernelPtr),
+ _currentDirectory(PATH_SEPARATOR),
+ _rootFolder(ConfMan.get("path")) {
}
// -----------------------------------------------------------------------------
@@ -152,8 +152,8 @@ BS_ScummVMPackageManager::~BS_ScummVMPackageManager() {
// -----------------------------------------------------------------------------
-BS_Service *BS_ScummVMPackageManager_CreateObject(BS_Kernel *KernelPtr) {
- return new BS_ScummVMPackageManager(KernelPtr);
+BS_Service *BS_ScummVMPackageManager_CreateObject(BS_Kernel *KernelPtr) {
+ return new BS_ScummVMPackageManager(KernelPtr);
}
// -----------------------------------------------------------------------------
@@ -177,11 +177,11 @@ Common::FSNode BS_ScummVMPackageManager::GetFSNode(const Common::String &FileNam
PathElementArray::iterator iEntry = i->MountPath.begin();
for (; iEntry != i->MountPath.end(); ++iEntry, ++iPath) {
- if (Common::String(iPath->GetBegin(), iPath->GetEnd()) ==
- Common::String(iEntry->GetBegin(), iEntry->GetEnd()))
+ if (Common::String(iPath->GetBegin(), iPath->GetEnd()) ==
+ Common::String(iEntry->GetBegin(), iEntry->GetEnd()))
break;
}
-
+
if (iEntry == i->MountPath.end()) {
// Look into the archive for the desired file
// Common::Archive *archiveFolder = i->Archive;
@@ -189,21 +189,21 @@ Common::FSNode BS_ScummVMPackageManager::GetFSNode(const Common::String &FileNam
// TODO: Loop through any folders in the archive
for (; iPath != pathElements.end(); ++iPath) {
- }
+ }
// Return the found node
return Common::FSNode();
}
}
- return Common::FSNode();
+ return Common::FSNode();
}
// -----------------------------------------------------------------------------
bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const Common::String &MountPosition) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
+ PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
Common::Archive *zipFile = Common::makeZipArchive(FileName);
if (zipFile == NULL) {
@@ -220,14 +220,14 @@ bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const
bool BS_ScummVMPackageManager::LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
+ PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
Common::FSNode directory(DirectoryName);
Common::Archive *folderArchive = new Common::FSDirectory(directory);
if (!directory.exists() || (folderArchive == NULL)) {
BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", DirectoryName.c_str(), MountPosition.c_str());
return false;
- } else {
+ } else {
BS_LOGLN("Directory '%s' mounted as '%s'.", DirectoryName.c_str(), MountPosition.c_str());
_archiveList.push_front(ArchiveEntry(folderArchive, pathElements));
return true;
@@ -241,14 +241,14 @@ void *BS_ScummVMPackageManager::GetFile(const Common::String &FileName, unsigned
Common::FSNode fileNode = GetFSNode(FileName);
if (!fileNode.exists()) return 0;
if (!f.open(fileNode)) return 0;
-
+
// If the filesize is desired, then output the size
if (FileSizePtr) *FileSizePtr = f.size();
// Read the file
byte *buffer = new byte[f.size()];
if (!f.read(buffer, f.size())) return 0;
-
+
f.close();
return buffer;
}
@@ -316,7 +316,7 @@ public:
_foundFilesIt(_foundFiles.begin()) {
}
- virtual Common::String GetCurFileName() {
+ virtual Common::String GetCurFileName() {
return *_foundFilesIt;
}
@@ -333,15 +333,15 @@ public:
return _foundFilesIt != _foundFiles.end();
}
- BS_PackageManager & _packageManager;
- Common::StringArray _foundFiles;
- Common::StringArray::const_iterator _foundFilesIt;
+ BS_PackageManager &_packageManager;
+ Common::StringArray _foundFiles;
+ Common::StringArray::const_iterator _foundFilesIt;
};
// -----------------------------------------------------------------------------
BS_PackageManager::FileSearch *BS_ScummVMPackageManager::CreateSearch(
- const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter) {
+ const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter) {
Common::String NormalizedPath = NormalizePath(Path, _currentDirectory);
Common::FSNode folderNode = GetFSNode(Path);
diff --git a/engines/sword25/package/scummvmpackagemanager.h b/engines/sword25/package/scummvmpackagemanager.h
index d279b7e8ad..a837f03bee 100644
--- a/engines/sword25/package/scummvmpackagemanager.h
+++ b/engines/sword25/package/scummvmpackagemanager.h
@@ -54,8 +54,12 @@ public:
PathElement() { }
PathElement(Common::String::const_iterator Begin, Common::String::const_iterator End) : m_Begin(Begin), m_End(End) {}
- Common::String::const_iterator GetBegin() const { return m_Begin; }
- Common::String::const_iterator GetEnd() const { return m_End; }
+ Common::String::const_iterator GetBegin() const {
+ return m_Begin;
+ }
+ Common::String::const_iterator GetEnd() const {
+ return m_End;
+ }
private:
Common::String::const_iterator m_Begin;
@@ -72,7 +76,7 @@ private:
PathElementArray MountPath;
ArchiveEntry(Common::Archive *Archive_, const PathElementArray &MountPath_):
- Archive(Archive_), MountPath(MountPath_) {
+ Archive(Archive_), MountPath(MountPath_) {
}
~ArchiveEntry() {
delete Archive;
@@ -85,13 +89,13 @@ private:
Common::FSNode GetFSNode(const Common::String &FileName);
public:
- BS_ScummVMPackageManager(BS_Kernel * KernelPtr);
+ BS_ScummVMPackageManager(BS_Kernel *KernelPtr);
virtual ~BS_ScummVMPackageManager();
virtual bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition);
virtual bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition);
virtual void *GetFile(const Common::String &FileName, unsigned int *FileSizePtr = 0);
- virtual Common::String GetCurrentDirectory();
+ virtual Common::String GetCurrentDirectory();
virtual bool ChangeDirectory(const Common::String &Directory);
virtual Common::String GetAbsolutePath(const Common::String &FileName);
virtual FileSearch *CreateSearch(const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE);
diff --git a/engines/sword25/script/lua_extensions.cpp b/engines/sword25/script/lua_extensions.cpp
index a9abb9ea82..f069da5075 100644
--- a/engines/sword25/script/lua_extensions.cpp
+++ b/engines/sword25/script/lua_extensions.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
diff --git a/engines/sword25/script/luabindhelper.cpp b/engines/sword25/script/luabindhelper.cpp
index f2182a6b11..76e8faac8e 100644
--- a/engines/sword25/script/luabindhelper.cpp
+++ b/engines/sword25/script/luabindhelper.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,39 +45,39 @@
// -----------------------------------------------------------------------------
namespace {
- const char * METATABLES_TABLE_NAME = "__METATABLES";
- const char * PERMANENTS_TABLE_NAME = "Permanents";
+const char *METATABLES_TABLE_NAME = "__METATABLES";
+const char *PERMANENTS_TABLE_NAME = "Permanents";
- bool RegisterPermanent(lua_State *L, const Common::String &Name) {
- // A C function has to be on the stack
- if (!lua_iscfunction(L, -1)) return false;
+bool RegisterPermanent(lua_State *L, const Common::String &Name) {
+ // A C function has to be on the stack
+ if (!lua_iscfunction(L, -1)) return false;
- // Make sure that the Permanents-Table is on top of the stack
- lua_getfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
- if (lua_isnil(L, -1)) {
- // Permanents-Table does not yet exist, so it has to be created
+ // Make sure that the Permanents-Table is on top of the stack
+ lua_getfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
+ if (lua_isnil(L, -1)) {
+ // Permanents-Table does not yet exist, so it has to be created
- // Pop nil from the stack
- lua_pop(L, 1);
+ // Pop nil from the stack
+ lua_pop(L, 1);
- // Create Permanents-Table and insert a second reference to it on the stack
- lua_newtable(L);
- lua_pushvalue(L, -1);
+ // Create Permanents-Table and insert a second reference to it on the stack
+ lua_newtable(L);
+ lua_pushvalue(L, -1);
- // Store the Permanents-Table in the registry. The second reference is left
- // on the stack to be used in the connection
- lua_setfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
- }
+ // Store the Permanents-Table in the registry. The second reference is left
+ // on the stack to be used in the connection
+ lua_setfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
+ }
- // C function with the name of an index in the Permanents-Table
- lua_insert(L, -2);
- lua_setfield(L, -2, Name.c_str());
+ // C function with the name of an index in the Permanents-Table
+ lua_insert(L, -2);
+ lua_setfield(L, -2, Name.c_str());
- // Remove the Permanents-Table from the stack
- lua_pop(L, 1);
+ // Remove the Permanents-Table from the stack
+ lua_pop(L, 1);
- return true;
- }
+ return true;
+}
}
namespace Sword25 {
@@ -86,12 +86,12 @@ namespace Sword25 {
/**
* Registers a set of functions into a Lua library.
- * @param L A pointer to the Lua VM
- * @param LibName The name of the library.
+ * @param L A pointer to the Lua VM
+ * @param LibName The name of the library.
* If this is an empty string, the functions will be added to the global namespace.
- * @param Functions An array of function pointers along with their names.
+ * @param Functions An array of function pointers along with their names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddFunctionsToLib(lua_State *L, const Common::String &LibName, const luaL_reg *Functions) {
#ifdef DEBUG
@@ -144,12 +144,12 @@ bool BS_LuaBindhelper::AddFunctionsToLib(lua_State *L, const Common::String &Lib
/**
* Adds a set of constants to the Lua library
- * @param L A pointer to the Lua VM
- * @param LibName The name of the library.
+ * @param L A pointer to the Lua VM
+ * @param LibName The name of the library.
* If this is an empty string, the functions will be added to the global namespace.
- * @param Constants An array of the constant values along with their names.
+ * @param Constants An array of the constant values along with their names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddConstantsToLib(lua_State *L, const Common::String &LibName, const lua_constant_reg *Constants) {
#ifdef DEBUG
@@ -168,7 +168,7 @@ bool BS_LuaBindhelper::AddConstantsToLib(lua_State *L, const Common::String &Lib
else {
// Ensure that the library table exists
if (!_CreateTable(L, LibName)) return false;
-
+
// Register each constant in the table
for (; Constants->Name; ++Constants) {
lua_pushstring(L, Constants->Name);
@@ -191,12 +191,12 @@ bool BS_LuaBindhelper::AddConstantsToLib(lua_State *L, const Common::String &Lib
/**
* Adds a set of methods to a Lua class
- * @param L A pointer to the Lua VM
- * @param ClassName The name of the class
+ * @param L A pointer to the Lua VM
+ * @param ClassName The name of the class
* When the class name specified does not exist, it is created.
- * @param Methods An array of function pointers along with their method names.
+ * @param Methods An array of function pointers along with their method names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::AddMethodsToClass(lua_State *L, const Common::String &ClassName, const luaL_reg *Methods) {
#ifdef DEBUG
@@ -205,7 +205,7 @@ bool BS_LuaBindhelper::AddMethodsToClass(lua_State *L, const Common::String &Cla
// Load the metatable onto the Lua stack
if (!GetMetatable(L, ClassName)) return false;
-
+
// Register each method in the Metatable
for (; Methods->name; ++Methods) {
lua_pushstring(L, Methods->name);
@@ -232,11 +232,11 @@ bool BS_LuaBindhelper::AddMethodsToClass(lua_State *L, const Common::String &Cla
/**
* Sets the garbage collector callback method when items of a particular class are deleted
- * @param L A pointer to the Lua VM
- * @param ClassName The name of the class
+ * @param L A pointer to the Lua VM
+ * @param ClassName The name of the class
* When the class name specified does not exist, it is created.
- * @param GCHandler A function pointer
- * @return Returns true if successful, otherwise false.
+ * @param GCHandler A function pointer
+ * @return Returns true if successful, otherwise false.
*/
bool BS_LuaBindhelper::SetClassGCHandler(lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler) {
#ifdef DEBUG
@@ -271,22 +271,22 @@ bool BS_LuaBindhelper::SetClassGCHandler(lua_State *L, const Common::String &Cla
// -----------------------------------------------------------------------------
namespace {
- void PushMetatableTable(lua_State *L) {
- // Push the Metatable table onto the stack
- lua_getglobal(L, METATABLES_TABLE_NAME);
+void PushMetatableTable(lua_State *L) {
+ // Push the Metatable table onto the stack
+ lua_getglobal(L, METATABLES_TABLE_NAME);
- // If the table doesn't yet exist, it must be created
- if (lua_isnil(L, -1)) {
- // Pop nil from stack
- lua_pop(L, 1);
+ // If the table doesn't yet exist, it must be created
+ if (lua_isnil(L, -1)) {
+ // Pop nil from stack
+ lua_pop(L, 1);
- // New table has been created, so add it to the global table and leave reference on stack
- lua_newtable(L);
- lua_pushvalue(L, -1);
- lua_setglobal(L, METATABLES_TABLE_NAME);
- }
+ // New table has been created, so add it to the global table and leave reference on stack
+ lua_newtable(L);
+ lua_pushvalue(L, -1);
+ lua_setglobal(L, METATABLES_TABLE_NAME);
}
}
+}
namespace Sword25 {
@@ -373,34 +373,34 @@ bool BS_LuaBindhelper::_CreateTable(lua_State *L, const Common::String &TableNam
} // End of namespace Sword25
namespace {
- Common::String GetLuaValueInfo(lua_State *L, int StackIndex) {
- switch (lua_type(L, StackIndex)) {
- case LUA_TNUMBER:
- lua_pushstring(L, lua_tostring(L, StackIndex));
- break;
-
- case LUA_TSTRING:
- lua_pushfstring(L, "\"%s\"", lua_tostring(L, StackIndex));
- break;
-
- case LUA_TBOOLEAN:
- lua_pushstring(L, (lua_toboolean(L, StackIndex) ? "true" : "false"));
- break;
-
- case LUA_TNIL:
- lua_pushliteral(L, "nil");
- break;
-
- default:
- lua_pushfstring(L, "%s: %p", luaL_typename(L, StackIndex), lua_topointer(L, StackIndex));
- break;
- }
+Common::String GetLuaValueInfo(lua_State *L, int StackIndex) {
+ switch (lua_type(L, StackIndex)) {
+ case LUA_TNUMBER:
+ lua_pushstring(L, lua_tostring(L, StackIndex));
+ break;
+
+ case LUA_TSTRING:
+ lua_pushfstring(L, "\"%s\"", lua_tostring(L, StackIndex));
+ break;
+
+ case LUA_TBOOLEAN:
+ lua_pushstring(L, (lua_toboolean(L, StackIndex) ? "true" : "false"));
+ break;
+
+ case LUA_TNIL:
+ lua_pushliteral(L, "nil");
+ break;
+
+ default:
+ lua_pushfstring(L, "%s: %p", luaL_typename(L, StackIndex), lua_topointer(L, StackIndex));
+ break;
+ }
- Common::String Result(lua_tostring(L, -1));
- lua_pop(L, 1);
+ Common::String Result(lua_tostring(L, -1));
+ lua_pop(L, 1);
- return Result;
- }
+ return Result;
+}
}
namespace Sword25 {
@@ -419,7 +419,7 @@ Common::String BS_LuaBindhelper::StackDump(lua_State *L) {
oss += "-------------- Stack Dump Finished ---------------\n";
return oss;
-}
+}
Common::String BS_LuaBindhelper::TableDump(lua_State *L) {
Common::String oss;
diff --git a/engines/sword25/script/luabindhelper.h b/engines/sword25/script/luabindhelper.h
index 6bb1a254b9..9c864c6085 100644
--- a/engines/sword25/script/luabindhelper.h
+++ b/engines/sword25/script/luabindhelper.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -41,8 +41,8 @@ namespace Lua {
extern "C"
{
- #include "sword25/util/lua/lua.h"
- #include "sword25/util/lua/lauxlib.h"
+#include "sword25/util/lua/lua.h"
+#include "sword25/util/lua/lauxlib.h"
}
}
@@ -55,65 +55,65 @@ namespace Sword25 {
#define lua_tobooleancpp(L, i) (lua_toboolean(L, i) == 0 ? false : true)
struct lua_constant_reg {
- const char * Name;
- lua_Number Value;
+ const char *Name;
+ lua_Number Value;
};
class BS_LuaBindhelper {
public:
/**
* Registers a set of functions into a Lua library.
- * @param L A pointer to the Lua VM
- * @param LibName The name of the library.
+ * @param L A pointer to the Lua VM
+ * @param LibName The name of the library.
* If this is an empty string, the functions will be added to the global namespace.
- * @param Functions An array of function pointers along with their names.
+ * @param Functions An array of function pointers along with their names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
static bool AddFunctionsToLib(lua_State *L, const Common::String &LibName, const luaL_reg *Functions);
/**
* Adds a set of constants to the Lua library
- * @param L A pointer to the Lua VM
- * @param LibName The name of the library.
+ * @param L A pointer to the Lua VM
+ * @param LibName The name of the library.
* If this is an empty string, the functions will be added to the global namespace.
- * @param Constants An array of the constant values along with their names.
+ * @param Constants An array of the constant values along with their names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
- static bool AddConstantsToLib(lua_State * L, const Common::String & LibName, const lua_constant_reg * Constants);
+ static bool AddConstantsToLib(lua_State *L, const Common::String &LibName, const lua_constant_reg *Constants);
/**
* Adds a set of methods to a Lua class
- * @param L A pointer to the Lua VM
- * @param ClassName The name of the class
+ * @param L A pointer to the Lua VM
+ * @param ClassName The name of the class
* When the class name specified does not exist, it is created.
- * @param Methods An array of function pointers along with their method names.
+ * @param Methods An array of function pointers along with their method names.
* The array must be terminated with the enry (0, 0)
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
static bool AddMethodsToClass(lua_State *L, const Common::String &ClassName, const luaL_reg *Methods);
/**
* Sets the garbage collector callback method when items of a particular class are deleted
- * @param L A pointer to the Lua VM
- * @param ClassName The name of the class
+ * @param L A pointer to the Lua VM
+ * @param ClassName The name of the class
* When the class name specified does not exist, it is created.
- * @param GCHandler A function pointer
- * @return Returns true if successful, otherwise false.
+ * @param GCHandler A function pointer
+ * @return Returns true if successful, otherwise false.
*/
static bool SetClassGCHandler(lua_State *L, const Common::String &ClassName, lua_CFunction GCHandler);
/**
* Returns a string containing a stack dump of the Lua stack
- * @param L A pointer to the Lua VM
+ * @param L A pointer to the Lua VM
*/
static Common::String StackDump(lua_State *L);
/**
* Returns a string that describes the contents of a table
- * @param L A pointer to the Lua VM
- * @remark The table must be on the Lua stack to be read out.
+ * @param L A pointer to the Lua VM
+ * @remark The table must be on the Lua stack to be read out.
*/
static Common::String TableDump(lua_State *L);
diff --git a/engines/sword25/script/luacallback.cpp b/engines/sword25/script/luacallback.cpp
index 37c6d04596..dfabc81807 100644
--- a/engines/sword25/script/luacallback.cpp
+++ b/engines/sword25/script/luacallback.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -43,11 +43,11 @@ namespace Lua {
extern "C"
{
- #include "sword25/util/lua/lua.h"
- #include "sword25/util/lua/lauxlib.h"
+#include "sword25/util/lua/lua.h"
+#include "sword25/util/lua/lauxlib.h"
}
-const char * CALLBACKTABLE_NAME = "__CALLBACKS";
+const char *CALLBACKTABLE_NAME = "__CALLBACKS";
}
@@ -88,7 +88,7 @@ void BS_LuaCallback::RegisterCallbackFunction(lua_State *L, unsigned int ObjectH
void BS_LuaCallback::UnregisterCallbackFunction(lua_State *L, unsigned int ObjectHandle) {
BS_ASSERT(lua_isfunction(L, -1));
- EnsureObjectCallbackTableExists(L,ObjectHandle);
+ EnsureObjectCallbackTableExists(L, ObjectHandle);
// Iterate over all elements of the object callback table and remove the function from it
lua_pushnil(L);
@@ -138,8 +138,7 @@ void BS_LuaCallback::InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHa
// The value of the current element is at the top of the stack, including the index
// If the value is a function, execute it
- if (lua_type(L, -1) == LUA_TFUNCTION)
- {
+ if (lua_type(L, -1) == LUA_TFUNCTION) {
// Pre-Function Call
// Derived classes can function in this parameter onto the stack.
// The return value indicates the number of parameters
@@ -153,9 +152,7 @@ void BS_LuaCallback::InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHa
// Pop error message from the stack
lua_pop(L, 1);
}
- }
- else
- {
+ } else {
// Pop value from the stack. The index is then ready for the next call to lua_next()
lua_pop(L, 1);
}
diff --git a/engines/sword25/script/luacallback.h b/engines/sword25/script/luacallback.h
index 7b7bbbe024..b8ac97fd95 100644
--- a/engines/sword25/script/luacallback.h
+++ b/engines/sword25/script/luacallback.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -61,7 +61,7 @@ namespace Sword25 {
class BS_LuaCallback {
public:
- BS_LuaCallback(lua_State * L);
+ BS_LuaCallback(lua_State *L);
virtual ~BS_LuaCallback();
// Funktion muss auf dem Lua-Stack liegen.
@@ -75,10 +75,12 @@ public:
void InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHandle);
protected:
- virtual int PreFunctionInvokation(lua_State *L) { return 0; }
+ virtual int PreFunctionInvokation(lua_State *L) {
+ return 0;
+ }
private:
- void EnsureObjectCallbackTableExists(lua_State *L,unsigned int ObjectHandle);
+ void EnsureObjectCallbackTableExists(lua_State *L, unsigned int ObjectHandle);
void PushCallbackTable(lua_State *L);
void PushObjectCallbackTable(lua_State *L, unsigned int ObjectHandle);
};
diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp
index 62b5791a82..2d475e1ed6 100644
--- a/engines/sword25/script/luascript.cpp
+++ b/engines/sword25/script/luascript.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,10 +49,10 @@
namespace Lua {
extern "C" {
- #include "sword25/util/lua/lua.h"
- #include "sword25/util/lua/lualib.h"
- #include "sword25/util/lua/lauxlib.h"
- #include "sword25/util/pluto/pluto.h"
+#include "sword25/util/lua/lua.h"
+#include "sword25/util/lua/lualib.h"
+#include "sword25/util/lua/lauxlib.h"
+#include "sword25/util/pluto/pluto.h"
}
}
@@ -80,15 +80,17 @@ BS_LuaScriptEngine::~BS_LuaScriptEngine() {
// -----------------------------------------------------------------------------
-BS_Service *BS_LuaScriptEngine_CreateObject(BS_Kernel * KernelPtr) { return new BS_LuaScriptEngine(KernelPtr); }
+BS_Service *BS_LuaScriptEngine_CreateObject(BS_Kernel *KernelPtr) {
+ return new BS_LuaScriptEngine(KernelPtr);
+}
// -----------------------------------------------------------------------------
namespace {
- int PanicCB(lua_State *L) {
- BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1));
- return 0;
- }
+int PanicCB(lua_State *L) {
+ BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1));
+ return 0;
+}
}
// -----------------------------------------------------------------------------
@@ -103,14 +105,14 @@ bool BS_LuaScriptEngine::Init() {
// Register panic callback function
lua_atpanic(m_State, PanicCB);
-
+
// Error handler for lua_pcall calls
- // The code below contains a local error handler function
+ // The code below contains a local error handler function
const char ErrorHandlerCode[] =
- "local function ErrorHandler(message) "
- " return message .. '\\n' .. debug.traceback('', 2) "
- "end "
- "return ErrorHandler";
+ "local function ErrorHandler(message) "
+ " return message .. '\\n' .. debug.traceback('', 2) "
+ "end "
+ "return ErrorHandler";
// Compile the code
if (luaL_loadbuffer(m_State, ErrorHandlerCode, strlen(ErrorHandlerCode), "PCALL ERRORHANDLER") != 0) {
@@ -128,7 +130,7 @@ bool BS_LuaScriptEngine::Init() {
return false;
}
-
+
// Place the error handler function in the Lua registry, and remember the index
m_PcallErrorhandlerRegistryIndex = luaL_ref(m_State, LUA_REGISTRYINDEX);
@@ -193,20 +195,20 @@ bool BS_LuaScriptEngine::ExecuteString(const Common::String &Code) {
namespace {
- void RemoveForbiddenFunctions(lua_State *L) {
- static const char *FORBIDDEN_FUNCTIONS[] = {
- "dofile",
- 0
- };
+void RemoveForbiddenFunctions(lua_State *L) {
+ static const char *FORBIDDEN_FUNCTIONS[] = {
+ "dofile",
+ 0
+ };
- const char ** Iterator = FORBIDDEN_FUNCTIONS;
- while (*Iterator) {
- lua_pushnil(L);
- lua_setfield(L, LUA_GLOBALSINDEX, *Iterator);
- ++Iterator;
- }
+ const char **Iterator = FORBIDDEN_FUNCTIONS;
+ while (*Iterator) {
+ lua_pushnil(L);
+ lua_setfield(L, LUA_GLOBALSINDEX, *Iterator);
+ ++Iterator;
}
}
+}
bool BS_LuaScriptEngine::RegisterStandardLibs() {
luaL_openlibs(m_State);
@@ -232,8 +234,8 @@ bool BS_LuaScriptEngine::ExecuteBuffer(const char *Data, unsigned int Size, cons
// Run buffer contents
if (lua_pcall(m_State, 0, 0, -2) != 0) {
BS_LOG_ERRORLN("An error occured while executing \"%s\":\n%s.",
- Name.c_str(),
- lua_tostring(m_State, -1));
+ Name.c_str(),
+ lua_tostring(m_State, -1));
lua_pop(m_State, 2);
return false;
@@ -262,161 +264,160 @@ void BS_LuaScriptEngine::SetCommandLine(const Common::StringArray &CommandLinePa
// -----------------------------------------------------------------------------
namespace {
- const char *PERMANENTS_TABLE_NAME = "Permanents";
-
- // -------------------------------------------------------------------------
-
- // This array contains the name of global Lua objects that should not be persisted
- const char *STANDARD_PERMANENTS[] = {
- "string",
- "xpcall",
- "package",
- "tostring",
- "print",
- "os",
- "unpack",
- "require",
- "getfenv",
- "setmetatable",
- "next",
- "assert",
- "tonumber",
- "io",
- "rawequal",
- "collectgarbage",
- "getmetatable",
- "module",
- "rawset",
- "warning",
- "math",
- "debug",
- "pcall",
- "table",
- "newproxy",
- "type",
- "coroutine",
- "select",
- "gcinfo",
- "pairs",
- "rawget",
- "loadstring",
- "ipairs",
- "_VERSION",
- "setfenv",
- "load",
- "error",
- "loadfile",
-
- "pairs_next",
- "ipairs_next",
- "pluto",
- "Cfg",
- "Translator",
- "Persistence",
- "CommandLine",
- 0
- };
-
- // -------------------------------------------------------------------------
-
- enum PERMANENT_TABLE_TYPE {
- PTT_PERSIST,
- PTT_UNPERSIST
- };
-
- // -------------------------------------------------------------------------
-
- bool PushPermanentsTable(lua_State *L, PERMANENT_TABLE_TYPE TableType) {
- // Permanents-Table
- lua_newtable(L);
+const char *PERMANENTS_TABLE_NAME = "Permanents";
+
+// -------------------------------------------------------------------------
+
+// This array contains the name of global Lua objects that should not be persisted
+const char *STANDARD_PERMANENTS[] = {
+ "string",
+ "xpcall",
+ "package",
+ "tostring",
+ "print",
+ "os",
+ "unpack",
+ "require",
+ "getfenv",
+ "setmetatable",
+ "next",
+ "assert",
+ "tonumber",
+ "io",
+ "rawequal",
+ "collectgarbage",
+ "getmetatable",
+ "module",
+ "rawset",
+ "warning",
+ "math",
+ "debug",
+ "pcall",
+ "table",
+ "newproxy",
+ "type",
+ "coroutine",
+ "select",
+ "gcinfo",
+ "pairs",
+ "rawget",
+ "loadstring",
+ "ipairs",
+ "_VERSION",
+ "setfenv",
+ "load",
+ "error",
+ "loadfile",
+
+ "pairs_next",
+ "ipairs_next",
+ "pluto",
+ "Cfg",
+ "Translator",
+ "Persistence",
+ "CommandLine",
+ 0
+};
+
+// -------------------------------------------------------------------------
+
+enum PERMANENT_TABLE_TYPE {
+ PTT_PERSIST,
+ PTT_UNPERSIST
+};
+
+// -------------------------------------------------------------------------
+
+bool PushPermanentsTable(lua_State *L, PERMANENT_TABLE_TYPE TableType) {
+ // Permanents-Table
+ lua_newtable(L);
+
+ // All standard permanents are inserted into this table
+ unsigned int Index = 0;
+ while (STANDARD_PERMANENTS[Index]) {
+ // Permanents are placed onto the stack; if it does not exist, it is simply ignored
+ lua_getglobal(L, STANDARD_PERMANENTS[Index]);
+ if (!lua_isnil(L, -1)) {
+ // Name of the element as a unique value on the stack
+ lua_pushstring(L, STANDARD_PERMANENTS[Index]);
- // All standard permanents are inserted into this table
- unsigned int Index = 0;
- while (STANDARD_PERMANENTS[Index]) {
- // Permanents are placed onto the stack; if it does not exist, it is simply ignored
- lua_getglobal(L, STANDARD_PERMANENTS[Index]);
- if (!lua_isnil(L, -1)) {
- // Name of the element as a unique value on the stack
- lua_pushstring(L, STANDARD_PERMANENTS[Index]);
+ // If it is loaded, then it can be used
+ // In this case, the position of name and object are reversed on the stack
+ if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
- // If it is loaded, then it can be used
- // In this case, the position of name and object are reversed on the stack
- if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
+ // Make an entry in the table
+ lua_settable(L, -3);
+ } else {
+ // Pop nil value from stack
+ lua_pop(L, 1);
+ }
- // Make an entry in the table
- lua_settable(L, -3);
- }
- else {
- // Pop nil value from stack
- lua_pop(L, 1);
- }
+ ++Index;
+ }
- ++Index;
- }
-
- // All registered C functions to be inserted into the table
- // BS_LuaBindhelper places in the register a table in which all registered C functions
- // are stored
+ // All registered C functions to be inserted into the table
+ // BS_LuaBindhelper places in the register a table in which all registered C functions
+ // are stored
- // Table is put on the stack
- lua_getfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
+ // Table is put on the stack
+ lua_getfield(L, LUA_REGISTRYINDEX, PERMANENTS_TABLE_NAME);
- if (!lua_isnil(L, -1)) {
- // Iterate over all elements of the table
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- // Value and index duplicated on the stack and changed in the sequence
- lua_pushvalue(L, -1);
- lua_pushvalue(L, -3);
+ if (!lua_isnil(L, -1)) {
+ // Iterate over all elements of the table
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ // Value and index duplicated on the stack and changed in the sequence
+ lua_pushvalue(L, -1);
+ lua_pushvalue(L, -3);
- // If it is loaded, then it can be used
- // In this case, the position of name and object are reversed on the stack
- if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
+ // If it is loaded, then it can be used
+ // In this case, the position of name and object are reversed on the stack
+ if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
- // Make an entry in the results table
- lua_settable(L, -6);
+ // Make an entry in the results table
+ lua_settable(L, -6);
- // Pop value from the stack. The index is then ready for the next call to lua_next()
- lua_pop(L, 1);
- }
+ // Pop value from the stack. The index is then ready for the next call to lua_next()
+ lua_pop(L, 1);
}
+ }
- // Pop the C-Permanents table from the stack
- lua_pop(L, 1);
+ // Pop the C-Permanents table from the stack
+ lua_pop(L, 1);
- // coroutine.yield must be registered in the extra-Permanents table because they
- // are inactive coroutine C functions on the stack
+ // coroutine.yield must be registered in the extra-Permanents table because they
+ // are inactive coroutine C functions on the stack
- // Function coroutine.yield placed on the stack
- lua_getglobal(L, "coroutine");
- lua_pushstring(L, "yield");
- lua_gettable(L, -2);
+ // Function coroutine.yield placed on the stack
+ lua_getglobal(L, "coroutine");
+ lua_pushstring(L, "yield");
+ lua_gettable(L, -2);
- // Store coroutine.yield with it's own unique value in the Permanents table
- lua_pushstring(L, "coroutine.yield");
+ // Store coroutine.yield with it's own unique value in the Permanents table
+ lua_pushstring(L, "coroutine.yield");
- if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
+ if (TableType == PTT_UNPERSIST) lua_insert(L, -2);
- lua_settable(L, -4);
+ lua_settable(L, -4);
- // Coroutine table is popped from the stack
- lua_pop(L, 1);
+ // Coroutine table is popped from the stack
+ lua_pop(L, 1);
- return true;
- }
+ return true;
+}
}
// -----------------------------------------------------------------------------
namespace {
- int Chunkwriter(lua_State *L, const void *p, size_t sz, void *ud) {
- Common::Array<unsigned char> & chunkData = *reinterpret_cast<Common::Array<unsigned char> * >(ud);
- const unsigned char *buffer = reinterpret_cast<const unsigned char *>(p);
+int Chunkwriter(lua_State *L, const void *p, size_t sz, void *ud) {
+ Common::Array<unsigned char> & chunkData = *reinterpret_cast<Common::Array<unsigned char> * >(ud);
+ const unsigned char *buffer = reinterpret_cast<const unsigned char *>(p);
- while (sz--) chunkData.push_back(*buffer++) ;
+ while (sz--) chunkData.push_back(*buffer++) ;
- return 1;
- }
+ return 1;
+}
}
bool BS_LuaScriptEngine::Persist(BS_OutputPersistenceBlock &Writer) {
@@ -447,66 +448,66 @@ bool BS_LuaScriptEngine::Persist(BS_OutputPersistenceBlock &Writer) {
// -----------------------------------------------------------------------------
namespace {
- // -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
- struct ChunkreaderData {
- void * BufferPtr;
- size_t Size;
- bool BufferReturned;
- };
+struct ChunkreaderData {
+ void *BufferPtr;
+ size_t Size;
+ bool BufferReturned;
+};
- // ------------------------------------------------------------------------
+// ------------------------------------------------------------------------
- const char *Chunkreader(lua_State *L, void *ud, size_t *sz) {
- ChunkreaderData & cd = *reinterpret_cast<ChunkreaderData *>(ud);
+const char *Chunkreader(lua_State *L, void *ud, size_t *sz) {
+ ChunkreaderData &cd = *reinterpret_cast<ChunkreaderData *>(ud);
- if (!cd.BufferReturned) {
- cd.BufferReturned = true;
- *sz = cd.Size;
- return reinterpret_cast<const char *>(cd.BufferPtr);
- } else {
- return 0;
- }
+ if (!cd.BufferReturned) {
+ cd.BufferReturned = true;
+ *sz = cd.Size;
+ return reinterpret_cast<const char *>(cd.BufferPtr);
+ } else {
+ return 0;
}
+}
- // -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
- void ClearGlobalTable(lua_State *L, const char **Exceptions) {
- // Iterate over all elements of the global table
- lua_pushvalue(L, LUA_GLOBALSINDEX);
- lua_pushnil(L);
- while (lua_next(L, -2) != 0) {
- // Now the value and the index of the current element is on the stack
- // This value does not interest us, so it is popped from the stack
- lua_pop(L, 1);
+void ClearGlobalTable(lua_State *L, const char **Exceptions) {
+ // Iterate over all elements of the global table
+ lua_pushvalue(L, LUA_GLOBALSINDEX);
+ lua_pushnil(L);
+ while (lua_next(L, -2) != 0) {
+ // Now the value and the index of the current element is on the stack
+ // This value does not interest us, so it is popped from the stack
+ lua_pop(L, 1);
- // Determine whether the item is set to nil, so you want to remove from the global table.
- // For this will determine whether the element name is a string and is present in
- // the list of exceptions
- bool SetElementToNil = true;
- if (lua_isstring(L, -1)) {
- const char *IndexString = lua_tostring(L, -1);
- const char ** ExceptionsWalker = Exceptions;
- while (*ExceptionsWalker) {
- if (strcmp(IndexString, *ExceptionsWalker) == 0) SetElementToNil = false;
- ++ExceptionsWalker;
- }
+ // Determine whether the item is set to nil, so you want to remove from the global table.
+ // For this will determine whether the element name is a string and is present in
+ // the list of exceptions
+ bool SetElementToNil = true;
+ if (lua_isstring(L, -1)) {
+ const char *IndexString = lua_tostring(L, -1);
+ const char **ExceptionsWalker = Exceptions;
+ while (*ExceptionsWalker) {
+ if (strcmp(IndexString, *ExceptionsWalker) == 0) SetElementToNil = false;
+ ++ExceptionsWalker;
}
+ }
- // If the above test showed that the item should be removed, it is removed by setting the value to nil.
- if (SetElementToNil) {
- lua_pushvalue(L, -1);
- lua_pushnil(L);
- lua_settable(L, LUA_GLOBALSINDEX);
- }
- }
+ // If the above test showed that the item should be removed, it is removed by setting the value to nil.
+ if (SetElementToNil) {
+ lua_pushvalue(L, -1);
+ lua_pushnil(L);
+ lua_settable(L, LUA_GLOBALSINDEX);
+ }
+ }
- // Pop the Global table from the stack
- lua_pop(L, 1);
+ // Pop the Global table from the stack
+ lua_pop(L, 1);
- // Perform garbage collection, so that all removed elements are deleted
- lua_gc(L, LUA_GCCOLLECT, 0);
- }
+ // Perform garbage collection, so that all removed elements are deleted
+ lua_gc(L, LUA_GCCOLLECT, 0);
+}
}
// -----------------------------------------------------------------------------
@@ -516,7 +517,7 @@ bool BS_LuaScriptEngine::Unpersist(BS_InputPersistenceBlock &Reader) {
lua_settop(m_State, 0);
// Permanents table is placed on the stack. This has already happened at this point, because
- // to create the table all permanents must be accessible. This is the case only for the
+ // to create the table all permanents must be accessible. This is the case only for the
// beginning of the function, because the global table is emptied below
PushPermanentsTable(m_State, PTT_UNPERSIST);
@@ -572,7 +573,7 @@ bool BS_LuaScriptEngine::Unpersist(BS_InputPersistenceBlock &Reader) {
// The table with the loaded data is popped from the stack
lua_pop(m_State, 1);
-
+
// Force garbage collection
lua_gc(m_State, LUA_GCCOLLECT, 0);
diff --git a/engines/sword25/script/luascript.h b/engines/sword25/script/luascript.h
index f0a8a9bbdc..228625a67b 100644
--- a/engines/sword25/script/luascript.h
+++ b/engines/sword25/script/luascript.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -75,44 +75,46 @@ public:
/**
* Initialises the scripting engine
- * @return Returns true if successful, otherwise false.
+ * @return Returns true if successful, otherwise false.
*/
virtual bool Init();
/**
* Loads a script file and executes it
- * @param FileName The filename of the script
- * @return Returns true if successful, otherwise false.
+ * @param FileName The filename of the script
+ * @return Returns true if successful, otherwise false.
*/
virtual bool ExecuteFile(const Common::String &FileName);
/**
* Execute a string of script code
- * @param Code A string of script code
- * @return Returns true if successful, otherwise false.
+ * @param Code A string of script code
+ * @return Returns true if successful, otherwise false.
*/
virtual bool ExecuteString(const Common::String &Code);
/**
* Returns a pointer to the main object of the scripting language
- * @remark Using this method breaks the encapsulation of the language
+ * @remark Using this method breaks the encapsulation of the language
*/
- virtual void *GetScriptObject() { return m_State; }
+ virtual void *GetScriptObject() {
+ return m_State;
+ }
/**
* Makes the command line parameters for the scripting environment available
- * @param CommandLineParameters An array containing all the command line parameters
- * @remark How the command line parameters will be used by scripts is
+ * @param CommandLineParameters An array containing all the command line parameters
+ * @remark How the command line parameters will be used by scripts is
* dependant on the particular implementation.
*/
virtual void SetCommandLine(const Common::StringArray &CommandLineParameters);
/**
- * @remark The Lua stack is cleared by this method
+ * @remark The Lua stack is cleared by this method
*/
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
/**
- * @remark The Lua stack is cleared by this method
+ * @remark The Lua stack is cleared by this method
*/
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
diff --git a/engines/sword25/script/script.h b/engines/sword25/script/script.h
index 0363daec0f..4804324226 100644
--- a/engines/sword25/script/script.h
+++ b/engines/sword25/script/script.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -64,28 +64,28 @@ public:
// -----------------------------------------------------------------------------
// Constructor / destructor
// -----------------------------------------------------------------------------
-
- BS_ScriptEngine(BS_Kernel * KernelPtr) : BS_Service(KernelPtr) {};
+
+ BS_ScriptEngine(BS_Kernel *KernelPtr) : BS_Service(KernelPtr) {};
virtual ~BS_ScriptEngine() {};
// -----------------------------------------------------------------------------
// This method must be implemented by the script engine
// -----------------------------------------------------------------------------
-
+
/**
* Initialises the scrip tengine. Returns true if successful, false otherwise.
*/
virtual bool Init() = 0;
/**
- * Loads a script file and executes it.
- * @param FileName The script filename
+ * Loads a script file and executes it.
+ * @param FileName The script filename
*/
virtual bool ExecuteFile(const Common::String &FileName) = 0;
/**
* Executes a specified script fragment
- * @param Code String of script code
+ * @param Code String of script code
*/
virtual bool ExecuteString(const Common::String &Code) = 0;
@@ -93,13 +93,13 @@ public:
* Returns a pointer to the main object of the script engine
* Note: Using this method breaks the encapsulation of the language from the rest of the engine.
*/
- virtual void * GetScriptObject() = 0;
+ virtual void *GetScriptObject() = 0;
/**
* Makes the command line parameters for the script environment available
* Note: How the command line parameters will be used by scripts is dependant on the
* particular implementation.
- * @param CommandLineParameters List containing the command line parameters
+ * @param CommandLineParameters List containing the command line parameters
*/
virtual void SetCommandLine(const Common::Array<Common::String> &CommandLineParameters) = 0;
diff --git a/engines/sword25/sfx/fmodexchannel.cpp b/engines/sword25/sfx/fmodexchannel.cpp
index 3fbec5b682..e8992e92a6 100644
--- a/engines/sword25/sfx/fmodexchannel.cpp
+++ b/engines/sword25/sfx/fmodexchannel.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -49,16 +49,14 @@
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL * ChannelPtr, FMOD_SOUND * SoundPtr) :
+BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr) :
m_ChannelPtr(ChannelPtr),
- m_SoundPtr(SoundPtr)
-{
+ m_SoundPtr(SoundPtr) {
}
// -----------------------------------------------------------------------------
-BS_FMODExChannel::~BS_FMODExChannel()
-{
+BS_FMODExChannel::~BS_FMODExChannel() {
if (m_ChannelPtr) FMOD_Channel_Stop(m_ChannelPtr);
if (m_SoundPtr) FMOD_Sound_Release(m_SoundPtr);
}
@@ -73,125 +71,102 @@ BS_FMODExChannel::~BS_FMODExChannel()
// Diese Fehler werden daher von den folgenden Methoden ignoriert.
// -----------------------------------------------------------------------------
-namespace
-{
- bool IsImportantError(FMOD_RESULT Result)
- {
- return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
- }
+namespace {
+bool IsImportantError(FMOD_RESULT Result) {
+ return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
+}
}
// -----------------------------------------------------------------------------
// Setter
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPaused(bool Paused)
-{
+bool BS_FMODExChannel::SetPaused(bool Paused) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPaused(m_ChannelPtr, Paused ? 1 : 0);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPaused()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetVolume(float Volume)
-{
+bool BS_FMODExChannel::SetVolume(float Volume) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetVolume(m_ChannelPtr, Volume);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetVolume()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPanning(float Panning)
-{
+bool BS_FMODExChannel::SetPanning(float Panning) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPan(m_ChannelPtr, Panning);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPan()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetLoop(bool Loop)
-{
+bool BS_FMODExChannel::SetLoop(bool Loop) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetLoopCount(m_ChannelPtr, Loop ? -1 : 0);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetLoopCount()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetLoopPoints(unsigned int LoopStart, unsigned int LoopEnd)
-{
+bool BS_FMODExChannel::SetLoopPoints(unsigned int LoopStart, unsigned int LoopEnd) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetLoopPoints(m_ChannelPtr, LoopStart, FMOD_TIMEUNIT_PCM, LoopEnd, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetLoopPoints()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::SetPosition(unsigned int Position)
-{
+bool BS_FMODExChannel::SetPosition(unsigned int Position) {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_SetPosition(m_ChannelPtr, Position, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_SetPosition()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::Stop()
-{
+bool BS_FMODExChannel::Stop() {
BS_ASSERT(m_ChannelPtr);
FMOD_RESULT Result = FMOD_Channel_Stop(m_ChannelPtr);
- if (IsImportantError(Result))
- {
+ if (IsImportantError(Result)) {
BS_FMODExException("FMOD_Channel_Stop()", Result).Log();
return false;
- }
- else
+ } else
return true;
}
@@ -199,34 +174,31 @@ bool BS_FMODExChannel::Stop()
// Getter
// -----------------------------------------------------------------------------
-float BS_FMODExChannel::GetVolume()
-{
+float BS_FMODExChannel::GetVolume() {
BS_ASSERT(m_ChannelPtr);
float Volume = 0;
FMOD_RESULT Result = FMOD_Channel_GetVolume(m_ChannelPtr, &Volume);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetVolume()", Result).Log();
-
+
return Volume;
}
// -----------------------------------------------------------------------------
-float BS_FMODExChannel::GetPanning()
-{
+float BS_FMODExChannel::GetPanning() {
BS_ASSERT(m_ChannelPtr);
float Panning = 0;
FMOD_RESULT Result = FMOD_Channel_GetPan(m_ChannelPtr, &Panning);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPan()", Result).Log();
-
+
return Panning;
}
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetPosition()
-{
+unsigned int BS_FMODExChannel::GetPosition() {
BS_ASSERT(m_ChannelPtr);
unsigned int Position = 0;
@@ -238,8 +210,7 @@ unsigned int BS_FMODExChannel::GetPosition()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetTime()
-{
+unsigned int BS_FMODExChannel::GetTime() {
BS_ASSERT(m_ChannelPtr);
unsigned int Time = 0;
@@ -251,8 +222,7 @@ unsigned int BS_FMODExChannel::GetTime()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetLoopStart()
-{
+unsigned int BS_FMODExChannel::GetLoopStart() {
BS_ASSERT(m_ChannelPtr);
unsigned int LoopStart = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, &LoopStart, FMOD_TIMEUNIT_PCM, 0, FMOD_TIMEUNIT_PCM);
@@ -263,8 +233,7 @@ unsigned int BS_FMODExChannel::GetLoopStart()
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExChannel::GetLoopEnd()
-{
+unsigned int BS_FMODExChannel::GetLoopEnd() {
BS_ASSERT(m_ChannelPtr);
unsigned int LoopEnd = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, 0, FMOD_TIMEUNIT_PCM, &LoopEnd, FMOD_TIMEUNIT_PCM);
@@ -275,39 +244,36 @@ unsigned int BS_FMODExChannel::GetLoopEnd()
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsLooping()
-{
+bool BS_FMODExChannel::IsLooping() {
BS_ASSERT(m_ChannelPtr);
int LoopCount = 0;
FMOD_RESULT Result = FMOD_Channel_GetLoopCount(m_ChannelPtr, &LoopCount);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetLoopCount()", Result).Log();
-
+
return LoopCount == -1;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsPaused()
-{
+bool BS_FMODExChannel::IsPaused() {
BS_ASSERT(m_ChannelPtr);
FMOD_BOOL Paused = 0;
FMOD_RESULT Result = FMOD_Channel_GetPaused(m_ChannelPtr, &Paused);
if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPaused()", Result).Log();
-
+
return Paused != 0;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExChannel::IsPlaying()
-{
+bool BS_FMODExChannel::IsPlaying() {
BS_ASSERT(m_ChannelPtr);
FMOD_BOOL Playing = 0;
FMOD_RESULT Result = FMOD_Channel_IsPlaying(m_ChannelPtr, &Playing);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_IsPlaying()", Result).Log();
+ if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_IsPlaying()", Result).Log();
return Playing != 0;
}
diff --git a/engines/sword25/sfx/fmodexchannel.h b/engines/sword25/sfx/fmodexchannel.h
index 1cab70956b..9d8b64f3b4 100644
--- a/engines/sword25/sfx/fmodexchannel.h
+++ b/engines/sword25/sfx/fmodexchannel.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,10 +52,9 @@ struct FMOD_SOUND;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExChannel
-{
+class BS_FMODExChannel {
public:
- BS_FMODExChannel(FMOD_CHANNEL * ChannelPtr, FMOD_SOUND * SoundPtr);
+ BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr);
virtual ~BS_FMODExChannel();
bool SetPaused(bool Paused);
@@ -66,19 +65,19 @@ public:
bool SetPosition(unsigned int Position);
bool Stop();
- float GetVolume();
- float GetPanning();
- unsigned int GetPosition();
- unsigned int GetTime();
- unsigned int GetLoopStart();
- unsigned int GetLoopEnd();
- bool IsLooping();
- bool IsPaused();
- bool IsPlaying();
+ float GetVolume();
+ float GetPanning();
+ unsigned int GetPosition();
+ unsigned int GetTime();
+ unsigned int GetLoopStart();
+ unsigned int GetLoopEnd();
+ bool IsLooping();
+ bool IsPaused();
+ bool IsPlaying();
private:
- FMOD_CHANNEL * m_ChannelPtr;
- FMOD_SOUND * m_SoundPtr;
+ FMOD_CHANNEL *m_ChannelPtr;
+ FMOD_SOUND *m_SoundPtr;
};
#endif
diff --git a/engines/sword25/sfx/fmodexexception.h b/engines/sword25/sfx/fmodexexception.h
index 7be4d6d978..05e6d82310 100644
--- a/engines/sword25/sfx/fmodexexception.h
+++ b/engines/sword25/sfx/fmodexexception.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,21 +45,19 @@
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExException
-{
+class BS_FMODExException {
public:
- BS_FMODExException(const char * Function_, FMOD_RESULT Result_) :
+ BS_FMODExException(const char *Function_, FMOD_RESULT Result_) :
Function(Function_),
Result(Result_) {}
- const char * Function;
- FMOD_RESULT Result;
+ const char *Function;
+ FMOD_RESULT Result;
- void Log()
- {
- BS_LOG_ERROR("Call to %s failed.", Function);
- BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
- }
+ void Log() {
+ BS_LOG_ERROR("Call to %s failed.", Function);
+ BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
+ }
};
#endif
diff --git a/engines/sword25/sfx/fmodexresource.cpp b/engines/sword25/sfx/fmodexresource.cpp
index 089458f9f5..2a987695bd 100644
--- a/engines/sword25/sfx/fmodexresource.cpp
+++ b/engines/sword25/sfx/fmodexresource.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -52,9 +52,8 @@
// Konstanten
// -----------------------------------------------------------------------------
-namespace
-{
- const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
+namespace {
+const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
}
// -----------------------------------------------------------------------------
@@ -62,29 +61,26 @@ namespace
// -----------------------------------------------------------------------------
-BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM * FMOD, bool & Success) :
+BS_FMODExResource::BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success) :
m_SoundPtr(0),
m_SoundDataPtr(0),
- BS_Resource(FileName, BS_Resource::TYPE_SOUND)
-{
+ BS_Resource(FileName, BS_Resource::TYPE_SOUND) {
BS_ASSERT(FMOD);
// Von Misserfolg ausgehen
Success = false;
// Pointer auf den Package-Manager bekommen
- BS_PackageManager * PackagePtr = BS_Kernel::GetInstance()->GetPackage();
- if (!PackagePtr)
- {
+ BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
+ if (!PackagePtr) {
BS_LOG_ERRORLN("Package manager not found.");
return;
}
// Datei laden
- unsigned int FileSize;
- char * FileDataPtr = (char*) PackagePtr->GetFile(GetFileName(), &FileSize);
- if (!FileDataPtr)
- {
+ unsigned int FileSize;
+ char *FileDataPtr = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
+ if (!FileDataPtr) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", GetFileName().c_str());
return;
}
@@ -93,25 +89,22 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
// Samples werden sofort intialisiert.
// Für Streams wird hingegen bei jedem Abspielen ein neuer Sound erstellt. Dieses Vorgehen ist notwendig, da FMOD Ex Samples beliebig oft
// gleichzeitig abspielen kann, Streams jedoch nur ein mal.
- if (FileSize <= MAX_SAMPLE_SIZE)
- {
+ if (FileSize <= MAX_SAMPLE_SIZE) {
FMOD_CREATESOUNDEXINFO ExInfo;
memset(&ExInfo, 0, sizeof(ExInfo));
ExInfo.cbsize = sizeof(ExInfo);
ExInfo.length = FileSize;
FMOD_RESULT Result = FMOD_System_CreateSound(FMOD, FileDataPtr,
- FMOD_CREATESAMPLE | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &m_SoundPtr);
+ FMOD_CREATESAMPLE | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
+ &ExInfo,
+ &m_SoundPtr);
if (Result != FMOD_OK) BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
Success = Result == FMOD_OK;
delete FileDataPtr;
- }
- else
- {
+ } else {
m_SoundDataPtr = FileDataPtr;
m_SoundDataSize = FileSize;
@@ -121,8 +114,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
// -----------------------------------------------------------------------------
-BS_FMODExResource::~BS_FMODExResource()
-{
+BS_FMODExResource::~BS_FMODExResource() {
// Sound freigeben, solange des Soundsystem noch läuft.
// Sollte das Soundsystem beendet worden sein müssen und können Sounds nicht mehr freigegeben werden.
if (m_SoundPtr && BS_Kernel::GetInstance()->GetService("sfx")) FMOD_Sound_Release(m_SoundPtr);
@@ -133,26 +125,22 @@ BS_FMODExResource::~BS_FMODExResource()
// Abspielen
// -----------------------------------------------------------------------------
-BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
-{
+BS_FMODExChannel *BS_FMODExResource::StartSound(FMOD_SYSTEM *FMOD) {
BS_ASSERT(FMOD);
- FMOD_CHANNEL * NewChannelPtr;
- FMOD_SOUND * NewSoundPtr = 0;
+ FMOD_CHANNEL *NewChannelPtr;
+ FMOD_SOUND *NewSoundPtr = 0;
// Sample können sofort abgespielt werden.
- if (m_SoundPtr)
- {
+ if (m_SoundPtr) {
FMOD_RESULT Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, m_SoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
return 0;
}
}
// Für Streams muss ein neuer Sound erstellt werden.
- else
- {
+ else {
FMOD_CREATESOUNDEXINFO ExInfo;
memset(&ExInfo, 0, sizeof(ExInfo));
ExInfo.cbsize = sizeof(ExInfo);
@@ -160,19 +148,17 @@ BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
FMOD_RESULT Result;
Result = FMOD_System_CreateSound(FMOD,
- m_SoundDataPtr,
- FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &NewSoundPtr);
- if (Result != FMOD_OK)
- {
+ m_SoundDataPtr,
+ FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
+ &ExInfo,
+ &NewSoundPtr);
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
return 0;
}
Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, NewSoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
return 0;
}
diff --git a/engines/sword25/sfx/fmodexresource.h b/engines/sword25/sfx/fmodexresource.h
index c6fd03a5b4..b8a6a07e1f 100644
--- a/engines/sword25/sfx/fmodexresource.h
+++ b/engines/sword25/sfx/fmodexresource.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -54,18 +54,17 @@ struct FMOD_SYSTEM;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExResource : public BS_Resource
-{
+class BS_FMODExResource : public BS_Resource {
public:
- BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM * FMOD, bool & Success);
+ BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success);
virtual ~BS_FMODExResource();
- BS_FMODExChannel * StartSound(FMOD_SYSTEM * FMOD);
+ BS_FMODExChannel *StartSound(FMOD_SYSTEM *FMOD);
private:
- FMOD_SOUND * m_SoundPtr;
- char * m_SoundDataPtr;
- unsigned int m_SoundDataSize;
+ FMOD_SOUND *m_SoundPtr;
+ char *m_SoundDataPtr;
+ unsigned int m_SoundDataSize;
};
#endif
diff --git a/engines/sword25/sfx/fmodexsound.cpp b/engines/sword25/sfx/fmodexsound.cpp
index e51c1e9874..49c87b9073 100644
--- a/engines/sword25/sfx/fmodexsound.cpp
+++ b/engines/sword25/sfx/fmodexsound.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -59,82 +59,77 @@
// Konstanten und lokale Funktionen
// -----------------------------------------------------------------------------
-namespace
-{
- const float DEFAULT_MUSIC_VOLUME = 1.0f;
- const float DEFAULT_SPEECH_VOLUME = 1.0f;
- const float DEFAULT_SFX_VOLUME = 1.0f;
- const unsigned int SOUNDTYPE_COUNT = 3;
- const unsigned int INVALID_SOUND_HANDLE = 0xffffffff;
+namespace {
+const float DEFAULT_MUSIC_VOLUME = 1.0f;
+const float DEFAULT_SPEECH_VOLUME = 1.0f;
+const float DEFAULT_SFX_VOLUME = 1.0f;
+const unsigned int SOUNDTYPE_COUNT = 3;
+const unsigned int INVALID_SOUND_HANDLE = 0xffffffff;
- // -------------------------------------------------------------------------
-
- inline float NormalizePanning(float Panning)
- {
- bool Corrected = false;
- float Result = Panning;
- if (Result > 1.0f)
- {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < -1.0f)
- {
- Result = -1.0f;
- Corrected = true;
- }
-
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid panning value of %.2f. It was corrected to %.2f", Panning, Result);
+// -------------------------------------------------------------------------
- return Result;
+inline float NormalizePanning(float Panning) {
+ bool Corrected = false;
+ float Result = Panning;
+ if (Result > 1.0f) {
+ Result = 1.0f;
+ Corrected = true;
+ }
+ if (Result < -1.0f) {
+ Result = -1.0f;
+ Corrected = true;
}
- // -------------------------------------------------------------------------
+ if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid panning value of %.2f. It was corrected to %.2f", Panning, Result);
- inline float NormalizeVolume(float Volume)
- {
- bool Corrected = false;
- float Result = Volume;
- if (Result> 1.0f)
- {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < 0.0f)
- {
- Result = 0.0f;
- Corrected = true;
- }
+ return Result;
+}
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid volume value of %.2f. It was corrected to %.2f", Volume, Result);
+// -------------------------------------------------------------------------
- return Result;
+inline float NormalizeVolume(float Volume) {
+ bool Corrected = false;
+ float Result = Volume;
+ if (Result > 1.0f) {
+ Result = 1.0f;
+ Corrected = true;
+ }
+ if (Result < 0.0f) {
+ Result = 0.0f;
+ Corrected = true;
}
- // -------------------------------------------------------------------------
+ if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid volume value of %.2f. It was corrected to %.2f", Volume, Result);
- inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample)
- {
- switch (BitsPerSample)
- {
- case 8: return FMOD_SOUND_FORMAT_PCM8;
- case 16: return FMOD_SOUND_FORMAT_PCM16;
- case 24: return FMOD_SOUND_FORMAT_PCM24;
- case 32: return FMOD_SOUND_FORMAT_PCM32;
- default: return FMOD_SOUND_FORMAT_NONE;
- }
+ return Result;
+}
+
+// -------------------------------------------------------------------------
+
+inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample) {
+ switch (BitsPerSample) {
+ case 8:
+ return FMOD_SOUND_FORMAT_PCM8;
+ case 16:
+ return FMOD_SOUND_FORMAT_PCM16;
+ case 24:
+ return FMOD_SOUND_FORMAT_PCM24;
+ case 32:
+ return FMOD_SOUND_FORMAT_PCM32;
+ default:
+ return FMOD_SOUND_FORMAT_NONE;
}
}
+}
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-BS_FMODExSound::BS_FMODExSound(BS_Kernel* pKernel) :
+BS_FMODExSound::BS_FMODExSound(BS_Kernel *pKernel) :
BS_SoundEngine(pKernel),
m_FMOD(0),
- m_NextHandle(1)
-{
+ m_NextHandle(1) {
// Lautstärkeneinstellungen auf die Standardwerte setzen
m_Volumes[MUSIC] = DEFAULT_MUSIC_VOLUME;
m_Volumes[SPEECH] = DEFAULT_SPEECH_VOLUME;
@@ -143,11 +138,9 @@ BS_FMODExSound::BS_FMODExSound(BS_Kernel* pKernel) :
// -----------------------------------------------------------------------------
-BS_FMODExSound::~BS_FMODExSound()
-{
+BS_FMODExSound::~BS_FMODExSound() {
// Alle noch spielenden Sounds stoppen und die Ressourcen freigeben
- for (PSM_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it)
- {
+ for (PSM_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) {
if (it->second.ChannelPtr) delete it->second.ChannelPtr;
if (it->second.ResourcePtr) it->second.ResourcePtr->Release();
}
@@ -158,23 +151,20 @@ BS_FMODExSound::~BS_FMODExSound()
// -----------------------------------------------------------------------------
-BS_Service * BS_FMODExSound_CreateObject(BS_Kernel* pKernel) { return new BS_FMODExSound(pKernel); }
+BS_Service *BS_FMODExSound_CreateObject(BS_Kernel *pKernel) {
+ return new BS_FMODExSound(pKernel);
+}
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
-{
+bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels) {
// Eine Warnung ausgeben, wenn dieser Service schon initialisiert wurde.
// Allerdings wird trotzdem true zurückgegeben, weil kein Fehler aufgetreten ist, der Service ist noch benutzbar.
- if (m_FMOD)
- {
+ if (m_FMOD) {
BS_LOG_WARNINGLN("Tried to initialize again. Call ignored.");
return true;
- }
- else
- {
- try
- {
+ } else {
+ try {
// Die FMOD Ex mit den übergebenen Werte initialisieren
FMOD_RESULT Result = FMOD_System_Create(&m_FMOD);
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Create()", Result));
@@ -186,20 +176,18 @@ bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Init()", Result));
}
- catch(BS_FMODExException Ex)
- {
+ catch (BS_FMODExException Ex) {
Ex.Log();
BS_LOG_ERRORLN("FMOD Ex could not be initialized.");
- if (m_FMOD)
- {
+ if (m_FMOD) {
FMOD_System_Release(m_FMOD);
m_FMOD = 0;
}
return false;
}
-
+
BS_LOGLN("FMOD Ex initialized. Sample rate: %d / Channels: %d", SampleRate, Channels);
return true;
}
@@ -207,8 +195,7 @@ bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::Update()
-{
+void BS_FMODExSound::Update() {
BS_ASSERT(m_FMOD);
FMOD_RESULT Result = FMOD_System_Update(m_FMOD);
@@ -221,56 +208,51 @@ void BS_FMODExSound::Update()
// Sounds abspielen
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::PlaySound(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer)
-{
+bool BS_FMODExSound::PlaySound(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer) {
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0) != 0;
}
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::PlaySoundEx(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer)
-{
+unsigned int BS_FMODExSound::PlaySoundEx(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer) {
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0);
}
// -------------------------------------------------------------------------
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
-{
+FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype) {
// In dynamischen Sounds wird nicht gesprungen, daher tut dieses Funktion nichts.
return FMOD_OK;
}
// -------------------------------------------------------------------------
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
-{
+FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen) {
// Handle auf das aktuelle Soundsystem holen, dies ist wohl dieses hier.
- BS_FMODExSound * t = reinterpret_cast<BS_FMODExSound *>(BS_Kernel::GetInstance()->GetSfx());
+ BS_FMODExSound *t = reinterpret_cast<BS_FMODExSound *>(BS_Kernel::GetInstance()->GetSfx());
// Handle auf den richtigen Sound holen, wurde als FMOD Ex Benutzerdaten gesetzt.
unsigned int Handle;
FMOD_RESULT Result = FMOD_Sound_GetUserData(sound, reinterpret_cast<void **>(&Handle));
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_Sound_GetUserData()", Result).Log();
return FMOD_OK;
}
// Sounddaten holen und Callbackfunktion aufrufen.
- PlayingSoundData * PSD = t->GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSD = t->GetPlayingSoundDataByHandle(Handle);
if (PSD) PSD->ReadCallback(PSD->UserData, data, datalen);
return FMOD_OK;
@@ -279,23 +261,20 @@ FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND
// -----------------------------------------------------------------------------
unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback,
- void * UserData,
- SOUND_TYPES Type,
- unsigned int SampleRate,
- unsigned int BitsPerSample,
- unsigned int Channels,
- float Volume,
- float Pan,
- unsigned int Layer)
-{
+ void *UserData,
+ SOUND_TYPES Type,
+ unsigned int SampleRate,
+ unsigned int BitsPerSample,
+ unsigned int Channels,
+ float Volume,
+ float Pan,
+ unsigned int Layer) {
// Parameter überprüfen
- if (BitsPerSampleToFMODExSoundFormat(BitsPerSample) == FMOD_SOUND_FORMAT_NONE)
- {
+ if (BitsPerSampleToFMODExSoundFormat(BitsPerSample) == FMOD_SOUND_FORMAT_NONE) {
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d bits per sample.", BitsPerSample);
return 0;
}
- if (Channels == 0 || Channels > 2)
- {
+ if (Channels == 0 || Channels > 2) {
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d channels.", Channels);
return 0;
}
@@ -320,35 +299,33 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
CreateSoundExInfo.format = BitsPerSampleToFMODExSoundFormat(BitsPerSample);
CreateSoundExInfo.pcmreadcallback = FMODExDynamicSoundReadCallback;
CreateSoundExInfo.pcmsetposcallback = FMODExDynamicSoundSetPosCallback;
- CreateSoundExInfo.userdata = reinterpret_cast<void *>(Handle);
+ CreateSoundExInfo.userdata = reinterpret_cast<void *>(Handle);
- FMOD_SOUND * FMODExSoundPtr;
+ FMOD_SOUND *FMODExSoundPtr;
FMOD_RESULT Result = FMOD_System_CreateSound(m_FMOD,
- 0,
- FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
- &CreateSoundExInfo,
- &FMODExSoundPtr);
- if (Result != FMOD_OK)
- {
+ 0,
+ FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
+ &CreateSoundExInfo,
+ &FMODExSoundPtr);
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_CreateSound() from PlayDynamicSoundEx()", Result).Log();
return 0;
}
// Neu erstellten Sound einem Kanal zuweisen
- FMOD_CHANNEL * FMODExChannelPtr;
+ FMOD_CHANNEL *FMODExChannelPtr;
Result = FMOD_System_PlaySound(m_FMOD, FMOD_CHANNEL_FREE, FMODExSoundPtr, 1, &FMODExChannelPtr);
- if (Result != FMOD_OK)
- {
+ if (Result != FMOD_OK) {
BS_FMODExException("FMOD_System_PlaySound() from PlayDynamicSoundEx()", Result).Log();
return 0;
}
// FMOD Ex Kanal an einen BS_FMODExChannel binden und abspielen
- BS_FMODExChannel * ChannelPtr = new BS_FMODExChannel(FMODExChannelPtr, FMODExSoundPtr);
+ BS_FMODExChannel *ChannelPtr = new BS_FMODExChannel(FMODExChannelPtr, FMODExSoundPtr);
ChannelPtr->SetPaused(false);
// ChannelPtr in die PlayingSoundData-Struktur eintragen
- PlayingSoundData * PSD = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSD = GetPlayingSoundDataByHandle(Handle);
if (PSD) PSD->ChannelPtr = ChannelPtr;
return Handle;
@@ -356,70 +333,61 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- unsigned int Layer,
- unsigned int Position,
- unsigned int Handle)
-{
+unsigned int BS_FMODExSound::PlaySoundInternal(const std::string &FileName,
+ SOUND_TYPES Type,
+ float Volume,
+ float Pan,
+ bool Loop,
+ int LoopStart, int LoopEnd,
+ unsigned int Layer,
+ unsigned int Position,
+ unsigned int Handle) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
// Resource anfordern
- BS_Resource * ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
- if (!ResourcePtr)
- {
+ BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
+ if (!ResourcePtr) {
BS_LOG_ERRORLN("Could not request resource \"%s\".", FileName.c_str());
return 0;
}
- if (ResourcePtr->GetType() != BS_Resource::TYPE_SOUND)
- {
+ if (ResourcePtr->GetType() != BS_Resource::TYPE_SOUND) {
BS_LOG_ERRORLN("Requested resource \"%s\" is not a sound.", FileName.c_str());
return 0;
}
- BS_FMODExResource * SoundResourcePtr = static_cast<BS_FMODExResource *>(ResourcePtr);
+ BS_FMODExResource *SoundResourcePtr = static_cast<BS_FMODExResource *>(ResourcePtr);
// Sound im Pause-Modus starten
- BS_FMODExChannel * ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
+ BS_FMODExChannel *ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
- if (ChannelPtr)
- {
- try
- {
+ if (ChannelPtr) {
+ try {
// Falls der Sound gelooped wird, Loop-Points setzen
- if (Loop)
- {
+ if (Loop) {
// Bestimmen, welche Loop-Points benutzt werden. Falls ein Loop-Point als Parameter nicht spezifiziert wurde (Wert -1),
// wird der Loop-Point von FMOD Ex benutzt.
unsigned int RealLoopStart = (LoopStart > 0) ? LoopStart : ChannelPtr->GetLoopStart();
unsigned int RealLoopEnd = (LoopEnd > 0) ? LoopEnd : ChannelPtr->GetLoopEnd();
// Loop-Points auf Gültigkeit überprüfen
- if (RealLoopStart > RealLoopEnd)
- {
+ if (RealLoopStart > RealLoopEnd) {
BS_LOG_ERRORLN("Loop start (%d) was placed after loop end (%d) for sound \"%s\".",
- RealLoopStart, RealLoopEnd,
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopStart, RealLoopEnd,
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
- if (RealLoopStart > ChannelPtr->GetLoopEnd())
- {
+ if (RealLoopStart > ChannelPtr->GetLoopEnd()) {
BS_LOG_ERRORLN("Loop start (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopStart,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopStart,
+ ChannelPtr->GetLoopEnd(),
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
- if (RealLoopEnd > ChannelPtr->GetLoopEnd())
- {
+ if (RealLoopEnd > ChannelPtr->GetLoopEnd()) {
BS_LOG_ERRORLN("Loop end (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopEnd,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
+ RealLoopEnd,
+ ChannelPtr->GetLoopEnd(),
+ SoundResourcePtr->GetFileName().c_str());
throw(0);
}
@@ -432,12 +400,10 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
if (!ChannelPtr->SetPanning(NormalizePanning(Pan))) throw(0);
if (!ChannelPtr->SetLoop(Loop)) throw(0);
if (!ChannelPtr->SetPosition(Position)) throw(0);
- }
- catch (...)
- {
+ } catch (...) {
delete ChannelPtr;
SoundResourcePtr->Release();
- return 0;
+ return 0;
}
unsigned int MyLoopStart = ChannelPtr->GetLoopStart();
@@ -452,9 +418,7 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
m_PlayingSoundsMap[NewHandle] = PlayingSoundData(SoundResourcePtr, ChannelPtr, Type, Layer, Volume);
return NewHandle;
- }
- else
- {
+ } else {
SoundResourcePtr->Release();
return 0;
}
@@ -464,17 +428,15 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
// Sonstige Methoden
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type)
-{
+void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
m_Volumes[Type] = NormalizeVolume(Volume);
// Alle Volumen der Sounds der Kategorie aktualisieren
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr && PSD.Type == Type) PSD.ChannelPtr->SetVolume(Volume * PSD.Volume);
++it;
@@ -483,8 +445,7 @@ void BS_FMODExSound::SetVolume(float Volume, SOUND_TYPES Type)
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetVolume(SOUND_TYPES Type)
-{
+float BS_FMODExSound::GetVolume(SOUND_TYPES Type) {
BS_ASSERT(m_FMOD);
BS_ASSERT(Type < SOUNDTYPE_COUNT);
return m_Volumes[Type];
@@ -492,17 +453,15 @@ float BS_FMODExSound::GetVolume(SOUND_TYPES Type)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseAll()
-{
+void BS_FMODExSound::PauseAll() {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen und alle pausieren.
- // Diese werden dann markiert, damit ResumeAll() feststellen kann, welche Sounds mit PauseAll() pausiert wurden.
+ // Diese werden dann markiert, damit ResumeAll() feststellen kann, welche Sounds mit PauseAll() pausiert wurden.
// ResumeAll() setzt dann nur diejenigen fort, die nur über PauseAll() pausiert wurden.
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
PSD.PausedGlobal = true;
@@ -513,19 +472,16 @@ void BS_FMODExSound::PauseAll()
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeAll()
-{
+void BS_FMODExSound::ResumeAll() {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen, die gloable Pause aufheben und diejenigen fortsetzen,
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.PausedGlobal)
- {
+ if (PSD.PausedGlobal) {
PSD.PausedGlobal = false;
if (PSD.ChannelPtr && !PSD.PausedLayer && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
}
@@ -536,20 +492,17 @@ void BS_FMODExSound::ResumeAll()
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseLayer(unsigned int Layer)
-{
+void BS_FMODExSound::PauseLayer(unsigned int Layer) {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen und alle pausieren, die sich auf den angegebenen Layer befinden.
- // Diese werden dann markiert, damit ResumeLayer() feststellen kann, welche Sounds mit PauseLayer() pausiert wurden.
+ // Diese werden dann markiert, damit ResumeLayer() feststellen kann, welche Sounds mit PauseLayer() pausiert wurden.
// ResumeLayer() setzt dann nur diejenigen fort, die nur über PauseLayer() mit der entsprechenden Layer-Nummer pausiert wurden.
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.Layer == Layer)
- {
+ if (PSD.Layer == Layer) {
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
PSD.PausedLayer = true;
}
@@ -560,19 +513,16 @@ void BS_FMODExSound::PauseLayer(unsigned int Layer)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeLayer(unsigned int Layer)
-{
+void BS_FMODExSound::ResumeLayer(unsigned int Layer) {
BS_ASSERT(m_FMOD);
// Alle Sounds durchgehen, die Layer-Pause aufheben und diejenigen fortsetzen,
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ PlayingSoundData &PSD = it->second;
- if (PSD.PausedLayer && PSD.Layer == Layer)
- {
+ if (PSD.PausedLayer && PSD.Layer == Layer) {
PSD.PausedLayer = false;
if (PSD.ChannelPtr && !PSD.PausedGlobal && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
}
@@ -585,30 +535,26 @@ void BS_FMODExSound::ResumeLayer(unsigned int Layer)
// Sound Setter
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume)
-{
+void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr) if (PSDPtr->ChannelPtr && PSDPtr->ChannelPtr->SetVolume(NormalizeVolume(Volume) * m_Volumes[PSDPtr->Type])) PSDPtr->Volume = Volume;
}
// -----------------------------------------------------------------------------
-void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan)
-{
+void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPanning(NormalizePanning(Pan));
}
// -----------------------------------------------------------------------------
-void BS_FMODExSound::PauseSound(unsigned int Handle)
-{
+void BS_FMODExSound::PauseSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr)
- {
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ if (PSDPtr) {
PSDPtr->Paused = true;
if (PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPaused(true);
}
@@ -616,12 +562,10 @@ void BS_FMODExSound::PauseSound(unsigned int Handle)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::ResumeSound(unsigned int Handle)
-{
+void BS_FMODExSound::ResumeSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr)
- {
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ if (PSDPtr) {
PSDPtr->Paused = false;
if (PSDPtr->ChannelPtr && !PSDPtr->PausedGlobal && !PSDPtr->PausedLayer) PSDPtr->ChannelPtr->SetPaused(false);
}
@@ -629,10 +573,9 @@ void BS_FMODExSound::ResumeSound(unsigned int Handle)
// -----------------------------------------------------------------------------
-void BS_FMODExSound::StopSound(unsigned int Handle)
-{
+void BS_FMODExSound::StopSound(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->Stop();
}
@@ -640,50 +583,45 @@ void BS_FMODExSound::StopSound(unsigned int Handle)
// Sound Getter
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::IsSoundPaused(unsigned int Handle)
-{
+bool BS_FMODExSound::IsSoundPaused(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPaused();
return false;
}
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle)
-{
+bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPlaying();
return false;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundVolume(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundVolume(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr) return PSDPtr->Volume;
return 0;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundPanning(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundPanning(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->GetPanning();
return 0;
}
// -----------------------------------------------------------------------------
-float BS_FMODExSound::GetSoundTime(unsigned int Handle)
-{
+float BS_FMODExSound::GetSoundTime(unsigned int Handle) {
BS_ASSERT(m_FMOD);
- PlayingSoundData * PSDPtr = GetPlayingSoundDataByHandle(Handle);
+ PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
if (PSDPtr && PSDPtr->ChannelPtr) return static_cast<float>(PSDPtr->ChannelPtr->GetTime()) / 1000.0f;
return 0;
}
@@ -692,21 +630,17 @@ float BS_FMODExSound::GetSoundTime(unsigned int Handle)
// Hilfsmethoden
// -----------------------------------------------------------------------------
-void BS_FMODExSound::RemoveInactiveSounds()
-{
+void BS_FMODExSound::RemoveInactiveSounds() {
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying())
- {
- PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying()) {
+ PlayingSoundData &PSD = it->second;
delete PSD.ChannelPtr;
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
it = m_PlayingSoundsMap.erase(it);
- }
- else
+ } else
++it;
}
@@ -714,16 +648,15 @@ void BS_FMODExSound::RemoveInactiveSounds()
static size_t lastActiveChannels = 0;
if (m_PlayingSoundsMap.size() != lastActiveChannels)
{
- BS_LOGLN("Aktive Kanaele: %d", m_PlayingSoundsMap.size());
- lastActiveChannels = m_PlayingSoundsMap.size();
+ BS_LOGLN("Aktive Kanaele: %d", m_PlayingSoundsMap.size());
+ lastActiveChannels = m_PlayingSoundsMap.size();
}
*/
}
// -----------------------------------------------------------------------------
-BS_FMODExSound::PlayingSoundData * BS_FMODExSound::GetPlayingSoundDataByHandle(unsigned int Handle)
-{
+BS_FMODExSound::PlayingSoundData *BS_FMODExSound::GetPlayingSoundDataByHandle(unsigned int Handle) {
// Zum Soundhandle gehörige Daten in der Hash-Map finden
PSM_ITER it = m_PlayingSoundsMap.find(Handle);
// Falls die Daten nicht gefunden werden konnten, Fehler zurückgebene, ansonsten ein Pointer auf die Daten.
@@ -733,8 +666,7 @@ BS_FMODExSound::PlayingSoundData * BS_FMODExSound::GetPlayingSoundDataByHandle(u
// -----------------------------------------------------------------------------
-unsigned int BS_FMODExSound::CountPlayingDynamicSounds()
-{
+unsigned int BS_FMODExSound::CountPlayingDynamicSounds() {
unsigned int Result = 0;
for (PSM_CONST_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) if (!it->second.ResourcePtr) ++Result;
@@ -745,33 +677,28 @@ unsigned int BS_FMODExSound::CountPlayingDynamicSounds()
// Ressourcen-Verwaltung
// -----------------------------------------------------------------------------
-BS_Resource * BS_FMODExSound::LoadResource(const std::string& FileName)
-{
+BS_Resource *BS_FMODExSound::LoadResource(const std::string &FileName) {
BS_ASSERT(m_FMOD);
BS_ASSERT(CanLoadResource(FileName));
bool Success;
- BS_FMODExResource * ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
+ BS_FMODExResource *ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
if (Success)
return ResourcePtr;
- else
- {
+ else {
delete ResourcePtr;
return 0;
}
}
-bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
-{
- if (FileName.size() >= 4)
- {
+bool BS_FMODExSound::CanLoadResource(const std::string &FileName) {
+ if (FileName.size() >= 4) {
std::string Extension(FileName.end() - 4, FileName.end());
- BS_String::ToLower(Extension);
+ BS_String::ToLower(Extension);
- return Extension == ".wav" ||
- Extension == ".ogg" ||
- Extension == ".mp3";
- }
- else
+ return Extension == ".wav" ||
+ Extension == ".ogg" ||
+ Extension == ".mp3";
+ } else
return false;
}
@@ -779,8 +706,7 @@ bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
// Persistenz
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
-{
+bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock &Writer) {
BS_ASSERT(m_FMOD);
// Alle inaktiven Sounds entfernen, damit kein unnötiger Ballast gespeichert wird
@@ -798,12 +724,10 @@ bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
// Informationen für jeden spielenden (nicht dynamischen) Sound speichern
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
- if (PSD.ResourcePtr)
- {
+ if (PSD.ResourcePtr) {
// Handle speichern
Writer.Write(it->first);
@@ -831,15 +755,13 @@ bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
// -----------------------------------------------------------------------------
-bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
-{
+bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock &Reader) {
BS_ASSERT(m_FMOD);
// Alle Sounds stoppen
PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end())
- {
- const PlayingSoundData & PSD = it->second;
+ while (it != m_PlayingSoundsMap.end()) {
+ const PlayingSoundData &PSD = it->second;
if (PSD.ChannelPtr) delete PSD.ChannelPtr;
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
++it;
@@ -847,7 +769,7 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
// Sound-Map leeren
m_PlayingSoundsMap.clear();
-
+
// Nächstes Handle laden
Reader.Read(m_NextHandle);
@@ -856,22 +778,21 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(SoundCount);
// Informationen über jeden spielenden Sound einlesen und ihn mit den Parametern abspielen
- for (unsigned int i = 0; i < SoundCount; ++i)
- {
- unsigned int Handle;
- std::string FileName;
- unsigned int Type;
- unsigned int Layer;
-
- float Volume;
- float Pan;
- bool Loop;
- unsigned int LoopStart;
- unsigned int LoopEnd;
- unsigned int Position;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
+ for (unsigned int i = 0; i < SoundCount; ++i) {
+ unsigned int Handle;
+ std::string FileName;
+ unsigned int Type;
+ unsigned int Layer;
+
+ float Volume;
+ float Pan;
+ bool Loop;
+ unsigned int LoopStart;
+ unsigned int LoopEnd;
+ unsigned int Position;
+ bool Paused;
+ bool PausedLayer;
+ bool PausedGlobal;
Reader.Read(Handle);
Reader.Read(FileName);
@@ -888,12 +809,9 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
Reader.Read(PausedLayer);
Reader.Read(PausedGlobal);
- if (Reader.IsGood())
- {
+ if (Reader.IsGood()) {
PlaySoundInternal(FileName, (SOUND_TYPES) Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, Position, Handle);
- }
- else
- {
+ } else {
return false;
}
}
diff --git a/engines/sword25/sfx/fmodexsound.h b/engines/sword25/sfx/fmodexsound.h
index 3b1a5f640a..a32d6bb4d8 100644
--- a/engines/sword25/sfx/fmodexsound.h
+++ b/engines/sword25/sfx/fmodexsound.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -60,54 +60,52 @@ struct FMOD_CHANNEL;
// Klassendefinition
// -----------------------------------------------------------------------------
-class BS_FMODExSound : public BS_SoundEngine
-{
+class BS_FMODExSound : public BS_SoundEngine {
public:
// -----------------------------------------------------------------------------
// Konstruktion / Destruktion
// -----------------------------------------------------------------------------
-
- BS_FMODExSound(BS_Kernel* pKernel);
+
+ BS_FMODExSound(BS_Kernel *pKernel);
virtual ~BS_FMODExSound();
- bool Init(unsigned int SampleRate, unsigned int Channels = 32);
- void Update();
- void SetVolume(float Volume, SOUND_TYPES Type);
- float GetVolume(SOUND_TYPES Type);
- void PauseAll();
- void ResumeAll();
- void PauseLayer(unsigned int Layer);
- void ResumeLayer(unsigned int Layer);
- bool PlaySound(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
- unsigned int PlaySoundEx(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
- unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void * UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0);
-
- void SetSoundVolume(unsigned int Handle, float Volume);
- void SetSoundPanning(unsigned int Handle, float Pan);
- void PauseSound(unsigned int Handle);
- void ResumeSound(unsigned int Handle);
- void StopSound(unsigned int Handle);
- bool IsSoundPaused(unsigned int Handle);
- bool IsSoundPlaying(unsigned int Handle);
- float GetSoundVolume(unsigned int Handle);
- float GetSoundPanning(unsigned int Handle);
- float GetSoundTime(unsigned int Handle);
-
- BS_Resource * LoadResource(const std::string& FileName);
- bool CanLoadResource(const std::string& FileName);
+ bool Init(unsigned int SampleRate, unsigned int Channels = 32);
+ void Update();
+ void SetVolume(float Volume, SOUND_TYPES Type);
+ float GetVolume(SOUND_TYPES Type);
+ void PauseAll();
+ void ResumeAll();
+ void PauseLayer(unsigned int Layer);
+ void ResumeLayer(unsigned int Layer);
+ bool PlaySound(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
+ unsigned int PlaySoundEx(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer);
+ unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0);
+
+ void SetSoundVolume(unsigned int Handle, float Volume);
+ void SetSoundPanning(unsigned int Handle, float Pan);
+ void PauseSound(unsigned int Handle);
+ void ResumeSound(unsigned int Handle);
+ void StopSound(unsigned int Handle);
+ bool IsSoundPaused(unsigned int Handle);
+ bool IsSoundPlaying(unsigned int Handle);
+ float GetSoundVolume(unsigned int Handle);
+ float GetSoundPanning(unsigned int Handle);
+ float GetSoundTime(unsigned int Handle);
+
+ BS_Resource *LoadResource(const std::string &FileName);
+ bool CanLoadResource(const std::string &FileName);
// -----------------------------------------------------------------------------
// Persistenz
// -----------------------------------------------------------------------------
-
- bool Persist(BS_OutputPersistenceBlock & Writer);
- bool Unpersist(BS_InputPersistenceBlock & Reader);
-
+
+ bool Persist(BS_OutputPersistenceBlock &Writer);
+ bool Unpersist(BS_InputPersistenceBlock &Reader);
+
private:
- struct PlayingSoundData
- {
+ struct PlayingSoundData {
PlayingSoundData() {};
- PlayingSoundData(BS_Resource * ResourcePtr_, BS_FMODExChannel * ChannelPtr_, SOUND_TYPES Type_, unsigned int Layer_, float Volume_, DynamicSoundReadCallback ReadCallback_ = 0, void * UserData_ = 0) :
+ PlayingSoundData(BS_Resource *ResourcePtr_, BS_FMODExChannel *ChannelPtr_, SOUND_TYPES Type_, unsigned int Layer_, float Volume_, DynamicSoundReadCallback ReadCallback_ = 0, void *UserData_ = 0) :
ResourcePtr(ResourcePtr_),
ChannelPtr(ChannelPtr_),
Type(Type_),
@@ -118,38 +116,38 @@ private:
Paused(false),
PausedLayer(false),
PausedGlobal(false)
- {}
-
- BS_Resource * ResourcePtr;
- BS_FMODExChannel * ChannelPtr;
- SOUND_TYPES Type;
- unsigned int Layer;
- DynamicSoundReadCallback ReadCallback;
- void * UserData;
-
- float Volume;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
+ {}
+
+ BS_Resource *ResourcePtr;
+ BS_FMODExChannel *ChannelPtr;
+ SOUND_TYPES Type;
+ unsigned int Layer;
+ DynamicSoundReadCallback ReadCallback;
+ void *UserData;
+
+ float Volume;
+ bool Paused;
+ bool PausedLayer;
+ bool PausedGlobal;
};
- typedef BS_Hashmap<unsigned int, PlayingSoundData> PSM;
- typedef BS_Hashmap<unsigned int, PlayingSoundData>::iterator PSM_ITER;
- typedef BS_Hashmap<unsigned int, PlayingSoundData>::const_iterator PSM_CONST_ITER;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData> PSM;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData>::iterator PSM_ITER;
+ typedef BS_Hashmap<unsigned int, PlayingSoundData>::const_iterator PSM_CONST_ITER;
PSM m_PlayingSoundsMap;
- FMOD_SYSTEM * m_FMOD;
- float m_Volumes[3];
- unsigned int m_NextHandle;
+ FMOD_SYSTEM *m_FMOD;
+ float m_Volumes[3];
+ unsigned int m_NextHandle;
- void RemoveInactiveSounds();
- PlayingSoundData * GetPlayingSoundDataByHandle(unsigned int Handle);
- unsigned int PlaySoundInternal(const std::string& FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer, unsigned int Handle, unsigned int Position);
- unsigned int CountPlayingDynamicSounds();
+ void RemoveInactiveSounds();
+ PlayingSoundData *GetPlayingSoundDataByHandle(unsigned int Handle);
+ unsigned int PlaySoundInternal(const std::string &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, unsigned int Layer, unsigned int Handle, unsigned int Position);
+ unsigned int CountPlayingDynamicSounds();
static FMOD_RESULT F_CALLBACK FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
static FMOD_RESULT F_CALLBACK FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, unsigned int datalen);
- static FMOD_RESULT F_CALLBACK DSPReadCallback(FMOD_DSP_STATE * dsp_state, float * inbuffer, float * outbuffer, unsigned int length, int inchannels, int outchannels);
+ static FMOD_RESULT F_CALLBACK DSPReadCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
};
#endif
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 44847e5f62..c3d845ad50 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -42,8 +42,7 @@
// -----------------------------------------------------------------------------
-BS_SoundEngine::BS_SoundEngine(BS_Kernel * pKernel) : BS_ResourceService(pKernel)
-{
+BS_SoundEngine::BS_SoundEngine(BS_Kernel *pKernel) : BS_ResourceService(pKernel) {
if (!_RegisterScriptBindings())
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
diff --git a/engines/sword25/sfx/soundengine.h b/engines/sword25/sfx/soundengine.h
index 35bab0c3d6..86efe4d3bd 100644
--- a/engines/sword25/sfx/soundengine.h
+++ b/engines/sword25/sfx/soundengine.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -67,7 +67,7 @@ public:
// -----------------------------------------------------------------------------
// Enums and Types
// -----------------------------------------------------------------------------
-
+
enum SOUND_TYPES {
MUSIC = 0,
SPEECH = 1,
@@ -76,29 +76,29 @@ public:
/**
* The callback function of PlayDynamicSoundEx
- * @param UserData User-specified pointer
- * @param Data Pointer to the data buffer
- * @param DataLength Length of the data to be written in bytes
+ * @param UserData User-specified pointer
+ * @param Data Pointer to the data buffer
+ * @param DataLength Length of the data to be written in bytes
*/
typedef void (*DynamicSoundReadCallback)(void *UserData, void *Data, unsigned int DataLength);
// -----------------------------------------------------------------------------
// Constructor / destructor
// -----------------------------------------------------------------------------
-
- BS_SoundEngine(BS_Kernel* pKernel);
+
+ BS_SoundEngine(BS_Kernel *pKernel);
virtual ~BS_SoundEngine() {};
// --------------------------------------------------------------
// THIS METHOD MUST BE IMPLEMENTED BY THE SOUND ENGINE
// --------------------------------------------------------------
- /**
+ /**
* Initialises the sound engine
- * @param SampleRate Specifies the sample rate to use.
- * @param Channels The maximum number of channels. The default is 32.
- * @return Returns true on success, otherwise false.
- * @remark Calls to other methods may take place only if this
+ * @param SampleRate Specifies the sample rate to use.
+ * @param Channels The maximum number of channels. The default is 32.
+ * @return Returns true on success, otherwise false.
+ * @remark Calls to other methods may take place only if this
* method was called successfully.
*/
virtual bool Init(unsigned int SampleRate, unsigned int Channels = 32) = 0;
@@ -112,17 +112,17 @@ public:
*/
virtual void Update() = 0;
- /**
+ /**
* Sets the default volume for the different sound types
- * @param Volume The default volume level (0 = off, 1 = full volume)
- * @param Type The SoundType whose volume is to be changed
+ * @param Volume The default volume level (0 = off, 1 = full volume)
+ * @param Type The SoundType whose volume is to be changed
*/
virtual void SetVolume(float Volume, SOUND_TYPES Type) = 0;
/**
* Specifies the default volume of different sound types
- * @param Type The SoundType
- * @return Returns the standard sound volume for the given type
+ * @param Type The SoundType
+ * @return Returns the standard sound volume for the given type
* (0 = off, 1 = full volume).
*/
virtual float GetVolume(SOUND_TYPES Type) = 0;
@@ -139,115 +139,115 @@ public:
/**
* Pauses all sounds of a given layer.
- * @param Layer The Sound Layer
+ * @param Layer The Sound Layer
*/
virtual void PauseLayer(unsigned int Layer) = 0;
/**
* Resumes all the sounds in a layer that was previously stopped with PauseLayer()
- * @param Layer The Sound Layer
+ * @param Layer The Sound Layer
*/
virtual void ResumeLayer(unsigned int Layer) = 0;
-
+
/**
* Plays a sound
- * @param FileName The filename of the sound to be played
- * @param Type The type of sound
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Loop Indicates whether the sound should be looped
- * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
+ * @param FileName The filename of the sound to be played
+ * @param Type The type of sound
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Loop Indicates whether the sound should be looped
+ * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
- * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
+ * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
- * @param Layer The sound layer
- * @return Returns true if the playback of the sound was started successfully.
- * @remark If more control is needed over the playing, eg. changing the sound parameters
+ * @param Layer The sound layer
+ * @return Returns true if the playback of the sound was started successfully.
+ * @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual bool PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
* Plays a sound
- * @param Type The type of sound
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Loop Indicates whether the sound should be looped
- * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
+ * @param Type The type of sound
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Loop Indicates whether the sound should be looped
+ * @param LoopStart Indicates the starting loop point. If a value less than 0 is passed, the start
* of the sound is used.
- * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
+ * @param LoopEnd Indicates the ending loop point. If a avlue is passed less than 0, the end of
* the sound is used.
- * @param Layer The sound layer
- * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
- * @remark If more control is needed over the playing, eg. changing the sound parameters
+ * @param Layer The sound layer
+ * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
+ * @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
virtual unsigned int PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, unsigned int Layer = 0) = 0;
/**
* Plays a sound generated at runtime
- * @param ReadCallback A pointer to a callback function that is called when sound data is needed.
+ * @param ReadCallback A pointer to a callback function that is called when sound data is needed.
* See the documentation for DynamicSoundReadCallback for more information.
- * @param UserData A pointer to the data. These are passed to the callback function each time.
+ * @param UserData A pointer to the data. These are passed to the callback function each time.
* If no such data is needed, this parameter can be set to NULL.
- * @param Type The type of sound
- * @param SampleRate The sample rate for the sound
- * @param BitsPerSample The size of the sample in bits. This statement is independant of the number of
+ * @param Type The type of sound
+ * @param SampleRate The sample rate for the sound
+ * @param BitsPerSample The size of the sample in bits. This statement is independant of the number of
* channels. Allowed values are 8, 16, 24, and 32.
- * @param Channels The number of channels. Allowed values are 1 and 2.
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
- * @param Pan Panning (-1 = full left, 1 = right)
- * @param Layer The sound layer
- * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
- * @remark Dynamic sounds cannot be persisted.
+ * @param Channels The number of channels. Allowed values are 1 and 2.
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Layer The sound layer
+ * @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
+ * @remark Dynamic sounds cannot be persisted.
*/
virtual unsigned int PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, unsigned int SampleRate, unsigned int BitsPerSample, unsigned int Channels, float Volume = 1.0f, float Pan = 0.0f, unsigned int Layer = 0) = 0;
/**
* Sets the volume of a playing sound
- * @param Handle The sound handle
- * @param Volume The volume of the sound (0 = off, 1 = full volume)
+ * @param Handle The sound handle
+ * @param Volume The volume of the sound (0 = off, 1 = full volume)
*/
virtual void SetSoundVolume(unsigned int Handle, float Volume) = 0;
/**
* Sets the panning of a playing sound
- * @param Handle The sound handle
- * @param Pan Panning (-1 = full left, 1 = right)
+ * @param Handle The sound handle
+ * @param Pan Panning (-1 = full left, 1 = right)
*/
virtual void SetSoundPanning(unsigned int Handle, float Pan) = 0;
/**
* Pauses a playing sound
- * @param Handle The sound handle
+ * @param Handle The sound handle
*/
virtual void PauseSound(unsigned int Handle) = 0;
/**
* Resumes a paused sound
- * @param Handle The sound handle
+ * @param Handle The sound handle
*/
virtual void ResumeSound(unsigned int Handle) = 0;
/**
* Stops a playing sound
- * @param Handle The sound handle
- * @remark Calling this method invalidates the passed handle; it can no longer be used.
+ * @param Handle The sound handle
+ * @remark Calling this method invalidates the passed handle; it can no longer be used.
*/
virtual void StopSound(unsigned int Handle) = 0;
/**
* Returns whether a sound is paused
- * @param Handle The sound handle
- * @return Returns true if the sound is paused, false otherwise.
+ * @param Handle The sound handle
+ * @return Returns true if the sound is paused, false otherwise.
*/
virtual bool IsSoundPaused(unsigned int Handle) = 0;
-
+
/**
* Returns whether a sound is still playing.
- * @param Handle The sound handle
- * @return Returns true if the sound is playing, false otherwise.
+ * @param Handle The sound handle
+ * @return Returns true if the sound is playing, false otherwise.
*/
virtual bool IsSoundPlaying(unsigned int Handle) = 0;
diff --git a/engines/sword25/sfx/soundengine_script.cpp b/engines/sword25/sfx/soundengine_script.cpp
index 34188e9f05..ecffd2b42a 100644
--- a/engines/sword25/sfx/soundengine_script.cpp
+++ b/engines/sword25/sfx/soundengine_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,11 +45,10 @@
// -----------------------------------------------------------------------------
-static int Init(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int Init(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
if (lua_gettop(L) == 0)
@@ -57,18 +56,17 @@ static int Init(lua_State * L)
else if (lua_gettop(L) == 1)
lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), 32));
else
- lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2))));
+ lua_pushbooleancpp(L, pSfx->Init(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<unsigned int>(luaL_checknumber(L, 2))));
return 1;
}
// -----------------------------------------------------------------------------
-static int Update(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int Update(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->Update();
@@ -78,26 +76,24 @@ static int Update(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetVolume(static_cast<float>(luaL_checknumber(L, 1)),
- static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2))));
+ static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2))));
return 0;
}
// -----------------------------------------------------------------------------
-static int GetVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetVolume(static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 1)))));
@@ -107,11 +103,10 @@ static int GetVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseAll(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseAll(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseAll();
@@ -121,11 +116,10 @@ static int PauseAll(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeAll(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeAll(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeAll();
@@ -135,11 +129,10 @@ static int ResumeAll(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseLayer(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseLayer(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseLayer(static_cast<int>(luaL_checknumber(L, 1)));
@@ -149,11 +142,10 @@ static int PauseLayer(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeLayer(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeLayer(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeLayer(static_cast<int>(luaL_checknumber(L, 1)));
@@ -163,8 +155,7 @@ static int ResumeLayer(lua_State * L)
// -----------------------------------------------------------------------------
-static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEngine::SOUND_TYPES & Type, float & Volume, float & Pan, bool & Loop, int & LoopStart, int & LoopEnd, unsigned int & Layer)
-{
+static void ProcessPlayParams(lua_State *L, std::string &FileName, BS_SoundEngine::SOUND_TYPES &Type, float &Volume, float &Pan, bool &Loop, int &LoopStart, int &LoopEnd, unsigned int &Layer) {
FileName = luaL_checkstring(L, 1);
Type = static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)));
@@ -188,11 +179,10 @@ static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEng
else Layer = static_cast<unsigned int>(luaL_checknumber(L, 8));
}
-static int PlaySound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PlaySound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
std::string FileName;
@@ -210,11 +200,10 @@ static int PlaySound(lua_State * L)
return 1;
}
-static int PlaySoundEx(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PlaySoundEx(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
std::string FileName;
@@ -234,11 +223,10 @@ static int PlaySoundEx(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetSoundVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetSoundVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2)));
@@ -248,11 +236,10 @@ static int SetSoundVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int SetSoundPanning(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int SetSoundPanning(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->SetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2)));
@@ -262,11 +249,10 @@ static int SetSoundPanning(lua_State * L)
// -----------------------------------------------------------------------------
-static int PauseSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int PauseSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->PauseSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -276,11 +262,10 @@ static int PauseSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int ResumeSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int ResumeSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->ResumeSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -290,11 +275,10 @@ static int ResumeSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int StopSound(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int StopSound(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
pSfx->StopSound(static_cast<unsigned int>(luaL_checknumber(L, 1)));
@@ -304,11 +288,10 @@ static int StopSound(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsSoundPaused(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int IsSoundPaused(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushbooleancpp(L, pSfx->IsSoundPaused(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -318,11 +301,10 @@ static int IsSoundPaused(lua_State * L)
// -----------------------------------------------------------------------------
-static int IsSoundPlaying(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int IsSoundPlaying(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushbooleancpp(L, pSfx->IsSoundPlaying(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -332,11 +314,10 @@ static int IsSoundPlaying(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetSoundVolume(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetSoundVolume(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetSoundVolume(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -346,11 +327,10 @@ static int GetSoundVolume(lua_State * L)
// -----------------------------------------------------------------------------
-static int GetSoundPanning(lua_State * L)
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+static int GetSoundPanning(lua_State *L) {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_SoundEngine * pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
+ BS_SoundEngine *pSfx = static_cast<BS_SoundEngine *>(BS_Kernel::GetInstance()->GetService("sfx"));
BS_ASSERT(pSfx);
lua_pushnumber(L, pSfx->GetSoundPanning(static_cast<unsigned int>(luaL_checknumber(L, 1))));
@@ -360,10 +340,9 @@ static int GetSoundPanning(lua_State * L)
// -----------------------------------------------------------------------------
-static const char * SFX_LIBRARY_NAME = "Sfx";
+static const char *SFX_LIBRARY_NAME = "Sfx";
-static const luaL_reg SFX_FUNCTIONS[] =
-{
+static const luaL_reg SFX_FUNCTIONS[] = {
"Init", Init,
"Update", Update,
"__SetVolume", SetVolume,
@@ -386,8 +365,7 @@ static const luaL_reg SFX_FUNCTIONS[] =
0, 0,
};
-static const lua_constant_reg SFX_CONSTANTS[] =
-{
+static const lua_constant_reg SFX_CONSTANTS[] = {
"MUSIC", BS_SoundEngine::MUSIC,
"SPEECH", BS_SoundEngine::SPEECH,
"SFX", BS_SoundEngine::SFX,
@@ -396,13 +374,12 @@ static const lua_constant_reg SFX_CONSTANTS[] =
// -----------------------------------------------------------------------------
-bool BS_SoundEngine::_RegisterScriptBindings()
-{
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+bool BS_SoundEngine::_RegisterScriptBindings() {
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
- lua_State * L = static_cast<lua_State *>(pScript->GetScriptObject());
+ lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
if (!BS_LuaBindhelper::AddFunctionsToLib(L, SFX_LIBRARY_NAME, SFX_FUNCTIONS)) return false;
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index 07fc302da0..a6aa79cc4c 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -45,9 +45,9 @@ namespace Sword25 {
#define BS_LOG_PREFIX "MAIN"
-const char * const PACKAGE_MANAGER = "archiveFS";
-const char * const DEFAULT_SCRIPT_FILE = "/system/boot.lua";
-const char * const MOUNT_DIR_PARAMETER = "-mount-dir";
+const char *const PACKAGE_MANAGER = "archiveFS";
+const char *const DEFAULT_SCRIPT_FILE = "/system/boot.lua";
+const char *const MOUNT_DIR_PARAMETER = "-mount-dir";
void LogToStdout(const char *Message) {
@@ -55,8 +55,8 @@ void LogToStdout(const char *Message) {
}
Sword25Engine::Sword25Engine(OSystem *syst, const Sword25GameDescription *gameDesc):
- Engine(syst),
- _gameDescription(gameDesc) {
+ Engine(syst),
+ _gameDescription(gameDesc) {
}
Sword25Engine::~Sword25Engine() {
@@ -125,7 +125,7 @@ Common::Error Sword25Engine::AppStart(const Common::StringArray &CommandParamete
bool Sword25Engine::AppMain() {
// The main script start. This script loads all the other scripts and starts the actual game.
- BS_ScriptEngine * ScriptPtr = static_cast<BS_ScriptEngine *>(BS_Kernel::GetInstance()->GetService("script"));
+ BS_ScriptEngine *ScriptPtr = static_cast<BS_ScriptEngine *>(BS_Kernel::GetInstance()->GetService("script"));
BS_ASSERT(ScriptPtr);
ScriptPtr->ExecuteFile(DEFAULT_SCRIPT_FILE);
@@ -192,10 +192,9 @@ bool Sword25Engine::LoadPackages() {
static const Common::String Suffix = ".b25c";
// Make sure the filename prefix and suffix has characters between them
- if ((CurFilename.size() >= Prefix.size() && Common::String(CurFilename.begin(), CurFilename.begin() + Prefix.size()) == Prefix) && // Prefix test
- (CurFilename.size() >= Suffix.size() && Common::String(CurFilename.end() - Suffix.size(), CurFilename.end()) == Suffix) && // Suffix test
- (CurFilename.size() > Prefix.size() + Suffix.size()))
- {
+ if ((CurFilename.size() >= Prefix.size() && Common::String(CurFilename.begin(), CurFilename.begin() + Prefix.size()) == Prefix) && // Prefix test
+ (CurFilename.size() >= Suffix.size() && Common::String(CurFilename.end() - Suffix.size(), CurFilename.end()) == Suffix) && // Suffix test
+ (CurFilename.size() > Prefix.size() + Suffix.size())) {
// Pattern matches - the file should be mounted
if (!PackageManagerPtr->LoadPackage(CurFilename, "/")) return false;
}
diff --git a/engines/sword25/sword25.h b/engines/sword25/sword25.h
index 7f10f58368..f4dc9f829f 100644
--- a/engines/sword25/sword25.h
+++ b/engines/sword25/sword25.h
@@ -59,7 +59,7 @@ private:
protected:
virtual Common::Error run();
void shutdown();
-
+
public:
Sword25Engine(OSystem *syst, const Sword25GameDescription *gameDesc);
virtual ~Sword25Engine();