2024-12-10 22:11:05 +01:00
|
|
|
## SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
## Copyright (c) 2024 interstellardevelopment.org
|
|
|
|
|
2024-12-03 12:52:14 +01:00
|
|
|
extends Node
|
|
|
|
|
2024-12-06 11:11:51 +01:00
|
|
|
var mutex: Mutex = Mutex.new()
|
2024-12-03 12:52:14 +01:00
|
|
|
|
|
|
|
# Used for errors.
|
|
|
|
func error(message: String, alert_message: String) -> void:
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.lock()
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
message = "Empty message string passed to an error message!"
|
2024-12-04 09:42:04 +01:00
|
|
|
if Game.logmode >= 1:
|
2024-12-03 12:52:14 +01:00
|
|
|
printerr("[ERROR] " + message)
|
|
|
|
OS.alert(alert_message, "Error!")
|
2024-12-03 21:44:07 +01:00
|
|
|
if OS.shell_open(OS.get_user_data_dir()) != OK:
|
|
|
|
Log.warning("Couldn't open file explorer!")
|
2024-12-03 12:52:14 +01:00
|
|
|
else:
|
2024-12-10 19:13:22 +01:00
|
|
|
OS.alert("An error has occurred. The program will now exit.", "Error!")
|
2024-12-03 12:52:14 +01:00
|
|
|
get_tree().quit()
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|
2024-12-03 12:52:14 +01:00
|
|
|
|
|
|
|
# Used for warnings.
|
|
|
|
func warning(message: String) -> void:
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.lock()
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
message = "Empty message string passed to a warning message!"
|
2024-12-04 09:42:04 +01:00
|
|
|
if Game.logmode >= 2:
|
2024-12-03 12:52:14 +01:00
|
|
|
printerr("[WARNING] " + message)
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|
2024-12-03 12:52:14 +01:00
|
|
|
|
|
|
|
# Used for simple info.
|
|
|
|
func info(message: String) -> void:
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.lock()
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
warning("Empty message string passed to an info message!")
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|
2024-12-03 21:44:07 +01:00
|
|
|
return
|
2024-12-04 09:42:04 +01:00
|
|
|
if Game.logmode >= 3:
|
2024-12-03 12:52:14 +01:00
|
|
|
print("[INFO] " + message)
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|
2024-12-03 12:52:14 +01:00
|
|
|
|
|
|
|
# Used for debugging.
|
|
|
|
func debug(message: String) -> void:
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.lock()
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
warning("Empty message string passed to a debug message!")
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|
2024-12-03 21:44:07 +01:00
|
|
|
return
|
2024-12-04 09:42:04 +01:00
|
|
|
if Game.logmode >= 4:
|
2024-12-03 12:52:14 +01:00
|
|
|
print("[DEBUG] " + message)
|
2024-12-06 11:11:51 +01:00
|
|
|
mutex.unlock()
|