├── Classes ├── CsvToScript.cpp └── CsvToScript.h ├── README.md ├── mac └── Csv2Script │ ├── Csv2Script.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── welove.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── welove.xcuserdatad │ │ └── xcschemes │ │ ├── Csv2Script.xcscheme │ │ └── xcschememanagement.plist │ ├── Csv2Script │ └── main.cpp │ └── example │ ├── Csv2Script │ ├── csv │ ├── role.csv │ └── skill.csv │ ├── export │ ├── DB_Role.cpp │ ├── DB_Role.h │ ├── DB_Role.txt │ ├── DB_Skill.cpp │ ├── DB_Skill.h │ └── DB_Skill.txt │ └── run.sh └── win └── Csv2Script ├── Csv2Script.VC.db ├── Csv2Script.sln ├── Csv2Script ├── Csv2Script.cpp ├── Csv2Script.vcxproj ├── Csv2Script.vcxproj.filters ├── Debug │ ├── Csv2Script.tlog │ │ ├── CL.command.1.tlog │ │ ├── CL.read.1.tlog │ │ ├── CL.write.1.tlog │ │ ├── Csv2Script.lastbuildstate │ │ ├── link.command.1.tlog │ │ ├── link.read.1.tlog │ │ └── link.write.1.tlog │ └── vc140.idb ├── ReadMe.txt ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── Debug ├── csv │ ├── role.csv │ └── skill.csv ├── export │ ├── DB_Skill.cpp │ ├── DB_Skill.h │ ├── DB_Skill.txt │ ├── DataSingletonManager.cpp │ └── DataSingletonManager.h └── run.bat └── ipch ├── CSV2SCRIPT-801f5e5e └── CSV2SCRIPT-24f117f.ipch └── CSV2SCRIPT-e1b95e18 └── CSV2SCRIPT-24f117f.ipch /Classes/CsvToScript.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "CsvToScript.h" 3 | #include 4 | #include 5 | 6 | 7 | enum AttType{ 8 | stringType = 0, 9 | intType = 1, 10 | boolType = 2, 11 | objectType = 3, 12 | classType = 4, 13 | }; 14 | 15 | CsvToScript::CsvToScript(){ 16 | typeVector = {"string","int","bool","object","class"};//now only three type,bool just contain 0 or 1 17 | } 18 | // read file 19 | bool CsvToScript::readFile(const string &filename, string &content) 20 | { 21 | content.clear(); 22 | 23 | 24 | struct stat st; 25 | 26 | if (stat (filename.c_str(), &st) >= 0) { 27 | 28 | //char *pFileContent = (char *)malloc(st.st_size + 1); 29 | //FILE *outfile = fopen(filename.c_str(), "r"); 30 | //fread(pFileContent, sizeof(char), st.st_size, outfile); 31 | //fclose(outfile); 32 | 33 | char *pFileContent = (char *)malloc(st.st_size+1); 34 | if (pFileContent == NULL) { 35 | cout << "Error: failed to malloc size= " << st.st_size << " memory." << endl; 36 | exit(-1); 37 | } 38 | pFileContent[st.st_size] = '\0'; 39 | FILE *fp_cfg = fopen(filename.c_str(), "r"); 40 | int count = 0; 41 | while (count < st.st_size) { 42 | fread(pFileContent, 1, st.st_size, fp_cfg); 43 | count++; 44 | } 45 | fclose(fp_cfg); 46 | 47 | content.append(pFileContent); 48 | free (pFileContent); 49 | } else { 50 | cout << "Error: can`t find file: " << filename << endl; 51 | return false; 52 | } 53 | 54 | return true; 55 | } 56 | vector CsvToScript::splitStringByDelim (const string str, const string delim) 57 | { 58 | vector vct; 59 | string::size_type prev_pos=0, curr_pos=0; 60 | 61 | while ((curr_pos = str.find(delim, curr_pos)) != string::npos) { 62 | string sub_str(str.substr(prev_pos, curr_pos-prev_pos)); 63 | curr_pos += delim.length(); 64 | prev_pos = curr_pos; 65 | vct.push_back(sub_str); 66 | } 67 | 68 | return vct; 69 | } 70 | vector CsvToScript::parseCsvLine(const string str) 71 | { 72 | vector vct; 73 | char *pos01=NULL, *pos02=NULL; 74 | int dmq = 0; 75 | 76 | char *str00 = (char*) malloc(str.length()+1); 77 | str00[str.length()] = 0; 78 | strncpy(str00, str.c_str(), str.length()); 79 | 80 | char *pstr00 = NULL; 81 | pstr00 = str00; 82 | long offset = 0; 83 | while((pos01 = strchr(str00 + offset, ',')) != NULL) { 84 | dmq = 0; 85 | char *str02 = NULL; 86 | char *pstr02 = NULL; 87 | if (pos01 != str00) { 88 | str02 = (char *) malloc(pos01 - str00 + 1); 89 | strncpy(str02, str00, pos01 - str00); 90 | str02[pos01 - str00] = 0; 91 | } 92 | pstr02 = str02; 93 | while (str02 != NULL && (pos02 = strchr(str02, '"')) != NULL) { 94 | dmq ++; 95 | str02 = pos02 +1; 96 | } 97 | if (pstr02) 98 | free(pstr02); 99 | if (dmq%2 == 1) { 100 | offset = pos01-str00+1; 101 | continue; 102 | } 103 | char* str01 = NULL; 104 | 105 | if (pos01 != str00) { 106 | str01 = (char *) malloc(pos01 - str00 + 1); 107 | strncpy(str01, str00, pos01 - str00); 108 | str01[pos01 - str00] = 0; 109 | } 110 | char *pstr01 = str01; 111 | str00 = pos01 + 1; 112 | offset = 0; 113 | 114 | if (str01) { 115 | if (str01[0] == 0x22) 116 | str01 ++; 117 | if (str01[strlen(str01)-1] == 0x22) 118 | str01[strlen(str01)-1] = 0; 119 | vct.push_back(str01); 120 | free(pstr01); 121 | } else { 122 | vct.push_back(""); 123 | } 124 | } 125 | if (str00 - pstr00 != str.length()) { 126 | string finalstr = str.substr(str00-pstr00); 127 | if (finalstr.length() > 0 && finalstr.c_str()[0] == '"') { 128 | finalstr.erase(0, 1); 129 | } 130 | if (finalstr.length() > 0 && finalstr.c_str()[finalstr.length()-1] == '"') { 131 | finalstr.erase(finalstr.length()-1); 132 | } 133 | vct.push_back(finalstr); 134 | } 135 | 136 | free(pstr00); 137 | 138 | return vct; 139 | } 140 | void string_replace(string&s1,const string&s2,const string&s3) 141 | { 142 | string::size_type pos=0; 143 | string::size_type a=s2.size(); 144 | string::size_type b=s3.size(); 145 | while((pos=s1.find(s2,pos))!=string::npos) 146 | { 147 | s1.replace(pos,a,s3); 148 | pos+=b; 149 | } 150 | } 151 | void CsvToScript::csvToScript(string csvFile,string path,string proj){ 152 | string sStr = csvFile; 153 | sStr[0] = toupper(sStr[0]); 154 | string_replace(sStr,".csv",""); 155 | 156 | m_dir = path; 157 | m_proj = proj; 158 | fileName = sStr; 159 | 160 | structName = "F"; 161 | structName.append(fileName); 162 | // expect csv 163 | string::size_type pos = csvFile.find(".csv"); 164 | if (pos == string::npos || pos != (csvFile.length() - 4)) { 165 | cout << "Warning: " << m_dir << "/" << csvFile << " is not a regular csv file." << endl; 166 | exit(-1); 167 | } 168 | // get path 169 | string csvFullFilename(m_dir); 170 | csvFullFilename.append("/csv/"); 171 | csvFullFilename.append(csvFile); 172 | 173 | vector attributes;//type 174 | vector attrinames;//value name 175 | string txtContent;//out txt 176 | 177 | 178 | string cfgFileContent; 179 | vector fileLines; 180 | // read csv 181 | readFile (csvFullFilename, cfgFileContent); 182 | if (cfgFileContent.length() > 0) { 183 | vector tmpV = splitStringByDelim(cfgFileContent, "\n"); 184 | 185 | if (tmpV.size() < 4) { 186 | cout << "Error. File " << csvFullFilename << " \'s row is illegal. we need at least 4 rows. but the file only contains " << tmpV.size() << " rows." << endl; 187 | exit(-1); 188 | } 189 | 190 | vector::iterator itr=tmpV.begin(); 191 | // expect first cow 192 | itr ++; 193 | // parse type 194 | attributes = parseCsvLine(*itr); 195 | // check type and name 196 | for (int i = 0; i < attributes.size(); i ++) { 197 | bool isHave = false; 198 | for (int j = 0; j tmpV01 = parseCsvLine(*itr); 227 | for (int i = 0; i < tmpV01.size(); i ++) { 228 | string value = tmpV01.at(i); 229 | //check first row is int 230 | if (i == 0) { 231 | if (value.compare("")==0 || attributes.at(0).compare(typeVector[intType])!=0 || std::atoi(value.c_str()) <= 0) { 232 | cout << "Error. the " << attributes.at(0) << " is null. or not type int" << endl; 233 | exit(-1); 234 | } 235 | } 236 | if (attributes.at(i).compare(typeVector[boolType])==0) { 237 | if (!(value.compare("0") == 0||value.compare("1")==0)) { 238 | cout << "Error. File " << csvFullFilename << ". The type bool error." << endl; 239 | exit(-1); 240 | } 241 | } 242 | else if(attributes.at(i).compare(typeVector[stringType])==0){ 243 | // string_replace(value,"\"","\""); 244 | string_replace(value,",","."); 245 | }else if (attributes.at(i).compare(typeVector[intType])==0){ 246 | if (value.compare("") == 0) { 247 | value = "0"; 248 | } 249 | }else if (attributes.at(i).compare(typeVector[objectType]) == 0){ 250 | string_replace(value, ",", "."); 251 | }else if (attributes.at(i).compare(typeVector[classType]) == 0){ 252 | string_replace(value, ",", "."); 253 | } 254 | txtContent.append(value).append(","); 255 | 256 | } 257 | } 258 | } 259 | string outFullFilename(m_dir); 260 | outFullFilename.append("/export/DB_"); 261 | outFullFilename.append(fileName).append(".txt"); 262 | 263 | FILE *fp = fopen (outFullFilename.c_str(), "w"); 264 | if (fp == NULL) { 265 | printf ("Error: failed to open file %s, %s\n", outFullFilename.c_str(), strerror(errno)); 266 | exit(-1); 267 | } 268 | fprintf(fp, "%s", txtContent.c_str()); 269 | 270 | fflush(fp); 271 | fclose(fp); 272 | 273 | 274 | writeHeadScript(attrinames, attributes); 275 | writeCppScript(attrinames,attributes); 276 | } 277 | 278 | void CsvToScript::writeHeadScript(vector attrinames,vector attributes){ 279 | string PROJ = m_proj; 280 | 281 | //upper 282 | for (int i = 0; i < PROJ.size(); i++) { 283 | PROJ[i] = toupper(PROJ[i]); 284 | } 285 | //write .h 286 | string className = "DB_"; 287 | className.append(fileName); 288 | //write include 289 | string dataStr; 290 | dataStr.append("#pragma once\n\n"); 291 | dataStr.append("#include \"Kismet/BlueprintFunctionLibrary.h\"\n"); 292 | dataStr.append("#include \"").append(className).append(".generated.h\"\n\n"); 293 | //write struct 294 | dataStr.append("USTRUCT(BlueprintType)\n"); 295 | dataStr.append("struct ").append(structName).append("\n"); 296 | dataStr.append("{\n"); 297 | dataStr.append(" GENERATED_USTRUCT_BODY()\n"); 298 | dataStr.append("public:\n"); 299 | dataStr.append(" ").append(structName).append("(){};\n"); 300 | for (int i =0; i getAll").append(fileName).append("DB();\n"); 332 | dataStr.append("};\n"); 333 | 334 | 335 | string outHeadFilename(m_dir); 336 | outHeadFilename.append("/export/DB_"); 337 | outHeadFilename.append(fileName).append(".h"); 338 | 339 | FILE *fp = fopen (outHeadFilename.c_str(), "w"); 340 | if (fp == NULL) { 341 | printf ("Error: failed to open file %s, %s\n", outHeadFilename.c_str(), strerror(errno)); 342 | exit(-1); 343 | } 344 | fprintf(fp, "%s", dataStr.c_str()); 345 | 346 | fflush(fp); 347 | fclose(fp); 348 | 349 | } 350 | void CsvToScript::writeCppScript(vector attrinames, vector attributes) 351 | { 352 | string PROJ = m_proj; 353 | //upper 354 | for (int i = 0; i < PROJ.size(); i++) { 355 | PROJ[i] = toupper(PROJ[i]); 356 | } 357 | 358 | string className = "DB_"; 359 | className.append(fileName); 360 | 361 | string dataStr= ""; 362 | dataStr.append("#include \"").append(m_proj).append(".h\"\n"); 363 | dataStr.append("#include \"").append(className).append(".h\"\n\n"); 364 | // 365 | 366 | dataStr.append("static TMap m_map;\n\n"); 367 | dataStr.append("UDB_").append(fileName).append("::UDB_").append(fileName).append("()\n"); 368 | dataStr.append("{\n loadData();\n}\n"); 369 | // add loadData function 370 | dataStr.append("bool UDB_").append(fileName).append("::loadData()\n"); 371 | dataStr.append("{\n"); 372 | dataStr.append(" m_map.Empty();\n"); 373 | dataStr.append(" FString path = FPaths::GameDir() + \"Content/DB/DB_").append(fileName).append(".txt\";\n"); 374 | dataStr.append(" if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*path))\n"); 375 | dataStr.append(" return false;\n"); 376 | dataStr.append(" TArray db;\n"); 377 | dataStr.append(" FString contentStr;\n"); 378 | dataStr.append(" FFileHelper::LoadFileToString(contentStr,*path);\n"); 379 | dataStr.append(" contentStr.ParseIntoArray(db, TEXT(\"\\n\"), false);\n"); 380 | dataStr.append(" for (int i = 0; i < db.Num(); i++)\n"); 381 | dataStr.append(" {\n"); 382 | dataStr.append(" FString aString = db[i];\n"); 383 | dataStr.append(" TArray array = {};\n"); 384 | dataStr.append(" aString.ParseIntoArray(array, TEXT(\",\"), false);\n"); 385 | dataStr.append(" ").append(structName).append(" dbS;\n"); 386 | for (int i =0; i(NULL, *array[").append(to_string(i)).append("]);\n"); 410 | dataStr.append(valueStr); 411 | } 412 | else if (attributes.at(i).compare(typeVector[classType]) == 0) 413 | { 414 | string valueStr = " dbS."; 415 | valueStr.append(attrinames.at(i)); 416 | valueStr.append(" = LoadClass(NULL, *array[").append(to_string(i)).append("]);\n"); 417 | dataStr.append(valueStr); 418 | } 419 | 420 | } 421 | dataStr.append(" m_map.Add(dbS.").append(attrinames.at(0)).append(", dbS);\n"); 422 | dataStr.append(" }\n"); 423 | dataStr.append(" return true;\n"); 424 | dataStr.append("}\n\n"); 425 | //add getXXXById() function 426 | dataStr.append(structName).append(" UDB_").append(fileName).append("::get").append(fileName).append("ById(int32 _id)\n"); 427 | dataStr.append("{\n"); 428 | dataStr.append(" return m_map.FindRef(_id);\n"); 429 | dataStr.append("}\n"); 430 | //add getAllXXXDB function 431 | dataStr.append("TArray<").append(structName).append("> UDB_").append(fileName).append("::getAll").append(fileName).append("DB()\n"); 432 | dataStr.append("{\n"); 433 | dataStr.append(" TArray<").append(structName).append("> db;\n"); 434 | dataStr.append(" for (TPair& element : m_map)\n"); 435 | dataStr.append(" {\n"); 436 | dataStr.append(" db.Add(element.Value);\n"); 437 | dataStr.append(" }\n"); 438 | dataStr.append(" return db;\n"); 439 | dataStr.append("}\n"); 440 | 441 | 442 | //write .cpp 443 | string outHeadFilename(m_dir); 444 | outHeadFilename.append("/export/DB_"); 445 | outHeadFilename.append(fileName).append(".cpp"); 446 | FILE *fp = fopen (outHeadFilename.c_str(), "w"); 447 | if (fp == NULL) { 448 | printf ("Error: failed to open file %s, %s\n", outHeadFilename.c_str(), strerror(errno)); 449 | exit(-1); 450 | } 451 | fprintf(fp, "%s", dataStr.c_str()); 452 | fflush(fp); 453 | fclose(fp); 454 | } 455 | -------------------------------------------------------------------------------- /Classes/CsvToScript.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | // class XmlToScript is an interface for script language. 10 | // such as Lua, Javascript. 11 | class CsvToScript { 12 | private: 13 | string m_dir; 14 | string m_proj; 15 | string structName; 16 | string fileName; 17 | vector typeVector;//table save type 18 | public: 19 | CsvToScript(); 20 | ~CsvToScript(){}; 21 | void csvToScript(string csvFile,string path,string proj); 22 | 23 | bool readFile(const string &filename, string &content); 24 | vector splitStringByDelim (const string str, const string delim); 25 | vector parseCsvLine(const string str); 26 | 27 | void writeHeadScript(vector attrinames,vector attributes); 28 | void writeCppScript(vector attrinames,vector attributes); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Csv2Script 2 | for UE4 , csv to cpp struct and use in blueprint 3 | 4 | ##How to use 5 | [how to use](http://www.hoospo.com/ue4-csv/) 6 | 7 | 8 | # 此项目不在维护,采用python重写了一次,并且加入了4.14版本以上 plueprint中能使用的TMap 特性 9 | [python版本](https://github.com/iyexiao/Excel2UE) -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E4A208651E6D41D600565844 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A208641E6D41D600565844 /* main.cpp */; }; 11 | E4EC0BFE1E70F305002AD587 /* CsvToScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4EC0BFC1E70F305002AD587 /* CsvToScript.cpp */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | E4A2085F1E6D41D600565844 /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = /usr/share/man/man1/; 19 | dstSubfolderSpec = 0; 20 | files = ( 21 | ); 22 | runOnlyForDeploymentPostprocessing = 1; 23 | }; 24 | /* End PBXCopyFilesBuildPhase section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | E4A208611E6D41D600565844 /* Csv2Script */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Csv2Script; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | E4A208641E6D41D600565844 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 29 | E4EC0BFC1E70F305002AD587 /* CsvToScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CsvToScript.cpp; path = ../../../Classes/CsvToScript.cpp; sourceTree = ""; }; 30 | E4EC0BFD1E70F305002AD587 /* CsvToScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CsvToScript.h; path = ../../../Classes/CsvToScript.h; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | E4A2085E1E6D41D600565844 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | E4A208581E6D41D600565844 = { 45 | isa = PBXGroup; 46 | children = ( 47 | E4A208631E6D41D600565844 /* Csv2Script */, 48 | E4A208621E6D41D600565844 /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | E4A208621E6D41D600565844 /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | E4A208611E6D41D600565844 /* Csv2Script */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | E4A208631E6D41D600565844 /* Csv2Script */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | E4EC0BFC1E70F305002AD587 /* CsvToScript.cpp */, 64 | E4EC0BFD1E70F305002AD587 /* CsvToScript.h */, 65 | E4A208641E6D41D600565844 /* main.cpp */, 66 | ); 67 | path = Csv2Script; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | E4A208601E6D41D600565844 /* Csv2Script */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = E4A208681E6D41D600565844 /* Build configuration list for PBXNativeTarget "Csv2Script" */; 76 | buildPhases = ( 77 | E4A2085D1E6D41D600565844 /* Sources */, 78 | E4A2085E1E6D41D600565844 /* Frameworks */, 79 | E4A2085F1E6D41D600565844 /* CopyFiles */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = Csv2Script; 86 | productName = Csv2Script; 87 | productReference = E4A208611E6D41D600565844 /* Csv2Script */; 88 | productType = "com.apple.product-type.tool"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | E4A208591E6D41D600565844 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastUpgradeCheck = 0820; 97 | ORGANIZATIONNAME = yexiao; 98 | TargetAttributes = { 99 | E4A208601E6D41D600565844 = { 100 | CreatedOnToolsVersion = 8.2.1; 101 | ProvisioningStyle = Automatic; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = E4A2085C1E6D41D600565844 /* Build configuration list for PBXProject "Csv2Script" */; 106 | compatibilityVersion = "Xcode 3.2"; 107 | developmentRegion = English; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | ); 112 | mainGroup = E4A208581E6D41D600565844; 113 | productRefGroup = E4A208621E6D41D600565844 /* Products */; 114 | projectDirPath = ""; 115 | projectRoot = ""; 116 | targets = ( 117 | E4A208601E6D41D600565844 /* Csv2Script */, 118 | ); 119 | }; 120 | /* End PBXProject section */ 121 | 122 | /* Begin PBXSourcesBuildPhase section */ 123 | E4A2085D1E6D41D600565844 /* Sources */ = { 124 | isa = PBXSourcesBuildPhase; 125 | buildActionMask = 2147483647; 126 | files = ( 127 | E4EC0BFE1E70F305002AD587 /* CsvToScript.cpp in Sources */, 128 | E4A208651E6D41D600565844 /* main.cpp in Sources */, 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXSourcesBuildPhase section */ 133 | 134 | /* Begin XCBuildConfiguration section */ 135 | E4A208661E6D41D600565844 /* Debug */ = { 136 | isa = XCBuildConfiguration; 137 | buildSettings = { 138 | ALWAYS_SEARCH_USER_PATHS = NO; 139 | CLANG_ANALYZER_NONNULL = YES; 140 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 141 | CLANG_CXX_LIBRARY = "libc++"; 142 | CLANG_ENABLE_MODULES = YES; 143 | CLANG_ENABLE_OBJC_ARC = YES; 144 | CLANG_WARN_BOOL_CONVERSION = YES; 145 | CLANG_WARN_CONSTANT_CONVERSION = YES; 146 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 147 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 148 | CLANG_WARN_EMPTY_BODY = YES; 149 | CLANG_WARN_ENUM_CONVERSION = YES; 150 | CLANG_WARN_INFINITE_RECURSION = YES; 151 | CLANG_WARN_INT_CONVERSION = YES; 152 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 153 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 154 | CLANG_WARN_UNREACHABLE_CODE = YES; 155 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 156 | CODE_SIGN_IDENTITY = "-"; 157 | COPY_PHASE_STRIP = NO; 158 | DEBUG_INFORMATION_FORMAT = dwarf; 159 | ENABLE_STRICT_OBJC_MSGSEND = YES; 160 | ENABLE_TESTABILITY = YES; 161 | GCC_C_LANGUAGE_STANDARD = gnu99; 162 | GCC_DYNAMIC_NO_PIC = NO; 163 | GCC_NO_COMMON_BLOCKS = YES; 164 | GCC_OPTIMIZATION_LEVEL = 0; 165 | GCC_PREPROCESSOR_DEFINITIONS = ( 166 | "DEBUG=1", 167 | "$(inherited)", 168 | ); 169 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 170 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 171 | GCC_WARN_UNDECLARED_SELECTOR = YES; 172 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 173 | GCC_WARN_UNUSED_FUNCTION = YES; 174 | GCC_WARN_UNUSED_VARIABLE = YES; 175 | MACOSX_DEPLOYMENT_TARGET = 10.11; 176 | MTL_ENABLE_DEBUG_INFO = YES; 177 | ONLY_ACTIVE_ARCH = YES; 178 | SDKROOT = macosx; 179 | }; 180 | name = Debug; 181 | }; 182 | E4A208671E6D41D600565844 /* Release */ = { 183 | isa = XCBuildConfiguration; 184 | buildSettings = { 185 | ALWAYS_SEARCH_USER_PATHS = NO; 186 | CLANG_ANALYZER_NONNULL = YES; 187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 188 | CLANG_CXX_LIBRARY = "libc++"; 189 | CLANG_ENABLE_MODULES = YES; 190 | CLANG_ENABLE_OBJC_ARC = YES; 191 | CLANG_WARN_BOOL_CONVERSION = YES; 192 | CLANG_WARN_CONSTANT_CONVERSION = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INFINITE_RECURSION = YES; 198 | CLANG_WARN_INT_CONVERSION = YES; 199 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 200 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 201 | CLANG_WARN_UNREACHABLE_CODE = YES; 202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 203 | CODE_SIGN_IDENTITY = "-"; 204 | COPY_PHASE_STRIP = NO; 205 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 206 | ENABLE_NS_ASSERTIONS = NO; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | GCC_C_LANGUAGE_STANDARD = gnu99; 209 | GCC_NO_COMMON_BLOCKS = YES; 210 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 211 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 212 | GCC_WARN_UNDECLARED_SELECTOR = YES; 213 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 214 | GCC_WARN_UNUSED_FUNCTION = YES; 215 | GCC_WARN_UNUSED_VARIABLE = YES; 216 | MACOSX_DEPLOYMENT_TARGET = 10.11; 217 | MTL_ENABLE_DEBUG_INFO = NO; 218 | SDKROOT = macosx; 219 | }; 220 | name = Release; 221 | }; 222 | E4A208691E6D41D600565844 /* Debug */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | PRODUCT_NAME = "$(TARGET_NAME)"; 226 | }; 227 | name = Debug; 228 | }; 229 | E4A2086A1E6D41D600565844 /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | PRODUCT_NAME = "$(TARGET_NAME)"; 233 | }; 234 | name = Release; 235 | }; 236 | /* End XCBuildConfiguration section */ 237 | 238 | /* Begin XCConfigurationList section */ 239 | E4A2085C1E6D41D600565844 /* Build configuration list for PBXProject "Csv2Script" */ = { 240 | isa = XCConfigurationList; 241 | buildConfigurations = ( 242 | E4A208661E6D41D600565844 /* Debug */, 243 | E4A208671E6D41D600565844 /* Release */, 244 | ); 245 | defaultConfigurationIsVisible = 0; 246 | defaultConfigurationName = Release; 247 | }; 248 | E4A208681E6D41D600565844 /* Build configuration list for PBXNativeTarget "Csv2Script" */ = { 249 | isa = XCConfigurationList; 250 | buildConfigurations = ( 251 | E4A208691E6D41D600565844 /* Debug */, 252 | E4A2086A1E6D41D600565844 /* Release */, 253 | ); 254 | defaultConfigurationIsVisible = 0; 255 | defaultConfigurationName = Release; 256 | }; 257 | /* End XCConfigurationList section */ 258 | }; 259 | rootObject = E4A208591E6D41D600565844 /* Project object */; 260 | } 261 | -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script.xcodeproj/project.xcworkspace/xcuserdata/welove.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/mac/Csv2Script/Csv2Script.xcodeproj/project.xcworkspace/xcuserdata/welove.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script.xcodeproj/xcuserdata/welove.xcuserdatad/xcschemes/Csv2Script.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script.xcodeproj/xcuserdata/welove.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Csv2Script.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E4A208601E6D41D600565844 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /mac/Csv2Script/Csv2Script/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // Csv2Script 4 | // 5 | // Created by yexiao on 17/3/6. 6 | // Copyright © 2017年 yexiao. All rights reserved. 7 | // 8 | 9 | #include 10 | #include "CsvToScript.h" 11 | 12 | int main(int argc, const char * argv[]) { 13 | if (argc != 4) { 14 | return -1; 15 | } 16 | 17 | CsvToScript *ctoScript = new CsvToScript(); 18 | ctoScript->csvToScript(argv[1],argv[2],argv[3]); 19 | delete ctoScript; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/Csv2Script: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/mac/Csv2Script/example/Csv2Script -------------------------------------------------------------------------------- /mac/Csv2Script/example/csv/role.csv: -------------------------------------------------------------------------------- 1 | "id","角色职业","角色性别","角色简介","是否解锁" 2 | "int","int","int","string","bool" 3 | "id","roleType","roleSex","roleDetail","isOpen", 4 | 1,1,0,"战士",1 5 | 2,2,0,"剑客",1 6 | 3,3,1,"法师",1 7 | 4,4,1,"药师",0 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/csv/skill.csv: -------------------------------------------------------------------------------- 1 | "id","宠物id","技能id","技能名字","技能效果","是否有特效" 2 | "int","int","int","string","string","bool" 3 | "id","petId","skillId","skillName","skillEffect","isEffect" 4 | 1,12001,13001,"恢复体力","雪花飘落",0 5 | 2,12001,13002,"时间停滞","未知",1 6 | 3,12001,13003,"无懈可击","未,知",0 7 | 4,12001,13004,"我的地带","未知",0 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Role.cpp: -------------------------------------------------------------------------------- 1 | #include "GodProj.h" 2 | #include "DB_Role.h" 3 | 4 | static TMap m_map; 5 | 6 | UDB_Role::UDB_Role() 7 | { 8 | loadData(); 9 | } 10 | bool UDB_Role::loadData() 11 | { 12 | m_map.Empty(); 13 | FString path = FPaths::GameDir() + "Content/DB/DB_Role.txt"; 14 | if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*path)) 15 | return false; 16 | TArray db; 17 | FString contentStr; 18 | FFileHelper::LoadFileToString(contentStr,*path); 19 | contentStr.ParseIntoArray(db, TEXT("\n"), false); 20 | for (int i = 0; i < db.Num(); i++) 21 | { 22 | FString aString = db[i]; 23 | TArray array = {}; 24 | aString.ParseIntoArray(array, TEXT(","), false); 25 | FRole dbS; 26 | dbS.id = FCString::Atoi(*array[0]); 27 | dbS.roleType = FCString::Atoi(*array[1]); 28 | dbS.roleSex = FCString::Atoi(*array[2]); 29 | dbS.roleDetail = *array[3]; 30 | if (FCString::Atoi(*array[4]) == 1) 31 | dbS.isOpen = true; 32 | else 33 | dbS.isOpen = false; 34 | m_map.Add(dbS.id, dbS); 35 | } 36 | return true; 37 | } 38 | 39 | FRole UDB_Role::getRoleById(int32 _id) 40 | { 41 | return m_map.FindRef(_id); 42 | } 43 | TArray UDB_Role::getAllRoleDB() 44 | { 45 | TArray db; 46 | for (TPair& element : m_map) 47 | { 48 | db.Add(element.Value); 49 | } 50 | return db; 51 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Role.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Kismet/BlueprintFunctionLibrary.h" 4 | #include "DB_Role.generated.h" 5 | 6 | USTRUCT(BlueprintType) 7 | struct FRole 8 | { 9 | GENERATED_USTRUCT_BODY() 10 | public: 11 | FRole(){}; 12 | 13 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 14 | int32 id; 15 | 16 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 17 | int32 roleType; 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 20 | int32 roleSex; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 23 | FString roleDetail; 24 | 25 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 26 | bool isOpen; 27 | }; 28 | 29 | 30 | UCLASS(Blueprintable) 31 | class GODPROJ_API UDB_Role : public UBlueprintFunctionLibrary 32 | { 33 | GENERATED_BODY() 34 | public: 35 | 36 | UDB_Role(); 37 | ~UDB_Role(){}; 38 | bool loadData(); 39 | 40 | 41 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 42 | static FRole getRoleById(int32 _id); 43 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 44 | static TArray getAllRoleDB(); 45 | }; 46 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Role.txt: -------------------------------------------------------------------------------- 1 | 1,1,0,战士,1, 2 | 2,2,0,剑客,1, 3 | 3,3,1,法师,1, 4 | 4,4,1,药师,0, -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Skill.cpp: -------------------------------------------------------------------------------- 1 | #include "GodProj.h" 2 | #include "DB_Skill.h" 3 | 4 | static TMap m_map; 5 | 6 | UDB_Skill::UDB_Skill() 7 | { 8 | loadData(); 9 | } 10 | bool UDB_Skill::loadData() 11 | { 12 | m_map.Empty(); 13 | FString path = FPaths::GameDir() + "Content/DB/DB_Skill.txt"; 14 | if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*path)) 15 | return false; 16 | TArray db; 17 | FString contentStr; 18 | FFileHelper::LoadFileToString(contentStr,*path); 19 | contentStr.ParseIntoArray(db, TEXT("\n"), false); 20 | for (int i = 0; i < db.Num(); i++) 21 | { 22 | FString aString = db[i]; 23 | TArray array = {}; 24 | aString.ParseIntoArray(array, TEXT(","), false); 25 | FSkill dbS; 26 | dbS.id = FCString::Atoi(*array[0]); 27 | dbS.petId = FCString::Atoi(*array[1]); 28 | dbS.skillId = FCString::Atoi(*array[2]); 29 | dbS.skillName = *array[3]; 30 | dbS.skillEffect = *array[4]; 31 | if (FCString::Atoi(*array[5]) == 1) 32 | dbS.isEffect = true; 33 | else 34 | dbS.isEffect = false; 35 | m_map.Add(dbS.id, dbS); 36 | } 37 | return true; 38 | } 39 | 40 | FSkill UDB_Skill::getSkillById(int32 _id) 41 | { 42 | return m_map.FindRef(_id); 43 | } 44 | TArray UDB_Skill::getAllSkillDB() 45 | { 46 | TArray db; 47 | for (TPair& element : m_map) 48 | { 49 | db.Add(element.Value); 50 | } 51 | return db; 52 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Skill.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Kismet/BlueprintFunctionLibrary.h" 4 | #include "DB_Skill.generated.h" 5 | 6 | USTRUCT(BlueprintType) 7 | struct FSkill 8 | { 9 | GENERATED_USTRUCT_BODY() 10 | public: 11 | FSkill(){}; 12 | 13 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 14 | int32 id; 15 | 16 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 17 | int32 petId; 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 20 | int32 skillId; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 23 | FString skillName; 24 | 25 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 26 | FString skillEffect; 27 | 28 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 29 | bool isEffect; 30 | }; 31 | 32 | 33 | UCLASS(Blueprintable) 34 | class GODPROJ_API UDB_Skill : public UBlueprintFunctionLibrary 35 | { 36 | GENERATED_BODY() 37 | public: 38 | 39 | UDB_Skill(); 40 | ~UDB_Skill(){}; 41 | bool loadData(); 42 | 43 | 44 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 45 | static FSkill getSkillById(int32 _id); 46 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 47 | static TArray getAllSkillDB(); 48 | }; 49 | -------------------------------------------------------------------------------- /mac/Csv2Script/example/export/DB_Skill.txt: -------------------------------------------------------------------------------- 1 | 1,12001,13001,恢复体力,雪花飘落,0, 2 | 2,12001,13002,时间停滞,未知,1, 3 | 3,12001,13003,无懈可击,未.知,0, 4 | 4,12001,13004,我的地带,未知,0, -------------------------------------------------------------------------------- /mac/Csv2Script/example/run.sh: -------------------------------------------------------------------------------- 1 | 2 | # 保证跟目录下有csv export文件夹 3 | # 保证是在当前路径运行脚本 4 | # 参数 1:项目名称GodProj(区分大小写) 5 | 6 | 7 | PROJ_NAME=$1 8 | 9 | ROOT_DIR=`pwd` 10 | 11 | cd $ROOT_DIR 12 | 13 | #删除旧资源 14 | rm -rf ${ROOT_DIR}/export/* 15 | 16 | function fncsv2TXT() 17 | { 18 | for filepath in `find ${ROOT_DIR}/csv -type f -depth 1` 19 | do 20 | local filename=`echo "${filepath}" | awk -F '.' '{print $1}' ` 21 | local filetype=`echo "${filepath}" | awk -F '.' '{print $NF}' ` 22 | filename=`echo "${filename}" "${ROOT_DIR}/csv/" | awk '{gsub($2,"");print $NF}'` #删掉前面的的路径字符串 23 | if [ ${filetype} == "csv" ] 24 | then 25 | # echo "fncsv2TXT, filename=${filename}" 26 | ./Csv2Script ${filename}.${filetype} . $PROJ_NAME 27 | fi 28 | done 29 | } 30 | fncsv2TXT 31 | 32 | echo "done" 33 | exit 0 -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script.VC.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script.VC.db -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Csv2Script", "Csv2Script\Csv2Script.vcxproj", "{BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Debug|x64.ActiveCfg = Debug|x64 17 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Debug|x64.Build.0 = Debug|x64 18 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Debug|x86.Build.0 = Debug|Win32 20 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Release|x64.ActiveCfg = Release|x64 21 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Release|x64.Build.0 = Release|x64 22 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Release|x86.ActiveCfg = Release|Win32 23 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Csv2Script.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Csv2Script.cpp -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Csv2Script.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {BC5E2D5B-2594-47A7-A0F0-E77F3E8B47A5} 23 | Win32Proj 24 | Csv2Script 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | Use 87 | Level3 88 | Disabled 89 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | Use 100 | Level3 101 | Disabled 102 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | true 104 | 105 | 106 | Console 107 | true 108 | 109 | 110 | 111 | 112 | Level3 113 | Use 114 | MaxSpeed 115 | true 116 | true 117 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Console 122 | true 123 | true 124 | true 125 | 126 | 127 | 128 | 129 | Level3 130 | Use 131 | MaxSpeed 132 | true 133 | true 134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | Console 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | NotUsing 155 | 156 | 157 | 158 | Create 159 | Create 160 | Create 161 | Create 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Csv2Script.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 32 | 33 | 源文件 34 | 35 | 36 | 源文件 37 | 38 | 39 | 源文件 40 | 41 | 42 | -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/Csv2Script.lastbuildstate: -------------------------------------------------------------------------------- 1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 2 | Debug|Win32|D:\git\Csv2Script\win\Csv2Script\| 3 | -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/Csv2Script.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/Debug/vc140.idb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/Debug/vc140.idb -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:Csv2Script 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 Csv2Script 应用程序。 6 | 7 | 本文件概要介绍组成 Csv2Script 应用程序的每个文件的内容。 8 | 9 | 10 | Csv2Script.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | Csv2Script.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | Csv2Script.cpp 17 | 这是主应用程序源文件。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 其他标准文件: 21 | 22 | StdAfx.h, StdAfx.cpp 23 | 这些文件用于生成名为 Csv2Script.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | 其他注释: 27 | 28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/stdafx.cpp -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/stdafx.h -------------------------------------------------------------------------------- /win/Csv2Script/Csv2Script/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/Csv2Script/targetver.h -------------------------------------------------------------------------------- /win/Csv2Script/Debug/csv/role.csv: -------------------------------------------------------------------------------- 1 | "id","角色职业","角色性别","角色简介","是否解锁" 2 | "int","int","int","string","bool" 3 | "id","roleType","roleSex","roleDetail","isOpen", 4 | 1,1,0,"战士",1 5 | 2,2,0,"剑客",1 6 | 3,3,1,"法师",1 7 | 4,4,1,"药师",0 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/csv/skill.csv: -------------------------------------------------------------------------------- 1 | "id","宠物id","技能id","技能名字","技能效果","是否有特效" 2 | "int","int","int","string","string","bool" 3 | "id","petId","skillId","skillName","skillEffect","isEffect" 4 | 1,12001,13001,"恢复体力","雪花飘落",0 5 | 2,12001,13002,"时间停滞","未知",1 6 | 3,12001,13003,"无懈可击","未,知",0 7 | 4,12001,13004,"我的地带","未知",0 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/export/DB_Skill.cpp: -------------------------------------------------------------------------------- 1 | #include "GodProj.h" 2 | #include "DB_Skill.h" 3 | 4 | UDB_Skill::UDB_Skill() 5 | { 6 | 7 | } 8 | bool UDB_Skill::loadData() 9 | { 10 | FString path = FPaths::GameDir() + "Content/DB/DB_Skill.txt"; 11 | if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*path)) 12 | return false; 13 | TArray db; 14 | FString contentStr; 15 | FFileHelper::LoadFileToString(contentStr,*path); 16 | contentStr.ParseIntoArray(db, TEXT("\\n"), false); 17 | for (int i = 0; i < db.Num(); i++) 18 | { 19 | FString aString = db[i]; 20 | TArray array = {}; 21 | aString.ParseIntoArray(array, TEXT(","), false); 22 | FSkill dbS; 23 | dbS.id = FCString::Atoi(*array[0]); 24 | dbS.petId = FCString::Atoi(*array[1]); 25 | dbS.skillId = FCString::Atoi(*array[2]); 26 | dbS.skillName = *array[3]; 27 | dbS.skillEffect = *array[4]; 28 | if (FCString::Atoi(*array[5]) == 1) 29 | dbS.isEffect = true; 30 | else 31 | dbS.isEffect = false; 32 | m_map.Add(dbS.id, dbS); 33 | } 34 | return true; 35 | } 36 | 37 | FSkill UDB_Skill::getSkillById(int32 _id) 38 | { 39 | return m_map.FindRef(_id); 40 | } 41 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/export/DB_Skill.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UObject/NoExportTypes.h" 4 | #include "DB_Skill.generated.h" 5 | 6 | USTRUCT(BlueprintType) 7 | struct FSkill 8 | { 9 | GENERATED_USTRUCT_BODY() 10 | public: 11 | FSkill(){}; 12 | 13 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 14 | int32 id; 15 | 16 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 17 | int32 petId; 18 | 19 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 20 | int32 skillId; 21 | 22 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 23 | FString skillName; 24 | 25 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 26 | FString skillEffect; 27 | 28 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "DATA_DB") 29 | bool isEffect; 30 | }; 31 | 32 | 33 | UCLASS(Blueprintable) 34 | class GODPROJ_API UDB_Skill : public UObject 35 | { 36 | GENERATED_BODY() 37 | public: 38 | TMap m_map; 39 | 40 | UDB_Skill(); 41 | ~UDB_Skill(){}; 42 | bool loadData(); 43 | 44 | 45 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 46 | FSkill getSkillById(int32 _id); 47 | }; 48 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/export/DB_Skill.txt: -------------------------------------------------------------------------------- 1 | 1,12001,13001,恢复体力,雪花飘落,0, 2 | 2,12001,13002,时间停滞,未知,1, 3 | 3,12001,13003,无懈可击,未.知,0, 4 | 4,12001,13004,我的地带,未知,0, -------------------------------------------------------------------------------- /win/Csv2Script/Debug/export/DataSingletonManager.cpp: -------------------------------------------------------------------------------- 1 | #include "GodProj.h" 2 | #include "DataSingletonManager.h" 3 | 4 | UDB_Skill* UDataSingletonManager::m_DB_Skill(NULL); 5 | UDB_Skill* UDataSingletonManager::GetDB_Skill() 6 | { if (!m_DB_Skill) 7 | { 8 | m_DB_Skill = NewObject(); 9 | m_DB_Skill->loadData(); 10 | } 11 | return m_DB_Skill; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/export/DataSingletonManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DB_Skill.h" 4 | #include "Kismet/BlueprintFunctionLibrary.h" 5 | #include "DataSingletonManager.generated.h" 6 | 7 | UCLASS(Blueprintable) 8 | class GODPROJ_API UDataSingletonManager : public UBlueprintFunctionLibrary 9 | { 10 | GENERATED_BODY() 11 | private: 12 | static UDB_Skill* m_DB_Skill; 13 | public: 14 | UFUNCTION(BlueprintCallable, Category = "DATA_DB") 15 | static UDB_Skill* GetDB_Skill(); 16 | }; 17 | -------------------------------------------------------------------------------- /win/Csv2Script/Debug/run.bat: -------------------------------------------------------------------------------- 1 | D: 2 | cd D:\git\Csv2Script\win\Csv2Script\Debug 3 | Csv2Script.exe skill.csv . GodProj 4 | 5 | pause -------------------------------------------------------------------------------- /win/Csv2Script/ipch/CSV2SCRIPT-801f5e5e/CSV2SCRIPT-24f117f.ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/ipch/CSV2SCRIPT-801f5e5e/CSV2SCRIPT-24f117f.ipch -------------------------------------------------------------------------------- /win/Csv2Script/ipch/CSV2SCRIPT-e1b95e18/CSV2SCRIPT-24f117f.ipch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iyexiao/Csv2Script/998c167719c81a4a9fae9ed240d1216ad4b86640/win/Csv2Script/ipch/CSV2SCRIPT-e1b95e18/CSV2SCRIPT-24f117f.ipch --------------------------------------------------------------------------------