CORE/coreinit.gd

52 lines
2.1 KiB
GDScript3
Raw Normal View History

# coreinit.gd
# CORE Initializer
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends Node
@onready
var engine_version = Engine.get_version_info()
func _ready() -> void:
print("coreinit -> Checking CORE requirements")
if engine_version["major"] != 4:
print("coreinit -> CORE only supports Godot 4. Please upgrade/downgrade your Godot Project to Godot 4.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(141)
return
if engine_version["minor"] != 0 and engine_version["minor"] != 1:
print("coreinit -> CORE only supports Godot 4.0 and 4.1. Please upgrade/downgrade your Godot Project to Godot 4.0 or 4.1.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(142)
return
if engine_version["status"] != "stable":
print("coreinit -> CORE only supports stable Godot 4 releases. Please upgrade/downgrade your Godot Project to a stable version.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(143)
return
if get_node_or_null(NodePath("/root/Logger")) == null:
2023-07-07 18:48:06 +02:00
print("coreinit -> The CORE logger is missing in your autoload project settings!")
await get_tree().create_timer(0.1).timeout
get_tree().quit(144)
return
if get_node_or_null(NodePath("/root/Preprocessor")) == null:
2023-07-07 18:48:06 +02:00
print("coreinit -> The CORE preprocessor is missing in your autoload project settings!")
await get_tree().create_timer(0.1).timeout
get_tree().quit(145)
return
if !FileAccess.file_exists("res://CORE/config.gd"):
print("coreinit -> The CORE configuration file (config.gd) is missing! Please copy the config.gd.example file and rename it to config.gd!")
await get_tree().create_timer(0.1).timeout
get_tree().quit(146)
return
print("coreinit -> Constructing coreloader")
var coreloader = Control.new()
coreloader.name = "coreloader"
coreloader.set_script(ResourceLoader.load("res://CORE/coreloader.gd"))
print("coreinit -> Injecting coreloader")
get_tree().root.add_child.call_deferred(coreloader)
print("coreinit -> Switching to COREBackground")
get_tree().change_scene_to_packed(ResourceLoader.load("res://CORE/background.tscn"))