From 103cb496a2caa2f106a885e0d12194970bc57bc6 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 30 Jan 2026 20:40:21 +0800 Subject: [PATCH] feat: update BMapInspector --- Ballance/BMapInspector/BMapInspector.cpp | 18 +++++++++++++++--- Ballance/BMapInspector/Ruleset.cpp | 4 ++++ Ballance/BMapInspector/Ruleset.hpp | 5 ++++- Ballance/BMapInspector/Utils.cpp | 4 +--- Ballance/BMapInspector/Utils.hpp | 4 +++- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Ballance/BMapInspector/BMapInspector.cpp b/Ballance/BMapInspector/BMapInspector.cpp index 0b6cc04..ec8d904 100644 --- a/Ballance/BMapInspector/BMapInspector.cpp +++ b/Ballance/BMapInspector/BMapInspector.cpp @@ -1,11 +1,14 @@ #include "Utils.hpp" +#include "Ruleset.hpp" #include #include #include +#include #include #include using namespace yycc::patch::stream; +namespace strop = yycc::string::op; namespace termcolor = yycc::carton::termcolor; int main(int argc, char *argv[]) { @@ -13,14 +16,23 @@ int main(int argc, char *argv[]) { // Show splash std::cout << termcolor::colored(u8"Ballance Map Inspector", termcolor::Color::LightYellow) << " (based on LibCmo " LIBCMO_VER_STR ") built at " __DATE__ " " __TIME__ << std::endl - << u8"The inspector for checking whether your Ballance custom map can be loaded without any issues." << std::endl; + << u8"The inspector for checking whether your Ballance custom map can be loaded without any issues." << std::endl + << std::endl; // Create reporter BMapInspector::Utils::Reporter reporter; - // Show report + // Get rule collection + BMapInspector::Ruleset::RuleCollection rule_collection; + // Show rule infos + std::cout << strop::printf(u8"Total %" PRIuSIZET " rule(s) are loaded.", rule_collection.GetRuleCount()) << std::endl + << u8"Check may take few minutes. Please do not close this console..." << std::endl + << std::endl; + + // Show report conclusion reporter.PrintConclusion(); - reporter.PrintDetails(); + // Print report in detail + reporter.PrintReport(); return 0; } diff --git a/Ballance/BMapInspector/Ruleset.cpp b/Ballance/BMapInspector/Ruleset.cpp index eff1531..b73344f 100644 --- a/Ballance/BMapInspector/Ruleset.cpp +++ b/Ballance/BMapInspector/Ruleset.cpp @@ -18,6 +18,10 @@ namespace BMapInspector::Ruleset { RuleCollection::~RuleCollection() {} + size_t RuleCollection::GetRuleCount() const { + return this->rules.size(); + } + const std::vector& RuleCollection::GetRules() const { return this->rules; } diff --git a/Ballance/BMapInspector/Ruleset.hpp b/Ballance/BMapInspector/Ruleset.hpp index 2671cc4..2a5a9cf 100644 --- a/Ballance/BMapInspector/Ruleset.hpp +++ b/Ballance/BMapInspector/Ruleset.hpp @@ -1,4 +1,6 @@ #pragma once +#include "Utils.hpp" +#include #include #include #include @@ -15,7 +17,7 @@ namespace BMapInspector::Ruleset { public: virtual std::u8string_view GetRuleName() const = 0; - virtual void Check() const = 0; + virtual void Check(Utils::Reporter& reporter) const = 0; }; class RuleCollection { @@ -25,6 +27,7 @@ namespace BMapInspector::Ruleset { YYCC_DELETE_COPY_MOVE(RuleCollection) public: + size_t GetRuleCount() const; const std::vector &GetRules() const; private: diff --git a/Ballance/BMapInspector/Utils.cpp b/Ballance/BMapInspector/Utils.cpp index 820ee37..832b959 100644 --- a/Ballance/BMapInspector/Utils.cpp +++ b/Ballance/BMapInspector/Utils.cpp @@ -9,8 +9,6 @@ using namespace yycc::patch::stream; namespace strop = yycc::string::op; namespace termcolor = yycc::carton::termcolor; -#define PRIuSIZET "zu" - namespace BMapInspector::Utils { #pragma region Reporter @@ -84,7 +82,7 @@ namespace BMapInspector::Utils { termcolor::Color::LightBlue); } - void Reporter::PrintDetails() const { + void Reporter::PrintReport() const { // Print all entries by different color for (const auto &report : this->reports) { switch (report.kind) { diff --git a/Ballance/BMapInspector/Utils.hpp b/Ballance/BMapInspector/Utils.hpp index 0d75772..f0cfe3e 100644 --- a/Ballance/BMapInspector/Utils.hpp +++ b/Ballance/BMapInspector/Utils.hpp @@ -5,6 +5,8 @@ #include #include +#define PRIuSIZET "zu" + namespace BMapInspector::Utils { enum class ReportKind { Error, Warning, Info }; @@ -34,7 +36,7 @@ namespace BMapInspector::Utils { public: void PrintConclusion() const; - void PrintDetails() const; + void PrintReport() const; private: std::vector reports;