Skip to content

Commit f2d9954

Browse files
style: resolve type and style requests from #562 (#566)
* style: clean nit picks from #562 * bug: fix editor feature check doesn't error when ModLoaderStore isn't initialized * bug: remove usage of deleted function `is_version_below` * chore: simplify editor check in `_print_rich` * chore: commit KANAjetzt's suggestion Co-authored-by: KANAjetzt <41547570+KANAjetzt@users.noreply.github.com> --------- Co-authored-by: KANAjetzt <41547570+KANAjetzt@users.noreply.github.com>
1 parent 3389ab4 commit f2d9954

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

addons/mod_loader/api/log.gd

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ class ModLoaderLogEntry:
108108
## [param exclude_type] ([bool]): (Optional) If true, the log type (e.g., DEBUG, WARN) will be excluded from the prefix. Default is false.[br]
109109
## [br]
110110
## [b]Returns:[/b] [String]
111-
func get_prefix(exclude_type: bool = false) -> String:
111+
func get_prefix(exclude_type := false) -> String:
112112
return "%s%s: " % [
113-
"" if exclude_type else type.to_upper() + " ",
113+
"" if exclude_type else "%s " % type.to_upper(),
114114
mod_name
115115
]
116116

@@ -402,7 +402,7 @@ static func get_all_entries_as_string(log_entries: Array) -> Array:
402402
# Internal log functions
403403
# =============================================================================
404404

405-
static func _print_rich(prefix: String, message: String, color: Color, bold := true):
405+
static func _print_rich(prefix: String, message: String, color: Color, bold := true) -> void:
406406
if OS.has_feature("editor"):
407407
var prefix_text := "[b]%s[/b]" % prefix if bold else prefix
408408
print_rich("[color=%s]%s[/color]%s" % [
@@ -444,7 +444,7 @@ static func _log(message: String, mod_name: String, log_type: String = "info", o
444444
_write_to_log_file(JSON.stringify(get_stack(), " "))
445445
assert(false, message)
446446
"error":
447-
if OS.has_feature("editor"):
447+
if ModLoaderStore.has_feature.editor:
448448
printerr(log_entry.get_prefix(true) + message)
449449
else:
450450
printerr(log_entry.get_prefix() + message)
@@ -468,8 +468,11 @@ static func _log(message: String, mod_name: String, log_type: String = "info", o
468468
_print_rich(log_entry.get_prefix(), message, debug_color, debug_bold)
469469
_write_to_log_file(log_entry.get_entry())
470470
"hint":
471-
if OS.has_feature("editor") and verbosity >= VERBOSITY_LEVEL.DEBUG:
472-
_print_rich(log_entry.get_prefix(), message, hint_color)
471+
if (
472+
ModLoaderStore.has_feature.editor and
473+
verbosity >= VERBOSITY_LEVEL.DEBUG
474+
):
475+
_print_rich(log_entry.get_prefix(), message, hint_color)
473476

474477

475478
static func _is_mod_name_ignored(mod_name: String) -> bool:

addons/mod_loader/internal/file.gd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ static func file_exists_in_zip(zip_path: String, path: String) -> bool:
195195
if not reader:
196196
return false
197197

198-
if _ModLoaderGodot.is_version_below(_ModLoaderGodot.ENGINE_VERSION_HEX_4_2_0):
199-
return reader.get_files().has(path.trim_prefix("res://"))
200-
else:
201-
return reader.file_exists(path.trim_prefix("res://"))
198+
return reader.get_files().has(path.trim_prefix("res://"))
202199

203200

204201
static func get_mod_dir_name_in_zip(zip_path: String) -> String:

0 commit comments

Comments
 (0)