$children = $node["children"]; foreach ($children as $child) { array_push($node_queue, $child); } } // cpp: loadUI function my_println($cpp_file_output, "void {$cpp_class_name}::loadUI()"); my_println($cpp_file_output, "{"); my_println($cpp_file_output, $loadUI_func_str); my_println($cpp_file_output, "}"); my_println($cpp_file_output, ""); // cpp: handleTouchEvent my_println($cpp_file_output, "void {$cpp_class_name}::handleTouchEvent(Ref *pSender, TouchEventType type)"); my_println($cpp_file_output, "{"); my_println($cpp_file_output, $handleTouchEvent_str); my_println($cpp_file_output, "}"); my_println($cpp_file_output, ""); // 2- class end: class define end my_println($header_file_output, "};"); // 1 - header end: macrio define end my_println($header_file_output, "#endif"); fwrite($export_header_file, $header_file_output); fwrite($export_cpp_file, $cpp_file_output); fclose($export_header_file); fclose($export_cpp_file); } // end function createCPP $jsonFiles = getDictionaryFile("json", ".json"); foreach ($jsonFiles as $tmpFile) { createCPPWithJson("json/{$tmpFile}"); }
for ($row = 2; $row <= $highestRow; $row++) { for ($column = 1; $column <= $highestColumn; $column++) { $key = $sheet->getCellByColumnAndRow($column, 1)->getValue(); $val = $sheet->getCellByColumnAndRow($column, $row)->getValue(); if ($key != "") { //$cellVal = iconv("utf-8", "gb2312", $val); //echo $key . "-" . $val . "\n"; print_key_val($key_val_str, $key, $val); } } //id $id = $sheet->getCellByColumnAndRow(0, $row)->getValue(); if ($id != "") { print_key_table($key_table_str, $id, $key_val_str); $key_val_str = ""; } } //echo $key_table_str; $configStr = ""; print_lua_config($configStr, $lua_class_name, $key_table_str); //echo $configStr; $export_lua_file = fopen("output_lua/{$lua_class_name}.lua", "w"); fwrite($export_lua_file, $configStr); fclose($export_lua_file); } //convert all xls files to lua file $excelFiles = getDictionaryFile("input_excel", ".xls"); foreach ($excelFiles as $tmpFile) { createLUAWithXls("input_excel/{$tmpFile}"); } //fgets(STDIN);
$docFile = getDictionaryFile("./protobuf/", ".proto"); foreach ($docFile as $fileName) { $output = shell_exec("protoc --proto_path=./protobuf --cpp_out=../protobuf protobuf/" . $fileName); } function getDictionaryFile($dir, $search) { $handler = opendir($dir); while (($filename = readdir($handler)) !== false) { if ($filename != "." && $filename != ".." && strpos($filename, $search)) { $files[] = $filename; } } closedir($handler); return $files; } $headerFiles = getDictionaryFile("../protobuf/", "pb.h"); //print_r($headerFiles); $outputStr = "// Do not edit this file!! this file created by php script!!\n"; $outputStr .= "#ifndef HiFly_ProtobufMsg_h\n"; $outputStr .= "#define HiFly_ProtobufMsg_h\n"; foreach ($headerFiles as $tmpFile) { $outputStr .= '#include "' . $tmpFile . '"' . "\n"; } $outputStr .= "using namespace protobuf;\n"; $outputStr .= "#endif\n"; // create new export header file that include all proto header files $exportHeaderFile = fopen("../protobuf/ProtobufMsg.h", "w"); fwrite($exportHeaderFile, $outputStr); fclose($exportHeaderFile); echo "creat header file: ../protobuf/ProtobufMsg.h"; ?>
// lua: initM function my_println($lua_file_content, "function {$lua_class_name}:initM()"); $loadUI_func_str = substr($loadUI_func_str, 0, strlen($loadUI_func_str) - 1); my_println($lua_file_content, $loadUI_func_str); my_println($lua_file_content, "\tself:initUI()"); my_println($lua_file_content, "end"); my_println($lua_file_content, ""); // lua: handleTouchEvent my_println($lua_file_content, "function {$lua_class_name}:handleTouchEvent(sender, event)"); my_println($lua_file_content, $handleTouchEvent_str); my_println($lua_file_content, "end"); my_println($lua_file_content, ""); // lua: initUI my_println($lua_file_content, "--init your ui here"); my_println($lua_file_content, "function {$lua_class_name}:initUI()"); my_println($lua_file_content, "end"); my_println($lua_file_content, ""); // lua:refreshUI my_println($lua_file_content, "--refresh all ui here"); my_println($lua_file_content, "function {$lua_class_name}:refreshUI()"); my_println($lua_file_content, "end"); my_println($lua_file_content, ""); my_println($lua_file_content, "return {$lua_class_name}"); fwrite($export_lua_file, $lua_file_content); fclose($export_lua_file); } // end function createLUA $jsonFiles = getDictionaryFile("json", ".ExportJson"); foreach ($jsonFiles as $tmpFile) { createLUAWithJson("json/{$tmpFile}"); }
$headerFileContent = preg_replace("/___className___/i", $className, $headerFileContent); $headerFileContent = preg_replace("/[^a-zA-Z_0-9]id\\s+/", "static " . $className . "* ", $headerFileContent); return $headerFileContent; } function processOCFileContent($ocRules, $ocFileContent, $className) { foreach ($ocRules as $key => $value) { //print_r($key);print_r('\n');print_r($value); $ocFileContent = preg_replace($key, $value, $ocFileContent); } $ocFileContent = preg_replace("/___className___/i", $className, $ocFileContent); $ocFileContent = preg_replace("/[^a-zA-Z_0-9]id\\s+/", $className . "* ", $ocFileContent); return $ocFileContent; } // get all .h file names $headerFileNames = getDictionaryFile(IN_PATH, ".h"); //var_dump($headerFileNames); foreach ($headerFileNames as $key => $headerFileName) { // 1. process this header file //print_r(getOnlyFileName($headerFileName, ".h") . "\n"); $outHeaderFileName = $headerFileName; $outCPPFileName = ""; $outHeaderFileContent = ""; $headerFileContent = file_get_contents(IN_PATH . $headerFileName); //print_r($headerFileContent); $outHeaderFileContent = processHeaderFileContent($HEADER_RULES, $headerFileContent, getOnlyFileName($headerFileName, ".h")); //print_r($outHeaderFileContent); $outHeaderFile = fopen(OUT_PATH . $outHeaderFileName, "w"); fwrite($outHeaderFile, $outHeaderFileContent); fclose($outHeaderFile); // 2. process this oc file
rename($dir . "/" . $filename, $dir . "/" . $newfilename); } if ($filename != "." && $filename != ".." && is_dir($dir . "/" . $filename)) { renamePngFile($dir . "/" . $filename, $postfix, $allPngFileNameArray); } } closedir($handler); } //0. postfix $imagePostfix = "_" . basename(dirname(__FILE__)) . ".png"; $jsonContentPostfix = "_" . basename(dirname(__FILE__)); //1. modify png file name $allPngFileNameArray = array(); renamePngFile("Resources", $imagePostfix, $allPngFileNameArray); //2. replace postfix in json file $jsonFileNames = getDictionaryFile("Json", ".json"); foreach ($jsonFileNames as $tmpFileName) { $fileStr = file_get_contents("Json/" . $tmpFileName); //$fileStr = utf8_encode($fileStr); //$encode = mb_detect_encoding($fileStr, array(GB2312,UTF-8, GBK)); //echo $encode; foreach ($allPngFileNameArray as $key => $value) { $onlyFileName = getOnlyFileName($value, ".png"); $encode = mb_detect_encoding($onlyFileName, array("GB2312", "GBK", "UTF-8")); //echo "____________________".$encode."____________________\n"; if ($encode == "GB2312") { $onlyFileName = iconv("GB2312", "UTF-8", $onlyFileName); } else { if ($encode == "GBK") { $onlyFileName = iconv("GBK", "UTF-8", $onlyFileName); } else {