MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _decompile_process

Method _decompile_process

editor/gdre_editor.cpp:579–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579void GodotREEditor::_decompile_process() {
580 Vector<String> files = script_dialog_d->get_file_list();
581 Vector<uint8_t> key = key_dialog->get_key();
582 String dir = script_dialog_d->get_target_dir();
583
584 print_warning("GDScriptDecomp{" + itos(script_dialog_d->get_bytecode_version()) + "}", RTR("Decompile"));
585
586 String failed_files;
587 Ref<GDScriptDecomp> dce = GDScriptDecompVersion::create_decomp_for_commit(script_dialog_d->get_bytecode_version());
588
589 if (dce.is_null()) {
590 show_warning(failed_files, RTR("Decompile"), RTR("Invalid bytecode version!"));
591 return;
592 }
593
594 Ref<EditorProgressGDDC> pr = memnew(EditorProgressGDDC(ne_parent, "re_decompile", RTR("Decompiling files..."), files.size(), true));
595 for (int i = 0; i < files.size(); i++) {
596 print_warning(RTR("decompiling") + " " + files[i].get_file(), RTR("Decompile"));
597
598 String target_name = dir.path_join(files[i].get_file().get_basename() + ".gd");
599
600 bool cancel = pr->step(files[i].get_file(), i, true);
601 if (cancel) {
602 break;
603 }
604
605 Error err;
606 if (files[i].ends_with(".gde")) {
607 err = dce->decompile_byte_code_encrypted(files[i], key);
608 } else {
609 err = dce->decompile_byte_code(files[i]);
610 }
611
612 if (err == OK) {
613 String scr = dce->get_script_text();
614 Ref<FileAccess> file = FileAccess::open(target_name, FileAccess::WRITE, &err);
615 if (err) {
616 failed_files += files[i] + " (FileAccess error)\n";
617 }
618 file->store_string(scr);
619 } else {
620 failed_files += files[i] + " (" + dce->get_error_message() + ")\n";
621 }
622 }
623
624 pr.unref();
625 dce.unref();
626
627 if (failed_files.length() > 0) {
628 show_warning(failed_files, RTR("Decompile"), RTR("At least one error was detected!"));
629 } else {
630 show_warning(RTR("No errors detected."), RTR("Decompile"), RTR("The operation completed successfully!"));
631 }
632}
633
634/*************************************************************************/
635/* Compile */

Callers

nothing calls this directly

Calls 13

stepMethod · 0.80
decompile_byte_codeMethod · 0.80
get_script_textMethod · 0.80
lengthMethod · 0.80
EditorProgressGDDCClass · 0.50
get_file_listMethod · 0.45
get_keyMethod · 0.45
get_target_dirMethod · 0.45
get_bytecode_versionMethod · 0.45
sizeMethod · 0.45
get_fileMethod · 0.45

Tested by

no test coverage detected