diff options
Diffstat (limited to 'src/graphics/engine')
-rw-r--r-- | src/graphics/engine/engine.cpp | 27 | ||||
-rw-r--r-- | src/graphics/engine/lightning.cpp | 2 | ||||
-rw-r--r-- | src/graphics/engine/modelfile.cpp | 20 | ||||
-rw-r--r-- | src/graphics/engine/modelmanager.cpp | 7 | ||||
-rw-r--r-- | src/graphics/engine/particle.cpp | 10 | ||||
-rw-r--r-- | src/graphics/engine/terrain.cpp | 19 | ||||
-rw-r--r-- | src/graphics/engine/text.cpp | 16 |
7 files changed, 45 insertions, 56 deletions
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index e0861d2..cfb794a 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -19,7 +19,6 @@ #include "graphics/engine/engine.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/image.h" #include "common/key.h" @@ -283,7 +282,7 @@ bool CEngine::Create() params.minFilter = TEX_MIN_FILTER_NEAREST; params.magFilter = TEX_MAG_FILTER_NEAREST; params.mipmap = false; - m_miceTexture = LoadTexture("mouse.png", params); + m_miceTexture = LoadTexture("interface/mouse.png", params); GetSystemUtils()->GetCurrentTimeStamp(m_currentFrameTime); GetSystemUtils()->GetCurrentTimeStamp(m_lastFrameTime); @@ -2258,7 +2257,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa if (image == nullptr) { - if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName))) + if (!img.Load("textures/"+texName)) { std::string error = img.GetError(); GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); @@ -2309,15 +2308,15 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams& bool CEngine::LoadAllTextures() { - LoadTexture("text.png"); - m_miceTexture = LoadTexture("mouse.png"); - LoadTexture("button1.png"); - LoadTexture("button2.png"); - LoadTexture("button3.png"); - LoadTexture("effect00.png"); - LoadTexture("effect01.png"); - LoadTexture("effect02.png"); - LoadTexture("map.png"); + LoadTexture("interface/text.png"); + m_miceTexture = LoadTexture("interface/mouse.png"); + LoadTexture("interface/button1.png"); + LoadTexture("interface/button2.png"); + LoadTexture("interface/button3.png"); + LoadTexture("interface/effect00.png"); + LoadTexture("interface/effect01.png"); + LoadTexture("interface/effect02.png"); + LoadTexture("interface/map.png"); if (! m_backgroundName.empty()) { @@ -2426,7 +2425,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName, CImage img; - if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName))) + if (!img.Load("textures/"+texName)) { std::string error = img.GetError(); GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); @@ -3785,7 +3784,7 @@ void CEngine::DrawShadow() SetMaterial(material); // TODO: create a separate texture - SetTexture("text.png"); + SetTexture("interface/text.png"); Math::Point ts, ti; diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp index 4395eec..b0e144c 100644 --- a/src/graphics/engine/lightning.cpp +++ b/src/graphics/engine/lightning.cpp @@ -235,7 +235,7 @@ void CLightning::Draw() mat.LoadIdentity(); device->SetTransform(TRANSFORM_WORLD, mat); - m_engine->SetTexture("effect00.png"); + m_engine->SetTexture("interface/effect00.png"); m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK); Math::Point texInf; diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp index 99496aa..5f10ff1 100644 --- a/src/graphics/engine/modelfile.cpp +++ b/src/graphics/engine/modelfile.cpp @@ -22,6 +22,8 @@ #include "common/logger.h" #include "common/stringutils.h" +#include "common/resources/inputstream.h" + #include "graphics/engine/engine.h" #include "math/geometry.h" @@ -432,9 +434,9 @@ bool CModelFile::ReadModel(const std::string& fileName) { m_triangles.clear(); - std::ifstream stream; - stream.open(fileName.c_str(), std::ios_base::in | std::ios_base::binary); - if (!stream.good()) + CInputStream stream; + stream.open(fileName.c_str()); + if (!stream.is_open()) { GetLogger()->Error("Could not open file '%s'\n", fileName.c_str()); return false; @@ -823,9 +825,9 @@ struct NewModelTriangle1 bool CModelFile::ReadTextModel(const std::string& fileName) { - std::ifstream stream; - stream.open(fileName.c_str(), std::ios_base::in); - if (!stream.good()) + CInputStream stream; + stream.open(fileName.c_str()); + if (!stream.is_open()) { GetLogger()->Error("Could not open file '%s'\n", fileName.c_str()); return false; @@ -1020,9 +1022,9 @@ bool CModelFile::WriteTextModel(std::ostream& stream) bool CModelFile::ReadBinaryModel(const std::string& fileName) { - std::ifstream stream; - stream.open(fileName.c_str(), std::ios_base::in | std::ios_base::binary); - if (!stream.good()) + CInputStream stream; + stream.open(fileName.c_str()); + if (!stream.is_open()) { GetLogger()->Error("Could not open file '%s'\n", fileName.c_str()); return false; diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index 0c0fb98..6ee0b86 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -18,7 +18,6 @@ #include "graphics/engine/modelmanager.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/logger.h" @@ -48,11 +47,9 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored) if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS)) modelFile.SetPrintDebugInfo(true); - std::string filePath = CGameData::GetInstancePointer()->GetFilePath(DIR_MODEL, fileName); - - if (!modelFile.ReadModel(filePath)) + if (!modelFile.ReadModel("models/" + fileName)) { - GetLogger()->Error("Loading model '%s' failed\n", filePath.c_str()); + GetLogger()->Error("Loading model '%s' failed\n", fileName.c_str()); return false; } diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index abee2e2..3dc8c0d 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -198,10 +198,10 @@ void CParticle::FlushParticle(int sheet) //! Returns file name of the effect effectNN.png, with NN = number void NameParticle(std::string &name, int num) { - if (num == 1) name = "effect00.png"; - else if (num == 2) name = "effect01.png"; - else if (num == 3) name = "effect02.png"; - else if (num == 4) name = "text.png"; + if (num == 1) name = "interface/effect00.png"; + else if (num == 2) name = "interface/effect01.png"; + else if (num == 3) name = "interface/effect02.png"; + else if (num == 4) name = "interface/text.png"; else name = ""; } @@ -3551,7 +3551,7 @@ void CParticle::DrawParticle(int sheet) // Draw tire marks. if (m_wheelTraceTotal > 0 && sheet == SH_WORLD) { - m_engine->SetTexture("text.png"); + m_engine->SetTexture("interface/text.png"); m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE); Math::Matrix matrix; matrix.LoadIdentity(); diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp index 5f37cd8..6a8dc6b 100644 --- a/src/graphics/engine/terrain.cpp +++ b/src/graphics/engine/terrain.cpp @@ -19,7 +19,6 @@ #include "graphics/engine/terrain.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/image.h" #include "common/logger.h" @@ -190,10 +189,10 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point bool CTerrain::LoadResources(const std::string& fileName) { CImage img; - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName); - if (! img.Load(path)) + + if (! img.Load(fileName)) { - GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str()); + GetLogger()->Error("Cannot load resource file: '%s'\n", fileName.c_str()); return false; } @@ -287,10 +286,10 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief, m_scaleRelief = scaleRelief; CImage img; - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName); - if (! img.Load(path)) + + if (! img.Load(fileName)) { - GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str()); + GetLogger()->Error("Could not load relief file: '%s'!\n", fileName.c_str()); return false; } @@ -366,17 +365,11 @@ bool CTerrain::RandomizeRelief() double xi, yi, a, b; a = modf(x * (rozmiar_oktawy-1), &xi); b = modf(y * (rozmiar_oktawy-1), &yi); - /*int xi = floor(x * (rozmiar_oktawy-1)); - int yi = floor(y * (rozmiar_oktawy-1)); - float a = (x * (rozmiar_oktawy-1)) - xi; - float b = (y * (rozmiar_oktawy-1)) - yi;*/ - //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", xi, yi, a, b); float lg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi)]; float pg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi + 1)]; float ld = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi)]; float pd = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi + 1)]; - //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", lg, pg, ld, pd); float g = pg * a + lg * (1-a); float d = pd * a + ld * (1-a); diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 8fd01b7..78cf7b8 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -19,11 +19,11 @@ #include "graphics/engine/text.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/image.h" #include "common/logger.h" #include "common/stringutils.h" +#include "common/resources/resourcemanager.h" #include "math/func.h" @@ -78,12 +78,12 @@ bool CText::Create() return false; } - m_fonts[FONT_COLOBOT] = new MultisizeFont("dvu_sans.ttf"); - m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("dvu_sans_bold.ttf"); - m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("dvu_sans_italic.ttf"); + m_fonts[FONT_COLOBOT] = new MultisizeFont("fonts/dvu_sans.ttf"); + m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("fonts/dvu_sans_bold.ttf"); + m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("fonts/dvu_sans_italic.ttf"); - m_fonts[FONT_COURIER] = new MultisizeFont("dvu_sans_mono.ttf"); - m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("dvu_sans_mono_bold.ttf"); + m_fonts[FONT_COURIER] = new MultisizeFont("fonts/dvu_sans_mono.ttf"); + m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("fonts/dvu_sans_mono_bold.ttf"); for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it) { @@ -866,10 +866,8 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size) return m_lastCachedFont; } - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName); - m_lastCachedFont = new CachedFont(); - m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize); + m_lastCachedFont->font = TTF_OpenFontRW(CResourceManager::GetSDLFileHandler(mf->fileName), 1, pointSize); if (m_lastCachedFont->font == nullptr) m_error = std::string("TTF_OpenFont error ") + std::string(TTF_GetError()); |