diff --git a/Ballance/BMapInspector/Rule.cpp b/Ballance/BMapInspector/Rule.cpp index 4384152..e18c08e 100644 --- a/Ballance/BMapInspector/Rule.cpp +++ b/Ballance/BMapInspector/Rule.cpp @@ -29,7 +29,8 @@ namespace BMapInspector::Rule { rules.emplace_back(new Ruleset::YYCRule1()); rules.emplace_back(new Ruleset::YYCRule2()); 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::BBugRule2()); rules.emplace_back(new Ruleset::BBugRule3()); @@ -59,4 +60,4 @@ namespace BMapInspector::Rule { #pragma endregion -} // namespace BMapInspector::RuleCollection +} // namespace BMapInspector::Rule diff --git a/Ballance/BMapInspector/Ruleset/BBugRules.cpp b/Ballance/BMapInspector/Ruleset/BBugRules.cpp index 3b88000..d6b44f4 100644 --- a/Ballance/BMapInspector/Ruleset/BBugRules.cpp +++ b/Ballance/BMapInspector/Ruleset/BBugRules.cpp @@ -54,9 +54,9 @@ namespace BMapInspector::Ruleset { void BBugRule3::Check(Reporter::Reporter& reporter, Map::Level& level) const { // TODO: - // This function is already presented in Ballance Blender Plugin, - // so I don't want write it in there now. - // Write this if I have spare time in future. + // This rule is complex and can be done by Ballance Blender Plugin. + // 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 diff --git a/Ballance/BMapInspector/Ruleset/GpRules.cpp b/Ballance/BMapInspector/Ruleset/GpRules.cpp index e02c0e3..d8c63d5 100644 --- a/Ballance/BMapInspector/Ruleset/GpRules.cpp +++ b/Ballance/BMapInspector/Ruleset/GpRules.cpp @@ -23,8 +23,9 @@ namespace BMapInspector::Ruleset { void GpRule1::Check(Reporter::Reporter& reporter, Map::Level& level) const { // TODO: - // Finish this rule. - // It is so complex that I don't want to implement it now. + // This rule is complex and can be done by Ballance Blender Plugin. + // 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 diff --git a/Ballance/BMapInspector/Ruleset/Shared/Name.cpp b/Ballance/BMapInspector/Ruleset/Shared/Name.cpp index e69de29..bb9215c 100644 --- a/Ballance/BMapInspector/Ruleset/Shared/Name.cpp +++ b/Ballance/BMapInspector/Ruleset/Shared/Name.cpp @@ -0,0 +1,3 @@ +#include "Name.hpp" + +namespace BMapInspector::Ruleset::Shared::Name {} diff --git a/Ballance/BMapInspector/Ruleset/YYCRules.cpp b/Ballance/BMapInspector/Ruleset/YYCRules.cpp index 214b2ce..65180ea 100644 --- a/Ballance/BMapInspector/Ruleset/YYCRules.cpp +++ b/Ballance/BMapInspector/Ruleset/YYCRules.cpp @@ -262,15 +262,15 @@ namespace BMapInspector::Ruleset { auto lower_tex_filename = strop::to_lower(tex_filename.value()); if (opaque_texs.contains(lower_tex_filename)) { if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_16_ARGB1555) { - reporter.FormatWarning(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. " - u8"This is mismatched with vanilla Ballance.", - Shared::Utility::QuoteObjectName(tex).c_str()); + reporter.FormatInfo(u8"Texture %s is Ballance opaque texture. But its video format is not ARGB1555. " + u8"This is mismatched with vanilla Ballance.", + Shared::Utility::QuoteObjectName(tex).c_str()); } } else if (transparent_texs.contains(lower_tex_filename)) { if (tex->GetVideoFormat() != V::VX_PIXELFORMAT::_32_ARGB8888) { - reporter.FormatWarning(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. " - u8"This is mismatched with vanilla Ballance.", - Shared::Utility::QuoteObjectName(tex).c_str()); + reporter.FormatInfo(u8"Texture %s is Ballance transparent texture. But its video format is not ARGB8888. " + u8"This is mismatched with vanilla Ballance.", + Shared::Utility::QuoteObjectName(tex).c_str()); } } else { switch (tex->GetVideoFormat()) { @@ -278,13 +278,13 @@ namespace BMapInspector::Ruleset { // Do nothing. break; case V::VX_PIXELFORMAT::_32_ARGB8888: - reporter.FormatWarning(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"Please check whether this is essential.", - Shared::Utility::QuoteObjectName(tex).c_str()); + 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"Please check whether this is essential.", + Shared::Utility::QuoteObjectName(tex).c_str()); break; default: - reporter.FormatWarning( + reporter.FormatInfo( u8"Texture %s is not Ballance texture. Its video format is not ARGB1555 or ARGB8888. " u8"This is mismatched with vanilla Ballance. " 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 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 diff --git a/Ballance/BMapInspector/Ruleset/YYCRules.hpp b/Ballance/BMapInspector/Ruleset/YYCRules.hpp index a4f4d3a..783efb6 100644 --- a/Ballance/BMapInspector/Ruleset/YYCRules.hpp +++ b/Ballance/BMapInspector/Ruleset/YYCRules.hpp @@ -56,9 +56,8 @@ namespace BMapInspector::Ruleset { /** * @brief YYC12345 Rule 4 * @details - * \li Check the video format for opaque and transparent texture respectively. - * \li Warning for video format which is not used by vanilla Ballance. - * \li Warning for transparent used video format in non-Ballance textures to conserve resources. + * Check the video format for Ballance and user-defined texture respectively. + * Report if there is non-vanilla Ballance settings. */ class YYCRule4 : public Rule::IRule { public: @@ -71,4 +70,21 @@ namespace BMapInspector::Ruleset { 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; + }; + }