1
1
extends Resource
2
- ## Stores and validates contents of the manifest set by the user
2
+ # Stores and validates contents of the manifest set by the user
3
3
class_name ModManifest
4
4
5
5
6
- ## Mod name.
7
- ## Validated by [method is_name_or_namespace_valid]
6
+ # Mod name.
7
+ # Validated by [method is_name_or_namespace_valid]
8
8
var name := ""
9
- ## Mod namespace, most commonly the main author.
10
- ## Validated by [method is_name_or_namespace_valid]
9
+ # Mod namespace, most commonly the main author.
10
+ # Validated by [method is_name_or_namespace_valid]
11
11
var namespace := ""
12
- ## Semantic version. Not a number, but required to be named like this by Thunderstore
13
- ## Validated by [method is_semver_valid]
12
+ # Semantic version. Not a number, but required to be named like this by Thunderstore
13
+ # Validated by [method is_semver_valid]
14
14
var version_number := "0.0.0"
15
15
var description := ""
16
16
var website_url := ""
17
- ## Used to determine mod load order
17
+ # Used to determine mod load order
18
18
var dependencies := [] # Array[String]
19
19
20
20
var authors := [] # Array[String]
21
- ## only used for information
21
+ # only used for information
22
22
var compatible_game_version := [] # Array[String]
23
- ## only used for information
23
+ # only used for information
24
24
var incompatibilities := [] # Array[String]
25
25
var tags := [] # Array[String]
26
26
var description_rich := ""
27
27
var image : StreamTexture
28
28
29
29
30
- ## Required keys in a mod's manifest.json file
30
+ # Required keys in a mod's manifest.json file
31
31
const REQUIRED_MANIFEST_KEYS_ROOT = [
32
32
"name" ,
33
33
"namespace" ,
@@ -38,7 +38,7 @@ const REQUIRED_MANIFEST_KEYS_ROOT = [
38
38
"extra" ,
39
39
]
40
40
41
- ## Required keys in manifest's `json.extra.godot`
41
+ # Required keys in manifest's `json.extra.godot`
42
42
const REQUIRED_MANIFEST_KEYS_EXTRA = [
43
43
"authors" ,
44
44
"compatible_mod_loader_version" ,
@@ -48,8 +48,8 @@ const REQUIRED_MANIFEST_KEYS_EXTRA = [
48
48
]
49
49
50
50
51
- ## Takes the manifest as [Dictionary] and validates everything.
52
- ## Will return null if something is invalid.
51
+ # Takes the manifest as [Dictionary] and validates everything.
52
+ # Will return null if something is invalid.
53
53
func _init (manifest : Dictionary ) -> void :
54
54
if (not dict_has_fields (manifest , REQUIRED_MANIFEST_KEYS_ROOT ) or
55
55
not dict_has_fields (manifest .extra , ["godot" ]) or
@@ -79,21 +79,21 @@ func _init(manifest: Dictionary) -> void:
79
79
# image StreamTexture
80
80
81
81
82
- ## Mod ID used in the mod loader
83
- ## Format: {namespace}-{name}
82
+ # Mod ID used in the mod loader
83
+ # Format: {namespace}-{name}
84
84
func get_mod_id () -> String :
85
85
return "%s -%s " % [namespace , name ]
86
86
87
87
88
- ## Package ID used by Thunderstore
89
- ## Format: {namespace}-{name}-{version_number}
88
+ # Package ID used by Thunderstore
89
+ # Format: {namespace}-{name}-{version_number}
90
90
func get_package_id () -> String :
91
91
return "%s -%s -%s " % [namespace , name , version_number ]
92
92
93
93
94
- ## A valid namespace may only use letters (any case), numbers and underscores
95
- ## and has to be longer than 3 characters
96
- ## /^[a-zA-Z0-9_]{3,}$/
94
+ # A valid namespace may only use letters (any case), numbers and underscores
95
+ # and has to be longer than 3 characters
96
+ # /^[a-zA-Z0-9_]{3,}$/
97
97
static func is_name_or_namespace_valid (name : String ) -> bool :
98
98
var re := RegEx .new ()
99
99
re .compile ("^[a-zA-Z0-9_]*$" ) # alphanumeric and _
@@ -110,9 +110,9 @@ static func is_name_or_namespace_valid(name: String) -> bool:
110
110
return true
111
111
112
112
113
- ## A valid semantic version should follow this format: {mayor}.{minor}.{patch}
114
- ## reference https://semver.org/ for details
115
- ## /^[0-9]+\\.[0-9]+\\.[0-9]+$/
113
+ # A valid semantic version should follow this format: {mayor}.{minor}.{patch}
114
+ # reference https://semver.org/ for details
115
+ # /^[0-9]+\\.[0-9]+\\.[0-9]+$/
116
116
static func is_semver_valid (version_number : String ) -> bool :
117
117
var re := RegEx .new ()
118
118
re .compile ("^[0-9]+\\ .[0-9]+\\ .[0-9]+$" )
@@ -125,22 +125,22 @@ static func is_semver_valid(version_number: String) -> bool:
125
125
return true
126
126
127
127
128
- ## Returns an empty String if the key does not exist
128
+ # Returns an empty String if the key does not exist
129
129
static func _get_string_from_dict (dict : Dictionary , key : String ) -> String :
130
130
if not dict .has (key ):
131
131
return ""
132
132
return dict [key ]
133
133
134
134
135
- ## Returns an empty Array if the key does not exist
135
+ # Returns an empty Array if the key does not exist
136
136
static func _get_array_from_dict (dict : Dictionary , key : String ) -> Array :
137
137
if not dict .has (key ):
138
138
return []
139
139
return dict [key ]
140
140
141
141
142
- ## Works like [method Dictionary.has_all],
143
- ## but allows for more specific errors if a field is missing
142
+ # Works like [method Dictionary.has_all],
143
+ # but allows for more specific errors if a field is missing
144
144
static func dict_has_fields (dict : Dictionary , required_fields : Array ) -> bool :
145
145
var missing_fields := required_fields
146
146
0 commit comments