Replacing std::format with fmt::format

This commit is contained in:
Dynamitos
2024-01-16 19:24:49 +01:00
parent c0da7d77a1
commit 861c146b46
55 changed files with 304 additions and 186 deletions
+2
View File
@@ -6,6 +6,8 @@
#include "Graphics/Texture.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include <iostream>
#include <fstream>
using namespace Seele;
+11 -9
View File
@@ -8,7 +8,9 @@
#include "Material/ShaderExpression.h"
#include "Asset/TextureAsset.h"
#include <nlohmann/json.hpp>
#include <format>
#include <fmt/core.h>
#include <iostream>
#include <fstream>
using namespace Seele;
using json = nlohmann::json;
@@ -131,14 +133,14 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
{
std::string str = obj.get<std::string>();
OConstantExpression c = new ConstantExpression(str, ExpressionType::UNKNOWN);
std::string name = std::format("const_{0}", auxKey++);
std::string name = fmt::format("const_{0}", auxKey++);
c->key = name;
expressions.add(std::move(c));
return name;
}
else
{
return std::format("{0}", obj.get<uint32>());
return fmt::format("{0}", obj.get<uint32>());
}
};
MaterialNode mat;
@@ -150,7 +152,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if (exp.compare("Const") == 0)
{
OConstantExpression p = new ConstantExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->expr = obj["value"];
expressions.add(std::move(p));
@@ -158,7 +160,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Add") == 0)
{
OAddExpression p = new AddExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -167,7 +169,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Sub") == 0)
{
OSubExpression p = new SubExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -176,7 +178,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Mul") == 0)
{
OMulExpression p = new MulExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->inputs["lhs"].source = referenceExpression(obj["lhs"]);
p->inputs["rhs"].source = referenceExpression(obj["rhs"]);
@@ -185,7 +187,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Swizzle") == 0)
{
OSwizzleExpression p = new SwizzleExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->inputs["target"].source = referenceExpression(obj["target"]);
int32 i = 0;
@@ -198,7 +200,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
if(exp.compare("Sample") == 0)
{
OSampleExpression p = new SampleExpression();
std::string name = std::format("{0}", key++);
std::string name = fmt::format("{0}", key++);
p->key = name;
p->inputs["texture"].source = referenceExpression(obj["texture"]);
p->inputs["sampler"].source = referenceExpression(obj["sampler"]);
+3 -3
View File
@@ -6,7 +6,7 @@
#include "Asset/AssetImporter.h"
#include "Asset/MaterialAsset.h"
#include <set>
#include <format>
#include <fmt/core.h>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
@@ -48,7 +48,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
{
aiMaterial* material = scene->mMaterials[i];
json matCode;
std::string materialName = std::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i);
std::string materialName = fmt::format("{0}{1}{2}", baseName, material->GetName().C_Str(), i);
materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later
matCode["name"] = materialName;
matCode["profile"] = "CelShading";
@@ -196,7 +196,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
});
PMaterialAsset baseMat = AssetRegistry::findMaterial(matCode["name"].get<std::string>());
globalMaterials[i] = baseMat->instantiate(InstantiationParameter{
.name = std::format("{0}_Inst_0", baseMat->getName()),
.name = fmt::format("{0}_Inst_0", baseMat->getName()),
.folderPath = baseMat->getFolderPath(),
});
}
+1
View File
@@ -13,6 +13,7 @@
#include <stb_image_write.h>
#pragma GCC diagnostic pop
#include "ktx.h"
#include <fstream>
using namespace Seele;
+1
View File
@@ -1,5 +1,6 @@
#include "ViewportControl.h"
#include "Component/Camera.h"
#include <iostream>
using namespace Seele;
using namespace Seele::Editor;
+4 -4
View File
@@ -12,7 +12,7 @@
#include "Asset/FontLoader.h"
#include "Asset/AssetImporter.h"
#include "Graphics/StaticMeshVertexData.h"
#include <format>
#include <fmt/core.h>
using namespace Seele;
using namespace Seele::Editor;
@@ -254,9 +254,9 @@ int main()
if (false)
{
std::filesystem::create_directories(outputPath);
std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str());
std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
std::system(std::format("cmake --build {}", cmakePath.generic_string()).c_str());
std::system(fmt::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str());
std::system(fmt::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
std::system(fmt::format("cmake --build {}", cmakePath.generic_string()).c_str());
std::filesystem::copy(sourcePath / "Assets", outputPath / "Assets", std::filesystem::copy_options::recursive);
std::filesystem::copy("shaders", outputPath / "shaders", std::filesystem::copy_options::recursive);
std::filesystem::copy("textures", outputPath / "textures", std::filesystem::copy_options::recursive);