diff --git a/resource/excel/Group.xlsx b/resource/excel/Group.xlsx index 70021905..9f97bf0b 100644 Binary files a/resource/excel/Group.xlsx and b/resource/excel/Group.xlsx differ diff --git a/resource/excel/Player.xlsx b/resource/excel/Player.xlsx index 24005403..3ffe3c4f 100644 Binary files a/resource/excel/Player.xlsx and b/resource/excel/Player.xlsx differ diff --git a/resource/excel/Scene.xlsx b/resource/excel/Scene.xlsx index ff8ac005..abbb6b4d 100644 Binary files a/resource/excel/Scene.xlsx and b/resource/excel/Scene.xlsx differ diff --git a/resource/excel/common/IObject.xlsx b/resource/excel/common/IObject.xlsx index ef76d7cd..f85b6ae7 100644 Binary files a/resource/excel/common/IObject.xlsx and b/resource/excel/common/IObject.xlsx differ diff --git a/resource/excel/example/Property.xlsx b/resource/excel/example/Property.xlsx index cb63180d..14689407 100644 Binary files a/resource/excel/example/Property.xlsx and b/resource/excel/example/Property.xlsx differ diff --git a/resource/excel/example/Record.xlsx b/resource/excel/example/Record.xlsx index 4d7e1e6a..96413e9b 100644 Binary files a/resource/excel/example/Record.xlsx and b/resource/excel/example/Record.xlsx differ diff --git a/src/squick/plugin/config/class_module.cc b/src/squick/plugin/config/class_module.cc index 96a695c6..5dac78c7 100644 --- a/src/squick/plugin/config/class_module.cc +++ b/src/squick/plugin/config/class_module.cc @@ -6,11 +6,11 @@ #include #include #include -ClassModule::ClassModule() { mConfigFileName = "config/struct/logic_class.xml"; } +ClassModule::ClassModule() { mConfigFileName = "config/struct/Root.xml"; } ClassModule::ClassModule(IPluginManager *p) { pm_ = p; - mConfigFileName = "config/struct/logic_class.xml"; + mConfigFileName = "config/struct/Root.xml"; #ifdef DEBUG std::cout << "Using [" << pm_->GetWorkPath() << "/" + mConfigFileName << "]" << std::endl; diff --git a/src/tools/sqkctl/excel/config_generator.cc b/src/tools/sqkctl/excel/config_generator.cc index b6b06598..f046c73a 100644 --- a/src/tools/sqkctl/excel/config_generator.cc +++ b/src/tools/sqkctl/excel/config_generator.cc @@ -15,12 +15,8 @@ ConfigGenerator::ConfigGenerator(const std::string &excelPath, const std::string mxGenerators.push_back(new CPPGenerator(excelPath, outPath)); mxGenerators.push_back(new CSGenerator(excelPath, outPath)); mxGenerators.push_back(new IniGenerator(excelPath, outPath)); - mxGenerators.push_back(new JAVAGenerator(excelPath, outPath)); mxGenerators.push_back(new LogicClassGenerator(excelPath, outPath)); - mxGenerators.push_back(new PBGenerator(excelPath, outPath)); - mxGenerators.push_back(new SQLGenerator(excelPath, outPath)); mxGenerators.push_back(new StructGenerator(excelPath, outPath)); - mxGenerators.push_back(new TSGenerator(excelPath, outPath)); mxGenerators.push_back(new LuaGenerator(excelPath, outPath)); strExcelIniPath = excelPath; diff --git a/src/tools/sqkctl/excel/config_generator.h b/src/tools/sqkctl/excel/config_generator.h index d4396c38..36c3ab8c 100644 --- a/src/tools/sqkctl/excel/config_generator.h +++ b/src/tools/sqkctl/excel/config_generator.h @@ -3,15 +3,11 @@ #include "cpp_generator.h" #include "cs_generator.h" #include "ini_generator.h" -#include "java_generator.h" #include "logic_class_generator.h" #include "lua_generator.h" #include "mini_excel_reader.h" -#include "pb_generator.h" -#include "sql_generator.h" #include "struct_generator.h" #include "third_party/common/lexical_cast.hpp" -#include "ts_generator.h" #include namespace sqkctl { @@ -50,9 +46,10 @@ class ConfigGenerator { private: bool bConvertIntoUTF8 = false; - const int nPropertyHeight = 10; // property line - const int nRecordHeight = 13; // record line - const int nRecordDescHeight = 9; // record line + // Excel base header attr line define + const int nPropertyHeight = 3; // property line + const int nRecordHeight = 6; // record line + const int nRecordDescHeight = 2; // record line std::string outPath; std::string strExcelIniPath; // = "../excel/"; diff --git a/src/tools/sqkctl/excel/java_generator.h b/src/tools/sqkctl/excel/java_generator.h deleted file mode 100644 index df5b8b2a..00000000 --- a/src/tools/sqkctl/excel/java_generator.h +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class JAVAGenerator : public IGenerator { - public: - JAVAGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - - FILE *javaWriter = fopen((outPath + "/excel/Excel.java").c_str(), "w"); - - std::string strFileHead = "// -------------------------------------------------------------------------\n"; - strFileHead = strFileHead + "// @FileName : Excel.java\n" + "// @Author : I0gan\n" + - "// @Module : Excel\n" + "// -------------------------------------------------------------------------\n\n" + - "package Excel;\n"; - - fwrite(strFileHead.c_str(), strFileHead.length(), 1, javaWriter); - ///////////////////////////////////////////////////// - - ClassData *pBaseObject = classData.at("IObject"); - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - // cs - std::string strPropertyInfo; - - strPropertyInfo += "\tpublic class " + className + "\n\t{\n"; - strPropertyInfo += "\t\t//Class name\n\t"; - strPropertyInfo += "\tpublic static final String ThisName = \"" + className + "\";\n"; - - if (className != "IObject") { - // add base class properties - strPropertyInfo += "\t\t// IObject\n"; - - for (std::map::iterator itProperty = pBaseObject->xStructData.xPropertyList.begin(); - itProperty != pBaseObject->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static final String " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - strPropertyInfo += "\t\t// Property\n"; - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static final String " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - - fwrite(strPropertyInfo.c_str(), strPropertyInfo.length(), 1, javaWriter); - - // record - std::string strRecordInfo = ""; - strRecordInfo += "\t\t// Record\n"; - - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - std::cout << "save for java ---> " << className << "::" << recordName << std::endl; - - strRecordInfo += "\t\tpublic class " + recordName + "\n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\tpublic static final String ThisName = \"" + recordName + "\";\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - strRecordInfo += - "\t\t\tpublic static final int " + colTag + " = " + std::to_string(pRecordColDesc->index) + ";//" + pRecordColDesc->type + "\n"; - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - fwrite(strRecordInfo.c_str(), strRecordInfo.length(), 1, javaWriter); - - std::string strHppEnumInfo = ""; - - std::string strClassEnd; - strClassEnd += "\n\t}\n"; - - fwrite(strClassEnd.c_str(), strClassEnd.length(), 1, javaWriter); - } - fclose(javaWriter); - - return false; - } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/logic_class_generator.h b/src/tools/sqkctl/excel/logic_class_generator.h index 7ae87842..95c0f52e 100644 --- a/src/tools/sqkctl/excel/logic_class_generator.h +++ b/src/tools/sqkctl/excel/logic_class_generator.h @@ -8,7 +8,7 @@ class LogicClassGenerator : public IGenerator { LogicClassGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } virtual bool Generate(const std::map &classData) override { - std::string fileName = strXMLStructPath + "logic_class.xml"; + std::string fileName = strXMLStructPath + "Root.xml"; FILE *iniWriter = fopen(fileName.c_str(), "w"); diff --git a/src/tools/sqkctl/excel/pb_generator.h b/src/tools/sqkctl/excel/pb_generator.h deleted file mode 100644 index 09afe91b..00000000 --- a/src/tools/sqkctl/excel/pb_generator.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class PBGenerator : public IGenerator { - public: - PBGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { return false; } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/sql_generator.h b/src/tools/sqkctl/excel/sql_generator.h deleted file mode 100644 index a7676df5..00000000 --- a/src/tools/sqkctl/excel/sql_generator.h +++ /dev/null @@ -1,124 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class SQLGenerator : public IGenerator { - - public: - SQLGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - // 1 class.sql - std::string fileName = outPath + "/excel/server.sql"; - - FILE *iniWriter = fopen(fileName.c_str(), "w"); - - std::string strElementData; - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - strElementData += "CREATE TABLE IF NOT EXISTS " + pClassDta->xStructData.className + " ("; - strElementData += " `ID` varchar(128) NOT NULL,"; - strElementData += " PRIMARY KEY (`ID`)"; - strElementData += " ) ENGINE=InnoDB DEFAULT CHARSET=utf8; \n"; - } - - // 2 fields - // ALTER TABLE `Buff` ADD `EffectType` bigint(11) DEFAULT '0' COMMENT '影响属性类型(效果类型) 生命,法力(可组合,叠加)'; - // 2.1) property - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *xPropertyData = itProperty->second; - - std::string strType; - std::string strSave; - std::string strCache; - std::string strDesc; - for (std::map::iterator itDesc = xPropertyData->descList.begin(); itDesc != xPropertyData->descList.end(); ++itDesc) { - const std::string &strKey = itDesc->first; - const std::string &value = itDesc->second; - if (strKey == "Type") { - strType = value; - } else if (strKey == "Save") { - strSave = value; - } else if (strKey == "Cache") { - strCache = value; - } else if (strKey == "Desc") { - strDesc = value; - } - } - - if (strSave == "1" || strCache == "1") { - std::string strAlter = "\nALTER TABLE `" + className + "` ADD `" + propertyName + "`"; - // ALTER TABLE `Buff` ADD `EffectType` bigint(11) DEFAULT '0' COMMENT '影响属性类型(效果类型) 生命,法力(可组合,叠加)'; - if (strType == "int") { - strAlter += " bigint(11) DEFAULT '0'"; - } else if (strType == "string") { - strAlter += " text COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "float") { - strAlter += " double DEFAULT '0.0'"; - } else if (strType == "object") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "vector2") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } else if (strType == "vector3") { - strAlter += " varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT ''"; - } - - strAlter += " COMMENT '" + strDesc + "';"; - - strElementData += strAlter; - } - } - - // 2.2) record - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *xRecordData = itRecord->second; - - std::string strType; - std::string strSave; - std::string strCache; - std::string strDesc; - for (std::map::iterator itDesc = xRecordData->descList.begin(); itDesc != xRecordData->descList.end(); ++itDesc) { - const std::string &strKey = itDesc->first; - const std::string &value = itDesc->second; - if (strKey == "Type") { - strType = value; - } else if (strKey == "Save") { - strSave = value; - } else if (strKey == "Cache") { - strCache = value; - } else if (strKey == "Desc") { - strDesc = value; - } - } - - if (strSave == "1" || strCache == "1") { - std::string strAlter = "\nALTER TABLE `" + className + "` ADD `" + recordName + "`"; - strAlter += " text COLLATE utf8mb4_unicode_ci DEFAULT ''"; - strAlter += " COMMENT '" + strDesc + "';"; - - strElementData += strAlter; - } - } - } - - fwrite(strElementData.c_str(), strElementData.length(), 1, iniWriter); - fclose(iniWriter); - - return true; - } -}; -} // namespace sqkctl diff --git a/src/tools/sqkctl/excel/ts_generator.h b/src/tools/sqkctl/excel/ts_generator.h deleted file mode 100644 index 405154b5..00000000 --- a/src/tools/sqkctl/excel/ts_generator.h +++ /dev/null @@ -1,167 +0,0 @@ -#pragma once - -#include "i_generator.h" -namespace sqkctl { -class TSGenerator : public IGenerator { - public: - TSGenerator(const std::string &excelPath, const std::string &outPath) { SetPath(excelPath, outPath); } - - virtual bool Generate(const std::map &classData) override { - - FILE *csWriter = fopen((outPath + "/excel/excel.ts").c_str(), "w"); - - std::string strFileHead = "// -------------------------------------------------------------------------\n"; - strFileHead = strFileHead + "// @FileName : excel.ts\n" + "// @Author : I0gan\n" + - "// @Module : Excel\n" + "// -------------------------------------------------------------------------\n\n"; - fwrite(strFileHead.c_str(), strFileHead.length(), 1, csWriter); - - ClassData *pBaseObject = classData.at("IObject"); - std::string allClassNames = "export const Excel={\n\t\t"; - for (std::map::const_iterator it = classData.begin(); it != classData.end(); ++it) { - const std::string &className = it->first; - ClassData *pClassDta = it->second; - - if (pClassDta->beIncluded || pClassDta->beParted || className == "Include") { - continue; - } - - // ts - std::string strPropertyInfo; - if (it != classData.begin()) { - allClassNames += ','; - } - allClassNames += className; - - strPropertyInfo += "\tclass " + className + "\n\t{\n"; - strPropertyInfo += "\t\t//Class name\n\t"; - strPropertyInfo += "\tpublic static ThisName = \"" + className + "\";\n"; - if (className != "IObject") { - // add base class properties - strPropertyInfo += "\t\t// IObject\n"; - - for (std::map::iterator itProperty = pBaseObject->xStructData.xPropertyList.begin(); - itProperty != pBaseObject->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - strPropertyInfo += "\t\t// Property\n"; - for (std::map::iterator itProperty = pClassDta->xStructData.xPropertyList.begin(); - itProperty != pClassDta->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - - // include property, come from - - for (std::string item : pClassDta->includes) { - auto includeClass = classData.at(item); - - strPropertyInfo += "\t\t// Include Property, come from " + includeClass->xStructData.className + " \n"; - - for (std::map::iterator itProperty = includeClass->xStructData.xPropertyList.begin(); - itProperty != includeClass->xStructData.xPropertyList.end(); ++itProperty) { - const std::string &propertyName = itProperty->first; - ClassProperty *pClassProperty = itProperty->second; - - strPropertyInfo += "\t\tpublic static " + propertyName + " = \"" + propertyName + "\";"; - strPropertyInfo += "// " + pClassProperty->descList["Type"] + "\n"; - } - } - - fwrite(strPropertyInfo.c_str(), strPropertyInfo.length(), 1, csWriter); - - // record - std::string strRecordInfo = ""; - strRecordInfo += "\t\t// Record\n"; - - for (std::map::iterator itRecord = pClassDta->xStructData.xRecordList.begin(); - itRecord != pClassDta->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - std::cout << "save for ts ---> " << className << "::" << recordName << std::endl; - - strRecordInfo += "\t\tpublic static " + recordName + " = \n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\t\"ThisName\":\"" + recordName + "\",\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - if (i != 0) { - strRecordInfo += ",\n"; - } - strRecordInfo += "\t\t\t\"" + colTag + "\":" + std::to_string(pRecordColDesc->index); - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - - for (std::string item : pClassDta->includes) { - auto includeClass = classData.at(item); - - strRecordInfo += "\t\t// Include Record, come from " + includeClass->xStructData.className + " \n"; - - for (std::map::iterator itRecord = includeClass->xStructData.xRecordList.begin(); - itRecord != includeClass->xStructData.xRecordList.end(); ++itRecord) { - const std::string &recordName = itRecord->first; - ClassRecord *pClassRecord = itRecord->second; - - strRecordInfo += "\t\tpublic static " + recordName + " = \n\t\t{\n"; - strRecordInfo += "\t\t\t//Class name\n\t"; - strRecordInfo += "\t\t\"ThisName\":\"" + recordName + "\",\n"; - - // col - for (int i = 0; i < pClassRecord->colList.size(); ++i) { - for (std::map::iterator itCol = pClassRecord->colList.begin(); - itCol != pClassRecord->colList.end(); ++itCol) { - - const std::string &colTag = itCol->first; - ClassRecord::RecordColDesc *pRecordColDesc = itCol->second; - - if (pRecordColDesc->index == i) { - if (i != 0) { - strRecordInfo += ",\n"; - } - strRecordInfo += "\t\t\t\"" + colTag + "\":" + std::to_string(pRecordColDesc->index); - } - } - } - - strRecordInfo += "\n\t\t}\n"; - } - } - - fwrite(strRecordInfo.c_str(), strRecordInfo.length(), 1, csWriter); - - std::string strHppEnumInfo = ""; - - std::string strClassEnd; - strClassEnd += "\n\t}\n"; - - fwrite(strClassEnd.c_str(), strClassEnd.length(), 1, csWriter); - } - allClassNames += "}\n"; - fwrite(allClassNames.c_str(), allClassNames.length(), 1, csWriter); - fclose(csWriter); - - return false; - } -}; -} // namespace sqkctl