2024-12-03 12:52:14 +01:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
# This tells the game what the logmode is.
|
|
|
|
# 0 -> None
|
|
|
|
# 1 -> Errors
|
|
|
|
# 2 -> Errors/Warnings
|
|
|
|
# 3 -> Errors/Warnings/Infos
|
|
|
|
# 4 -> All
|
|
|
|
var logmode: int = 4
|
|
|
|
|
2024-12-03 21:44:07 +01:00
|
|
|
func test() -> void:
|
2024-12-03 12:52:14 +01:00
|
|
|
debug("Test")
|
|
|
|
info("Test")
|
|
|
|
warning("Test")
|
|
|
|
|
|
|
|
# Used for errors.
|
|
|
|
func error(message: String, alert_message: String) -> void:
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
message = "Empty message string passed to an error message!"
|
2024-12-03 12:52:14 +01:00
|
|
|
if logmode >= 1:
|
|
|
|
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:
|
|
|
|
OS.alert("An error has occured. The program will now exit.", "Error!")
|
|
|
|
get_tree().quit()
|
|
|
|
|
|
|
|
# Used for warnings.
|
|
|
|
func warning(message: String) -> void:
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
message = "Empty message string passed to a warning message!"
|
2024-12-03 12:52:14 +01:00
|
|
|
if logmode >= 2:
|
|
|
|
printerr("[WARNING] " + message)
|
|
|
|
|
|
|
|
# Used for simple info.
|
|
|
|
func info(message: String) -> void:
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
warning("Empty message string passed to an info message!")
|
|
|
|
return
|
2024-12-03 12:52:14 +01:00
|
|
|
if logmode >= 3:
|
|
|
|
print("[INFO] " + message)
|
|
|
|
|
|
|
|
# Used for debugging.
|
|
|
|
func debug(message: String) -> void:
|
2024-12-03 21:44:07 +01:00
|
|
|
if message == "":
|
|
|
|
warning("Empty message string passed to a debug message!")
|
|
|
|
return
|
2024-12-03 12:52:14 +01:00
|
|
|
if logmode >= 4:
|
|
|
|
print("[DEBUG] " + message)
|