From 4a237f5925eb0d371e097416b17dd5e919cd2258 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 31 Dec 2013 12:58:45 +0100 Subject: CPauseManager --- src/graphics/engine/engine.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/graphics/engine/engine.cpp') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 5cf7b23..0ee7715 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -63,6 +63,7 @@ CEngine::CEngine(CApplication *app) m_planet = nullptr; m_sound = nullptr; m_terrain = nullptr; + m_pause = nullptr; m_showStats = false; @@ -80,7 +81,6 @@ CEngine::CEngine(CApplication *app) m_fogStart[1] = 0.75f; m_waterAddColor = Color(0.0f, 0.0f, 0.0f, 0.0f); - m_pause = false; m_render = true; m_movieLock = false; m_shadowVisible = true; @@ -179,6 +179,7 @@ CEngine::~CEngine() m_lightning = nullptr; m_planet = nullptr; m_terrain = nullptr; + m_pause = nullptr; GetSystemUtils()->DestroyTimeStamp(m_lastFrameTime); m_lastFrameTime = nullptr; @@ -252,6 +253,7 @@ bool CEngine::Create() m_cloud = new CCloud(this); m_lightning = new CLightning(this); m_planet = new CPlanet(this); + m_pause = new CPauseManager(); m_lightMan->SetDevice(m_device); m_particle->SetDevice(m_device); @@ -422,18 +424,13 @@ void CEngine::FrameUpdate() bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height) { // TODO write screenshot: not very important for now - GetLogger()->Trace("CEngine::WriteSceenShot(): stub!\n"); + GetLogger()->Debug("CEngine::WriteSceenShot(): stub!\n"); return true; } -void CEngine::SetPause(bool pause) -{ - m_pause = pause; -} - bool CEngine::GetPause() { - return m_pause; + return m_pause->GetPause(); } void CEngine::SetMovieLock(bool lock) -- cgit v1.2.3-1-g7c22 From f0d97bfdb91a2c0a17d1697b145d4df930280dbb Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 18 May 2014 12:12:47 +0200 Subject: Better datadir mod support --- src/graphics/engine/engine.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'src/graphics/engine/engine.cpp') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 0ee7715..d6e4415 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -19,6 +19,7 @@ #include "graphics/engine/engine.h" #include "app/app.h" +#include "app/gamedata.h" #include "common/image.h" #include "common/key.h" @@ -2246,33 +2247,12 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa if (image == nullptr) { - bool loadedFromTexPack = false; - - std::string texPackName = m_app->GetTexPackFilePath(texName); - if (! texPackName.empty()) + if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName))) { - if (img.Load(texPackName)) - { - loadedFromTexPack = true; - } - else - { - std::string error = img.GetError(); - GetLogger()->Error("Couldn't load texture '%s' from texpack: %s, blacklisting the texpack path\n", - texName.c_str(), error.c_str()); - m_texBlacklist.insert(texPackName); - } - } - - if (!loadedFromTexPack) - { - if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName))) - { - std::string error = img.GetError(); - GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); - m_texBlacklist.insert(texName); - return Texture(); // invalid texture - } + std::string error = img.GetError(); + GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); + m_texBlacklist.insert(texName); + return Texture(); // invalid texture } image = &img; @@ -2435,7 +2415,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName, CImage img; - if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName))) + if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName))) { std::string error = img.GetError(); GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); -- cgit v1.2.3-1-g7c22 From 613e1d74c47cf3a756af9aff75575c7567699381 Mon Sep 17 00:00:00 2001 From: Mohamed Waheed Date: Tue, 24 Jun 2014 01:35:05 +0300 Subject: implemented savefile screenshot feature --- src/graphics/engine/engine.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/graphics/engine/engine.cpp') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index d6e4415..9216fb0 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -424,9 +424,20 @@ void CEngine::FrameUpdate() bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height) { - // TODO write screenshot: not very important for now - GetLogger()->Debug("CEngine::WriteSceenShot(): stub!\n"); - return true; + void *pixels = m_device->GetFrameBufferPixels(); + CImage img({width,height}); + + img.SetDataPixels(pixels); + img.flipVertical(); + + if ( img.SavePNG(fileName.c_str()) ){ + GetLogger()->Info("Save SceenShot Saved Successfully!\n"); + return true; + } + else{ + GetLogger()->Error("%s!\n",img.GetError().c_str()); + return false; + } } bool CEngine::GetPause() -- cgit v1.2.3-1-g7c22 From b7125a5b24bc6d2581bec0d3f792ba948e0e7edd Mon Sep 17 00:00:00 2001 From: Mohamed Waheed Date: Tue, 24 Jun 2014 20:27:31 +0300 Subject: formatting and enhancements for savefile screenshot feature --- src/graphics/engine/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/graphics/engine/engine.cpp') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 9216fb0..e0861d2 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -428,7 +428,7 @@ bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height CImage img({width,height}); img.SetDataPixels(pixels); - img.flipVertical(); + img.flipVertically(); if ( img.SavePNG(fileName.c_str()) ){ GetLogger()->Info("Save SceenShot Saved Successfully!\n"); -- cgit v1.2.3-1-g7c22