SWORD25: Mass-astyle.
svn-id: r53222
This commit is contained in:
parent
ca17def625
commit
47904bc7b2
146 changed files with 5057 additions and 5644 deletions
|
@ -38,7 +38,9 @@ namespace Sword25 {
|
||||||
|
|
||||||
#define BS_LOG_PREFIX "MOVIEPLAYER"
|
#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) {
|
BS_MoviePlayer::BS_MoviePlayer(BS_Kernel *pKernel) : BS_Service(pKernel) {
|
||||||
if (!_RegisterScriptBindings())
|
if (!_RegisterScriptBindings())
|
||||||
|
|
24
engines/sword25/fmv/theora_decoder.h
Executable file → Normal file
24
engines/sword25/fmv/theora_decoder.h
Executable file → Normal file
|
@ -65,16 +65,28 @@ public:
|
||||||
*/
|
*/
|
||||||
Graphics::Surface *decodeNextFrame();
|
Graphics::Surface *decodeNextFrame();
|
||||||
|
|
||||||
bool isVideoLoaded() const { return _fileStream != 0; }
|
bool isVideoLoaded() const {
|
||||||
uint16 getWidth() const { return _surface->w; }
|
return _fileStream != 0;
|
||||||
uint16 getHeight() const { return _surface->h; }
|
}
|
||||||
uint32 getFrameCount() const { return _frameCount; }
|
uint16 getWidth() const {
|
||||||
Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 0, 0, 0); }
|
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;
|
uint32 getElapsedTime() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Common::Rational getFrameRate() const { return _frameRate; }
|
Common::Rational getFrameRate() const {
|
||||||
|
return _frameRate;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void queuePage(ogg_page *page);
|
void queuePage(ogg_page *page);
|
||||||
|
|
|
@ -58,8 +58,7 @@ namespace Sword25 {
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
||||||
BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &FileName) :
|
BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &FileName) :
|
||||||
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION)
|
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION) {
|
||||||
{
|
|
||||||
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
||||||
if (!m_InitSuccess) return;
|
if (!m_InitSuccess) return;
|
||||||
|
|
||||||
|
@ -77,8 +76,7 @@ BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate &Template) :
|
BS_Animation::BS_Animation(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const BS_AnimationTemplate &Template) :
|
||||||
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION)
|
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION) {
|
||||||
{
|
|
||||||
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
||||||
if (!m_InitSuccess) return;
|
if (!m_InitSuccess) return;
|
||||||
|
|
||||||
|
@ -96,8 +94,7 @@ 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_Animation::BS_Animation(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
|
||||||
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION, Handle)
|
BS_TimedRenderObject(ParentPtr, BS_RenderObject::TYPE_ANIMATION, Handle) {
|
||||||
{
|
|
||||||
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
// Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
||||||
if (!m_InitSuccess) return;
|
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.
|
// 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)
|
if (ResourcePtr && ResourcePtr->GetType() == BS_Resource::TYPE_ANIMATION)
|
||||||
m_AnimationResourcePtr = static_cast<BS_AnimationResource *>(ResourcePtr);
|
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());
|
BS_LOG_ERRORLN("The resource \"%s\" could not be requested. The Animation can't be created.", FileName.c_str());
|
||||||
return;
|
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_CurrentFrame = 0;
|
||||||
m_CurrentFrameTime = 0;
|
m_CurrentFrameTime = 0;
|
||||||
m_Direction = FORWARD;
|
m_Direction = FORWARD;
|
||||||
|
@ -146,10 +140,8 @@ void BS_Animation::InitMembers()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Animation::~BS_Animation()
|
BS_Animation::~BS_Animation() {
|
||||||
{
|
if (GetAnimationDescription()) {
|
||||||
if (GetAnimationDescription())
|
|
||||||
{
|
|
||||||
Stop();
|
Stop();
|
||||||
GetAnimationDescription()->Unlock();
|
GetAnimationDescription()->Unlock();
|
||||||
}
|
}
|
||||||
|
@ -164,8 +156,7 @@ BS_Animation::~BS_Animation()
|
||||||
// Steuermethoden
|
// Steuermethoden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::Play()
|
void BS_Animation::Play() {
|
||||||
{
|
|
||||||
// Wenn die Animation zuvor komplett durchgelaufen ist, wird sie wieder von Anfang abgespielt
|
// Wenn die Animation zuvor komplett durchgelaufen ist, wird sie wieder von Anfang abgespielt
|
||||||
if (m_Finished) Stop();
|
if (m_Finished) Stop();
|
||||||
|
|
||||||
|
@ -175,16 +166,14 @@ void BS_Animation::Play()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::Pause()
|
void BS_Animation::Pause() {
|
||||||
{
|
|
||||||
m_Running = false;
|
m_Running = false;
|
||||||
UnlockAllFrames();
|
UnlockAllFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::Stop()
|
void BS_Animation::Stop() {
|
||||||
{
|
|
||||||
m_CurrentFrame = 0;
|
m_CurrentFrame = 0;
|
||||||
m_CurrentFrameTime = 0;
|
m_CurrentFrameTime = 0;
|
||||||
m_Direction = FORWARD;
|
m_Direction = FORWARD;
|
||||||
|
@ -193,13 +182,11 @@ void BS_Animation::Stop()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetFrame(unsigned int Nr)
|
void BS_Animation::SetFrame(unsigned int Nr) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
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.",
|
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;
|
return;
|
||||||
|
@ -215,8 +202,7 @@ void BS_Animation::SetFrame(unsigned int Nr)
|
||||||
// Rendern
|
// Rendern
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::DoRender()
|
bool BS_Animation::DoRender() {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
BS_ASSERT(m_CurrentFrame < animationDescriptionPtr->GetFrameCount());
|
BS_ASSERT(m_CurrentFrame < animationDescriptionPtr->GetFrameCount());
|
||||||
|
@ -233,15 +219,12 @@ bool BS_Animation::DoRender()
|
||||||
|
|
||||||
// Bitmap zeichnen
|
// Bitmap zeichnen
|
||||||
bool Result;
|
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,
|
Result = pBitmapResource->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
0, m_ModulationColor, m_Width, m_Height);
|
0, m_ModulationColor, m_Width, m_Height);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Result = pBitmapResource->Blit(m_AbsoluteX, m_AbsoluteY,
|
Result = pBitmapResource->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(animationDescriptionPtr->GetFrame(m_CurrentFrame).FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
|
@ -258,15 +241,13 @@ bool BS_Animation::DoRender()
|
||||||
// Frame Notifikation
|
// Frame Notifikation
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::FrameNotification(int TimeElapsed)
|
void BS_Animation::FrameNotification(int TimeElapsed) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
BS_ASSERT(TimeElapsed >= 0);
|
BS_ASSERT(TimeElapsed >= 0);
|
||||||
|
|
||||||
// Nur wenn die Animation läuft wird sie auch weiterbewegt
|
// Nur wenn die Animation läuft wird sie auch weiterbewegt
|
||||||
if (m_Running)
|
if (m_Running) {
|
||||||
{
|
|
||||||
int OldFrame = m_CurrentFrame;
|
int OldFrame = m_CurrentFrame;
|
||||||
|
|
||||||
// Gesamte vergangene Zeit bestimmen (inkl. Restzeit des aktuellen Frames)
|
// 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)
|
// Neuen Frame bestimmen (je nach aktuellener Abspielrichtung wird addiert oder subtrahiert)
|
||||||
int TmpCurFrame = m_CurrentFrame;
|
int TmpCurFrame = m_CurrentFrame;
|
||||||
switch (m_Direction)
|
switch (m_Direction) {
|
||||||
{
|
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
TmpCurFrame += SkipFrames;
|
TmpCurFrame += SkipFrames;
|
||||||
break;
|
break;
|
||||||
|
@ -295,17 +275,13 @@ void BS_Animation::FrameNotification(int TimeElapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Überläufe behandeln
|
// Überläufe behandeln
|
||||||
if (TmpCurFrame < 0)
|
if (TmpCurFrame < 0) {
|
||||||
{
|
|
||||||
// Loop-Point Callbacks
|
// Loop-Point Callbacks
|
||||||
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_LoopPointCallbacks.begin();
|
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) {
|
||||||
if (((*it).Callback)((*it).Data) == false)
|
|
||||||
{
|
|
||||||
it = m_LoopPointCallbacks.erase(it);
|
it = m_LoopPointCallbacks.erase(it);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,21 +289,17 @@ void BS_Animation::FrameNotification(int TimeElapsed)
|
||||||
BS_ASSERT(animationDescriptionPtr->GetAnimationType() == AT_JOJO);
|
BS_ASSERT(animationDescriptionPtr->GetAnimationType() == AT_JOJO);
|
||||||
TmpCurFrame = - TmpCurFrame;
|
TmpCurFrame = - TmpCurFrame;
|
||||||
m_Direction = FORWARD;
|
m_Direction = FORWARD;
|
||||||
}
|
} else if (static_cast<unsigned int>(TmpCurFrame) >= animationDescriptionPtr->GetFrameCount()) {
|
||||||
else if (static_cast<unsigned int>(TmpCurFrame) >= animationDescriptionPtr->GetFrameCount())
|
|
||||||
{
|
|
||||||
// Loop-Point Callbacks
|
// Loop-Point Callbacks
|
||||||
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_LoopPointCallbacks.begin();
|
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)
|
if (((*it).Callback)((*it).Data) == false)
|
||||||
it = m_LoopPointCallbacks.erase(it);
|
it = m_LoopPointCallbacks.erase(it);
|
||||||
else
|
else
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (animationDescriptionPtr->GetAnimationType())
|
switch (animationDescriptionPtr->GetAnimationType()) {
|
||||||
{
|
|
||||||
case AT_ONESHOT:
|
case AT_ONESHOT:
|
||||||
TmpCurFrame = animationDescriptionPtr->GetFrameCount() - 1;
|
TmpCurFrame = animationDescriptionPtr->GetFrameCount() - 1;
|
||||||
m_Finished = true;
|
m_Finished = true;
|
||||||
|
@ -348,16 +320,13 @@ void BS_Animation::FrameNotification(int TimeElapsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CurrentFrame != TmpCurFrame)
|
if (m_CurrentFrame != TmpCurFrame) {
|
||||||
{
|
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
|
|
||||||
if (animationDescriptionPtr->GetFrame(m_CurrentFrame).Action != "")
|
if (animationDescriptionPtr->GetFrame(m_CurrentFrame).Action != "") {
|
||||||
{
|
|
||||||
// Action Callbacks
|
// Action Callbacks
|
||||||
Common::Array<ANIMATION_CALLBACK_DATA>::iterator it = m_ActionCallbacks.begin();
|
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)
|
if (((*it).Callback)((*it).Data) == false)
|
||||||
it = m_ActionCallbacks.erase(it);
|
it = m_ActionCallbacks.erase(it);
|
||||||
else
|
else
|
||||||
|
@ -378,8 +347,7 @@ void BS_Animation::FrameNotification(int TimeElapsed)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::ComputeCurrentCharacteristics()
|
void BS_Animation::ComputeCurrentCharacteristics() {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
||||||
|
@ -404,16 +372,12 @@ void BS_Animation::ComputeCurrentCharacteristics()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::LockAllFrames()
|
bool BS_Animation::LockAllFrames() {
|
||||||
{
|
if (!m_FramesLocked) {
|
||||||
if (!m_FramesLocked)
|
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i)
|
for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i) {
|
||||||
{
|
if (!BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName)) {
|
||||||
if (!BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName))
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not lock all animation frames.");
|
BS_LOG_ERRORLN("Could not lock all animation frames.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -427,17 +391,13 @@ bool BS_Animation::LockAllFrames()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::UnlockAllFrames()
|
bool BS_Animation::UnlockAllFrames() {
|
||||||
{
|
if (m_FramesLocked) {
|
||||||
if (m_FramesLocked)
|
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i)
|
for (unsigned int i = 0; i < animationDescriptionPtr->GetFrameCount(); ++i) {
|
||||||
{
|
|
||||||
BS_Resource *pResource;
|
BS_Resource *pResource;
|
||||||
if (!(pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName)))
|
if (!(pResource = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->GetFrame(i).FileName))) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not unlock all animation frames.");
|
BS_LOG_ERRORLN("Could not unlock all animation frames.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -457,8 +417,7 @@ bool BS_Animation::UnlockAllFrames()
|
||||||
// Getter
|
// Getter
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Animation::ANIMATION_TYPES BS_Animation::GetAnimationType() const
|
BS_Animation::ANIMATION_TYPES BS_Animation::GetAnimationType() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->GetAnimationType();
|
return animationDescriptionPtr->GetAnimationType();
|
||||||
|
@ -466,8 +425,7 @@ BS_Animation::ANIMATION_TYPES BS_Animation::GetAnimationType() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetFPS() const
|
int BS_Animation::GetFPS() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->GetFPS();
|
return animationDescriptionPtr->GetFPS();
|
||||||
|
@ -475,8 +433,7 @@ int BS_Animation::GetFPS() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetFrameCount() const
|
int BS_Animation::GetFrameCount() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->GetFrameCount();
|
return animationDescriptionPtr->GetFrameCount();
|
||||||
|
@ -484,8 +441,7 @@ int BS_Animation::GetFrameCount() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::IsScalingAllowed() const
|
bool BS_Animation::IsScalingAllowed() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->IsScalingAllowed();
|
return animationDescriptionPtr->IsScalingAllowed();
|
||||||
|
@ -493,8 +449,7 @@ bool BS_Animation::IsScalingAllowed() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::IsAlphaAllowed() const
|
bool BS_Animation::IsAlphaAllowed() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->IsAlphaAllowed();
|
return animationDescriptionPtr->IsAlphaAllowed();
|
||||||
|
@ -502,8 +457,7 @@ bool BS_Animation::IsAlphaAllowed() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Animation::IsColorModulationAllowed() const
|
bool BS_Animation::IsColorModulationAllowed() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->IsColorModulationAllowed();
|
return animationDescriptionPtr->IsColorModulationAllowed();
|
||||||
|
@ -513,8 +467,7 @@ bool BS_Animation::IsColorModulationAllowed() const
|
||||||
// Positionieren
|
// Positionieren
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetPos(int RelX, int RelY)
|
void BS_Animation::SetPos(int RelX, int RelY) {
|
||||||
{
|
|
||||||
m_RelX = RelX;
|
m_RelX = RelX;
|
||||||
m_RelY = RelY;
|
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;
|
m_RelX = RelX;
|
||||||
|
|
||||||
ComputeCurrentCharacteristics();
|
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;
|
m_RelY = RelY;
|
||||||
|
|
||||||
ComputeCurrentCharacteristics();
|
ComputeCurrentCharacteristics();
|
||||||
|
@ -543,19 +494,16 @@ void BS_Animation::SetY(int RelY)
|
||||||
// Darstellungsart festlegen
|
// Darstellungsart festlegen
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetAlpha(int Alpha)
|
void BS_Animation::SetAlpha(int Alpha) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
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.");
|
BS_LOG_WARNINGLN("Tried to set alpha value on an animation that does not support alpha. Call was ignored.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
@ -563,19 +511,16 @@ void BS_Animation::SetAlpha(int Alpha)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetModulationColor(unsigned int ModulationColor)
|
void BS_Animation::SetModulationColor(unsigned int ModulationColor) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
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");
|
BS_LOG_WARNINGLN("Tried to set modulation color on an animation that does not support color modulation. Call was ignored");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
|
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
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);
|
SetScaleFactorX(ScaleFactor);
|
||||||
SetScaleFactorY(ScaleFactor);
|
SetScaleFactorY(ScaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetScaleFactorX(float ScaleFactorX)
|
void BS_Animation::SetScaleFactorX(float ScaleFactorX) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
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");
|
BS_LOG_WARNINGLN("Tried to set x scale factor on an animation that does not support scaling. Call was ignored");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScaleFactorX != m_ScaleFactorX)
|
if (ScaleFactorX != m_ScaleFactorX) {
|
||||||
{
|
|
||||||
m_ScaleFactorX = ScaleFactorX;
|
m_ScaleFactorX = ScaleFactorX;
|
||||||
if (m_ScaleFactorX <= 0.0f) m_ScaleFactorX = 0.001f;
|
if (m_ScaleFactorX <= 0.0f) m_ScaleFactorX = 0.001f;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
|
@ -612,18 +553,15 @@ void BS_Animation::SetScaleFactorX(float ScaleFactorX)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Animation::SetScaleFactorY(float ScaleFactorY)
|
void BS_Animation::SetScaleFactorY(float ScaleFactorY) {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
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");
|
BS_LOG_WARNINGLN("Tried to set y scale factor on an animation that does not support scaling. Call was ignored");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScaleFactorY != m_ScaleFactorY)
|
if (ScaleFactorY != m_ScaleFactorY) {
|
||||||
{
|
|
||||||
m_ScaleFactorY = ScaleFactorY;
|
m_ScaleFactorY = ScaleFactorY;
|
||||||
if (m_ScaleFactorY <= 0.0f) m_ScaleFactorY = 0.001f;
|
if (m_ScaleFactorY <= 0.0f) m_ScaleFactorY = 0.001f;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
|
@ -633,8 +571,7 @@ void BS_Animation::SetScaleFactorY(float ScaleFactorY)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
const Common::String & BS_Animation::GetCurrentAction() const
|
const Common::String &BS_Animation::GetCurrentAction() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
return animationDescriptionPtr->GetFrame(m_CurrentFrame).Action;
|
return animationDescriptionPtr->GetFrame(m_CurrentFrame).Action;
|
||||||
|
@ -642,36 +579,31 @@ const Common::String & BS_Animation::GetCurrentAction() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetX() const
|
int BS_Animation::GetX() const {
|
||||||
{
|
|
||||||
return m_RelX;
|
return m_RelX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetY() const
|
int BS_Animation::GetY() const {
|
||||||
{
|
|
||||||
return m_RelY;
|
return m_RelY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetAbsoluteX() const
|
int BS_Animation::GetAbsoluteX() const {
|
||||||
{
|
|
||||||
return m_AbsoluteX + (m_RelX - m_X);
|
return m_AbsoluteX + (m_RelX - m_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::GetAbsoluteY() const
|
int BS_Animation::GetAbsoluteY() const {
|
||||||
{
|
|
||||||
return m_AbsoluteY + (m_RelY - m_Y);
|
return m_AbsoluteY + (m_RelY - m_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::ComputeXModifier() const
|
int BS_Animation::ComputeXModifier() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
||||||
|
@ -691,8 +623,7 @@ int BS_Animation::ComputeXModifier() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int BS_Animation::ComputeYModifier() const
|
int BS_Animation::ComputeYModifier() const {
|
||||||
{
|
|
||||||
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
BS_AnimationDescription *animationDescriptionPtr = GetAnimationDescription();
|
||||||
BS_ASSERT(animationDescriptionPtr);
|
BS_ASSERT(animationDescriptionPtr);
|
||||||
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
const BS_AnimationResource::Frame &CurFrame = animationDescriptionPtr->GetFrame(m_CurrentFrame);
|
||||||
|
@ -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;
|
ANIMATION_CALLBACK_DATA CD;
|
||||||
CD.Callback = Callback;
|
CD.Callback = Callback;
|
||||||
CD.Data = Data;
|
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;
|
ANIMATION_CALLBACK_DATA CD;
|
||||||
CD.Callback = Callback;
|
CD.Callback = Callback;
|
||||||
CD.Data = Data;
|
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;
|
ANIMATION_CALLBACK_DATA CD;
|
||||||
CD.Callback = Callback;
|
CD.Callback = Callback;
|
||||||
CD.Data = Data;
|
CD.Data = Data;
|
||||||
|
@ -744,15 +672,13 @@ void BS_Animation::RegisterDeleteCallback(ANIMATION_CALLBACK Callback, unsigned
|
||||||
// Persistenz
|
// 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.
|
// Anzahl an Callbacks persistieren.
|
||||||
Writer.Write(Vector.size());
|
Writer.Write(Vector.size());
|
||||||
|
|
||||||
// Alle Callbacks einzeln persistieren.
|
// Alle Callbacks einzeln persistieren.
|
||||||
Common::Array<ANIMATION_CALLBACK_DATA>::const_iterator It = Vector.begin();
|
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(BS_CallbackRegistry::GetInstance().ResolveCallbackPointer(It->Callback));
|
||||||
Writer.Write(It->Data);
|
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.
|
// Callbackvector leeren.
|
||||||
Vector.resize(0);
|
Vector.resize(0);
|
||||||
|
|
||||||
|
@ -772,8 +697,7 @@ void BS_Animation::UnpersistCallbackVector(BS_InputPersistenceBlock & Reader, Co
|
||||||
Reader.Read(CallbackCount);
|
Reader.Read(CallbackCount);
|
||||||
|
|
||||||
// Alle Callbacks einzeln wieder herstellen.
|
// 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;
|
ANIMATION_CALLBACK_DATA CallbackData;
|
||||||
|
|
||||||
Common::String CallbackFunctionName;
|
Common::String CallbackFunctionName;
|
||||||
|
@ -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;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Persist(Writer);
|
Result &= BS_RenderObject::Persist(Writer);
|
||||||
|
@ -806,20 +729,15 @@ bool BS_Animation::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
Writer.Write(static_cast<unsigned int>(m_Direction));
|
Writer.Write(static_cast<unsigned int>(m_Direction));
|
||||||
|
|
||||||
// Je nach Animationstyp entweder das Template oder die Ressource speichern.
|
// Je nach Animationstyp entweder das Template oder die Ressource speichern.
|
||||||
if (m_AnimationResourcePtr)
|
if (m_AnimationResourcePtr) {
|
||||||
{
|
|
||||||
unsigned int Marker = 0;
|
unsigned int Marker = 0;
|
||||||
Writer.Write(Marker);
|
Writer.Write(Marker);
|
||||||
Writer.Write(m_AnimationResourcePtr->GetFileName());
|
Writer.Write(m_AnimationResourcePtr->GetFileName());
|
||||||
}
|
} else if (m_AnimationTemplateHandle) {
|
||||||
else if (m_AnimationTemplateHandle)
|
|
||||||
{
|
|
||||||
unsigned int Marker = 1;
|
unsigned int Marker = 1;
|
||||||
Writer.Write(Marker);
|
Writer.Write(Marker);
|
||||||
Writer.Write(m_AnimationTemplateHandle);
|
Writer.Write(m_AnimationTemplateHandle);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BS_ASSERT(false);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Unpersist(Reader);
|
Result &= BS_RenderObject::Unpersist(Reader);
|
||||||
|
@ -859,18 +776,13 @@ bool BS_Animation::Unpersist(BS_InputPersistenceBlock & Reader)
|
||||||
// Animationstyp einlesen.
|
// Animationstyp einlesen.
|
||||||
unsigned int Marker;
|
unsigned int Marker;
|
||||||
Reader.Read(Marker);
|
Reader.Read(Marker);
|
||||||
if (Marker == 0)
|
if (Marker == 0) {
|
||||||
{
|
|
||||||
Common::String ResourceFilename;
|
Common::String ResourceFilename;
|
||||||
Reader.Read(ResourceFilename);
|
Reader.Read(ResourceFilename);
|
||||||
InitializeAnimationResource(ResourceFilename);
|
InitializeAnimationResource(ResourceFilename);
|
||||||
}
|
} else if (Marker == 1) {
|
||||||
else if (Marker == 1)
|
|
||||||
{
|
|
||||||
Reader.Read(m_AnimationTemplateHandle);
|
Reader.Read(m_AnimationTemplateHandle);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BS_ASSERT(false);
|
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;
|
if (m_AnimationResourcePtr) return m_AnimationResourcePtr;
|
||||||
else return BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(m_AnimationTemplateHandle);
|
else return BS_AnimationTemplateRegistry::GetInstance().ResolveHandle(m_AnimationTemplateHandle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,7 @@ class BS_AnimationTemplate;
|
||||||
class BS_AnimationDescription;
|
class BS_AnimationDescription;
|
||||||
class BS_InputPersistenceBlock;
|
class BS_InputPersistenceBlock;
|
||||||
|
|
||||||
class BS_Animation : public BS_TimedRenderObject
|
class BS_Animation : public BS_TimedRenderObject {
|
||||||
{
|
|
||||||
friend class BS_RenderObject;
|
friend class BS_RenderObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -63,8 +62,7 @@ private:
|
||||||
BS_Animation(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
|
BS_Animation(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ANIMATION_TYPES
|
enum ANIMATION_TYPES {
|
||||||
{
|
|
||||||
AT_ONESHOT,
|
AT_ONESHOT,
|
||||||
AT_LOOP,
|
AT_LOOP,
|
||||||
AT_JOJO
|
AT_JOJO
|
||||||
|
@ -125,13 +123,17 @@ public:
|
||||||
@brief Gibt den Skalierungsfakter der Animation auf der X-Achse zurück.
|
@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.
|
@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.
|
@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.
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
@ -144,9 +146,13 @@ public:
|
||||||
bool IsScalingAllowed() const;
|
bool IsScalingAllowed() const;
|
||||||
bool IsAlphaAllowed() const;
|
bool IsAlphaAllowed() const;
|
||||||
bool IsColorModulationAllowed() const;
|
bool IsColorModulationAllowed() const;
|
||||||
unsigned int GetCurrentFrame() const { return m_CurrentFrame; }
|
unsigned int GetCurrentFrame() const {
|
||||||
|
return m_CurrentFrame;
|
||||||
|
}
|
||||||
const Common::String &GetCurrentAction() const ;
|
const Common::String &GetCurrentAction() const ;
|
||||||
bool IsRunning() const { return m_Running; }
|
bool IsRunning() const {
|
||||||
|
return m_Running;
|
||||||
|
}
|
||||||
|
|
||||||
typedef bool (*ANIMATION_CALLBACK)(unsigned int);
|
typedef bool (*ANIMATION_CALLBACK)(unsigned int);
|
||||||
|
|
||||||
|
@ -158,8 +164,7 @@ protected:
|
||||||
virtual bool DoRender();
|
virtual bool DoRender();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum DIRECTION
|
enum DIRECTION {
|
||||||
{
|
|
||||||
FORWARD,
|
FORWARD,
|
||||||
BACKWARD
|
BACKWARD
|
||||||
};
|
};
|
||||||
|
@ -178,8 +183,7 @@ private:
|
||||||
unsigned int m_AnimationTemplateHandle;
|
unsigned int m_AnimationTemplateHandle;
|
||||||
bool m_FramesLocked;
|
bool m_FramesLocked;
|
||||||
|
|
||||||
struct ANIMATION_CALLBACK_DATA
|
struct ANIMATION_CALLBACK_DATA {
|
||||||
{
|
|
||||||
ANIMATION_CALLBACK Callback;
|
ANIMATION_CALLBACK Callback;
|
||||||
unsigned int Data;
|
unsigned int Data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,8 +46,7 @@ namespace Sword25 {
|
||||||
// Persistenz
|
// 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(static_cast<unsigned int>(m_AnimationType));
|
||||||
Writer.Write(m_FPS);
|
Writer.Write(m_FPS);
|
||||||
Writer.Write(m_MillisPerFrame);
|
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;
|
unsigned int AnimationType;
|
||||||
Reader.Read(AnimationType);
|
Reader.Read(AnimationType);
|
||||||
m_AnimationType = static_cast<BS_Animation::ANIMATION_TYPES>(AnimationType);
|
m_AnimationType = static_cast<BS_Animation::ANIMATION_TYPES>(AnimationType);
|
||||||
|
|
|
@ -49,8 +49,7 @@ namespace Sword25 {
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_AnimationDescription : public BS_Persistable
|
class BS_AnimationDescription : public BS_Persistable {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
BS_AnimationDescription() :
|
BS_AnimationDescription() :
|
||||||
m_AnimationType(BS_Animation::AT_LOOP),
|
m_AnimationType(BS_Animation::AT_LOOP),
|
||||||
|
@ -62,8 +61,7 @@ protected:
|
||||||
{};
|
{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Frame
|
struct Frame {
|
||||||
{
|
|
||||||
// Die Hotspot-Angabe bezieht sich auf das ungeflippte Bild!!
|
// Die Hotspot-Angabe bezieht sich auf das ungeflippte Bild!!
|
||||||
int HotspotX;
|
int HotspotX;
|
||||||
int HotspotY;
|
int HotspotY;
|
||||||
|
@ -85,12 +83,24 @@ public:
|
||||||
// Getter Methoden
|
// Getter Methoden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Animation::ANIMATION_TYPES GetAnimationType() const { return m_AnimationType; }
|
BS_Animation::ANIMATION_TYPES GetAnimationType() const {
|
||||||
int GetFPS() const { return m_FPS; }
|
return m_AnimationType;
|
||||||
int GetMillisPerFrame() const { return m_MillisPerFrame; }
|
}
|
||||||
bool IsScalingAllowed() const { return m_ScalingAllowed; }
|
int GetFPS() const {
|
||||||
bool IsAlphaAllowed() const { return m_AlphaAllowed; }
|
return m_FPS;
|
||||||
bool IsColorModulationAllowed() const { return m_ColorModulationAllowed; }
|
}
|
||||||
|
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 Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
|
|
@ -54,8 +54,7 @@ namespace Sword25 {
|
||||||
// Constants
|
// Constants
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const int DEFAULT_FPS = 10;
|
const int DEFAULT_FPS = 10;
|
||||||
const int MIN_FPS = 1;
|
const int MIN_FPS = 1;
|
||||||
const int MAX_FPS = 200;
|
const int MAX_FPS = 200;
|
||||||
|
@ -67,8 +66,7 @@ namespace
|
||||||
|
|
||||||
BS_AnimationResource::BS_AnimationResource(const Common::String &FileName) :
|
BS_AnimationResource::BS_AnimationResource(const Common::String &FileName) :
|
||||||
BS_Resource(FileName, BS_Resource::TYPE_ANIMATION),
|
BS_Resource(FileName, BS_Resource::TYPE_ANIMATION),
|
||||||
m_Valid(false)
|
m_Valid(false) {
|
||||||
{
|
|
||||||
// Pointer auf den Package-Manager bekommen
|
// Pointer auf den Package-Manager bekommen
|
||||||
BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
|
BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
|
||||||
BS_ASSERT(PackagePtr);
|
BS_ASSERT(PackagePtr);
|
||||||
|
@ -80,8 +78,7 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
// NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
|
// NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
|
||||||
unsigned int FileSize;
|
unsigned int FileSize;
|
||||||
char *LoadBuffer = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
|
char *LoadBuffer = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
|
||||||
if (!LoadBuffer)
|
if (!LoadBuffer) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +91,7 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
// Datei parsen
|
// Datei parsen
|
||||||
Doc.Parse(&WorkBuffer[0]);
|
Doc.Parse(&WorkBuffer[0]);
|
||||||
free(WorkBuffer);
|
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());
|
BS_LOG_ERRORLN("The following TinyXML-Error occured while parsing \"%s\": %s", GetFileName().c_str(), Doc.ErrorDesc());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,16 +101,14 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
TiXmlElement *pElement;
|
TiXmlElement *pElement;
|
||||||
{
|
{
|
||||||
TiXmlNode *pNode = Doc.FirstChild("animation");
|
TiXmlNode *pNode = Doc.FirstChild("animation");
|
||||||
if (!pNode || pNode->Type() != TiXmlNode::ELEMENT)
|
if (!pNode || pNode->Type() != TiXmlNode::ELEMENT) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("No <animation> tag found in \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("No <animation> tag found in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pElement = pNode->ToElement();
|
pElement = pNode->ToElement();
|
||||||
|
|
||||||
// Animation-Tag parsen
|
// 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());
|
BS_LOG_ERRORLN("An error occurred while parsing <animation> tag in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,12 +126,10 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
|
|
||||||
// Nacheinander alle Frames-Informationen erstellen.
|
// Nacheinander alle Frames-Informationen erstellen.
|
||||||
TiXmlElement *pFrameElement = pElement->FirstChild("frame")->ToElement();
|
TiXmlElement *pFrameElement = pElement->FirstChild("frame")->ToElement();
|
||||||
while (pFrameElement)
|
while (pFrameElement) {
|
||||||
{
|
|
||||||
Frame CurFrame;
|
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());
|
BS_LOG_ERRORLN("An error occurred in \"%s\" while parsing <frame> tag.", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -150,22 +142,19 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
PackagePtr->ChangeDirectory(OldDirectory);
|
PackagePtr->ChangeDirectory(OldDirectory);
|
||||||
|
|
||||||
// Sicherstellen, dass die Animation mindestens einen Frame besitzt
|
// 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());
|
BS_LOG_ERRORLN("\"%s\" does not have any frames.", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alle Frame-Dateien werden vorgecached
|
// Alle Frame-Dateien werden vorgecached
|
||||||
if (!PrecacheAllFrames())
|
if (!PrecacheAllFrames()) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not precache all frames of \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("Could not precache all frames of \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feststellen, ob die Animation skalierbar ist
|
// Feststellen, ob die Animation skalierbar ist
|
||||||
if (!ComputeFeatures())
|
if (!ComputeFeatures()) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not determine the features of \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("Could not determine the features of \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,27 +166,22 @@ BS_AnimationResource::BS_AnimationResource(const Common::String& FileName) :
|
||||||
// Dokument-Parsermethoden
|
// 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
|
// FPS einlesen
|
||||||
const char *FPSString;
|
const char *FPSString;
|
||||||
if (FPSString = AnimationTag.Attribute("fps"))
|
if (FPSString = AnimationTag.Attribute("fps")) {
|
||||||
{
|
|
||||||
int TempFPS;
|
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\"). "
|
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.",
|
"The fps value has to be between %d and %d.",
|
||||||
FPSString, GetFileName().c_str(), DEFAULT_FPS, MIN_FPS, MAX_FPS);
|
FPSString, GetFileName().c_str(), DEFAULT_FPS, MIN_FPS, MAX_FPS);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
FPS = TempFPS;
|
FPS = TempFPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop-Typ einlesen
|
// Loop-Typ einlesen
|
||||||
const char *LoopTypeString;
|
const char *LoopTypeString;
|
||||||
if (LoopTypeString = AnimationTag.Attribute("type"))
|
if (LoopTypeString = AnimationTag.Attribute("type")) {
|
||||||
{
|
|
||||||
if (strcmp(LoopTypeString, "oneshot") == 0)
|
if (strcmp(LoopTypeString, "oneshot") == 0)
|
||||||
AnimationType = BS_Animation::AT_ONESHOT;
|
AnimationType = BS_Animation::AT_ONESHOT;
|
||||||
else if (strcmp(LoopTypeString, "loop") == 0)
|
else if (strcmp(LoopTypeString, "loop") == 0)
|
||||||
|
@ -214,17 +198,14 @@ bool BS_AnimationResource::ParseAnimationTag(TiXmlElement& AnimationTag, int& FP
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationResource::ParseFrameTag(TiXmlElement& FrameTag, Frame& Frame_, BS_PackageManager& PackageManager)
|
bool BS_AnimationResource::ParseFrameTag(TiXmlElement &FrameTag, Frame &Frame_, BS_PackageManager &PackageManager) {
|
||||||
{
|
|
||||||
const char *FileString = FrameTag.Attribute("file");
|
const char *FileString = FrameTag.Attribute("file");
|
||||||
if (!FileString)
|
if (!FileString) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Frame_.FileName = PackageManager.GetAbsolutePath(FileString);
|
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);
|
BS_LOG_ERRORLN("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".", GetFileName().c_str(), FileString);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -253,29 +234,23 @@ bool BS_AnimationResource::ParseFrameTag(TiXmlElement& FrameTag, Frame& Frame_,
|
||||||
HotspotyString, GetFileName().c_str(), Frame_.HotspotY);
|
HotspotyString, GetFileName().c_str(), Frame_.HotspotY);
|
||||||
|
|
||||||
const char *FlipVString = FrameTag.Attribute("flipv");
|
const char *FlipVString = FrameTag.Attribute("flipv");
|
||||||
if (FlipVString)
|
if (FlipVString) {
|
||||||
{
|
if (!BS_String::ToBool(Common::String(FlipVString), Frame_.FlipV)) {
|
||||||
if (!BS_String::ToBool(Common::String(FlipVString), Frame_.FlipV))
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Illegal flipv value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").",
|
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;
|
Frame_.FlipV = false;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
Frame_.FlipV = false;
|
Frame_.FlipV = false;
|
||||||
|
|
||||||
const char *FlipHString = FrameTag.Attribute("fliph");
|
const char *FlipHString = FrameTag.Attribute("fliph");
|
||||||
if (FlipHString)
|
if (FlipHString) {
|
||||||
{
|
if (!BS_String::ToBool(FlipHString, Frame_.FlipH)) {
|
||||||
if (!BS_String::ToBool(FlipHString, Frame_.FlipH))
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Illegal fliph value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").",
|
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;
|
Frame_.FlipH = false;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
Frame_.FlipH = false;
|
Frame_.FlipH = false;
|
||||||
|
|
||||||
return true;
|
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();
|
Common::Array<Frame>::const_iterator Iter = m_Frames.begin();
|
||||||
for (; Iter != m_Frames.end(); ++Iter)
|
for (; Iter != m_Frames.end(); ++Iter) {
|
||||||
{
|
if (!BS_Kernel::GetInstance()->GetResourceManager()->PrecacheResource((*Iter).FileName)) {
|
||||||
if (!BS_Kernel::GetInstance()->GetResourceManager()->PrecacheResource((*Iter).FileName))
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not precache \"%s\".", (*Iter).FileName.c_str());
|
BS_LOG_ERRORLN("Could not precache \"%s\".", (*Iter).FileName.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -306,8 +277,7 @@ bool BS_AnimationResource::PrecacheAllFrames() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationResource::ComputeFeatures()
|
bool BS_AnimationResource::ComputeFeatures() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_Frames.size());
|
BS_ASSERT(m_Frames.size());
|
||||||
|
|
||||||
// Alle Features werden als vorhanden angenommen
|
// 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.
|
// 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();
|
Common::Array<Frame>::const_iterator Iter = m_Frames.begin();
|
||||||
for (; Iter != m_Frames.end(); ++Iter)
|
for (; Iter != m_Frames.end(); ++Iter) {
|
||||||
{
|
|
||||||
BS_BitmapResource *pBitmap;
|
BS_BitmapResource *pBitmap;
|
||||||
if (!(pBitmap = static_cast<BS_BitmapResource*> (BS_Kernel::GetInstance()->GetResourceManager()->RequestResource((*Iter).FileName))))
|
if (!(pBitmap = static_cast<BS_BitmapResource *>(BS_Kernel::GetInstance()->GetResourceManager()->RequestResource((*Iter).FileName)))) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not request \"%s\".", (*Iter).FileName.c_str());
|
BS_LOG_ERRORLN("Could not request \"%s\".", (*Iter).FileName.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,23 +63,43 @@ class BS_PackageManager;
|
||||||
// Class Definition
|
// Class Definition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_AnimationResource : public BS_Resource, public BS_AnimationDescription
|
class BS_AnimationResource : public BS_Resource, public BS_AnimationDescription {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_AnimationResource(const Common::String &FileName);
|
BS_AnimationResource(const Common::String &FileName);
|
||||||
virtual ~BS_AnimationResource();
|
virtual ~BS_AnimationResource();
|
||||||
|
|
||||||
virtual const Frame & GetFrame(unsigned int Index) const { BS_ASSERT(Index < m_Frames.size()); return m_Frames[Index]; }
|
virtual const Frame &GetFrame(unsigned int Index) const {
|
||||||
virtual unsigned int GetFrameCount() const { return m_Frames.size(); }
|
BS_ASSERT(Index < m_Frames.size());
|
||||||
virtual void Unlock() { Release(); }
|
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; }
|
BS_Animation::ANIMATION_TYPES GetAnimationType() const {
|
||||||
int GetFPS() const { return m_FPS; }
|
return m_AnimationType;
|
||||||
int GetMillisPerFrame() const { return m_MillisPerFrame; }
|
}
|
||||||
bool IsScalingAllowed() const { return m_ScalingAllowed; }
|
int GetFPS() const {
|
||||||
bool IsAlphaAllowed() const { return m_AlphaAllowed; }
|
return m_FPS;
|
||||||
bool IsColorModulationAllowed() const { return m_ColorModulationAllowed; }
|
}
|
||||||
bool IsValid() const { return m_Valid; }
|
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:
|
private:
|
||||||
bool m_Valid;
|
bool m_Valid;
|
||||||
|
|
|
@ -53,16 +53,12 @@ namespace Sword25 {
|
||||||
// Konstruktion / Destruktion
|
// Konstruktion / Destruktion
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned int BS_AnimationTemplate::Create(const Common::String & SourceAnimation)
|
unsigned int BS_AnimationTemplate::Create(const Common::String &SourceAnimation) {
|
||||||
{
|
|
||||||
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(SourceAnimation);
|
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(SourceAnimation);
|
||||||
|
|
||||||
if (AnimationTemplatePtr->IsValid())
|
if (AnimationTemplatePtr->IsValid()) {
|
||||||
{
|
|
||||||
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
delete AnimationTemplatePtr;
|
delete AnimationTemplatePtr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,16 +66,12 @@ unsigned int BS_AnimationTemplate::Create(const Common::String & SourceAnimation
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned int BS_AnimationTemplate::Create(const BS_AnimationTemplate & Other)
|
unsigned int BS_AnimationTemplate::Create(const BS_AnimationTemplate &Other) {
|
||||||
{
|
|
||||||
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Other);
|
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Other);
|
||||||
|
|
||||||
if (AnimationTemplatePtr->IsValid())
|
if (AnimationTemplatePtr->IsValid()) {
|
||||||
{
|
|
||||||
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
delete AnimationTemplatePtr;
|
delete AnimationTemplatePtr;
|
||||||
return 0;
|
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)
|
unsigned int BS_AnimationTemplate::Create(BS_InputPersistenceBlock &Reader, unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Reader, Handle);
|
BS_AnimationTemplate *AnimationTemplatePtr = new BS_AnimationTemplate(Reader, Handle);
|
||||||
|
|
||||||
if (AnimationTemplatePtr->IsValid())
|
if (AnimationTemplatePtr->IsValid()) {
|
||||||
{
|
|
||||||
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
return BS_AnimationTemplateRegistry::GetInstance().ResolvePtr(AnimationTemplatePtr);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
delete AnimationTemplatePtr;
|
delete AnimationTemplatePtr;
|
||||||
return 0;
|
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.
|
// Objekt registrieren.
|
||||||
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this);
|
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.
|
// Objekt registrieren.
|
||||||
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this);
|
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this);
|
||||||
|
|
||||||
|
@ -147,8 +133,7 @@ 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.
|
// Objekt registrieren.
|
||||||
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this, Handle);
|
BS_AnimationTemplateRegistry::GetInstance().RegisterObject(this, Handle);
|
||||||
|
|
||||||
|
@ -158,12 +143,10 @@ BS_AnimationTemplate::BS_AnimationTemplate(BS_InputPersistenceBlock & Reader, un
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_AnimationResource * BS_AnimationTemplate::RequestSourceAnimation(const Common::String & SourceAnimation) const
|
BS_AnimationResource *BS_AnimationTemplate::RequestSourceAnimation(const Common::String &SourceAnimation) const {
|
||||||
{
|
|
||||||
BS_ResourceManager *RMPtr = BS_Kernel::GetInstance()->GetResourceManager();
|
BS_ResourceManager *RMPtr = BS_Kernel::GetInstance()->GetResourceManager();
|
||||||
BS_Resource *ResourcePtr;
|
BS_Resource *ResourcePtr;
|
||||||
if (NULL == (ResourcePtr = RMPtr->RequestResource(SourceAnimation)) || ResourcePtr->GetType() != BS_Resource::TYPE_ANIMATION)
|
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());
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -172,11 +155,9 @@ BS_AnimationResource * BS_AnimationTemplate::RequestSourceAnimation(const Common
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_AnimationTemplate::~BS_AnimationTemplate()
|
BS_AnimationTemplate::~BS_AnimationTemplate() {
|
||||||
{
|
|
||||||
// Animations-Resource freigeben
|
// Animations-Resource freigeben
|
||||||
if (m_SourceAnimationPtr)
|
if (m_SourceAnimationPtr) {
|
||||||
{
|
|
||||||
m_SourceAnimationPtr->Release();
|
m_SourceAnimationPtr->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,64 +167,52 @@ BS_AnimationTemplate::~BS_AnimationTemplate()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_AnimationTemplate::AddFrame(int Index)
|
void BS_AnimationTemplate::AddFrame(int Index) {
|
||||||
{
|
if (ValidateSourceIndex(Index)) {
|
||||||
if (ValidateSourceIndex(Index))
|
|
||||||
{
|
|
||||||
m_Frames.push_back(m_SourceAnimationPtr->GetFrame(Index));
|
m_Frames.push_back(m_SourceAnimationPtr->GetFrame(Index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_AnimationTemplate::SetFrame(int DestIndex, int SrcIndex)
|
void BS_AnimationTemplate::SetFrame(int DestIndex, int SrcIndex) {
|
||||||
{
|
if (ValidateDestIndex(DestIndex) && ValidateSourceIndex(SrcIndex)) {
|
||||||
if (ValidateDestIndex(DestIndex) && ValidateSourceIndex(SrcIndex))
|
|
||||||
{
|
|
||||||
m_Frames[DestIndex] = m_SourceAnimationPtr->GetFrame(SrcIndex);
|
m_Frames[DestIndex] = m_SourceAnimationPtr->GetFrame(SrcIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationTemplate::ValidateSourceIndex(unsigned int Index) const
|
bool BS_AnimationTemplate::ValidateSourceIndex(unsigned int Index) const {
|
||||||
{
|
if (Index > m_SourceAnimationPtr->GetFrameCount()) {
|
||||||
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.",
|
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;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationTemplate::ValidateDestIndex(unsigned int Index) const
|
bool BS_AnimationTemplate::ValidateDestIndex(unsigned int Index) const {
|
||||||
{
|
if (Index > m_Frames.size()) {
|
||||||
if (Index > m_Frames.size())
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Tried to change a nonexistent frame (\"%d\") in a template animation. Ignoring call.",
|
BS_LOG_WARNINGLN("Tried to change a nonexistent frame (\"%d\") in a template animation. Ignoring call.",
|
||||||
Index);
|
Index);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_AnimationTemplate::SetFPS(int FPS)
|
void BS_AnimationTemplate::SetFPS(int FPS) {
|
||||||
{
|
|
||||||
m_FPS = FPS;
|
m_FPS = FPS;
|
||||||
m_MillisPerFrame = 1000000 / m_FPS;
|
m_MillisPerFrame = 1000000 / m_FPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
// Parent persistieren.
|
// Parent persistieren.
|
||||||
|
@ -254,8 +223,7 @@ bool BS_AnimationTemplate::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
|
|
||||||
// Frames einzeln persistieren.
|
// Frames einzeln persistieren.
|
||||||
Common::Array<const Frame>::const_iterator Iter = m_Frames.begin();
|
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->HotspotX);
|
||||||
Writer.Write(Iter->HotspotY);
|
Writer.Write(Iter->HotspotY);
|
||||||
Writer.Write(Iter->FlipV);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
// Parent wieder herstellen.
|
// Parent wieder herstellen.
|
||||||
|
@ -286,8 +253,7 @@ bool BS_AnimationTemplate::Unpersist(BS_InputPersistenceBlock & Reader)
|
||||||
Reader.Read(FrameCount);
|
Reader.Read(FrameCount);
|
||||||
|
|
||||||
// Frames einzeln wieder herstellen.
|
// Frames einzeln wieder herstellen.
|
||||||
for (unsigned int i = 0; i < FrameCount; ++i)
|
for (unsigned int i = 0; i < FrameCount; ++i) {
|
||||||
{
|
|
||||||
Frame frame;
|
Frame frame;
|
||||||
Reader.Read(frame.HotspotX);
|
Reader.Read(frame.HotspotX);
|
||||||
Reader.Read(frame.HotspotY);
|
Reader.Read(frame.HotspotY);
|
||||||
|
|
|
@ -59,8 +59,7 @@ class BS_AnimationResource;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_AnimationTemplate : public BS_AnimationDescription
|
class BS_AnimationTemplate : public BS_AnimationDescription {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static unsigned int Create(const Common::String &SourceAnimation);
|
static unsigned int Create(const Common::String &SourceAnimation);
|
||||||
static unsigned int Create(const BS_AnimationTemplate &Other);
|
static unsigned int Create(const BS_AnimationTemplate &Other);
|
||||||
|
@ -75,11 +74,20 @@ private:
|
||||||
public:
|
public:
|
||||||
~BS_AnimationTemplate();
|
~BS_AnimationTemplate();
|
||||||
|
|
||||||
virtual const Frame & GetFrame(unsigned int Index) const { BS_ASSERT(Index < m_Frames.size()); return m_Frames[Index]; }
|
virtual const Frame &GetFrame(unsigned int Index) const {
|
||||||
virtual unsigned int GetFrameCount() const { return m_Frames.size(); }
|
BS_ASSERT(Index < m_Frames.size());
|
||||||
virtual void Unlock() { delete this; }
|
return m_Frames[Index];
|
||||||
|
}
|
||||||
|
virtual unsigned int GetFrameCount() const {
|
||||||
|
return m_Frames.size();
|
||||||
|
}
|
||||||
|
virtual void Unlock() {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsValid() const { return m_Valid; }
|
bool IsValid() const {
|
||||||
|
return m_Valid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Fügt einen neuen Frame zur Animation hinzu.
|
@brief Fügt einen neuen Frame zur Animation hinzu.
|
||||||
|
@ -101,7 +109,9 @@ public:
|
||||||
@brief Setzt den Animationstyp.
|
@brief Setzt den Animationstyp.
|
||||||
@param Type der Typ der Animation. Muss aus den enum BS_Animation::ANIMATION_TYPES sein.
|
@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.
|
@brief Setzt die Abspielgeschwindigkeit.
|
||||||
|
|
|
@ -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);
|
BS_LOG_ERRORLN(Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_AnimationTemplateRegistry::LogWarningLn(const char * Message) const
|
void BS_AnimationTemplateRegistry::LogWarningLn(const char *Message) const {
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN(Message);
|
BS_LOG_WARNINGLN(Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
// Das nächste zu vergebene Handle schreiben.
|
// Das nächste zu vergebene Handle schreiben.
|
||||||
|
@ -83,8 +80,7 @@ bool BS_AnimationTemplateRegistry::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
|
|
||||||
// Alle BS_AnimationTemplates persistieren.
|
// Alle BS_AnimationTemplates persistieren.
|
||||||
HANDLE2PTR_MAP::const_iterator Iter = m_Handle2PtrMap.begin();
|
HANDLE2PTR_MAP::const_iterator Iter = m_Handle2PtrMap.begin();
|
||||||
while (Iter != m_Handle2PtrMap.end())
|
while (Iter != m_Handle2PtrMap.end()) {
|
||||||
{
|
|
||||||
// Handle persistieren.
|
// Handle persistieren.
|
||||||
Writer.Write(Iter->first);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
// Das nächste zu vergebene Handle wieder herstellen.
|
// Das nächste zu vergebene Handle wieder herstellen.
|
||||||
|
@ -114,8 +109,7 @@ bool BS_AnimationTemplateRegistry::Unpersist(BS_InputPersistenceBlock & Reader)
|
||||||
Reader.Read(AnimationTemplateCount);
|
Reader.Read(AnimationTemplateCount);
|
||||||
|
|
||||||
// Alle gespeicherten BS_AnimationTemplates wieder herstellen.
|
// Alle gespeicherten BS_AnimationTemplates wieder herstellen.
|
||||||
for (unsigned int i = 0; i < AnimationTemplateCount; ++i)
|
for (unsigned int i = 0; i < AnimationTemplateCount; ++i) {
|
||||||
{
|
|
||||||
// Handle lesen.
|
// Handle lesen.
|
||||||
unsigned int Handle;
|
unsigned int Handle;
|
||||||
Reader.Read(Handle);
|
Reader.Read(Handle);
|
||||||
|
|
|
@ -59,11 +59,9 @@ class BS_AnimationTemplate;
|
||||||
// Klassendeklaration
|
// Klassendeklaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_AnimationTemplateRegistry : public BS_ObjectRegistry<BS_AnimationTemplate>, public BS_Persistable
|
class BS_AnimationTemplateRegistry : public BS_ObjectRegistry<BS_AnimationTemplate>, public BS_Persistable {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static BS_AnimationTemplateRegistry & GetInstance()
|
static BS_AnimationTemplateRegistry &GetInstance() {
|
||||||
{
|
|
||||||
if (!m_InstancePtr.get()) m_InstancePtr.reset(new BS_AnimationTemplateRegistry);
|
if (!m_InstancePtr.get()) m_InstancePtr.reset(new BS_AnimationTemplateRegistry);
|
||||||
return *m_InstancePtr.get();
|
return *m_InstancePtr.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,30 +58,25 @@ BS_Bitmap::BS_Bitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, TYPES Type,
|
||||||
m_ScaleFactorX(1.0f),
|
m_ScaleFactorX(1.0f),
|
||||||
m_ScaleFactorY(1.0f),
|
m_ScaleFactorY(1.0f),
|
||||||
m_FlipH(false),
|
m_FlipH(false),
|
||||||
m_FlipV(false)
|
m_FlipV(false) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Bitmap::~BS_Bitmap()
|
BS_Bitmap::~BS_Bitmap() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Darstellungsart festlegen
|
// Darstellungsart festlegen
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Bitmap::SetAlpha(int Alpha)
|
void BS_Bitmap::SetAlpha(int Alpha) {
|
||||||
{
|
if (!IsAlphaAllowed()) {
|
||||||
if (!IsAlphaAllowed())
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Tried to set alpha value on a bitmap that does not support alpha blending. Call was ignored.");
|
BS_LOG_WARNINGLN("Tried to set alpha value on a bitmap that does not support alpha blending. Call was ignored.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Alpha < 0 || Alpha > 255)
|
if (Alpha < 0 || Alpha > 255) {
|
||||||
{
|
|
||||||
int OldAlpha = Alpha;
|
int OldAlpha = Alpha;
|
||||||
if (Alpha < 0) Alpha = 0;
|
if (Alpha < 0) Alpha = 0;
|
||||||
if (Alpha > 255) Alpha = 255;
|
if (Alpha > 255) Alpha = 255;
|
||||||
|
@ -91,8 +86,7 @@ void BS_Bitmap::SetAlpha(int Alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
@ -100,17 +94,14 @@ void BS_Bitmap::SetAlpha(int Alpha)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Bitmap::SetModulationColor(unsigned int ModulationColor)
|
void BS_Bitmap::SetModulationColor(unsigned int ModulationColor) {
|
||||||
{
|
if (!IsColorModulationAllowed()) {
|
||||||
if (!IsColorModulationAllowed())
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Tried to set modulation color of a bitmap that does not support color modulation. Call was ignored.");
|
BS_LOG_WARNINGLN("Tried to set modulation color of a bitmap that does not support color modulation. Call was ignored.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
|
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
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);
|
SetScaleFactorX(ScaleFactor);
|
||||||
SetScaleFactorY(ScaleFactor);
|
SetScaleFactorY(ScaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Bitmap::SetScaleFactorX(float ScaleFactorX)
|
void BS_Bitmap::SetScaleFactorX(float ScaleFactorX) {
|
||||||
{
|
if (!IsScalingAllowed()) {
|
||||||
if (!IsScalingAllowed())
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
|
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
|
||||||
return;
|
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.");
|
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScaleFactorX != m_ScaleFactorX)
|
if (ScaleFactorX != m_ScaleFactorX) {
|
||||||
{
|
|
||||||
m_ScaleFactorX = ScaleFactorX;
|
m_ScaleFactorX = ScaleFactorX;
|
||||||
m_Width = static_cast<int>(m_OriginalWidth * m_ScaleFactorX);
|
m_Width = static_cast<int>(m_OriginalWidth * m_ScaleFactorX);
|
||||||
if (m_ScaleFactorX <= 0.0f) m_ScaleFactorX = 0.001f;
|
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)
|
void BS_Bitmap::SetScaleFactorY(float ScaleFactorY) {
|
||||||
{
|
if (!IsScalingAllowed()) {
|
||||||
if (!IsScalingAllowed())
|
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
|
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored.");
|
||||||
return;
|
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.");
|
BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScaleFactorY != m_ScaleFactorY)
|
if (ScaleFactorY != m_ScaleFactorY) {
|
||||||
{
|
|
||||||
m_ScaleFactorY = ScaleFactorY;
|
m_ScaleFactorY = ScaleFactorY;
|
||||||
m_Height = static_cast<int>(m_OriginalHeight * ScaleFactorY);
|
m_Height = static_cast<int>(m_OriginalHeight * ScaleFactorY);
|
||||||
if (m_ScaleFactorY <= 0.0f) m_ScaleFactorY = 0.001f;
|
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;
|
m_FlipH = FlipH;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Bitmap::SetFlipV(bool FlipV)
|
void BS_Bitmap::SetFlipV(bool FlipV) {
|
||||||
{
|
|
||||||
m_FlipV = FlipV;
|
m_FlipV = FlipV;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
@ -194,8 +174,7 @@ void BS_Bitmap::SetFlipV(bool FlipV)
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Bitmap::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_Bitmap::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Persist(Writer);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Unpersist(Reader);
|
Result &= BS_RenderObject::Unpersist(Reader);
|
||||||
|
|
|
@ -48,8 +48,7 @@ namespace Sword25 {
|
||||||
// Klassendeklaration
|
// Klassendeklaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_Bitmap : public BS_RenderObject
|
class BS_Bitmap : public BS_RenderObject {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
BS_Bitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, TYPES Type, unsigned int Handle = 0);
|
BS_Bitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, TYPES Type, unsigned int Handle = 0);
|
||||||
|
|
||||||
|
@ -106,35 +105,47 @@ public:
|
||||||
@brief Gibt den aktuellen Alphawert des Bildes zurück.
|
@brief Gibt den aktuellen Alphawert des Bildes zurück.
|
||||||
@remark Diese Methode darf nur aufgerufen werden, wenn die Methode IsAlphaAllowed() true zurückgibt.
|
@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.
|
@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.
|
@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.
|
@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.
|
@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.
|
@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.
|
@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
|
// Die folgenden Methoden müssen alle BS_Bitmap-Klassen implementieren
|
||||||
|
|
|
@ -50,20 +50,17 @@ namespace Sword25 {
|
||||||
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_Valid(false),
|
||||||
m_pImage(pImage),
|
m_pImage(pImage),
|
||||||
BS_Resource(Filename, BS_Resource::TYPE_BITMAP)
|
BS_Resource(Filename, BS_Resource::TYPE_BITMAP) {
|
||||||
{
|
|
||||||
m_Valid = m_pImage != 0;
|
m_Valid = m_pImage != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_BitmapResource::~BS_BitmapResource()
|
BS_BitmapResource::~BS_BitmapResource() {
|
||||||
{
|
|
||||||
delete m_pImage;
|
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(X >= 0 && X < m_pImage->GetWidth());
|
||||||
BS_ASSERT(Y >= 0 && Y < m_pImage->GetHeight());
|
BS_ASSERT(Y >= 0 && Y < m_pImage->GetHeight());
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,12 @@ namespace Sword25 {
|
||||||
|
|
||||||
class BS_Rect;
|
class BS_Rect;
|
||||||
|
|
||||||
class BS_BitmapResource : public BS_Resource
|
class BS_BitmapResource : public BS_Resource {
|
||||||
{
|
|
||||||
public:
|
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.
|
/// Das Bild wird nicht gespiegelt.
|
||||||
FLIP_NONE = 0,
|
FLIP_NONE = 0,
|
||||||
/// Das Bild wird an der horizontalen Achse gespiegelt.
|
/// Das Bild wird an der horizontalen Achse gespiegelt.
|
||||||
|
@ -74,17 +72,25 @@ public:
|
||||||
/**
|
/**
|
||||||
@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.
|
@brief Rendert das Bild in den Framebuffer.
|
||||||
|
@ -126,8 +132,7 @@ public:
|
||||||
int Flipping = FLIP_NONE,
|
int Flipping = FLIP_NONE,
|
||||||
BS_Rect *pSrcPartRect = NULL,
|
BS_Rect *pSrcPartRect = NULL,
|
||||||
unsigned int Color = BS_ARGB(255, 255, 255, 255),
|
unsigned int Color = BS_ARGB(255, 255, 255, 255),
|
||||||
int Width = -1, int Height = -1)
|
int Width = -1, int Height = -1) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_pImage);
|
BS_ASSERT(m_pImage);
|
||||||
return m_pImage->Blit(PosX, PosY, Flipping, pSrcPartRect, Color, Width, Height);
|
return m_pImage->Blit(PosX, PosY, Flipping, pSrcPartRect, Color, Width, Height);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +150,10 @@ public:
|
||||||
BS_RGB und BS_ARGB benutzt werden.
|
BS_RGB und BS_ARGB benutzt werden.
|
||||||
@remark Falls das Rechteck nicht völlig innerhalb des Bildschirms ist, wird es automatisch zurechtgestutzt.
|
@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.
|
@brief Liest einen Pixel des Bildes.
|
||||||
|
@ -164,27 +172,42 @@ public:
|
||||||
@brief Überprüft, ob das BS_Image ein Zielbild für einen Blit-Aufruf sein kann.
|
@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.
|
@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:
|
private:
|
||||||
BS_Image *m_pImage;
|
BS_Image *m_pImage;
|
||||||
|
|
|
@ -56,8 +56,7 @@ namespace Sword25 {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_DynamicBitmap::BS_DynamicBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Width, unsigned int Height) :
|
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.
|
// Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
||||||
if (!m_InitSuccess) return;
|
if (!m_InitSuccess) return;
|
||||||
|
|
||||||
|
@ -67,15 +66,13 @@ 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_DynamicBitmap::BS_DynamicBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
|
||||||
BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP, Handle)
|
BS_Bitmap(ParentPtr, TYPE_DYNAMICBITMAP, Handle) {
|
||||||
{
|
|
||||||
m_InitSuccess = Unpersist(Reader);
|
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
|
// GLImage mit den gewünschten Maßen erstellen
|
||||||
bool Result;
|
bool Result;
|
||||||
m_Image.reset(new BS_GLImage(Width, Height, 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(X >= 0 && X < m_Width);
|
||||||
BS_ASSERT(Y >= 0 && Y < m_Height);
|
BS_ASSERT(Y >= 0 && Y < m_Height);
|
||||||
|
|
||||||
|
@ -104,23 +99,19 @@ unsigned int BS_DynamicBitmap::GetPixel(int X, int Y) const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::DoRender()
|
bool BS_DynamicBitmap::DoRender() {
|
||||||
{
|
|
||||||
// Framebufferobjekt holen
|
// 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);
|
BS_ASSERT(pGfx);
|
||||||
|
|
||||||
// Bitmap zeichnen
|
// Bitmap zeichnen
|
||||||
bool Result;
|
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,
|
Result = m_Image->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
0, m_ModulationColor, -1, -1);
|
0, m_ModulationColor, -1, -1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Result = m_Image->Blit(m_AbsoluteX, m_AbsoluteY,
|
Result = m_Image->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
|
@ -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);
|
return m_Image->SetContent(Pixeldata, Offset, Stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,29 +131,25 @@ bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, un
|
||||||
// Auskunftsmethoden
|
// Auskunftsmethoden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::IsScalingAllowed() const
|
bool BS_DynamicBitmap::IsScalingAllowed() const {
|
||||||
{
|
|
||||||
return m_Image->IsScalingAllowed();
|
return m_Image->IsScalingAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::IsAlphaAllowed() const
|
bool BS_DynamicBitmap::IsAlphaAllowed() const {
|
||||||
{
|
|
||||||
return m_Image->IsAlphaAllowed();
|
return m_Image->IsAlphaAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::IsColorModulationAllowed() const
|
bool BS_DynamicBitmap::IsColorModulationAllowed() const {
|
||||||
{
|
|
||||||
return m_Image->IsColorModulationAllowed();
|
return m_Image->IsColorModulationAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::IsSetContentAllowed() const
|
bool BS_DynamicBitmap::IsSetContentAllowed() const {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +157,7 @@ bool BS_DynamicBitmap::IsSetContentAllowed() const
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_Bitmap::Persist(Writer);
|
Result &= BS_Bitmap::Persist(Writer);
|
||||||
|
@ -186,8 +171,7 @@ bool BS_DynamicBitmap::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BS_DynamicBitmap::Unpersist(BS_InputPersistenceBlock & Reader)
|
bool BS_DynamicBitmap::Unpersist(BS_InputPersistenceBlock &Reader) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_Bitmap::Unpersist(Reader);
|
Result &= BS_Bitmap::Unpersist(Reader);
|
||||||
|
|
|
@ -54,8 +54,7 @@ namespace Sword25 {
|
||||||
// Klassendeklaration
|
// Klassendeklaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_DynamicBitmap : public BS_Bitmap
|
class BS_DynamicBitmap : public BS_Bitmap {
|
||||||
{
|
|
||||||
friend class BS_RenderObject;
|
friend class BS_RenderObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -63,28 +63,24 @@ static const unsigned int DEFAULT_GAPWIDTH = 1;
|
||||||
BS_FontResource::BS_FontResource(BS_Kernel *pKernel, const Common::String &FileName) :
|
BS_FontResource::BS_FontResource(BS_Kernel *pKernel, const Common::String &FileName) :
|
||||||
_pKernel(pKernel),
|
_pKernel(pKernel),
|
||||||
_Valid(false),
|
_Valid(false),
|
||||||
BS_Resource(FileName, BS_Resource::TYPE_FONT)
|
BS_Resource(FileName, BS_Resource::TYPE_FONT) {
|
||||||
{
|
|
||||||
// XML Fontdatei parsen
|
// XML Fontdatei parsen
|
||||||
TiXmlDocument Doc;
|
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());
|
BS_LOG_ERRORLN("The following TinyXML-Error occured while parsing \"%s\": %s", GetFileName().c_str(), Doc.ErrorDesc());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font-Tag finden
|
// Font-Tag finden
|
||||||
TiXmlElement *pElement = Doc.FirstChildElement("font");
|
TiXmlElement *pElement = Doc.FirstChildElement("font");
|
||||||
if (!pElement)
|
if (!pElement) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("No <font> tag found in \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("No <font> tag found in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font-Tag parsen
|
// Font-Tag parsen
|
||||||
Common::String BitmapFileName;
|
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());
|
BS_LOG_ERRORLN("An error occurred while parsing <font> tag in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,16 +94,14 @@ BS_FontResource::BS_FontResource(BS_Kernel* pKernel, const Common::String& FileN
|
||||||
|
|
||||||
// Absoluten, eindeutigen Pfad bestimmen
|
// Absoluten, eindeutigen Pfad bestimmen
|
||||||
_BitmapFileName = pPackage->GetAbsolutePath(BitmapFileName);
|
_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.",
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bitmapdatei cachen
|
// Bitmapdatei cachen
|
||||||
if (!_pKernel->GetResourceManager()->PrecacheResource(_BitmapFileName))
|
if (!_pKernel->GetResourceManager()->PrecacheResource(_BitmapFileName)) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not precache \"%s\".", _BitmapFileName.c_str());
|
BS_LOG_ERRORLN("Could not precache \"%s\".", _BitmapFileName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -115,21 +109,18 @@ BS_FontResource::BS_FontResource(BS_Kernel* pKernel, const Common::String& FileN
|
||||||
|
|
||||||
// Das Erste Character-Tag finden
|
// Das Erste Character-Tag finden
|
||||||
pElement = pElement->FirstChildElement("character");
|
pElement = pElement->FirstChildElement("character");
|
||||||
if (!pElement)
|
if (!pElement) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("No <character> tag found in \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("No <character> tag found in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alle Character-Tags parsen
|
// Alle Character-Tags parsen
|
||||||
while (pElement)
|
while (pElement) {
|
||||||
{
|
|
||||||
int CharCode;
|
int CharCode;
|
||||||
BS_Rect CharRect;
|
BS_Rect CharRect;
|
||||||
|
|
||||||
// Aktuelles Character-Tag parsen
|
// 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());
|
BS_LOG_ERRORLN("An error occured while parsing a <character> tag in \"%s\".", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -148,8 +139,7 @@ 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
|
// Pointer auf den Package-Manager bekommen
|
||||||
BS_ASSERT(_pKernel);
|
BS_ASSERT(_pKernel);
|
||||||
BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
|
BS_PackageManager *pPackage = static_cast<BS_PackageManager *>(_pKernel->GetService("package"));
|
||||||
|
@ -159,8 +149,7 @@ bool BS_FontResource::_ParseXMLDocument(const Common::String & FileName, TiXmlDo
|
||||||
// und NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
|
// und NULL-Terminiert, da TinyXML NULL-Terminierte Daten benötigt.
|
||||||
unsigned int FileSize;
|
unsigned int FileSize;
|
||||||
char *LoadBuffer = (char *) pPackage->GetFile(GetFileName(), &FileSize);
|
char *LoadBuffer = (char *) pPackage->GetFile(GetFileName(), &FileSize);
|
||||||
if (!LoadBuffer)
|
if (!LoadBuffer) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("Could not read \"%s\".", GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -182,12 +171,10 @@ 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
|
// Bitmap Attribut auslesen
|
||||||
const char *BitmapString = Tag.Attribute("bitmap");
|
const char *BitmapString = Tag.Attribute("bitmap");
|
||||||
if (!BitmapString)
|
if (!BitmapString) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("<font> tag without bitmap attribute occurred in \"%s\".", GetFileName().c_str());
|
BS_LOG_ERRORLN("<font> tag without bitmap attribute occurred in \"%s\".", GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -195,8 +182,7 @@ bool BS_FontResource::_ParseFontTag(TiXmlElement & Tag, Common::String & BitmapF
|
||||||
|
|
||||||
// Lineheight Attribut auslesen
|
// Lineheight Attribut auslesen
|
||||||
const char *LineheightString = Tag.Attribute("lineheight");
|
const char *LineheightString = Tag.Attribute("lineheight");
|
||||||
if (!LineheightString || !BS_String::ToInt(Common::String(LineheightString), Lineheight) || Lineheight < 0)
|
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\").",
|
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;
|
Lineheight = DEFAULT_LINEHEIGHT;
|
||||||
|
@ -205,8 +191,7 @@ bool BS_FontResource::_ParseFontTag(TiXmlElement & Tag, Common::String & BitmapF
|
||||||
|
|
||||||
// Gap Attribut auslesen
|
// Gap Attribut auslesen
|
||||||
const char *GapString = Tag.Attribute("gap");
|
const char *GapString = Tag.Attribute("gap");
|
||||||
if (!GapString || !BS_String::ToInt(Common::String(GapString), GapWidth) || GapWidth < 0)
|
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\").",
|
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;
|
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
|
// Code Attribut auslesen
|
||||||
const char *CodeString = Tag.Attribute("code");
|
const char *CodeString = Tag.Attribute("code");
|
||||||
if (!CodeString || !BS_String::ToInt(Common::String(CodeString), Code) || Code < 0 || Code >= 256)
|
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());
|
BS_LOG_ERRORLN("Illegal or missing code attribute in <character> tag in \"%s\".", GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -255,8 +238,7 @@ bool BS_FontResource::_ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect
|
||||||
|
|
||||||
// Bottom Attribut auslesen
|
// Bottom Attribut auslesen
|
||||||
const char *BottomString = Tag.Attribute("bottom");
|
const char *BottomString = Tag.Attribute("bottom");
|
||||||
if (!BottomString || !BS_String::ToInt(BottomString, tmp) || tmp < 0)
|
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());
|
BS_LOG_ERRORLN("Illegal or missing bottom attribute in <character> tag in \"%s\".", GetFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,7 @@ class BS_Kernel;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_FontResource : public BS_Resource
|
class BS_FontResource : public BS_Resource {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief Erzeugt eine neues Exemplar von BS_FontResource
|
@brief Erzeugt eine neues Exemplar von BS_FontResource
|
||||||
|
@ -74,33 +73,44 @@ public:
|
||||||
|
|
||||||
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.
|
@brief Gibt das Bounding-Rect eines Zeichens auf der Charactermap zurück.
|
||||||
@param Character der ASCII-Code des Zeichens
|
@param Character der ASCII-Code des Zeichens
|
||||||
@return Das Bounding-Rect des übergebenen Zeichens auf der Charactermap.
|
@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:
|
private:
|
||||||
BS_Kernel *_pKernel;
|
BS_Kernel *_pKernel;
|
||||||
|
|
|
@ -44,8 +44,7 @@ BS_Framecounter::BS_Framecounter(int UpdateFrequency) :
|
||||||
SetUpdateFrequency(UpdateFrequency);
|
SetUpdateFrequency(UpdateFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_Framecounter::Update()
|
void BS_Framecounter::Update() {
|
||||||
{
|
|
||||||
// Aktuellen Systemtimerstand auslesen
|
// Aktuellen Systemtimerstand auslesen
|
||||||
uint64_t Timer = g_system->getMillis() * 1000;
|
uint64_t Timer = g_system->getMillis() * 1000;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the current FPS value.
|
* Returns the current FPS value.
|
||||||
*/
|
*/
|
||||||
int GetFPS() const { return m_FPS; }
|
int GetFPS() const {
|
||||||
|
return m_FPS;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_FPS;
|
int m_FPS;
|
||||||
|
|
|
@ -70,8 +70,7 @@ BS_GraphicEngine::BS_GraphicEngine(BS_Kernel * pKernel) :
|
||||||
m_TimerActive(true),
|
m_TimerActive(true),
|
||||||
m_FrameTimeSampleSlot(0),
|
m_FrameTimeSampleSlot(0),
|
||||||
m_RepaintedPixels(0),
|
m_RepaintedPixels(0),
|
||||||
BS_ResourceService(pKernel)
|
BS_ResourceService(pKernel) {
|
||||||
{
|
|
||||||
for (int i = 0; i < FRAMETIME_SAMPLE_COUNT; i++)
|
for (int i = 0; i < FRAMETIME_SAMPLE_COUNT; i++)
|
||||||
m_FrameTimeSamples[i] = 0;
|
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
|
// Aktuelle Zeit holen
|
||||||
uint64_t CurrentTime = BS_Kernel::GetInstance()->GetMicroTicks();
|
uint64_t CurrentTime = BS_Kernel::GetInstance()->GetMicroTicks();
|
||||||
|
|
||||||
|
@ -106,15 +104,12 @@ void BS_GraphicEngine::UpdateLastFrameDuration()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
bool DoSaveScreenshot(BS_GraphicEngine &GraphicEngine, const Common::String &Filename, bool Thumbnail) {
|
||||||
bool DoSaveScreenshot(BS_GraphicEngine & GraphicEngine, const Common::String & Filename, bool Thumbnail)
|
|
||||||
{
|
|
||||||
unsigned int Width;
|
unsigned int Width;
|
||||||
unsigned int Height;
|
unsigned int Height;
|
||||||
Common::Array<unsigned int> Data;
|
Common::Array<unsigned int> Data;
|
||||||
if (!GraphicEngine.GetScreenshot(Width, Height, Data))
|
if (!GraphicEngine.GetScreenshot(Width, Height, Data)) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
|
BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,24 +125,20 @@ namespace
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_GraphicEngine::SaveScreenshot(const Common::String & Filename)
|
bool BS_GraphicEngine::SaveScreenshot(const Common::String &Filename) {
|
||||||
{
|
|
||||||
return DoSaveScreenshot(*this, Filename, false);
|
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);
|
return DoSaveScreenshot(*this, Filename, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_GraphicEngine::ARGBColorToLuaColor(lua_State * L, unsigned int Color)
|
void BS_GraphicEngine::ARGBColorToLuaColor(lua_State *L, unsigned int Color) {
|
||||||
{
|
lua_Number Components[4] = {
|
||||||
lua_Number Components[4] =
|
|
||||||
{
|
|
||||||
(Color >> 16) & 0xff, // Rot
|
(Color >> 16) & 0xff, // Rot
|
||||||
(Color >> 8) & 0xff, // Grün
|
(Color >> 8) & 0xff, // Grün
|
||||||
Color & 0xff, // Blau
|
Color & 0xff, // Blau
|
||||||
|
@ -156,8 +147,7 @@ void BS_GraphicEngine::ARGBColorToLuaColor(lua_State * L, unsigned int Color)
|
||||||
|
|
||||||
lua_newtable(L);
|
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, i);
|
||||||
lua_pushnumber(L, Components[i - 1]);
|
lua_pushnumber(L, Components[i - 1]);
|
||||||
lua_settable(L, -3);
|
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
|
#ifdef DEBUG
|
||||||
int __startStackDepth = lua_gettop(L);
|
int __startStackDepth = lua_gettop(L);
|
||||||
#endif
|
#endif
|
||||||
|
@ -199,8 +188,7 @@ unsigned int BS_GraphicEngine::LuaColorToARGBColor(lua_State * L, int StackIndex
|
||||||
|
|
||||||
// Alpha Farbkomponente auslesen
|
// Alpha Farbkomponente auslesen
|
||||||
unsigned int Alpha = 0xff;
|
unsigned int Alpha = 0xff;
|
||||||
if (n == 4)
|
if (n == 4) {
|
||||||
{
|
|
||||||
lua_rawgeti(L, StackIndex, 4);
|
lua_rawgeti(L, StackIndex, 4);
|
||||||
Alpha = static_cast<unsigned int>(lua_tonumber(L, -1));
|
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");
|
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);
|
Writer.Write(m_TimerActive);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_GraphicEngine::Unpersist(BS_InputPersistenceBlock & Reader)
|
bool BS_GraphicEngine::Unpersist(BS_InputPersistenceBlock &Reader) {
|
||||||
{
|
|
||||||
Reader.Read(m_TimerActive);
|
Reader.Read(m_TimerActive);
|
||||||
return Reader.IsGood();
|
return Reader.IsGood();
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,38 +207,58 @@ public:
|
||||||
/**
|
/**
|
||||||
* Specifies the time (in microseconds) since the last frame has passed
|
* 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
|
* 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 StopMainTimer() {
|
||||||
void ResumeMainTimer() { m_TimerActive = true; }
|
m_TimerActive = false;
|
||||||
float GetSecondaryFrameDuration() { return static_cast<float>(m_LastFrameDuration) / 1000000.0f; }
|
}
|
||||||
|
void ResumeMainTimer() {
|
||||||
|
m_TimerActive = true;
|
||||||
|
}
|
||||||
|
float GetSecondaryFrameDuration() {
|
||||||
|
return static_cast<float>(m_LastFrameDuration) / 1000000.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Accessor methods
|
// Accessor methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the width of the output buffer in pixels
|
* 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
|
* 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)
|
* 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
|
* 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.
|
* Determines whether the frame buffer change is to be synchronised with Vsync. This is turned on by default.
|
||||||
|
@ -256,7 +276,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns true if the engine is running in Windowed mode.
|
* 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.
|
* Fills a rectangular area of the frame buffer with a colour.
|
||||||
|
@ -271,8 +293,12 @@ public:
|
||||||
|
|
||||||
// Debugging Methods
|
// Debugging Methods
|
||||||
|
|
||||||
int GetFPSCount() const { return m_FPSCounter.GetFPS(); }
|
int GetFPSCount() const {
|
||||||
int GetRepaintedPixels() const { return m_RepaintedPixels; }
|
return m_FPSCounter.GetFPS();
|
||||||
|
}
|
||||||
|
int GetRepaintedPixels() const {
|
||||||
|
return m_RepaintedPixels;
|
||||||
|
}
|
||||||
|
|
||||||
// Access methods
|
// Access methods
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,10 +50,8 @@ namespace Sword25 {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
unsigned int FindEmbeddedPNG(const char *FileDataPtr, unsigned int FileSize) {
|
||||||
unsigned int FindEmbeddedPNG(const char * FileDataPtr, unsigned int FileSize)
|
|
||||||
{
|
|
||||||
// Einen Stringstream mit dem Anfang der Datei intialisieren. 512 Byte sollten hierfür genügen.
|
// 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)));
|
istringstream StringStream(string(FileDataPtr, FileDataPtr + min(static_cast<unsigned int>(512), FileSize)));
|
||||||
|
|
||||||
|
@ -64,8 +62,7 @@ namespace
|
||||||
if (!StringStream.good()) return 0;
|
if (!StringStream.good()) return 0;
|
||||||
|
|
||||||
// Testen, ob wir tatsächlich einen Spielstand haben.
|
// Testen, ob wir tatsächlich einen Spielstand haben.
|
||||||
if (Marker == "BS25SAVEGAME")
|
if (Marker == "BS25SAVEGAME") {
|
||||||
{
|
|
||||||
// Offset zum PNG innerhalb des Spielstandes berechnen und zurückgeben.
|
// Offset zum PNG innerhalb des Spielstandes berechnen und zurückgeben.
|
||||||
return static_cast<unsigned int>(StringStream.tellg()) + CompressedGamedataSize + 1;
|
return static_cast<unsigned int>(StringStream.tellg()) + CompressedGamedataSize + 1;
|
||||||
}
|
}
|
||||||
|
@ -76,12 +73,10 @@ namespace
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
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.
|
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
|
||||||
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
|
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
|
||||||
if (PNGOffset > 0)
|
if (PNGOffset > 0) {
|
||||||
{
|
|
||||||
return BS_PNGLoader::DoIsCorrectImageFormat(FileDataPtr + PNGOffset, FileSize - PNGOffset);
|
return BS_PNGLoader::DoIsCorrectImageFormat(FileDataPtr + PNGOffset, FileSize - PNGOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +86,10 @@ 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,
|
bool BS_B25SLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
|
||||||
int & Width, int & Height, int & Pitch)
|
int &Width, int &Height, int &Pitch) {
|
||||||
{
|
|
||||||
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
|
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
|
||||||
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
|
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);
|
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.
|
// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
|
||||||
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
|
unsigned int PNGOffset = FindEmbeddedPNG(FileDataPtr, FileSize);
|
||||||
if (PNGOffset > 0)
|
if (PNGOffset > 0) {
|
||||||
{
|
|
||||||
return BS_PNGLoader::DoImageProperties(FileDataPtr + PNGOffset, FileSize - PNGOffset, ColorFormat, Width, Height);
|
return BS_PNGLoader::DoImageProperties(FileDataPtr + PNGOffset, FileSize - PNGOffset, ColorFormat, Width, Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,9 @@ namespace Sword25 {
|
||||||
// Klassendeklaration
|
// Klassendeklaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_B25SLoader : public BS_ImageLoader
|
class BS_B25SLoader : public BS_ImageLoader {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static BS_ImageLoader * CreateInstance()
|
static BS_ImageLoader *CreateInstance() {
|
||||||
{
|
|
||||||
#include "sword25/kernel/memlog_off.h"
|
#include "sword25/kernel/memlog_off.h"
|
||||||
return static_cast<BS_ImageLoader *>(new BS_B25SLoader());
|
return static_cast<BS_ImageLoader *>(new BS_B25SLoader());
|
||||||
#include "sword25/kernel/memlog_on.h"
|
#include "sword25/kernel/memlog_on.h"
|
||||||
|
|
|
@ -52,8 +52,7 @@
|
||||||
|
|
||||||
namespace Sword25 {
|
namespace Sword25 {
|
||||||
|
|
||||||
class BS_Image
|
class BS_Image {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~BS_Image() {};
|
virtual ~BS_Image() {};
|
||||||
|
|
||||||
|
@ -61,8 +60,7 @@ 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.
|
/// Das Bild wird nicht gespiegelt.
|
||||||
FLIP_NONE = 0,
|
FLIP_NONE = 0,
|
||||||
/// Das Bild wird an der horizontalen Achse gespiegelt.
|
/// Das Bild wird an der horizontalen Achse gespiegelt.
|
||||||
|
|
|
@ -50,16 +50,14 @@ bool BS_ImageLoader::LoadImage(const char* pFileData, unsigned int FileSize,
|
||||||
BS_GraphicEngine::COLOR_FORMATS ColorFormat,
|
BS_GraphicEngine::COLOR_FORMATS ColorFormat,
|
||||||
char*& pUncompressedData,
|
char*& pUncompressedData,
|
||||||
int &Width, int &Height,
|
int &Width, int &Height,
|
||||||
int& Pitch)
|
int &Pitch) {
|
||||||
{
|
|
||||||
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
|
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
|
||||||
if (!_ImageLoaderListInitialized)
|
if (!_ImageLoaderListInitialized)
|
||||||
_InitializeLoaderList();
|
_InitializeLoaderList();
|
||||||
|
|
||||||
// Passenden BS_ImageLoader finden und Bild dekodieren
|
// Passenden BS_ImageLoader finden und Bild dekodieren
|
||||||
BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
|
BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
|
||||||
if (pLoader)
|
if (pLoader) {
|
||||||
{
|
|
||||||
return pLoader->DecodeImage(pFileData, FileSize,
|
return pLoader->DecodeImage(pFileData, FileSize,
|
||||||
ColorFormat,
|
ColorFormat,
|
||||||
pUncompressedData,
|
pUncompressedData,
|
||||||
|
@ -75,16 +73,14 @@ bool BS_ImageLoader::LoadImage(const char* pFileData, unsigned int FileSize,
|
||||||
|
|
||||||
bool BS_ImageLoader::ExtractImageProperties(const char *pFileData, unsigned int FileSize,
|
bool BS_ImageLoader::ExtractImageProperties(const char *pFileData, unsigned int FileSize,
|
||||||
BS_GraphicEngine::COLOR_FORMATS &ColorFormat,
|
BS_GraphicEngine::COLOR_FORMATS &ColorFormat,
|
||||||
int& Width, int& Height)
|
int &Width, int &Height) {
|
||||||
{
|
|
||||||
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
|
// Falls die Liste der BS_ImageLoader noch nicht initialisiert wurde, wird dies getan.
|
||||||
if (!_ImageLoaderListInitialized)
|
if (!_ImageLoaderListInitialized)
|
||||||
_InitializeLoaderList();
|
_InitializeLoaderList();
|
||||||
|
|
||||||
// Passenden BS_ImageLoader finden und Bildeigenschaften auslesen.
|
// Passenden BS_ImageLoader finden und Bildeigenschaften auslesen.
|
||||||
BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
|
BS_ImageLoader *pLoader = _FindSuitableImageLoader(pFileData, FileSize);
|
||||||
if (pLoader)
|
if (pLoader) {
|
||||||
{
|
|
||||||
return pLoader->ImageProperties(pFileData, FileSize,
|
return pLoader->ImageProperties(pFileData, FileSize,
|
||||||
ColorFormat,
|
ColorFormat,
|
||||||
Width, Height);
|
Width, Height);
|
||||||
|
@ -96,8 +92,7 @@ bool BS_ImageLoader::ExtractImageProperties(const char* pFileData, unsigned int
|
||||||
// Verwaltungs Methoden
|
// 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.
|
// 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++)
|
for (int i = 0; i < BS_IMAGELOADER_COUNT; i++)
|
||||||
BS_IMAGELOADER_IDS[i]();
|
BS_IMAGELOADER_IDS[i]();
|
||||||
|
@ -109,24 +104,19 @@ void BS_ImageLoader::_InitializeLoaderList()
|
||||||
atexit(BS_ImageLoader::_DeinitializeLoaderList);
|
atexit(BS_ImageLoader::_DeinitializeLoaderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_ImageLoader::_DeinitializeLoaderList()
|
void BS_ImageLoader::_DeinitializeLoaderList() {
|
||||||
{
|
while (!_ImageLoaderList.empty()) {
|
||||||
while (!_ImageLoaderList.empty())
|
|
||||||
{
|
|
||||||
delete _ImageLoaderList.back();
|
delete _ImageLoaderList.back();
|
||||||
_ImageLoaderList.pop_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
|
// Alle BS_ImageLoader-Objekte durchgehen, bis eins gefunden wurde, dass das Bild laden kann
|
||||||
std::list<BS_ImageLoader *>::iterator Iter = _ImageLoaderList.begin();
|
std::list<BS_ImageLoader *>::iterator Iter = _ImageLoaderList.begin();
|
||||||
for (; Iter != _ImageLoaderList.end(); ++Iter)
|
for (; Iter != _ImageLoaderList.end(); ++Iter) {
|
||||||
{
|
|
||||||
// Falls ein geeigneter BS-ImageLoader gefunden wurde, wird er zurückgegeben.
|
// Falls ein geeigneter BS-ImageLoader gefunden wurde, wird er zurückgegeben.
|
||||||
if ((*Iter)->IsCorrectImageFormat(pFileData, FileSize))
|
if ((*Iter)->IsCorrectImageFormat(pFileData, FileSize)) {
|
||||||
{
|
|
||||||
return (*Iter);
|
return (*Iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,7 @@ namespace Sword25 {
|
||||||
- Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten
|
- Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten
|
||||||
Farbformate konvertieren.
|
Farbformate konvertieren.
|
||||||
*/
|
*/
|
||||||
class BS_ImageLoader
|
class BS_ImageLoader {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
|
@ -137,8 +136,7 @@ protected:
|
||||||
Diese Liste enthält jeweils eine Instanz jedes #BS_ImageLoader und wird benutzt um beliebige Bilddateien einem Loader zuzuordnen.
|
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.
|
@remark Dieser Konstruktor ist protected damit nur #BS_ImageLoader-Objekte diese Klasse instanziieren können.
|
||||||
*/
|
*/
|
||||||
BS_ImageLoader()
|
BS_ImageLoader() {
|
||||||
{
|
|
||||||
// Klasse registrieren
|
// Klasse registrieren
|
||||||
_ImageLoaderList.push_front(this);
|
_ImageLoaderList.push_front(this);
|
||||||
}
|
}
|
||||||
|
@ -209,10 +207,8 @@ protected:
|
||||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||||
Es sind mindestens Width * 2 Byte notwendig.
|
Es sind mindestens Width * 2 Byte notwendig.
|
||||||
*/
|
*/
|
||||||
static void RowARGB32ToRGB16(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
|
static void RowARGB32ToRGB16(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
|
||||||
{
|
for (unsigned int i = 0; i < Width; i++) {
|
||||||
for (unsigned int i = 0; i < Width; i++)
|
|
||||||
{
|
|
||||||
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3);
|
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3);
|
||||||
pSrcData += 4;
|
pSrcData += 4;
|
||||||
}
|
}
|
||||||
|
@ -226,10 +222,8 @@ protected:
|
||||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||||
Es sind mindestens Width * 2 Byte notwendig.
|
Es sind mindestens Width * 2 Byte notwendig.
|
||||||
*/
|
*/
|
||||||
static void RowARGB32ToRGB15(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
|
static void RowARGB32ToRGB15(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
|
||||||
{
|
for (unsigned int i = 0; i < Width; i++) {
|
||||||
for (unsigned int i = 0; i < Width; i++)
|
|
||||||
{
|
|
||||||
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3);
|
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3);
|
||||||
pSrcData += 4;
|
pSrcData += 4;
|
||||||
}
|
}
|
||||||
|
@ -243,13 +237,11 @@ protected:
|
||||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.<br>
|
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.<br>
|
||||||
Es sind mindestens ((Width + 3) / 4) * 12 Byte notwendig.
|
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
|
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
|
||||||
unsigned int BlockFillCount = 0;
|
unsigned int BlockFillCount = 0;
|
||||||
unsigned int AlphaBlock = 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
|
// Alphawert in den Alphablock schreiben
|
||||||
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
||||||
|
|
||||||
|
@ -257,8 +249,7 @@ protected:
|
||||||
BlockFillCount++;
|
BlockFillCount++;
|
||||||
|
|
||||||
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
|
// 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
|
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
|
||||||
// "left aligned" sind.
|
// "left aligned" sind.
|
||||||
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
||||||
|
@ -290,13 +281,11 @@ protected:
|
||||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||||
Es sind mindestens (Width / 4 + Width % 4) * 3 Byte notwendig.
|
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
|
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
|
||||||
unsigned int BlockFillCount = 0;
|
unsigned int BlockFillCount = 0;
|
||||||
unsigned int AlphaBlock = 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
|
// Alphawert in den Alphablock schreiben
|
||||||
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
||||||
|
|
||||||
|
@ -304,8 +293,7 @@ protected:
|
||||||
BlockFillCount++;
|
BlockFillCount++;
|
||||||
|
|
||||||
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
|
// 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
|
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
|
||||||
// "left aligned" sind.
|
// "left aligned" sind.
|
||||||
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
||||||
|
@ -335,10 +323,8 @@ protected:
|
||||||
@param pDestData ein Pointer auf den Zielpuffern.
|
@param pDestData ein Pointer auf den Zielpuffern.
|
||||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||||
*/
|
*/
|
||||||
static void RowARGB32ToABGR32(unsigned char* pSrcData, unsigned char* pDestData, unsigned int Width)
|
static void RowARGB32ToABGR32(unsigned char *pSrcData, unsigned char *pDestData, unsigned int Width) {
|
||||||
{
|
for (unsigned int i = 0; i < Width; ++i) {
|
||||||
for (unsigned int i = 0; i < Width; ++i)
|
|
||||||
{
|
|
||||||
*pDestData++ = pSrcData[2];
|
*pDestData++ = pSrcData[2];
|
||||||
*pDestData++ = pSrcData[1];
|
*pDestData++ = pSrcData[1];
|
||||||
*pDestData++ = pSrcData[0];
|
*pDestData++ = pSrcData[0];
|
||||||
|
|
|
@ -52,8 +52,7 @@ namespace Sword25 {
|
||||||
// Die Tabelle enthält Pointer auf statische Member-Funktionen innerhalb der Klassen, die eine Instanz der Klasse
|
// Die Tabelle enthält Pointer auf statische Member-Funktionen innerhalb der Klassen, die eine Instanz der Klasse
|
||||||
// erzeugen
|
// erzeugen
|
||||||
typedef BS_ImageLoader*(*BS_IMAGELOADER_NEW)();
|
typedef BS_ImageLoader*(*BS_IMAGELOADER_NEW)();
|
||||||
const BS_IMAGELOADER_NEW BS_IMAGELOADER_IDS[] =
|
const BS_IMAGELOADER_NEW BS_IMAGELOADER_IDS[] = {
|
||||||
{
|
|
||||||
BS_PNGLoader::CreateInstance,
|
BS_PNGLoader::CreateInstance,
|
||||||
BS_B25SLoader::CreateInstance,
|
BS_B25SLoader::CreateInstance,
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,16 +48,14 @@ namespace Sword25 {
|
||||||
// Konstruktor / Destruktor
|
// Konstruktor / Destruktor
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_PNGLoader::BS_PNGLoader()
|
BS_PNGLoader::BS_PNGLoader() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Laden
|
// Laden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t 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);
|
memcpy(data, (char *)png_ptr->io_ptr, length);
|
||||||
png_ptr->io_ptr = (void *)((png_size_t)png_ptr->io_ptr + length);
|
png_ptr->io_ptr = (void *)((png_size_t)png_ptr->io_ptr + length);
|
||||||
}
|
}
|
||||||
|
@ -65,8 +63,7 @@ static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t l
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
|
bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
|
||||||
int & Width, int & Height, int & Pitch)
|
int &Width, int &Height, int &Pitch) {
|
||||||
{
|
|
||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL;
|
png_infop info_ptr = NULL;
|
||||||
png_bytep RawDataBuffer = NULL;
|
png_bytep RawDataBuffer = NULL;
|
||||||
|
@ -83,31 +80,26 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
ColorFormat != BS_GraphicEngine::CF_RGB16_INTERLEAVED &&
|
ColorFormat != BS_GraphicEngine::CF_RGB16_INTERLEAVED &&
|
||||||
ColorFormat != BS_GraphicEngine::CF_RGB15_INTERLEAVED &&
|
ColorFormat != BS_GraphicEngine::CF_RGB15_INTERLEAVED &&
|
||||||
ColorFormat != BS_GraphicEngine::CF_ARGB32 &&
|
ColorFormat != BS_GraphicEngine::CF_ARGB32 &&
|
||||||
ColorFormat != BS_GraphicEngine::CF_ABGR32)
|
ColorFormat != BS_GraphicEngine::CF_ABGR32) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Illegal or unsupported color format.");
|
BS_LOG_ERRORLN("Illegal or unsupported color format.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// PNG Signatur überprüfen
|
// 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);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die beiden PNG Strukturen erstellen
|
// Die beiden PNG Strukturen erstellen
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
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.");
|
BS_LOG_ERRORLN("Could not create libpng read struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!info_ptr)
|
if (!info_ptr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not create libpng info struct.");
|
BS_LOG_ERRORLN("Could not create libpng info struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
@ -130,8 +122,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
// Speicher für die endgültigen Bilddaten reservieren
|
// 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
|
// 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];
|
UncompressedDataPtr = new char[Pitch * Height];
|
||||||
if (!UncompressedDataPtr)
|
if (!UncompressedDataPtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not allocate memory for output image.");
|
BS_LOG_ERRORLN("Could not allocate memory for output image.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
@ -159,25 +150,21 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
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
|
// PNGs ohne Interlacing werden Zeilenweise eingelesen
|
||||||
if (InterlaceType == PNG_INTERLACE_NONE)
|
if (InterlaceType == PNG_INTERLACE_NONE) {
|
||||||
{
|
|
||||||
// Speicher für eine Bildzeile reservieren
|
// Speicher für eine Bildzeile reservieren
|
||||||
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
|
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.");
|
BS_LOG_ERRORLN("Could not allocate memory for row buffer.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
|
// Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
|
||||||
for (i = 0; i < Height; i++)
|
for (i = 0; i < Height; i++) {
|
||||||
{
|
|
||||||
// Zeile einlesen
|
// Zeile einlesen
|
||||||
png_read_row(png_ptr, RawDataBuffer, NULL);
|
png_read_row(png_ptr, RawDataBuffer, NULL);
|
||||||
|
|
||||||
// Zeile konvertieren
|
// Zeile konvertieren
|
||||||
switch (ColorFormat)
|
switch (ColorFormat) {
|
||||||
{
|
|
||||||
case BS_GraphicEngine::CF_RGB16:
|
case BS_GraphicEngine::CF_RGB16:
|
||||||
RowARGB32ToRGB16((unsigned char *)RawDataBuffer,
|
RowARGB32ToRGB16((unsigned char *)RawDataBuffer,
|
||||||
(unsigned char *)&UncompressedDataPtr[i * Pitch],
|
(unsigned char *)&UncompressedDataPtr[i * Pitch],
|
||||||
|
@ -220,20 +207,17 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// PNGs mit Interlacing werden an einem Stück eingelesen
|
// PNGs mit Interlacing werden an einem Stück eingelesen
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// Speicher für das komplette Bild reservieren
|
// Speicher für das komplette Bild reservieren
|
||||||
RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height];
|
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.");
|
BS_LOG_ERRORLN("Could not allocate memory for raw image buffer.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Speicher für die Rowpointer reservieren
|
// Speicher für die Rowpointer reservieren
|
||||||
pRowPtr = new png_bytep[Height];
|
pRowPtr = new png_bytep[Height];
|
||||||
if (!pRowPtr)
|
if (!pRowPtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not allocate memory for row pointers.");
|
BS_LOG_ERRORLN("Could not allocate memory for row pointers.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
@ -246,8 +230,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
png_read_image(png_ptr, pRowPtr);
|
png_read_image(png_ptr, pRowPtr);
|
||||||
|
|
||||||
// Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
|
// Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
|
||||||
switch (ColorFormat)
|
switch (ColorFormat) {
|
||||||
{
|
|
||||||
case BS_GraphicEngine::CF_RGB16:
|
case BS_GraphicEngine::CF_RGB16:
|
||||||
for (i = 0; i < Height; i++)
|
for (i = 0; i < Height; i++)
|
||||||
RowARGB32ToRGB16((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
RowARGB32ToRGB16((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
||||||
|
@ -296,8 +279,7 @@ bool BS_PNGLoader::DoDecodeImage(const char * FileDataPtr, unsigned int FileSize
|
||||||
delete[] RawDataBuffer;
|
delete[] RawDataBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(int)
|
catch (int) {
|
||||||
{
|
|
||||||
delete[] pRowPtr;
|
delete[] pRowPtr;
|
||||||
delete[] RawDataBuffer;
|
delete[] RawDataBuffer;
|
||||||
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
|
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
|
@ -314,33 +296,28 @@ 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,
|
bool BS_PNGLoader::DecodeImage(const char *FileDataPtr, unsigned int FileSize, BS_GraphicEngine::COLOR_FORMATS ColorFormat, char * & UncompressedDataPtr,
|
||||||
int & Width, int & Height, int & Pitch)
|
int &Width, int &Height, int &Pitch) {
|
||||||
{
|
|
||||||
return DoDecodeImage(FileDataPtr, FileSize, ColorFormat, UncompressedDataPtr, Width, Height, 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
|
// PNG Signatur überprüfen
|
||||||
if (!DoIsCorrectImageFormat(FileDataPtr, FileSize)) return false;
|
if (!DoIsCorrectImageFormat(FileDataPtr, FileSize)) return false;
|
||||||
|
|
||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL;
|
png_infop info_ptr = NULL;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// Die beiden PNG Strukturen erstellen
|
// Die beiden PNG Strukturen erstellen
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
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.");
|
BS_LOG_ERRORLN("Could not create libpng read struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!info_ptr)
|
if (!info_ptr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not create libpng info struct.");
|
BS_LOG_ERRORLN("Could not create libpng info struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
@ -366,8 +343,7 @@ bool BS_PNGLoader::DoImageProperties(const char * FileDataPtr, unsigned int File
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
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 (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, 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);
|
return DoImageProperties(FileDataPtr, FileSize, ColorFormat, Width, Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,8 +365,7 @@ bool BS_PNGLoader::ImageProperties(const char* FileDataPtr, unsigned int FileSiz
|
||||||
// Header überprüfen
|
// 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)
|
if (FileSize > 8)
|
||||||
return png_check_sig((unsigned char *)FileDataPtr, 8) ? true : false;
|
return png_check_sig((unsigned char *)FileDataPtr, 8) ? true : false;
|
||||||
else
|
else
|
||||||
|
@ -400,8 +374,7 @@ bool BS_PNGLoader::DoIsCorrectImageFormat(const char * FileDataPtr, unsigned int
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_PNGLoader::IsCorrectImageFormat(const char* FileDataPtr, unsigned int FileSize)
|
bool BS_PNGLoader::IsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
|
||||||
{
|
|
||||||
return DoIsCorrectImageFormat(FileDataPtr, FileSize);
|
return DoIsCorrectImageFormat(FileDataPtr, FileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,9 @@
|
||||||
namespace Sword25 {
|
namespace Sword25 {
|
||||||
|
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
class BS_PNGLoader : public BS_ImageLoader
|
class BS_PNGLoader : public BS_ImageLoader {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static BS_ImageLoader* CreateInstance()
|
static BS_ImageLoader *CreateInstance() {
|
||||||
{
|
|
||||||
#include "sword25/kernel/memlog_off.h"
|
#include "sword25/kernel/memlog_off.h"
|
||||||
return (BS_ImageLoader *) new BS_PNGLoader();
|
return (BS_ImageLoader *) new BS_PNGLoader();
|
||||||
#include "sword25/kernel/memlog_on.h"
|
#include "sword25/kernel/memlog_on.h"
|
||||||
|
|
|
@ -68,23 +68,19 @@ typedef int16_t s32;
|
||||||
// Diese Klasse ist speziell dafür ausgestattet.
|
// Diese Klasse ist speziell dafür ausgestattet.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_VectorImage::SWFBitStream
|
class BS_VectorImage::SWFBitStream {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
SWFBitStream(const unsigned char *pData, unsigned int DataSize) :
|
SWFBitStream(const unsigned char *pData, unsigned int DataSize) :
|
||||||
m_Pos(pData), m_End(pData + DataSize), m_WordMask(0)
|
m_Pos(pData), m_End(pData + DataSize), m_WordMask(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline u32 GetBits(unsigned int BitCount)
|
inline u32 GetBits(unsigned int BitCount) {
|
||||||
{
|
if (BitCount == 0 || BitCount > 32) {
|
||||||
if (BitCount == 0 || BitCount > 32)
|
|
||||||
{
|
|
||||||
throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time"));
|
throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 value = 0;
|
u32 value = 0;
|
||||||
while (BitCount)
|
while (BitCount) {
|
||||||
{
|
|
||||||
if (m_WordMask == 0) FlushByte();
|
if (m_WordMask == 0) FlushByte();
|
||||||
|
|
||||||
value <<= 1;
|
value <<= 1;
|
||||||
|
@ -97,8 +93,7 @@ public:
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline s32 GetSignedBits(unsigned int BitCount)
|
inline s32 GetSignedBits(unsigned int BitCount) {
|
||||||
{
|
|
||||||
// Bits einlesen
|
// Bits einlesen
|
||||||
u32 Temp = GetBits(BitCount);
|
u32 Temp = GetBits(BitCount);
|
||||||
|
|
||||||
|
@ -109,8 +104,7 @@ public:
|
||||||
return Temp;
|
return Temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 GetU32()
|
inline u32 GetU32() {
|
||||||
{
|
|
||||||
u32 Byte1 = GetU8();
|
u32 Byte1 = GetU8();
|
||||||
u32 Byte2 = GetU8();
|
u32 Byte2 = GetU8();
|
||||||
u32 Byte3 = GetU8();
|
u32 Byte3 = GetU8();
|
||||||
|
@ -119,16 +113,14 @@ public:
|
||||||
return Byte1 | (Byte2 << 8) | (Byte3 << 16) | (Byte4 << 24);
|
return Byte1 | (Byte2 << 8) | (Byte3 << 16) | (Byte4 << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u16 GetU16()
|
inline u16 GetU16() {
|
||||||
{
|
|
||||||
u32 Byte1 = GetU8();
|
u32 Byte1 = GetU8();
|
||||||
u32 Byte2 = GetU8();
|
u32 Byte2 = GetU8();
|
||||||
|
|
||||||
return Byte1 | (Byte2 << 8);
|
return Byte1 | (Byte2 << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u8 GetU8()
|
inline u8 GetU8() {
|
||||||
{
|
|
||||||
FlushByte();
|
FlushByte();
|
||||||
u8 Value = m_Word;
|
u8 Value = m_Word;
|
||||||
m_WordMask = 0;
|
m_WordMask = 0;
|
||||||
|
@ -137,31 +129,22 @@ public:
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FlushByte()
|
inline void FlushByte() {
|
||||||
{
|
if (m_WordMask != 128) {
|
||||||
if (m_WordMask != 128)
|
if (m_Pos >= m_End) {
|
||||||
{
|
|
||||||
if (m_Pos >= m_End)
|
|
||||||
{
|
|
||||||
throw(runtime_error("Attempted to read past end of file"));
|
throw(runtime_error("Attempted to read past end of file"));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Word = *m_Pos++;
|
m_Word = *m_Pos++;
|
||||||
m_WordMask = 128;
|
m_WordMask = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SkipBytes(unsigned int SkipLength)
|
inline void SkipBytes(unsigned int SkipLength) {
|
||||||
{
|
|
||||||
FlushByte();
|
FlushByte();
|
||||||
if (m_Pos + SkipLength >= m_End)
|
if (m_Pos + SkipLength >= m_End) {
|
||||||
{
|
|
||||||
throw(runtime_error("Attempted to read past end of file"));
|
throw(runtime_error("Attempted to read past end of file"));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Pos += SkipLength;
|
m_Pos += SkipLength;
|
||||||
m_Word = *(m_Pos - 1);
|
m_Word = *(m_Pos - 1);
|
||||||
}
|
}
|
||||||
|
@ -180,8 +163,7 @@ private:
|
||||||
// Konstanten und Hilfsfunktionen
|
// Konstanten und Hilfsfunktionen
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Konstanten
|
// Konstanten
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -193,8 +175,7 @@ namespace
|
||||||
// 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_Rect FlashRectToBSRect(BS_VectorImage::SWFBitStream &bs) {
|
||||||
{
|
|
||||||
bs.FlushByte();
|
bs.FlushByte();
|
||||||
|
|
||||||
// Feststellen mit wie vielen Bits die einzelnen Komponenten kodiert sind
|
// Feststellen mit wie vielen Bits die einzelnen Komponenten kodiert sind
|
||||||
|
@ -214,8 +195,7 @@ namespace
|
||||||
// Konvertiert SWF-Farben in AntiGrain Farben
|
// Konvertiert SWF-Farben in AntiGrain Farben
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
agg::rgba8 FlashColorToAGGRGBA8(unsigned int FlashColor)
|
agg::rgba8 FlashColorToAGGRGBA8(unsigned int FlashColor) {
|
||||||
{
|
|
||||||
agg::rgba8 ResultColor((FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff, FlashColor >> 24);
|
agg::rgba8 ResultColor((FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff, FlashColor >> 24);
|
||||||
ResultColor.premultiply();
|
ResultColor.premultiply();
|
||||||
return ResultColor;
|
return ResultColor;
|
||||||
|
@ -226,15 +206,15 @@ namespace
|
||||||
// Berechnet die Bounding-Box eines BS_VectorImageElement
|
// Berechnet die Bounding-Box eines BS_VectorImageElement
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct CBBGetId
|
struct CBBGetId {
|
||||||
{
|
|
||||||
CBBGetId(const BS_VectorImageElement &VectorImageElement_) : VectorImageElement(VectorImageElement_) {}
|
CBBGetId(const BS_VectorImageElement &VectorImageElement_) : VectorImageElement(VectorImageElement_) {}
|
||||||
unsigned operator [] (unsigned i) const { return VectorImageElement.GetPathInfo(i).GetID(); }
|
unsigned operator [](unsigned i) const {
|
||||||
|
return VectorImageElement.GetPathInfo(i).GetID();
|
||||||
|
}
|
||||||
const BS_VectorImageElement &VectorImageElement;
|
const BS_VectorImageElement &VectorImageElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
BS_Rect CalculateBoundingBox(const BS_VectorImageElement & VectorImageElement)
|
BS_Rect CalculateBoundingBox(const BS_VectorImageElement &VectorImageElement) {
|
||||||
{
|
|
||||||
agg::path_storage Path = VectorImageElement.GetPaths();
|
agg::path_storage Path = VectorImageElement.GetPaths();
|
||||||
CBBGetId IdSource(VectorImageElement);
|
CBBGetId IdSource(VectorImageElement);
|
||||||
|
|
||||||
|
@ -250,16 +230,14 @@ namespace
|
||||||
// Konstruktion
|
// 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;
|
Success = false;
|
||||||
|
|
||||||
// Bitstream-Objekt erzeugen
|
// Bitstream-Objekt erzeugen
|
||||||
// Im Folgenden werden die Dateidaten aus diesem ausgelesen.
|
// Im Folgenden werden die Dateidaten aus diesem ausgelesen.
|
||||||
SWFBitStream bs(pFileData, FileSize);
|
SWFBitStream bs(pFileData, FileSize);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// SWF-Signatur überprüfen
|
// SWF-Signatur überprüfen
|
||||||
u32 Signature[3];
|
u32 Signature[3];
|
||||||
Signature[0] = bs.GetU8();
|
Signature[0] = bs.GetU8();
|
||||||
|
@ -267,24 +245,21 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
|
||||||
Signature[2] = bs.GetU8();
|
Signature[2] = bs.GetU8();
|
||||||
if (Signature[0] != 'F' ||
|
if (Signature[0] != 'F' ||
|
||||||
Signature[1] != 'W' ||
|
Signature[1] != 'W' ||
|
||||||
Signature[2] != 'S')
|
Signature[2] != 'S') {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("File is not a valid SWF-file");
|
BS_LOG_ERRORLN("File is not a valid SWF-file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Versionsangabe überprüfen
|
// Versionsangabe überprüfen
|
||||||
u32 Version = bs.GetU8();
|
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);
|
BS_LOG_ERRORLN("File is of version %d. Highest accepted version is %d.", Version, MAX_ACCEPTED_FLASH_VERSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dateigröße auslesen und mit der tatsächlichen Größe vergleichen
|
// Dateigröße auslesen und mit der tatsächlichen Größe vergleichen
|
||||||
u32 StoredFileSize = bs.GetU32();
|
u32 StoredFileSize = bs.GetU32();
|
||||||
if (StoredFileSize != FileSize)
|
if (StoredFileSize != FileSize) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("File is not a valid SWF-file");
|
BS_LOG_ERRORLN("File is not a valid SWF-file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -299,8 +274,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
|
||||||
// Tags parsen
|
// Tags parsen
|
||||||
// Da wir uns nur für das erste DefineShape-Tag interessieren
|
// Da wir uns nur für das erste DefineShape-Tag interessieren
|
||||||
bool KeepParsing = true;
|
bool KeepParsing = true;
|
||||||
while (KeepParsing)
|
while (KeepParsing) {
|
||||||
{
|
|
||||||
// Tags beginnen immer an Bytegrenzen
|
// Tags beginnen immer an Bytegrenzen
|
||||||
bs.FlushByte();
|
bs.FlushByte();
|
||||||
|
|
||||||
|
@ -310,8 +284,7 @@ BS_VectorImage::BS_VectorImage(const unsigned char * pFileData, unsigned int Fil
|
||||||
u32 TagLength = TagTypeAndLength & 0x3f;
|
u32 TagLength = TagTypeAndLength & 0x3f;
|
||||||
if (TagLength == 0x3f) TagLength = bs.GetU32();
|
if (TagLength == 0x3f) TagLength = bs.GetU32();
|
||||||
|
|
||||||
switch (TagType)
|
switch (TagType) {
|
||||||
{
|
|
||||||
case 2:
|
case 2:
|
||||||
// DefineShape
|
// DefineShape
|
||||||
Success = ParseDefineShape(2, bs);
|
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
|
// Fehler loggen und Funktion verlassen
|
||||||
// Success ist somit "false" und signalisiert dem Programmierer, dass die Konstruktion fehlgeschlagen ist.
|
// 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());
|
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();
|
u32 ShapeID = bs.GetU16();
|
||||||
|
|
||||||
// Bounding Box auslesen
|
// Bounding Box auslesen
|
||||||
|
@ -368,13 +339,11 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
|
||||||
// ------------------
|
// ------------------
|
||||||
|
|
||||||
bool EndOfShapeDiscovered = false;
|
bool EndOfShapeDiscovered = false;
|
||||||
while (!EndOfShapeDiscovered)
|
while (!EndOfShapeDiscovered) {
|
||||||
{
|
|
||||||
u32 TypeFlag = bs.GetBits(1);
|
u32 TypeFlag = bs.GetBits(1);
|
||||||
|
|
||||||
// Non-Edge Record
|
// Non-Edge Record
|
||||||
if (TypeFlag == 0)
|
if (TypeFlag == 0) {
|
||||||
{
|
|
||||||
// Feststellen welche Parameter gesetzt werden
|
// Feststellen welche Parameter gesetzt werden
|
||||||
u32 StateNewStyles = bs.GetBits(1);
|
u32 StateNewStyles = bs.GetBits(1);
|
||||||
u32 StateLineStyle = 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)
|
if (!StateNewStyles && !StateLineStyle && !StateFillStyle0 && !StateFillStyle1 && !StateMoveTo)
|
||||||
EndOfShapeDiscovered = true;
|
EndOfShapeDiscovered = true;
|
||||||
// Parameter dekodieren
|
// Parameter dekodieren
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
s32 MoveDeltaX = 0;
|
s32 MoveDeltaX = 0;
|
||||||
s32 MoveDeltaY = 0;
|
s32 MoveDeltaY = 0;
|
||||||
if (StateMoveTo)
|
if (StateMoveTo) {
|
||||||
{
|
|
||||||
u32 MoveToBits = bs.GetBits(5);
|
u32 MoveToBits = bs.GetBits(5);
|
||||||
MoveDeltaX = bs.GetSignedBits(MoveToBits);
|
MoveDeltaX = bs.GetSignedBits(MoveToBits);
|
||||||
MoveDeltaY = bs.GetSignedBits(MoveToBits);
|
MoveDeltaY = bs.GetSignedBits(MoveToBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StateFillStyle0)
|
if (StateFillStyle0) {
|
||||||
{
|
|
||||||
if (NumFillBits > 0)
|
if (NumFillBits > 0)
|
||||||
FillStyle0 = bs.GetBits(NumFillBits);
|
FillStyle0 = bs.GetBits(NumFillBits);
|
||||||
else
|
else
|
||||||
FillStyle0 = 0;
|
FillStyle0 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StateFillStyle1)
|
if (StateFillStyle1) {
|
||||||
{
|
|
||||||
if (NumFillBits > 0)
|
if (NumFillBits > 0)
|
||||||
FillStyle1 = bs.GetBits(NumFillBits);
|
FillStyle1 = bs.GetBits(NumFillBits);
|
||||||
else
|
else
|
||||||
FillStyle1 = 0;
|
FillStyle1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StateLineStyle)
|
if (StateLineStyle) {
|
||||||
{
|
|
||||||
if (NumLineBits)
|
if (NumLineBits)
|
||||||
LineStyle = bs.GetBits(NumLineBits);
|
LineStyle = bs.GetBits(NumLineBits);
|
||||||
else
|
else
|
||||||
NumLineBits = 0;
|
NumLineBits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StateNewStyles)
|
if (StateNewStyles) {
|
||||||
{
|
|
||||||
// An dieser Stelle werden in Flash die alten Style-Definitionen verworfen und mit den neuen überschrieben.
|
// An dieser Stelle werden in Flash die alten Style-Definitionen verworfen und mit den neuen überschrieben.
|
||||||
// Es wird ein neues Element begonnen.
|
// Es wird ein neues Element begonnen.
|
||||||
m_Elements.resize(m_Elements.size() + 1);
|
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
|
// 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
|
// 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 LastX = m_Elements.back().m_Paths.last_x();
|
||||||
double LastY = m_Elements.back().m_Paths.last_y();
|
double LastY = m_Elements.back().m_Paths.last_y();
|
||||||
|
@ -449,14 +411,12 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream & bs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Edge Record
|
// Edge Record
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
u32 EdgeFlag = bs.GetBits(1);
|
u32 EdgeFlag = bs.GetBits(1);
|
||||||
u32 NumBits = bs.GetBits(4) + 2;
|
u32 NumBits = bs.GetBits(4) + 2;
|
||||||
|
|
||||||
// Curved edge
|
// Curved edge
|
||||||
if (EdgeFlag == 0)
|
if (EdgeFlag == 0) {
|
||||||
{
|
|
||||||
s32 ControlDeltaX = bs.GetSignedBits(NumBits);
|
s32 ControlDeltaX = bs.GetSignedBits(NumBits);
|
||||||
s32 ControlDeltaY = bs.GetSignedBits(NumBits);
|
s32 ControlDeltaY = bs.GetSignedBits(NumBits);
|
||||||
s32 AnchorDeltaX = 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);
|
m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY);
|
||||||
}
|
}
|
||||||
// Staight edge
|
// Staight edge
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
s32 DeltaX = 0;
|
s32 DeltaX = 0;
|
||||||
s32 DeltaY = 0;
|
s32 DeltaY = 0;
|
||||||
|
|
||||||
u32 GeneralLineFlag = bs.GetBits(1);
|
u32 GeneralLineFlag = bs.GetBits(1);
|
||||||
if (GeneralLineFlag)
|
if (GeneralLineFlag) {
|
||||||
{
|
|
||||||
DeltaX = bs.GetSignedBits(NumBits);
|
DeltaX = bs.GetSignedBits(NumBits);
|
||||||
DeltaY = bs.GetSignedBits(NumBits);
|
DeltaY = bs.GetSignedBits(NumBits);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
u32 VertLineFlag = bs.GetBits(1);
|
u32 VertLineFlag = bs.GetBits(1);
|
||||||
if (VertLineFlag)
|
if (VertLineFlag)
|
||||||
DeltaY = bs.GetSignedBits(NumBits);
|
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();
|
bs.FlushByte();
|
||||||
|
|
||||||
// Fillstyles parsen
|
// 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.
|
// Alle Fillstyles einlesen, falls ein Fillstyle mit Typ != 0 gefunden wird, wird das Parsen abgebrochen.
|
||||||
// Es wird nur "solid fill" (Typ 0) unterstützt.
|
// Es wird nur "solid fill" (Typ 0) unterstützt.
|
||||||
m_Elements.back().m_FillStyles.reserve(FillStyleCount);
|
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();
|
u8 Type = bs.GetU8();
|
||||||
u32 Color;
|
u32 Color;
|
||||||
if (ShapeType == 3)
|
if (ShapeType == 3) {
|
||||||
{
|
|
||||||
Color = (bs.GetU8() << 16) | (bs.GetU8() << 8) | bs.GetU8() | (bs.GetU8() << 24);
|
Color = (bs.GetU8() << 16) | (bs.GetU8() << 8) | bs.GetU8() | (bs.GetU8() << 24);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
Color = bs.GetBits(24) | (0xff << 24);
|
Color = bs.GetBits(24) | (0xff << 24);
|
||||||
if (Type != 0) return false;
|
if (Type != 0) return false;
|
||||||
|
|
||||||
|
@ -542,8 +494,7 @@ bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream & bs, unsi
|
||||||
|
|
||||||
// Alle Linestyles einlesen
|
// Alle Linestyles einlesen
|
||||||
m_Elements.back().m_LineStyles.reserve(LineStyleCount);
|
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();
|
double Width = bs.GetU16();
|
||||||
u32 Color;
|
u32 Color;
|
||||||
if (ShapeType == 3)
|
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.");
|
BS_LOG_ERRORLN("Fill() is not supported.");
|
||||||
return false;
|
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.");
|
BS_LOG_ERRORLN("GetPixel() is not supported. Returning black.");
|
||||||
return 0;
|
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.");
|
BS_LOG_ERRORLN("SetContent() is not supported.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,16 +59,23 @@ class BS_VectorImage;
|
||||||
gespeichert werden.
|
gespeichert werden.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BS_VectorPathInfo
|
class BS_VectorPathInfo {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_VectorPathInfo(unsigned int ID, unsigned int LineStyle, unsigned int FillStyle0, unsigned int FillStyle1) :
|
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 GetID() const {
|
||||||
unsigned int GetLineStyle() const { return m_LineStyle; }
|
return m_ID;
|
||||||
unsigned int GetFillStyle0() const { return m_FillStyle0; }
|
}
|
||||||
unsigned int GetFillStyle1() const { return m_FillStyle1; }
|
unsigned int GetLineStyle() const {
|
||||||
|
return m_LineStyle;
|
||||||
|
}
|
||||||
|
unsigned int GetFillStyle0() const {
|
||||||
|
return m_FillStyle0;
|
||||||
|
}
|
||||||
|
unsigned int GetFillStyle1() const {
|
||||||
|
return m_FillStyle1;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_ID;
|
unsigned int m_ID;
|
||||||
|
@ -82,41 +89,49 @@ private:
|
||||||
@brief Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil der Graphik definieren.
|
@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.
|
Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild.
|
||||||
*/
|
*/
|
||||||
class BS_VectorImageElement
|
class BS_VectorImageElement {
|
||||||
{
|
|
||||||
friend BS_VectorImage;
|
friend BS_VectorImage;
|
||||||
public:
|
public:
|
||||||
const agg::path_storage & GetPaths() const { return m_Paths; }
|
const agg::path_storage &GetPaths() const {
|
||||||
unsigned int GetPathCount() const { return m_PathInfos.size(); }
|
return m_Paths;
|
||||||
const BS_VectorPathInfo & GetPathInfo(unsigned int PathNr) const { BS_ASSERT(PathNr < GetPathCount()); return m_PathInfos[PathNr]; }
|
}
|
||||||
|
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());
|
BS_ASSERT(LineStyle < m_LineStyles.size());
|
||||||
return m_LineStyles[LineStyle].Width;
|
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());
|
BS_ASSERT(LineStyle < m_LineStyles.size());
|
||||||
return m_LineStyles[LineStyle].Color;
|
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());
|
BS_ASSERT(FillStyle < m_FillStyles.size());
|
||||||
return m_FillStyles[FillStyle];
|
return m_FillStyles[FillStyle];
|
||||||
}
|
}
|
||||||
|
|
||||||
const BS_Rect & GetBoundingBox() const { return m_BoundingBox; }
|
const BS_Rect &GetBoundingBox() const {
|
||||||
|
return m_BoundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct LineStyleType
|
struct LineStyleType {
|
||||||
{
|
|
||||||
LineStyleType(double Width_, const agg::rgba8 &Color_) : Width(Width_), Color(Color_) {};
|
LineStyleType(double Width_, const agg::rgba8 &Color_) : Width(Width_), Color(Color_) {};
|
||||||
double Width;
|
double Width;
|
||||||
agg::rgba8 Color;
|
agg::rgba8 Color;
|
||||||
|
@ -136,34 +151,56 @@ private:
|
||||||
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:
|
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(); }
|
unsigned int GetElementCount() const {
|
||||||
const BS_VectorImageElement & GetElement(unsigned int ElementNr) const
|
return m_Elements.size();
|
||||||
{
|
}
|
||||||
|
const BS_VectorImageElement &GetElement(unsigned int ElementNr) const {
|
||||||
BS_ASSERT(ElementNr < m_Elements.size());
|
BS_ASSERT(ElementNr < m_Elements.size());
|
||||||
return m_Elements[ElementNr];
|
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
|
// Die abstrakten Methoden von BS_Image
|
||||||
//
|
//
|
||||||
virtual int GetWidth() const { return m_BoundingBox.GetWidth(); }
|
virtual int GetWidth() const {
|
||||||
virtual int GetHeight() const { return m_BoundingBox.GetHeight(); }
|
return m_BoundingBox.GetWidth();
|
||||||
virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
|
}
|
||||||
|
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 bool Fill(const BS_Rect *pFillRect = 0, unsigned int Color = BS_RGB(0, 0, 0));
|
||||||
virtual unsigned int GetPixel(int X, int Y);
|
virtual unsigned int GetPixel(int X, int Y);
|
||||||
virtual bool IsBlitSource() const { return true; }
|
virtual bool IsBlitSource() const {
|
||||||
virtual bool IsBlitTarget() const { return false; }
|
return true;
|
||||||
virtual bool IsScalingAllowed() const { return true; }
|
}
|
||||||
virtual bool IsFillingAllowed() const { return false; }
|
virtual bool IsBlitTarget() const {
|
||||||
virtual bool IsAlphaAllowed() const { return true; }
|
return false;
|
||||||
virtual bool IsColorModulationAllowed() const { return true; }
|
}
|
||||||
virtual bool IsSetContentAllowed() 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 SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride);
|
||||||
virtual bool Blit(int PosX = 0, int PosY = 0,
|
virtual bool Blit(int PosX = 0, int PosY = 0,
|
||||||
int Flipping = FLIP_NONE,
|
int Flipping = FLIP_NONE,
|
||||||
|
|
|
@ -49,8 +49,7 @@ namespace Sword25 {
|
||||||
// CompoundShape
|
// CompoundShape
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class CompoundShape
|
class CompoundShape {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CompoundShape(const BS_VectorImageElement &VectorImageElement) :
|
CompoundShape(const BS_VectorImageElement &VectorImageElement) :
|
||||||
m_ImageElement(VectorImageElement),
|
m_ImageElement(VectorImageElement),
|
||||||
|
@ -60,20 +59,19 @@ public:
|
||||||
m_Trans(m_Curve, m_Affine)
|
m_Trans(m_Curve, m_Affine)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
unsigned operator [] (unsigned i) const
|
unsigned operator [](unsigned i) const {
|
||||||
{
|
|
||||||
return m_ImageElement.GetPathInfo(i).GetID();
|
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);
|
m_Trans.rewind(path_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned vertex(double* x, double* y)
|
unsigned vertex(double *x, double *y) {
|
||||||
{
|
|
||||||
return m_Trans.vertex(x, y);
|
return m_Trans.vertex(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,23 +88,19 @@ private:
|
||||||
// StyleHandler
|
// StyleHandler
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class StyleHandler
|
class StyleHandler {
|
||||||
{
|
|
||||||
public:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const agg::rgba8 & color(unsigned style) const
|
const agg::rgba8 &color(unsigned style) const {
|
||||||
{
|
|
||||||
return m_ImageElement.GetFillStyleColor(style);
|
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
|
// Wird nicht benutzt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -121,8 +115,7 @@ private:
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_VectorImageRenderer::BS_VectorImageRenderer() :
|
BS_VectorImageRenderer::BS_VectorImageRenderer() :
|
||||||
PixelFormat(rbuf)
|
PixelFormat(rbuf) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +127,7 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
|
||||||
unsigned int &Width, unsigned int &Height,
|
unsigned int &Width, unsigned int &Height,
|
||||||
Common::Array<char> & ImageData,
|
Common::Array<char> & ImageData,
|
||||||
float LineScaleFactor,
|
float LineScaleFactor,
|
||||||
bool NoAlphaShapes)
|
bool NoAlphaShapes) {
|
||||||
{
|
|
||||||
Width = static_cast<unsigned int>(VectorImage.GetWidth() * ScaleFactorX);
|
Width = static_cast<unsigned int>(VectorImage.GetWidth() * ScaleFactorX);
|
||||||
Height = static_cast<unsigned int>(VectorImage.GetHeight() * ScaleFactorY);
|
Height = static_cast<unsigned int>(VectorImage.GetHeight() * ScaleFactorY);
|
||||||
|
|
||||||
|
@ -151,8 +143,7 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
|
||||||
Scale = agg::trans_affine_translation(- VectorImage.GetBoundingBox().left, - VectorImage.GetBoundingBox().top);
|
Scale = agg::trans_affine_translation(- VectorImage.GetBoundingBox().left, - VectorImage.GetBoundingBox().top);
|
||||||
Scale *= agg::trans_affine_scaling(ScaleFactorX, ScaleFactorY);
|
Scale *= agg::trans_affine_scaling(ScaleFactorX, ScaleFactorY);
|
||||||
|
|
||||||
for (unsigned int element = 0; element < VectorImage.GetElementCount(); ++element)
|
for (unsigned int element = 0; element < VectorImage.GetElementCount(); ++element) {
|
||||||
{
|
|
||||||
const BS_VectorImageElement &CurImageElement = VectorImage.GetElement(element);
|
const BS_VectorImageElement &CurImageElement = VectorImage.GetElement(element);
|
||||||
|
|
||||||
CompoundShape ImageCompoundShape(CurImageElement);
|
CompoundShape ImageCompoundShape(CurImageElement);
|
||||||
|
@ -164,19 +155,16 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage & VectorImage,
|
||||||
//----------------------
|
//----------------------
|
||||||
CompoundRasterizer.clip_box(0, 0, Width, Height);
|
CompoundRasterizer.clip_box(0, 0, Width, Height);
|
||||||
CompoundRasterizer.reset();
|
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 FillStyle0 = CurImageElement.GetPathInfo(i).GetFillStyle0();
|
||||||
unsigned int FillStyle1 = CurImageElement.GetPathInfo(i).GetFillStyle1();
|
unsigned int FillStyle1 = CurImageElement.GetPathInfo(i).GetFillStyle1();
|
||||||
|
|
||||||
if (NoAlphaShapes)
|
if (NoAlphaShapes) {
|
||||||
{
|
|
||||||
if (FillStyle0 != 0 && CurImageElement.GetFillStyleColor(FillStyle0 - 1).a != 255) FillStyle0 = 0;
|
if (FillStyle0 != 0 && CurImageElement.GetFillStyleColor(FillStyle0 - 1).a != 255) FillStyle0 = 0;
|
||||||
if (FillStyle1 != 0 && CurImageElement.GetFillStyleColor(FillStyle1 - 1).a != 255) FillStyle1 = 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.styles(FillStyle0 - 1, FillStyle1 - 1);
|
||||||
CompoundRasterizer.add_path(Shape, CurImageElement.GetPathInfo(i).GetID());
|
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);
|
Rasterizer.clip_box(0, 0, Width, Height);
|
||||||
Stroke.line_join(agg::round_join);
|
Stroke.line_join(agg::round_join);
|
||||||
Stroke.line_cap(agg::round_cap);
|
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();
|
Rasterizer.reset();
|
||||||
|
|
||||||
unsigned int CurrentLineStyle = CurImageElement.GetPathInfo(i).GetLineStyle();
|
unsigned int CurrentLineStyle = CurImageElement.GetPathInfo(i).GetLineStyle();
|
||||||
if (CurrentLineStyle != 0)
|
if (CurrentLineStyle != 0) {
|
||||||
{
|
|
||||||
Stroke.width(ScaleFactorX * CurImageElement.GetLineStyleWidth(CurrentLineStyle - 1) * LineScaleFactor);
|
Stroke.width(ScaleFactorX * CurImageElement.GetLineStyleWidth(CurrentLineStyle - 1) * LineScaleFactor);
|
||||||
Rasterizer.add_path(Stroke, CurImageElement.GetPathInfo(i).GetID());
|
Rasterizer.add_path(Stroke, CurImageElement.GetPathInfo(i).GetID());
|
||||||
ScanlineRenderer.color(CurImageElement.GetLineStyleColor(CurrentLineStyle - 1));
|
ScanlineRenderer.color(CurImageElement.GetLineStyleColor(CurrentLineStyle - 1));
|
||||||
|
|
|
@ -61,8 +61,7 @@ class BS_VectorImage;
|
||||||
@brief Rendert BS_VectorImage Objekte
|
@brief Rendert BS_VectorImage Objekte
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BS_VectorImageRenderer
|
class BS_VectorImageRenderer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_VectorImageRenderer();
|
BS_VectorImageRenderer();
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,7 @@ namespace Sword25 {
|
||||||
BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :
|
BS_GLImage::BS_GLImage(const Common::String &Filename, bool &Result) :
|
||||||
m_Sprite(0),
|
m_Sprite(0),
|
||||||
m_Width(0),
|
m_Width(0),
|
||||||
m_Height(0)
|
m_Height(0) {
|
||||||
{
|
|
||||||
Result = false;
|
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"));
|
||||||
|
@ -63,8 +62,7 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
|
||||||
// Datei laden
|
// Datei laden
|
||||||
char *pFileData;
|
char *pFileData;
|
||||||
unsigned int FileSize;
|
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());
|
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", Filename.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -72,16 +70,14 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
|
||||||
// Bildeigenschaften bestimmen
|
// Bildeigenschaften bestimmen
|
||||||
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
|
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
|
||||||
int Pitch;
|
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.");
|
BS_LOG_ERRORLN("Could not read image properties.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Das Bild dekomprimieren
|
// Das Bild dekomprimieren
|
||||||
char *pUncompressedData;
|
char *pUncompressedData;
|
||||||
if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch))
|
if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not decode image.");
|
BS_LOG_ERRORLN("Could not decode image.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +90,7 @@ BS_GLImage::BS_GLImage(const Common::String & Filename, bool & Result) :
|
||||||
(ColorFormat == BS_GraphicEngine::CF_ARGB32) ? GLS_True : GLS_False,
|
(ColorFormat == BS_GraphicEngine::CF_ARGB32) ? GLS_True : GLS_False,
|
||||||
pUncompressedData,
|
pUncompressedData,
|
||||||
&m_Sprite);
|
&m_Sprite);
|
||||||
if (Result != GLS_OK)
|
if (Result != GLS_OK) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
|
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +107,7 @@ 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_Sprite(0),
|
||||||
m_Width(Width),
|
m_Width(Width),
|
||||||
m_Height(Height)
|
m_Height(Height) {
|
||||||
{
|
|
||||||
Result = false;
|
Result = false;
|
||||||
|
|
||||||
// GLS-Sprite mit den Bilddaten erstellen
|
// GLS-Sprite mit den Bilddaten erstellen
|
||||||
|
@ -121,8 +115,7 @@ BS_GLImage::BS_GLImage(unsigned int Width, unsigned int Height, bool & Result) :
|
||||||
GLS_True,
|
GLS_True,
|
||||||
0,
|
0,
|
||||||
&m_Sprite);
|
&m_Sprite);
|
||||||
if (GLSResult != GLS_OK)
|
if (GLSResult != GLS_OK) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
|
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(GLSResult));
|
||||||
return;
|
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);
|
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.");
|
BS_LOG_ERRORLN("Fill() is not supported.");
|
||||||
return false;
|
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
|
// Ü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);
|
BS_LOG_ERRORLN("PixelData vector is too small to define a 32 bit %dx%d image.", m_Width, m_Height);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLS-Sprite mit den Bilddaten füllen
|
// GLS-Sprite mit den Bilddaten füllen
|
||||||
GLS_Result GLSResult = GLS_SetSpriteData(m_Sprite, m_Width, m_Height, &Pixeldata[Offset], Stride / 4);
|
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));
|
BS_LOG_ERRORLN("CGLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(GLSResult));
|
||||||
return false;
|
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.");
|
BS_LOG_ERRORLN("GetPixel() is not supported. Returning black.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -182,12 +169,10 @@ bool BS_GLImage::Blit(int PosX, int PosY,
|
||||||
int Flipping,
|
int Flipping,
|
||||||
BS_Rect *pPartRect,
|
BS_Rect *pPartRect,
|
||||||
unsigned int Color,
|
unsigned int Color,
|
||||||
int Width, int Height)
|
int Width, int Height) {
|
||||||
{
|
|
||||||
// BS_Rect nach GLS_Rect konvertieren
|
// BS_Rect nach GLS_Rect konvertieren
|
||||||
GLS_Rect SubImage;
|
GLS_Rect SubImage;
|
||||||
if (pPartRect)
|
if (pPartRect) {
|
||||||
{
|
|
||||||
SubImage.x1 = pPartRect->left;
|
SubImage.x1 = pPartRect->left;
|
||||||
SubImage.y1 = pPartRect->top;
|
SubImage.y1 = pPartRect->top;
|
||||||
SubImage.x2 = pPartRect->right;
|
SubImage.x2 = pPartRect->right;
|
||||||
|
|
|
@ -57,8 +57,7 @@ typedef void * GLS_Sprite;
|
||||||
// CLASS DEFINITION
|
// CLASS DEFINITION
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_GLImage : public BS_Image
|
class BS_GLImage : public BS_Image {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_GLImage(const Common::String &Filename, bool &Result);
|
BS_GLImage(const Common::String &Filename, bool &Result);
|
||||||
|
|
||||||
|
@ -73,9 +72,15 @@ public:
|
||||||
BS_GLImage(unsigned int Width, unsigned int Height, bool &Result);
|
BS_GLImage(unsigned int Width, unsigned int Height, bool &Result);
|
||||||
virtual ~BS_GLImage();
|
virtual ~BS_GLImage();
|
||||||
|
|
||||||
virtual int GetWidth() const { return m_Width; }
|
virtual int GetWidth() const {
|
||||||
virtual int GetHeight() const { return m_Height; }
|
return m_Width;
|
||||||
virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
|
}
|
||||||
|
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,
|
virtual bool Blit(int PosX = 0, int PosY = 0,
|
||||||
int Flipping = BS_Image::FLIP_NONE,
|
int Flipping = BS_Image::FLIP_NONE,
|
||||||
|
@ -86,13 +91,27 @@ public:
|
||||||
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0);
|
virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0);
|
||||||
virtual unsigned int GetPixel(int X, int Y);
|
virtual unsigned int GetPixel(int X, int Y);
|
||||||
|
|
||||||
virtual bool IsBlitSource() const { return true; }
|
virtual bool IsBlitSource() const {
|
||||||
virtual bool IsBlitTarget() const { return false; }
|
return true;
|
||||||
virtual bool IsScalingAllowed() const { return true; }
|
}
|
||||||
virtual bool IsFillingAllowed() const { return false; }
|
virtual bool IsBlitTarget() const {
|
||||||
virtual bool IsAlphaAllowed() const { return true; }
|
return false;
|
||||||
virtual bool IsColorModulationAllowed() const { return true; }
|
}
|
||||||
virtual bool IsSetContentAllowed() const { return true; }
|
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:
|
private:
|
||||||
GLS_Sprite m_Sprite;
|
GLS_Sprite m_Sprite;
|
||||||
int m_Width;
|
int m_Width;
|
||||||
|
|
|
@ -50,8 +50,7 @@ using namespace std;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const float LINE_SCALE_FACTOR = 1.0f;
|
const float LINE_SCALE_FACTOR = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +60,7 @@ bool BS_VectorImage::Blit(int PosX, int PosY,
|
||||||
int Flipping,
|
int Flipping,
|
||||||
BS_Rect *pPartRect,
|
BS_Rect *pPartRect,
|
||||||
unsigned int Color,
|
unsigned int Color,
|
||||||
int Width, int Height)
|
int Width, int Height) {
|
||||||
{
|
|
||||||
static BS_VectorImageRenderer VectorImageRenderer;
|
static BS_VectorImageRenderer VectorImageRenderer;
|
||||||
static vector<char> PixelData;
|
static vector<char> PixelData;
|
||||||
static GLS_Sprite Sprite = 0;
|
static GLS_Sprite Sprite = 0;
|
||||||
|
@ -75,39 +73,33 @@ bool BS_VectorImage::Blit(int PosX, int PosY,
|
||||||
if (Width == 0 || Height == 0) return true;
|
if (Width == 0 || Height == 0) return true;
|
||||||
|
|
||||||
// Sprite erstellen, falls es noch nicht erstellt wurde
|
// 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);
|
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));
|
BS_LOG_ERRORLN("Could not create GLS_Sprite. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feststellen, ob das alte Bild im Cache nicht wiederbenutzt werden kann und neu Berechnet werden muss
|
// 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 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 RenderedWidth;
|
||||||
unsigned int RenderedHeight;
|
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.");
|
BS_LOG_ERRORLN("Call to BS_VectorImageRenderer::Render() failed.");
|
||||||
return false;
|
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.");
|
BS_LOG_WARNINGLN("Currently the maximum size for scaled vector images is 512x512.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, &PixelData[0], 0);
|
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));
|
BS_LOG_ERRORLN("Call to GLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,7 @@ using namespace std;
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const unsigned int BIT_DEPTH = 32;
|
const unsigned int BIT_DEPTH = 32;
|
||||||
const unsigned int BACKBUFFER_COUNT = 1;
|
const unsigned int BACKBUFFER_COUNT = 1;
|
||||||
const Common::String PNG_EXTENSION(".png");
|
const Common::String PNG_EXTENSION(".png");
|
||||||
|
@ -87,21 +86,18 @@ namespace
|
||||||
|
|
||||||
BS_OpenGLGfx::BS_OpenGLGfx(BS_Kernel *pKernel) :
|
BS_OpenGLGfx::BS_OpenGLGfx(BS_Kernel *pKernel) :
|
||||||
BS_GraphicEngine(pKernel),
|
BS_GraphicEngine(pKernel),
|
||||||
m_GLspritesInitialized(false)
|
m_GLspritesInitialized(false) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_OpenGLGfx::~BS_OpenGLGfx()
|
BS_OpenGLGfx::~BS_OpenGLGfx() {
|
||||||
{
|
|
||||||
if (m_GLspritesInitialized) GLS_Quit();
|
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);
|
return new BS_OpenGLGfx(pKernel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,18 +106,15 @@ BS_Service * BS_OpenGLGfx_CreateObject(BS_Kernel* pKernel)
|
||||||
// INTERFACE
|
// 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.
|
// 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);
|
BS_LOG_WARNINGLN("Can't use a bit depth of %d (not supported). Falling back to %d.", BitDepth, BIT_DEPTH);
|
||||||
m_BitDepth = BIT_DEPTH;
|
m_BitDepth = BIT_DEPTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnung ausgeben, wenn nicht genau ein Backbuffer gewählt wurde.
|
// 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);
|
BS_LOG_WARNINGLN("Can't use %d backbuffers (not supported). Falling back to %d.", BackbufferCount, BACKBUFFER_COUNT);
|
||||||
BackbufferCount = BACKBUFFER_COUNT;
|
BackbufferCount = BACKBUFFER_COUNT;
|
||||||
}
|
}
|
||||||
|
@ -139,8 +132,7 @@ bool BS_OpenGLGfx::Init(int Width, int Height, int BitDepth, int BackbufferCount
|
||||||
// GLsprites initialisieren
|
// GLsprites initialisieren
|
||||||
HWND hwnd = reinterpret_cast<HWND>(BS_Kernel::GetInstance()->GetWindow()->GetWindowHandle());
|
HWND hwnd = reinterpret_cast<HWND>(BS_Kernel::GetInstance()->GetWindow()->GetWindowHandle());
|
||||||
GLS_Result Result = GLS_InitExternalWindow(Width, Height, Windowed ? GLS_False : GLS_True, hwnd);
|
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));
|
BS_LOG_ERRORLN("Could not initialize GLsprites. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// Berechnen, wie viel Zeit seit dem letzten Frame vergangen ist.
|
||||||
// Dieser Wert kann über GetLastFrameDuration() von Modulen abgefragt werden, die zeitabhängig arbeiten.
|
// Dieser Wert kann über GetLastFrameDuration() von Modulen abgefragt werden, die zeitabhängig arbeiten.
|
||||||
UpdateLastFrameDuration();
|
UpdateLastFrameDuration();
|
||||||
|
@ -173,8 +164,7 @@ bool BS_OpenGLGfx::StartFrame(bool UpdateAll)
|
||||||
|
|
||||||
// GLsprites bescheidgeben
|
// GLsprites bescheidgeben
|
||||||
GLS_Result Result = GLS_StartFrame();
|
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));
|
BS_LOG_ERRORLN("Call to GLS_StartFrame() failed. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -184,20 +174,17 @@ bool BS_OpenGLGfx::StartFrame(bool UpdateAll)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_OpenGLGfx::EndFrame()
|
bool BS_OpenGLGfx::EndFrame() {
|
||||||
{
|
|
||||||
// Scene zeichnen
|
// Scene zeichnen
|
||||||
m_RenderObjectManagerPtr->Render();
|
m_RenderObjectManagerPtr->Render();
|
||||||
|
|
||||||
// Debug-Lines zeichnen
|
// Debug-Lines zeichnen
|
||||||
if (!m_DebugLines.empty())
|
if (!m_DebugLines.empty()) {
|
||||||
{
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
||||||
Common::Array<DebugLine>::const_iterator iter = m_DebugLines.begin();
|
Common::Array<DebugLine>::const_iterator iter = m_DebugLines.begin();
|
||||||
for (; iter != m_DebugLines.end(); ++iter)
|
for (; iter != m_DebugLines.end(); ++iter) {
|
||||||
{
|
|
||||||
const unsigned int &Color = (*iter).Color;
|
const unsigned int &Color = (*iter).Color;
|
||||||
const BS_Vertex &Start = (*iter).Start;
|
const BS_Vertex &Start = (*iter).Start;
|
||||||
const BS_Vertex &End = (*iter).End;
|
const BS_Vertex &End = (*iter).End;
|
||||||
|
@ -215,8 +202,7 @@ bool BS_OpenGLGfx::EndFrame()
|
||||||
|
|
||||||
// Flippen
|
// Flippen
|
||||||
GLS_Result Result = GLS_EndFrame();
|
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));
|
BS_LOG_ERRORLN("Call to GLS_EndFrame() failed. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
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;
|
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);
|
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));
|
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_Bool Status;
|
||||||
GLS_Result Result = GLS_IsVsync(&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));
|
BS_LOG_WARNINGLN("Could not get vsync status. Returning false. Reason: %s", GLS_ResultString(Result));
|
||||||
return false;
|
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;
|
BS_Rect Rect;
|
||||||
|
|
||||||
if (!FillRectPtr)
|
if (!FillRectPtr) {
|
||||||
{
|
|
||||||
Rect.left = 0;
|
Rect.left = 0;
|
||||||
Rect.top = 0;
|
Rect.top = 0;
|
||||||
Rect.right = m_Width;
|
Rect.right = m_Width;
|
||||||
|
@ -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;
|
if (!ReadFramebufferContents(m_Width, m_Height, Data)) return false;
|
||||||
|
|
||||||
// Die Größe des Framebuffers zurückgeben.
|
// 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);
|
Data.resize(Width * Height);
|
||||||
glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Data[0]);
|
glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Data[0]);
|
||||||
|
|
||||||
if (glGetError() == 0)
|
if (glGetError() == 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Data.clear();
|
Data.clear();
|
||||||
return false;
|
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();
|
vector<unsigned int>::iterator It = Data.begin();
|
||||||
while (It != Data.end())
|
while (It != Data.end()) {
|
||||||
{
|
|
||||||
unsigned int Pixel = *It;
|
unsigned int Pixel = *It;
|
||||||
*It = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16);
|
*It = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16);
|
||||||
++It;
|
++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);
|
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 Line1It = Data.begin() + Y * Width;
|
||||||
vector<unsigned int>::iterator Line2It = Data.begin() + (Height - 1 - Y) * Width;
|
vector<unsigned int>::iterator Line2It = Data.begin() + (Height - 1 - Y) * Width;
|
||||||
copy(Line1It, Line1It + Width, LineBuffer.begin());
|
copy(Line1It, Line1It + Width, LineBuffer.begin());
|
||||||
|
@ -350,8 +323,7 @@ void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height
|
||||||
// RESOURCE MANAGING
|
// 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);
|
Common::String::size_type StringPos = String.rfind(OtherString);
|
||||||
if (StringPos == Common::String::npos) return false;
|
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));
|
BS_ASSERT(CanLoadResource(FileName));
|
||||||
|
|
||||||
// Bild für den Softwarebuffer laden
|
// Bild für den Softwarebuffer laden
|
||||||
if (DoesStringEndWith(FileName, PNG_S_EXTENSION))
|
if (DoesStringEndWith(FileName, PNG_S_EXTENSION)) {
|
||||||
{
|
|
||||||
bool Result;
|
bool Result;
|
||||||
BS_SWImage *pImage = new BS_SWImage(FileName, Result);
|
BS_SWImage *pImage = new BS_SWImage(FileName, Result);
|
||||||
if (!Result)
|
if (!Result) {
|
||||||
{
|
|
||||||
delete pImage;
|
delete pImage;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
||||||
if (!pResource->IsValid())
|
if (!pResource->IsValid()) {
|
||||||
{
|
|
||||||
delete pResource;
|
delete pResource;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -386,19 +354,16 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sprite-Bild laden
|
// Sprite-Bild laden
|
||||||
if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION))
|
if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION)) {
|
||||||
{
|
|
||||||
bool Result;
|
bool Result;
|
||||||
BS_GLImage *pImage = new BS_GLImage(FileName, Result);
|
BS_GLImage *pImage = new BS_GLImage(FileName, Result);
|
||||||
if (!Result)
|
if (!Result) {
|
||||||
{
|
|
||||||
delete pImage;
|
delete pImage;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
||||||
if (!pResource->IsValid())
|
if (!pResource->IsValid()) {
|
||||||
{
|
|
||||||
delete pResource;
|
delete pResource;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -408,8 +373,7 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
|
||||||
|
|
||||||
|
|
||||||
// Vectorgraphik laden
|
// Vectorgraphik laden
|
||||||
if (DoesStringEndWith(FileName, SWF_EXTENSION))
|
if (DoesStringEndWith(FileName, SWF_EXTENSION)) {
|
||||||
{
|
|
||||||
// Pointer auf Package-Manager holen
|
// Pointer auf Package-Manager holen
|
||||||
BS_PackageManager *pPackage = BS_Kernel::GetInstance()->GetPackage();
|
BS_PackageManager *pPackage = BS_Kernel::GetInstance()->GetPackage();
|
||||||
BS_ASSERT(pPackage);
|
BS_ASSERT(pPackage);
|
||||||
|
@ -417,24 +381,21 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
|
||||||
// Datei laden
|
// Datei laden
|
||||||
unsigned char *pFileData;
|
unsigned char *pFileData;
|
||||||
unsigned int FileSize;
|
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());
|
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", FileName.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Result;
|
bool Result;
|
||||||
BS_VectorImage *pImage = new BS_VectorImage(pFileData, FileSize, Result);
|
BS_VectorImage *pImage = new BS_VectorImage(pFileData, FileSize, Result);
|
||||||
if (!Result)
|
if (!Result) {
|
||||||
{
|
|
||||||
delete pImage;
|
delete pImage;
|
||||||
delete [] pFileData;
|
delete [] pFileData;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
BS_BitmapResource *pResource = new BS_BitmapResource(FileName, pImage);
|
||||||
if (!pResource->IsValid())
|
if (!pResource->IsValid()) {
|
||||||
{
|
|
||||||
delete pResource;
|
delete pResource;
|
||||||
delete [] pFileData;
|
delete [] pFileData;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -445,26 +406,22 @@ BS_Resource * BS_OpenGLGfx::LoadResource(const Common::String& FileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animation laden
|
// Animation laden
|
||||||
if (DoesStringEndWith(FileName, ANI_EXTENSION))
|
if (DoesStringEndWith(FileName, ANI_EXTENSION)) {
|
||||||
{
|
|
||||||
BS_AnimationResource *pResource = new BS_AnimationResource(FileName);
|
BS_AnimationResource *pResource = new BS_AnimationResource(FileName);
|
||||||
if (pResource->IsValid())
|
if (pResource->IsValid())
|
||||||
return pResource;
|
return pResource;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
delete pResource;
|
delete pResource;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font laden
|
// Font laden
|
||||||
if (DoesStringEndWith(FileName, FNT_EXTENSION))
|
if (DoesStringEndWith(FileName, FNT_EXTENSION)) {
|
||||||
{
|
|
||||||
BS_FontResource *pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName);
|
BS_FontResource *pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName);
|
||||||
if (pResource->IsValid())
|
if (pResource->IsValid())
|
||||||
return pResource;
|
return pResource;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
delete pResource;
|
delete pResource;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -476,8 +433,7 @@ 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) ||
|
return DoesStringEndWith(FileName, PNG_EXTENSION) ||
|
||||||
DoesStringEndWith(FileName, ANI_EXTENSION) ||
|
DoesStringEndWith(FileName, ANI_EXTENSION) ||
|
||||||
DoesStringEndWith(FileName, FNT_EXTENSION) ||
|
DoesStringEndWith(FileName, FNT_EXTENSION) ||
|
||||||
|
@ -490,8 +446,7 @@ bool BS_OpenGLGfx::CanLoadResource(const Common::String& FileName)
|
||||||
// DEBUGGING
|
// 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));
|
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
|
// PERSISTENZ
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_OpenGLGfx::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_OpenGLGfx::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
result &= BS_GraphicEngine::Persist(Writer);
|
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;
|
bool result = true;
|
||||||
|
|
||||||
result &= BS_GraphicEngine::Unpersist(Reader);
|
result &= BS_GraphicEngine::Unpersist(Reader);
|
||||||
|
|
|
@ -67,8 +67,7 @@ class BS_RenderObjectManager;
|
||||||
// CLASS DECLARATION
|
// CLASS DECLARATION
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_OpenGLGfx : public BS_GraphicEngine
|
class BS_OpenGLGfx : public BS_GraphicEngine {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_OpenGLGfx(BS_Kernel *pKernel);
|
BS_OpenGLGfx(BS_Kernel *pKernel);
|
||||||
virtual ~BS_OpenGLGfx();
|
virtual ~BS_OpenGLGfx();
|
||||||
|
@ -109,8 +108,7 @@ private:
|
||||||
|
|
||||||
std::auto_ptr<BS_RenderObjectManager> m_RenderObjectManagerPtr;
|
std::auto_ptr<BS_RenderObjectManager> m_RenderObjectManagerPtr;
|
||||||
|
|
||||||
struct DebugLine
|
struct DebugLine {
|
||||||
{
|
|
||||||
DebugLine(const BS_Vertex &_Start, const BS_Vertex &_End, unsigned int _Color) :
|
DebugLine(const BS_Vertex &_Start, const BS_Vertex &_End, unsigned int _Color) :
|
||||||
Start(_Start),
|
Start(_Start),
|
||||||
End(_End),
|
End(_End),
|
||||||
|
|
|
@ -53,8 +53,7 @@ namespace Sword25 {
|
||||||
BS_SWImage::BS_SWImage(const Common::String &Filename, bool &Result) :
|
BS_SWImage::BS_SWImage(const Common::String &Filename, bool &Result) :
|
||||||
_ImageDataPtr(0),
|
_ImageDataPtr(0),
|
||||||
m_Width(0),
|
m_Width(0),
|
||||||
m_Height(0)
|
m_Height(0) {
|
||||||
{
|
|
||||||
Result = false;
|
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"));
|
||||||
|
@ -63,8 +62,7 @@ BS_SWImage::BS_SWImage(const Common::String & Filename, bool & Result) :
|
||||||
// Datei laden
|
// Datei laden
|
||||||
char *pFileData;
|
char *pFileData;
|
||||||
unsigned int FileSize;
|
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());
|
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", Filename.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -72,16 +70,14 @@ BS_SWImage::BS_SWImage(const Common::String & Filename, bool & Result) :
|
||||||
// Bildeigenschaften bestimmen
|
// Bildeigenschaften bestimmen
|
||||||
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
|
BS_GraphicEngine::COLOR_FORMATS ColorFormat;
|
||||||
int Pitch;
|
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.");
|
BS_LOG_ERRORLN("Could not read image properties.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Das Bild dekomprimieren
|
// Das Bild dekomprimieren
|
||||||
char *pUncompressedData;
|
char *pUncompressedData;
|
||||||
if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch))
|
if (!BS_ImageLoader::LoadImage(pFileData, FileSize, BS_GraphicEngine::CF_ABGR32, pUncompressedData, m_Width, m_Height, Pitch)) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not decode image.");
|
BS_LOG_ERRORLN("Could not decode image.");
|
||||||
return;
|
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;
|
delete [] _ImageDataPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,32 +104,28 @@ bool BS_SWImage::Blit(int PosX, int PosY,
|
||||||
int Flipping,
|
int Flipping,
|
||||||
BS_Rect *pPartRect,
|
BS_Rect *pPartRect,
|
||||||
unsigned int Color,
|
unsigned int Color,
|
||||||
int Width, int Height)
|
int Width, int Height) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Blit() is not supported.");
|
BS_LOG_ERRORLN("Blit() is not supported.");
|
||||||
return false;
|
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.");
|
BS_LOG_ERRORLN("Fill() is not supported.");
|
||||||
return false;
|
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.");
|
BS_LOG_ERRORLN("SetContent() is not supported.");
|
||||||
return false;
|
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(X >= 0 && X < m_Width);
|
||||||
BS_ASSERT(Y >= 0 && Y < m_Height);
|
BS_ASSERT(Y >= 0 && Y < m_Height);
|
||||||
|
|
||||||
|
|
|
@ -50,15 +50,20 @@ namespace Sword25 {
|
||||||
// CLASS DEFINITION
|
// CLASS DEFINITION
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_SWImage : public BS_Image
|
class BS_SWImage : public BS_Image {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_SWImage(const Common::String &Filename, bool &Result);
|
BS_SWImage(const Common::String &Filename, bool &Result);
|
||||||
virtual ~BS_SWImage();
|
virtual ~BS_SWImage();
|
||||||
|
|
||||||
virtual int GetWidth() const { return m_Width; }
|
virtual int GetWidth() const {
|
||||||
virtual int GetHeight() const { return m_Height; }
|
return m_Width;
|
||||||
virtual BS_GraphicEngine::COLOR_FORMATS GetColorFormat() const { return BS_GraphicEngine::CF_ARGB32; }
|
}
|
||||||
|
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,
|
virtual bool Blit(int PosX = 0, int PosY = 0,
|
||||||
int Flipping = BS_Image::FLIP_NONE,
|
int Flipping = BS_Image::FLIP_NONE,
|
||||||
|
@ -69,13 +74,27 @@ public:
|
||||||
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 unsigned int GetPixel(int X, int Y);
|
virtual unsigned int GetPixel(int X, int Y);
|
||||||
|
|
||||||
virtual bool IsBlitSource() const { return false; }
|
virtual bool IsBlitSource() const {
|
||||||
virtual bool IsBlitTarget() const { return false; }
|
return false;
|
||||||
virtual bool IsScalingAllowed() const { return false; }
|
}
|
||||||
virtual bool IsFillingAllowed() const { return false; }
|
virtual bool IsBlitTarget() const {
|
||||||
virtual bool IsAlphaAllowed() const { return false; }
|
return false;
|
||||||
virtual bool IsColorModulationAllowed() const { return false; }
|
}
|
||||||
virtual bool IsSetContentAllowed() 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:
|
private:
|
||||||
unsigned int *_ImageDataPtr;
|
unsigned int *_ImageDataPtr;
|
||||||
|
|
||||||
|
|
|
@ -55,21 +55,18 @@ namespace Sword25 {
|
||||||
|
|
||||||
BS_Panel::BS_Panel(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, int Width, int Height, unsigned int Color) :
|
BS_Panel::BS_Panel(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, int Width, int Height, unsigned int Color) :
|
||||||
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL),
|
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL),
|
||||||
m_Color(Color)
|
m_Color(Color) {
|
||||||
{
|
|
||||||
m_InitSuccess = false;
|
m_InitSuccess = false;
|
||||||
|
|
||||||
m_Width = Width;
|
m_Width = Width;
|
||||||
m_Height = Height;
|
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);
|
BS_LOG_ERRORLN("Tried to initialise a panel with an invalid width (%d).", m_Width);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Height < 0)
|
if (m_Height < 0) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Tried to initialise a panel with an invalid height (%d).", m_Height);
|
BS_LOG_ERRORLN("Tried to initialise a panel with an invalid height (%d).", m_Height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,23 +77,20 @@ 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_Panel::BS_Panel(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
|
||||||
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL, Handle)
|
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_PANEL, Handle) {
|
||||||
{
|
|
||||||
m_InitSuccess = Unpersist(Reader);
|
m_InitSuccess = Unpersist(Reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_Panel::~BS_Panel()
|
BS_Panel::~BS_Panel() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Rendern
|
// 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.
|
// Falls der Alphawert 0 ist, ist das Panel komplett durchsichtig und es muss nichts gezeichnet werden.
|
||||||
if (m_Color >> 24 == 0) return true;
|
if (m_Color >> 24 == 0) return true;
|
||||||
|
|
||||||
|
@ -110,8 +104,7 @@ bool BS_Panel::DoRender()
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Panel::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_Panel::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Persist(Writer);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Unpersist(Reader);
|
Result &= BS_RenderObject::Unpersist(Reader);
|
||||||
|
|
|
@ -48,8 +48,7 @@ namespace Sword25 {
|
||||||
// Class Definition
|
// Class Definition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_Panel : public BS_RenderObject
|
class BS_Panel : public BS_RenderObject {
|
||||||
{
|
|
||||||
friend class BS_RenderObject;
|
friend class BS_RenderObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -59,8 +58,13 @@ private:
|
||||||
public:
|
public:
|
||||||
virtual ~BS_Panel();
|
virtual ~BS_Panel();
|
||||||
|
|
||||||
unsigned int GetColor() const { return m_Color; }
|
unsigned int GetColor() const {
|
||||||
void SetColor(unsigned int Color) { m_Color = Color; ForceRefresh(); }
|
return m_Color;
|
||||||
|
}
|
||||||
|
void SetColor(unsigned int Color) {
|
||||||
|
m_Color = Color;
|
||||||
|
ForceRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
|
|
@ -70,8 +70,7 @@ BS_RenderObject::BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
|
||||||
m_Type(Type),
|
m_Type(Type),
|
||||||
m_InitSuccess(false),
|
m_InitSuccess(false),
|
||||||
m_RefreshForced(true),
|
m_RefreshForced(true),
|
||||||
m_Handle(0)
|
m_Handle(0) {
|
||||||
{
|
|
||||||
// Renderobject registrieren, abhängig vom Handle-Parameter entweder mit beliebigem oder vorgegebenen Handle.
|
// Renderobject registrieren, abhängig vom Handle-Parameter entweder mit beliebigem oder vorgegebenen Handle.
|
||||||
if (Handle == 0)
|
if (Handle == 0)
|
||||||
m_Handle = BS_RenderObjectRegistry::GetInstance().RegisterObject(this);
|
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
|
// Dieses Objekt zu den Kindern der Elternobjektes hinzufügen, falls nicht Wurzel (ParentPtr ungültig) und dem
|
||||||
// selben RenderObjektManager zuweisen.
|
// selben RenderObjektManager zuweisen.
|
||||||
if (m_ParentPtr.IsValid())
|
if (m_ParentPtr.IsValid()) {
|
||||||
{
|
|
||||||
m_ManagerPtr = m_ParentPtr->GetManager();
|
m_ManagerPtr = m_ParentPtr->GetManager();
|
||||||
m_ParentPtr->AddObject(this);
|
m_ParentPtr->AddObject(this);
|
||||||
}
|
} else {
|
||||||
else
|
if (GetType() != TYPE_ROOT) {
|
||||||
{
|
|
||||||
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.");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -102,8 +97,7 @@ BS_RenderObject::BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject> ParentPtr,
|
||||||
m_InitSuccess = true;
|
m_InitSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_RenderObject::~BS_RenderObject()
|
BS_RenderObject::~BS_RenderObject() {
|
||||||
{
|
|
||||||
// Objekt aus dem Elternobjekt entfernen.
|
// Objekt aus dem Elternobjekt entfernen.
|
||||||
if (m_ParentPtr.IsValid()) m_ParentPtr->DetatchChildren(this);
|
if (m_ParentPtr.IsValid()) m_ParentPtr->DetatchChildren(this);
|
||||||
|
|
||||||
|
@ -115,8 +109,7 @@ BS_RenderObject::~BS_RenderObject()
|
||||||
|
|
||||||
// Rendern
|
// Rendern
|
||||||
// -------
|
// -------
|
||||||
bool BS_RenderObject::Render()
|
bool BS_RenderObject::Render() {
|
||||||
{
|
|
||||||
// Objektänderungen validieren
|
// Objektänderungen validieren
|
||||||
ValidateObject();
|
ValidateObject();
|
||||||
|
|
||||||
|
@ -124,8 +117,7 @@ bool BS_RenderObject::Render()
|
||||||
if (!m_Visible) return true;
|
if (!m_Visible) return true;
|
||||||
|
|
||||||
// Falls notwendig, wird die Renderreihenfolge der Kinderobjekte aktualisiert.
|
// Falls notwendig, wird die Renderreihenfolge der Kinderobjekte aktualisiert.
|
||||||
if (m_ChildChanged)
|
if (m_ChildChanged) {
|
||||||
{
|
|
||||||
SortRenderObjects();
|
SortRenderObjects();
|
||||||
m_ChildChanged = false;
|
m_ChildChanged = false;
|
||||||
}
|
}
|
||||||
|
@ -144,8 +136,7 @@ bool BS_RenderObject::Render()
|
||||||
// Objektverwaltung
|
// Objektverwaltung
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
void BS_RenderObject::ValidateObject()
|
void BS_RenderObject::ValidateObject() {
|
||||||
{
|
|
||||||
// Die Veränderungen in den Objektvariablen aufheben
|
// Die Veränderungen in den Objektvariablen aufheben
|
||||||
m_OldBBox = m_BBox;
|
m_OldBBox = m_BBox;
|
||||||
m_OldVisible = m_Visible;
|
m_OldVisible = m_Visible;
|
||||||
|
@ -155,8 +146,7 @@ void BS_RenderObject::ValidateObject()
|
||||||
m_RefreshForced = false;
|
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
|
// 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.
|
// registriert werden.
|
||||||
if ((CalcBoundingBox() != m_OldBBox) ||
|
if ((CalcBoundingBox() != m_OldBBox) ||
|
||||||
|
@ -164,8 +154,7 @@ bool BS_RenderObject::UpdateObjectState()
|
||||||
(m_X != m_OldX) ||
|
(m_X != m_OldX) ||
|
||||||
(m_Y != m_OldY) ||
|
(m_Y != m_OldY) ||
|
||||||
(m_Z != m_OldZ) ||
|
(m_Z != m_OldZ) ||
|
||||||
m_RefreshForced)
|
m_RefreshForced) {
|
||||||
{
|
|
||||||
// Renderrang des Objektes neu bestimmen, da sich dieser verändert haben könnte
|
// Renderrang des Objektes neu bestimmen, da sich dieser verändert haben könnte
|
||||||
if (m_ParentPtr.IsValid()) m_ParentPtr->SignalChildChange();
|
if (m_ParentPtr.IsValid()) m_ParentPtr->SignalChildChange();
|
||||||
|
|
||||||
|
@ -184,14 +173,12 @@ bool BS_RenderObject::UpdateObjectState()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::UpdateBoxes()
|
void BS_RenderObject::UpdateBoxes() {
|
||||||
{
|
|
||||||
// Bounding-Box aktualisieren
|
// Bounding-Box aktualisieren
|
||||||
m_BBox = CalcBoundingBox();
|
m_BBox = CalcBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_Rect BS_RenderObject::CalcBoundingBox() const
|
BS_Rect BS_RenderObject::CalcBoundingBox() const {
|
||||||
{
|
|
||||||
// Die Bounding-Box mit der Objektgröße initialisieren.
|
// Die Bounding-Box mit der Objektgröße initialisieren.
|
||||||
BS_Rect BBox(0, 0, m_Width, m_Height);
|
BS_Rect BBox(0, 0, m_Width, m_Height);
|
||||||
|
|
||||||
|
@ -204,22 +191,19 @@ BS_Rect BS_RenderObject::CalcBoundingBox() const
|
||||||
return BBox;
|
return BBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::CalcAbsolutePos(int& X, int& Y) const
|
void BS_RenderObject::CalcAbsolutePos(int &X, int &Y) const {
|
||||||
{
|
|
||||||
X = CalcAbsoluteX();
|
X = CalcAbsoluteX();
|
||||||
Y = CalcAbsoluteY();
|
Y = CalcAbsoluteY();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BS_RenderObject::CalcAbsoluteX() const
|
int BS_RenderObject::CalcAbsoluteX() const {
|
||||||
{
|
|
||||||
if (m_ParentPtr.IsValid())
|
if (m_ParentPtr.IsValid())
|
||||||
return m_ParentPtr->GetAbsoluteX() + m_X;
|
return m_ParentPtr->GetAbsoluteX() + m_X;
|
||||||
else
|
else
|
||||||
return m_X;
|
return m_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BS_RenderObject::CalcAbsoluteY() const
|
int BS_RenderObject::CalcAbsoluteY() const {
|
||||||
{
|
|
||||||
if (m_ParentPtr.IsValid())
|
if (m_ParentPtr.IsValid())
|
||||||
return m_ParentPtr->GetAbsoluteY() + m_Y;
|
return m_ParentPtr->GetAbsoluteY() + m_Y;
|
||||||
else
|
else
|
||||||
|
@ -229,21 +213,17 @@ int BS_RenderObject::CalcAbsoluteY() const
|
||||||
// Baumverwaltung
|
// 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
|
// 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.
|
// 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();
|
BS_RenderObjectPtr<BS_RenderObject> CurPtr = m_Children.back();
|
||||||
CurPtr.Erase();
|
CurPtr.Erase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BS_RenderObject::AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject)
|
bool BS_RenderObject::AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject) {
|
||||||
{
|
if (!pObject.IsValid()) {
|
||||||
if (!pObject.IsValid())
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Tried to add a null object to a renderobject.");
|
BS_LOG_ERRORLN("Tried to add a null object to a renderobject.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -257,13 +237,11 @@ bool BS_RenderObject::AddObject(BS_RenderObjectPtr<BS_RenderObject> pObject)
|
||||||
return true;
|
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
|
// Kinderliste durchgehen und Objekt entfernen falls vorhanden
|
||||||
RENDEROBJECT_ITER it = m_Children.begin();
|
RENDEROBJECT_ITER it = m_Children.begin();
|
||||||
for (; it != m_Children.end(); ++it)
|
for (; it != m_Children.end(); ++it)
|
||||||
if (*it == pObject)
|
if (*it == pObject) {
|
||||||
{
|
|
||||||
m_Children.erase(it);
|
m_Children.erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -272,13 +250,11 @@ bool BS_RenderObject::DetatchChildren(BS_RenderObjectPtr<BS_RenderObject> pObjec
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::SortRenderObjects()
|
void BS_RenderObject::SortRenderObjects() {
|
||||||
{
|
|
||||||
std::sort(m_Children.begin(), m_Children.end(), Greater);
|
std::sort(m_Children.begin(), m_Children.end(), Greater);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::UpdateAbsolutePos()
|
void BS_RenderObject::UpdateAbsolutePos() {
|
||||||
{
|
|
||||||
CalcAbsolutePos(m_AbsoluteX, m_AbsoluteY);
|
CalcAbsolutePos(m_AbsoluteX, m_AbsoluteY);
|
||||||
|
|
||||||
RENDEROBJECT_ITER it = m_Children.begin();
|
RENDEROBJECT_ITER it = m_Children.begin();
|
||||||
|
@ -289,42 +265,36 @@ void BS_RenderObject::UpdateAbsolutePos()
|
||||||
// Get-Methoden
|
// 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);
|
return m_BBox.Intersect(pObject->GetBBox(), Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set-Methoden
|
// Set-Methoden
|
||||||
// ------------
|
// ------------
|
||||||
void BS_RenderObject::SetPos(int X, int Y)
|
void BS_RenderObject::SetPos(int X, int Y) {
|
||||||
{
|
|
||||||
m_X = X;
|
m_X = X;
|
||||||
m_Y = Y;
|
m_Y = Y;
|
||||||
UpdateAbsolutePos();
|
UpdateAbsolutePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::SetX(int X)
|
void BS_RenderObject::SetX(int X) {
|
||||||
{
|
|
||||||
m_X = X;
|
m_X = X;
|
||||||
UpdateAbsolutePos();
|
UpdateAbsolutePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::SetY(int Y)
|
void BS_RenderObject::SetY(int Y) {
|
||||||
{
|
|
||||||
m_Y = Y;
|
m_Y = Y;
|
||||||
UpdateAbsolutePos();
|
UpdateAbsolutePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::SetZ(int Z)
|
void BS_RenderObject::SetZ(int Z) {
|
||||||
{
|
|
||||||
if (Z < 0)
|
if (Z < 0)
|
||||||
BS_LOG_ERRORLN("Tried to set a negative Z value (%d).", Z);
|
BS_LOG_ERRORLN("Tried to set a negative Z value (%d).", Z);
|
||||||
else
|
else
|
||||||
m_Z = Z;
|
m_Z = Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BS_RenderObject::SetVisible(bool Visible)
|
void BS_RenderObject::SetVisible(bool Visible) {
|
||||||
{
|
|
||||||
m_Visible = Visible;
|
m_Visible = Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,13 +302,11 @@ void BS_RenderObject::SetVisible(bool Visible)
|
||||||
// Objekterzeuger
|
// 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));
|
BS_RenderObjectPtr<BS_Animation> AniPtr(new BS_Animation(this, Filename));
|
||||||
if (AniPtr.IsValid() && AniPtr->GetInitSuccess())
|
if (AniPtr.IsValid() && AniPtr->GetInitSuccess())
|
||||||
return AniPtr;
|
return AniPtr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (AniPtr.IsValid()) AniPtr.Erase();
|
if (AniPtr.IsValid()) AniPtr.Erase();
|
||||||
return BS_RenderObjectPtr<BS_Animation>();
|
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_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate &AnimationTemplate) {
|
||||||
{
|
|
||||||
BS_Animation *AniPtr = new BS_Animation(this, AnimationTemplate);
|
BS_Animation *AniPtr = new BS_Animation(this, AnimationTemplate);
|
||||||
if (AniPtr && AniPtr->GetInitSuccess())
|
if (AniPtr && AniPtr->GetInitSuccess())
|
||||||
return AniPtr;
|
return AniPtr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
delete AniPtr;
|
delete AniPtr;
|
||||||
return BS_RenderObjectPtr<BS_Animation>();
|
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));
|
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_StaticBitmap(this, Filename));
|
||||||
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
|
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
|
||||||
return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr);
|
return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
|
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
|
||||||
return BS_RenderObjectPtr<BS_Bitmap>();
|
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));
|
BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_DynamicBitmap(this, Width, Height));
|
||||||
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
|
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
|
||||||
return BitmapPtr;
|
return BitmapPtr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
|
if (BitmapPtr.IsValid()) BitmapPtr.Erase();
|
||||||
return BS_RenderObjectPtr<BS_Bitmap>();
|
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));
|
BS_RenderObjectPtr<BS_Panel> PanelPtr(new BS_Panel(this, Width, Height, Color));
|
||||||
if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess())
|
if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess())
|
||||||
return PanelPtr;
|
return PanelPtr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (PanelPtr.IsValid()) PanelPtr.Erase();
|
if (PanelPtr.IsValid()) PanelPtr.Erase();
|
||||||
return BS_RenderObjectPtr<BS_Panel>();
|
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));
|
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);
|
TextPtr->SetText(Text);
|
||||||
return TextPtr;
|
return TextPtr;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (TextPtr.IsValid()) TextPtr.Erase();
|
if (TextPtr.IsValid()) TextPtr.Erase();
|
||||||
return BS_RenderObjectPtr<BS_Text>();
|
return BS_RenderObjectPtr<BS_Text>();
|
||||||
}
|
}
|
||||||
|
@ -421,8 +377,7 @@ BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String & Font
|
||||||
// Persistenz-Methoden
|
// 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.
|
// 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(static_cast<unsigned int>(m_Type));
|
||||||
Writer.Write(m_Handle);
|
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.
|
// Typ und Handle wurden schon von RecreatePersistedRenderObject() ausgelesen. Jetzt werden die restlichen Objekteigenschaften ausgelesen.
|
||||||
Reader.Read(m_X);
|
Reader.Read(m_X);
|
||||||
Reader.Read(m_Y);
|
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;
|
bool Result = true;
|
||||||
|
|
||||||
// Kinderanzahl speichern.
|
// Kinderanzahl speichern.
|
||||||
|
@ -505,8 +458,7 @@ bool BS_RenderObject::PersistChildren(BS_OutputPersistenceBlock & Writer)
|
||||||
|
|
||||||
// Rekursiv alle Kinder speichern.
|
// Rekursiv alle Kinder speichern.
|
||||||
RENDEROBJECT_LIST::iterator It = m_Children.begin();
|
RENDEROBJECT_LIST::iterator It = m_Children.begin();
|
||||||
while (It != m_Children.end())
|
while (It != m_Children.end()) {
|
||||||
{
|
|
||||||
Result &= (*It)->Persist(Writer);
|
Result &= (*It)->Persist(Writer);
|
||||||
++It;
|
++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;
|
bool Result = true;
|
||||||
|
|
||||||
// Kinderanzahl einlesen.
|
// Kinderanzahl einlesen.
|
||||||
|
@ -526,8 +477,7 @@ bool BS_RenderObject::UnpersistChildren(BS_InputPersistenceBlock & Reader)
|
||||||
if (!Reader.IsGood()) return false;
|
if (!Reader.IsGood()) return false;
|
||||||
|
|
||||||
// Alle Kinder rekursiv wieder herstellen.
|
// 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;
|
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;
|
BS_RenderObjectPtr<BS_RenderObject> Result;
|
||||||
|
|
||||||
// Typ und Handle auslesen.
|
// Typ und Handle auslesen.
|
||||||
|
@ -547,8 +496,7 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
|
||||||
Reader.Read(Handle);
|
Reader.Read(Handle);
|
||||||
if (!Reader.IsGood()) return Result;
|
if (!Reader.IsGood()) return Result;
|
||||||
|
|
||||||
switch (Type)
|
switch (Type) {
|
||||||
{
|
|
||||||
case TYPE_PANEL:
|
case TYPE_PANEL:
|
||||||
Result = new BS_Panel(Reader, this, Handle);
|
Result = new BS_Panel(Reader, this, Handle);
|
||||||
break;
|
break;
|
||||||
|
@ -578,8 +526,7 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
|
||||||
|
|
||||||
// Hilfs-Methoden
|
// 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.
|
// Das Objekt mit dem kleinem Z-Wert müssen zuerst gerendert werden.
|
||||||
if (lhs->m_Z != rhs->m_Z)
|
if (lhs->m_Z != rhs->m_Z)
|
||||||
return lhs->m_Z < rhs->m_Z;
|
return lhs->m_Z < rhs->m_Z;
|
||||||
|
|
|
@ -75,13 +75,11 @@ class BS_Text;
|
||||||
Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
|
Diese Klasse erledigt Aufgaben wie: minimales Neuzeichnen, Renderreihenfolge, Objekthierachie.
|
||||||
Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet.
|
Alle BS_RenderObject Instanzen werden von einem BS_RenderObjektManager in einem Baum verwaltet.
|
||||||
*/
|
*/
|
||||||
class BS_RenderObject
|
class BS_RenderObject {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
// Konstanten
|
// Konstanten
|
||||||
// ----------
|
// ----------
|
||||||
enum TYPES
|
enum TYPES {
|
||||||
{
|
|
||||||
/// Das Wurzelobjekt. Siehe BS_RenderObjectManager
|
/// Das Wurzelobjekt. Siehe BS_RenderObjectManager
|
||||||
TYPE_ROOT,
|
TYPE_ROOT,
|
||||||
/// Ein Image. Siehe BS_Bitmap.
|
/// Ein Image. Siehe BS_Bitmap.
|
||||||
|
@ -158,36 +156,36 @@ public:
|
||||||
@return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
|
@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.
|
Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
|
||||||
*/
|
*/
|
||||||
BS_RenderObjectPtr<BS_Bitmap> ToBitmap()
|
BS_RenderObjectPtr<BS_Bitmap> ToBitmap() {
|
||||||
{
|
if (m_Type == TYPE_STATICBITMAP || m_Type == TYPE_DYNAMICBITMAP) return BS_RenderObjectPtr<BS_Bitmap>(this);
|
||||||
if (m_Type == TYPE_STATICBITMAP || m_Type == TYPE_DYNAMICBITMAP) return BS_RenderObjectPtr<BS_Bitmap>(this); else return BS_RenderObjectPtr<BS_Bitmap>();
|
else return BS_RenderObjectPtr<BS_Bitmap>();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@brief Castet das Objekt zu einem BS_Animation-Objekt wenn zulässig.
|
@brief Castet das Objekt zu einem BS_Animation-Objekt wenn zulässig.
|
||||||
@return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
|
@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.
|
Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
|
||||||
*/
|
*/
|
||||||
BS_RenderObjectPtr<BS_Animation> ToAnimation()
|
BS_RenderObjectPtr<BS_Animation> ToAnimation() {
|
||||||
{
|
if (m_Type == TYPE_ANIMATION) return BS_RenderObjectPtr<BS_Animation>(this);
|
||||||
if (m_Type == TYPE_ANIMATION) return BS_RenderObjectPtr<BS_Animation>(this); else return BS_RenderObjectPtr<BS_Animation>();
|
else return BS_RenderObjectPtr<BS_Animation>();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@brief Castet das Objekt zu einem BS_Panel-Objekt wenn zulässig.
|
@brief Castet das Objekt zu einem BS_Panel-Objekt wenn zulässig.
|
||||||
@return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
|
@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.
|
Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
|
||||||
*/
|
*/
|
||||||
BS_RenderObjectPtr<BS_Panel> ToPanel()
|
BS_RenderObjectPtr<BS_Panel> ToPanel() {
|
||||||
{
|
if (m_Type == TYPE_PANEL) return BS_RenderObjectPtr<BS_Panel>(this);
|
||||||
if (m_Type == TYPE_PANEL) return BS_RenderObjectPtr<BS_Panel>(this); else return BS_RenderObjectPtr<BS_Panel>();
|
else return BS_RenderObjectPtr<BS_Panel>();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@brief Castet das Object zu einem BS_Text-Objekt wenn zulässig.
|
@brief Castet das Object zu einem BS_Text-Objekt wenn zulässig.
|
||||||
@return Gibt einen BS_RenderObjectPtr auf das Objekt zurück.<br>
|
@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.
|
Falls der Cast nicht zulässig ist, wird ein ungültiger BS_RenderObjectPtr zurückgegeben.
|
||||||
*/
|
*/
|
||||||
BS_RenderObjectPtr<BS_Text> ToText()
|
BS_RenderObjectPtr<BS_Text> ToText() {
|
||||||
{
|
if (m_Type == TYPE_TEXT) return BS_RenderObjectPtr<BS_Text>(this);
|
||||||
if (m_Type == TYPE_TEXT) return BS_RenderObjectPtr<BS_Text>(this); else return BS_RenderObjectPtr<BS_Text>();
|
else return BS_RenderObjectPtr<BS_Text>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Konstruktor / Desktruktor
|
// Konstruktor / Desktruktor
|
||||||
|
@ -270,19 +268,27 @@ public:
|
||||||
/**
|
/**
|
||||||
@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.
|
@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
|
@remark Der Z-Wert legt die Renderreihenfolge der Objekte fest. Objekte mit niedrigem Z-Wert werden vor Objekten mit höherem
|
||||||
|
@ -290,43 +296,61 @@ public:
|
||||||
Wie alle andere Attribute ist auch dieses relativ zum Elternobjekt, ein Kinderobjekt kann also nie unter seinem
|
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.
|
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.
|
@brief Gibt den Sichtbarkeitszustand des Objektes zurück.
|
||||||
@return Gibt den Sichtbarkeitszustand des Objektes zurück.<br>
|
@return Gibt den Sichtbarkeitszustand des Objektes zurück.<br>
|
||||||
true entspricht sichtbar, false entspricht unsichtbar.
|
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.
|
@brief Gibt zurück, ob das Objekt erfolgreich initialisiert wurde.
|
||||||
@remark Hässlicher Workaround um das Problem, dass Konstruktoren keine Rückgabewerte haben.
|
@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.
|
@brief Gibt die Bounding-Box des Objektes zurück.
|
||||||
@remark Diese Angabe erfolgt ausnahmsweise in Bildschirmkoordianten und nicht relativ zum Elternobjekt.
|
@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
|
// Persistenz-Methoden
|
||||||
// -------------------
|
// -------------------
|
||||||
|
@ -409,7 +433,9 @@ protected:
|
||||||
/**
|
/**
|
||||||
@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.
|
@brief Fügt dem Objekt ein neues Kinderobjekt hinzu.
|
||||||
@param pObject ein Pointer auf das einzufügende Objekt
|
@param pObject ein Pointer auf das einzufügende Objekt
|
||||||
|
@ -474,7 +500,9 @@ private:
|
||||||
@brief Teilt dem Objekt mit, dass sich eines seiner Kinderobjekte dahingehend verändert hat, die eine erneute Bestimmung der
|
@brief Teilt dem Objekt mit, dass sich eines seiner Kinderobjekte dahingehend verändert hat, die eine erneute Bestimmung der
|
||||||
Rendereihenfolge verlangt.
|
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.
|
@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 pObjekt ein Pointer auf das Objekt mit dem geschnitten werden soll
|
||||||
|
|
|
@ -57,16 +57,14 @@ namespace Sword25 {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) :
|
BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) :
|
||||||
m_FrameStarted(false)
|
m_FrameStarted(false) {
|
||||||
{
|
|
||||||
// Wurzel des BS_RenderObject-Baumes erzeugen.
|
// Wurzel des BS_RenderObject-Baumes erzeugen.
|
||||||
m_RootPtr = new BS_RootRenderObject(this, Width, Height);
|
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.
|
// Die Wurzel des Baumes löschen, damit werden alle BS_RenderObjects mitgelöscht.
|
||||||
m_RootPtr.Erase();
|
m_RootPtr.Erase();
|
||||||
}
|
}
|
||||||
|
@ -75,8 +73,7 @@ BS_RenderObjectManager::~BS_RenderObjectManager()
|
||||||
// Interface
|
// Interface
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_RenderObjectManager::StartFrame()
|
void BS_RenderObjectManager::StartFrame() {
|
||||||
{
|
|
||||||
m_FrameStarted = true;
|
m_FrameStarted = true;
|
||||||
|
|
||||||
// Verstrichene Zeit bestimmen
|
// 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.
|
// 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
|
// Beim aktualisieren des Objekt-Status werden auch die Update-Rects gefunden, so dass feststeht, was neu gezeichnet
|
||||||
// werden muss.
|
// werden muss.
|
||||||
|
@ -105,15 +101,13 @@ 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);
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -122,8 +116,7 @@ void BS_RenderObjectManager::DetatchTimedRenderObject(BS_RenderObjectPtr<BS_Time
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_RenderObjectManager::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
// Alle Kinder des Wurzelknotens speichern. Dadurch werden alle BS_RenderObjects gespeichert rekursiv gespeichert.
|
// 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.
|
// Referenzen auf die TimedRenderObjects persistieren.
|
||||||
Writer.Write(m_TimedRenderObjects.size());
|
Writer.Write(m_TimedRenderObjects.size());
|
||||||
RenderObjectList::const_iterator Iter = m_TimedRenderObjects.begin();
|
RenderObjectList::const_iterator Iter = m_TimedRenderObjects.begin();
|
||||||
while (Iter != m_TimedRenderObjects.end())
|
while (Iter != m_TimedRenderObjects.end()) {
|
||||||
{
|
|
||||||
Writer.Write((*Iter)->GetHandle());
|
Writer.Write((*Iter)->GetHandle());
|
||||||
++Iter;
|
++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;
|
bool Result = true;
|
||||||
|
|
||||||
// Alle Kinder des Wurzelknotens löschen. Damit werden alle BS_RenderObjects gelöscht.
|
// 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.
|
// Referenzen auf die TimedRenderObjects wieder herstellen.
|
||||||
unsigned int TimedObjectCount;
|
unsigned int TimedObjectCount;
|
||||||
Reader.Read(TimedObjectCount);
|
Reader.Read(TimedObjectCount);
|
||||||
for (unsigned int i = 0; i < TimedObjectCount; ++i)
|
for (unsigned int i = 0; i < TimedObjectCount; ++i) {
|
||||||
{
|
|
||||||
unsigned int Handle;
|
unsigned int Handle;
|
||||||
Reader.Read(Handle);
|
Reader.Read(Handle);
|
||||||
m_TimedRenderObjects.push_back(Handle);
|
m_TimedRenderObjects.push_back(Handle);
|
||||||
|
|
|
@ -68,8 +68,7 @@ class BS_TimedRenderObject;
|
||||||
Sie sorgt dafür, dass die BS_RenderObjects in der richtigen Reihenfolge gerendert werden und ermöglicht den Zugriff auf die
|
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.
|
BS_RenderObjects über einen String.
|
||||||
*/
|
*/
|
||||||
class BS_RenderObjectManager : public BS_Persistable
|
class BS_RenderObjectManager : public BS_Persistable {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief Erzeugt ein neues BS_RenderObjectManager-Objekt.
|
@brief Erzeugt ein neues BS_RenderObjectManager-Objekt.
|
||||||
|
@ -99,7 +98,9 @@ public:
|
||||||
/**
|
/**
|
||||||
@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.
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,7 @@ class BS_RenderObject;
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class BS_RenderObjectPtr
|
class BS_RenderObjectPtr {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_RenderObjectPtr() : m_Handle(0)
|
BS_RenderObjectPtr() : m_Handle(0)
|
||||||
{}
|
{}
|
||||||
|
@ -66,23 +65,19 @@ public:
|
||||||
|
|
||||||
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));
|
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;
|
return m_Handle == other.m_Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValid() const
|
bool IsValid() const {
|
||||||
{
|
|
||||||
return BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle) != 0;
|
return BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Erase()
|
void Erase() {
|
||||||
{
|
|
||||||
delete static_cast<T *>(BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle));
|
delete static_cast<T *>(BS_RenderObjectRegistry::GetInstance().ResolveHandle(m_Handle));
|
||||||
m_Handle = 0;
|
m_Handle = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
BS_LOG_ERRORLN(Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_RenderObjectRegistry::LogWarningLn(const char * Message) const
|
void BS_RenderObjectRegistry::LogWarningLn(const char *Message) const {
|
||||||
{
|
|
||||||
BS_LOG_WARNINGLN(Message);
|
BS_LOG_WARNINGLN(Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,21 +50,21 @@ class BS_Kernel;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
class BS_RenderObjectManager;
|
class BS_RenderObjectManager;
|
||||||
|
|
||||||
class BS_RootRenderObject : public BS_RenderObject
|
class BS_RootRenderObject : public BS_RenderObject {
|
||||||
{
|
|
||||||
friend BS_RenderObjectManager;
|
friend BS_RenderObjectManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BS_RootRenderObject(BS_RenderObjectManager *ManagerPtr, int Width, int Height) :
|
BS_RootRenderObject(BS_RenderObjectManager *ManagerPtr, int Width, int Height) :
|
||||||
BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject>(), TYPE_ROOT)
|
BS_RenderObject(BS_RenderObjectPtr<BS_RenderObject>(), TYPE_ROOT) {
|
||||||
{
|
|
||||||
m_ManagerPtr = ManagerPtr;
|
m_ManagerPtr = ManagerPtr;
|
||||||
m_Width = Width;
|
m_Width = Width;
|
||||||
m_Height = Height;
|
m_Height = Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool DoRender() { return true; }
|
virtual bool DoRender() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Sword25
|
} // End of namespace Sword25
|
||||||
|
|
|
@ -47,8 +47,7 @@ using namespace std;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct RGB_PIXEL
|
struct RGB_PIXEL {
|
||||||
{
|
|
||||||
RGB_PIXEL(unsigned char _Red, unsigned char _Green, unsigned char _Blue) :
|
RGB_PIXEL(unsigned char _Red, unsigned char _Green, unsigned char _Blue) :
|
||||||
Red(_Red),
|
Red(_Red),
|
||||||
Green(_Green),
|
Green(_Green),
|
||||||
|
@ -60,8 +59,7 @@ struct RGB_PIXEL
|
||||||
unsigned char Blue;
|
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);
|
BS_ASSERT(Data.size() == Width * Height);
|
||||||
|
|
||||||
// Buffer für Bildschirminhalt in RGB reservieren
|
// 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
|
// Framebufferdaten pixelweise von RGBA nach RGB konvertieren
|
||||||
vector<unsigned int>::const_iterator it = Data.begin();
|
vector<unsigned int>::const_iterator it = Data.begin();
|
||||||
for (unsigned int y = 0; y < Height; y++)
|
for (unsigned int y = 0; y < Height; y++) {
|
||||||
{
|
for (unsigned int x = 0; x < Width; x++) {
|
||||||
for (unsigned int x = 0; x < Width; x++)
|
|
||||||
{
|
|
||||||
unsigned int SrcPixel = *it++;
|
unsigned int SrcPixel = *it++;
|
||||||
PixelBuffer.push_back(RGB_PIXEL((SrcPixel >> 16) & 0xff, (SrcPixel >> 8) & 0xff, SrcPixel & 0xff));
|
PixelBuffer.push_back(RGB_PIXEL((SrcPixel >> 16) & 0xff, (SrcPixel >> 8) & 0xff, SrcPixel & 0xff));
|
||||||
}
|
}
|
||||||
|
@ -86,25 +82,21 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
|
||||||
png_structp png_ptr = 0;
|
png_structp png_ptr = 0;
|
||||||
png_infop info_ptr = 0;
|
png_infop info_ptr = 0;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
OutFile = fopen(Filename.c_str(), "wb");
|
OutFile = fopen(Filename.c_str(), "wb");
|
||||||
if (!OutFile)
|
if (!OutFile) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not create screenshot-file \"%s\".", Filename.c_str());
|
BS_LOG_ERRORLN("Could not create screenshot-file \"%s\".", Filename.c_str());
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
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.");
|
BS_LOG_ERRORLN("Could not create PNG write-struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
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.");
|
BS_LOG_ERRORLN("Could not create PNG info-struct.");
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
|
@ -127,8 +119,7 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
|
||||||
// Rowpointer erstellen
|
// Rowpointer erstellen
|
||||||
vector<png_bytep> RowPointers;
|
vector<png_bytep> RowPointers;
|
||||||
RowPointers.reserve(Height);
|
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]));
|
RowPointers.push_back((png_bytep)(&PixelBuffer[Width * i]));
|
||||||
}
|
}
|
||||||
png_set_rows(png_ptr, info_ptr, &RowPointers[0]);
|
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);
|
fclose(OutFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (int)
|
catch (int) {
|
||||||
{
|
|
||||||
// Wenn die Datei bereits erstellt wurde, Datei schließen und löschen.
|
// Wenn die Datei bereits erstellt wurde, Datei schließen und löschen.
|
||||||
if (OutFile)
|
if (OutFile) {
|
||||||
{
|
|
||||||
fclose(OutFile);
|
fclose(OutFile);
|
||||||
remove(Filename.c_str());
|
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.
|
// 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
|
// Dabei werden je 50 Pixel oben und unten abgeschnitten (die Interface-Leisten im Spiel). Das verbleibende Bild von 800x500 wird auf
|
||||||
|
@ -173,8 +161,7 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
|
||||||
//
|
//
|
||||||
|
|
||||||
// Die Ausgangsgröße muss 800x600 sein.
|
// 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.");
|
BS_LOG_ERRORLN("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -185,15 +172,12 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
|
||||||
// Über das Zielbild iterieren und einen Pixel zur Zeit berechnen.
|
// Über das Zielbild iterieren und einen Pixel zur Zeit berechnen.
|
||||||
unsigned int x, y;
|
unsigned int x, y;
|
||||||
x = y = 0;
|
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.
|
// Durchschnitt über 4x4 Pixelblock im Quellbild bilden.
|
||||||
unsigned int Alpha, Red, Green, Blue;
|
unsigned int Alpha, Red, Green, Blue;
|
||||||
Alpha = Red = Green = Blue = 0;
|
Alpha = Red = Green = Blue = 0;
|
||||||
for (unsigned int j = 0; j < 4; ++j)
|
for (unsigned int j = 0; j < 4; ++j) {
|
||||||
{
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
for (unsigned int i = 0; i < 4; ++i)
|
|
||||||
{
|
|
||||||
unsigned int Pixel = Data[((y * 4) + j + 50) * 800 + ((x * 4) + i)];
|
unsigned int Pixel = Data[((y * 4) + j + 50) * 800 + ((x * 4) + i)];
|
||||||
Alpha += (Pixel >> 24);
|
Alpha += (Pixel >> 24);
|
||||||
Red += (Pixel >> 16) & 0xff;
|
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.
|
// Mitzählen an welcher Stelle im Zielbild wir uns befinden.
|
||||||
++x;
|
++x;
|
||||||
if (x == 200)
|
if (x == 200) {
|
||||||
{
|
|
||||||
x = 0;
|
x = 0;
|
||||||
++y;
|
++y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,7 @@ namespace Sword25 {
|
||||||
// Class declaration
|
// Class declaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_Screenshot
|
class BS_Screenshot {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static bool SaveToFile(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);
|
static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename);
|
||||||
|
|
|
@ -55,8 +55,7 @@ namespace Sword25 {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_StaticBitmap::BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &Filename) :
|
BS_StaticBitmap::BS_StaticBitmap(BS_RenderObjectPtr<BS_RenderObject> ParentPtr, const Common::String &Filename) :
|
||||||
BS_Bitmap(ParentPtr, TYPE_STATICBITMAP)
|
BS_Bitmap(ParentPtr, TYPE_STATICBITMAP) {
|
||||||
{
|
|
||||||
// Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
// Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden.
|
||||||
if (!m_InitSuccess) return;
|
if (!m_InitSuccess) return;
|
||||||
|
|
||||||
|
@ -66,24 +65,20 @@ 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_StaticBitmap::BS_StaticBitmap(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
|
||||||
BS_Bitmap(ParentPtr, TYPE_STATICBITMAP, Handle)
|
BS_Bitmap(ParentPtr, TYPE_STATICBITMAP, Handle) {
|
||||||
{
|
|
||||||
m_InitSuccess = Unpersist(Reader);
|
m_InitSuccess = Unpersist(Reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_StaticBitmap::InitBitmapResource(const Common::String & Filename)
|
bool BS_StaticBitmap::InitBitmapResource(const Common::String &Filename) {
|
||||||
{
|
|
||||||
// Bild-Resource laden
|
// Bild-Resource laden
|
||||||
BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(Filename);
|
BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(Filename);
|
||||||
if (!ResourcePtr)
|
if (!ResourcePtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not request resource \"%s\".", Filename.c_str());
|
BS_LOG_ERRORLN("Could not request resource \"%s\".", Filename.c_str());
|
||||||
return false;
|
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());
|
BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", Filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -105,14 +100,12 @@ 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
|
// 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);
|
||||||
|
@ -125,15 +118,12 @@ bool BS_StaticBitmap::DoRender()
|
||||||
|
|
||||||
// Bitmap zeichnen
|
// Bitmap zeichnen
|
||||||
bool Result;
|
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,
|
Result = BitmapResourcePtr->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
0, m_ModulationColor, -1, -1);
|
0, m_ModulationColor, -1, -1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Result = BitmapResourcePtr->Blit(m_AbsoluteX, m_AbsoluteY,
|
Result = BitmapResourcePtr->Blit(m_AbsoluteX, m_AbsoluteY,
|
||||||
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
(m_FlipV ? BS_BitmapResource::FLIP_V : 0) |
|
||||||
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
(m_FlipH ? BS_BitmapResource::FLIP_H : 0),
|
||||||
|
@ -148,8 +138,7 @@ 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(X >= 0 && X < m_Width);
|
||||||
BS_ASSERT(Y >= 0 && Y < m_Height);
|
BS_ASSERT(Y >= 0 && Y < m_Height);
|
||||||
|
|
||||||
|
@ -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.");
|
BS_LOG_ERRORLN("SetContent() ist not supported with this object.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +161,7 @@ bool BS_StaticBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, uns
|
||||||
// Auskunftsmethoden
|
// Auskunftsmethoden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_StaticBitmap::IsAlphaAllowed() const
|
bool BS_StaticBitmap::IsAlphaAllowed() const {
|
||||||
{
|
|
||||||
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_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
|
||||||
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsAlphaAllowed();
|
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsAlphaAllowed();
|
||||||
|
@ -184,8 +171,7 @@ bool BS_StaticBitmap::IsAlphaAllowed() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_StaticBitmap::IsColorModulationAllowed() const
|
bool BS_StaticBitmap::IsColorModulationAllowed() const {
|
||||||
{
|
|
||||||
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_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
|
||||||
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsColorModulationAllowed();
|
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsColorModulationAllowed();
|
||||||
|
@ -195,8 +181,7 @@ bool BS_StaticBitmap::IsColorModulationAllowed() const
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_StaticBitmap::IsScalingAllowed() const
|
bool BS_StaticBitmap::IsScalingAllowed() const {
|
||||||
{
|
|
||||||
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_ASSERT(pResource->GetType() == BS_Resource::TYPE_BITMAP);
|
||||||
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsScalingAllowed();
|
bool Result = static_cast<BS_BitmapResource *>(pResource)->IsScalingAllowed();
|
||||||
|
@ -208,8 +193,7 @@ bool BS_StaticBitmap::IsScalingAllowed() const
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_Bitmap::Persist(Writer);
|
Result &= BS_Bitmap::Persist(Writer);
|
||||||
|
@ -220,8 +204,7 @@ bool BS_StaticBitmap::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BS_StaticBitmap::Unpersist(BS_InputPersistenceBlock & Reader)
|
bool BS_StaticBitmap::Unpersist(BS_InputPersistenceBlock &Reader) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_Bitmap::Unpersist(Reader);
|
Result &= BS_Bitmap::Unpersist(Reader);
|
||||||
|
|
|
@ -48,8 +48,7 @@ namespace Sword25 {
|
||||||
// Klassendeklaration
|
// Klassendeklaration
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_StaticBitmap : public BS_Bitmap
|
class BS_StaticBitmap : public BS_Bitmap {
|
||||||
{
|
|
||||||
friend class BS_RenderObject;
|
friend class BS_RenderObject;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -69,7 +68,9 @@ public:
|
||||||
virtual bool IsScalingAllowed() const;
|
virtual bool IsScalingAllowed() const;
|
||||||
virtual bool IsAlphaAllowed() const;
|
virtual bool IsAlphaAllowed() const;
|
||||||
virtual bool IsColorModulationAllowed() const;
|
virtual bool IsColorModulationAllowed() const;
|
||||||
virtual bool IsSetContentAllowed() const { return false; }
|
virtual bool IsSetContentAllowed() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
|
|
@ -56,8 +56,7 @@ namespace Sword25 {
|
||||||
// Konstanten
|
// Konstanten
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const unsigned int AUTO_WRAP_THRESHOLD_DEFAULT = 300;
|
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),
|
BS_RenderObject(ParentPtr, BS_RenderObject::TYPE_TEXT),
|
||||||
m_ModulationColor(0xffffffff),
|
m_ModulationColor(0xffffffff),
|
||||||
m_AutoWrap(false),
|
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_Text::BS_Text(BS_InputPersistenceBlock &Reader, BS_RenderObjectPtr<BS_RenderObject> ParentPtr, unsigned int Handle) :
|
||||||
BS_RenderObject(ParentPtr, TYPE_TEXT, Handle)
|
BS_RenderObject(ParentPtr, TYPE_TEXT, Handle) {
|
||||||
{
|
|
||||||
m_InitSuccess = Unpersist(Reader);
|
m_InitSuccess = Unpersist(Reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Text::SetFont(const Common::String & Font)
|
bool BS_Text::SetFont(const Common::String &Font) {
|
||||||
{
|
|
||||||
// Font precachen.
|
// Font precachen.
|
||||||
if (GetResourceManager()->PrecacheResource(Font))
|
if (GetResourceManager()->PrecacheResource(Font)) {
|
||||||
{
|
|
||||||
m_Font = Font;
|
m_Font = Font;
|
||||||
UpdateFormat();
|
UpdateFormat();
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not precache font \"%s\". Font probably does not exist.", Font.c_str());
|
BS_LOG_ERRORLN("Could not precache font \"%s\". Font probably does not exist.", Font.c_str());
|
||||||
return false;
|
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;
|
m_Text = Text;
|
||||||
UpdateFormat();
|
UpdateFormat();
|
||||||
ForceRefresh();
|
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);
|
unsigned int NewModulationColor = (ModulationColor & 0x00ffffff) | (m_ModulationColor & 0xff000000);
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
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);
|
BS_ASSERT(Alpha >= 0 && Alpha < 256);
|
||||||
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
unsigned int NewModulationColor = (m_ModulationColor & 0x00ffffff) | Alpha << 24;
|
||||||
if (NewModulationColor != m_ModulationColor)
|
if (NewModulationColor != m_ModulationColor) {
|
||||||
{
|
|
||||||
m_ModulationColor = NewModulationColor;
|
m_ModulationColor = NewModulationColor;
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
}
|
}
|
||||||
|
@ -138,10 +126,8 @@ void BS_Text::SetAlpha(int Alpha)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Text::SetAutoWrap(bool AutoWrap)
|
void BS_Text::SetAutoWrap(bool AutoWrap) {
|
||||||
{
|
if (AutoWrap != m_AutoWrap) {
|
||||||
if (AutoWrap != m_AutoWrap)
|
|
||||||
{
|
|
||||||
m_AutoWrap = AutoWrap;
|
m_AutoWrap = AutoWrap;
|
||||||
UpdateFormat();
|
UpdateFormat();
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
|
@ -150,10 +136,8 @@ void BS_Text::SetAutoWrap(bool AutoWrap)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold)
|
void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold) {
|
||||||
{
|
if (AutoWrapThreshold != m_AutoWrapThreshold) {
|
||||||
if (AutoWrapThreshold != m_AutoWrapThreshold)
|
|
||||||
{
|
|
||||||
m_AutoWrapThreshold = AutoWrapThreshold;
|
m_AutoWrapThreshold = AutoWrapThreshold;
|
||||||
UpdateFormat();
|
UpdateFormat();
|
||||||
ForceRefresh();
|
ForceRefresh();
|
||||||
|
@ -162,8 +146,7 @@ void BS_Text::SetAutoWrapThreshold(unsigned int AutoWrapThreshold)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Text::DoRender()
|
bool BS_Text::DoRender() {
|
||||||
{
|
|
||||||
// Font-Resource locken.
|
// Font-Resource locken.
|
||||||
BS_FontResource *FontPtr = LockFontResource();
|
BS_FontResource *FontPtr = LockFontResource();
|
||||||
if (!FontPtr) return false;
|
if (!FontPtr) return false;
|
||||||
|
@ -173,13 +156,11 @@ bool BS_Text::DoRender()
|
||||||
BS_BitmapResource *CharMapPtr;
|
BS_BitmapResource *CharMapPtr;
|
||||||
{
|
{
|
||||||
BS_Resource *pResource = RMPtr->RequestResource(FontPtr->GetCharactermapFileName());
|
BS_Resource *pResource = RMPtr->RequestResource(FontPtr->GetCharactermapFileName());
|
||||||
if (!pResource)
|
if (!pResource) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not request resource \"%s\".", FontPtr->GetCharactermapFileName().c_str());
|
BS_LOG_ERRORLN("Could not request resource \"%s\".", FontPtr->GetCharactermapFileName().c_str());
|
||||||
return false;
|
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());
|
BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", FontPtr->GetCharactermapFileName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -193,8 +174,7 @@ bool BS_Text::DoRender()
|
||||||
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
Common::Array<LINE>::iterator Iter = m_Lines.begin();
|
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.
|
// Feststellen, ob überhaupt Buchstaben der aktuellen Zeile vom Update betroffen sind.
|
||||||
BS_Rect CheckRect = (*Iter).BBox;
|
BS_Rect CheckRect = (*Iter).BBox;
|
||||||
CheckRect.Move(m_AbsoluteX, m_AbsoluteY);
|
CheckRect.Move(m_AbsoluteX, m_AbsoluteY);
|
||||||
|
@ -202,8 +182,7 @@ bool BS_Text::DoRender()
|
||||||
// Jeden Buchstaben einzeln Rendern.
|
// Jeden Buchstaben einzeln Rendern.
|
||||||
int CurX = m_AbsoluteX + (*Iter).BBox.left;
|
int CurX = m_AbsoluteX + (*Iter).BBox.left;
|
||||||
int CurY = m_AbsoluteY + (*Iter).BBox.top;
|
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 CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text.at(i));
|
||||||
|
|
||||||
BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight());
|
BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight());
|
||||||
|
@ -228,29 +207,25 @@ bool BS_Text::DoRender()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_ResourceManager * BS_Text::GetResourceManager()
|
BS_ResourceManager *BS_Text::GetResourceManager() {
|
||||||
{
|
|
||||||
// Pointer auf den Resource-Manager holen.
|
// Pointer auf den Resource-Manager holen.
|
||||||
return BS_Kernel::GetInstance()->GetResourceManager();
|
return BS_Kernel::GetInstance()->GetResourceManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_FontResource * BS_Text::LockFontResource()
|
BS_FontResource *BS_Text::LockFontResource() {
|
||||||
{
|
|
||||||
BS_ResourceManager *RMPtr = GetResourceManager();
|
BS_ResourceManager *RMPtr = GetResourceManager();
|
||||||
|
|
||||||
// Font-Resource locken.
|
// Font-Resource locken.
|
||||||
BS_FontResource *FontPtr;
|
BS_FontResource *FontPtr;
|
||||||
{
|
{
|
||||||
BS_Resource *ResourcePtr = RMPtr->RequestResource(m_Font);
|
BS_Resource *ResourcePtr = RMPtr->RequestResource(m_Font);
|
||||||
if (!ResourcePtr)
|
if (!ResourcePtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not request resource \"%s\".", m_Font.c_str());
|
BS_LOG_ERRORLN("Could not request resource \"%s\".", m_Font.c_str());
|
||||||
return NULL;
|
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());
|
BS_LOG_ERRORLN("Requested resource \"%s\" is not a font.", m_Font.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -263,16 +238,14 @@ BS_FontResource * BS_Text::LockFontResource()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Text::UpdateFormat()
|
void BS_Text::UpdateFormat() {
|
||||||
{
|
|
||||||
BS_FontResource *FontPtr = LockFontResource();
|
BS_FontResource *FontPtr = LockFontResource();
|
||||||
BS_ASSERT(FontPtr);
|
BS_ASSERT(FontPtr);
|
||||||
|
|
||||||
UpdateMetrics(*FontPtr);
|
UpdateMetrics(*FontPtr);
|
||||||
|
|
||||||
m_Lines.resize(1);
|
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;
|
m_Width = 0;
|
||||||
unsigned int CurLineWidth = 0;
|
unsigned int CurLineWidth = 0;
|
||||||
unsigned int CurLineHeight = 0;
|
unsigned int CurLineHeight = 0;
|
||||||
|
@ -280,13 +253,11 @@ void BS_Text::UpdateFormat()
|
||||||
unsigned int TempLineWidth = 0;
|
unsigned int TempLineWidth = 0;
|
||||||
unsigned int LastSpace = 0; // we need at least 1 space character to start a new line...
|
unsigned int LastSpace = 0; // we need at least 1 space character to start a new line...
|
||||||
m_Lines[0].Text = "";
|
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;
|
unsigned int j;
|
||||||
TempLineWidth = 0;
|
TempLineWidth = 0;
|
||||||
LastSpace = 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;
|
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]);
|
||||||
|
@ -301,8 +272,7 @@ void BS_Text::UpdateFormat()
|
||||||
|
|
||||||
CurLineWidth = 0;
|
CurLineWidth = 0;
|
||||||
CurLineHeight = 0;
|
CurLineHeight = 0;
|
||||||
for (j = i; j < LastSpace; ++j)
|
for (j = i; j < LastSpace; ++j) {
|
||||||
{
|
|
||||||
m_Lines[CurLine].Text += m_Text[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]);
|
||||||
|
@ -315,8 +285,7 @@ void BS_Text::UpdateFormat()
|
||||||
m_Lines[CurLine].BBox.bottom = CurLineHeight;
|
m_Lines[CurLine].BBox.bottom = CurLineHeight;
|
||||||
if ((unsigned int) m_Width < CurLineWidth) m_Width = CurLineWidth;
|
if ((unsigned int) m_Width < CurLineWidth) m_Width = CurLineWidth;
|
||||||
|
|
||||||
if(LastSpace < m_Text.size())
|
if (LastSpace < m_Text.size()) {
|
||||||
{
|
|
||||||
++CurLine;
|
++CurLine;
|
||||||
BS_ASSERT(CurLine == m_Lines.size());
|
BS_ASSERT(CurLine == m_Lines.size());
|
||||||
m_Lines.resize(CurLine + 1);
|
m_Lines.resize(CurLine + 1);
|
||||||
|
@ -329,8 +298,7 @@ void BS_Text::UpdateFormat()
|
||||||
// Bounding-Box der einzelnen Zeilen relativ zur ersten festlegen (vor allem zentrieren).
|
// Bounding-Box der einzelnen Zeilen relativ zur ersten festlegen (vor allem zentrieren).
|
||||||
m_Height = 0;
|
m_Height = 0;
|
||||||
Common::Array<LINE>::iterator Iter = m_Lines.begin();
|
Common::Array<LINE>::iterator Iter = m_Lines.begin();
|
||||||
for (; Iter != m_Lines.end(); ++Iter)
|
for (; Iter != m_Lines.end(); ++Iter) {
|
||||||
{
|
|
||||||
BS_Rect &BBox = (*Iter).BBox;
|
BS_Rect &BBox = (*Iter).BBox;
|
||||||
BBox.left = (m_Width - BBox.right) / 2;
|
BBox.left = (m_Width - BBox.right) / 2;
|
||||||
BBox.right = BBox.left + BBox.right;
|
BBox.right = BBox.left + BBox.right;
|
||||||
|
@ -338,9 +306,7 @@ void BS_Text::UpdateFormat()
|
||||||
BBox.bottom = BBox.top + BBox.bottom;
|
BBox.bottom = BBox.top + BBox.bottom;
|
||||||
m_Height += BBox.GetHeight();
|
m_Height += BBox.GetHeight();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Keine automatische Formatierung, also wird der gesamte Text in nur eine Zeile kopiert.
|
// Keine automatische Formatierung, also wird der gesamte Text in nur eine Zeile kopiert.
|
||||||
m_Lines[0].Text = m_Text;
|
m_Lines[0].Text = m_Text;
|
||||||
m_Lines[0].BBox = BS_Rect(0, 0, m_Width, m_Height);
|
m_Lines[0].BBox = BS_Rect(0, 0, m_Width, m_Height);
|
||||||
|
@ -351,13 +317,11 @@ void BS_Text::UpdateFormat()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_Text::UpdateMetrics(BS_FontResource & FontResource)
|
void BS_Text::UpdateMetrics(BS_FontResource &FontResource) {
|
||||||
{
|
|
||||||
m_Width = 0;
|
m_Width = 0;
|
||||||
m_Height = 0;
|
m_Height = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_Text.size(); ++i)
|
for (unsigned int i = 0; i < m_Text.size(); ++i) {
|
||||||
{
|
|
||||||
const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i));
|
const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i));
|
||||||
m_Width += CurRect.GetWidth();
|
m_Width += CurRect.GetWidth();
|
||||||
if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth();
|
if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth();
|
||||||
|
@ -369,8 +333,7 @@ void BS_Text::UpdateMetrics(BS_FontResource & FontResource)
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_Text::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_Text::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Persist(Writer);
|
Result &= BS_RenderObject::Persist(Writer);
|
||||||
|
@ -386,8 +349,7 @@ bool BS_Text::Persist(BS_OutputPersistenceBlock & Writer)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BS_Text::Unpersist(BS_InputPersistenceBlock & Reader)
|
bool BS_Text::Unpersist(BS_InputPersistenceBlock &Reader) {
|
||||||
{
|
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
|
||||||
Result &= BS_RenderObject::Unpersist(Reader);
|
Result &= BS_RenderObject::Unpersist(Reader);
|
||||||
|
|
|
@ -61,8 +61,7 @@ class BS_ResourceManager;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_Text : public BS_RenderObject
|
class BS_Text : public BS_RenderObject {
|
||||||
{
|
|
||||||
friend class BS_RenderObject;
|
friend class BS_RenderObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -105,12 +104,16 @@ public:
|
||||||
/**
|
/**
|
||||||
@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.
|
@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.
|
@brief Setzt die Farbe des Textes.
|
||||||
|
@ -122,23 +125,31 @@ public:
|
||||||
@brief Gibt den Alphawert des Textes zurück.
|
@brief Gibt den Alphawert des Textes zurück.
|
||||||
@return Der Alphawert des Textes (0 = keine Deckung, 255 = volle Deckung).
|
@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.
|
@brief Gibt die Farbe des Textes zurück.
|
||||||
@return Eine 24-Bit RGB Farbe, die die Farbe des Textes angibt.
|
@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 Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
@ -156,8 +167,7 @@ private:
|
||||||
bool m_AutoWrap;
|
bool m_AutoWrap;
|
||||||
unsigned int m_AutoWrapThreshold;
|
unsigned int m_AutoWrapThreshold;
|
||||||
|
|
||||||
struct LINE
|
struct LINE {
|
||||||
{
|
|
||||||
BS_Rect BBox;
|
BS_Rect BBox;
|
||||||
Common::String Text;
|
Common::String Text;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,14 +43,12 @@ namespace Sword25 {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_TimedRenderObject::BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle) :
|
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());
|
BS_ASSERT(GetManager());
|
||||||
GetManager()->AttatchTimedRenderObject(this);
|
GetManager()->AttatchTimedRenderObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BS_TimedRenderObject::~BS_TimedRenderObject()
|
BS_TimedRenderObject::~BS_TimedRenderObject() {
|
||||||
{
|
|
||||||
BS_ASSERT(GetManager());
|
BS_ASSERT(GetManager());
|
||||||
GetManager()->DetatchTimedRenderObject(this);
|
GetManager()->DetatchTimedRenderObject(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,7 @@ namespace Sword25 {
|
||||||
@brief
|
@brief
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BS_TimedRenderObject : public BS_RenderObject
|
class BS_TimedRenderObject : public BS_RenderObject {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle = 0);
|
BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle = 0);
|
||||||
~BS_TimedRenderObject();
|
~BS_TimedRenderObject();
|
||||||
|
|
|
@ -79,7 +79,9 @@ namespace {
|
||||||
|
|
||||||
class CommandCallbackClass : public BS_LuaCallback {
|
class CommandCallbackClass : public BS_LuaCallback {
|
||||||
public:
|
public:
|
||||||
CommandCallbackClass(lua_State *L) : BS_LuaCallback(L) { Command = BS_InputEngine::KEY_COMMAND_BACKSPACE; }
|
CommandCallbackClass(lua_State *L) : BS_LuaCallback(L) {
|
||||||
|
Command = BS_InputEngine::KEY_COMMAND_BACKSPACE;
|
||||||
|
}
|
||||||
|
|
||||||
BS_InputEngine::KEY_COMMANDS Command;
|
BS_InputEngine::KEY_COMMANDS Command;
|
||||||
|
|
||||||
|
|
|
@ -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_LBUTTONDOWN:
|
||||||
case Common::EVENT_LBUTTONUP:
|
case Common::EVENT_LBUTTONUP:
|
||||||
m_LeftMouseDown = event.type == Common::EVENT_LBUTTONDOWN;
|
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;
|
handleEvents = false;
|
||||||
break;
|
break;
|
||||||
case Common::EVENT_RBUTTONDOWN:
|
case Common::EVENT_RBUTTONDOWN:
|
||||||
case Common::EVENT_RBUTTONUP:
|
case Common::EVENT_RBUTTONUP:
|
||||||
m_RightMouseDown = event.type == Common::EVENT_RBUTTONDOWN;
|
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;
|
handleEvents = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Common::EVENT_MOUSEMOVE:
|
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;
|
break;
|
||||||
|
|
||||||
case Common::EVENT_KEYDOWN:
|
case Common::EVENT_KEYDOWN:
|
||||||
|
|
|
@ -70,7 +70,9 @@ private:
|
||||||
NameToPtrMap m_NameToPtrMap;
|
NameToPtrMap m_NameToPtrMap;
|
||||||
|
|
||||||
struct CallbackPtr_EqualTo {
|
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 {
|
struct CallbackPtr_Hash {
|
||||||
uint operator()(CallbackPtr x) const {
|
uint operator()(CallbackPtr x) const {
|
||||||
|
|
|
@ -68,8 +68,12 @@ public:
|
||||||
void Read(Common::String &Value);
|
void Read(Common::String &Value);
|
||||||
void Read(Common::Array<unsigned char> &Value);
|
void Read(Common::Array<unsigned char> &Value);
|
||||||
|
|
||||||
bool IsGood() const { return m_ErrorState == NONE; }
|
bool IsGood() const {
|
||||||
ErrorState GetErrorState() const { return m_ErrorState; }
|
return m_ErrorState == NONE;
|
||||||
|
}
|
||||||
|
ErrorState GetErrorState() const {
|
||||||
|
return m_ErrorState;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool CheckMarker(unsigned char Marker);
|
bool CheckMarker(unsigned char Marker);
|
||||||
|
|
|
@ -133,8 +133,7 @@ BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Ide
|
||||||
_pKernel(pKernel),
|
_pKernel(pKernel),
|
||||||
_Identifier(Identifier),
|
_Identifier(Identifier),
|
||||||
_ServiceCount(0),
|
_ServiceCount(0),
|
||||||
_ActiveService(NULL)
|
_ActiveService(NULL) {
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
|
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
|
||||||
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
|
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
|
||||||
_ServiceCount++;
|
_ServiceCount++;
|
||||||
|
@ -180,20 +179,16 @@ Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number)
|
||||||
BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
|
BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
|
||||||
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
|
for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++)
|
||||||
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
|
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
|
||||||
BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier)
|
BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) {
|
||||||
{
|
|
||||||
BS_Service *NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel);
|
BS_Service *NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel);
|
||||||
|
|
||||||
if (NewService)
|
if (NewService) {
|
||||||
{
|
|
||||||
DisconnectService();
|
DisconnectService();
|
||||||
BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
|
BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
|
||||||
_ActiveService = NewService;
|
_ActiveService = NewService;
|
||||||
_ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier;
|
_ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier;
|
||||||
return _ActiveService;
|
return _ActiveService;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
|
BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -386,12 +381,9 @@ size_t BS_Kernel::GetUsedMemory() {
|
||||||
#ifdef SCUMMVM_DISABLED_CODE
|
#ifdef SCUMMVM_DISABLED_CODE
|
||||||
PROCESS_MEMORY_COUNTERS pmc;
|
PROCESS_MEMORY_COUNTERS pmc;
|
||||||
pmc.cb = sizeof(pmc);
|
pmc.cb = sizeof(pmc);
|
||||||
if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
|
if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
|
||||||
{
|
|
||||||
return pmc.WorkingSetSize;
|
return pmc.WorkingSetSize;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
|
BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the window object
|
* Returns a pointer to the window object
|
||||||
*/
|
*/
|
||||||
BS_Window *GetWindow() { return _pWindow; }
|
BS_Window *GetWindow() {
|
||||||
|
return _pWindow;
|
||||||
|
}
|
||||||
|
|
||||||
// Service Methods
|
// Service Methods
|
||||||
// ---------------
|
// ---------------
|
||||||
|
@ -166,11 +168,15 @@ public:
|
||||||
/**
|
/**
|
||||||
* Specifies whether the kernel was successfully initialised
|
* Specifies whether the kernel was successfully initialised
|
||||||
*/
|
*/
|
||||||
bool GetInitSuccess() { return _InitSuccess; }
|
bool GetInitSuccess() {
|
||||||
|
return _InitSuccess;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the BS_ResourceManager
|
* Returns a pointer to the BS_ResourceManager
|
||||||
*/
|
*/
|
||||||
BS_ResourceManager *GetResourceManager() { return _pResourceManager; }
|
BS_ResourceManager *GetResourceManager() {
|
||||||
|
return _pResourceManager;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns how much memory is being used
|
* Returns how much memory is being used
|
||||||
*/
|
*/
|
||||||
|
@ -267,10 +273,18 @@ private:
|
||||||
Superclass(BS_Kernel *pKernel, const Common::String &Identifier);
|
Superclass(BS_Kernel *pKernel, const Common::String &Identifier);
|
||||||
~Superclass();
|
~Superclass();
|
||||||
|
|
||||||
unsigned int GetServiceCount() const { return _ServiceCount; }
|
unsigned int GetServiceCount() const {
|
||||||
Common::String GetIdentifier() const { return _Identifier; }
|
return _ServiceCount;
|
||||||
BS_Service *GetActiveService() const { return _ActiveService; }
|
}
|
||||||
Common::String GetActiveServiceName() const { return _ActiveServiceName; }
|
Common::String GetIdentifier() const {
|
||||||
|
return _Identifier;
|
||||||
|
}
|
||||||
|
BS_Service *GetActiveService() const {
|
||||||
|
return _ActiveService;
|
||||||
|
}
|
||||||
|
Common::String GetActiveServiceName() const {
|
||||||
|
return _ActiveServiceName;
|
||||||
|
}
|
||||||
Common::String GetServiceIdentifier(unsigned int Number);
|
Common::String GetServiceIdentifier(unsigned int Number);
|
||||||
BS_Service *NewService(const Common::String &ServiceIdentifier);
|
BS_Service *NewService(const Common::String &ServiceIdentifier);
|
||||||
bool DisconnectService();
|
bool DisconnectService();
|
||||||
|
|
|
@ -56,21 +56,30 @@ namespace Sword25 {
|
||||||
#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_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
|
// Die Version der Logging-Klasse mit aktiviertem Logging
|
||||||
class BS_Log
|
class BS_Log {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static void Clear();
|
static void Clear();
|
||||||
static void Log(const char *Format, ...);
|
static void Log(const char *Format, ...);
|
||||||
static void LogPrefix(const char *Prefix, const char *Format, ...);
|
static void LogPrefix(const char *Prefix, const char *Format, ...);
|
||||||
static void LogDecorated(const char *Format, ...);
|
static void LogDecorated(const char *Format, ...);
|
||||||
|
|
||||||
static void SetPrefix(const char* Prefix) { _Prefix = Prefix; }
|
static void SetPrefix(const char *Prefix) {
|
||||||
static void SetFile(const char* File) { _File = File; }
|
_Prefix = Prefix;
|
||||||
static void SetLine(int Line) { _Line = Line; }
|
}
|
||||||
static void SetAutoNewline(bool AutoNewline) { _AutoNewline = AutoNewline; }
|
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 *);
|
typedef void (*LOG_LISTENER_CALLBACK)(const char *);
|
||||||
static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) { _LogListener.push_back(Callback); }
|
static void RegisterLogListener(LOG_LISTENER_CALLBACK Callback) {
|
||||||
|
_LogListener.push_back(Callback);
|
||||||
|
}
|
||||||
static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) {
|
static bool IsListenerRegistered(LOG_LISTENER_CALLBACK Callback) {
|
||||||
Common::Array<LOG_LISTENER_CALLBACK>::iterator i;
|
Common::Array<LOG_LISTENER_CALLBACK>::iterator i;
|
||||||
for (i = _LogListener.begin(); i != _LogListener.end(); ++i) {
|
for (i = _LogListener.begin(); i != _LogListener.end(); ++i) {
|
||||||
|
|
|
@ -53,8 +53,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
unsigned int address;
|
unsigned int address;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
std::string file;
|
std::string file;
|
||||||
|
@ -68,33 +67,27 @@ std::vector< std::vector<ALLOC_INFO> > TrackData(BUCKET_COUNT);
|
||||||
static unsigned int TotalSize = 0;
|
static unsigned int TotalSize = 0;
|
||||||
|
|
||||||
// Diese Klasse stellt sicher, dass beim Programmende, das Memory-Leak Log geschrieben wird.
|
// Diese Klasse stellt sicher, dass beim Programmende, das Memory-Leak Log geschrieben wird.
|
||||||
static class LeakDumper
|
static class LeakDumper {
|
||||||
{
|
|
||||||
public:
|
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.
|
// Sicherstellen, dass das Ausgabeverzeichnis für die Datei existiert.
|
||||||
BS_FileSystemUtil::GetInstance().CreateDirectory(BS_FileSystemUtil::GetInstance().GetUserdataDirectory());
|
BS_FileSystemUtil::GetInstance().CreateDirectory(BS_FileSystemUtil::GetInstance().GetUserdataDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
~LeakDumper()
|
~LeakDumper() {
|
||||||
{
|
|
||||||
DumpUnfreed(OutputFilename.c_str());
|
DumpUnfreed(OutputFilename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OutputFilename;
|
std::string OutputFilename;
|
||||||
} LeakDumperInstance;
|
} LeakDumperInstance;
|
||||||
|
|
||||||
void DumpUnfreed(const char * OutputFilename)
|
void DumpUnfreed(const char *OutputFilename) {
|
||||||
{
|
|
||||||
FILE *Log = fopen(OutputFilename, "w");
|
FILE *Log = fopen(OutputFilename, "w");
|
||||||
fputs("MEMORY LEAK REPORT:\n----------------------\n", Log);
|
fputs("MEMORY LEAK REPORT:\n----------------------\n", Log);
|
||||||
std::vector< std::vector<ALLOC_INFO> >::iterator BucketIter = TrackData.begin();
|
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();
|
std::vector<ALLOC_INFO>::iterator Iter = (*BucketIter).begin();
|
||||||
for (; Iter != (*BucketIter).end(); ++Iter)
|
for (; Iter != (*BucketIter).end(); ++Iter) {
|
||||||
{
|
|
||||||
ALLOC_INFO &CurItem = (*Iter);
|
ALLOC_INFO &CurItem = (*Iter);
|
||||||
fprintf(Log, "%-50s LINE:%d ADDRESS:0x%x SIZE:%d\n",
|
fprintf(Log, "%-50s LINE:%d ADDRESS:0x%x SIZE:%d\n",
|
||||||
CurItem.file.c_str(),
|
CurItem.file.c_str(),
|
||||||
|
@ -109,8 +102,7 @@ void DumpUnfreed(const char * OutputFilename)
|
||||||
fclose(Log);
|
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];
|
std::vector<ALLOC_INFO> & CurBucket = TrackData[(addr >> 3) % BUCKET_COUNT];
|
||||||
ALLOC_INFO Info;
|
ALLOC_INFO Info;
|
||||||
Info.address = addr;
|
Info.address = addr;
|
||||||
|
@ -122,16 +114,12 @@ void AddTrack(unsigned int addr, unsigned int asize, const char *fname, unsign
|
||||||
TotalSize += asize;
|
TotalSize += asize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTrack(unsigned int addr)
|
void RemoveTrack(unsigned int addr) {
|
||||||
{
|
if (addr != 0 && TrackData.size() == BUCKET_COUNT) {
|
||||||
if (addr != 0 && TrackData.size() == BUCKET_COUNT)
|
|
||||||
{
|
|
||||||
std::vector<ALLOC_INFO> & CurBucket = TrackData[(addr >> 3) % BUCKET_COUNT];
|
std::vector<ALLOC_INFO> & CurBucket = TrackData[(addr >> 3) % BUCKET_COUNT];
|
||||||
std::vector<ALLOC_INFO>::iterator Iter = CurBucket.begin();
|
std::vector<ALLOC_INFO>::iterator Iter = CurBucket.begin();
|
||||||
for (; Iter != CurBucket.end(); ++Iter)
|
for (; Iter != CurBucket.end(); ++Iter) {
|
||||||
{
|
if ((*Iter).address == addr) {
|
||||||
if ((*Iter).address == addr)
|
|
||||||
{
|
|
||||||
TotalSize -= (*Iter).size;
|
TotalSize -= (*Iter).size;
|
||||||
|
|
||||||
std::swap(*Iter, CurBucket.back());
|
std::swap(*Iter, CurBucket.back());
|
||||||
|
|
|
@ -47,21 +47,18 @@ void DumpUnfreed(const char * OutputFilename);
|
||||||
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);
|
||||||
void RemoveTrack(unsigned int addr);
|
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);
|
void *ptr = malloc(size);
|
||||||
if (ptr) AddTrack((unsigned int)ptr, size, file, line);
|
if (ptr) AddTrack((unsigned int)ptr, size, file, line);
|
||||||
return(ptr);
|
return(ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void __cdecl operator delete(void *p)
|
inline void __cdecl operator delete(void *p) {
|
||||||
{
|
|
||||||
RemoveTrack((unsigned int)p);
|
RemoveTrack((unsigned int)p);
|
||||||
free(p);
|
free(p);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void __cdecl operator delete[](void *p)
|
inline void __cdecl operator delete[](void *p) {
|
||||||
{
|
|
||||||
RemoveTrack((unsigned int)p);
|
RemoveTrack((unsigned int)p);
|
||||||
free(p);
|
free(p);
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,7 +150,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// FIXME: I'm not entirely sure my current hash function is legitimate
|
// FIXME: I'm not entirely sure my current hash function is legitimate
|
||||||
struct ClassPointer_EqualTo {
|
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 {
|
struct ClassPointer_Hash {
|
||||||
uint operator()(const T *x) const {
|
uint operator()(const T *x) const {
|
||||||
|
|
|
@ -59,8 +59,12 @@ public:
|
||||||
void Write(const Common::String &String);
|
void Write(const Common::String &String);
|
||||||
void Write(const void *BufferPtr, size_t Size);
|
void Write(const void *BufferPtr, size_t Size);
|
||||||
|
|
||||||
const void *GetData() const { return &m_Data[0]; }
|
const void *GetData() const {
|
||||||
unsigned int GetDataSize() const { return m_Data.size(); }
|
return &m_Data[0];
|
||||||
|
}
|
||||||
|
unsigned int GetDataSize() const {
|
||||||
|
return m_Data.size();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void WriteMarker(unsigned char Marker);
|
void WriteMarker(unsigned char Marker);
|
||||||
|
|
|
@ -49,10 +49,18 @@ namespace Sword25 {
|
||||||
|
|
||||||
class BS_PersistenceBlock {
|
class BS_PersistenceBlock {
|
||||||
public:
|
public:
|
||||||
static unsigned int GetSInt32Size() { return sizeof(signed int) + sizeof(unsigned char); }
|
static unsigned int GetSInt32Size() {
|
||||||
static unsigned int GetUInt32Size() { return sizeof(unsigned int) + sizeof(unsigned char); }
|
return sizeof(signed 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 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) {
|
static unsigned int GetStringSize(const Common::String &String) {
|
||||||
return static_cast<unsigned int>(sizeof(unsigned int) + String.size() + sizeof(unsigned char));
|
return static_cast<unsigned int>(sizeof(unsigned int) + String.size() + sizeof(unsigned char));
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,9 @@ struct SavegameInformation {
|
||||||
unsigned int GamedataOffset;
|
unsigned int GamedataOffset;
|
||||||
unsigned int GamedataUncompressedLength;
|
unsigned int GamedataUncompressedLength;
|
||||||
|
|
||||||
SavegameInformation() { Clear(); }
|
SavegameInformation() {
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
IsOccupied = false;
|
IsOccupied = false;
|
||||||
|
@ -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,
|
// 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.
|
// da sich die Versions-ID bei jeder Codeänderung mitändert.
|
||||||
#ifndef DEBUG
|
#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);
|
BS_LOG_ERRORLN("Tried to load a savegame (%d) that is not compatible with this engine version.", SlotID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,9 @@ BS_ResourceManager::~BS_ResourceManager() {
|
||||||
BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*Iter)->GetFileName().c_str());
|
BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*Iter)->GetFileName().c_str());
|
||||||
|
|
||||||
// Set the lock count to zero
|
// Set the lock count to zero
|
||||||
while ((*Iter)->GetLockCount() > 0) { (*Iter)->Release(); };
|
while ((*Iter)->GetLockCount() > 0) {
|
||||||
|
(*Iter)->Release();
|
||||||
|
};
|
||||||
|
|
||||||
// Delete the resource
|
// Delete the resource
|
||||||
delete(*Iter);
|
delete(*Iter);
|
||||||
|
@ -298,8 +300,7 @@ BS_Resource * BS_ResourceManager::GetResource(const Common::String &UniqueFileNa
|
||||||
BS_String::GetHash(UniqueFileName) % HASH_TABLE_BUCKETS];
|
BS_String::GetHash(UniqueFileName) % HASH_TABLE_BUCKETS];
|
||||||
{
|
{
|
||||||
Common::List<BS_Resource *>::const_iterator Iter = HashBucket.begin();
|
Common::List<BS_Resource *>::const_iterator Iter = HashBucket.begin();
|
||||||
for (; Iter != HashBucket.end(); ++Iter)
|
for (; Iter != HashBucket.end(); ++Iter) {
|
||||||
{
|
|
||||||
// Wenn die Resource gefunden wurde wird sie zurückgegeben.
|
// Wenn die Resource gefunden wurde wird sie zurückgegeben.
|
||||||
if ((*Iter)->GetFileName() == UniqueFileName)
|
if ((*Iter)->GetFileName() == UniqueFileName)
|
||||||
return *Iter;
|
return *Iter;
|
||||||
|
|
|
@ -68,7 +68,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the number of loaded resources
|
* 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
|
* Returns a resource by it's ordinal index. Returns NULL if any error occurs
|
||||||
|
@ -92,7 +94,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the maximum memory the kernel has used
|
* 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.
|
* 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.
|
* Specifies whether a warning is written to the log when a cache miss occurs.
|
||||||
* THe default value is "false".
|
* 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.
|
* 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
|
* Writes the names of all currently locked resources to the log file
|
||||||
|
@ -131,8 +139,7 @@ private:
|
||||||
{};
|
{};
|
||||||
virtual ~BS_ResourceManager();
|
virtual ~BS_ResourceManager();
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
HASH_TABLE_BUCKETS = 256
|
HASH_TABLE_BUCKETS = 256
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,9 @@ public:
|
||||||
* Prevents the resource from being released.
|
* 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
|
* Cancels a previous lock
|
||||||
|
@ -75,22 +77,30 @@ public:
|
||||||
* Returns the current lock count for the resource
|
* 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
|
* 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
|
* 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
|
* Returns a resource's type
|
||||||
*/
|
*/
|
||||||
unsigned int GetType() const { return _Type; }
|
unsigned int GetType() const {
|
||||||
|
return _Type;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~BS_Resource() {};
|
virtual ~BS_Resource() {};
|
||||||
|
|
|
@ -47,8 +47,7 @@ class BS_Resource;
|
||||||
|
|
||||||
class BS_ResourceService : public BS_Service {
|
class BS_ResourceService : public BS_Service {
|
||||||
public:
|
public:
|
||||||
BS_ResourceService(BS_Kernel* pKernel) : BS_Service(pKernel)
|
BS_ResourceService(BS_Kernel *pKernel) : BS_Service(pKernel) {
|
||||||
{
|
|
||||||
BS_ResourceManager *pResource = pKernel->GetResourceManager();
|
BS_ResourceManager *pResource = pKernel->GetResourceManager();
|
||||||
pResource->RegisterResourceService(this);
|
pResource->RegisterResourceService(this);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +88,9 @@ private:
|
||||||
if (*Pattern == '*') {
|
if (*Pattern == '*') {
|
||||||
// Use a copy of the pattern pointer so as not to destroy the current state
|
// Use a copy of the pattern pointer so as not to destroy the current state
|
||||||
const char *PatternCopy = Pattern;
|
const char *PatternCopy = Pattern;
|
||||||
while (*PatternCopy == '*') { PatternCopy++; }
|
while (*PatternCopy == '*') {
|
||||||
|
PatternCopy++;
|
||||||
|
}
|
||||||
if (!*PatternCopy) return true;
|
if (!*PatternCopy) return true;
|
||||||
}
|
}
|
||||||
// 2. The string is over, but the patern is not -> FALSE
|
// 2. The string is over, but the patern is not -> FALSE
|
||||||
|
|
|
@ -62,7 +62,9 @@ private:
|
||||||
protected:
|
protected:
|
||||||
BS_Service(BS_Kernel *pKernel) : _pKernel(pKernel) {};
|
BS_Service(BS_Kernel *pKernel) : _pKernel(pKernel) {};
|
||||||
|
|
||||||
BS_Kernel* GetKernel() const { return _pKernel; }
|
BS_Kernel *GetKernel() const {
|
||||||
|
return _pKernel;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~BS_Service() {};
|
virtual ~BS_Service() {};
|
||||||
|
|
|
@ -52,7 +52,9 @@ inline bool ToInt(const Common::String &Str, int &Result) {
|
||||||
Common::String::const_iterator Iter = Str.begin();
|
Common::String::const_iterator Iter = Str.begin();
|
||||||
|
|
||||||
// Skip whitespaces
|
// Skip whitespaces
|
||||||
while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
|
while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
|
||||||
|
++Iter;
|
||||||
|
}
|
||||||
if (Iter == Str.end()) return false;
|
if (Iter == Str.end()) return false;
|
||||||
|
|
||||||
// Read sign, if available
|
// Read sign, if available
|
||||||
|
@ -60,19 +62,22 @@ inline bool ToInt(const Common::String &Str, int &Result) {
|
||||||
if (*Iter == '-') {
|
if (*Iter == '-') {
|
||||||
IsNegative = true;
|
IsNegative = true;
|
||||||
++Iter;
|
++Iter;
|
||||||
}
|
} else if (*Iter == '+')
|
||||||
else if (*Iter == '+')
|
|
||||||
++Iter;
|
++Iter;
|
||||||
|
|
||||||
// Skip whitespaces
|
// Skip whitespaces
|
||||||
while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
|
while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
|
||||||
|
++Iter;
|
||||||
|
}
|
||||||
if (Iter == Str.end()) return false;
|
if (Iter == Str.end()) return false;
|
||||||
|
|
||||||
// Convert string to integer
|
// Convert string to integer
|
||||||
Result = 0;
|
Result = 0;
|
||||||
while (Iter != Str.end()) {
|
while (Iter != Str.end()) {
|
||||||
if (*Iter < '0' || *Iter > '9') {
|
if (*Iter < '0' || *Iter > '9') {
|
||||||
while (*Iter && (*Iter == ' ' || *Iter == '\t')) { ++Iter; }
|
while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
|
||||||
|
++Iter;
|
||||||
|
}
|
||||||
if (Iter != Str.end()) return false;
|
if (Iter != Str.end()) return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,8 @@ static void *my_checkudata(lua_State *L, int ud, const char *tname) {
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
void *p = lua_touserdata(L, ud);
|
void *p = lua_touserdata(L, ud);
|
||||||
if (p != NULL) /* value is a userdata? */
|
if (p != NULL) { /* value is a userdata? */
|
||||||
{
|
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
||||||
if (lua_getmetatable(L, ud)) /* does it have a metatable? */
|
|
||||||
{
|
|
||||||
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
||||||
BS_LuaBindhelper::GetMetatable(L, tname);
|
BS_LuaBindhelper::GetMetatable(L, tname);
|
||||||
/* does it have the correct mt? */
|
/* does it have the correct mt? */
|
||||||
|
@ -157,8 +155,7 @@ static void TablePolygonToPolygon(lua_State *L, BS_Polygon &Polygon) {
|
||||||
Vertecies.reserve(VertexCount);
|
Vertecies.reserve(VertexCount);
|
||||||
|
|
||||||
// Create Vertecies
|
// Create Vertecies
|
||||||
for (int i = 0; i < VertexCount; i++)
|
for (int i = 0; i < VertexCount; i++) {
|
||||||
{
|
|
||||||
// X Value
|
// X Value
|
||||||
lua_rawgeti(L, -1, (i * 2) + 1);
|
lua_rawgeti(L, -1, (i * 2) + 1);
|
||||||
int X = static_cast<int>(lua_tonumber(L, -1));
|
int X = static_cast<int>(lua_tonumber(L, -1));
|
||||||
|
@ -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
|
// Region due to the Lua code to create
|
||||||
// Any errors that occur will be intercepted to the luaL_error
|
// Any errors that occur will be intercepted to the luaL_error
|
||||||
unsigned int RegionHandle = TableRegionToRegion(L, ClassName);
|
unsigned int RegionHandle = TableRegionToRegion(L, ClassName);
|
||||||
|
|
|
@ -54,9 +54,13 @@ public:
|
||||||
BS_Rect(int16 w, int16 h) : Common::Rect(w, h) {}
|
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) {}
|
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 {
|
bool Intersect(const BS_Rect &Rect_, BS_Rect &Result) const {
|
||||||
Result = Rect_;
|
Result = Rect_;
|
||||||
|
@ -70,23 +74,41 @@ public:
|
||||||
Result.extend(*this);
|
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
|
} // End of namespace Sword25
|
||||||
|
|
|
@ -94,22 +94,30 @@ public:
|
||||||
* @return Returns true if the object is in a valid state, otherwise false.
|
* @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.
|
* @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
|
* 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
|
* 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
|
* 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
|
* Indicates whether a point is inside the region
|
||||||
|
@ -129,12 +137,16 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the countour of the region
|
* 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
|
* 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
|
* Returns a specific hole polygon in the region
|
||||||
|
|
|
@ -63,7 +63,10 @@ namespace Sword25 {
|
||||||
class BS_Vertex {
|
class BS_Vertex {
|
||||||
public:
|
public:
|
||||||
BS_Vertex() : X(0), Y(0) {};
|
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 X;
|
||||||
int Y;
|
int Y;
|
||||||
|
@ -71,30 +74,46 @@ public:
|
||||||
/**
|
/**
|
||||||
* Compares two Vertecies.
|
* 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.
|
* 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
|
* 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
|
* 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
|
* 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
|
* 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.
|
* Calculates the square of the distance between two Vertecies.
|
||||||
|
@ -132,8 +151,7 @@ public:
|
||||||
* @param Vertex The second vertex
|
* @param Vertex The second vertex
|
||||||
* @return Returns the dot product of this vertex and the passed 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;
|
return X * Vertex.X + Y * Vertex.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,7 @@ bool BS_WalkRegion::QueryPath(BS_Vertex StartPoint, BS_Vertex EndPoint, BS_Path
|
||||||
if (!CheckAndPrepareStartAndEnd(StartPoint, EndPoint)) return false;
|
if (!CheckAndPrepareStartAndEnd(StartPoint, EndPoint)) return false;
|
||||||
|
|
||||||
// If between the start and point a line of sight exists, then it can be returned.
|
// 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(StartPoint);
|
||||||
Path.push_back(EndPoint);
|
Path.push_back(EndPoint);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -96,8 +96,12 @@ public:
|
||||||
|
|
||||||
virtual void SetPos(int X, int Y);
|
virtual void SetPos(int X, int Y);
|
||||||
|
|
||||||
const Common::Array<BS_Vertex> &GetNodes() const { return m_Nodes; }
|
const Common::Array<BS_Vertex> &GetNodes() const {
|
||||||
const Common::Array< Common::Array<int> > &GetVisibilityMatrix() const { return m_VisibilityMatrix; }
|
return m_Nodes;
|
||||||
|
}
|
||||||
|
const Common::Array< Common::Array<int> > &GetVisibilityMatrix() const {
|
||||||
|
return m_VisibilityMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
virtual bool Persist(BS_OutputPersistenceBlock &Writer);
|
||||||
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
virtual bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
|
|
@ -54,8 +54,12 @@ public:
|
||||||
PathElement() { }
|
PathElement() { }
|
||||||
PathElement(Common::String::const_iterator Begin, Common::String::const_iterator End) : m_Begin(Begin), m_End(End) {}
|
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 GetBegin() const {
|
||||||
Common::String::const_iterator GetEnd() const { return m_End; }
|
return m_Begin;
|
||||||
|
}
|
||||||
|
Common::String::const_iterator GetEnd() const {
|
||||||
|
return m_End;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::String::const_iterator m_Begin;
|
Common::String::const_iterator m_Begin;
|
||||||
|
|
|
@ -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
|
// 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 the value is a function, execute it
|
||||||
if (lua_type(L, -1) == LUA_TFUNCTION)
|
if (lua_type(L, -1) == LUA_TFUNCTION) {
|
||||||
{
|
|
||||||
// Pre-Function Call
|
// Pre-Function Call
|
||||||
// Derived classes can function in this parameter onto the stack.
|
// Derived classes can function in this parameter onto the stack.
|
||||||
// The return value indicates the number of parameters
|
// 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
|
// Pop error message from the stack
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Pop value from the stack. The index is then ready for the next call to lua_next()
|
// Pop value from the stack. The index is then ready for the next call to lua_next()
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,9 @@ public:
|
||||||
void InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHandle);
|
void InvokeCallbackFunctions(lua_State *L, unsigned int ObjectHandle);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int PreFunctionInvokation(lua_State *L) { return 0; }
|
virtual int PreFunctionInvokation(lua_State *L) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnsureObjectCallbackTableExists(lua_State *L, unsigned int ObjectHandle);
|
void EnsureObjectCallbackTableExists(lua_State *L, unsigned int ObjectHandle);
|
||||||
|
|
|
@ -80,7 +80,9 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -345,8 +347,7 @@ namespace {
|
||||||
|
|
||||||
// Make an entry in the table
|
// Make an entry in the table
|
||||||
lua_settable(L, -3);
|
lua_settable(L, -3);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Pop nil value from stack
|
// Pop nil value from stack
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ public:
|
||||||
* Returns a pointer to the main object of the scripting language
|
* 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
|
* Makes the command line parameters for the scripting environment available
|
||||||
|
|
|
@ -51,14 +51,12 @@
|
||||||
|
|
||||||
BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr) :
|
BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr) :
|
||||||
m_ChannelPtr(ChannelPtr),
|
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_ChannelPtr) FMOD_Channel_Stop(m_ChannelPtr);
|
||||||
if (m_SoundPtr) FMOD_Sound_Release(m_SoundPtr);
|
if (m_SoundPtr) FMOD_Sound_Release(m_SoundPtr);
|
||||||
}
|
}
|
||||||
|
@ -73,10 +71,8 @@ BS_FMODExChannel::~BS_FMODExChannel()
|
||||||
// Diese Fehler werden daher von den folgenden Methoden ignoriert.
|
// Diese Fehler werden daher von den folgenden Methoden ignoriert.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
bool IsImportantError(FMOD_RESULT Result) {
|
||||||
bool IsImportantError(FMOD_RESULT Result)
|
|
||||||
{
|
|
||||||
return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
|
return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,113 +81,92 @@ namespace
|
||||||
// Setter
|
// Setter
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::SetPaused(bool Paused)
|
bool BS_FMODExChannel::SetPaused(bool Paused) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetPaused(m_ChannelPtr, Paused ? 1 : 0);
|
FMOD_RESULT Result = FMOD_Channel_SetPaused(m_ChannelPtr, Paused ? 1 : 0);
|
||||||
if (IsImportantError(Result))
|
if (IsImportantError(Result)) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_Channel_SetPaused()", Result).Log();
|
BS_FMODExException("FMOD_Channel_SetPaused()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::SetVolume(float Volume)
|
bool BS_FMODExChannel::SetVolume(float Volume) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetVolume(m_ChannelPtr, Volume);
|
FMOD_RESULT Result = FMOD_Channel_SetVolume(m_ChannelPtr, Volume);
|
||||||
if (IsImportantError(Result))
|
if (IsImportantError(Result)) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_Channel_SetVolume()", Result).Log();
|
BS_FMODExException("FMOD_Channel_SetVolume()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::SetPanning(float Panning)
|
bool BS_FMODExChannel::SetPanning(float Panning) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetPan(m_ChannelPtr, Panning);
|
FMOD_RESULT Result = FMOD_Channel_SetPan(m_ChannelPtr, Panning);
|
||||||
if (IsImportantError(Result))
|
if (IsImportantError(Result)) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_Channel_SetPan()", Result).Log();
|
BS_FMODExException("FMOD_Channel_SetPan()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::SetLoop(bool Loop)
|
bool BS_FMODExChannel::SetLoop(bool Loop) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetLoopCount(m_ChannelPtr, Loop ? -1 : 0);
|
FMOD_RESULT Result = FMOD_Channel_SetLoopCount(m_ChannelPtr, Loop ? -1 : 0);
|
||||||
if (IsImportantError(Result))
|
if (IsImportantError(Result)) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_Channel_SetLoopCount()", Result).Log();
|
BS_FMODExException("FMOD_Channel_SetLoopCount()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
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);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetLoopPoints(m_ChannelPtr, LoopStart, FMOD_TIMEUNIT_PCM, LoopEnd, FMOD_TIMEUNIT_PCM);
|
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();
|
BS_FMODExException("FMOD_Channel_SetLoopPoints()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::SetPosition(unsigned int Position)
|
bool BS_FMODExChannel::SetPosition(unsigned int Position) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_SetPosition(m_ChannelPtr, Position, FMOD_TIMEUNIT_PCM);
|
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();
|
BS_FMODExException("FMOD_Channel_SetPosition()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::Stop()
|
bool BS_FMODExChannel::Stop() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_Channel_Stop(m_ChannelPtr);
|
FMOD_RESULT Result = FMOD_Channel_Stop(m_ChannelPtr);
|
||||||
if (IsImportantError(Result))
|
if (IsImportantError(Result)) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_Channel_Stop()", Result).Log();
|
BS_FMODExException("FMOD_Channel_Stop()", Result).Log();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,8 +174,7 @@ bool BS_FMODExChannel::Stop()
|
||||||
// Getter
|
// Getter
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
float BS_FMODExChannel::GetVolume()
|
float BS_FMODExChannel::GetVolume() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
float Volume = 0;
|
float Volume = 0;
|
||||||
|
@ -212,8 +186,7 @@ float BS_FMODExChannel::GetVolume()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
float BS_FMODExChannel::GetPanning()
|
float BS_FMODExChannel::GetPanning() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
float Panning = 0;
|
float Panning = 0;
|
||||||
|
@ -225,8 +198,7 @@ float BS_FMODExChannel::GetPanning()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned int BS_FMODExChannel::GetPosition()
|
unsigned int BS_FMODExChannel::GetPosition() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
unsigned int Position = 0;
|
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);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
unsigned int Time = 0;
|
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);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
unsigned int LoopStart = 0;
|
unsigned int LoopStart = 0;
|
||||||
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, &LoopStart, FMOD_TIMEUNIT_PCM, 0, FMOD_TIMEUNIT_PCM);
|
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);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
unsigned int LoopEnd = 0;
|
unsigned int LoopEnd = 0;
|
||||||
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, 0, FMOD_TIMEUNIT_PCM, &LoopEnd, FMOD_TIMEUNIT_PCM);
|
FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, 0, FMOD_TIMEUNIT_PCM, &LoopEnd, FMOD_TIMEUNIT_PCM);
|
||||||
|
@ -275,8 +244,7 @@ unsigned int BS_FMODExChannel::GetLoopEnd()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::IsLooping()
|
bool BS_FMODExChannel::IsLooping() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
int LoopCount = 0;
|
int LoopCount = 0;
|
||||||
|
@ -288,8 +256,7 @@ bool BS_FMODExChannel::IsLooping()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::IsPaused()
|
bool BS_FMODExChannel::IsPaused() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_BOOL Paused = 0;
|
FMOD_BOOL Paused = 0;
|
||||||
|
@ -301,8 +268,7 @@ bool BS_FMODExChannel::IsPaused()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExChannel::IsPlaying()
|
bool BS_FMODExChannel::IsPlaying() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_ChannelPtr);
|
BS_ASSERT(m_ChannelPtr);
|
||||||
|
|
||||||
FMOD_BOOL Playing = 0;
|
FMOD_BOOL Playing = 0;
|
||||||
|
|
|
@ -52,8 +52,7 @@ struct FMOD_SOUND;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_FMODExChannel
|
class BS_FMODExChannel {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr);
|
BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr);
|
||||||
virtual ~BS_FMODExChannel();
|
virtual ~BS_FMODExChannel();
|
||||||
|
|
|
@ -45,8 +45,7 @@
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_FMODExException
|
class BS_FMODExException {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BS_FMODExException(const char *Function_, FMOD_RESULT Result_) :
|
BS_FMODExException(const char *Function_, FMOD_RESULT Result_) :
|
||||||
Function(Function_),
|
Function(Function_),
|
||||||
|
@ -55,8 +54,7 @@ public:
|
||||||
const char *Function;
|
const char *Function;
|
||||||
FMOD_RESULT Result;
|
FMOD_RESULT Result;
|
||||||
|
|
||||||
void Log()
|
void Log() {
|
||||||
{
|
|
||||||
BS_LOG_ERROR("Call to %s failed.", Function);
|
BS_LOG_ERROR("Call to %s failed.", Function);
|
||||||
BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
|
BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@
|
||||||
// Konstanten
|
// Konstanten
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
|
const unsigned int MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +64,7 @@ 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_SoundPtr(0),
|
||||||
m_SoundDataPtr(0),
|
m_SoundDataPtr(0),
|
||||||
BS_Resource(FileName, BS_Resource::TYPE_SOUND)
|
BS_Resource(FileName, BS_Resource::TYPE_SOUND) {
|
||||||
{
|
|
||||||
BS_ASSERT(FMOD);
|
BS_ASSERT(FMOD);
|
||||||
|
|
||||||
// Von Misserfolg ausgehen
|
// Von Misserfolg ausgehen
|
||||||
|
@ -74,8 +72,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
|
||||||
|
|
||||||
// Pointer auf den Package-Manager bekommen
|
// Pointer auf den Package-Manager bekommen
|
||||||
BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
|
BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
|
||||||
if (!PackagePtr)
|
if (!PackagePtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Package manager not found.");
|
BS_LOG_ERRORLN("Package manager not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +80,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
|
||||||
// Datei laden
|
// Datei laden
|
||||||
unsigned int FileSize;
|
unsigned int FileSize;
|
||||||
char *FileDataPtr = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
|
char *FileDataPtr = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
|
||||||
if (!FileDataPtr)
|
if (!FileDataPtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", GetFileName().c_str());
|
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", GetFileName().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,8 +89,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
|
||||||
// Samples werden sofort intialisiert.
|
// 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
|
// 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.
|
// gleichzeitig abspielen kann, Streams jedoch nur ein mal.
|
||||||
if (FileSize <= MAX_SAMPLE_SIZE)
|
if (FileSize <= MAX_SAMPLE_SIZE) {
|
||||||
{
|
|
||||||
FMOD_CREATESOUNDEXINFO ExInfo;
|
FMOD_CREATESOUNDEXINFO ExInfo;
|
||||||
memset(&ExInfo, 0, sizeof(ExInfo));
|
memset(&ExInfo, 0, sizeof(ExInfo));
|
||||||
ExInfo.cbsize = sizeof(ExInfo);
|
ExInfo.cbsize = sizeof(ExInfo);
|
||||||
|
@ -109,9 +104,7 @@ BS_FMODExResource::BS_FMODExResource(const std::string& FileName, FMOD_SYSTEM *
|
||||||
Success = Result == FMOD_OK;
|
Success = Result == FMOD_OK;
|
||||||
|
|
||||||
delete FileDataPtr;
|
delete FileDataPtr;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_SoundDataPtr = FileDataPtr;
|
m_SoundDataPtr = FileDataPtr;
|
||||||
m_SoundDataSize = FileSize;
|
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.
|
// Sound freigeben, solange des Soundsystem noch läuft.
|
||||||
// Sollte das Soundsystem beendet worden sein müssen und können Sounds nicht mehr freigegeben werden.
|
// 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);
|
if (m_SoundPtr && BS_Kernel::GetInstance()->GetService("sfx")) FMOD_Sound_Release(m_SoundPtr);
|
||||||
|
@ -133,26 +125,22 @@ BS_FMODExResource::~BS_FMODExResource()
|
||||||
// Abspielen
|
// Abspielen
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
|
BS_FMODExChannel *BS_FMODExResource::StartSound(FMOD_SYSTEM *FMOD) {
|
||||||
{
|
|
||||||
BS_ASSERT(FMOD);
|
BS_ASSERT(FMOD);
|
||||||
|
|
||||||
FMOD_CHANNEL *NewChannelPtr;
|
FMOD_CHANNEL *NewChannelPtr;
|
||||||
FMOD_SOUND *NewSoundPtr = 0;
|
FMOD_SOUND *NewSoundPtr = 0;
|
||||||
|
|
||||||
// Sample können sofort abgespielt werden.
|
// 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);
|
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();
|
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Für Streams muss ein neuer Sound erstellt werden.
|
// Für Streams muss ein neuer Sound erstellt werden.
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
FMOD_CREATESOUNDEXINFO ExInfo;
|
FMOD_CREATESOUNDEXINFO ExInfo;
|
||||||
memset(&ExInfo, 0, sizeof(ExInfo));
|
memset(&ExInfo, 0, sizeof(ExInfo));
|
||||||
ExInfo.cbsize = sizeof(ExInfo);
|
ExInfo.cbsize = sizeof(ExInfo);
|
||||||
|
@ -164,15 +152,13 @@ BS_FMODExChannel * BS_FMODExResource::StartSound(FMOD_SYSTEM * FMOD)
|
||||||
FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
|
FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
|
||||||
&ExInfo,
|
&ExInfo,
|
||||||
&NewSoundPtr);
|
&NewSoundPtr);
|
||||||
if (Result != FMOD_OK)
|
if (Result != FMOD_OK) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
|
BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, NewSoundPtr, 1, &NewChannelPtr);
|
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();
|
BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,7 @@ struct FMOD_SYSTEM;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_FMODExResource : public BS_Resource
|
class BS_FMODExResource : public BS_Resource {
|
||||||
{
|
|
||||||
public:
|
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();
|
virtual ~BS_FMODExResource();
|
||||||
|
|
|
@ -59,8 +59,7 @@
|
||||||
// Konstanten und lokale Funktionen
|
// Konstanten und lokale Funktionen
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
const float DEFAULT_MUSIC_VOLUME = 1.0f;
|
const float DEFAULT_MUSIC_VOLUME = 1.0f;
|
||||||
const float DEFAULT_SPEECH_VOLUME = 1.0f;
|
const float DEFAULT_SPEECH_VOLUME = 1.0f;
|
||||||
const float DEFAULT_SFX_VOLUME = 1.0f;
|
const float DEFAULT_SFX_VOLUME = 1.0f;
|
||||||
|
@ -69,17 +68,14 @@ namespace
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
inline float NormalizePanning(float Panning)
|
inline float NormalizePanning(float Panning) {
|
||||||
{
|
|
||||||
bool Corrected = false;
|
bool Corrected = false;
|
||||||
float Result = Panning;
|
float Result = Panning;
|
||||||
if (Result > 1.0f)
|
if (Result > 1.0f) {
|
||||||
{
|
|
||||||
Result = 1.0f;
|
Result = 1.0f;
|
||||||
Corrected = true;
|
Corrected = true;
|
||||||
}
|
}
|
||||||
if (Result < -1.0f)
|
if (Result < -1.0f) {
|
||||||
{
|
|
||||||
Result = -1.0f;
|
Result = -1.0f;
|
||||||
Corrected = true;
|
Corrected = true;
|
||||||
}
|
}
|
||||||
|
@ -91,17 +87,14 @@ namespace
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
inline float NormalizeVolume(float Volume)
|
inline float NormalizeVolume(float Volume) {
|
||||||
{
|
|
||||||
bool Corrected = false;
|
bool Corrected = false;
|
||||||
float Result = Volume;
|
float Result = Volume;
|
||||||
if (Result> 1.0f)
|
if (Result > 1.0f) {
|
||||||
{
|
|
||||||
Result = 1.0f;
|
Result = 1.0f;
|
||||||
Corrected = true;
|
Corrected = true;
|
||||||
}
|
}
|
||||||
if (Result < 0.0f)
|
if (Result < 0.0f) {
|
||||||
{
|
|
||||||
Result = 0.0f;
|
Result = 0.0f;
|
||||||
Corrected = true;
|
Corrected = true;
|
||||||
}
|
}
|
||||||
|
@ -113,15 +106,18 @@ namespace
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample)
|
inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(unsigned int BitsPerSample) {
|
||||||
{
|
switch (BitsPerSample) {
|
||||||
switch (BitsPerSample)
|
case 8:
|
||||||
{
|
return FMOD_SOUND_FORMAT_PCM8;
|
||||||
case 8: return FMOD_SOUND_FORMAT_PCM8;
|
case 16:
|
||||||
case 16: return FMOD_SOUND_FORMAT_PCM16;
|
return FMOD_SOUND_FORMAT_PCM16;
|
||||||
case 24: return FMOD_SOUND_FORMAT_PCM24;
|
case 24:
|
||||||
case 32: return FMOD_SOUND_FORMAT_PCM32;
|
return FMOD_SOUND_FORMAT_PCM24;
|
||||||
default: return FMOD_SOUND_FORMAT_NONE;
|
case 32:
|
||||||
|
return FMOD_SOUND_FORMAT_PCM32;
|
||||||
|
default:
|
||||||
|
return FMOD_SOUND_FORMAT_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,8 +129,7 @@ namespace
|
||||||
BS_FMODExSound::BS_FMODExSound(BS_Kernel *pKernel) :
|
BS_FMODExSound::BS_FMODExSound(BS_Kernel *pKernel) :
|
||||||
BS_SoundEngine(pKernel),
|
BS_SoundEngine(pKernel),
|
||||||
m_FMOD(0),
|
m_FMOD(0),
|
||||||
m_NextHandle(1)
|
m_NextHandle(1) {
|
||||||
{
|
|
||||||
// Lautstärkeneinstellungen auf die Standardwerte setzen
|
// Lautstärkeneinstellungen auf die Standardwerte setzen
|
||||||
m_Volumes[MUSIC] = DEFAULT_MUSIC_VOLUME;
|
m_Volumes[MUSIC] = DEFAULT_MUSIC_VOLUME;
|
||||||
m_Volumes[SPEECH] = DEFAULT_SPEECH_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
|
// 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.ChannelPtr) delete it->second.ChannelPtr;
|
||||||
if (it->second.ResourcePtr) it->second.ResourcePtr->Release();
|
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.
|
// 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.
|
// 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.");
|
BS_LOG_WARNINGLN("Tried to initialize again. Call ignored.");
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
try {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Die FMOD Ex mit den übergebenen Werte initialisieren
|
// Die FMOD Ex mit den übergebenen Werte initialisieren
|
||||||
FMOD_RESULT Result = FMOD_System_Create(&m_FMOD);
|
FMOD_RESULT Result = FMOD_System_Create(&m_FMOD);
|
||||||
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Create()", Result));
|
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Create()", Result));
|
||||||
|
@ -186,13 +176,11 @@ bool BS_FMODExSound::Init(unsigned int SampleRate, unsigned int Channels)
|
||||||
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Init()", Result));
|
if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Init()", Result));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(BS_FMODExException Ex)
|
catch (BS_FMODExException Ex) {
|
||||||
{
|
|
||||||
Ex.Log();
|
Ex.Log();
|
||||||
BS_LOG_ERRORLN("FMOD Ex could not be initialized.");
|
BS_LOG_ERRORLN("FMOD Ex could not be initialized.");
|
||||||
|
|
||||||
if (m_FMOD)
|
if (m_FMOD) {
|
||||||
{
|
|
||||||
FMOD_System_Release(m_FMOD);
|
FMOD_System_Release(m_FMOD);
|
||||||
m_FMOD = 0;
|
m_FMOD = 0;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
FMOD_RESULT Result = FMOD_System_Update(m_FMOD);
|
FMOD_RESULT Result = FMOD_System_Update(m_FMOD);
|
||||||
|
@ -227,8 +214,7 @@ bool BS_FMODExSound::PlaySound(const std::string& FileName,
|
||||||
float Pan,
|
float Pan,
|
||||||
bool Loop,
|
bool Loop,
|
||||||
int LoopStart, int LoopEnd,
|
int LoopStart, int LoopEnd,
|
||||||
unsigned int Layer)
|
unsigned int Layer) {
|
||||||
{
|
|
||||||
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0) != 0;
|
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,31 +226,27 @@ unsigned int BS_FMODExSound::PlaySoundEx(const std::string& FileName,
|
||||||
float Pan,
|
float Pan,
|
||||||
bool Loop,
|
bool Loop,
|
||||||
int LoopStart, int LoopEnd,
|
int LoopStart, int LoopEnd,
|
||||||
unsigned int Layer)
|
unsigned int Layer) {
|
||||||
{
|
|
||||||
return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0);
|
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.
|
// In dynamischen Sounds wird nicht gesprungen, daher tut dieses Funktion nichts.
|
||||||
return FMOD_OK;
|
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.
|
// 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.
|
// Handle auf den richtigen Sound holen, wurde als FMOD Ex Benutzerdaten gesetzt.
|
||||||
unsigned int Handle;
|
unsigned int Handle;
|
||||||
FMOD_RESULT Result = FMOD_Sound_GetUserData(sound, reinterpret_cast<void **>(&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();
|
BS_FMODExException("FMOD_Sound_GetUserData()", Result).Log();
|
||||||
return FMOD_OK;
|
return FMOD_OK;
|
||||||
}
|
}
|
||||||
|
@ -286,16 +268,13 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
|
||||||
unsigned int Channels,
|
unsigned int Channels,
|
||||||
float Volume,
|
float Volume,
|
||||||
float Pan,
|
float Pan,
|
||||||
unsigned int Layer)
|
unsigned int Layer) {
|
||||||
{
|
|
||||||
// Parameter überprüfen
|
// 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);
|
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d bits per sample.", BitsPerSample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (Channels == 0 || Channels > 2)
|
if (Channels == 0 || Channels > 2) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d channels.", Channels);
|
BS_LOG_ERRORLN("Cannot create a dynamic sound with %d channels.", Channels);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -328,8 +307,7 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
|
||||||
FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
|
FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
|
||||||
&CreateSoundExInfo,
|
&CreateSoundExInfo,
|
||||||
&FMODExSoundPtr);
|
&FMODExSoundPtr);
|
||||||
if (Result != FMOD_OK)
|
if (Result != FMOD_OK) {
|
||||||
{
|
|
||||||
BS_FMODExException("FMOD_System_CreateSound() from PlayDynamicSoundEx()", Result).Log();
|
BS_FMODExException("FMOD_System_CreateSound() from PlayDynamicSoundEx()", Result).Log();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -337,8 +315,7 @@ unsigned int BS_FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCal
|
||||||
// Neu erstellten Sound einem Kanal zuweisen
|
// Neu erstellten Sound einem Kanal zuweisen
|
||||||
FMOD_CHANNEL *FMODExChannelPtr;
|
FMOD_CHANNEL *FMODExChannelPtr;
|
||||||
Result = FMOD_System_PlaySound(m_FMOD, FMOD_CHANNEL_FREE, FMODExSoundPtr, 1, &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();
|
BS_FMODExException("FMOD_System_PlaySound() from PlayDynamicSoundEx()", Result).Log();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -364,20 +341,17 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
|
||||||
int LoopStart, int LoopEnd,
|
int LoopStart, int LoopEnd,
|
||||||
unsigned int Layer,
|
unsigned int Layer,
|
||||||
unsigned int Position,
|
unsigned int Position,
|
||||||
unsigned int Handle)
|
unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
||||||
|
|
||||||
// Resource anfordern
|
// Resource anfordern
|
||||||
BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
|
BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
|
||||||
if (!ResourcePtr)
|
if (!ResourcePtr) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Could not request resource \"%s\".", FileName.c_str());
|
BS_LOG_ERRORLN("Could not request resource \"%s\".", FileName.c_str());
|
||||||
return 0;
|
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());
|
BS_LOG_ERRORLN("Requested resource \"%s\" is not a sound.", FileName.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -386,36 +360,30 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
|
||||||
// Sound im Pause-Modus starten
|
// Sound im Pause-Modus starten
|
||||||
BS_FMODExChannel *ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
|
BS_FMODExChannel *ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
|
||||||
|
|
||||||
if (ChannelPtr)
|
if (ChannelPtr) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
// Falls der Sound gelooped wird, Loop-Points setzen
|
// 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),
|
// 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.
|
// wird der Loop-Point von FMOD Ex benutzt.
|
||||||
unsigned int RealLoopStart = (LoopStart > 0) ? LoopStart : ChannelPtr->GetLoopStart();
|
unsigned int RealLoopStart = (LoopStart > 0) ? LoopStart : ChannelPtr->GetLoopStart();
|
||||||
unsigned int RealLoopEnd = (LoopEnd > 0) ? LoopEnd : ChannelPtr->GetLoopEnd();
|
unsigned int RealLoopEnd = (LoopEnd > 0) ? LoopEnd : ChannelPtr->GetLoopEnd();
|
||||||
|
|
||||||
// Loop-Points auf Gültigkeit überprüfen
|
// 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\".",
|
BS_LOG_ERRORLN("Loop start (%d) was placed after loop end (%d) for sound \"%s\".",
|
||||||
RealLoopStart, RealLoopEnd,
|
RealLoopStart, RealLoopEnd,
|
||||||
SoundResourcePtr->GetFileName().c_str());
|
SoundResourcePtr->GetFileName().c_str());
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
if (RealLoopStart > ChannelPtr->GetLoopEnd())
|
if (RealLoopStart > ChannelPtr->GetLoopEnd()) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Loop start (%d) was placed after end (%d) of sound \"%s\".",
|
BS_LOG_ERRORLN("Loop start (%d) was placed after end (%d) of sound \"%s\".",
|
||||||
RealLoopStart,
|
RealLoopStart,
|
||||||
ChannelPtr->GetLoopEnd(),
|
ChannelPtr->GetLoopEnd(),
|
||||||
SoundResourcePtr->GetFileName().c_str());
|
SoundResourcePtr->GetFileName().c_str());
|
||||||
throw(0);
|
throw(0);
|
||||||
}
|
}
|
||||||
if (RealLoopEnd > ChannelPtr->GetLoopEnd())
|
if (RealLoopEnd > ChannelPtr->GetLoopEnd()) {
|
||||||
{
|
|
||||||
BS_LOG_ERRORLN("Loop end (%d) was placed after end (%d) of sound \"%s\".",
|
BS_LOG_ERRORLN("Loop end (%d) was placed after end (%d) of sound \"%s\".",
|
||||||
RealLoopEnd,
|
RealLoopEnd,
|
||||||
ChannelPtr->GetLoopEnd(),
|
ChannelPtr->GetLoopEnd(),
|
||||||
|
@ -432,9 +400,7 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
|
||||||
if (!ChannelPtr->SetPanning(NormalizePanning(Pan))) throw(0);
|
if (!ChannelPtr->SetPanning(NormalizePanning(Pan))) throw(0);
|
||||||
if (!ChannelPtr->SetLoop(Loop)) throw(0);
|
if (!ChannelPtr->SetLoop(Loop)) throw(0);
|
||||||
if (!ChannelPtr->SetPosition(Position)) throw(0);
|
if (!ChannelPtr->SetPosition(Position)) throw(0);
|
||||||
}
|
} catch (...) {
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
delete ChannelPtr;
|
delete ChannelPtr;
|
||||||
SoundResourcePtr->Release();
|
SoundResourcePtr->Release();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -452,9 +418,7 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
|
||||||
m_PlayingSoundsMap[NewHandle] = PlayingSoundData(SoundResourcePtr, ChannelPtr, Type, Layer, Volume);
|
m_PlayingSoundsMap[NewHandle] = PlayingSoundData(SoundResourcePtr, ChannelPtr, Type, Layer, Volume);
|
||||||
|
|
||||||
return NewHandle;
|
return NewHandle;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SoundResourcePtr->Release();
|
SoundResourcePtr->Release();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -464,16 +428,14 @@ unsigned int BS_FMODExSound::PlaySoundInternal(const std::string& FileName,
|
||||||
// Sonstige Methoden
|
// 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(m_FMOD);
|
||||||
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
||||||
m_Volumes[Type] = NormalizeVolume(Volume);
|
m_Volumes[Type] = NormalizeVolume(Volume);
|
||||||
|
|
||||||
// Alle Volumen der Sounds der Kategorie aktualisieren
|
// Alle Volumen der Sounds der Kategorie aktualisieren
|
||||||
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
|
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
const PlayingSoundData &PSD = it->second;
|
const PlayingSoundData &PSD = it->second;
|
||||||
if (PSD.ChannelPtr && PSD.Type == Type) PSD.ChannelPtr->SetVolume(Volume * PSD.Volume);
|
if (PSD.ChannelPtr && PSD.Type == Type) PSD.ChannelPtr->SetVolume(Volume * PSD.Volume);
|
||||||
|
|
||||||
|
@ -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(m_FMOD);
|
||||||
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
BS_ASSERT(Type < SOUNDTYPE_COUNT);
|
||||||
return m_Volumes[Type];
|
return m_Volumes[Type];
|
||||||
|
@ -492,16 +453,14 @@ float BS_FMODExSound::GetVolume(SOUND_TYPES Type)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::PauseAll()
|
void BS_FMODExSound::PauseAll() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle Sounds durchgehen und alle pausieren.
|
// 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.
|
// ResumeAll() setzt dann nur diejenigen fort, die nur über PauseAll() pausiert wurden.
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
PlayingSoundData &PSD = it->second;
|
PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
|
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
|
||||||
|
@ -513,19 +472,16 @@ void BS_FMODExSound::PauseAll()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::ResumeAll()
|
void BS_FMODExSound::ResumeAll() {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle Sounds durchgehen, die gloable Pause aufheben und diejenigen fortsetzen,
|
// Alle Sounds durchgehen, die gloable Pause aufheben und diejenigen fortsetzen,
|
||||||
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
|
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
PlayingSoundData &PSD = it->second;
|
PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
if (PSD.PausedGlobal)
|
if (PSD.PausedGlobal) {
|
||||||
{
|
|
||||||
PSD.PausedGlobal = false;
|
PSD.PausedGlobal = false;
|
||||||
if (PSD.ChannelPtr && !PSD.PausedLayer && !PSD.Paused) PSD.ChannelPtr->SetPaused(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);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle Sounds durchgehen und alle pausieren, die sich auf den angegebenen Layer befinden.
|
// 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.
|
// ResumeLayer() setzt dann nur diejenigen fort, die nur über PauseLayer() mit der entsprechenden Layer-Nummer pausiert wurden.
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
PlayingSoundData &PSD = it->second;
|
PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
if (PSD.Layer == Layer)
|
if (PSD.Layer == Layer) {
|
||||||
{
|
|
||||||
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
|
if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
|
||||||
PSD.PausedLayer = 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);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle Sounds durchgehen, die Layer-Pause aufheben und diejenigen fortsetzen,
|
// Alle Sounds durchgehen, die Layer-Pause aufheben und diejenigen fortsetzen,
|
||||||
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
|
// die keine Pause mehr haben (weder explizit, über den Layer oder global).
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
PlayingSoundData &PSD = it->second;
|
PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
if (PSD.PausedLayer && PSD.Layer == Layer)
|
if (PSD.PausedLayer && PSD.Layer == Layer) {
|
||||||
{
|
|
||||||
PSD.PausedLayer = false;
|
PSD.PausedLayer = false;
|
||||||
if (PSD.ChannelPtr && !PSD.PausedGlobal && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
|
if (PSD.ChannelPtr && !PSD.PausedGlobal && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
|
||||||
}
|
}
|
||||||
|
@ -585,8 +535,7 @@ void BS_FMODExSound::ResumeLayer(unsigned int Layer)
|
||||||
// Sound Setter
|
// Sound Setter
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume)
|
void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
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;
|
if (PSDPtr) if (PSDPtr->ChannelPtr && PSDPtr->ChannelPtr->SetVolume(NormalizeVolume(Volume) * m_Volumes[PSDPtr->Type])) PSDPtr->Volume = Volume;
|
||||||
|
@ -594,8 +543,7 @@ void BS_FMODExSound::SetSoundVolume(unsigned int Handle, float Volume)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan)
|
void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPanning(NormalizePanning(Pan));
|
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPanning(NormalizePanning(Pan));
|
||||||
|
@ -603,12 +551,10 @@ void BS_FMODExSound::SetSoundPanning(unsigned int Handle, float Pan)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::PauseSound(unsigned int Handle)
|
void BS_FMODExSound::PauseSound(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr)
|
if (PSDPtr) {
|
||||||
{
|
|
||||||
PSDPtr->Paused = true;
|
PSDPtr->Paused = true;
|
||||||
if (PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPaused(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);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr)
|
if (PSDPtr) {
|
||||||
{
|
|
||||||
PSDPtr->Paused = false;
|
PSDPtr->Paused = false;
|
||||||
if (PSDPtr->ChannelPtr && !PSDPtr->PausedGlobal && !PSDPtr->PausedLayer) PSDPtr->ChannelPtr->SetPaused(false);
|
if (PSDPtr->ChannelPtr && !PSDPtr->PausedGlobal && !PSDPtr->PausedLayer) PSDPtr->ChannelPtr->SetPaused(false);
|
||||||
}
|
}
|
||||||
|
@ -629,8 +573,7 @@ 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);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->Stop();
|
if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->Stop();
|
||||||
|
@ -640,8 +583,7 @@ void BS_FMODExSound::StopSound(unsigned int Handle)
|
||||||
// Sound Getter
|
// Sound Getter
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExSound::IsSoundPaused(unsigned int Handle)
|
bool BS_FMODExSound::IsSoundPaused(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPaused();
|
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPaused();
|
||||||
|
@ -650,8 +592,7 @@ bool BS_FMODExSound::IsSoundPaused(unsigned int Handle)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle)
|
bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPlaying();
|
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPlaying();
|
||||||
|
@ -660,8 +601,7 @@ bool BS_FMODExSound::IsSoundPlaying(unsigned int Handle)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
float BS_FMODExSound::GetSoundVolume(unsigned int Handle)
|
float BS_FMODExSound::GetSoundVolume(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr) return PSDPtr->Volume;
|
if (PSDPtr) return PSDPtr->Volume;
|
||||||
|
@ -670,8 +610,7 @@ float BS_FMODExSound::GetSoundVolume(unsigned int Handle)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
float BS_FMODExSound::GetSoundPanning(unsigned int Handle)
|
float BS_FMODExSound::GetSoundPanning(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
|
||||||
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->GetPanning();
|
if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->GetPanning();
|
||||||
|
@ -680,8 +619,7 @@ float BS_FMODExSound::GetSoundPanning(unsigned int Handle)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
float BS_FMODExSound::GetSoundTime(unsigned int Handle)
|
float BS_FMODExSound::GetSoundTime(unsigned int Handle) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
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;
|
if (PSDPtr && PSDPtr->ChannelPtr) return static_cast<float>(PSDPtr->ChannelPtr->GetTime()) / 1000.0f;
|
||||||
|
@ -692,21 +630,17 @@ float BS_FMODExSound::GetSoundTime(unsigned int Handle)
|
||||||
// Hilfsmethoden
|
// Hilfsmethoden
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void BS_FMODExSound::RemoveInactiveSounds()
|
void BS_FMODExSound::RemoveInactiveSounds() {
|
||||||
{
|
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying()) {
|
||||||
if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying())
|
|
||||||
{
|
|
||||||
PlayingSoundData &PSD = it->second;
|
PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
delete PSD.ChannelPtr;
|
delete PSD.ChannelPtr;
|
||||||
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
|
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
|
||||||
|
|
||||||
it = m_PlayingSoundsMap.erase(it);
|
it = m_PlayingSoundsMap.erase(it);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,8 +656,7 @@ void BS_FMODExSound::RemoveInactiveSounds()
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
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
|
// Zum Soundhandle gehörige Daten in der Hash-Map finden
|
||||||
PSM_ITER it = m_PlayingSoundsMap.find(Handle);
|
PSM_ITER it = m_PlayingSoundsMap.find(Handle);
|
||||||
// Falls die Daten nicht gefunden werden konnten, Fehler zurückgebene, ansonsten ein Pointer auf die Daten.
|
// 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;
|
unsigned int Result = 0;
|
||||||
for (PSM_CONST_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) if (!it->second.ResourcePtr) ++Result;
|
for (PSM_CONST_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) if (!it->second.ResourcePtr) ++Result;
|
||||||
|
|
||||||
|
@ -745,8 +677,7 @@ unsigned int BS_FMODExSound::CountPlayingDynamicSounds()
|
||||||
// Ressourcen-Verwaltung
|
// 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(m_FMOD);
|
||||||
BS_ASSERT(CanLoadResource(FileName));
|
BS_ASSERT(CanLoadResource(FileName));
|
||||||
|
|
||||||
|
@ -754,24 +685,20 @@ BS_Resource * BS_FMODExSound::LoadResource(const std::string& FileName)
|
||||||
BS_FMODExResource *ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
|
BS_FMODExResource *ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
|
||||||
if (Success)
|
if (Success)
|
||||||
return ResourcePtr;
|
return ResourcePtr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
delete ResourcePtr;
|
delete ResourcePtr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
|
bool BS_FMODExSound::CanLoadResource(const std::string &FileName) {
|
||||||
{
|
if (FileName.size() >= 4) {
|
||||||
if (FileName.size() >= 4)
|
|
||||||
{
|
|
||||||
std::string Extension(FileName.end() - 4, FileName.end());
|
std::string Extension(FileName.end() - 4, FileName.end());
|
||||||
BS_String::ToLower(Extension);
|
BS_String::ToLower(Extension);
|
||||||
|
|
||||||
return Extension == ".wav" ||
|
return Extension == ".wav" ||
|
||||||
Extension == ".ogg" ||
|
Extension == ".ogg" ||
|
||||||
Extension == ".mp3";
|
Extension == ".mp3";
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,8 +706,7 @@ bool BS_FMODExSound::CanLoadResource(const std::string& FileName)
|
||||||
// Persistenz
|
// Persistenz
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock & Writer)
|
bool BS_FMODExSound::Persist(BS_OutputPersistenceBlock &Writer) {
|
||||||
{
|
|
||||||
BS_ASSERT(m_FMOD);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle inaktiven Sounds entfernen, damit kein unnötiger Ballast gespeichert wird
|
// 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
|
// Informationen für jeden spielenden (nicht dynamischen) Sound speichern
|
||||||
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
|
PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
const PlayingSoundData &PSD = it->second;
|
const PlayingSoundData &PSD = it->second;
|
||||||
|
|
||||||
if (PSD.ResourcePtr)
|
if (PSD.ResourcePtr) {
|
||||||
{
|
|
||||||
// Handle speichern
|
// Handle speichern
|
||||||
Writer.Write(it->first);
|
Writer.Write(it->first);
|
||||||
|
|
||||||
|
@ -831,14 +755,12 @@ 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);
|
BS_ASSERT(m_FMOD);
|
||||||
|
|
||||||
// Alle Sounds stoppen
|
// Alle Sounds stoppen
|
||||||
PSM_ITER it = m_PlayingSoundsMap.begin();
|
PSM_ITER it = m_PlayingSoundsMap.begin();
|
||||||
while (it != m_PlayingSoundsMap.end())
|
while (it != m_PlayingSoundsMap.end()) {
|
||||||
{
|
|
||||||
const PlayingSoundData &PSD = it->second;
|
const PlayingSoundData &PSD = it->second;
|
||||||
if (PSD.ChannelPtr) delete PSD.ChannelPtr;
|
if (PSD.ChannelPtr) delete PSD.ChannelPtr;
|
||||||
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
|
if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
|
||||||
|
@ -856,8 +778,7 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
|
||||||
Reader.Read(SoundCount);
|
Reader.Read(SoundCount);
|
||||||
|
|
||||||
// Informationen über jeden spielenden Sound einlesen und ihn mit den Parametern abspielen
|
// Informationen über jeden spielenden Sound einlesen und ihn mit den Parametern abspielen
|
||||||
for (unsigned int i = 0; i < SoundCount; ++i)
|
for (unsigned int i = 0; i < SoundCount; ++i) {
|
||||||
{
|
|
||||||
unsigned int Handle;
|
unsigned int Handle;
|
||||||
std::string FileName;
|
std::string FileName;
|
||||||
unsigned int Type;
|
unsigned int Type;
|
||||||
|
@ -888,12 +809,9 @@ bool BS_FMODExSound::Unpersist(BS_InputPersistenceBlock & Reader)
|
||||||
Reader.Read(PausedLayer);
|
Reader.Read(PausedLayer);
|
||||||
Reader.Read(PausedGlobal);
|
Reader.Read(PausedGlobal);
|
||||||
|
|
||||||
if (Reader.IsGood())
|
if (Reader.IsGood()) {
|
||||||
{
|
|
||||||
PlaySoundInternal(FileName, (SOUND_TYPES) Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, Position, Handle);
|
PlaySoundInternal(FileName, (SOUND_TYPES) Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, Position, Handle);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,7 @@ struct FMOD_CHANNEL;
|
||||||
// Klassendefinition
|
// Klassendefinition
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
class BS_FMODExSound : public BS_SoundEngine
|
class BS_FMODExSound : public BS_SoundEngine {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Konstruktion / Destruktion
|
// Konstruktion / Destruktion
|
||||||
|
@ -104,8 +103,7 @@ public:
|
||||||
bool Unpersist(BS_InputPersistenceBlock &Reader);
|
bool Unpersist(BS_InputPersistenceBlock &Reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PlayingSoundData
|
struct PlayingSoundData {
|
||||||
{
|
|
||||||
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_),
|
ResourcePtr(ResourcePtr_),
|
||||||
|
|
|
@ -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())
|
if (!_RegisterScriptBindings())
|
||||||
BS_LOG_ERRORLN("Script bindings could not be registered.");
|
BS_LOG_ERRORLN("Script bindings could not be registered.");
|
||||||
else
|
else
|
||||||
|
|
|
@ -45,8 +45,7 @@
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int Init(lua_State * L)
|
static int Init(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -64,8 +63,7 @@ static int Init(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int Update(lua_State * L)
|
static int Update(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -78,8 +76,7 @@ static int Update(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int SetVolume(lua_State * L)
|
static int SetVolume(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -93,8 +90,7 @@ static int SetVolume(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int GetVolume(lua_State * L)
|
static int GetVolume(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -107,8 +103,7 @@ static int GetVolume(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int PauseAll(lua_State * L)
|
static int PauseAll(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -121,8 +116,7 @@ static int PauseAll(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int ResumeAll(lua_State * L)
|
static int ResumeAll(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -135,8 +129,7 @@ static int ResumeAll(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int PauseLayer(lua_State * L)
|
static int PauseLayer(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -149,8 +142,7 @@ static int PauseLayer(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int ResumeLayer(lua_State * L)
|
static int ResumeLayer(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -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);
|
FileName = luaL_checkstring(L, 1);
|
||||||
|
|
||||||
Type = static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)));
|
Type = static_cast<BS_SoundEngine::SOUND_TYPES>(static_cast<unsigned int>(luaL_checknumber(L, 2)));
|
||||||
|
@ -188,8 +179,7 @@ static void ProcessPlayParams(lua_State * L, std::string & FileName, BS_SoundEng
|
||||||
else Layer = static_cast<unsigned int>(luaL_checknumber(L, 8));
|
else Layer = static_cast<unsigned int>(luaL_checknumber(L, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PlaySound(lua_State * L)
|
static int PlaySound(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -210,8 +200,7 @@ static int PlaySound(lua_State * L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PlaySoundEx(lua_State * L)
|
static int PlaySoundEx(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -234,8 +223,7 @@ static int PlaySoundEx(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int SetSoundVolume(lua_State * L)
|
static int SetSoundVolume(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -248,8 +236,7 @@ static int SetSoundVolume(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int SetSoundPanning(lua_State * L)
|
static int SetSoundPanning(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -262,8 +249,7 @@ static int SetSoundPanning(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int PauseSound(lua_State * L)
|
static int PauseSound(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -276,8 +262,7 @@ static int PauseSound(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int ResumeSound(lua_State * L)
|
static int ResumeSound(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -290,8 +275,7 @@ static int ResumeSound(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int StopSound(lua_State * L)
|
static int StopSound(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -304,8 +288,7 @@ static int StopSound(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int IsSoundPaused(lua_State * L)
|
static int IsSoundPaused(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -318,8 +301,7 @@ static int IsSoundPaused(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int IsSoundPlaying(lua_State * L)
|
static int IsSoundPlaying(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -332,8 +314,7 @@ static int IsSoundPlaying(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int GetSoundVolume(lua_State * L)
|
static int GetSoundVolume(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -346,8 +327,7 @@ static int GetSoundVolume(lua_State * L)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int GetSoundPanning(lua_State * L)
|
static int GetSoundPanning(lua_State *L) {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
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"));
|
||||||
|
@ -362,8 +342,7 @@ 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,
|
"Init", Init,
|
||||||
"Update", Update,
|
"Update", Update,
|
||||||
"__SetVolume", SetVolume,
|
"__SetVolume", SetVolume,
|
||||||
|
@ -386,8 +365,7 @@ static const luaL_reg SFX_FUNCTIONS[] =
|
||||||
0, 0,
|
0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const lua_constant_reg SFX_CONSTANTS[] =
|
static const lua_constant_reg SFX_CONSTANTS[] = {
|
||||||
{
|
|
||||||
"MUSIC", BS_SoundEngine::MUSIC,
|
"MUSIC", BS_SoundEngine::MUSIC,
|
||||||
"SPEECH", BS_SoundEngine::SPEECH,
|
"SPEECH", BS_SoundEngine::SPEECH,
|
||||||
"SFX", BS_SoundEngine::SFX,
|
"SFX", BS_SoundEngine::SFX,
|
||||||
|
@ -396,8 +374,7 @@ static const lua_constant_reg SFX_CONSTANTS[] =
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool BS_SoundEngine::_RegisterScriptBindings()
|
bool BS_SoundEngine::_RegisterScriptBindings() {
|
||||||
{
|
|
||||||
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
BS_Kernel *pKernel = BS_Kernel::GetInstance();
|
||||||
BS_ASSERT(pKernel);
|
BS_ASSERT(pKernel);
|
||||||
BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
|
BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue