From e63d4400bdea9ea6a7b8c4f8fecf74532be3f790 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 28 Nov 2023 07:50:29 -0500 Subject: [PATCH] Verbose position --- source/Irrlicht/CB3DJSONMeshFileLoader.cpp | 42 ++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/source/Irrlicht/CB3DJSONMeshFileLoader.cpp b/source/Irrlicht/CB3DJSONMeshFileLoader.cpp index 57cf728b..5c7c3391 100644 --- a/source/Irrlicht/CB3DJSONMeshFileLoader.cpp +++ b/source/Irrlicht/CB3DJSONMeshFileLoader.cpp @@ -246,6 +246,8 @@ std::tuple CB3DJSONMeshFileLoader::readChunkTEXS() { // This part should probably be it's own function. //todo: look into making this it's own function. + // This part is a bit complex, for ease of use for the plugin dev/modders advantage. + //* Name. if (t.contains("name") && t["name"].is_string()) { @@ -294,18 +296,38 @@ std::tuple CB3DJSONMeshFileLoader::readChunkTEXS() { return {false, "Missing \"blend\" in TEXS block index(" + std::to_string(index)+")."}; } + //* Position. + if (t.contains("pos") && t["pos"].is_array()) { + + irr::core::vector2df pos {0,0}; + + auto posSuccess = grabVec2f(t, "pos", pos); + + // Something went horribly wrong. + if (!std::get<0>(posSuccess)) { + + return {false, "TEXS: " + std::get<1>(posSuccess)}; + } + + // Success. + B3DTexture.Xpos = pos.X; + B3DTexture.Ypos = pos.Y; + + } else { + + if (t.contains("pos") && !t["pos"].is_array()) { + return {false, "\"pos\" in TEXS block index(" + std::to_string(index)+") is not an array."}; + } + + if (!t.contains("pos") ) { + return {false, "\"pos\" in TEXS block index(" + std::to_string(index)+") is missing."}; + } + + return {false, "Malformed \"pos\" in TEXS block index (" + std::to_string(index) + "). Must be an array with 2 numbers."}; + } + - // This part is a bit complex, for ease of use for the plugin dev/modders advantage. - // if (t.contains("pos") && t["pos"].is_array()) { - // irr::core::vector2df pos {0,0}; - // auto posSuccess = grabVec2f(t, "pos", pos); - // if (!std::get<0>(posSuccess)) { - // return {false, "TEXS: " + std::get<1>(posSuccess)}; - // } - // } else { - // return {false, "Malformed \"pos\" in TEXS block index (" + std::to_string(index) + "). Must be an array with 2 numbers."}; - // } index++; }