1
0

feat: update BMapInspector

This commit is contained in:
2026-01-30 20:40:21 +08:00
parent 8dfa4bd039
commit 103cb496a2
5 changed files with 27 additions and 8 deletions

View File

@@ -1,11 +1,14 @@
#include "Utils.hpp"
#include "Ruleset.hpp"
#include <VTAll.hpp>
#include <yycc.hpp>
#include <yycc/carton/termcolor.hpp>
#include <yycc/string/op.hpp>
#include <yycc/patch/stream.hpp>
#include <iostream>
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;
}

View File

@@ -18,6 +18,10 @@ namespace BMapInspector::Ruleset {
RuleCollection::~RuleCollection() {}
size_t RuleCollection::GetRuleCount() const {
return this->rules.size();
}
const std::vector<IRule*>& RuleCollection::GetRules() const {
return this->rules;
}

View File

@@ -1,4 +1,6 @@
#pragma once
#include "Utils.hpp"
#include <VTAll.hpp>
#include <yycc.hpp>
#include <yycc/macro/class_copy_move.hpp>
#include <string>
@@ -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<IRule *> &GetRules() const;
private:

View File

@@ -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) {

View File

@@ -5,6 +5,8 @@
#include <string_view>
#include <vector>
#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<Report> reports;