Verbose position

This commit is contained in:
jordan4ibanez 2023-11-28 07:50:29 -05:00
parent 5becfee6bb
commit e63d4400bd
1 changed files with 32 additions and 10 deletions

View File

@ -246,6 +246,8 @@ std::tuple<bool, std::string> 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<bool, std::string> 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++;
}