From 2decd2e99386491d8e02ca633148b14ea3754111 Mon Sep 17 00:00:00 2001 From: hexagon-recursion Date: Wed, 21 Aug 2024 23:08:15 +0300 Subject: [PATCH] Refactor planet --- colobot-base/src/graphics/engine/planet.cpp | 6 +++--- colobot-base/src/graphics/engine/planet.h | 5 +++-- colobot-base/src/level/robotmain.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/colobot-base/src/graphics/engine/planet.cpp b/colobot-base/src/graphics/engine/planet.cpp index 99b09fc8c..fdea6ef47 100644 --- a/colobot-base/src/graphics/engine/planet.cpp +++ b/colobot-base/src/graphics/engine/planet.cpp @@ -93,7 +93,7 @@ void CPlanet::LoadTexture() { for (const auto& planet : m_planets) { - m_engine->LoadTexture(TempToPath(planet.name)); + m_engine->LoadTexture(planet.name); } } @@ -114,7 +114,7 @@ void CPlanet::Draw() if (planet.type != m_visibleType) continue; - auto texture = m_engine->LoadTexture(TempToPath(planet.name)); + auto texture = m_engine->LoadTexture(planet.name); renderer->SetAlbedoTexture(texture); @@ -172,7 +172,7 @@ void CPlanet::Draw() } void CPlanet::Create(PlanetType type, const glm::vec2& start, float dim, float speed, - float dir, const std::string& name, const glm::vec2& uv1, const glm::vec2& uv2, + float dir, const std::filesystem::path& name, const glm::vec2& uv1, const glm::vec2& uv2, bool transparent) { Planet planet; diff --git a/colobot-base/src/graphics/engine/planet.h b/colobot-base/src/graphics/engine/planet.h index ea3e0feac..46fbb8c1d 100644 --- a/colobot-base/src/graphics/engine/planet.h +++ b/colobot-base/src/graphics/engine/planet.h @@ -30,6 +30,7 @@ #include #include +#include struct Event; @@ -59,7 +60,7 @@ class CPlanet bool EventProcess(const Event &event); //! Creates a new planet void Create(PlanetType type, const glm::vec2& start, float dim, float speed, float dir, - const std::string& name, const glm::vec2& uv1, const glm::vec2& uv2, + const std::filesystem::path& name, const glm::vec2& uv1, const glm::vec2& uv2, bool transparent); //! Indicates if there is at least one planet bool PlanetExist(); @@ -99,7 +100,7 @@ class CPlanet //! Direction in the sky float dir = 0.0f; //! Name of the texture - std::string name; + std::filesystem::path name; //! Texture mapping glm::vec2 uv1, uv2; diff --git a/colobot-base/src/level/robotmain.cpp b/colobot-base/src/level/robotmain.cpp index 8320799c0..41befc491 100644 --- a/colobot-base/src/level/robotmain.cpp +++ b/colobot-base/src/level/robotmain.cpp @@ -3153,10 +3153,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) line->GetParam("dim")->AsFloat(0.2f), line->GetParam("speed")->AsFloat(0.0f), line->GetParam("dir")->AsFloat(0.0f), - TempToString(line->GetParam("image")->AsPath("textures")), + line->GetParam("image")->AsPath("textures"), { uv1.x, uv1.z }, { uv2.x, uv2.z }, - TempToString(line->GetParam("image")->AsPath("textures")).find("planet") != std::string::npos // TODO: add transparent op or modify textures + StrUtils::ToString(line->GetParam("image")->AsPath("textures")).find("planet") != std::string::npos // TODO: add transparent op or modify textures ); continue; }