summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/register_types.cpp64
-rw-r--r--modules/mono/editor/godotsharp_editor.cpp21
2 files changed, 71 insertions, 14 deletions
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index d99d04bdbe..9b55e99282 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -54,20 +54,74 @@ class EditorExportGDScript : public EditorExportPlugin {
public:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
- if (!p_path.ends_with(".gd"))
+ int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
+ String script_key;
+
+ const Ref<EditorExportPreset> &preset = get_export_preset();
+
+ if (preset.is_valid()) {
+ script_mode = preset->get_script_export_mode();
+ script_key = preset->get_script_encryption_key().to_lower();
+ }
+
+ if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT)
return;
Vector<uint8_t> file = FileAccess::get_file_as_array(p_path);
if (file.empty())
return;
+
String txt;
txt.parse_utf8((const char *)file.ptr(), file.size());
file = GDScriptTokenizerBuffer::parse_code_string(txt);
- if (file.empty())
- return;
-
- add_file(p_path.get_basename() + ".gdc", file, true);
+ if (!file.empty()) {
+
+ if (script_mode == EditorExportPreset::MODE_SCRIPT_ENCRYPTED) {
+
+ String tmp_path = EditorSettings::get_singleton()->get_settings_dir().plus_file("tmp/script.gde");
+ FileAccess *fa = FileAccess::open(tmp_path, FileAccess::WRITE);
+
+ Vector<uint8_t> key;
+ key.resize(32);
+ for (int i = 0; i < 32; i++) {
+ int v = 0;
+ if (i * 2 < script_key.length()) {
+ CharType ct = script_key[i * 2];
+ if (ct >= '0' && ct <= '9')
+ ct = ct - '0';
+ else if (ct >= 'a' && ct <= 'f')
+ ct = 10 + ct - 'a';
+ v |= ct << 4;
+ }
+
+ if (i * 2 + 1 < script_key.length()) {
+ CharType ct = script_key[i * 2 + 1];
+ if (ct >= '0' && ct <= '9')
+ ct = ct - '0';
+ else if (ct >= 'a' && ct <= 'f')
+ ct = 10 + ct - 'a';
+ v |= ct;
+ }
+ key.write[i] = v;
+ }
+ FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
+ Error err = fae->open_and_parse(fa, key, FileAccessEncrypted::MODE_WRITE_AES256);
+
+ if (err == OK) {
+ fae->store_buffer(file.ptr(), file.size());
+ }
+
+ memdelete(fae);
+
+ file = FileAccess::get_file_as_array(tmp_path);
+ add_file(p_path.get_basename() + ".gde", file, true);
+
+ } else {
+
+ add_file(p_path.get_basename() + ".gdc", file, true);
+ }
+ }
}
};
diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp
index 1aa3b2dd8b..cee4405826 100644
--- a/modules/mono/editor/godotsharp_editor.cpp
+++ b/modules/mono/editor/godotsharp_editor.cpp
@@ -248,16 +248,19 @@ Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int
static String vscode_path;
if (vscode_path.empty() || !FileAccess::exists(vscode_path)) {
+ static List<String> vscode_name;
+ vscode_name.push_back("code");
+ vscode_name.push_back("code-oss");
+ vscode_name.push_back("vscode");
+ vscode_name.push_back("vscode-oss");
+ vscode_name.push_back("visual-studio-code");
+ vscode_name.push_back("visual-studio-code-oss");
// Try to search it again if it wasn't found last time or if it was removed from its location
- vscode_path = path_which("code");
- }
- if (vscode_path.empty() || !FileAccess::exists(vscode_path)) {
- // On some Linux distro the executable has the name vscode
- vscode_path = path_which("vscode");
- }
- if (vscode_path.empty() || !FileAccess::exists(vscode_path)) {
- // Executable name when installing VSCode directly from MS on Linux
- vscode_path = path_which("visual-studio-code");
+ for (int i = 0; i < vscode_name.size(); i++) {
+ vscode_path = path_which(vscode_name[i]);
+ if (!vscode_path.empty() || FileAccess::exists(vscode_path))
+ break;
+ }
}
List<String> args;