From a5f5adae08e5255148030850e5a38ad2adf9b7b9 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 3 Jun 2022 20:45:44 +0200 Subject: [PATCH] Actually write the cpp and header files. --- game/addons/gdc_converter/plugin.gd | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/game/addons/gdc_converter/plugin.gd b/game/addons/gdc_converter/plugin.gd index c8d9c1fb..85a635bd 100644 --- a/game/addons/gdc_converter/plugin.gd +++ b/game/addons/gdc_converter/plugin.gd @@ -23,7 +23,6 @@ func on_menu_clicked(val) -> void: if !dir.current_is_dir(): if file_name.get_extension() == "gd": process_file(dir_name + file_name) - return file_name = dir.get_next() @@ -242,7 +241,7 @@ class GDSScope: s += " {\n" if scope_data_alt != "": - s += indents + " GDCLASS(" + scope_data + ", " + scope_data_alt + ")\n\n" + s += indents + " GDCLASS(" + scope_data + ", " + scope_data_alt + ");\n\n" s += indents + " public:\n" @@ -753,5 +752,22 @@ func process_file(file_name : String) -> void: parser.parse(contents, file_name) #print(parser) #print(parser.get_cpp_header_string(file_name)) - print(parser.get_cpp_impl_string(file_name)) + #print(parser.get_cpp_impl_string(file_name)) + var save_base_file_path : String = file_name.get_base_dir() + var save_base_file_name : String = file_name.get_file().to_lower().trim_suffix(".gd") + + var header_file : String = save_base_file_path + "/" + save_base_file_name + ".h" + var impl_file : String = save_base_file_path + "/" + save_base_file_name + ".cpp" + + var header_data : String = parser.get_cpp_header_string(file_name) + var impl_data : String = parser.get_cpp_impl_string(file_name) + + file.open(header_file, File.WRITE) + file.store_string(header_data) + file.close() + + file.open(impl_file, File.WRITE) + file.store_string(impl_data) + file.close() +