Skip to content

Commit e912619

Browse files
Qubus0KANAjetzt
authored andcommitted
🚧 refactor: move methods
1 parent cae54ae commit e912619

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

addons/mod_loader/_export_plugin/export_plugin.gd

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extends EditorExportPlugin
22

33
const REQUIRE_EXPLICIT_ADDITION := false
44
const METHOD_PREFIX := "vanilla_"
5-
const HASH_COLLISION_ERROR :="MODDING EXPORT ERROR: Hash collision between %s and %s. The collision can be resolved by renaming one of the methods or changing their scripts path."
5+
const HASH_COLLISION_ERROR := "MODDING EXPORT ERROR: Hash collision between %s and %s. The collision can be resolved by renaming one of the methods or changing their script's path."
66

77
static var regex_getter_setter: RegEx
88

@@ -14,9 +14,7 @@ func _get_name() -> String:
1414

1515

1616
func _export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int) -> void:
17-
hashmap.clear()
18-
regex_getter_setter = RegEx.new()
19-
regex_getter_setter.compile("(.*?[sg]et\\s*=\\s*)(\\w+)(\\g<1>)?(\\g<2>)?")
17+
process_begin()
2018

2119

2220
func _export_file(path: String, type: String, features: PackedStringArray) -> void:
@@ -26,6 +24,17 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
2624
if type != "GDScript":
2725
return
2826

27+
skip()
28+
add_file(path, process_script(path, type, features).to_utf8_buffer(), false)
29+
30+
31+
func process_begin() -> void:
32+
hashmap.clear()
33+
regex_getter_setter = RegEx.new()
34+
regex_getter_setter.compile("(.*?[sg]et\\s*=\\s*)(\\w+)(\\g<1>)?(\\g<2>)?")
35+
36+
37+
func process_script(path: String, type: String, features: PackedStringArray) -> String:
2938
var current_script := load(path) as GDScript
3039
var source_code := current_script.source_code
3140
var source_code_additions := ""
@@ -92,8 +101,8 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
92101
if source_code_additions != "":
93102
source_code = "%s\n%s\n%s" % [source_code,mod_loader_hooks_start_string, source_code_additions]
94103

95-
skip()
96-
add_file(path, source_code.to_utf8_buffer(), false)
104+
return source_code
105+
97106

98107

99108
static func get_function_arg_name_string(args: Array) -> String:

0 commit comments

Comments
 (0)