Added coreinit and cut down one autoload singleton

This commit is contained in:
JeremyStar™ 2023-03-19 13:14:30 +01:00
parent 616afa9460
commit 0ff88791a6
6 changed files with 72 additions and 6 deletions

View file

@ -9,7 +9,7 @@ CORE is only useful for new projects. Already existing projects could break beca
# Requirements
- No autoload singletons are allowed before CORE has initialized
- Startup scene must be `res://CORE/background.tscn`
- Startup scene must be `res://CORE/coreinit.tscn`
- Scene management must be done with smgr (the CORE scene manager)
- Logging should be handled using the CORE logger
@ -19,10 +19,9 @@ CORE is only useful for new projects. Already existing projects could break beca
- Add three scripts to your autoload:
| Name | Path |
| ------------ | ---------------------------- |
| coreloader | `res://CORE/coreloader.gd` |
| Logger | `res://CORE/logger.gd` |
| Preprocessor | `res://CORE/preprocessor.gd` |
- Select `res://CORE/background.tscn` as your startup scene
- Select `res://CORE/coreinit.tscn` as your startup scene
- [Follow the post-installation guide](https://git.staropensource.de/StarOpenSource/core/wiki/Using-CORE)
# How to update

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://pqe5af0fmvvf"]
[ext_resource type="FontFile" uid="uid://ma5ix8lrywfr" path="res://CORE/hack.ttf" id="1_lr4q1"]
[ext_resource type="FontFile" uid="uid://cdfmc7wbwejab" path="res://CORE/hack.ttf" id="1_lr4q1"]
[ext_resource type="Script" path="res://CORE/corelog.gd" id="2_6qdog"]
[node name="COREBackground" type="Control"]

51
coreinit.gd Normal file
View file

@ -0,0 +1,51 @@
extends Node
@onready
var engine_version = Engine.get_version_info()
func _ready():
print("coreinit -> Checking CORE requirements")
if engine_version["major"] != 4:
print("coreinit -> CORE only supports Godot 4.x.x. 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:
print("coreinit -> CORE only supports Godot 4.0.x. Please upgrade/downgrade your Godot Project to Godot 4.0.")
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 Godot 4.0.stable.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(143)
return
if get_node_or_null(NodePath("/root/Logger")) == null:
print("coreinit -> The CORE logger is missing in your autoload project settings! Please retry installing CORE.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(144)
return
if get_node_or_null(NodePath("/root/Preprocessor")) == null:
print("coreinit -> The CORE preprocessor is missing in your autoload project settings! Please retry installing CORE.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(145)
return
if get_tree().root.get_children().size() != 3:
print("coreinit -> CORE only supports projects without autoload singletons (excluding CORE). Please remove them from your project settings and register them using core.autoloader in your init script.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(146)
return
for i in get_tree().root.get_children():
if i.name != "coreinit" and i.name != "Logger" and i.name != "Preprocessor":
print("coreinit -> CORE only supports projects without autoload singletons (excluding CORE). Please remove them from your project settings and register them using core.autoloader in your init script.")
await get_tree().create_timer(0.1).timeout
get_tree().quit(147)
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"))

16
coreinit.tscn Normal file
View file

@ -0,0 +1,16 @@
[gd_scene load_steps=2 format=3 uid="uid://bimimtdarnyu"]
[ext_resource type="Script" path="res://CORE/coreinit.gd" id="1_ubktt"]
[node name="coreinit" type="Control"]
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_ubktt")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 0
offset_left = -5e+08
offset_top = -5e+08
offset_right = 5e+08
offset_bottom = 5e+08
color = Color(0, 0, 0, 1)

View file

@ -53,4 +53,4 @@ func _ready() -> void:
Logger.info("coreloader","Adding project init script to /root/")
get_tree().root.add_child(initscr_obj)
Logger.info("coreloader","Removing coreloader")
coreloader.queue_free()
queue_free()

View file

@ -19,7 +19,7 @@ func _ready():
get_child(0,true).add_theme_stylebox_override("grabber_pressed",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("scroll",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("scroll_focus",StyleBoxEmpty.new())
get_child(0,true).size = Vector2i(0,0)
get_child(0,true).set_deferred("size",Vector2i(0,0))
get_child(0,true).mouse_filter = Control.MOUSE_FILTER_IGNORE
# Make RichTextLabel ignore all mouse events (to disable scrolling)
mouse_filter = Control.MOUSE_FILTER_IGNORE