feat: add new rule in BMapInspector
This commit is contained in:
@@ -30,6 +30,7 @@ namespace BMapInspector::Rule {
|
|||||||
rules.emplace_back(new Ruleset::YYCRule2());
|
rules.emplace_back(new Ruleset::YYCRule2());
|
||||||
rules.emplace_back(new Ruleset::YYCRule3());
|
rules.emplace_back(new Ruleset::YYCRule3());
|
||||||
rules.emplace_back(new Ruleset::YYCRule4());
|
rules.emplace_back(new Ruleset::YYCRule4());
|
||||||
|
rules.emplace_back(new Ruleset::YYCRule5());
|
||||||
rules.emplace_back(new Ruleset::BBugRule1());
|
rules.emplace_back(new Ruleset::BBugRule1());
|
||||||
rules.emplace_back(new Ruleset::BBugRule2());
|
rules.emplace_back(new Ruleset::BBugRule2());
|
||||||
rules.emplace_back(new Ruleset::BBugRule3());
|
rules.emplace_back(new Ruleset::BBugRule3());
|
||||||
@@ -59,4 +60,4 @@ namespace BMapInspector::Rule {
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
} // namespace BMapInspector::RuleCollection
|
} // namespace BMapInspector::Rule
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ namespace BMapInspector::Ruleset {
|
|||||||
|
|
||||||
void BBugRule3::Check(Reporter::Reporter& reporter, Map::Level& level) const {
|
void BBugRule3::Check(Reporter::Reporter& reporter, Map::Level& level) const {
|
||||||
// TODO:
|
// TODO:
|
||||||
// This function is already presented in Ballance Blender Plugin,
|
// This rule is complex and can be done by Ballance Blender Plugin.
|
||||||
// so I don't want write it in there now.
|
// So we are not urgently to implement it in there.
|
||||||
// Write this if I have spare time in future.
|
// Just make a rule placeholder in there and may finish it in future.
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ namespace BMapInspector::Ruleset {
|
|||||||
|
|
||||||
void GpRule1::Check(Reporter::Reporter& reporter, Map::Level& level) const {
|
void GpRule1::Check(Reporter::Reporter& reporter, Map::Level& level) const {
|
||||||
// TODO:
|
// TODO:
|
||||||
// Finish this rule.
|
// This rule is complex and can be done by Ballance Blender Plugin.
|
||||||
// It is so complex that I don't want to implement it now.
|
// So we are not urgently to implement it in there.
|
||||||
|
// Just make a rule placeholder in there and may finish it in future.
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#include "Name.hpp"
|
||||||
|
|
||||||
|
namespace BMapInspector::Ruleset::Shared::Name {}
|
||||||
|
|||||||
@@ -262,13 +262,13 @@ namespace BMapInspector::Ruleset {
|
|||||||
auto lower_tex_filename = strop::to_lower(tex_filename.value());
|
auto lower_tex_filename = strop::to_lower(tex_filename.value());
|
||||||
if (opaque_texs.contains(lower_tex_filename)) {
|
if (opaque_texs.contains(lower_tex_filename)) {
|
||||||
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_16_ARGB1555) {
|
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_16_ARGB1555) {
|
||||||
reporter.FormatWarning(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. "
|
reporter.FormatInfo(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. "
|
||||||
u8"This is mismatched with vanilla Ballance.",
|
u8"This is mismatched with vanilla Ballance.",
|
||||||
Shared::Utility::QuoteObjectName(tex).c_str());
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
}
|
}
|
||||||
} else if (transparent_texs.contains(lower_tex_filename)) {
|
} else if (transparent_texs.contains(lower_tex_filename)) {
|
||||||
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_32_ARGB8888) {
|
if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_32_ARGB8888) {
|
||||||
reporter.FormatWarning(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. "
|
reporter.FormatInfo(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. "
|
||||||
u8"This is mismatched with vanilla Ballance.",
|
u8"This is mismatched with vanilla Ballance.",
|
||||||
Shared::Utility::QuoteObjectName(tex).c_str());
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
}
|
}
|
||||||
@@ -278,13 +278,13 @@ namespace BMapInspector::Ruleset {
|
|||||||
// Do nothing.
|
// Do nothing.
|
||||||
break;
|
break;
|
||||||
case V::VX_PIXELFORMAT::_32_ARGB8888:
|
case V::VX_PIXELFORMAT::_32_ARGB8888:
|
||||||
reporter.FormatWarning(u8"Texture %s is not Ballance texture. Its video format is ARGB8888. "
|
reporter.FormatInfo(u8"Texture %s is not Ballance texture. Its video format is ARGB8888. "
|
||||||
u8"This may cause useless performance consumption if there is no transparent inside it. "
|
u8"This may cause useless performance consumption if there is no transparent inside it. "
|
||||||
u8"Please check whether this is essential.",
|
u8"Please check whether this is essential.",
|
||||||
Shared::Utility::QuoteObjectName(tex).c_str());
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
reporter.FormatWarning(
|
reporter.FormatInfo(
|
||||||
u8"Texture %s is not Ballance texture. Its video format is not ARGB1555 or ARGB8888. "
|
u8"Texture %s is not Ballance texture. Its video format is not ARGB1555 or ARGB8888. "
|
||||||
u8"This is mismatched with vanilla Ballance. "
|
u8"This is mismatched with vanilla Ballance. "
|
||||||
u8"Please set it to ARGB1555 for opaque texture, or ARGB8888 for transaprent texture, except special scenario.",
|
u8"Please set it to ARGB1555 for opaque texture, or ARGB8888 for transaprent texture, except special scenario.",
|
||||||
@@ -295,4 +295,60 @@ namespace BMapInspector::Ruleset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region YYC Rule 5
|
||||||
|
|
||||||
|
YYCRule5::YYCRule5() : Rule::IRule() {}
|
||||||
|
|
||||||
|
YYCRule5::~YYCRule5() {}
|
||||||
|
|
||||||
|
std::u8string_view YYCRule5::GetRuleName() const {
|
||||||
|
return u8"YYC5";
|
||||||
|
}
|
||||||
|
|
||||||
|
void YYCRule5::Check(Reporter::Reporter& reporter, Map::Level& level) const {
|
||||||
|
// Build lowercase texture name set first.
|
||||||
|
std::set<std::u8string> texs;
|
||||||
|
for (const auto* tex_name : Shared::Name::Texture::ALL) {
|
||||||
|
texs.emplace(strop::to_lower(tex_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check texture one by one
|
||||||
|
for (auto& tex : level.GetTextures()) {
|
||||||
|
auto tex_filename = Shared::Utility::ExtractTextureFileName(tex);
|
||||||
|
if (!tex_filename.has_value()) continue;
|
||||||
|
|
||||||
|
auto lower_tex_filename = strop::to_lower(tex_filename.value());
|
||||||
|
bool is_ballance_tex = texs.contains(lower_tex_filename);
|
||||||
|
|
||||||
|
using C::CK_TEXTURE_SAVEOPTIONS;
|
||||||
|
switch (tex->GetUnderlyingData().GetSaveOptions()) {
|
||||||
|
case CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_USEGLOBAL:
|
||||||
|
reporter.FormatInfo(u8"The save option of texture %s rely on global Virtools settings. "
|
||||||
|
u8"This cause ambiguity and different behavior on different Virtools by different user settings. "
|
||||||
|
u8"Please consider change it to explicit option, such as External or Raw Data.",
|
||||||
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
|
break;
|
||||||
|
case CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL:
|
||||||
|
if (!is_ballance_tex) {
|
||||||
|
reporter.FormatWarning(u8"Texture %s is not Ballance texture, but its save option is External. "
|
||||||
|
u8"This may cause texture loss when rendering in game. Please consider store it inside map.",
|
||||||
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (is_ballance_tex) {
|
||||||
|
reporter.FormatInfo(u8"Texture %s is Ballance texture, but its save option is not External. "
|
||||||
|
u8"Please consider storing it as External to reduce the final size of map file, "
|
||||||
|
u8"and let user specified texture pack work.",
|
||||||
|
Shared::Utility::QuoteObjectName(tex).c_str());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
} // namespace BMapInspector::Ruleset
|
} // namespace BMapInspector::Ruleset
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ namespace BMapInspector::Ruleset {
|
|||||||
/**
|
/**
|
||||||
* @brief YYC12345 Rule 4
|
* @brief YYC12345 Rule 4
|
||||||
* @details
|
* @details
|
||||||
* \li Check the video format for opaque and transparent texture respectively.
|
* Check the video format for Ballance and user-defined texture respectively.
|
||||||
* \li Warning for video format which is not used by vanilla Ballance.
|
* Report if there is non-vanilla Ballance settings.
|
||||||
* \li Warning for transparent used video format in non-Ballance textures to conserve resources.
|
|
||||||
*/
|
*/
|
||||||
class YYCRule4 : public Rule::IRule {
|
class YYCRule4 : public Rule::IRule {
|
||||||
public:
|
public:
|
||||||
@@ -71,4 +70,21 @@ namespace BMapInspector::Ruleset {
|
|||||||
void Check(Reporter::Reporter& reporter, Map::Level& level) const override;
|
void Check(Reporter::Reporter& reporter, Map::Level& level) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief YYC12345 Rule 5
|
||||||
|
* @details
|
||||||
|
* Check the save options for Ballance and user-defined texture respectively
|
||||||
|
* for reducing map size and avoid ambiguity.
|
||||||
|
*/
|
||||||
|
class YYCRule5 : public Rule::IRule {
|
||||||
|
public:
|
||||||
|
YYCRule5();
|
||||||
|
virtual ~YYCRule5();
|
||||||
|
YYCC_DELETE_COPY_MOVE(YYCRule5)
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::u8string_view GetRuleName() const override;
|
||||||
|
void Check(Reporter::Reporter& reporter, Map::Level& level) const override;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user